From: pvtroshin Date: Mon, 22 Nov 2010 15:38:01 +0000 (+0000) Subject: Java doc and package infos from JWS" branch. Also rethink of MSAWS interface in light... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0d5cea4e42cddb134c1c252847a6c17aa30e3182;p=jabaws.git Java doc and package infos from JWS" branch. Also rethink of MSAWS interface in light of new web services e.g. AACon web service. git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3345 e3abac25-378b-4346-85de-24260fe3988d --- diff --git a/webservices/compbio/data/msa/JManagement.java b/webservices/compbio/data/msa/JManagement.java index b9b2f01..8232260 100644 --- a/webservices/compbio/data/msa/JManagement.java +++ b/webservices/compbio/data/msa/JManagement.java @@ -10,43 +10,44 @@ import compbio.metadata.JobStatus; public interface JManagement { /** - * Stop running job but leave its output untouched + * Stop running the job jobId but leave its output untouched * * @return true if job was cancelled successfully, false otherwise * @throws InvalidParameterException - * thrown if jobId is empty or cannot be recognised e.g. in + * is thrown if jobId is empty or cannot be recognised e.g. in * invalid format */ boolean cancelJob(@WebParam(name = "jobId") String jobId); /** - * Return the status of the job. @see JobStatus + * Return the status of the job. * * @param jobId * - unique job identifier * @return JobStatus - status of the job * @throws InvalidParameterException - * thrown if jobId is empty or cannot be recognised e.g. in + * is thrown if jobId is empty or cannot be recognised e.g. in * invalid format + * @see JobStatus */ JobStatus getJobStatus(@WebParam(name = "jobId") String jobId); /** * Reads 1kb chunk from the statistics file which is specific to a given web - * service from the position. If in time of a request less then 1kb data is - * available from the position to the end of the file, then it returns all - * the data available from the position to the end of the file. + * service from the position. If in time of a request less then + * 1kb data is available from the position to the end of the file, then it + * returns all the data available from the position to the end of the file. * * @param jobId * - unique job identifier * @param position * - next position within the file to read - * @return ChunkHolder - @see ChunkHolder which contains a chuink of data - * and a next position within the file from which no data has been - * read + * @return ChunkHolder - which contains a chunk of data and a next position + * within the file from which no data has been read * @throws InvalidParameterException * thrown if jobId is empty or cannot be recognised e.g. in * invalid format and also if the position value is negative + * @see ChunkHolder */ ChunkHolder pullExecStatistics(@WebParam(name = "jobId") String jobId, @WebParam(name = "position") long position); diff --git a/webservices/compbio/data/msa/Metadata.java b/webservices/compbio/data/msa/Metadata.java index 67abb5d..e73e01d 100644 --- a/webservices/compbio/data/msa/Metadata.java +++ b/webservices/compbio/data/msa/Metadata.java @@ -39,10 +39,6 @@ public interface Metadata { /** * List Limits supported by a web service. * - * @param presetName - * the name of the preset. if no name is provided, then the - * default preset is returned. If no limit for a particular - * preset is defined then the default preset is returned * @return LimitManager */ LimitsManager getLimits(); diff --git a/webservices/compbio/data/msa/MsaWS.java b/webservices/compbio/data/msa/MsaWS.java index b1735fb..d5b64f8 100644 --- a/webservices/compbio/data/msa/MsaWS.java +++ b/webservices/compbio/data/msa/MsaWS.java @@ -50,8 +50,8 @@ public interface MsaWS extends JManagement, Metadata { /** * Align a list of sequences with default settings. * - * Any dataset containing a greater number of sequences or the average - * length of the sequences are greater then defined in the default Limit + * Any dataset containing a greater number of sequences or when the average + * length of the sequences are greater then defined in the default Limit, * will not be accepted for an alignment operation and * JobSubmissionException will be thrown. * @@ -59,25 +59,25 @@ public interface MsaWS extends JManagement, Metadata { * List of FastaSequence objects. The programme does not perform * any sequence validity checks. Nor does it checks whether the * sequences names are unique. It is responsibility of the caller - * to validate this information + * to make sure of this * @return jobId - unique identifier for the job - * @throws JobSubmissionException. This - * exception is thrown when the job could not be submitted due - * to the following reasons: 1) The number of sequences in the + * @throws JobSubmissionException + * is thrown when the job could not be submitted due to the + * following reasons: 1) The number of sequences in the * submission or their average length is greater then defined by * the default Limit. 2) Any problems on the server side e.g. it * is misconfigured or malfunction, is reported via this * exception. In the first case the information on the limit * could be obtained from an exception. * @throws InvalidParameterException - * thrown if input list of fasta sequence is null or empty + * thrown if input list of FASTA sequences is null or empty * @throws UnsupportedRuntimeException * thrown if server OS does not support native executables for a - * given web service, e.g. JWS2 is deployed on Windows and Mafft - * service is called + * given web service, e.g. JABAWS is deployed on Windows and + * Mafft service is called * @throws LimitExceededException - * is throw if the input sequences number or average length - * exceeds what is defined by the limit + * is throw if the input sequences number or their average + * length exceeds what is defined by the limit */ String align( @WebParam(name = "fastaSequences") List sequences) @@ -100,9 +100,9 @@ public interface MsaWS extends JManagement, Metadata { * @param options * A list of Options * @return jobId - unique identifier for the job - * @throws JobSubmissionException. This - * exception is thrown when the job could not be submitted due - * to the following reasons: 1) The number of sequences in the + * @throws JobSubmissionException + * is thrown when the job could not be submitted due to the + * following reasons: 1) The number of sequences in the * submission or their average length is greater then defined by * the default Limit. 2) Any problems on the server side e.g. it * is misconfigured or malfunction, is reported via this @@ -114,14 +114,14 @@ public interface MsaWS extends JManagement, Metadata { * boundaries. In both cases exception object contain the * information on the violating Option. * @throws InvalidParameterException - * thrown if input list of fasta sequence is null or empty + * thrown if input list of FASTA sequence is null or empty * @throws UnsupportedRuntimeException * thrown if server OS does not support native executables for a - * given web service, e.g. JWS2 is deployed on Windows and Mafft - * service is called + * given web service, e.g. JABAWS is deployed on Windows and + * Mafft service is called * @throws LimitExceededException - * is throw if the input sequences number or average length - * exceeds what is defined by the limit + * is throw if the input sequences number or their average + * length exceeds what is defined by the limit */ String customAlign( @WebParam(name = "fastaSequences") List sequences, @@ -130,7 +130,7 @@ public interface MsaWS extends JManagement, Metadata { JobSubmissionException, WrongParameterException; /** - * Align a list of sequences with preset. @see Preset + * Align a list of sequences with preset. * * Limit for a presetName is used whether the calculation will be permitted * or denied. If no Limit was defined for a presetName, than default limit @@ -144,9 +144,9 @@ public interface MsaWS extends JManagement, Metadata { * @param preset * A list of Options * @return String - jobId - unique identifier for the job - * @throws JobSubmissionException. This - * exception is thrown when the job could not be submitted due - * to the following reasons: 1) The number of sequences in the + * @throws JobSubmissionException + * is thrown when the job could not be submitted due to the + * following reasons: 1) The number of sequences in the * submission or their average length is greater then defined by * the default Limit. 2) Any problems on the server side e.g. it * is misconfigured or malfunction, is reported via this @@ -158,14 +158,15 @@ public interface MsaWS extends JManagement, Metadata { * boundaries. In both cases exception object contain the * information on the violating Option. * @throws InvalidParameterException - * thrown if input list of fasta sequence is null or empty + * thrown if input list of FASTA sequence is null or empty * @throws UnsupportedRuntimeException * thrown if server OS does not support native executables for a - * given web service, e.g. JWS2 is deployed on Windows and Mafft - * service is called + * given web service, e.g. JABAWS is deployed on Windows and + * Mafft service is called * @throws LimitExceededException * is throw if the input sequences number or average length * exceeds what is defined by the limit + * @see Preset */ String presetAlign( @WebParam(name = "fastaSequences") List sequences, @@ -174,7 +175,8 @@ public interface MsaWS extends JManagement, Metadata { JobSubmissionException, WrongParameterException; /** - * Return the result of the job. + * Return the result of the job. This method waits for the job + * jobId to complete before return. * * @param jobId * a unique job identifier @@ -182,13 +184,13 @@ public interface MsaWS extends JManagement, Metadata { * @throws ResultNotAvailableException * this exception is throw if the job execution was not * successful or the result of the execution could not be found. - * (e.g. removed). Exception could also be thrown is dues to the + * (e.g. removed). Exception could also be thrown due to the * lower level problems on the server i.e. IOException, * FileNotFoundException problems as well as * UnknownFileFormatException. * @throws InvalidParameterException - * thrown if jobId is empty or cannot be recognised e.g. in - * invalid format + * thrown if jobId is empty or is not recognised e.g. in invalid + * format */ Alignment getResult(@WebParam(name = "jobId") String jobId) throws ResultNotAvailableException; diff --git a/webservices/compbio/data/msa/package-info.java b/webservices/compbio/data/msa/package-info.java new file mode 100644 index 0000000..49990db --- /dev/null +++ b/webservices/compbio/data/msa/package-info.java @@ -0,0 +1,9 @@ +/** + * Web Service interfaces for JAva Bioinformatics Analysis Web Services. + * + * @author Peter Troshin + * @version 1.0 April 2010 + * + */ +package compbio.data.msa; + diff --git a/webservices/compbio/ws/client/WSTester.java b/webservices/compbio/ws/client/WSTester.java index 6223de0..ddd6742 100644 --- a/webservices/compbio/ws/client/WSTester.java +++ b/webservices/compbio/ws/client/WSTester.java @@ -50,317 +50,317 @@ import compbio.metadata.WrongParameterException; */ public class WSTester { - /** - * Sequences to be used as input for all WS - */ - static final String fastaInput = ">Foobar\n" - + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQLLPEEPYITAQLLNWRRRLCDWRALDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKA" - + "\n>Barbar\n" - + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVAQGVGAVEPFAFLSEDASAAESVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESGVFEMDGFADDFGALLQALARRHGWLGI" - + "\n>Foofriend\n" - + "MTADGPRELLQLRAAVRHRPQDVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDHQLLPEEPYITAQLDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESI\n"; + /** + * Sequences to be used as input for all WS + */ + static final String fastaInput = ">Foobar\n" + + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQLLPEEPYITAQLLNWRRRLCDWRALDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKA" + + "\n>Barbar\n" + + "ASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAHQLLPEEPYITAQLLNAVAQGVGAVEPFAFLSEDASAAESVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESGVFEMDGFADDFGALLQALARRHGWLGI" + + "\n>Foofriend\n" + + "MTADGPRELLQLRAAVRHRPQDVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRVRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDHQLLPEEPYITAQLDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESI\n"; - static final List seqs = loadSeqs(); + static final List seqs = loadSeqs(); - private static final String FAILED = "FAILED"; - private static final String OK = "OK"; + private static final String FAILED = "FAILED"; + private static final String OK = "OK"; - /** - * Converting input to a form accepted by WS - * - * @return List of FastaSequence records - */ - static List loadSeqs() { - try { - return SequenceUtil.readFasta(new ByteArrayInputStream(fastaInput - .getBytes())); - } catch (IOException ignored) { - // Should not happen as a source is not a external stream - ignored.printStackTrace(); + /** + * Converting input to a form accepted by WS + * + * @return List of FastaSequence records + */ + static List loadSeqs() { + try { + return SequenceUtil.readFasta(new ByteArrayInputStream(fastaInput + .getBytes())); + } catch (IOException ignored) { + // Should not happen as a source is not a external stream + ignored.printStackTrace(); + } + return null; } - return null; - } - /** - * Prints usage - */ - static void printUsage() { - System.out.println("Usage: " - + Jws2Client.hostkey + Jws2Client.pseparator - + "host_and_context " + "<" + Jws2Client.servicekey - + Jws2Client.pseparator + "serviceName>"); - System.out.println(); - System.out - .println(Jws2Client.hostkey - + Jws2Client.pseparator - + " - a full URL to the JWS2 web server including context path e.g. http://10.31.1.159:8080/ws"); - System.out - .println(Jws2Client.servicekey - + Jws2Client.pseparator - + " - optional if unspecified all services are tested otherwise one of " - + Arrays.toString(Services.values())); - System.out.println(); + /** + * Prints usage + */ + static void printUsage() { + System.out.println("Usage: " + + Jws2Client.hostkey + Jws2Client.pseparator + + "host_and_context " + "<" + Jws2Client.servicekey + + Jws2Client.pseparator + "serviceName>"); + System.out.println(); + System.out + .println(Jws2Client.hostkey + + Jws2Client.pseparator + + " - a full URL to the JABAWS web server including context path e.g. http://10.31.1.159:8080/ws"); + System.out + .println(Jws2Client.servicekey + + Jws2Client.pseparator + + " - optional if unspecified all services are tested otherwise one of " + + Arrays.toString(Services.values())); + System.out.println(); - } + } - /** - * Calls alignment with preset - * - * @param - * @param msaws - * @param presets - * list of the Preset - * @throws UnsupportedRuntimeException - */ - static boolean presetAlign(MsaWS msaws, List> presets) - throws UnsupportedRuntimeException { - boolean succeed = false; - for (Preset preset : presets) { - System.out.print("Aligning with preset '" + preset.getName() - + "'... "); - Alignment al = null; - try { - String taskId = msaws.presetAlign(seqs, preset); - al = msaws.getResult(taskId); - if (al != null) { - System.out.println(OK); + /** + * Calls alignment with preset + * + * @param + * @param msaws + * @param presets + * list of the Preset + * @throws UnsupportedRuntimeException + */ + static boolean presetAlign(MsaWS msaws, List> presets) + throws UnsupportedRuntimeException { + boolean succeed = false; + for (Preset preset : presets) { + System.out.print("Aligning with preset '" + preset.getName() + + "'... "); + Alignment al = null; + try { + String taskId = msaws.presetAlign(seqs, preset); + al = msaws.getResult(taskId); + if (al != null) { + System.out.println(OK); + } + succeed = true; + } catch (UnsupportedRuntimeException e) { + System.out.println(FAILED); + // If executable is not supported than none of the presets are + // going to work + throw new UnsupportedRuntimeException(e); + } catch (JobSubmissionException e) { + // TODO custom message + System.out.println(FAILED); + System.out.println(); + e.printStackTrace(); + continue; + } catch (WrongParameterException e) { + // TODO custom message + System.out.println(FAILED); + System.out.println(); + e.printStackTrace(); + continue; + } catch (ResultNotAvailableException e) { + // TODO custom message + System.out.println(FAILED); + System.out.println(); + e.printStackTrace(); + continue; + } } - succeed = true; - } catch (UnsupportedRuntimeException e) { - System.out.println(FAILED); - // If executable is not supported than none of the presets are - // going to work - throw new UnsupportedRuntimeException(e); - } catch (JobSubmissionException e) { - // TODO custom message - System.out.println(FAILED); - System.out.println(); - e.printStackTrace(); - continue; - } catch (WrongParameterException e) { - // TODO custom message - System.out.println(FAILED); - System.out.println(); - e.printStackTrace(); - continue; - } catch (ResultNotAvailableException e) { - // TODO custom message - System.out.println(FAILED); - System.out.println(); - e.printStackTrace(); - continue; - } + return succeed; } - return succeed; - } - /** - * Call most of web services functions and check the output - * - * @param - * web service type - * @param msaws - * @throws UnsupportedRuntimeException - * is thrown if the connection to a web service was made, but - * the web service is not functional. e.g. when native - * executable does not exists for a server platform - */ - static boolean checkService(MsaWS msaws) - throws UnsupportedRuntimeException { + /** + * Call most of web services functions and check the output + * + * @param + * web service type + * @param msaws + * @throws UnsupportedRuntimeException + * is thrown if the connection to a web service was made, but + * the web service is not functional. e.g. when native + * executable does not exists for a server platform + */ + static boolean checkService(MsaWS msaws) + throws UnsupportedRuntimeException { - boolean succeed = testDefaultAlignment(msaws); + boolean succeed = testDefaultAlignment(msaws); - // If exception above is thrown than the tests below is not run + // If exception above is thrown than the tests below is not run - PresetManager pmanager = msaws.getPresets(); - if (pmanager != null && pmanager.getPresets().size() > 0) { - System.out.println("Testing alignment with presets:"); - List> plist = pmanager.getPresets(); - succeed = !succeed ? presetAlign(msaws, plist) : succeed; - } + PresetManager pmanager = msaws.getPresets(); + if (pmanager != null && pmanager.getPresets().size() > 0) { + System.out.println("Testing alignment with presets:"); + List> plist = pmanager.getPresets(); + succeed = !succeed ? presetAlign(msaws, plist) : succeed; + } - System.out.print("Querying presets..."); + System.out.print("Querying presets..."); - if (pmanager != null && pmanager.getPresets().size() > 0) { - System.out.println(OK); - } else { - System.out.println("UNSUPPORTED"); - } + if (pmanager != null && pmanager.getPresets().size() > 0) { + System.out.println(OK); + } else { + System.out.println("UNSUPPORTED"); + } - System.out.print("Querying Parameters..."); - RunnerConfig options = msaws.getRunnerOptions(); - if (options != null && options.getArguments().size() > 0) { - System.out.println(OK); - } else { - System.out.println(FAILED); - succeed = false; - } + System.out.print("Querying Parameters..."); + RunnerConfig options = msaws.getRunnerOptions(); + if (options != null && options.getArguments().size() > 0) { + System.out.println(OK); + } else { + System.out.println(FAILED); + succeed = false; + } - System.out.print("Querying Limits..."); - LimitsManager limits = msaws.getLimits(); - if (limits != null && limits.getLimits().size() > 0) { - System.out.println(OK); - } else { - System.out.println("UNSUPPORTED"); - } + System.out.print("Querying Limits..."); + LimitsManager limits = msaws.getLimits(); + if (limits != null && limits.getLimits().size() > 0) { + System.out.println(OK); + } else { + System.out.println("UNSUPPORTED"); + } - System.out.print("Querying Local Engine Limits..."); - Limit localLimit = msaws - .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET); - if (localLimit != null) { - System.out.println(OK); - } else { - System.out.println("UNSUPPORTED"); + System.out.print("Querying Local Engine Limits..."); + Limit localLimit = msaws + .getLimit(PresetManager.LOCAL_ENGINE_LIMIT_PRESET); + if (localLimit != null) { + System.out.println(OK); + } else { + System.out.println("UNSUPPORTED"); + } + return succeed; } - return succeed; - } - /** - * Align using default settings - * - * @param - * @param msaws - * @throws UnsupportedRuntimeException - */ - static boolean testDefaultAlignment(MsaWS msaws) - throws UnsupportedRuntimeException { - System.out.print("Testing alignment with default parameters:"); - Alignment al = null; - boolean succeed = false; - try { - String taskId = msaws.align(seqs); - System.out.print("\nQuerying job status..."); - JobStatus status = msaws.getJobStatus(taskId); - while (status != JobStatus.FINISHED) { - Thread.sleep(1000); - status = msaws.getJobStatus(taskId); - } - System.out.println(OK); - System.out.print("Retrieving results..."); - al = msaws.getResult(taskId); - succeed = true; - } catch (ResultNotAvailableException e) { - System.out.println(FAILED); - e.printStackTrace(); - } catch (JobSubmissionException e) { - System.out.println(FAILED); - System.out.println(); - e.printStackTrace(); - } catch (InterruptedException e) { - System.out.println(FAILED); - System.out.println(); - e.printStackTrace(); - } - if (al != null) { - System.out.println(OK); + /** + * Align using default settings + * + * @param + * @param msaws + * @throws UnsupportedRuntimeException + */ + static boolean testDefaultAlignment(MsaWS msaws) + throws UnsupportedRuntimeException { + System.out.print("Testing alignment with default parameters:"); + Alignment al = null; + boolean succeed = false; + try { + String taskId = msaws.align(seqs); + System.out.print("\nQuerying job status..."); + JobStatus status = msaws.getJobStatus(taskId); + while (status != JobStatus.FINISHED) { + Thread.sleep(1000); + status = msaws.getJobStatus(taskId); + } + System.out.println(OK); + System.out.print("Retrieving results..."); + al = msaws.getResult(taskId); + succeed = true; + } catch (ResultNotAvailableException e) { + System.out.println(FAILED); + e.printStackTrace(); + } catch (JobSubmissionException e) { + System.out.println(FAILED); + System.out.println(); + e.printStackTrace(); + } catch (InterruptedException e) { + System.out.println(FAILED); + System.out.println(); + e.printStackTrace(); + } + if (al != null) { + System.out.println(OK); + } + return succeed; } - return succeed; - } - /** - * Connect to a WS using the host and the service name - * - * @param - * @param host - * @param service - * @return - */ - static MsaWS connect(String host, Services service) { - MsaWS msaws = null; - try { - System.out.print("Connecting to service " + service + " on " + host - + " ... "); - msaws = Jws2Client.connect(host, service); - System.out.println(OK); - } catch (WebServiceException e) { - System.out.println(FAILED); + /** + * Connect to a WS using the host and the service name + * + * @param + * @param host + * @param service + * @return + */ + static MsaWS connect(String host, Services service) { + MsaWS msaws = null; + try { + System.out.print("Connecting to service " + service + " on " + host + + " ... "); + msaws = Jws2Client.connect(host, service); + System.out.println(OK); + } catch (WebServiceException e) { + System.out.println(FAILED); + } + return msaws; } - return msaws; - } - /** - * Test JWS2 web services - * - * @param - * web service type - * @param args - * -h= - * - * -s= which is optional. If service name is not - * provided then all known JWS2 web services are tested - * @throws IOException - */ - public static void main(String[] args) throws IOException { + /** + * Test JWS2 web services + * + * @param + * web service type + * @param args + * -h= + * + * -s= which is optional. If service name is not + * provided then all known JWS2 web services are tested + * @throws IOException + */ + public static void main(String[] args) throws IOException { - if (args == null || args.length < 1) { - printUsage(); - System.exit(0); - } - String host = Jws2Client.getHost(args); - String serviceName = Jws2Client.getServiceName(args); - if (!Jws2Client.validURL(host)) { - System.out - .println(" parameter is not provided or is incorrect!"); - System.exit(1); - } - boolean succeed = false; - MsaWS msaws = null; - if (serviceName != null) { - Services service = Services.getService(serviceName); - if (service == null) { - System.out.println("Service '" + serviceName - + "' is not supported. Valid values are: " - + Arrays.toString(Services.values())); - System.out.println(); - printUsage(); - System.exit(1); - } + if (args == null || args.length < 1) { + printUsage(); + System.exit(0); + } + String host = Jws2Client.getHost(args); + String serviceName = Jws2Client.getServiceName(args); + if (!Jws2Client.validURL(host)) { + System.out + .println(" parameter is not provided or is incorrect!"); + System.exit(1); + } + boolean succeed = false; + MsaWS msaws = null; + if (serviceName != null) { + Services service = Services.getService(serviceName); + if (service == null) { + System.out.println("Service '" + serviceName + + "' is not supported. Valid values are: " + + Arrays.toString(Services.values())); + System.out.println(); + printUsage(); + System.exit(1); + } - msaws = connect(host, service); - if (msaws == null) { - System.exit(1); - } - try { - succeed = checkService(msaws); - } catch (UnsupportedRuntimeException ignored) { - System.exit(1); - } finally { - ((Closeable) msaws).close(); - } - reportResults(service, succeed); - System.exit(0); - } + msaws = connect(host, service); + if (msaws == null) { + System.exit(1); + } + try { + succeed = checkService(msaws); + } catch (UnsupportedRuntimeException ignored) { + System.exit(1); + } finally { + ((Closeable) msaws).close(); + } + reportResults(service, succeed); + System.exit(0); + } - System.out - .println(" is not provided checking all known services..."); + System.out + .println(" is not provided checking all known services..."); - for (Services serv : Services.values()) { - System.out.println(); - msaws = connect(host, serv); - if (msaws == null) { - continue; - } - try { - succeed = checkService(msaws); - } catch (UnsupportedRuntimeException ignored) { - System.out.println("Service " + serv + " IS NOT FUNCTIONAL"); - continue; - } finally { - ((Closeable) msaws).close(); - } - reportResults(serv, succeed); - } + for (Services serv : Services.values()) { + System.out.println(); + msaws = connect(host, serv); + if (msaws == null) { + continue; + } + try { + succeed = checkService(msaws); + } catch (UnsupportedRuntimeException ignored) { + System.out.println("Service " + serv + " IS NOT FUNCTIONAL"); + continue; + } finally { + ((Closeable) msaws).close(); + } + reportResults(serv, succeed); + } - } + } - private static void reportResults(Services serv, boolean succeed) { - if (succeed) { - System.out.println("Check is completed. The Service " + serv - + " IS WORKING"); - } else { - System.out.println("Check is completed. The Service " + serv - + " HAS SOME PROBLEMS"); + private static void reportResults(Services serv, boolean succeed) { + if (succeed) { + System.out.println("Check is completed. The Service " + serv + + " IS WORKING"); + } else { + System.out.println("Check is completed. The Service " + serv + + " HAS SOME PROBLEMS"); + } } - } } diff --git a/webservices/compbio/ws/client/package-info.java b/webservices/compbio/ws/client/package-info.java new file mode 100644 index 0000000..303d76d --- /dev/null +++ b/webservices/compbio/ws/client/package-info.java @@ -0,0 +1,10 @@ +/** + * A command line client and web services testing client for + * JAva Bioinformatics Analysis Web Services. + * + * @author Peter Troshin + * @version 1.0 April 2010 + * + */ +package compbio.ws.client; +