JABAWS MANUAL

Using JABAWS From Your Program

Web services functions overview

All JABA multiple sequence alignment web services comply to the same interface, thus the function described below are available from all the services.

Functions for initiating the alignment String id = align(List<FastaSequence> list)
String id = customAlign(List<FastaSequence> sequenceList, List<Option> optionList)
String id = presetAlign(List<FastaSequence> sequenceList, Preset preset)

Functions pertaining to job monitoring and control
JobStatus status = getJobStatus(String id)
Alignment al = getResult(String id)
boolean cancelled = cancelJob(String id)
ChunkHolder chunk = pullExecStatistics(String id, long marker)

Functions relating to service features discovery
RunnerConfig rc = getRunnerOptions()
Limit limit = getLimit(String name)
LimitsManager lm = getLimits()
PresetManager pm = getPresets()

Please refer to a data model javadoc for a detailed description of each methods.

Structure of the template command line client

Packages Classes and Interfaces
compbio.data.msa MsaWS the interface for all multiple sequence alignment web services
compbio.data.sequence JABAWS data types
compbio.metadata JABAWS meta data types
compbio.ws.client JABAWS command line client

Additional utility libraries this client depend upon is the compbio-util-1.3.jar and compbio-annotation-1.0.jar.
Please refer to a data model javadoc for a detailed description of each class and its methods.

Connecting to JABAWS

For a complete working example of JABAWS command line client please see compbio.ws.client.Jws2Client class. JABAWS command line client source code is available from the download page. Please note that for now all the examples are in Java other languages will follow given a sufficient demand.

Download a binary JABAWS client. Add the client to the class path. The following code excerpt will connect your program to Clustal web service deployed in the University of Dundee.

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
...............
1) String qualifiedName = "http://msa.data.compbio/01/01/2010/";
2) URL url = new URL("http://www.compbio.dundee.ac.uk/jabaws/ClustalWS?wsdl");
3) QName qname = new QName(, "ClustalWS");
4) Service serv = Service.create(url, qname);
5) MsaWS msaws = serv.getPort(new QName(qualifiedName, "ClustalWSPort"), MsaWS.class);

Line 1 makes a qualified name for JABA web services.
Line 2 constructs the URL to the web services WSDL.
Line 3 makes a qualified name instance for Clustal JABA web service.
Line 4 creates a service instance.
Line 5 makes a connection to the server.

A more generic connection method would look like this

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import compbio.ws.client.Services
..............
String qualifiedServiceName = "http://msa.data.compbio/01/01/2010/";
String host = "http://www.compbio.dundee.ac.uk/jabaws";
// In real life the service name can come from args
Services clustal = Services.ClustalWS;
URL url = new URL(host + "/" + clustal.toString() + "?wsdl");
QName qname = new QName(qualifiedServiceName, clustal.toString());
Service serv = Service.create(url, qname);
MsaWS msaws = serv.getPort(new QName(qualifiedServiceName, clustal
+ "Port"), MsaWS.class);

Where Services is enumeration of JABAWS web services. All JABAWS multiple sequence alignment methods confirm to MsaWS specification, thus from the caller point of view all JABAWS web services can be represented by MsaWS interface. The full documentation of MsaWS functions is available from the javadoc.

Valid JABAWS service names and WSDL files

Multiple sequence alignment services

  • ClustalOWS (http://www.compbio.dundee.ac.uk/jabaws/ClustalOWS?wsdl)
  • ClustalWS (http://www.compbio.dundee.ac.uk/jabaws/ClustalWS?wsdl)
  • MuscleWS (http://www.compbio.dundee.ac.uk/jabaws/MuscleWS?wsdl)
  • MafftWS (http://www.compbio.dundee.ac.uk/jabaws/MafftWS?wsdl)
  • TcoffeeWS (http://www.compbio.dundee.ac.uk/jabaws/TcoffeeWS?wsdl)
  • ProbconsWS (http://www.compbio.dundee.ac.uk/jabaws/ProbconsWS?wsdl)

Protein disorder prediction services

  • IUPredWS (http://www.compbio.dundee.ac.uk/jabaws/IUPredWS?wsdl)
  • GlobPlotWS (http://www.compbio.dundee.ac.uk/jabaws/GlobPlotWS?wsdl)
  • DisemblWS (http://www.compbio.dundee.ac.uk/jabaws/DisemblWS?wsdl)
  • JronnWS (http://www.compbio.dundee.ac.uk/jabaws/JronnWS?wsdl)

Amino acid conservation service

  • AAConWS (http://www.compbio.dundee.ac.uk/jabaws/AAConWS?wsdl)

Please replace http://www.compbio.dundee.ac.uk/ with your JABAWS instance host name, and jabaws with your JABAWS context name to access your local version of JABAWS web services. For example http://localhost:8080/jabaws would be a valid URL for the default Apache-Tomcat installation and jabaws.war file deployment.

Aligning sequences

Given that msaws is web service proxy, created as described in "Connecting to JABAWS" section, the actual alignment can be obtained as follows:

1) List<FastaSequence> fastalist = SequenceUtil.readFasta(new FileInputStream(file));
2) String jobId = msaws.align(fastalist);
3) Alignment alignment = msaws.getResult(jobId);

Line one loads FASTA sequence from the file
Line two submits them to web service represented by msaws proxy
Line three retrieves the alignment from a web service. This line will block the execution until the result is available. Use this with caution. In general, you should make sure that the calculation has been completed before attempting retrieving results. This is to avoid keeping the connection to the server on hold for a prolonged periods of time. While this may be ok with your local server, our public server (www.compbio.dundee.ac.uk/jabaws) will not let you hold the connection for longer than 10 minutes. This is done to prevent excessive load on the server. The next section describes how to check the status of the calculation.
Methods and classes mentioned in the excerpt are available from the JABAWS client library.

Checking the status of the calculation

You may have noticed that there was no pause between submitting the job and retrieving of the results. This is because getResult(jobId) method block the processing until the calculation is completed. However, taking into account that the connection holds server resources, our public server (www.compbio.dundee.ac.uk/jabaws) is configured to reset the connection after 10 minutes of waiting. To work around the connection reset you are encouraged to check whether the calculation has been completed before accessing the results. You can do it like this:

while (msaws.getJobStatus(jobId) != JobStatus.FINISHED) {
    Thread.sleep(2000); // wait two seconds, then recheck the status
}

Aligning with presets

1) PresetManager presetman = msaws.getPresets();
2) Preset preset = presetman.getPresetByName(presetName);
3) List<FastaSequence> fastalist = SequenceUtil.readFasta(new FileInputStream(file));
4) String jobId = msaws.presetAlign(fastalist, preset);
5) Alignment alignment = msaws.getResult(jobId);

Line one obtains the lists of presets supported by a web service.
Line two return a particular Preset by its name
Lines three to five are doing the same job as in the first aligning sequences example.

Aligning with custom parameters

1) RunnerConfig options = msaws.getRunnerOptions();
2) Argument matrix = options.getArgument("MATRIX");
3) matrix.setValue("PAM300");
4) Argument gapopenpenalty = options.getArgument("GAPOPEN");
5) gapopenpenalty.setValue("20");
6) List<Argument> arguments = new ArrayList<Argument>();
7) arguments.add(matrix); arguments.add(gapopenpenalty);
8) List<FastaSequence> fastalist = SequenceUtil.readFasta(new FileInputStream(file));
9) String jobId = msaws.customAlign(fastalist, arguments);
10) Alignment alignment = msaws.getResult(jobId);

Line one obtains the RunnerConfig object that holds information on supported parameters and their values
Line two retrieve a particular parameter from the holder by its name
Lines three sets a value to this parameter which will be used in the calculation.
Line four and five do the same but for another parameter
Line 6 makes a List to hold the parameters
Line seven puts the parameters into that list
Line eight and ten is the same as in previous examples
Line nine submit an alignment request with the sequences and the parameters
The names of all the parameters supported by a web service e.g. "PAM300" can be obtained using options.getArguments() method. Further details on the methods available from RunnerConfig object are available from the javadoc.

Writing alignments to a file

There is a utility method in the client library that does exactly that.

Alignment alignment = align(...)
FileOutputStream outStream = new FileOutputStream(file);
ClustalAlignmentUtil.writeClustalAlignment(outStream, align);

A complete client example

Finally, a complete example of the program that connects to JABAWS Clustal service and aligns sequences using one of the Clustal web service preset. Three is also a PDF version of this example with syntax highlighted. The text comments are commented by block style comments e.g. /* comment */, the alternatives given in the code are line commented // comment. You may want to remove line style comments to test alternatives of the functions. All you need for this to work is a JABAWS binary client. Please make sure that the client is in the Java class path before running this example.

import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.List;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;

import compbio.data.msa.MsaWS;
import compbio.data.sequence.Alignment;
import compbio.data.sequence.FastaSequence;
import compbio.data.sequence.SequenceUtil;
import compbio.metadata.JobSubmissionException;
import compbio.metadata.LimitExceededException;
import compbio.metadata.Preset;
import compbio.metadata.PresetManager;
import compbio.metadata.ResultNotAvailableException;
import compbio.metadata.UnsupportedRuntimeException;
import compbio.metadata.WrongParameterException;

public class Example {

	/*
	 * Input sequences for alignment
	 */
	static final String input = ">Foo\r\n"
			+ "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGR"
			+ "VRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQLLPEEPYITAQ"
			+ "LLNWRRRLCDWRALDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPL"
			+ "APTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQA"
			+ "STLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMD"
			+ "YVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLN"
			+ "PQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHAD"
			+ "LFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALAS"
			+ "DPAALTALHARVDVLRRESGVFEMDGFADDFGALLQALARRHGWLGI\r\n"
			+ "\r\n"
			+ ">Bar\r\n"
			+ "MGDTTAGEMAVQRGLALHQQRHAEAAVLLQQASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAH"
			+ "QLLPEEPYITAQLLNAVAQGVGAVEPFAFLSEDASAAESVRPLAPTRVRSKGPLRVGFVSNGFGA"
			+ "HPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHG"
			+ "IDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVL"
			+ "RLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLL"
			+ "SGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGC"
			+ "PVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESGV"
			+ "FEMDGFADDFGALLQALARRHGWLGI\r\n"
			+ "\r\n"
			+ ">Friends\r\n"
			+ "MTADGPRELLQLRAAVRHRPQDVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRV"
			+ "RWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDHQLLPEEPYITAQLDVLSAQVRAAVAQG"
			+ "VGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLL"
			+ "TVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFD"
			+ "LRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAF"
			+ "QPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEA"
			+ "DARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTP"
			+ "GETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESI";

	public static void main(String[] args) throws UnsupportedRuntimeException,
			LimitExceededException, JobSubmissionException,
			WrongParameterException, FileNotFoundException, IOException,
			ResultNotAvailableException, InterruptedException {

		String qualifiedServiceName = "http://msa.data.compbio/01/01/2010/";

		/* Make a URL pointing to web service WSDL */
		URL url = new URL(
				"http://www.compbio.dundee.ac.uk/jabaws/ClustalWS?wsdl");

		/*
		 * If you are making a client that connects to different web services
		 * you can use something like this:
		 */
		// URL url = new URL(host + "/" + Services.ClustalWS.toString() +
		// "?wsdl");

		QName qname = new QName(qualifiedServiceName, "ClustalWS");
		Service serv = Service.create(url, qname);
		/*
		 * Multiple sequence alignment interface for Clustal web service
		 * instance
		 */
		MsaWS msaws = serv.getPort(new QName(qualifiedServiceName, "ClustalWS"
				+ "Port"), MsaWS.class);

		/* Get the list of available presets */
		PresetManager presetman = msaws.getPresets();

		/* Get the Preset object by preset name */
		Preset preset = presetman
				.getPresetByName("Disable gap weighting (Speed-oriented)");

		/*
		 * Load sequences in FASTA format from the file You can use something
		 * like new FileInputStream(<filename>) to load sequence from the file
		 */
		List<FastaSequence> fastalist = SequenceUtil
				.readFasta(new ByteArrayInputStream(input.getBytes()));

		/*
		 * Submit loaded sequences for an alignment using preset. The job
		 * identifier is returned by this method, you can retrieve the results
		 * with it sometime later.
		 */
		String jobId = msaws.presetAlign(fastalist, preset);

		/* This method will block for the duration of the calculation */
		Alignment alignment = msaws.getResult(jobId);

		/*
		 * This is a better way of obtaining results, it does not involve
		 * holding the connection open for the duration of the calculation,
		 * Besides, as the University of Dundee public server will reset the
		 * connection after 10 minutes of idling, this is the only way to obtain
		 * the results of long running task from our public server.
		 */
		// while (msaws.getJobStatus(jobId) != JobStatus.FINISHED) {
		// Thread.sleep(1000); // wait a second, then recheck the status
		// }

		/* Output the alignment to standard out */
		System.out.println(alignment);

		// Alternatively, you can record retrieved alignment into the file in
		// ClustalW format

		// ClustalAlignmentUtil.writeClustalAlignment(new FileOutputStream(
		// "output.al"), alignment);

	}
}
For a more detailed description of all available types and their functions please refer to the data model javadoc.

Building web services artifacts

JABAWS are the standard JAX-WS SOAP web services, which are WS-I basic profile compatible. This means that you could use whatever tool your language has to work with web services. Below is how you can generate portable artifacts to work with JABAWS from Java. However, if programming in Java we recommend using our client library as it provides a handful of useful methods in addition to plain data types.

wsimport -keep http://www.compbio.dundee.ac.uk/jabaws/ClustalWS?wsdl