-
Notifications
You must be signed in to change notification settings - Fork 5
/
import_hapmap_ns_json.php
executable file
·54 lines (45 loc) · 1.19 KB
/
import_hapmap_ns_json.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
#!/usr/bin/php
<?php
;
// Copyright: see COPYING
// Authors: see git-blame(1)
if ($_SERVER["argc"] != 2)
{
die ("Usage: ".$_SERVER["argv"][0]." ns.json\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 "Inserting/replacing rows in allele_frequency...";
$json = file_get_contents ($_SERVER["argv"][1]);
$json = "[" . ereg_replace ("}\n{", "},\n{", $json) . "]";
$in = json_decode ($json);
$done = 0;
foreach ($in as $row) {
if (!sizeof($row->taf))
continue;
if (isset($row->taf->all_n) &&
$row->taf->all_d > 0 &&
$row->taf->all_d >= $row->taf->all_n) {
theDb()->query ("REPLACE INTO allele_frequency
(chr, chr_pos, allele, dbtag, num, denom)
VALUES (?, ?, ?, ?, ?, ?)",
array ($row->chromosome,
$row->coordinates,
$row->trait_allele,
'HapMap',
$row->taf->all_n,
$row->taf->all_d));
$done += theDb()->affectedRows();
print ".";
}
}
print "$done\n";
?>