Clustal Omega web service wrapper and tester
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 4 Aug 2011 13:17:10 +0000 (13:17 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 4 Aug 2011 13:17:10 +0000 (13:17 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4464 e3abac25-378b-4346-85de-24260fe3988d

testsrc/compbio/runner/msa/ClustalOTester.java
testsrc/testdata/ClustaloParameters.xml [new file with mode: 0644]

index c02904d..663b81a 100644 (file)
@@ -74,14 +74,14 @@ import compbio.util.SysPrefs;
 public class ClustalOTester {\r
 \r
        static final String clustalConfigFile = AllTestSuit.TEST_DATA_PATH\r
-                       + "ClustalParameters.xml";\r
-       public static String test_outfile = "TO1381.clustal.out";\r
-       public static String cluster_test_outfile = "TO1381.clustal.cluster.out";\r
+                       + "ClustaloParameters.xml";\r
+       public static String test_outfile = "TO1381.clustalo.out";\r
+       public static String cluster_test_outfile = "TO1381.clustalo.cluster.out";\r
 \r
        @Test(groups = {AllTestSuit.test_group_cluster,\r
                        AllTestSuit.test_group_runner})\r
        public void testRunOnCluster() {\r
-               ClustalW clustal = new ClustalW();\r
+               ClustalO clustal = new ClustalO();\r
                assertFalse(SysPrefs.isWindows,\r
                                "Cluster execution can only be in unix environment");\r
                clustal.setInput(AllTestSuit.test_input)\r
@@ -89,7 +89,7 @@ public class ClustalOTester {
 \r
                try {\r
 \r
-                       ConfiguredExecutable<ClustalW> confClustal = Configurator\r
+                       ConfiguredExecutable<ClustalO> confClustal = Configurator\r
                                        .configureExecutable(clustal);\r
                        JobRunner runner = JobRunner.getInstance(confClustal);\r
                        // ClusterSession csession = JobRunner.getSession();\r
@@ -165,22 +165,23 @@ public class ClustalOTester {
        @Test(groups = {AllTestSuit.test_group_runner})\r
        public void testConfigurationLoading() {\r
                try {\r
-                       RunnerConfig<ClustalW> clustalConfig = ConfExecutable\r
-                                       .getRunnerOptions(ClustalW.class);\r
+                       RunnerConfig<ClustalO> clustalConfig = ConfExecutable\r
+                                       .getRunnerOptions(ClustalO.class);\r
                        assertNotNull(clustalConfig);\r
                        assertTrue(clustalConfig.getArguments().size() > 0);\r
 \r
-                       PresetManager<ClustalW> clustalPresets = ConfExecutable\r
-                                       .getRunnerPresets(ClustalW.class);\r
+                       /* Unsupported\r
+                       PresetManager<ClustalO> clustalPresets = ConfExecutable\r
+                                       .getRunnerPresets(ClustalO.class);\r
                        assertNotNull(clustalPresets);\r
                        assertTrue(clustalPresets.getPresets().size() > 0);\r
                        clustalPresets.validate(clustalConfig);\r
-\r
-                       LimitsManager<ClustalW> clustalLimits = ConfExecutable\r
-                                       .getRunnerLimits(ClustalW.class);\r
+                        */\r
+                       LimitsManager<ClustalO> clustalLimits = ConfExecutable\r
+                                       .getRunnerLimits(ClustalO.class);\r
                        assertNotNull(clustalLimits);\r
                        assertTrue(clustalLimits.getLimits().size() > 0);\r
-                       clustalLimits.validate(clustalPresets);\r
+                       //clustalLimits.validate(clustalPresets);\r
 \r
                } catch (FileNotFoundException e) {\r
                        e.printStackTrace();\r
@@ -188,9 +189,6 @@ public class ClustalOTester {
                } catch (IOException e) {\r
                        e.printStackTrace();\r
                        fail(e.getLocalizedMessage());\r
-               } catch (ValidationException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getLocalizedMessage());\r
                }\r
        }\r
 \r
@@ -198,10 +196,10 @@ public class ClustalOTester {
        public void testOptionsLocally() {\r
                try {\r
 \r
-                       RunnerConfigMarshaller<ClustalW> clustalmarsh = new RunnerConfigMarshaller<ClustalW>(\r
+                       RunnerConfigMarshaller<ClustalO> clustalmarsh = new RunnerConfigMarshaller<ClustalO>(\r
                                        RunnerConfig.class);\r
 \r
-                       RunnerConfig<ClustalW> clustalConfig = clustalmarsh.read(\r
+                       RunnerConfig<ClustalO> clustalConfig = clustalmarsh.read(\r
                                        new FileInputStream(new File(clustalConfigFile)),\r
                                        RunnerConfig.class);\r
 \r
@@ -209,12 +207,12 @@ public class ClustalOTester {
                        List<String> options = clustalOpc.getOptionsAtRandom();\r
                        for (int i = 0; i < options.size(); i++) {\r
                                System.out.println("Using options: " + options);\r
-                               ClustalW clustal = new ClustalW();\r
+                               ClustalO clustal = new ClustalO();\r
                                clustal.setInput(AllTestSuit.test_input)\r
                                                .setOutput(test_outfile);\r
 \r
                                // For local execution use relavive\r
-                               ConfiguredExecutable<ClustalW> confClustal = Configurator\r
+                               ConfiguredExecutable<ClustalO> confClustal = Configurator\r
                                                .configureExecutable(clustal, ExecProvider.Local);\r
 \r
                                // Add options to the executable\r
@@ -222,7 +220,7 @@ public class ClustalOTester {
 \r
                                LocalRunner lr = new LocalRunner(confClustal);\r
                                lr.executeJob();\r
-                               confClustal = (ConfiguredExecutable<ClustalW>) lr\r
+                               confClustal = (ConfiguredExecutable<ClustalO>) lr\r
                                                .waitForResult();\r
                                assertNotNull(confClustal.getResults());\r
                                Collections.shuffle(options);\r
@@ -248,10 +246,10 @@ public class ClustalOTester {
 \r
        public static final void main(String[] args) throws JobSubmissionException,\r
                        JobExecutionException, InterruptedException {\r
-               ClustalW clustal = new ClustalW();\r
+               ClustalO clustal = new ClustalO();\r
                clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
                // For local execution use relavive\r
-               ConfiguredExecutable<ClustalW> confClustal = Configurator\r
+               ConfiguredExecutable<ClustalO> confClustal = Configurator\r
                                .configureExecutable(clustal);\r
                AsyncExecutor lr = new AsyncLocalRunner();\r
                lr.submitJob(confClustal);\r
@@ -259,76 +257,21 @@ public class ClustalOTester {
                LocalExecutorService.shutDown();\r
        }\r
 \r
-       @Test(enabled = false)\r
-       public void testAddParameters() {\r
-               ArrayList<FastaSequence> seqs = new ArrayList<FastaSequence>();\r
-               FastaSequence fs = new FastaSequence("tests1",\r
-                               "aqtctcatcatctcatctgcccccgggttatgagtagtacgcatctacg");\r
-               FastaSequence fs2 = new FastaSequence("tests2",\r
-                               "aqtctcatcatctcatctgcccccgggttatgagtagtacgcatctacg");\r
-               FastaSequence fs3 = new FastaSequence("tests3",\r
-                               "aqtctcatcatctcatctgcccccgggttatgagtagtacgcatctacg");\r
-               seqs.add(fs);\r
-               seqs.add(fs2);\r
-               seqs.add(fs3);\r
-               ClustalW cl = new ClustalW();\r
-               cl.setInput("input.txt").setOutput("output.txt");\r
-               ConfiguredExecutable<ClustalW> confClustal;\r
-               try {\r
-                       confClustal = Configurator.configureExecutable(cl);\r
-                       Util.writeInput(seqs, confClustal);\r
-\r
-                       LocalRunner lr = new LocalRunner(confClustal);\r
-                       lr.executeJob();\r
-                       confClustal = (ConfiguredExecutable<ClustalW>) lr.waitForResult();\r
-                       assertNotNull(confClustal.getResults());\r
-\r
-                       assertTrue(confClustal.saveRunConfiguration());\r
-                       ConfiguredExecutable<ClustalW> cexec = (ConfiguredExecutable<ClustalW>) confClustal\r
-                                       .loadRunConfiguration(new FileInputStream(new File(\r
-                                                       confClustal.getWorkDirectory(),\r
-                                                       RunConfiguration.rconfigFile)));\r
-                       assertNotNull(cexec);\r
-\r
-                       lr = new LocalRunner(cexec);\r
-                       lr.executeJob();\r
-                       confClustal = (ConfiguredExecutable<ClustalW>) lr.waitForResult();\r
-                       assertNotNull(confClustal.getResults());\r
-\r
-                       System.out.println("CE:" + cexec);\r
-               } catch (JobSubmissionException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               } catch (FileNotFoundException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               } catch (JobExecutionException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               } catch (ResultNotAvailableException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               } catch (IOException e) {\r
-                       e.printStackTrace();\r
-                       fail(e.getMessage());\r
-               }\r
-       }\r
-\r
        @Test(groups = {AllTestSuit.test_group_runner})\r
        public void testPersistance() {\r
                try {\r
-                       ClustalW clustal = new ClustalW();\r
+                       ClustalO clustal = new ClustalO();\r
                        clustal.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
                                        .setOutput("outtt.txt");\r
                        assertEquals(clustal.getInput(), AllTestSuit.test_input);\r
                        assertEquals(clustal.getError(), "errrr.txt");\r
                        assertEquals(clustal.getOutput(), "outtt.txt");\r
-                       ConfiguredExecutable<ClustalW> cClustal = Configurator\r
+                       ConfiguredExecutable<ClustalO> cClustal = Configurator\r
                                        .configureExecutable(clustal, Executable.ExecProvider.Local);\r
 \r
                        SyncExecutor sexec = Configurator.getSyncEngine(cClustal);\r
                        sexec.executeJob();\r
-                       cClustal = (ConfiguredExecutable<ClustalW>) sexec.waitForResult();\r
+                       cClustal = (ConfiguredExecutable<ClustalO>) sexec.waitForResult();\r
                        assertNotNull(cClustal.getResults());\r
                        // Save run configuration\r
                        assertTrue(cClustal.saveRunConfiguration());\r
@@ -337,10 +280,10 @@ public class ClustalOTester {
                        RunConfiguration loadedRun = RunConfiguration\r
                                        .load(new FileInputStream(new File(cClustal\r
                                                        .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
-                       assertTrue(((ConfExecutable<ClustalW>) cClustal)\r
+                       assertTrue(((ConfExecutable<ClustalO>) cClustal)\r
                                        .getRunConfiguration().equals(loadedRun));\r
                        // Load run configuration as ConfExecutable\r
-                       ConfiguredExecutable<ClustalW> resurrectedCclustal = (ConfiguredExecutable<ClustalW>) cClustal\r
+                       ConfiguredExecutable<ClustalO> resurrectedCclustal = (ConfiguredExecutable<ClustalO>) cClustal\r
                                        .loadRunConfiguration(new FileInputStream(new File(cClustal\r
                                                        .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
                        assertNotNull(resurrectedCclustal);\r
@@ -348,14 +291,14 @@ public class ClustalOTester {
                        assertEquals(resurrectedCclustal.getExecutable(), clustal);\r
 \r
                        // Finally rerun the job in the new task directory\r
-                       ConfiguredExecutable<ClustalW> resclustal = Configurator\r
+                       ConfiguredExecutable<ClustalO> resclustal = Configurator\r
                                        .configureExecutable(resurrectedCclustal.getExecutable(),\r
                                                        Executable.ExecProvider.Local);\r
 \r
                        sexec = Configurator.getSyncEngine(resclustal,\r
                                        Executable.ExecProvider.Local);\r
                        sexec.executeJob();\r
-                       cClustal = (ConfiguredExecutable<ClustalW>) sexec.waitForResult();\r
+                       cClustal = (ConfiguredExecutable<ClustalO>) sexec.waitForResult();\r
                        assertNotNull(cClustal.getResults());\r
 \r
                } catch (JobSubmissionException e) {\r
@@ -379,9 +322,9 @@ public class ClustalOTester {
        @Test(groups = {AllTestSuit.test_group_runner})\r
        public void readStatistics() {\r
                try {\r
-                       ClustalW clustal = new ClustalW().setInput(AllTestSuit.test_input)\r
+                       ClustalO clustal = new ClustalO().setInput(AllTestSuit.test_input)\r
                                        .setOutput(test_outfile);\r
-                       ConfiguredExecutable<ClustalW> confClustal = Configurator\r
+                       ConfiguredExecutable<ClustalO> confClustal = Configurator\r
                                        .configureExecutable(clustal, Executable.ExecProvider.Local);\r
 \r
                        AsyncExecutor sexec = Configurator.getAsyncEngine(confClustal);\r
@@ -422,9 +365,9 @@ public class ClustalOTester {
                        AllTestSuit.test_group_runner})\r
        public void readStatisticsClusterExecution() {\r
                try {\r
-                       ClustalW clustal = new ClustalW().setInput(AllTestSuit.test_input)\r
+                       ClustalO clustal = new ClustalO().setInput(AllTestSuit.test_input)\r
                                        .setOutput(test_outfile);\r
-                       ConfiguredExecutable<ClustalW> confClustal = Configurator\r
+                       ConfiguredExecutable<ClustalO> confClustal = Configurator\r
                                        .configureExecutable(clustal,\r
                                                        Executable.ExecProvider.Cluster);\r
 \r
@@ -449,6 +392,7 @@ public class ClustalOTester {
                                position = ch.getNextPosition();\r
                                System.out.print(chunk);\r
                                count++;\r
+                               Thread.sleep(200);\r
                                if (sexec.getJobStatus(jobId) == JobStatus.UNDEFINED) {\r
                                        System.out.println("DRMAA reported wrong status for job + "\r
                                                        + jobId + " continue anyway!");\r
@@ -467,6 +411,9 @@ public class ClustalOTester {
                } catch (IOException e) {\r
                        e.printStackTrace();\r
                        fail(e.getMessage());\r
+               } catch (InterruptedException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
                }\r
        }\r
 }\r
diff --git a/testsrc/testdata/ClustaloParameters.xml b/testsrc/testdata/ClustaloParameters.xml
new file mode 100644 (file)
index 0000000..711011e
--- /dev/null
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="US-ASCII" standalone="yes"?>\r
+<runnerConfig>\r
+       <runnerClassName>compbio.runner.msa.ClustalO</runnerClassName>\r
+       <options>\r
+               <name>Dealign</name>\r
+               <description>Dealign input sequences</description>\r
+               <optionNames>--dealign</optionNames>\r
+               <furtherDetails>prog_docs/clustalo.txt</furtherDetails>\r
+       </options>\r
+       <options>\r
+               <name>Full distance matrix</name>\r
+               <description>Use full distance matrix for guide-tree calculation (slow; mBed is default)</description>\r
+               <optionNames>--full</optionNames>\r
+               <furtherDetails>prog_docs/clustalo.txt</furtherDetails>\r
+       </options>\r
+       <options>\r
+               <name>Full distance matrix for each iteration</name>\r
+               <description>Use full distance matrix for guide-tree calculation during iteration (mBed is default)</description>\r
+               <optionNames>--full-iter</optionNames>\r
+               <furtherDetails>prog_docs/clustalo.txt</furtherDetails>\r
+       </options>\r
+       <prmSeparator>=</prmSeparator>\r
+       <parameters>\r
+               <name>Max Guide tree iterations</name>\r
+               <description>Maximum number of HMM iterations</description>\r
+               <optionNames>--max-hmm-iterations</optionNames>\r
+               <furtherDetails>prog_docs/clustalo.txt</furtherDetails>\r
+               <defaultValue>1</defaultValue>\r
+               <validValue>\r
+                       <type>Integer</type>\r
+                       <min>1</min>\r
+                       <max>100</max>\r
+               </validValue>\r
+       </parameters>\r
+       <parameters>\r
+               <name>Number of iterations (combined)</name>\r
+               <description>Number of (combined guide tree/HMM) iterations</description>\r
+               <optionNames>--iter</optionNames>\r
+               <furtherDetails>prog_docs/clustalo.txt</furtherDetails>\r
+               <defaultValue>1</defaultValue>\r
+               <validValue>\r
+                       <type>Integer</type>\r
+                       <min>1</min>\r
+                       <max>100</max>\r
+               </validValue>\r
+       </parameters>\r
+       <parameters>\r
+               <name>Max Guide tree iterations</name>\r
+               <description>Maximum guide tree iterations</description>\r
+               <optionNames>--max-guidetree-iterations</optionNames>\r
+               <furtherDetails>prog_docs/clustalo.txt</furtherDetails>\r
+               <defaultValue>1</defaultValue>\r
+               <validValue>\r
+                       <type>Integer</type>\r
+                       <min>1</min>\r
+                       <max>100</max>\r
+               </validValue>\r
+       </parameters>\r
+</runnerConfig>\r