forked from tomclegg/get-evidence
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimport_yahoo_search.php
executable file
·85 lines (69 loc) · 2.03 KB
/
import_yahoo_search.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/php
<?php
;
// Copyright: see COPYING
// Authors: see git-blame(1)
if (!getenv ("APIKEY"))
die ("Please set environment variable APIKEY to your Yahoo BOSS API key.\n");
chdir ('public_html');
require_once 'lib/setup.php';
require_once 'lib/openid.php';
require_once 'lib/yahoo_boss.php';
ini_set ("output_buffering", FALSE);
ini_set ("memory_limit", 67108864);
print "Creating/updating yahoo_boss tables...";
evidence_create_tables ();
print "\n";
openid_login_as_robot ("Yahoo! Search Robot");
if (in_array ("--update-all", $_SERVER["argv"])) {
print "Updating variant_external for existing searches...";
$q = theDb()->query ("SELECT DISTINCT variant_id FROM yahoo_boss_cache");
if ($q && !theDb()->isError ($q)) {
$n=0;
while ($row =& $q->fetchRow()) {
yahoo_boss_update_external ($row["variant_id"]);
++$n;
if ($n % 10 == 0) print ".";
}
print "$n";
}
else
print "(none)";
print "\n";
}
print "Building queue...";
$q = theDb()->query ("CREATE TEMPORARY TABLE yahoo_boss_queue (
variant_id BIGINT UNSIGNED NOT NULL
) AS
SELECT v.variant_id
FROM variants v
LEFT JOIN gene_disease
ON gene=v.variant_gene
LEFT JOIN flat_summary
ON v.variant_id=flat_summary.variant_id AND n_genomes=1
LEFT JOIN yahoo_boss_cache c
ON c.variant_id=v.variant_id
WHERE (gene IS NOT NULL OR flat_summary.variant_id IS NOT NULL)
AND c.xml IS NULL
GROUP BY v.variant_id");
if (theDb()->isError($q)) die($q->getMessage());
print theDb()->affectedRows();
print "\n";
$q = theDb()->query ("SELECT q.variant_id variant_id, v.*
FROM yahoo_boss_queue q
LEFT JOIN variants v
ON v.variant_id=q.variant_id");
while ($row =& $q->fetchRow()) {
$r = yahoo_boss_lookup ($row["variant_id"]);
if (!$r) {
print "Lookup failed; stopping.";
exit;
}
yahoo_boss_update_external ($row["variant_id"]);
printf ("%8d %s %s%d%s (%d)\n",
$r["hitcount"],
$row["variant_gene"], $row["variant_aa_from"], $row["variant_aa_pos"], $row["variant_aa_to"],
$row["variant_id"]);
sleep (1);
}
?>