Difference between revisions of "BIRD Data Access Protocol"
(→Data Browsing at Décrypthon Data Center) |
(→PhP) |
||
(34 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
− | ==BIRD Data Access Protocol | + | ==BIRD Data Access Protocol for Data-Intensive Applications == |
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
===Simple Services-Bank ID=== | ===Simple Services-Bank ID=== | ||
Service : | Service : | ||
− | http:// | + | http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=<database>&accession=<ac or id>&field=<DE,OS..> &format=<fasta/flat> |
+ | |||
+ | Example 1: get dbsnp by ID | ||
+ | http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnp&accession=268 | ||
− | Example | + | Example 2: get dbsnp genotype by ID |
− | http:// | + | http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnpgt&accession=268 |
− | Example | + | Example 3: get dbsnp genotype population by ID |
− | http:// | + | http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnpgtpop&accession=1371 |
− | Example | + | Example 4: get dbsnp genotype individual by ID |
− | + | http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnpgtind&accession=867 | |
− | Example | + | Example 5: get RefSeq Protein |
− | http:// | + | http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=refseqp&accession=NP_001256133&format=fasta |
+ | |||
+ | Example 6: get Protein : | ||
+ | http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=uniprot&accession=Q23456 | ||
+ | |||
+ | Example 7: get PDB : | ||
+ | http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=pdb&accession=1XDS | ||
+ | |||
+ | Example 8: get Fasta : | ||
+ | http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=pdb&accession=1XDS&format=fasta | ||
+ | |||
+ | |||
+ | ===Data Selection by [[BIRDQL]] Query Engine Service=== | ||
+ | Data can also be selected with [[BIRDQL]] queries; Expert users can however modify queries by hand. Three query service are available: | ||
+ | |||
+ | # <source lang = bash>curl -F upload=@your_bird.ql 'http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql'</source> | ||
+ | # <source lang = bash>http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql&query=your_birdql</source> | ||
+ | #* Example: | ||
+ | #**<source lang = bash> http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql&query=ID * DB Uniprot--WH DE contains "histone"--LM 10--FD AC,DE--FM FLAT</source> | ||
+ | #**<source lang = bash>http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql&query=ID * DB Uniprot--WH DE contains "Helianthinin"--LM 10--FM FASTA</source> | ||
+ | #**<source lang = bash>http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql&query=ID * DB Uniprot--WH DE contains "Helianthinin"--LM 10--FM JSON</source> | ||
+ | # BIRD-QL Editor (in pres). | ||
+ | #*User can use this engine for intensive computation, download [birdql cmd]. | ||
+ | #*Till then you can test your queries on the star3-8 in the program /groupes/poch/dkieffer/test_tools/BirdClient/BirdConsole.sh ( or download [http://alnitak.u-strasbg.fr/~dkieffer/PublicDirectory/appli_java/BirdClient.tar.gz here]). | ||
− | |||
− | |||
===API JAVA - BIRDQL Client=== | ===API JAVA - BIRDQL Client=== | ||
Line 49: | Line 60: | ||
InterfactDB birddb = new InterfaceDB(“my-bird”) | InterfactDB birddb = new InterfaceDB(“my-bird”) | ||
// BIRD-QL | // BIRD-QL | ||
− | String birdql = ” ID * DB | + | String birdql = ” ID * DB MyBank |
--WH OS contains "Mus mus" | --WH OS contains "Mus mus" | ||
--WH OC contains "Eukaryota" & not "Metazoa" | --WH OC contains "Eukaryota" & not "Metazoa" | ||
Line 60: | Line 71: | ||
} | } | ||
+ | ====PhP & Java Connection to BIRD HTTP Post ==== | ||
+ | =====PhP===== | ||
+ | <?php | ||
+ | function executeBIRDQuery($params=array()) { | ||
+ | $data = http_build_query($params); | ||
+ | $targetWebserviceUrl = 'http://kbm.u-strasbg.fr:8080/birdsnp/bsearch'; | ||
+ | $options = array('http' => array( | ||
+ | 'user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9', // who am i | ||
+ | 'max_redirects' => 10, // stop after 10 redirects | ||
+ | 'timeout' => 60, // timeout on response | ||
+ | 'method' => 'POST', | ||
+ | 'header' => "Content-type: application/x-www-form-urlencoded\r\n" | ||
+ | ."Content-Length: " . strlen($data) . "\r\n", | ||
+ | 'content' => $data | ||
+ | )); | ||
+ | $context = stream_context_create($options); | ||
+ | return file_get_contents($targetWebserviceUrl, false, $context); | ||
+ | } | ||
+ | |||
+ | $bql = <<<EOT | ||
+ | ID * DB MYBANK | ||
+ | WH TEXT CONTAINS "polymerase" | ||
+ | LM 10 | ||
+ | FM FASTA | ||
+ | EOT; | ||
+ | |||
+ | echo executeBIRDQuery(array('service'=>'birdql','query'=>$bql)); | ||
+ | |||
+ | ?> | ||
− | ==== | + | =====Java===== |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | /** download httpclient from http://hc.apache.org/downloads.cgi**/ | |
+ | import org.apache.commons.httpclient.HttpClient; | ||
+ | import org.apache.commons.httpclient.methods.PostMethod; | ||
+ | //bird server | ||
+ | String url = "http://kbm.u-strasbg.fr:8080/birdsnp/bsearch"; | ||
+ | String mybioql="ID * DB MyBANK \n" + | ||
+ | "WH TEXT CONTAINS \"DMD\" \n"+ | ||
+ | "LM 100 \n"+ | ||
+ | "FM FASTA \n"; | ||
+ | PostMethod postMethod = new PostMethod(url); | ||
+ | client.setConnectionTimeout(300); | ||
+ | // post parameters: service="birdql" & query="...." | ||
+ | postMethod.addParameter("service","birdql"); | ||
+ | postMethod.addParameter("query",mybioql); | ||
+ | // running birdql query | ||
+ | int statusCode1 = client.executeMethod(postMethod); | ||
+ | // get results | ||
+ | String result= postMethod.getResponseBodyAsString(); | ||
+ | postMethod.releaseConnection(); | ||
====BirdHttpClient==== | ====BirdHttpClient==== | ||
− | A fonctional API to use Bird with Java by HTTP. Available by subversion in svn/dkieffer/BirdHTTPClient. | + | A fonctional API to use Bird with Java by HTTP. Available by subversion in svn/dkieffer/BirdHTTPClient. Or download beta version [http://alnitak.u-strasbg.fr/~dkieffer/Librairie/BirdHttpClient.zip here]. |
[[Category:Bird_project]] | [[Category:Bird_project]] |
Latest revision as of 10:17, 10 March 2014
Contents
BIRD Data Access Protocol for Data-Intensive Applications
Simple Services-Bank ID
Service : http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=<database>&accession=<ac or id>&field=<DE,OS..> &format=<fasta/flat>
Example 1: get dbsnp by ID
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnp&accession=268
Example 2: get dbsnp genotype by ID
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnpgt&accession=268
Example 3: get dbsnp genotype population by ID
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnpgtpop&accession=1371
Example 4: get dbsnp genotype individual by ID
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnpgtind&accession=867
Example 5: get RefSeq Protein
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=refseqp&accession=NP_001256133&format=fasta
Example 6: get Protein :
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=uniprot&accession=Q23456
Example 7: get PDB :
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=pdb&accession=1XDS
Example 8: get Fasta :
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=pdb&accession=1XDS&format=fasta
Data Selection by BIRDQL Query Engine Service
Data can also be selected with BIRDQL queries; Expert users can however modify queries by hand. Three query service are available:
-
curl -F upload=@your_bird.ql 'http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql'
-
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql&query=your_birdql
- Example:
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql&query=ID * DB Uniprot--WH DE contains "histone"--LM 10--FD AC,DE--FM FLAT
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql&query=ID * DB Uniprot--WH DE contains "Helianthinin"--LM 10--FM FASTA
http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql&query=ID * DB Uniprot--WH DE contains "Helianthinin"--LM 10--FM JSON
- Example:
- BIRD-QL Editor (in pres).
- User can use this engine for intensive computation, download [birdql cmd].
- Till then you can test your queries on the star3-8 in the program /groupes/poch/dkieffer/test_tools/BirdClient/BirdConsole.sh ( or download here).
API JAVA - BIRDQL Client
The API is an Interface of programming which defines the way in which a data-processing component can communicate with another. The API Java of BIRD contains useful reusable classes by external modules of access to the databases. It has functions (methods) returning the data selected under various formats. The user of high-level can use the API to develop new functionalities exploiting of the data. It can also be used to make personalized graphic interfaces and Web Services. The codes Java below illustrate the exploitation of BIRD API. BIRDQL Engine doesn’t return data but just OIDs of selected records. The content of the record must then be searched by the API.
API BIRD
Import org.igbmc.bird.* Class ExampleUtilisationAPI {
InterfactDB birddb = new InterfaceDB(“my-bird”) // BIRD-QL String birdql = ” ID * DB MyBank --WH OS contains "Mus mus" --WH OC contains "Eukaryota" & not "Metazoa" --FM OID” Vector OID=birddb.queryengine.run(birdql); For { i=1 to OID.size() } { // result treatment UniProt obj=(UniProt)birddb.getObject(OID[i]); …. }
PhP & Java Connection to BIRD HTTP Post
PhP
<?php function executeBIRDQuery($params=array()) { $data = http_build_query($params); $targetWebserviceUrl = 'http://kbm.u-strasbg.fr:8080/birdsnp/bsearch'; $options = array('http' => array( 'user_agent' => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9', // who am i 'max_redirects' => 10, // stop after 10 redirects 'timeout' => 60, // timeout on response 'method' => 'POST', 'header' => "Content-type: application/x-www-form-urlencoded\r\n" ."Content-Length: " . strlen($data) . "\r\n", 'content' => $data )); $context = stream_context_create($options); return file_get_contents($targetWebserviceUrl, false, $context); } $bql = <<<EOT ID * DB MYBANK WH TEXT CONTAINS "polymerase" LM 10 FM FASTA EOT; echo executeBIRDQuery(array('service'=>'birdql','query'=>$bql)); ?>
Java
/** download httpclient from http://hc.apache.org/downloads.cgi**/ import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.methods.PostMethod; //bird server String url = "http://kbm.u-strasbg.fr:8080/birdsnp/bsearch"; String mybioql="ID * DB MyBANK \n" + "WH TEXT CONTAINS \"DMD\" \n"+ "LM 100 \n"+ "FM FASTA \n"; PostMethod postMethod = new PostMethod(url); client.setConnectionTimeout(300); // post parameters: service="birdql" & query="...." postMethod.addParameter("service","birdql"); postMethod.addParameter("query",mybioql); // running birdql query int statusCode1 = client.executeMethod(postMethod); // get results String result= postMethod.getResponseBodyAsString(); postMethod.releaseConnection();
BirdHttpClient
A fonctional API to use Bird with Java by HTTP. Available by subversion in svn/dkieffer/BirdHTTPClient. Or download beta version here.