-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphp_ubi.php
88 lines (36 loc) · 1.26 KB
/
php_ubi.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
86
87
88
#!/usr/bin/php
<?php
if (ob_get_level() == 0) ob_start();
foreach(file('input.txt') as $line) {
echo "working on query: ". $line."<br>";
downloadData(trim($line));
ob_flush();
flush();
sleep(10);
}
ob_end_flush();
function downloadData($qry){
$url1 = "http://ubibrowser.ncpsb.org/strict/networkview/networkview/name/".$qry;
// Initiate curl
$ch = curl_init();
// Disable SSL verification
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
// Will return the response, if false it print the response
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Set the url
curl_setopt($ch, CURLOPT_URL,$url1);
// Execute
$result=curl_exec($ch);
// Closing
curl_close($ch);
preg_match('#window.allData = (.*?);\s*$#m', $result, $matches);
$final = trim($matches[0]);
$final = str_replace("window.allData =", "", $final);
$final = substr($final, 0, -1);
$arr = json_decode($final, true);
$str = "E3,E3GENE,SUB,SUBGENE,HOMO,PFAM,GO,NET,MOTIF,SCORE\n";
foreach ($arr as $key => $value) {
$str .= $value["E3"].",".$value["E3GENE"].",".$value["SUB"].",".$value["SUBGENE"].",".$value["HOMO"].",".$value["PFAM"].",".$value["GO"].",".$value["NET"].",".$value["MOTIF"].",".$value["SCORE"]."\n";
}
file_put_contents("file-".$qry.".csv", $str);
}