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