diff db2dbRestClient.php @ 2:ae43e2d7f68a draft

Uploaded
author cheanney
date Tue, 07 Jul 2015 13:01:27 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/db2dbRestClient.php	Tue Jul 07 13:01:27 2015 -0400
@@ -0,0 +1,117 @@
+{\rtf1\ansi\ansicpg1252\cocoartf1344\cocoasubrtf720
+{\fonttbl\f0\fnil\fcharset0 Monaco;}
+{\colortbl;\red255\green255\blue255;\red255\green0\blue0;\red85\green127\blue95;\red0\green0\blue192;
+\red127\green0\blue85;}
+\margl1440\margr1440\vieww21520\viewh8280\viewkind0
+\deftab720
+\pard\pardeftab720
+
+\f0\fs22 \cf2 <?php\cf0 \
+\pard\pardeftab720
+\cf3 //$client = new SoapClient("http://biodbnet.abcc.ncifcrf.gov/webServices/bioDBnet.wsdl");\cf0 \
+\cf3 /*\cf0 \
+\cf3 $input = 'Ensembl Gene ID';\cf0 \
+\cf3 $inputValues = 'ENSG00000121410, ENSG00000171428';\cf0 \
+\cf3 $outputs = 'Gene Symbol, Ensembl Protein ID';\cf0 \
+\cf3 $taxonId = '9606';\cf0 \
+\cf3 $methods = array(\cf0 \
+\cf3 			'getInputs',\cf0 \
+\cf3 			'getOutputsForInput',XML: http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=getoutputsforinput&input=genesymbol\cf0 \
+\cf3 			'getDirectOutputsForInput',http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=getdirectoutputsforinput&input=genesymbol&directOutput=1\cf0 \
+\cf3 			'getPathways', http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi?method=getpathways&pathways=ncipid,kegg&taxonId=9606\cf0 \
+\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 \
+\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 \
+\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 \
+\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 \
+\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 \
+\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 \
+\cf3 			)\cf0 \
+\cf3 */\cf0 \
+\
+$taxonId = \cf4 ""\cf0 ;\
+\
+\
+\cf3 //format='row' input='ensemblgeneid' inputValues='ENSG00000121410' outputs='genesymbol' taxonId='9606'\cf0 \
+\cf3 //&format=row&input=genesymbol&inputValues=MYC,MTOR&outputs=geneid,affyid&taxonId=9606";\cf0 \
+\cf3 //$biodbnetRestApiCall = "http://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.json?method=getinputs";\cf0 \
+\
+\
+\cf3 //print_r($argv);\cf0 \
+\
+$biodbnetRestApiCall = \cf4 ''\cf0 ;\
+\pard\pardeftab720
+\cf5 foreach \cf0 ($argv \cf5 as \cf0 $val)\
+\{\
+	$arr = preg_split(\cf4 "/=/"\cf0 , $val);\
+	\cf5 if \cf0 (strcmp(\cf4 'input'\cf0 , $arr[0]) == 0)\
+	\{\
+		$input = $arr[1];\
+		$biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&input=" \cf0 . $input;\
+	\}\
+	\cf5 else if \cf0 (strcmp(\cf4 'taxonId'\cf0 , $arr[0]) == 0)\
+	\{\
+		$taxonId = $arr[1];\
+		$biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&taxonId=" \cf0 . $taxonId;\
+	\}\
+	\cf5 else if \cf0 (strcmp(\cf4 'inputValues'\cf0 , $arr[0]) == 0)\
+	\{\
+		$inputValues = $arr[1];\
+		$biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&inputValues=" \cf0 . $inputValues;\
+	\}\
+	\cf5 else if \cf0 (strcmp(\cf4 'outputs'\cf0 , $arr[0]) == 0)\
+	\{\
+		$outputs = $arr[1];\
+		$biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&outputs=" \cf0 . $outputs;\
+	\}\
+	\cf5 else if \cf0 (strcmp(\cf4 'fileType'\cf0 , $arr[0]) == 0)\
+	\{\
+		$fileType = strtolower($arr[1]);\
+		\cf5 if \cf0 ($fileType == \cf4 'xml'\cf0 )\{\
+			$biodbnetRestApiCallCore = \cf4 "http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.xml?method=db2db"\cf0 ;\
+		\}\
+		\cf5 else\cf0 \{\
+			$biodbnetRestApiCallCore = \cf4 "http://fr-s-bsg-bdb-0.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.json?method=db2db"\cf0 ;\
+		\}\
+		\cf5 if \cf0 ($fileType == \cf4 'table'\cf0 )\{\
+			$biodbnetRestApiCall = $biodbnetRestApiCall . \cf4 "&format=row"\cf0 ;\
+		\}\
+	\}\
+\}\
+$restApiCall =  $biodbnetRestApiCallCore . $biodbnetRestApiCall;\
+$response = file_get_contents($restApiCall);\
+\cf5 if \cf0 ($fileType == \cf4 'xml' \cf0 || $fileType == \cf4 'json'\cf0 )\{\
+	print_r($response);\
+\}\cf5 elseif \cf0 ($fileType == \cf4 'table'\cf0 )\{\
+	\
+	$formattedResponse = json_decode($response, \cf5 true\cf0 );\
+	\cf3 //print_r($formattedResponse);\cf0 \
+	\
+	\cf5 echo \cf4 "<html>\\n"\cf0 ;\
+	\cf5 echo \cf4 "<br/><br/><b>bioDBnet: db2db results</b><br/>"\cf0 ;\
+	\cf5 echo \cf4 "<table border=1>\\n"\cf0 ;\
+	$colNames = array_keys($formattedResponse[0]);\
+	\cf5 echo \cf4 "<tr>"\cf0 ;\
+	\cf5 foreach \cf0 ($colNames \cf5 as \cf0 $col)\
+	\{\
+		\cf5 if \cf0 ($col == \cf4 'InputValue'\cf0 )\
+			$col = $input;\
+		\cf5 echo \cf4 "<th>\cf0 $col\cf4 </th>"\cf0 ;\
+	\}\
+	\cf5 echo \cf4 "</tr>\\n"\cf0 ;\
+	\cf5 foreach \cf0 ($formattedResponse \cf5 as \cf0 $row)\
+	\{\
+		\cf5 echo \cf4 "<tr>"\cf0 ;\
+		\cf5 foreach \cf0 ($row \cf5 as \cf0 $key => $col)\
+		\{\
+			\cf5 echo \cf4 "<td>\cf0 $col\cf4 </td>"\cf0 ;\
+		\}\
+		\cf5 echo \cf4 "</tr>\\n"\cf0 ;\
+	\}\
+	\
+	\cf5 echo \cf4 "</table>\\n"\cf0 ;\
+	\cf5 echo \cf4 "</html>\\n"\cf0 ;\
+\}\
+\
+\
+\pard\pardeftab720
+\cf2 ?>}
\ No newline at end of file