Reverted some testing changes in TestRNAalifoldWS so that it will run
authorDaniel Barton <daluke.barton@gmail.com>
Wed, 21 Aug 2013 11:27:03 +0000 (12:27 +0100)
committerDaniel Barton <daluke.barton@gmail.com>
Wed, 21 Aug 2013 11:27:03 +0000 (12:27 +0100)
successfully.

testsrc/compbio/ws/client/TestRNAalifoldWS.java
webservices/compbio/ws/server/RNAalifoldWS.java

index 7a844ea..fd8fb9b 100644 (file)
-       package compbio.ws.client;\r
-\r
-import static org.testng.Assert.assertNotNull;\r
-import static org.testng.Assert.fail;\r
-\r
-import java.io.FileInputStream;\r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
-import java.io.OutputStreamWriter;\r
-import java.io.Writer;\r
-import java.net.ConnectException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import javax.xml.ws.WebServiceException;\r
-\r
-import org.testng.annotations.BeforeTest;\r
-import org.testng.annotations.Test;\r
-\r
-import compbio.data.msa.JABAService;\r
-import compbio.data.msa.SequenceAnnotation;\r
-import compbio.data.sequence.Alignment;\r
-import compbio.data.sequence.ClustalAlignmentUtil;\r
-import compbio.data.sequence.FastaSequence;\r
-import compbio.data.sequence.RNAStructScoreManager;\r
-import compbio.data.sequence.ScoreManager;\r
-import compbio.data.sequence.UnknownFileFormatException;\r
-import compbio.metadata.AllTestSuit;\r
-import compbio.metadata.JobSubmissionException;\r
-import compbio.metadata.LimitExceededException;\r
-import compbio.metadata.Option;\r
-import compbio.metadata.ResultNotAvailableException;\r
-import compbio.metadata.UnsupportedRuntimeException;\r
-import compbio.metadata.WrongParameterException;\r
-import compbio.runner.structure.RNAalifold;\r
-import compbio.ws.server.RNAalifoldWS;\r
-\r
-\r
-public class TestRNAalifoldWS {\r
-       \r
-//     SequenceAnnotation<RNAalifoldWS> foldws;\r
-       RNAalifoldWS foldws;\r
-       \r
-       @BeforeTest(groups = {AllTestSuit.test_group_webservices})\r
-       void initConnection() {\r
-               \r
-               try {\r
-                       JABAService client = Jws2Client.connect(\r
-                                       "http://localhost:8080/jabaws", Services.RNAalifoldWS);\r
-                       foldws = (RNAalifoldWS) client;\r
-               } catch (ConnectException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               } catch (WebServiceException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               }\r
-       }\r
-\r
-       \r
-       @Test(groups = {AllTestSuit.test_group_webservices})\r
-       public void testFold() throws FileNotFoundException, IOException,\r
-                       UnknownFileFormatException {\r
-               \r
-//             String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()\r
-//                             + File.separator;\r
-               \r
-               Alignment aln = ClustalAlignmentUtil.readClustalFile(new FileInputStream(\r
-                               AllTestSuit.test_input_aln));\r
-               \r
-               List<FastaSequence> fsl = aln.getSequences();\r
-               \r
-               try {\r
-                       List<Option<RNAalifold>> options  = new ArrayList<Option<RNAalifold>>();\r
-                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("--mis"));\r
-                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("-p"));\r
-                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("--MEA"));\r
-                       \r
-//                     System.out.println("TestRNAalifoldWS: print options: " + options.toString());\r
-                       \r
-                       String jobId = foldws.customAnalize(fsl, options);\r
-                       System.out.println("J: " + jobId);\r
-                       \r
-                       Writer stdout = new OutputStreamWriter(System.out);\r
-                       \r
-                       System.out.println("results class: " + foldws.getAnnotation(jobId).getClass().getName());\r
-                       RNAStructScoreManager result = (RNAStructScoreManager)foldws.getAnnotation(jobId);\r
-                       \r
-                       \r
-                       result.writeOut(stdout);\r
-                       System.out.println("fold results: \n" + result.toString());\r
-                       assertNotNull(result);\r
-                       \r
-               } catch (UnsupportedRuntimeException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               } catch (LimitExceededException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               } catch (JobSubmissionException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               } catch (ResultNotAvailableException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               } catch (WrongParameterException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               }\r
-       }\r
-}\r
-       \r
-\r
-\r
+       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<RNAalifoldWS> foldws;
+       
+       @BeforeTest(groups = {AllTestSuit.test_group_webservices})
+       void initConnection() {
+               
+               try {
+                       JABAService client = Jws2Client.connect(
+                                       "http://localhost:8080/jabaws", Services.RNAalifoldWS);
+                       foldws = (SequenceAnnotation<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<FastaSequence> fsl = aln.getSequences();
+               
+               try {
+                       List<Option<RNAalifoldWS>> options  = new ArrayList<Option<RNAalifoldWS>>();
+                       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());
+               }
+       }
+}
+       
+
+
index a6ed826..d640e27 100644 (file)
@@ -9,6 +9,7 @@ import org.apache.log4j.Logger;
 import compbio.data.msa.JABAService;\r
 import compbio.data.msa.SequenceAnnotation;\r
 import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.RNAStructScoreManager;\r
 import compbio.engine.client.ConfiguredExecutable;\r
 import compbio.metadata.JobSubmissionException;\r
 import compbio.metadata.LimitExceededException;\r
@@ -31,6 +32,45 @@ public class RNAalifoldWS extends SequenceAnnotationService<RNAalifold>
                super (new RNAalifold(), log);\r
        }\r
 \r
+       \r
+//     // for testing\r
+//     @Override\r
+//     public RNAStructScoreManager getAnnotation(String jobId) \r
+//                     throws ResultNotAvailableException {\r
+//             return WSUtil.getAnnotation(jobId, log);\r
+//     }\r
+       \r
+       \r
+       // Only purpose of Overrides is to replace "analize" with "fold" method \r
+       // so that a clustal input file and not fasta will be generated\r
+       @Override\r
+       public String analize(List<FastaSequence> sequences)\r
+                       throws UnsupportedRuntimeException, LimitExceededException,\r
+                       JobSubmissionException {\r
+               WSUtil.validateFastaInput(sequences);\r
+               ConfiguredExecutable<RNAalifoldWS> confRNAalifold = init(sequences);\r
+               return WSUtil.fold(sequences, confRNAalifold, log, "analize",\r
+                               getLimit(""));\r
+       }\r
+\r
+       // Only purpose of Overrides is to replace "analize" with "fold" method \r
+               // so that a clustal input file and not fasta will be generated\r
+       @Override\r
+       public String customAnalize(List<FastaSequence> sequences,\r
+                       List<Option<RNAalifold>> options) throws UnsupportedRuntimeException,\r
+                       LimitExceededException, JobSubmissionException,\r
+                       WrongParameterException {\r
+               WSUtil.validateFastaInput(sequences);\r
+               ConfiguredExecutable<RNAalifold> confRNAalifold = init(sequences);\r
+               \r
+               List<String> params = WSUtil.getCommands(options,\r
+                               AACon.KEY_VALUE_SEPARATOR);\r
+               confRNAalifold.addParameters(params);\r
+               return WSUtil.fold(sequences, confRNAalifold, log, "customAnalize",\r
+                               getLimit(""));\r
+       }\r
+       \r
+       \r
        /*\r
         * No presets are supported, thus the result of this call will be as simple\r
         * call to analize without parameters\r