Mercurial > repos > cheanney > db2db
comparison db2dbRestClient.php @ 2:ae43e2d7f68a draft
Uploaded
author | cheanney |
---|---|
date | Tue, 07 Jul 2015 13:01:27 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:6c2176813df3 | 2:ae43e2d7f68a |
---|---|
1 {\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720 | |
2 {\fonttbl\f0\fnil\fcharset0 Monaco;} | |
3 {\colortbl;\red255\green255\blue255;\red255\green0\blue0;\red85\green127\blue95;\red0\green0\blue192; | |
4 \red127\green0\blue85;} | |
5 \margl1440\margr1440\vieww21520\viewh8280\viewkind0 | |
6 \deftab720 | |
7 \pard\pardeftab720 | |
8 | |
9 \f0\fs22 \cf2 <?php\cf0 \ | |
10 \pard\pardeftab720 | |
11 \cf3 //$client = new SoapClient("http://biodbnet.abcc.ncifcrf.gov/webServices/bioDBnet.wsdl");\cf0 \ | |
12 \cf3 /*\cf0 \ | |
13 \cf3 $input = 'Ensembl Gene ID';\cf0 \ | |
14 \cf3 $inputValues = 'ENSG00000121410, ENSG00000171428';\cf0 \ | |
15 \cf3 $outputs = 'Gene Symbol, Ensembl Protein ID';\cf0 \ | |
16 \cf3 $taxonId = '9606';\cf0 \ | |
17 \cf3 $methods = array(\cf0 \ | |
18 \cf3 'getInputs',\cf0 \ | |
19 \cf3 'getOutputsForInput',XML: http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=getoutputsforinput&input=genesymbol\cf0 \ | |
20 \cf3 'getDirectOutputsForInput',http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=getdirectoutputsforinput&input=genesymbol&directOutput=1\cf0 \ | |
21 \cf3 'getPathways', http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=getpathways&pathways=ncipid,kegg&taxonId=9606\cf0 \ | |
22 \cf3 'db2db',http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=db2db&input=geneid&inputValues=1,3&outputs=genesymbol,affyid&taxonId=9606&format=row\cf0 \ | |
23 \cf3 'dbReport',http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=dbreport&input=geneid&inputValues=1,3&taxonId=9606&format=row\cf0 \ | |
24 \cf3 'dbWalk',http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=dbwalk&inputValues=A1BG,MYC&dbPath=genesymbol-%3Egeneid-%3Eaffyid&taxonId=9606&format=row\cf0 \ | |
25 \cf3 'dbFind',http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=dbfind&inputValues=A1BG,MYC,1,3&output=geneid&taxonId=9606&format=row\cf0 \ | |
26 \cf3 'dbOrtho',http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=dbortho&input=geneid&inputValues=1,3&inputTaxon=9606&outputTaxon=10090&output=genesymbol&format=row\cf0 \ | |
27 \cf3 'dbAnnot'http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=dbannot&inputValues=1,MYC,MTOR_HUMAN&taxonId=9606&annotations=Genes,Pathways&format=row\cf0 \ | |
28 \cf3 )\cf0 \ | |
29 \cf3 */\cf0 \ | |
30 \ | |
31 $taxonId = \cf4 ""\cf0 ;\ | |
32 \ | |
33 \ | |
34 \cf3 //format='row' input='ensemblgeneid' inputValues='ENSG00000121410' outputs='genesymbol' taxonId='9606'\cf0 \ | |
35 \cf3 //&format=row&input=genesymbol&inputValues=MYC,MTOR&outputs=geneid,affyid&taxonId=9606";\cf0 \ | |
36 \cf3 //$biodbnetRestApiCall = "http://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.json?method=getinputs";\cf0 \ | |
37 \ | |
38 \ | |
39 \cf3 //print_r($argv);\cf0 \ | |
40 \ | |
41 $biodbnetRestApiCall = \cf4 ''\cf0 ;\ | |
42 \pard\pardeftab720 | |
43 \cf5 foreach \cf0 ($argv \cf5 as \cf0 $val)\ | |
44 \{\ | |
45 $arr = preg_split(\cf4 "/=/"\cf0 , $val);\ | |
46 \cf5 if \cf0 (strcmp(\cf4 'input'\cf0 , $arr[0]) == 0)\ | |
47 \{\ | |
48 $input = $arr[1];\ | |
49 $biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&input=" \cf0 . $input;\ | |
50 \}\ | |
51 \cf5 else if \cf0 (strcmp(\cf4 'taxonId'\cf0 , $arr[0]) == 0)\ | |
52 \{\ | |
53 $taxonId = $arr[1];\ | |
54 $biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&taxonId=" \cf0 . $taxonId;\ | |
55 \}\ | |
56 \cf5 else if \cf0 (strcmp(\cf4 'inputValues'\cf0 , $arr[0]) == 0)\ | |
57 \{\ | |
58 $inputValues = $arr[1];\ | |
59 $biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&inputValues=" \cf0 . $inputValues;\ | |
60 \}\ | |
61 \cf5 else if \cf0 (strcmp(\cf4 'outputs'\cf0 , $arr[0]) == 0)\ | |
62 \{\ | |
63 $outputs = $arr[1];\ | |
64 $biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&outputs=" \cf0 . $outputs;\ | |
65 \}\ | |
66 \cf5 else if \cf0 (strcmp(\cf4 'fileType'\cf0 , $arr[0]) == 0)\ | |
67 \{\ | |
68 $fileType = strtolower($arr[1]);\ | |
69 \cf5 if \cf0 ($fileType == \cf4 'xml'\cf0 )\{\ | |
70 $biodbnetRestApiCallCore = \cf4 "http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.xml?method=db2db"\cf0 ;\ | |
71 \}\ | |
72 \cf5 else\cf0 \{\ | |
73 $biodbnetRestApiCallCore = \cf4 "http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.json?method=db2db"\cf0 ;\ | |
74 \}\ | |
75 \cf5 if \cf0 ($fileType == \cf4 'table'\cf0 )\{\ | |
76 $biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&format=row"\cf0 ;\ | |
77 \}\ | |
78 \}\ | |
79 \}\ | |
80 $restApiCall = $biodbnetRestApiCallCore . $biodbnetRestApiCall;\ | |
81 $response = file_get_contents($restApiCall);\ | |
82 \cf5 if \cf0 ($fileType == \cf4 'xml' \cf0 || $fileType == \cf4 'json'\cf0 )\{\ | |
83 print_r($response);\ | |
84 \}\cf5 elseif \cf0 ($fileType == \cf4 'table'\cf0 )\{\ | |
85 \ | |
86 $formattedResponse = json_decode($response, \cf5 true\cf0 );\ | |
87 \cf3 //print_r($formattedResponse);\cf0 \ | |
88 \ | |
89 \cf5 echo \cf4 "<html>\\n"\cf0 ;\ | |
90 \cf5 echo \cf4 "<br/><br/><b>bioDBnet: db2db results</b><br/>"\cf0 ;\ | |
91 \cf5 echo \cf4 "<table border=1>\\n"\cf0 ;\ | |
92 $colNames = array_keys($formattedResponse[0]);\ | |
93 \cf5 echo \cf4 "<tr>"\cf0 ;\ | |
94 \cf5 foreach \cf0 ($colNames \cf5 as \cf0 $col)\ | |
95 \{\ | |
96 \cf5 if \cf0 ($col == \cf4 'InputValue'\cf0 )\ | |
97 $col = $input;\ | |
98 \cf5 echo \cf4 "<th>\cf0 $col\cf4 </th>"\cf0 ;\ | |
99 \}\ | |
100 \cf5 echo \cf4 "</tr>\\n"\cf0 ;\ | |
101 \cf5 foreach \cf0 ($formattedResponse \cf5 as \cf0 $row)\ | |
102 \{\ | |
103 \cf5 echo \cf4 "<tr>"\cf0 ;\ | |
104 \cf5 foreach \cf0 ($row \cf5 as \cf0 $key => $col)\ | |
105 \{\ | |
106 \cf5 echo \cf4 "<td>\cf0 $col\cf4 </td>"\cf0 ;\ | |
107 \}\ | |
108 \cf5 echo \cf4 "</tr>\\n"\cf0 ;\ | |
109 \}\ | |
110 \ | |
111 \cf5 echo \cf4 "</table>\\n"\cf0 ;\ | |
112 \cf5 echo \cf4 "</html>\\n"\cf0 ;\ | |
113 \}\ | |
114 \ | |
115 \ | |
116 \pard\pardeftab720 | |
117 \cf2 ?>} |