BioNemus Web Services generation tool


Document/Literal SOAP-based Web Services

Generated SOAP-based web services can be accessed through Simple Object Access Protocol (SOAP) 1.1.

Every generated web service has a corresponding Web Services Description Language (WSDL) 1.1 decriptor. This descriptor may also contain Semantic Annotations embedded into the generated WSDL in a form of OWL 2 Web Ontology Language.

Spanish National Bioinformatics Institute has deployed a proxy for all its BioMoby web services that can be found at:

Authority Description
inb.bsc.es Algorithmic Support Unit at Barcelona Supercomputing Centre (BSC).
INB Computational Bioinformatics Node (GN6).
cnio.es Structural Computational Biology Group at Spanish National Cancer Research Centre (CNIO).
Bioinformatics and Proteomics Node (GN2).
mmb.pcb.ub.es Institute for Research in Biomedicine (IRB).
Molecular Modelling & Bioinformatics Unit (GN4).

Service description files have enough information to use corresponding web services. Here we are going to explain how to work with these services using Java. Java 6 already has web services stack - Java API for XML Web Services. Let's choose NCBI Blastp web service for the example:

http://www.inab.org/dproxy/inb.bsc.es/runNCBIBlastp?wsdl

A simplest way is to generate our client code automatically using wsimport utility. It is as simple as executing:

wsimport http://www.inab.org/dproxy/inb.bsc.es/runNCBIBlastp?wsdl

This will generate a client for the runNCBIBlastp service. Generated classes may be placed in three categories: primitive datatypes, ontology datatypes and web-service related. Note that ontology datatypes classes are different from those generated by BioNemus.

Next step would be to create a simple program to call the service. Here is a java code:

public class RunNCBIBlastpTest
{
    public static void main(String[] args)
    {
        RunNCBIBlastp_Service service = new RunNCBIBlastp_Service();

        RunNCBIBlastp port = service.getRunNCBIBlastpPort();

        AminoAcidSequence sequence = new AminoAcidSequence();
        sequence.setNemusId("O14862");

        NemusString string = new NemusString();

        string.setValue("MESKYKEILLLTGLDNITDEELDRFKFFLSDEFNIATGKLHTANRIQVATLMIQNAGAVS" +
                        "AVMKTIRIFQKLNYMLLAKRLQEEKEKVDKQYKSVTKPKPLSQAEMSPAASAAIRNDVAK" +
                        "QRAAPKVSPHVKPEQKQMVAQQESIREGFQKRCLPVMVLKAKKPFTFETQEGKQEMFHAT" +
                        "VATEKEFFFVKVFNTLLKDKFIPKRIIIIARYYRHSGFLEVNSASRVLDAESDQKVNVPL" +
                        "NIIRKAGETPKINTLQTQPLGTIVNGLFVVQKVTEKKKNILFDLSDNTGKMEVLGVRNED" +
                        "TMKCKEGDKVRLTFFTLSKNGEKLQLTSGVHSTIKVIKAKKKT");

        sequence.setSequenceString(string);

        RunNCBIBlastpRequest request = new RunNCBIBlastpRequest();
        request.setSequence(sequence);

        try
        {
            RunNCBIBlastpResponse response = port.runNCBIBlastp(request, 20, 20);

            BLASTText blast_text = response.getBlastReport();

            NemusString ns = blast_text.getContent();

            System.out.println(ns.getValue());
        }
        catch(RunNCBIBlastpException ex)
        {
            ex.printStackTrace();
        }
    }
}
      

RESTful Web Services

Another type of Web-services supported by BioNemus tool is so-called REST services. Based on JAX-RS 1.0 specification they use a same pattern as previous ones and are very easy to use. Generated services support both XML Schema and JSON based encoding, thus could be used directly from a web-page using java script. Note that to create an XML message it is possible to use an ontology based java classes along with a JAXB API.

Authority Description
inb.bsc.es Algorithmic Support Unit at Barcelona Supercomputing Centre (BSC).
INB Computational Bioinformatics Node (GN6).
cnio.es Structural Computational Biology Group at Spanish National Cancer Research Centre (CNIO).
Bioinformatics and Proteomics Node (GN2).
mmb.pcb.ub.es Institute for Research in Biomedicine (IRB).
Molecular Modelling & Bioinformatics Unit (GN4).

Here are several examples of usage using Java:

URL url = new URL("http://www.inab.org/dproxy-rest/inb.bsc.es/getEntryFromPDB");

HttpURLConnection  conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/xml");
conn.setRequestProperty("Accept", "application/xml");
conn.setDoOutput(true);

NemusObject id = new NemusObject();
id.setNemusId("1pio");
id.setNemusNamespace(new QName(null, "PDB"));

JAXBContext ctx = JAXBContext.newInstance(NemusObject.class);

OutputStream out = conn.getOutputStream();
ctx.createMarshaller().marshal(id, out);

BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));

String line;
while ((line = rd.readLine()) != null) {
    System.out.println(line);
}
      

URL url = new URL("http://www.inab.org/dproxy-rest/inb.bsc.es/getEntryFromPDB");

HttpURLConnection  conn = (HttpURLConnection)url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Accept", "application/json");
conn.setDoOutput(true);

OutputStream out = conn.getOutputStream();

out.write("{\"nemusId\" : \"1pio\", \"nemusNamespace\" : \"PDB\"}".getBytes());
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));

String line;
while ((line = rd.readLine()) != null) {
    System.out.println(line);
}
      

Example of calling RESTful services from JavaScript:

<html>
  <head>
    <script type="text/javascript">
      function get_pdb(pdb_id)
      {
        var url = "http://www.inab.org/dproxy-rest/inb.bsc.es/getEntryFromPDB";
        var http = new XMLHttpRequest();
        http.open("POST", url, true);
        http.setRequestHeader("Content-Type", "application/json");
        http.setRequestHeader("Accept", "application/json");
        http.onreadystatechange = function () {

          if ( http.readyState == 4 && http.status == 200 ) {
            var response = JSON.parse(http.responseText);

            document.getElementById("pdb_file").value = response.content.value;
          }
        }
        var request = new Object();
        request.nemusId = pdb_id;
        request.nemusNamespace = "PDB";
  
        var req = JSON.stringify(request); // req = '{"nemusId" : "1pio", "nemusNamespace" : "PDB"}';
        http.send(req);
     }
    </script>
  </head>
  <body>
    PDB ID: 
    <input type="text" id="pdb_id" maxlength="4" size="4" onkeypress="if (event.keyCode == '13') get_pdb(this.value)"/>
    <button type="button" onclick="get_pdb(document.getElementById('pdb_id').value)">Get PDB</button>
    <textarea id="pdb_file" style="width: 100%; height: 60%; white-space: pre;"></textarea>
 </body>
</html>