spacer
spacer

Calling Soaplab based EMBOSS Web Services

For programmatic access to Soaplab based EMBOSS Web Services most of the standard Web Services client libraries/tools can be used, alternatively when programming in Java it is possible to use Soaplab Client Library distributed as part of Soaplab.

EMBL-EBI Soaplab Web Services have two interfaces.

You can find below an example Perl script that use the typed interface to call two example EMBOSS Web Services. If you decide to use Soaplab client library there is an example Java program below that lists all available Web Services categories in the EMBL-EBI Soaplab server and retrieves an example UniProtKB entry using the seqret Web Service.

Alternative ways of accessing to Soaplab Web Services that requires no programming effort would be listed as follows

Writing your client in Perl

The following example Perl script demonstrates use of the EMBL-EBI EMBOSS Web Services. It first calls the needle Web Service to calculate global(overlap) alignment of two input sequences and then calls the plotcon Web Service to draw a plot of the sequence conservation within windows over the alignment.

#!/usr/bin/perl

use XML::Compile::SOAP11;
use XML::Compile::WSDL11;
use XML::Compile::Transport::SOAPHTTP;
use strict;

my ( $seqid1, $seqid2 ) = @ARGV;
$seqid1 = 'uniprot:hba_human' unless $seqid1;
$seqid2 = 'uniprot:hbb_human' unless $seqid2;

my $serviceendpoint = 'http://www.ebi.ac.uk/soaplab/typed/services/';

my $alignment = &align('alignment_global.needle');

# In order to call EMBOSS local alignment tool 'water'
# instead of the global alignment program 'neeedle'
# comment above line and uncomment the following line.
#my $alignment = &align('alignment_local.water');

&plot($alignment);

sub align($) {
	my $alignmentprogram = shift;
	my $runAndWaitFor = &getWebMethod( $serviceendpoint . $alignmentprogram );

	print "Calling the alignment web service and getting its response\n";

	# This example assumes you use sequence identifiers recognised by the
	# Soaplab EMBOSS server.
	# If you run the script for your own sequences you should use 'direct_data'
	# parameter rather than the 'usa' parameter. See below how its used
	# when calling the plotcon web service.
	my ( $answer, $trace ) = $runAndWaitFor->(
		asequence       => { usa => $seqid1 },
		bsequence       => { usa => $seqid2 },
		gapopen         => 10,
		gapextend       => 0.4,
		aformat_outfile => 'msf'
	);

	my %answer_   = &getResponse($answer);
	my $alignment = $answer_{"outfile"};

	open( OUT, "> alignment.msf" );
	print OUT $alignment;
	close(OUT);
	return $alignment;
}

sub plot($) {
	my $alignment     = shift;
	my $runAndWaitFor =
	  &getWebMethod( $serviceendpoint . 'alignment_multiple.plotcon' );
	print "Calling the plotcon web service and getting its response\n";
	my ( $answer, $trace ) = $runAndWaitFor->(
		sequences    => { direct_data => $alignment },
		winsize      => 4,
		graph_format => 'png'
	);

	my %answer_ = &getResponse($answer);
	my $graph   = $answer_{"Graphics_in_PNG"};

	my $i = 1;
	foreach my $grph (@$graph) {
		open( OUT, "> plotcon$i.png" );
		foreach my $b ($grph) {
			print OUT $b;
		}
		close(OUT);
		$i++;
	}
}

sub getResponse($) {
	my $answer          = shift;
	my %answer          = %{$answer};
	my %answer_         = %{ $answer{"runAndWaitForResponse"} };
	my $detailed_status = $answer_{"detailed_status"};
	if ( $detailed_status != 0 ) {
		my $report = $answer_{"report"};
		print "Service call didn't return normally:\n" . $report;
		exit 1;
	}
	return %answer_;
}

sub getWebMethod($) {
	my $endpoint = shift;
	print "Retriving and processing the WSDL\n";
	my $wsdl  = XML::LibXML->new->parse_file( $endpoint . '?wsdl' );
	my $proxy = XML::Compile::WSDL11->new($wsdl);
	print "Retriving and processing the XSDs\n";
	foreach my $schema ( 1, 2, 3 ) {
		my $xsdXml =
		  XML::LibXML->new->parse_file( $endpoint . '?xsd=' . $schema );
		if ( $XML::Compile::SOAP::VERSION < 2.0 ) {
			$proxy->schemas->importDefinitions($xsdXml);
		}
		else {
			$proxy->importDefinitions($xsdXml);
		}
	}
	print "Generating a request message based on the WSDL\n";
	my $runAndWaitFor = $proxy->compileClient('runAndWaitFor');
}

Using Soaplab command-line client script

Soaplab-2 command-line client is a typical testing tool that covers the most functionality of the Soaplab features. Although its user-friendliness is limited it can be used for batch and automated Soaplab services calls. It supports both Soaplab-1 and Soaplab-2 servers. You need to install Soaplab clients module to have the Soaplab command-line client script installed in your system.

In order to see the list of options, type:

build/run/run-cmdline-client -help

To access the list service running at the EMBL-EBI Soaplab server you may try to use:

 build/run/run-cmdline-client -l\
     -e http://www.ebi.ac.uk/soaplab/services -protocol axis1

You will get names of all available services. These are the names you need to know when making service calls.

Here are some examples to try:

build/run/run-cmdline-client \
  (1)       -e http://www.ebi.ac.uk/soaplab/services/edit.seqret \
  (2)       -name edit.seqret \
  (3)       sequence_direct_data aaaaaccccc  \
  (4)       osformat embl \
  (5)       -w \
  (6)       -r

where (1) shows where to go, (2) says what service to invoke, (3) and (4) are named input data, (5) means “create a job, start it and wait for its completion”, and finally (6) says “give me all results”.

build/run/run-cmdline-client \
  (1)       -e http://www.ebi.ac.uk/soaplab/services/edit.seqret \
  (2)       -name edit.seqret \
  (3)       -i \
  (4)       -o \
  (5)       -t \

where (3) shows all input data names, (4) shows all result names, and (5) gives few properties associated with this analysis.

build/run/run-cmdline-client \
  (1)       -e http://www.ebi.ac.uk/soaplab/services/edit.seqret \
  (2)       -name edit.seqret \
  (3)       -ii \
  (4)       -oo

now (3) and (4) show not only names but also types and other input data properties.

Using Soaplab client library

This example uses Soaplab2 API for getting available service categories from the EMBL-EBI Soaplab server, and also retrieves an example UniProtKB entry using the seqret Web Service:

    static SoaplabBaseClient getClient(String endpoint) {
        ServiceLocator locator = new ServiceLocator();
        locator.setProtocol(ClientConfig.PROTOCOL_AXIS1);
        locator.setServiceEndpoint(endpoint);
        try {
            return new SoaplabBaseClient(locator);
        } catch (SoaplabException e) {
            e.printStackTrace();
            System.exit(1);
        }
        return null;
    }
 
    static void printCategories() {
        SoaplabBaseClient client = getClient("http://www.ebi.ac.uk/soaplab/services");
        String[] catgs = client.getAvailableCategories();
        for (String category : catgs) {
            System.out.println(" - " + category);
        }
    }
 
    public static void main(String[] arg) {
        printCategories();
        SoaplabBaseClient client = getClient("http://www.ebi.ac.uk/soaplab/services/edit.seqret");
        Map<String, Object> inputs = new HashMap<String, Object>();
        inputs.put("sequence_usa", "uniprot:p12345");
        try {
            SoaplabMap results = client.runAndWaitFor(SoaplabMap
                    .fromMap(inputs));
            Map<String, Object> outputs = SoaplabMap.toMap(results);
            System.out.println("sequence retrieved: " + outputs.get("outseq"));
        } catch (SoaplabException e) {
            e.printStackTrace();
        }
    }
 
services/archive/soaplab/guide.txt · Last modified: 2013/04/23 16:39 by hpm
spacer
spacer