Difference between revisions of "BIRD Data Access Protocol"

From Wikili
Jump to: navigation, search
(Data Browsing at Décrypthon Data Center)
(PhP)
 
(27 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==BIRD Data Access Protocol==
+
==BIRD Data Access Protocol for Data-Intensive Applications ==  
===Data Browsing at Décrypthon Data Center===
+
 
Database content can be browsed from Bird Website [http://decrypthon.u-strasbg.fr/birdweb/] (beta version)
 
Node ENS-Lyon: [http://decrypthon-1.ens-lyon.fr/birdweb]
 
Node IGBMC: [http://decrypthon.u-strasbg.fr:8080/birdweb/]
 
  
===Data Selection by [[BIRDQL]] 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://bird.u-strasbg.fr:8080/bird/bsearch?service=birdql'</source>
 
# <source lang = bash>http://bird.u-strasbg.fr:8080/bird/bsearch?service=birdql&query=your_birdql</source>
 
#* Example:
 
#**<source lang = bash> http://bird.u-strasbg.fr:8080/bird/bsearch?service=birdql&query=ID * DB Uniprot--WH DE contains "histone"--LM 10--FD AC,DE--FM FLAT</source>
 
#**<source lang = bash>http://bird.u-strasbg.fr:8080/bird/bsearch?service=birdql&query=ID * DB Uniprot--WH DE contains "Helianthinin"--LM 10--FM FASTA</source>
 
#**<source lang = bash>http://bird.u-strasbg.fr:8080/bird/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/BirdQlConsol/BirdQlConsol.sh ( or download [http://alnitak.u-strasbg.fr/~dkieffer/PublicDirectory/appli_java/BirdQlConsol.tar.gz here]).
 
  
 
===Simple Services-Bank ID===  
 
===Simple Services-Bank ID===  
  
 
Service :     
 
Service :     
http://bird.u-strasbg.fr:8080/bird/bsearch?db=<database>&accession=<ac or id>&field=<DE,OS..> &format=<fasta/flat>
+
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 1: get EST
+
Example 2: get dbsnp genotype by ID
       http://bird.u-strasbg.fr:8080/bird/bsearch?db=gbest&accession=Cj133605&field=DE,OS,OC,TISSUE_TYPE,DEV_STAGE
+
       http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnpgt&accession=268
  
Example 2: get Protein :   
+
Example 3: get dbsnp genotype population by ID
       http://bird.u-strasbg.fr:8080/bird/bsearch?db=uniprot&accession=Q23456
+
       http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnpgtpop&accession=1371
  
Example 3: get PDB :       
+
Example 4: get dbsnp genotype individual by ID
    http://bird.u-strasbg.fr:8080/bird/bsearch?db=pdb&accession=1XDS
+
      http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?db=dbsnpgtind&accession=867
  
Example 4: get Fasta :   
+
Example 5: get RefSeq Protein
     http://bird.u-strasbg.fr:8080/bird/bsearch?db=pdb&accession=1XDS&format=fasta
+
      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]).
  
===WEB Server===
 
  under construction:  [http://decrypthon.u-strasbg.fr:8080/birdweb]
 
  
 
===API JAVA - BIRDQL Client===
 
===API JAVA - BIRDQL Client===
Line 50: Line 60:
 
   InterfactDB birddb  = new InterfaceDB(“my-bird”)
 
   InterfactDB birddb  = new InterfaceDB(“my-bird”)
 
   // BIRD-QL
 
   // BIRD-QL
       String birdql = ” ID * DB UniProt
+
       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 61: 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)); 
 +
   
 +
    ?>
  
====BIRDQL CLient====
+
=====Java=====
 
 
java org.igbmc.bird.datadiscovery.BirdQLClient birdql  nameServer outFile
 
 
 
@birdql    : file name contains your bird-ql query
 
 
 
@nameServer: name of BIRD Server (d1.crihan.fr or bird.u-strasbg.fr)
 
  
@outFile  : file name, the result will be print to this file
+
      /** 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====

Latest revision as of 11:17, 10 March 2014

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:

  1. curl -F upload=@your_bird.ql 'http://kbm.u-strasbg.fr:8080/birdsnp/bsearch?service=birdql'
    
  2. 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
        
  3. 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.