forked from tomclegg/get-evidence
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimport_variant_locations.php
executable file
·60 lines (47 loc) · 1.36 KB
/
import_variant_locations.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
#!/usr/bin/php
<?php
;
// Copyright: see COPYING
// Authors: see git-blame(1)
if ($_SERVER["argc"] != 2)
{
die ("Usage: ".$_SERVER["argv"][0]." variant_locations.tsv\n");
}
chdir ('public_html');
require_once 'lib/setup.php';
require_once 'lib/genomes.php';
require_once 'lib/openid.php';
require_once 'lib/bp.php';
ini_set ("output_buffering", FALSE);
ini_set ("memory_limit", 67108864);
print "Creating/updating get-evidence tables...";
evidence_create_tables ();
print "\n";
print "Creating temporary table...";
$q = theDb()->query ("CREATE TEMPORARY TABLE var_loc (
chr CHAR(6) NOT NULL,
chr_pos INT UNSIGNED NOT NULL,
allele CHAR(1) NOT NULL,
rsid BIGINT UNSIGNED,
gene_aa VARCHAR(32) NOT NULL,
INDEX (chr,chr_pos,allele)
)");
if (theDb()->isError($q)) die ($q->getMessage());
print "\n";
print "Importing data...";
$q = theDb()->query ("LOAD DATA LOCAL INFILE ? INTO TABLE var_loc
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'",
array ($_SERVER["argv"][1]));
if (theDb()->isError($q)) die ($q->getMessage());
print theDb()->affectedRows();
print "\n";
print "Copying to variant_locations...";
$q = theDb()->query ("INSERT IGNORE INTO variant_locations
(chr, chr_pos, allele, rsid, gene_aa)
SELECT chr, chr_pos, allele, rsid, gene_aa
FROM var_loc");
if (theDb()->isError($q)) die ($q->getMessage());
print theDb()->affectedRows();
print "\n";
?>