From: Daniel Barton Date: Wed, 21 Aug 2013 11:27:03 +0000 (+0100) Subject: Reverted some testing changes in TestRNAalifoldWS so that it will run X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=d182b2d2b6ede7c952c6ca5a24b1576c6a194eed;p=jabaws.git Reverted some testing changes in TestRNAalifoldWS so that it will run successfully. --- diff --git a/testsrc/compbio/ws/client/TestRNAalifoldWS.java b/testsrc/compbio/ws/client/TestRNAalifoldWS.java index 7a844ea..fd8fb9b 100644 --- a/testsrc/compbio/ws/client/TestRNAalifoldWS.java +++ b/testsrc/compbio/ws/client/TestRNAalifoldWS.java @@ -1,114 +1,118 @@ - package compbio.ws.client; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.Writer; -import java.net.ConnectException; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.ws.WebServiceException; - -import org.testng.annotations.BeforeTest; -import org.testng.annotations.Test; - -import compbio.data.msa.JABAService; -import compbio.data.msa.SequenceAnnotation; -import compbio.data.sequence.Alignment; -import compbio.data.sequence.ClustalAlignmentUtil; -import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.RNAStructScoreManager; -import compbio.data.sequence.ScoreManager; -import compbio.data.sequence.UnknownFileFormatException; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.LimitExceededException; -import compbio.metadata.Option; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.UnsupportedRuntimeException; -import compbio.metadata.WrongParameterException; -import compbio.runner.structure.RNAalifold; -import compbio.ws.server.RNAalifoldWS; - - -public class TestRNAalifoldWS { - -// SequenceAnnotation foldws; - RNAalifoldWS foldws; - - @BeforeTest(groups = {AllTestSuit.test_group_webservices}) - void initConnection() { - - try { - JABAService client = Jws2Client.connect( - "http://localhost:8080/jabaws", Services.RNAalifoldWS); - foldws = (RNAalifoldWS) client; - } catch (ConnectException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (WebServiceException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - - @Test(groups = {AllTestSuit.test_group_webservices}) - public void testFold() throws FileNotFoundException, IOException, - UnknownFileFormatException { - -// String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() -// + File.separator; - - Alignment aln = ClustalAlignmentUtil.readClustalFile(new FileInputStream( - AllTestSuit.test_input_aln)); - - List fsl = aln.getSequences(); - - try { - List> options = new ArrayList>(); - options.add(foldws.getRunnerOptions().getArgumentByOptionName("--mis")); - options.add(foldws.getRunnerOptions().getArgumentByOptionName("-p")); - options.add(foldws.getRunnerOptions().getArgumentByOptionName("--MEA")); - -// System.out.println("TestRNAalifoldWS: print options: " + options.toString()); - - String jobId = foldws.customAnalize(fsl, options); - System.out.println("J: " + jobId); - - Writer stdout = new OutputStreamWriter(System.out); - - System.out.println("results class: " + foldws.getAnnotation(jobId).getClass().getName()); - RNAStructScoreManager result = (RNAStructScoreManager)foldws.getAnnotation(jobId); - - - result.writeOut(stdout); - System.out.println("fold results: \n" + result.toString()); - assertNotNull(result); - - } catch (UnsupportedRuntimeException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (LimitExceededException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (WrongParameterException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } -} - - - + package compbio.ws.client; + +import compbio.metadata.AllTestSuit; +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; +import static org.testng.Assert.fail; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.Writer; +import java.io.OutputStreamWriter; +import java.net.ConnectException; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.ws.WebServiceException; + +import org.testng.annotations.BeforeTest; +import org.testng.annotations.Test; + +import compbio.data.msa.FoldWS; +import compbio.data.msa.JABAService; +import compbio.data.msa.SequenceAnnotation; +import compbio.data.sequence.Alignment; +import compbio.data.sequence.ClustalAlignmentUtil; +import compbio.data.sequence.ConservationMethod; +import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.ScoreManager; +import compbio.data.sequence.SequenceUtil; +import compbio.data.sequence.UnknownFileFormatException; +import compbio.metadata.AllTestSuit; +import compbio.metadata.JobSubmissionException; +import compbio.metadata.LimitExceededException; +import compbio.metadata.Option; +import compbio.metadata.PresetManager; +import compbio.metadata.ResultNotAvailableException; +import compbio.metadata.RunnerConfig; +import compbio.metadata.UnsupportedRuntimeException; +import compbio.metadata.WrongParameterException; +import compbio.runner.conservation.AACon; +import compbio.util.SysPrefs; +import compbio.ws.server.RNAalifoldWS; + + +public class TestRNAalifoldWS { + + SequenceAnnotation foldws; + + @BeforeTest(groups = {AllTestSuit.test_group_webservices}) + void initConnection() { + + try { + JABAService client = Jws2Client.connect( + "http://localhost:8080/jabaws", Services.RNAalifoldWS); + foldws = (SequenceAnnotation) client; + } catch (ConnectException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (WebServiceException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + + @Test(groups = {AllTestSuit.test_group_webservices}) + public void testFold() throws FileNotFoundException, IOException, + UnknownFileFormatException { + +// String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() +// + File.separator; + + Alignment aln = ClustalAlignmentUtil.readClustalFile(new FileInputStream( + AllTestSuit.test_input_aln)); + + List fsl = aln.getSequences(); + + try { + List> options = new ArrayList>(); + options.add(foldws.getRunnerOptions().getArgumentByOptionName("--mis")); + options.add(foldws.getRunnerOptions().getArgumentByOptionName("-p")); + options.add(foldws.getRunnerOptions().getArgumentByOptionName("--MEA")); + + System.out.println("TestRNAalifoldWS: print options: " + options.toString()); + + String jobId = foldws.customAnalize(fsl, options); + System.out.println("J: " + jobId); + ScoreManager result = foldws.getAnnotation(jobId); + System.out.println("fold results: \n" + result.toString()); + + Writer writer = new OutputStreamWriter(System.out); + result.writeOut(writer); + + assertNotNull(result); + + } catch (UnsupportedRuntimeException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (LimitExceededException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (WrongParameterException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } +} + + + diff --git a/webservices/compbio/ws/server/RNAalifoldWS.java b/webservices/compbio/ws/server/RNAalifoldWS.java index a6ed826..d640e27 100644 --- a/webservices/compbio/ws/server/RNAalifoldWS.java +++ b/webservices/compbio/ws/server/RNAalifoldWS.java @@ -9,6 +9,7 @@ import org.apache.log4j.Logger; import compbio.data.msa.JABAService; import compbio.data.msa.SequenceAnnotation; import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.RNAStructScoreManager; import compbio.engine.client.ConfiguredExecutable; import compbio.metadata.JobSubmissionException; import compbio.metadata.LimitExceededException; @@ -31,6 +32,45 @@ public class RNAalifoldWS extends SequenceAnnotationService super (new RNAalifold(), log); } + +// // for testing +// @Override +// public RNAStructScoreManager getAnnotation(String jobId) +// throws ResultNotAvailableException { +// return WSUtil.getAnnotation(jobId, log); +// } + + + // Only purpose of Overrides is to replace "analize" with "fold" method + // so that a clustal input file and not fasta will be generated + @Override + public String analize(List sequences) + throws UnsupportedRuntimeException, LimitExceededException, + JobSubmissionException { + WSUtil.validateFastaInput(sequences); + ConfiguredExecutable confRNAalifold = init(sequences); + return WSUtil.fold(sequences, confRNAalifold, log, "analize", + getLimit("")); + } + + // Only purpose of Overrides is to replace "analize" with "fold" method + // so that a clustal input file and not fasta will be generated + @Override + public String customAnalize(List sequences, + List> options) throws UnsupportedRuntimeException, + LimitExceededException, JobSubmissionException, + WrongParameterException { + WSUtil.validateFastaInput(sequences); + ConfiguredExecutable confRNAalifold = init(sequences); + + List params = WSUtil.getCommands(options, + AACon.KEY_VALUE_SEPARATOR); + confRNAalifold.addParameters(params); + return WSUtil.fold(sequences, confRNAalifold, log, "customAnalize", + getLimit("")); + } + + /* * No presets are supported, thus the result of this call will be as simple * call to analize without parameters