diff dbAnnotRestClient.php @ 0:8129ff2290dd draft

Uploaded
author cheanney
date Thu, 16 Jul 2015 09:17:00 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dbAnnotRestClient.php	Thu Jul 16 09:17:00 2015 -0400
@@ -0,0 +1,57 @@
+<?php
+$restApiCall = "";
+$restParams = "";
+
+foreach ($argv as $val)
+{
+	$arr = preg_split("/=/", $val);
+	if (strcmp('inputValues', $arr[0]) == 0){
+		$inputvalues = $arr[1];
+		$restParams = $restParams . "&inputValues=$inputvalues";
+	}
+	if (strcmp('annotations', $arr[0]) == 0){
+		$annotations = $arr[1];
+		$restParams = $restParams . "&annotations=$annotations";
+	}
+	if (strcmp('TaxonId', $arr[0]) == 0){
+		$taxonid = $arr[1];
+		$restParams = $restParams . "&taxonId=$taxonid";
+	}
+	else if (strcmp('fileType', $arr[0]) == 0){
+		$fileType = $arr[1];
+		if ($fileType == 'xml'){
+			$biodbnetRestApiCallCore = "http://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.xml?method=dbannot&format=row";
+		}
+		else{
+			$biodbnetRestApiCallCore = "http://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.json?method=dbannot&format=row";
+		}
+	}
+}
+
+$restApiCall = $biodbnetRestApiCallCore . $restParams;
+$response = file_get_contents($restApiCall);
+
+if ($fileType == 'xml' || $fileType == 'json'){
+	print_r($response);
+}elseif ($fileType == 'table'){
+	$formattedResponse = json_decode($response, true);
+	echo "<html>\n";
+	echo "<br/><br/><b>bioDBnet: dbAnnot Result</b><br/>";
+	echo "<table border=1>\n";
+	$fields = array_keys($formattedResponse[0]);
+	echo "<tr>";
+	foreach ($fields as $f){
+		echo "<th>$f</th>";
+	}
+	echo "</tr>\n";
+	foreach ($formattedResponse as $key => $value){
+		echo "<tr>";
+		foreach ($value as $v){
+			echo "<td>$v</td>";
+		}
+		echo "</tr>\n";
+	}
+	echo "</table>\n";
+	echo "</html>\n";
+}
+?>
\ No newline at end of file