forked from tomclegg/get-evidence
-
Notifications
You must be signed in to change notification settings - Fork 1
/
import_polyphen2.php
executable file
·66 lines (52 loc) · 1.95 KB
/
import_polyphen2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/php
<?php
;
// Copyright: see COPYING
// Authors: see git-blame(1)
if ($_SERVER["argc"] != 2)
{
die ("Usage: ".$_SERVER["argv"][0]." pph2_getev_scores.tsv [tag]\n");
}
$rundir = getcwd();
chdir ('public_html');
require_once 'lib/setup.php';
chdir ($rundir);
print "Creating/updating get-evidence tables...";
evidence_create_tables ();
print "\n";
theDb()->query ("CREATE TEMPORARY TABLE import_pph2 (
variant_name VARCHAR(32) NOT NULL,
variant_id BIGINT UNSIGNED NOT NULL PRIMARY KEY,
polyphen2_score FLOAT
)");
print "Importing {$_SERVER['argv'][1]} ... ";
$q = theDb()->query ("LOAD DATA LOCAL INFILE ?
INTO TABLE import_pph2
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'",
array ($_SERVER["argv"][1]));
if (theDb()->isError($q)) print $q->getMessage();
print theDb()->affectedRows();
print "\n";
print "Attaching annotations for score ranges ... ";
theDb()->query ("ALTER TABLE import_pph2 ADD annotation VARCHAR(64)");
theDb()->query ("UPDATE import_pph2 SET annotation=' (benign)'");
print theDb()->affectedRows() . " total, ";
theDb()->query ("UPDATE import_pph2 SET annotation=' (possibly damaging)' where polyphen2_score >= 0.2");
print theDb()->affectedRows() . " >= 0.2, ";
theDb()->query ("UPDATE import_pph2 SET annotation=' (probably damaging)' where polyphen2_score >= 0.85");
print theDb()->affectedRows() . " >= 0.85\n";
print "Copying data into variant_external ...";
theDb()->query ("LOCK TABLES variant_external WRITE");
theDb()->query ("DELETE FROM variant_external WHERE tag='PolyPhen-2'");
$q = theDb()->query ("REPLACE INTO variant_external
(variant_id, tag, content, updated)
SELECT variant_id, ?, concat('Score: ',if(polyphen2_score=1,'1.0',polyphen2_score),annotation), now()
FROM import_pph2",
array ('PolyPhen-2'));
if (theDb()->isError($q)) print $q->getMessage();
print theDb()->affectedRows();
print "\n";
theDb()->query ("UNLOCK TABLES");
theDb()->query ("DROP TEMPORARY TABLE import_pph2");
?>