import java.io.FileInputStream;\r
import java.io.FileNotFoundException;\r
import java.io.IOException;\r
-import java.net.URL;\r
+import java.util.ArrayList;\r
import java.util.HashSet;\r
import java.util.List;\r
+import java.util.Map;\r
\r
-import javax.xml.namespace.QName;\r
-import javax.xml.ws.Service;\r
-\r
+import org.testng.annotations.BeforeTest;\r
import org.testng.annotations.Test;\r
\r
-import compbio.conservation.Method;\r
-import compbio.data.msa.Annotation;\r
+import compbio.data.msa.JABAService;\r
+import compbio.data.msa.SequenceAnnotation;\r
+import compbio.data.sequence.ConservationMethod;\r
import compbio.data.sequence.FastaSequence;\r
import compbio.data.sequence.Score;\r
import compbio.data.sequence.SequenceUtil;\r
import compbio.metadata.JobSubmissionException;\r
import compbio.metadata.LimitExceededException;\r
+import compbio.metadata.PresetManager;\r
import compbio.metadata.ResultNotAvailableException;\r
+import compbio.metadata.RunnerConfig;\r
import compbio.metadata.UnsupportedRuntimeException;\r
+import compbio.metadata.WrongParameterException;\r
+import compbio.runner.conservation.AACon;\r
import compbio.util.SysPrefs;\r
-import compbio.ws.server.AAConWS;\r
\r
public class TestAAConWS {\r
\r
+ SequenceAnnotation<AACon> msaws;\r
+\r
+ @BeforeTest\r
+ void initConnection() {\r
+ /*\r
+ * URL url = null; try { url = new\r
+ * URL("http://localhost:8080/jabaws/AAConWS?wsdl"); } catch\r
+ * (MalformedURLException e) { e.printStackTrace();\r
+ * fail(e.getLocalizedMessage()); } String namespace =\r
+ * "http://msa.data.compbio/01/12/2010/"; QName qname = new\r
+ * QName(namespace, "AAConWS"); Service serv = Service.create(url,\r
+ * qname); msaws = serv.getPort(new QName(namespace, "AAConWSPort"),\r
+ * Annotation.class);\r
+ */\r
+ JABAService client = Jws2Client.connect("http://localhost:8080/jabaws",\r
+ Services.AAConWS);\r
+ msaws = (SequenceAnnotation<AACon>) client;\r
+ }\r
+\r
@Test\r
- public void test() throws FileNotFoundException, IOException {\r
+ public void testAnalize() throws FileNotFoundException, IOException {\r
\r
- URL url = new URL("http://localhost:8080/jabaws/AAConWS?wsdl");\r
- String namespace = "http://msa.data.compbio/01/12/2010/";\r
- QName qname = new QName(namespace, "AAConWS");\r
- Service serv = Service.create(url, qname);\r
/*\r
* MsaWS msaws = serv.getPort(new QName(\r
* "http://msa.data.compbio/01/01/2010/", "ClustalWSPort"),\r
// Annotation<AACon> msaws = serv.getPort(new QName(namespace,\r
// "ClustalWSPort"), Annotation.class);\r
\r
- Annotation<AAConWS> msaws = serv.getPort(new QName(namespace,\r
- "AAConWSPort"), Annotation.class);\r
-\r
// List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(\r
// AAConTester.test_alignment_input));\r
\r
+ File.separator + "TO1381.fasta.aln"));\r
\r
try {\r
- System.out.println("Pres: "\r
- + msaws.getPresets().getPresets().get(0));\r
+ System.out.println("Pres: " + msaws.getPresets().getPresets());\r
String jobId = msaws.analize(fsl);\r
System.out.println("J: " + jobId);\r
- HashSet<Score> result = msaws.getConservation(jobId);\r
+ Map<String, HashSet<Score>> result = msaws.getAnnotation(jobId);\r
assertNotNull(result);\r
assertEquals(result.size(), 1);\r
- assertEquals(result.iterator().next().getMethod(), Method.SHENKIN);\r
- List<Float> scores = result.iterator().next().getScores();\r
+ assertEquals(result.values().iterator().next().iterator().next()\r
+ .getMethod(), ConservationMethod.SHENKIN);\r
+ List<Float> scores = result.values().iterator().next().iterator()\r
+ .next().getScores();\r
assertNotNull(scores);\r
assertEquals(scores.size(), 568);\r
\r
+ // Using presets\r
+ PresetManager<AACon> presets = msaws.getPresets();\r
+ jobId = msaws.presetAnalize(fsl,\r
+ presets.getPresetByName("Quick conservation"));\r
+ result = msaws.getAnnotation(jobId);\r
+ assertNotNull(result);\r
+ assertEquals(result.size(), 13);\r
+\r
+ jobId = msaws.presetAnalize(fsl,\r
+ presets.getPresetByName("Slow conservation"));\r
+ result = msaws.getAnnotation(jobId);\r
+ assertNotNull(result);\r
+ assertEquals(result.size(), 5);\r
+\r
+ jobId = msaws.presetAnalize(fsl,\r
+ presets.getPresetByName("Complete conservation"));\r
+ result = msaws.getAnnotation(jobId);\r
+ assertNotNull(result);\r
+ assertEquals(result.size(), 18);\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
+ @Test\r
+ public void testPresetAnalize() throws FileNotFoundException, IOException {\r
+\r
+ String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()\r
+ + File.separator;\r
+\r
+ List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(\r
+ CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"\r
+ + File.separator + "TO1381.fasta.aln"));\r
+\r
+ try {\r
+ System.out.println("Pres: " + msaws.getPresets().getPresets());\r
+\r
+ // Using presets\r
+ PresetManager<AACon> presets = msaws.getPresets();\r
+ String jobId = msaws.presetAnalize(fsl,\r
+ presets.getPresetByName("Quick conservation"));\r
+ Map<String, HashSet<Score>> result = msaws.getAnnotation(jobId);\r
+ assertNotNull(result);\r
+ assertEquals(result.size(), 13);\r
+\r
+ jobId = msaws.presetAnalize(fsl,\r
+ presets.getPresetByName("Slow conservation"));\r
+ result = msaws.getAnnotation(jobId);\r
+ assertNotNull(result);\r
+ assertEquals(result.size(), 5);\r
+\r
+ jobId = msaws.presetAnalize(fsl,\r
+ presets.getPresetByName("Complete conservation"));\r
+ result = msaws.getAnnotation(jobId);\r
+ assertNotNull(result);\r
+ assertEquals(result.size(), 18);\r
+\r
} catch (UnsupportedRuntimeException 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
+ @Test\r
+ public void testCustomAnalize() throws FileNotFoundException, IOException {\r
+\r
+ String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()\r
+ + File.separator;\r
+\r
+ List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(\r
+ CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"\r
+ + File.separator + "TO1381.fasta.aln"));\r
+\r
+ // Using options\r
+ RunnerConfig<AACon> options = msaws.getRunnerOptions();\r
+ // System.out.println(options.getArguments());\r
+\r
+ try {\r
+ options.getArgument("Calculation method").setDefaultValue("SMERFS");\r
+ // options.getArgument("SMERFS Column Scoring Method")\r
+ // .setDefaultValue("MAX_SCORE");\r
+ // options.getArgument("SMERFS Gap Threshhold").setDefaultValue("1");\r
+ String jobId = msaws.customAnalize(fsl, options.getArguments());\r
+ Map<String, HashSet<Score>> result = msaws.getAnnotation(jobId);\r
+ assertNotNull(result);\r
+ assertEquals(result.size(), 1);\r
+ assertEquals(\r
+ new ArrayList<Score>(result.values().iterator().next())\r
+ .get(0).getScores().get(0), 0.698f);\r
+\r
+ options.getArgument("Calculation method").setDefaultValue("SMERFS");\r
+ options.removeArgument("Normalize");\r
+ System.out.println(options);\r
+ jobId = msaws.customAnalize(fsl, options.getArguments());\r
+ result = msaws.getAnnotation(jobId);\r
+ assertNotNull(result);\r
+ assertEquals(result.size(), 1);\r
+ assertEquals(\r
+ new ArrayList<Score>(result.values().iterator().next())\r
+ .get(0).getScores().get(0), 0.401f);\r
+\r
+ } catch (WrongParameterException e) {\r
+ e.printStackTrace();\r
+ fail(e.getMessage());\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
+ }\r
+ }\r
}\r