Sample code in different languagues is provided. If you would like to share your code with other bioDBnet users, please
contact us.
PHP: Convert JSON results from bioDBnet's db2db call to a PHP array
$biodbnetRestApiCall = "https://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.json?method=db2db&format=row&input=genesymbol&inputValues=MYC,MTOR&outputs=geneid,affyid&taxonId=9606";
$response = file_get_contents($biodbnetRestApiCall);
$formattedResponse = json_decode($response, true);
Python: Call to get XML formatted results from bioDBnet's db2db
import urllib
url = 'https://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.xml?method=db2db&format=row&input=genesymbol&inputValues=MYC,MTOR&outputs=geneid,affyid&taxonId=9606'
u = urllib.urlopen(url)
response = u.read()
Java: Call to get JSON results as a Java String object from bioDBnet's db2db. (http://rest.elkstein.org/2008/02/using-rest-in-java.html)
import java.net.*;
import java.io.*;
public class RestCalls {
public static void main(String[] args) throws Exception {
String urlStr = "https://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.json?method=db2db&format=row&input=genesymbol&inputValues=MYC,MTOR&outputs=geneid,affyid&taxonId=9606";
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = rd.readLine()) != null) {
sb.append(line);
}
rd.close();
conn.disconnect();
System.out.println(sb.toString());
}
}
R: Sample code using the RCurl library.
library('RCurl')
response = getURL("https://biodbnet.abcc.ncifcrf.gov/webServices/rest.php/biodbnetRestApi.json?method=db2db&format=row&input=genesymbol&inputValues=MYC,MTOR&outputs=geneid,affyid&taxonId=9606")
cat(response)