From: Sasha Sherstnev Date: Thu, 8 Aug 2013 13:12:07 +0000 (+0100) Subject: Check and correct several runner testers X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0f57cbfe1c32ea507785af0f67f5de477c9de121;p=jabaws.git Check and correct several runner testers --- diff --git a/testsrc/compbio/runner/conservation/AAConTester.java b/testsrc/compbio/runner/conservation/AAConTester.java index 353509a..b453eb7 100644 --- a/testsrc/compbio/runner/conservation/AAConTester.java +++ b/testsrc/compbio/runner/conservation/AAConTester.java @@ -1,6 +1,8 @@ -/* - * Copyright (c) 2010 Peter Troshin JAva Bioinformatics Analysis Web Services - * (JABAWS) @version: 2.0 +/* Copyright (c) 2010 Peter Troshin + * Copyright (c) 2013 Alexander Sherstnev + * + * Java Bioinformatics Analysis Web Services (JABAWS) + * (JABAWS) @version: 2.5 * * This library is free software; you can redistribute it and/or modify it under * the terms of the Apache License version 2 as published @@ -29,7 +31,6 @@ import java.io.FileNotFoundException; import java.io.IOException; import java.text.ParseException; import java.util.Arrays; -import java.util.HashSet; import javax.xml.bind.ValidationException; @@ -38,7 +39,6 @@ import org.ggf.drmaa.JobInfo; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import compbio.data.sequence.Score; import compbio.data.sequence.ScoreManager; import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; @@ -68,12 +68,9 @@ import compbio.util.SysPrefs; public class AAConTester { - public static final String CURRENT_DIRECTORY = SysPrefs - .getCurrentDirectory() + File.separator; - - public static String test_outfile = "TO1381.aacon.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out - public static String test_alignment_input = CURRENT_DIRECTORY + "testsrc" - + File.separator + "testdata" + File.separator + "TO1381.fasta.aln"; + public static final String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() + File.separator; + public static String test_outfile = "TO1381.aacon.out"; + public static String test_alignment_input = CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata" + File.separator + "TO1381.fasta.aln"; private AACon aacon; @BeforeMethod(alwaysRun = true) @@ -83,32 +80,25 @@ public class AAConTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunOnCluster() { - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); + public void RunOnCluster() { + assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); try { - ConfiguredExecutable confAAcon = Configurator - .configureExecutable(aacon, Executable.ExecProvider.Cluster); + ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Cluster); JobRunner runner = JobRunner.getInstance(confAAcon); assertNotNull(runner, "Runner is NULL"); runner.executeJob(); - // assertNotNull("JobId is null", jobId1); JobStatus status = runner.getJobStatus(); - assertTrue(status == JobStatus.PENDING - || status == JobStatus.RUNNING, - "Status of the process is wrong!"); + assertTrue(status == JobStatus.PENDING || status == JobStatus.RUNNING, "Status of the process is wrong!"); JobInfo info = runner.getJobInfo(); assertNotNull(info, "JobInfo is null"); StatisticManager sm = new StatisticManager(info); assertNotNull(sm, "Statictic manager is null"); try { - String exits = sm.getExitStatus(); assertNotNull("Exit status is null", exits); // cut 4 trailing zeros from the number - int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits) - .intValue(); + int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits).intValue(); assertEquals(0, exitsInt); System.out.println(sm.getAllStats()); @@ -116,12 +106,10 @@ public class AAConTester { e.printStackTrace(); fail("Parse Exception: " + e.getMessage()); } - // assertFalse(runner.cleanup()); assertTrue(sm.hasExited()); assertFalse(sm.wasAborted()); assertFalse(sm.hasDump()); assertFalse(sm.hasSignaled()); - } catch (JobSubmissionException e) { e.printStackTrace(); fail("DrmaaException caught:" + e.getMessage()); @@ -135,16 +123,14 @@ public class AAConTester { } /** - * This tests fails from time to time depending on the cluster load or some + * This test fails from time to time depending on the cluster load or some * other factors. Any client code has to adjust for this issue */ @Test(groups = {AllTestSuit.test_group_runner, AllTestSuit.test_group_cluster}) - public void testRunOnClusterAsync() { - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); + public void RunOnClusterAsync() { + assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); try { - ConfiguredExecutable confAAcon = Configurator - .configureExecutable(aacon, Executable.ExecProvider.Cluster); + ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Cluster); AsyncExecutor aengine = Configurator.getAsyncEngine(confAAcon); String jobId = aengine.submitJob(confAAcon); assertNotNull(jobId, "Runner is NULL"); @@ -155,14 +141,11 @@ public class AAConTester { System.out.println("Job Status: " + status); Thread.sleep(1000); status = aengine.getJobStatus(jobId); - ConfiguredExecutable result = (ConfiguredExecutable) aengine - .getResults(jobId); + ConfiguredExecutable result = (ConfiguredExecutable) aengine.getResults(jobId); assertNotNull(result); System.out.println("RES:" + result); - // Some times the job could be removed from the cluster - // accounting - // before it has been reported to finish. Make sure - // to stop waiting in such case + // Some times the job could be removed from the cluster accounting + // before it has been reported to finish. Make sure to stop waiting in such case if (status == JobStatus.UNDEFINED) { break; } @@ -180,10 +163,9 @@ public class AAConTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocally() { + public void RunLocally() { try { - ConfiguredExecutable confAAcon = Configurator - .configureExecutable(aacon, Executable.ExecProvider.Local); + ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Local); // For local execution use relative LocalRunner lr = new LocalRunner(confAAcon); @@ -207,14 +189,12 @@ public class AAConTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocallyWithPreset() { + public void RunLocallyWithPreset() { try { PresetManager aaconPresets = Util.getPresets(AACon.class); assert aaconPresets != null; - ConfiguredExecutable confAAcon = Configurator - .configureExecutable(aacon, Executable.ExecProvider.Local); - Preset quick = aaconPresets - .getPresetByName("Quick conservation"); + ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Local); + Preset quick = aaconPresets.getPresetByName("Quick conservation"); confAAcon.addParameters(quick.getOptions()); // For local execution use relative LocalRunner lr = new LocalRunner(confAAcon); @@ -238,14 +218,13 @@ public class AAConTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocallyOnTwoCpu() { + public void RunLocallyOnTwoCpu() { try { aacon = new AACon(); aacon.setInput(test_alignment_input).setOutput(test_outfile); aacon.setNCore(2); - ConfiguredExecutable confAAcon = Configurator - .configureExecutable(aacon, Executable.ExecProvider.Local); + ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Local); confAAcon.addParameters(Arrays.asList("-m=KABAT,JORES")); confAAcon.addParameters(Arrays.asList("-m=TAYLOR_GAPS")); // For local execution use relative @@ -258,7 +237,6 @@ public class AAConTester { assertNotNull(annotations); assertEquals(annotations.asSet().size(), 3); assertEquals(al1.getResults(), annotations); - } catch (JobSubmissionException e) { e.printStackTrace(); fail(e.getLocalizedMessage()); @@ -274,25 +252,23 @@ public class AAConTester { @Test(groups = {AllTestSuit.test_group_runner}) public void readStatistics() { try { - ConfiguredExecutable confAAcon = Configurator - .configureExecutable(aacon, Executable.ExecProvider.Local); + ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Local); // For local execution use relative AsyncExecutor sexec = Configurator.getAsyncEngine(confAAcon); String jobId = sexec.submitJob(confAAcon); - FilePuller fw = FilePuller.newFilePuller( - confAAcon.getWorkDirectory() + File.separator - + AACon.getStatFile(), - FileWatcher.MIN_CHUNK_SIZE_BYTES); + String file = confAAcon.getWorkDirectory() + File.separator + AACon.getStatFile(); + FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); int count = 0; long position = 0; fw.waitForFile(2); JobStatus status = sexec.getJobStatus(jobId); do { - ChunkHolder ch = fw.pull(position); - String chunk = ch.getChunk(); - position = ch.getNextPosition(); - // System.out.println(chunk); + if (fw.hasMoreData()) { + ChunkHolder ch = fw.pull(position); + String chunk = ch.getChunk(); + position = ch.getNextPosition(); + } count++; // Make sure the loop is terminated if the job fails if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) { @@ -302,7 +278,6 @@ public class AAConTester { Thread.sleep(300); status = sexec.getJobStatus(jobId); } while (status != JobStatus.FINISHED || fw.hasMoreData()); - assertTrue(count >= 1); ConfiguredExecutable al = sexec.getResults(jobId); assertNotNull(al.getResults()); @@ -322,21 +297,22 @@ public class AAConTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testPersistance() { + public void Persistance() { try { AACon aacon = new AACon(); - aacon.setError("errrr.txt").setInput(test_alignment_input) - .setOutput("outtt.txt"); + aacon.setError("errrr.txt"); + aacon.setInput(test_alignment_input); + aacon.setOutput("outtt.txt"); assertEquals(aacon.getInput(), test_alignment_input); assertEquals(aacon.getError(), "errrr.txt"); assertEquals(aacon.getOutput(), "outtt.txt"); - ConfiguredExecutable cAAcon = Configurator - .configureExecutable(aacon, Executable.ExecProvider.Local); + ConfiguredExecutable cAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Local); SyncExecutor sexec = Configurator.getSyncEngine(cAAcon); sexec.executeJob(); ConfiguredExecutable al = sexec.waitForResult(); assertNotNull(al.getResults()); + // Save run configuration assertTrue(cAAcon.saveRunConfiguration()); @@ -344,33 +320,27 @@ public class AAConTester { RunConfiguration loadedRun = RunConfiguration .load(new FileInputStream(new File(cAAcon .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals( - ((ConfExecutable) cAAcon).getRunConfiguration(), - loadedRun); + assertEquals(((ConfExecutable) cAAcon).getRunConfiguration(),loadedRun); + // Load run configuration as ConfExecutable ConfiguredExecutable resurrectedCAAcon = (ConfiguredExecutable) cAAcon .loadRunConfiguration(new FileInputStream(new File(cAAcon .getWorkDirectory(), RunConfiguration.rconfigFile))); assertNotNull(resurrectedCAAcon); - assertEquals(resurrectedCAAcon.getExecutable().getInput(), - test_alignment_input); - assertEquals(resurrectedCAAcon.getExecutable().getError(), - "errrr.txt"); - assertEquals(resurrectedCAAcon.getExecutable().getOutput(), - "outtt.txt"); + assertEquals(resurrectedCAAcon.getExecutable().getInput(), test_alignment_input); + assertEquals(resurrectedCAAcon.getExecutable().getError(), "errrr.txt"); + assertEquals(resurrectedCAAcon.getExecutable().getOutput(), "outtt.txt"); + // See in details whether executables are the same assertEquals(resurrectedCAAcon.getExecutable(), aacon); - ConfiguredExecutable resAAcon = Configurator - .configureExecutable(resurrectedCAAcon.getExecutable(), + ConfiguredExecutable resAAcon = Configurator.configureExecutable(resurrectedCAAcon.getExecutable(), Executable.ExecProvider.Local); - sexec = Configurator.getSyncEngine(resAAcon, - Executable.ExecProvider.Local); + sexec = Configurator.getSyncEngine(resAAcon, Executable.ExecProvider.Local); sexec.executeJob(); al = sexec.waitForResult(); assertNotNull(al); - } catch (JobSubmissionException e) { e.printStackTrace(); fail(e.getMessage()); @@ -390,23 +360,19 @@ public class AAConTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testConfigurationLoading() { + public void ConfigurationLoading() { try { - RunnerConfig aaconConfig = ConfExecutable - .getRunnerOptions(AACon.class); + RunnerConfig aaconConfig = ConfExecutable.getRunnerOptions(AACon.class); assertNotNull(aaconConfig); assertTrue(aaconConfig.getArguments().size() > 0); - PresetManager aaconPresets = ConfExecutable - .getRunnerPresets(AACon.class); + PresetManager aaconPresets = ConfExecutable.getRunnerPresets(AACon.class); assertNotNull(aaconPresets); - LimitsManager jronnLimits = ConfExecutable - .getRunnerLimits(AACon.class); - assertNotNull(jronnLimits); - assertTrue(jronnLimits.getLimits().size() > 0); - jronnLimits.validate(aaconPresets); - + LimitsManager aaconLimits = ConfExecutable.getRunnerLimits(AACon.class); + assertNotNull(aaconLimits); + assertTrue(aaconLimits.getLimits().size() > 0); + aaconLimits.validate(aaconPresets); } catch (FileNotFoundException e) { e.printStackTrace(); fail(e.getLocalizedMessage()); @@ -418,5 +384,4 @@ public class AAConTester { fail(e.getLocalizedMessage()); } } - } diff --git a/testsrc/compbio/runner/disorder/JronnTester.java b/testsrc/compbio/runner/disorder/JronnTester.java index 4635d10..a3e0905 100644 --- a/testsrc/compbio/runner/disorder/JronnTester.java +++ b/testsrc/compbio/runner/disorder/JronnTester.java @@ -1,6 +1,8 @@ /* Copyright (c) 2009 Peter Troshin + * Copyright (c) 2013 Alexander Sherstnev * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 + * Java Bioinformatics Analysis Web Services (JABAWS) + * @version: 2.5 * * This library is free software; you can redistribute it and/or modify it under the terms of the * Apache License version 2 as published by the Apache Software Foundation @@ -30,7 +32,6 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.text.ParseException; -import java.util.Map; import javax.xml.bind.ValidationException; @@ -39,7 +40,6 @@ import org.ggf.drmaa.JobInfo; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; -import compbio.data.sequence.Score; import compbio.data.sequence.ScoreManager; import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; @@ -67,8 +67,7 @@ import compbio.util.SysPrefs; public class JronnTester { - public static String test_outfile = "TO1381.jronn.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out - + public static String test_outfile = "TO1381.jronn.out"; private Jronn jronn; @BeforeMethod(alwaysRun = true) @@ -77,47 +76,36 @@ public class JronnTester { jronn.setInput(AllTestSuit.test_input).setOutput(test_outfile); } - @Test(groups = {AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner}) - public void testRunOnCluster() { - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); + @Test(groups = {AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner}) + public void RunOnCluster() { + assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); try { - ConfiguredExecutable confJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Cluster); + ConfiguredExecutable confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Cluster); JobRunner runner = JobRunner.getInstance(confJronn); assertNotNull(runner, "Runner is NULL"); runner.executeJob(); - // assertNotNull("JobId is null", jobId1); JobStatus status = runner.getJobStatus(); - assertTrue(status == JobStatus.PENDING - || status == JobStatus.RUNNING, - "Status of the process is wrong!"); + assertTrue(status == JobStatus.PENDING || status == JobStatus.RUNNING, "Status of the process is wrong!"); JobInfo info = runner.getJobInfo(); assertNotNull(info, "JobInfo is null"); StatisticManager sm = new StatisticManager(info); assertNotNull(sm, "Statictic manager is null"); try { - String exits = sm.getExitStatus(); assertNotNull("Exit status is null", exits); // cut 4 trailing zeros from the number - int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits) - .intValue(); + int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits).intValue(); assertEquals(0, exitsInt); - System.out.println(sm.getAllStats()); - + //System.out.println(sm.getAllStats()); } catch (ParseException e) { e.printStackTrace(); fail("Parse Exception: " + e.getMessage()); } - // assertFalse(runner.cleanup()); assertTrue(sm.hasExited()); assertFalse(sm.wasAborted()); assertFalse(sm.hasDump()); assertFalse(sm.hasSignaled()); - } catch (JobSubmissionException e) { e.printStackTrace(); fail("DrmaaException caught:" + e.getMessage()); @@ -134,14 +122,11 @@ public class JronnTester { * This tests fails from time to time depending on the cluster load or some * other factors. Any client code has to adjust for this issue */ - @Test(groups = {AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner}) - public void testRunOnClusterAsync() { - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); + @Test(groups = {AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner}) + public void RunOnClusterAsync() { + assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); try { - ConfiguredExecutable confJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Cluster); + ConfiguredExecutable confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Cluster); AsyncExecutor aengine = Configurator.getAsyncEngine(confJronn); String jobId = aengine.submitJob(confJronn); assertNotNull(jobId, "Runner is NULL"); @@ -152,14 +137,11 @@ public class JronnTester { System.out.println("Job Status: " + status); Thread.sleep(1000); status = aengine.getJobStatus(jobId); - ConfiguredExecutable result = (ConfiguredExecutable) aengine - .getResults(jobId); + ConfiguredExecutable result = (ConfiguredExecutable) aengine.getResults(jobId); assertNotNull(result); System.out.println("RES:" + result); - // Some times the job could be removed from the cluster - // accounting - // before it has been reported to finish. Make sure - // to stop waiting in such case + // Some times the job could be removed from the cluster accounting before + // it has been reported to finish. Make sure to stop waiting in such case if (status == JobStatus.UNDEFINED) { break; } @@ -177,10 +159,9 @@ public class JronnTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocally() { + public void RunLocally() { try { - ConfiguredExecutable confJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Local); + ConfiguredExecutable confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Local); // For local execution use relative LocalRunner lr = new LocalRunner(confJronn); @@ -204,11 +185,10 @@ public class JronnTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocallyOnTwoCpu() { + public void RunLocallyOnTwoCpu() { try { jronn.setNCore(2); - ConfiguredExecutable confJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Local); + ConfiguredExecutable confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Local); // For local execution use relative LocalRunner lr = new LocalRunner(confJronn); @@ -234,16 +214,13 @@ public class JronnTester { @Test(groups = {AllTestSuit.test_group_runner}) public void readStatistics() { try { - ConfiguredExecutable confJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Local); + ConfiguredExecutable confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Local); // For local execution use relavive AsyncExecutor sexec = Configurator.getAsyncEngine(confJronn); String jobId = sexec.submitJob(confJronn); - FilePuller fw = FilePuller.newFilePuller( - confJronn.getWorkDirectory() + File.separator - + Jronn.getStatFile(), - FileWatcher.MIN_CHUNK_SIZE_BYTES); + String file = confJronn.getWorkDirectory() + File.separator + Jronn.getStatFile(); + FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); int count = 0; long position = 0; fw.waitForFile(4); @@ -281,17 +258,16 @@ public class JronnTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testPersistance() { + public void Persistance() { try { Jronn jronn = new Jronn(); - jronn.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); + jronn.setError("errrr.txt"); + jronn.setInput(AllTestSuit.test_input); + jronn.setOutput("outtt.txt"); assertEquals(jronn.getInput(), AllTestSuit.test_input); assertEquals(jronn.getError(), "errrr.txt"); assertEquals(jronn.getOutput(), "outtt.txt"); - ConfiguredExecutable cJronn = Configurator - .configureExecutable(jronn, Executable.ExecProvider.Local); - + ConfiguredExecutable cJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Local); SyncExecutor sexec = Configurator.getSyncEngine(cJronn); sexec.executeJob(); ConfiguredExecutable al = sexec.waitForResult(); @@ -308,8 +284,7 @@ public class JronnTester { loadedRun); // Load run configuration as ConfExecutable ConfiguredExecutable resurrectedCMuscle = (ConfiguredExecutable) cJronn - .loadRunConfiguration(new FileInputStream(new File(cJronn - .getWorkDirectory(), RunConfiguration.rconfigFile))); + .loadRunConfiguration(new FileInputStream(new File(cJronn.getWorkDirectory(), RunConfiguration.rconfigFile))); assertNotNull(resurrectedCMuscle); assertEquals(resurrectedCMuscle.getExecutable().getInput(), AllTestSuit.test_input); @@ -324,12 +299,10 @@ public class JronnTester { .configureExecutable(resurrectedCMuscle.getExecutable(), Executable.ExecProvider.Local); - sexec = Configurator.getSyncEngine(resJronn, - Executable.ExecProvider.Local); + sexec = Configurator.getSyncEngine(resJronn, Executable.ExecProvider.Local); sexec.executeJob(); al = sexec.waitForResult(); assertNotNull(al); - } catch (JobSubmissionException e) { e.printStackTrace(); fail(e.getMessage()); @@ -349,19 +322,15 @@ public class JronnTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testConfigurationLoading() { + public void ConfigurationLoading() { try { - RunnerConfig jronnConfig = ConfExecutable - .getRunnerOptions(Jronn.class); - // There is not supported parameters for Jronn - assertNull(jronnConfig); + RunnerConfig jronnConfig = ConfExecutable.getRunnerOptions(Jronn.class); + assertNull(jronnConfig); // There is no supported parameters for Jronn - PresetManager jronnPresets = ConfExecutable - .getRunnerPresets(Jronn.class); + PresetManager jronnPresets = ConfExecutable.getRunnerPresets(Jronn.class); assertNull(jronnPresets); // there is no presets - LimitsManager jronnLimits = ConfExecutable - .getRunnerLimits(Jronn.class); + LimitsManager jronnLimits = ConfExecutable.getRunnerLimits(Jronn.class); assertNotNull(jronnLimits); assertTrue(jronnLimits.getLimits().size() > 0); jronnLimits.validate(jronnPresets); @@ -377,5 +346,4 @@ public class JronnTester { fail(e.getLocalizedMessage()); } } - } diff --git a/testsrc/compbio/runner/msa/ClustalOTester.java b/testsrc/compbio/runner/msa/ClustalOTester.java index 663b81a..9712ef8 100644 --- a/testsrc/compbio/runner/msa/ClustalOTester.java +++ b/testsrc/compbio/runner/msa/ClustalOTester.java @@ -1,6 +1,8 @@ /* Copyright (c) 2009 Peter Troshin + * Copyright (c) 2013 Alexander Sherstnev * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 + * JAva Bioinformatics Analysis Web Services (JABAWS) + * @version: 2.5 * * This library is free software; you can redistribute it and/or modify it under the terms of the * Apache License version 2 as published by the Apache Software Foundation @@ -29,22 +31,20 @@ import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.text.ParseException; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.xml.bind.JAXBException; -import javax.xml.bind.ValidationException; import org.ggf.drmaa.DrmaaException; import org.ggf.drmaa.JobInfo; import org.testng.annotations.Test; -import compbio.data.sequence.FastaSequence; import compbio.engine.AsyncExecutor; import compbio.engine.Configurator; import compbio.engine.FilePuller; import compbio.engine.SyncExecutor; +import compbio.engine.client.Util; import compbio.engine.client.ConfExecutable; import compbio.engine.client.ConfiguredExecutable; import compbio.engine.client.Executable; @@ -63,89 +63,25 @@ import compbio.metadata.JobExecutionException; import compbio.metadata.JobStatus; import compbio.metadata.JobSubmissionException; import compbio.metadata.LimitsManager; -import compbio.metadata.PresetManager; import compbio.metadata.ResultNotAvailableException; import compbio.metadata.RunnerConfig; import compbio.runner.OptionCombinator; -import compbio.runner.Util; import compbio.util.FileWatcher; import compbio.util.SysPrefs; public class ClustalOTester { - static final String clustalConfigFile = AllTestSuit.TEST_DATA_PATH - + "ClustaloParameters.xml"; + static final String clustalConfigFile = AllTestSuit.TEST_DATA_PATH + "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() { - ClustalO clustal = new ClustalO(); - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); - clustal.setInput(AllTestSuit.test_input) - .setOutput(cluster_test_outfile); - - try { - - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal); - JobRunner runner = JobRunner.getInstance(confClustal); - // ClusterSession csession = JobRunner.getSession(); - assertNotNull(runner); - runner.executeJob(); - // assertNotNull("JobId is null", jobId1); - JobStatus status = runner.getJobStatus(); - assertTrue(status == JobStatus.PENDING - || status == JobStatus.RUNNING); - JobInfo info = runner.getJobInfo(); - assertNotNull(info); - StatisticManager sm = new StatisticManager(info); - assertNotNull(sm); - try { - String exits = sm.getExitStatus(); - assertNotNull("Exit status is null", exits); - // cut 4 trailing zeros from the number - int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits) - .intValue(); - assertEquals(0, exitsInt); - System.out.println(sm.getAllStats()); - - } catch (ParseException e) { - e.printStackTrace(); - fail("Parse Exception: " + e.getMessage()); - } - // At present the task directory could not be completely removed - // @see JobRunner.cleanup() - assertFalse(runner.cleanup(), - "Could not remove some files whilst cleaning up "); - assertTrue(sm.hasExited()); - assertFalse(sm.wasAborted()); - assertFalse(sm.hasDump()); - assertFalse(sm.hasSignaled()); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (DrmaaException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } - } - @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocally() { + public void RunLocally() { ClustalO clustal = new ClustalO(); clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile); try { - // For local execution use relavive - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, Executable.ExecProvider.Local); + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal, Executable.ExecProvider.Local); LocalRunner lr = new LocalRunner(confClustal); lr.executeJob(); confClustal = (ConfiguredExecutable) lr.waitForResult(); @@ -163,26 +99,15 @@ public class ClustalOTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testConfigurationLoading() { + public void ConfigurationLoading() { try { - RunnerConfig clustalConfig = ConfExecutable - .getRunnerOptions(ClustalO.class); + RunnerConfig clustalConfig = ConfExecutable.getRunnerOptions(ClustalO.class); assertNotNull(clustalConfig); assertTrue(clustalConfig.getArguments().size() > 0); - /* Unsupported - PresetManager clustalPresets = ConfExecutable - .getRunnerPresets(ClustalO.class); - assertNotNull(clustalPresets); - assertTrue(clustalPresets.getPresets().size() > 0); - clustalPresets.validate(clustalConfig); - */ - LimitsManager clustalLimits = ConfExecutable - .getRunnerLimits(ClustalO.class); + LimitsManager clustalLimits = ConfExecutable.getRunnerLimits(ClustalO.class); assertNotNull(clustalLimits); assertTrue(clustalLimits.getLimits().size() > 0); - //clustalLimits.validate(clustalPresets); - } catch (FileNotFoundException e) { e.printStackTrace(); fail(e.getLocalizedMessage()); @@ -193,35 +118,28 @@ public class ClustalOTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testOptionsLocally() { + public void OptionsLocally() { try { - - RunnerConfigMarshaller clustalmarsh = new RunnerConfigMarshaller( - RunnerConfig.class); - - RunnerConfig clustalConfig = clustalmarsh.read( - new FileInputStream(new File(clustalConfigFile)), - RunnerConfig.class); + RunnerConfigMarshaller clustalmarsh = new RunnerConfigMarshaller(RunnerConfig.class); + RunnerConfig clustalConfig = clustalmarsh.read(new FileInputStream(new File(clustalConfigFile)), RunnerConfig.class); OptionCombinator clustalOpc = new OptionCombinator(clustalConfig); List options = clustalOpc.getOptionsAtRandom(); for (int i = 0; i < options.size(); i++) { System.out.println("Using options: " + options); ClustalO clustal = new ClustalO(); - clustal.setInput(AllTestSuit.test_input) - .setOutput(test_outfile); + clustal.setInput(AllTestSuit.test_input); + clustal.setOutput(test_outfile); // For local execution use relavive - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, ExecProvider.Local); + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal, ExecProvider.Local); // Add options to the executable confClustal.addParameters(options); LocalRunner lr = new LocalRunner(confClustal); lr.executeJob(); - confClustal = (ConfiguredExecutable) lr - .waitForResult(); + confClustal = (ConfiguredExecutable) lr.waitForResult(); assertNotNull(confClustal.getResults()); Collections.shuffle(options); } @@ -244,13 +162,12 @@ public class ClustalOTester { } } - public static final void main(String[] args) throws JobSubmissionException, - JobExecutionException, InterruptedException { + public static final void main(String[] args) + throws JobSubmissionException, JobExecutionException, InterruptedException { ClustalO clustal = new ClustalO(); clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile); // For local execution use relavive - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal); + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal); AsyncExecutor lr = new AsyncLocalRunner(); lr.submitJob(confClustal); Thread.sleep(3000); @@ -258,16 +175,16 @@ public class ClustalOTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void testPersistance() { + public void Persistance() { try { ClustalO clustal = new ClustalO(); - clustal.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); + clustal.setError("errrr.txt"); + clustal.setInput(AllTestSuit.test_input); + clustal.setOutput("outtt.txt"); assertEquals(clustal.getInput(), AllTestSuit.test_input); assertEquals(clustal.getError(), "errrr.txt"); assertEquals(clustal.getOutput(), "outtt.txt"); - ConfiguredExecutable cClustal = Configurator - .configureExecutable(clustal, Executable.ExecProvider.Local); + ConfiguredExecutable cClustal = Configurator.configureExecutable(clustal, Executable.ExecProvider.Local); SyncExecutor sexec = Configurator.getSyncEngine(cClustal); sexec.executeJob(); @@ -277,9 +194,7 @@ public class ClustalOTester { assertTrue(cClustal.saveRunConfiguration()); // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cClustal - .getWorkDirectory(), RunConfiguration.rconfigFile))); + RunConfiguration loadedRun = RunConfiguration.load(new FileInputStream(new File(cClustal.getWorkDirectory(), RunConfiguration.rconfigFile))); assertTrue(((ConfExecutable) cClustal) .getRunConfiguration().equals(loadedRun)); // Load run configuration as ConfExecutable @@ -295,8 +210,7 @@ public class ClustalOTester { .configureExecutable(resurrectedCclustal.getExecutable(), Executable.ExecProvider.Local); - sexec = Configurator.getSyncEngine(resclustal, - Executable.ExecProvider.Local); + sexec = Configurator.getSyncEngine(resclustal, Executable.ExecProvider.Local); sexec.executeJob(); cClustal = (ConfiguredExecutable) sexec.waitForResult(); assertNotNull(cClustal.getResults()); @@ -320,35 +234,40 @@ public class ClustalOTester { } @Test(groups = {AllTestSuit.test_group_runner}) - public void readStatistics() { + public void readStatistics() + throws InterruptedException { try { - ClustalO clustal = new ClustalO().setInput(AllTestSuit.test_input) - .setOutput(test_outfile); - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, Executable.ExecProvider.Local); - - AsyncExecutor sexec = Configurator.getAsyncEngine(confClustal); - String jobId = sexec.submitJob(confClustal); - FilePuller fw = FilePuller.newFilePuller( - confClustal.getWorkDirectory() + File.separator - + ClustalW.getStatFile(), - FileWatcher.MIN_CHUNK_SIZE_BYTES); + ClustalO al = new ClustalO(); + al.setInput(AllTestSuit.test_input); + al.setOutput(test_outfile); + ConfiguredExecutable confal = Configurator.configureExecutable(al, Executable.ExecProvider.Local); + + AsyncExecutor sexec = Configurator.getAsyncEngine(confal); + String jobId = sexec.submitJob(confal); + String file = Util.getFullPath(confal.getWorkDirectory(), ClustalW.getStatFile()); + FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); int count = 0; long position = 0; fw.waitForFile(4); - while (!(sexec.getJobStatus(jobId) == JobStatus.FINISHED - || sexec.getJobStatus(jobId) == JobStatus.FAILED || sexec - .getJobStatus(jobId) == JobStatus.UNDEFINED) - || fw.hasMoreData()) { - ChunkHolder ch = fw.pull(position); - String chunk = ch.getChunk(); - position = ch.getNextPosition(); - System.out.print(chunk); + JobStatus status = sexec.getJobStatus(jobId); + while (status != JobStatus.FINISHED || fw.hasMoreData()) { + if (fw.hasMoreData()) { + ChunkHolder ch = fw.pull(position); + String chunk = ch.getChunk(); + position = ch.getNextPosition(); + } count++; + if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) { + fail("job " + jobId +" failed!"); + break; + } + Thread.sleep(200); + status = sexec.getJobStatus(jobId); + System.out.println("CLustalO: Job status = " + status + ", file status = " + fw.hasMoreData()); } assertTrue(count > 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); + ConfiguredExecutable al2 = sexec.getResults(jobId); + assertNotNull(al2.getResults()); } catch (JobSubmissionException e) { e.printStackTrace(); fail(e.getMessage()); @@ -361,32 +280,74 @@ public class ClustalOTester { } } - @Test(groups = {AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner}) + @Test(groups = {AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner}) + public void RunOnCluster() { + ClustalO clustal = new ClustalO(); + assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); + clustal.setInput(AllTestSuit.test_input).setOutput(cluster_test_outfile); + try { + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal); + JobRunner runner = JobRunner.getInstance(confClustal); + // ClusterSession csession = JobRunner.getSession(); + assertNotNull(runner); + runner.executeJob(); + // assertNotNull("JobId is null", jobId1); + JobStatus status = runner.getJobStatus(); + assertTrue(status == JobStatus.PENDING || status == JobStatus.RUNNING); + JobInfo info = runner.getJobInfo(); + assertNotNull(info); + StatisticManager sm = new StatisticManager(info); + assertNotNull(sm); + try { + String exits = sm.getExitStatus(); + assertNotNull("Exit status is null", exits); + // cut 4 trailing zeros from the number + int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits).intValue(); + assertEquals(0, exitsInt); + System.out.println(sm.getAllStats()); + } catch (ParseException e) { + e.printStackTrace(); + fail("Parse Exception: " + e.getMessage()); + } + // At present the task directory could not be completely removed + // @see JobRunner.cleanup() + assertFalse(runner.cleanup(), "Could not remove some files whilst cleaning up "); + assertTrue(sm.hasExited()); + assertFalse(sm.wasAborted()); + assertFalse(sm.hasDump()); + assertFalse(sm.hasSignaled()); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } catch (JobExecutionException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } catch (DrmaaException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } + } + + @Test(groups = {AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner}) public void readStatisticsClusterExecution() { try { - ClustalO clustal = new ClustalO().setInput(AllTestSuit.test_input) - .setOutput(test_outfile); - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, - Executable.ExecProvider.Cluster); + ClustalO clustal = new ClustalO().setInput(AllTestSuit.test_input).setOutput(test_outfile); + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal, Executable.ExecProvider.Cluster); AsyncExecutor sexec = Configurator.getAsyncEngine(confClustal); String jobId = sexec.submitJob(confClustal); - FilePuller fw = FilePuller.newFilePuller( - confClustal.getWorkDirectory() + File.separator - + ClustalW.getStatFile(), - FileWatcher.MIN_CHUNK_SIZE_BYTES); + String file = Util.getFullPath(confClustal.getWorkDirectory(), ClustalW.getStatFile()); + FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); int count = 0; long position = 0; + int maxloopcount = 108000; // max waiting time = 6h*60m*60s/0.2(one loop sleep) fw.waitForFile(200); /* * Under certain circumstances DRMAA could report the status wrongly - * thus this loop never ends TODO deal with this! + * thus this loop never ends. maxloopcount ensures hard stop of the loop... */ - while (!(sexec.getJobStatus(jobId) == JobStatus.FINISHED || sexec - .getJobStatus(jobId) == JobStatus.FAILED) - || fw.hasMoreData()) { + while (!( sexec.getJobStatus(jobId) == JobStatus.FINISHED || sexec.getJobStatus(jobId) == JobStatus.FAILED) + || count < maxloopcount || fw.hasMoreData()) { ChunkHolder ch = fw.pull(position); String chunk = ch.getChunk(); position = ch.getNextPosition(); @@ -394,8 +355,7 @@ public class ClustalOTester { count++; Thread.sleep(200); if (sexec.getJobStatus(jobId) == JobStatus.UNDEFINED) { - System.out.println("DRMAA reported wrong status for job + " - + jobId + " continue anyway!"); + System.out.println("DRMAA reported wrong status for job + " + jobId + " continue anyway!"); break; } } diff --git a/testsrc/compbio/runner/msa/ClustalWTester.java b/testsrc/compbio/runner/msa/ClustalWTester.java index 562919e..44f5ec0 100644 --- a/testsrc/compbio/runner/msa/ClustalWTester.java +++ b/testsrc/compbio/runner/msa/ClustalWTester.java @@ -1,6 +1,8 @@ /* Copyright (c) 2009 Peter Troshin + * Copyright (c) 2013 Alexander Sherstnev * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 + * JAva Bioinformatics Analysis Web Services (JABAWS) + * @version: 2.5 * * This library is free software; you can redistribute it and/or modify it under the terms of the * Apache License version 2 as published by the Apache Software Foundation @@ -74,79 +76,18 @@ import compbio.util.SysPrefs; public class ClustalWTester { - static final String clustalConfigFile = AllTestSuit.TEST_DATA_PATH - + "ClustalParameters.xml"; + 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"; - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner }) - public void testRunOnCluster() { - ClustalW clustal = new ClustalW(); - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); - clustal.setInput(AllTestSuit.test_input) - .setOutput(cluster_test_outfile); - - try { - - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal); - JobRunner runner = JobRunner.getInstance(confClustal); - // ClusterSession csession = JobRunner.getSession(); - assertNotNull(runner); - runner.executeJob(); - // assertNotNull("JobId is null", jobId1); - JobStatus status = runner.getJobStatus(); - assertTrue(status == JobStatus.PENDING - || status == JobStatus.RUNNING); - JobInfo info = runner.getJobInfo(); - assertNotNull(info); - StatisticManager sm = new StatisticManager(info); - assertNotNull(sm); - try { - String exits = sm.getExitStatus(); - assertNotNull("Exit status is null", exits); - // cut 4 trailing zeros from the number - int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits) - .intValue(); - assertEquals(0, exitsInt); - System.out.println(sm.getAllStats()); - - } catch (ParseException e) { - e.printStackTrace(); - fail("Parse Exception: " + e.getMessage()); - } - // At present the task directory could not be completely removed - // @see JobRunner.cleanup() - assertFalse(runner.cleanup(), - "Could not remove some files whilst cleaning up "); - assertTrue(sm.hasExited()); - assertFalse(sm.wasAborted()); - assertFalse(sm.hasDump()); - assertFalse(sm.hasSignaled()); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (DrmaaException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } - } - @Test(groups = { AllTestSuit.test_group_runner }) - public void testRunLocally() { + public void RunLocally() { ClustalW clustal = new ClustalW(); clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile); try { // For local execution use relavive - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, Executable.ExecProvider.Local); + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal, Executable.ExecProvider.Local); LocalRunner lr = new LocalRunner(confClustal); lr.executeJob(); confClustal = (ConfiguredExecutable) lr.waitForResult(); @@ -164,7 +105,7 @@ public class ClustalWTester { } @Test(groups = { AllTestSuit.test_group_runner }) - public void testRunWithMatrix() { + public void RunWithMatrix() { ClustalW clustal = new ClustalW(); clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile); clustal.setParameter("-matrix=BLOSUM62"); @@ -189,26 +130,22 @@ public class ClustalWTester { } } - @Test(groups = { AllTestSuit.test_group_runner }) - public void testConfigurationLoading() { + @Test(groups = {AllTestSuit.test_group_runner}) + public void ConfigurationLoading() { try { - RunnerConfig clustalConfig = ConfExecutable - .getRunnerOptions(ClustalW.class); + RunnerConfig clustalConfig = ConfExecutable.getRunnerOptions(ClustalW.class); assertNotNull(clustalConfig); assertTrue(clustalConfig.getArguments().size() > 0); - PresetManager clustalPresets = ConfExecutable - .getRunnerPresets(ClustalW.class); + PresetManager clustalPresets = ConfExecutable.getRunnerPresets(ClustalW.class); assertNotNull(clustalPresets); assertTrue(clustalPresets.getPresets().size() > 0); clustalPresets.validate(clustalConfig); - LimitsManager clustalLimits = ConfExecutable - .getRunnerLimits(ClustalW.class); + LimitsManager clustalLimits = ConfExecutable.getRunnerLimits(ClustalW.class); assertNotNull(clustalLimits); assertTrue(clustalLimits.getLimits().size() > 0); clustalLimits.validate(clustalPresets); - } catch (FileNotFoundException e) { e.printStackTrace(); fail(e.getLocalizedMessage()); @@ -222,39 +159,30 @@ public class ClustalWTester { } @Test(groups = { AllTestSuit.test_group_runner }) - public void testOptionsLocally() { + public void OptionsLocally() { try { - - RunnerConfigMarshaller clustalmarsh = new RunnerConfigMarshaller( - RunnerConfig.class); - - RunnerConfig clustalConfig = clustalmarsh.read( - new FileInputStream(new File(clustalConfigFile)), - RunnerConfig.class); + RunnerConfigMarshaller clustalmarsh = new RunnerConfigMarshaller(RunnerConfig.class); + RunnerConfig clustalConfig = clustalmarsh.read(new FileInputStream(new File(clustalConfigFile)),RunnerConfig.class); OptionCombinator clustalOpc = new OptionCombinator(clustalConfig); List options = clustalOpc.getOptionsAtRandom(); for (int i = 0; i < options.size(); i++) { System.out.println("Using options: " + options); ClustalW clustal = new ClustalW(); - clustal.setInput(AllTestSuit.test_input) - .setOutput(test_outfile); + clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile); // For local execution use relavive - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, ExecProvider.Local); + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal, ExecProvider.Local); // Add options to the executable confClustal.addParameters(options); LocalRunner lr = new LocalRunner(confClustal); lr.executeJob(); - confClustal = (ConfiguredExecutable) lr - .waitForResult(); + confClustal = (ConfiguredExecutable) lr.waitForResult(); assertNotNull(confClustal.getResults()); Collections.shuffle(options); } - } catch (JobSubmissionException e) { e.printStackTrace(); fail(e.getLocalizedMessage()); @@ -273,28 +201,25 @@ public class ClustalWTester { } } - public static final void main(String[] args) throws JobSubmissionException, - JobExecutionException, InterruptedException { + public static final void main(String[] args) + throws JobSubmissionException, JobExecutionException, InterruptedException { ClustalW clustal = new ClustalW(); clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile); // For local execution use relavive - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal); + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal); AsyncExecutor lr = new AsyncLocalRunner(); lr.submitJob(confClustal); Thread.sleep(3000); LocalExecutorService.shutDown(); } + // disabled @Test(enabled = false) - public void testAddParameters() { + public void AddParameters() { ArrayList seqs = new ArrayList(); - FastaSequence fs = new FastaSequence("tests1", - "aqtctcatcatctcatctgcccccgggttatgagtagtacgcatctacg"); - FastaSequence fs2 = new FastaSequence("tests2", - "aqtctcatcatctcatctgcccccgggttatgagtagtacgcatctacg"); - FastaSequence fs3 = new FastaSequence("tests3", - "aqtctcatcatctcatctgcccccgggttatgagtagtacgcatctacg"); + 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); @@ -342,16 +267,16 @@ public class ClustalWTester { } @Test(groups = { AllTestSuit.test_group_runner }) - public void testPersistance() { + public void Persistance() { try { ClustalW clustal = new ClustalW(); - clustal.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); + clustal.setError("errrr.txt"); + clustal.setInput(AllTestSuit.test_input); + clustal.setOutput("outtt.txt"); assertEquals(clustal.getInput(), AllTestSuit.test_input); assertEquals(clustal.getError(), "errrr.txt"); assertEquals(clustal.getOutput(), "outtt.txt"); - ConfiguredExecutable cClustal = Configurator - .configureExecutable(clustal, Executable.ExecProvider.Local); + ConfiguredExecutable cClustal = Configurator.configureExecutable(clustal, Executable.ExecProvider.Local); SyncExecutor sexec = Configurator.getSyncEngine(cClustal); sexec.executeJob(); @@ -379,12 +304,10 @@ public class ClustalWTester { .configureExecutable(resurrectedCclustal.getExecutable(), Executable.ExecProvider.Local); - sexec = Configurator.getSyncEngine(resclustal, - Executable.ExecProvider.Local); + sexec = Configurator.getSyncEngine(resclustal, Executable.ExecProvider.Local); sexec.executeJob(); cClustal = (ConfiguredExecutable) sexec.waitForResult(); assertNotNull(cClustal.getResults()); - } catch (JobSubmissionException e) { e.printStackTrace(); fail(e.getMessage()); @@ -406,17 +329,13 @@ public class ClustalWTester { @Test(groups = { AllTestSuit.test_group_runner }) public void readStatistics() { try { - ClustalW clustal = new ClustalW().setInput(AllTestSuit.test_input) - .setOutput(test_outfile); - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, Executable.ExecProvider.Local); + ClustalW clustal = new ClustalW().setInput(AllTestSuit.test_input).setOutput(test_outfile); + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal, Executable.ExecProvider.Local); AsyncExecutor sexec = Configurator.getAsyncEngine(confClustal); String jobId = sexec.submitJob(confClustal); - FilePuller fw = FilePuller.newFilePuller(confClustal - .getWorkDirectory() - + File.separator + ClustalW.getStatFile(), - FileWatcher.MIN_CHUNK_SIZE_BYTES); + String file = confClustal.getWorkDirectory() + File.separator + ClustalW.getStatFile(); + FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); int count = 0; long position = 0; fw.waitForFile(4); @@ -445,22 +364,67 @@ public class ClustalWTester { } } - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner }) + @Test(groups = { AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner }) + public void RunOnCluster() { + ClustalW clustal = new ClustalW(); + assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); + clustal.setInput(AllTestSuit.test_input).setOutput(cluster_test_outfile); + + try { + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal); + JobRunner runner = JobRunner.getInstance(confClustal); + // ClusterSession csession = JobRunner.getSession(); + assertNotNull(runner); + runner.executeJob(); + // assertNotNull("JobId is null", jobId1); + JobStatus status = runner.getJobStatus(); + assertTrue(status == JobStatus.PENDING || status == JobStatus.RUNNING); + JobInfo info = runner.getJobInfo(); + assertNotNull(info); + StatisticManager sm = new StatisticManager(info); + assertNotNull(sm); + try { + String exits = sm.getExitStatus(); + assertNotNull("Exit status is null", exits); + // cut 4 trailing zeros from the number + int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits).intValue(); + assertEquals(0, exitsInt); + System.out.println(sm.getAllStats()); + } catch (ParseException e) { + e.printStackTrace(); + fail("Parse Exception: " + e.getMessage()); + } + // At present the task directory could not be completely removed + // @see JobRunner.cleanup() + assertFalse(runner.cleanup(), "Could not remove some files whilst cleaning up "); + assertTrue(sm.hasExited()); + assertFalse(sm.wasAborted()); + assertFalse(sm.hasDump()); + assertFalse(sm.hasSignaled()); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } catch (JobExecutionException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } catch (DrmaaException e) { + e.printStackTrace(); + fail("DrmaaException caught:" + e.getMessage()); + } + } + + @Test(groups = { AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner }) public void readStatisticsClusterExecution() { try { - ClustalW clustal = new ClustalW().setInput(AllTestSuit.test_input) - .setOutput(test_outfile); - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, - Executable.ExecProvider.Cluster); + ClustalW clustal = new ClustalW(); + clustal.setInput(AllTestSuit.test_input); + clustal.setOutput(test_outfile); + ConfiguredExecutable confClustal = Configurator.configureExecutable(clustal, Executable.ExecProvider.Cluster); AsyncExecutor sexec = Configurator.getAsyncEngine(confClustal); String jobId = sexec.submitJob(confClustal); - FilePuller fw = FilePuller.newFilePuller(confClustal - .getWorkDirectory() - + File.separator + ClustalW.getStatFile(), - FileWatcher.MIN_CHUNK_SIZE_BYTES); + String file = confClustal.getWorkDirectory() + File.separator + ClustalW.getStatFile(); + FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); int count = 0; long position = 0; fw.waitForFile(200); diff --git a/testsrc/compbio/runner/msa/TcoffeeTester.java b/testsrc/compbio/runner/msa/TcoffeeTester.java index 659103d..f0f07bf 100644 --- a/testsrc/compbio/runner/msa/TcoffeeTester.java +++ b/testsrc/compbio/runner/msa/TcoffeeTester.java @@ -1,6 +1,8 @@ /* Copyright (c) 2009 Peter Troshin + * Copyright (c) 2013 Alexander Sherstnev * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 + * Java Bioinformatics Analysis Web Services (JABAWS) + * @version: 2.5 * * This library is free software; you can redistribute it and/or modify it under the terms of the * Apache License version 2 as published by the Apache Software Foundation @@ -27,6 +29,7 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.Arrays; import javax.xml.bind.ValidationException; @@ -43,6 +46,7 @@ import compbio.engine.client.ConfiguredExecutable; import compbio.engine.client.Executable; import compbio.engine.client.RunConfiguration; import compbio.engine.cluster.drmaa.JobRunner; +import compbio.engine.local.LocalRunner; import compbio.metadata.AllTestSuit; import compbio.metadata.ChunkHolder; import compbio.metadata.JobExecutionException; @@ -53,35 +57,45 @@ import compbio.metadata.PresetManager; import compbio.metadata.ResultNotAvailableException; import compbio.metadata.RunnerConfig; import compbio.runner.msa.Tcoffee; +import compbio.runner.predictors.Jpred; import compbio.util.FileWatcher; +import compbio.util.SysPrefs; public class TcoffeeTester { private Tcoffee tcoffee; + public static final String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() + File.separator; + public static String test_output = "tcoffee.out"; + public static String test_input = CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata" + File.separator + "TO1381.fasta"; - @BeforeMethod(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) + @BeforeMethod(groups = {AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows}) public void init() { tcoffee = new Tcoffee(); - tcoffee.setInput(AllTestSuit.test_input).setOutput("tcoffee.out") - .setError("tcoffee.progress"); + tcoffee.setInput(test_input); + tcoffee.setOutput(test_output); + tcoffee.setError("tcoffee.progress"); + //System.out.println("Tcoffee has been configured!"); } - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testExecute() { + @Test(groups = { AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) + public void RunLocally() { try { - ConfiguredExecutable ctcoffee = Configurator - .configureExecutable(tcoffee, Executable.ExecProvider.Local); + ConfiguredExecutable ctcoffee = Configurator.configureExecutable(tcoffee, Executable.ExecProvider.Local); // matrix does not appear to work // ctcoffee.getParameters().setParam("-matrix","BLOSUM62"); + SyncExecutor sexecutor = Configurator.getSyncEngine(ctcoffee); sexecutor.executeJob(); ConfiguredExecutable al = sexecutor.waitForResult(); Alignment align = al.getResults(); assertNotNull(align); - // System.out.println("Tcoffee stat file: " + tcoffee.getError()); +// LocalRunner sexecutor = new LocalRunner(ctcoffee); +// sexecutor.executeJob(); +// ConfiguredExecutable al = sexecutor.waitForResult(); +// Alignment align = al.getResults(); +// assertNotNull(align); + } catch (JobSubmissionException e) { e.printStackTrace(); fail(e.getMessage()); @@ -94,31 +108,28 @@ public class TcoffeeTester { } } - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) + @Test(groups = {AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows}) public void readStatistics() { try { Tcoffee tcoffee = new Tcoffee().setInput(AllTestSuit.test_input); - ConfiguredExecutable confTcoffee = Configurator - .configureExecutable(tcoffee, Executable.ExecProvider.Local); + ConfiguredExecutable confTcoffee = Configurator.configureExecutable(tcoffee, Executable.ExecProvider.Local); AsyncExecutor sexec = Configurator.getAsyncEngine(confTcoffee); String jobId = sexec.submitJob(confTcoffee); - FilePuller fw = FilePuller.newFilePuller(confTcoffee - .getWorkDirectory() - + File.separator + tcoffee.getError(), - FileWatcher.MIN_CHUNK_SIZE_BYTES); + String file = confTcoffee.getWorkDirectory() + File.separator + tcoffee.getError(); + FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); int count = 0; long position = 0; fw.waitForFile(4); - while (!(sexec.getJobStatus(jobId) == JobStatus.FINISHED || sexec - .getJobStatus(jobId) == JobStatus.FAILED || sexec - .getJobStatus(jobId) == JobStatus.UNDEFINED) - || fw.hasMoreData()) { - ChunkHolder ch = fw.pull(position); - String chunk = ch.getChunk(); - position = ch.getNextPosition(); - System.out.print(chunk); + while (!(sexec.getJobStatus(jobId) == JobStatus.FINISHED || + sexec.getJobStatus(jobId) == JobStatus.FAILED || + sexec.getJobStatus(jobId) == JobStatus.UNDEFINED) || fw.hasMoreData()) { + if (fw.hasMoreData()) { + ChunkHolder ch = fw.pull(position); + String chunk = ch.getChunk(); + position = ch.getNextPosition(); + System.out.print(chunk); + } count++; } assertTrue(count > 1); @@ -136,36 +147,9 @@ public class TcoffeeTester { } } - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) - public void testClusterExecute() { - try { - ConfiguredExecutable cmafft = Configurator - .configureExecutable(tcoffee, - Executable.ExecProvider.Cluster); - JobRunner sexecutor = (JobRunner) Configurator.getSyncEngine( - cmafft, Executable.ExecProvider.Cluster); - sexecutor.executeJob(); - ConfiguredExecutable al = sexecutor.waitForResult(); - Alignment align = al.getResults(); - assertNotNull(align); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testNcore() { + @Test(groups = { AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) + public void SetNcore() { Tcoffee tc = new Tcoffee(); - // System.out.println("TCPRM:" + tc.getParameters(null)); assertEquals(tc.getParameters(null).size(), 3); tc.setNCore(2); assertEquals(2, tc.getNCore()); @@ -175,19 +159,18 @@ public class TcoffeeTester { assertEquals(tc.getParameters(null).size(), 3); } - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) - public void testPersistance() { + @Test(groups = { AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) + public void Persistance() { try { Tcoffee tcoffee = new Tcoffee(); - tcoffee.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); + tcoffee.setError("errrr.txt"); + tcoffee.setInput(AllTestSuit.test_input); + tcoffee.setOutput("outtt.txt"); assertEquals(tcoffee.getInput(), AllTestSuit.test_input); assertEquals(tcoffee.getError(), "errrr.txt"); assertEquals(tcoffee.getOutput(), "outtt.txt"); - ConfiguredExecutable ctcofee = Configurator - .configureExecutable(tcoffee, Executable.ExecProvider.Local); + ConfiguredExecutable ctcofee = Configurator.configureExecutable(tcoffee, Executable.ExecProvider.Local); SyncExecutor sexec = Configurator.getSyncEngine(ctcofee); sexec.executeJob(); ConfiguredExecutable al = sexec.waitForResult(); @@ -196,26 +179,21 @@ public class TcoffeeTester { assertTrue(ctcofee.saveRunConfiguration()); // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(ctcofee - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals(((ConfExecutable) ctcofee) - .getRunConfiguration(), loadedRun); + RunConfiguration loadedRun = RunConfiguration.load(new FileInputStream(new File(ctcofee.getWorkDirectory(), RunConfiguration.rconfigFile))); + assertEquals(((ConfExecutable) ctcofee).getRunConfiguration(), loadedRun); + // Load run configuration as ConfExecutable ConfiguredExecutable resurrectedCTcoffee = (ConfiguredExecutable) ctcofee - .loadRunConfiguration(new FileInputStream(new File(ctcofee - .getWorkDirectory(), RunConfiguration.rconfigFile))); + .loadRunConfiguration(new FileInputStream(new File(ctcofee.getWorkDirectory(), RunConfiguration.rconfigFile))); assertNotNull(resurrectedCTcoffee); + // See in details whether executables are the same assertEquals(resurrectedCTcoffee.getExecutable(), tcoffee); // Finally rerun the job in the new task directory - ConfiguredExecutable restcoffee = Configurator - .configureExecutable(resurrectedCTcoffee.getExecutable(), - Executable.ExecProvider.Local); + ConfiguredExecutable restcoffee = Configurator.configureExecutable(resurrectedCTcoffee.getExecutable(), Executable.ExecProvider.Local); - sexec = Configurator.getSyncEngine(restcoffee, - Executable.ExecProvider.Local); + sexec = Configurator.getSyncEngine(restcoffee,Executable.ExecProvider.Local); sexec.executeJob(); al = sexec.waitForResult(); assertNotNull(al); @@ -239,21 +217,18 @@ public class TcoffeeTester { } @Test(groups = { AllTestSuit.test_group_runner }) - public void testConfigurationLoading() { + public void ConfigurationLoading() { try { - RunnerConfig tcoffeeConfig = ConfExecutable - .getRunnerOptions(Tcoffee.class); + RunnerConfig tcoffeeConfig = ConfExecutable.getRunnerOptions(Tcoffee.class); assertNotNull(tcoffeeConfig); assertTrue(tcoffeeConfig.getArguments().size() > 0); - PresetManager tcoffeePresets = ConfExecutable - .getRunnerPresets(Tcoffee.class); + PresetManager tcoffeePresets = ConfExecutable.getRunnerPresets(Tcoffee.class); assertNotNull(tcoffeePresets); assertTrue(tcoffeePresets.getPresets().size() > 0); tcoffeePresets.validate(tcoffeeConfig); - LimitsManager tcoffeeLimits = ConfExecutable - .getRunnerLimits(Tcoffee.class); + LimitsManager tcoffeeLimits = ConfExecutable.getRunnerLimits(Tcoffee.class); assertNotNull(tcoffeeLimits); assertTrue(tcoffeeLimits.getLimits().size() > 0); tcoffeeLimits.validate(tcoffeePresets); @@ -267,6 +242,27 @@ public class TcoffeeTester { e.printStackTrace(); fail(e.getLocalizedMessage()); } + } + // disabled + @Test(enabled=false,groups = { AllTestSuit.test_group_cluster, AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) + public void RunOnCluster() { + try { + ConfiguredExecutable cmafft = Configurator.configureExecutable(tcoffee, Executable.ExecProvider.Cluster); + JobRunner sexecutor = (JobRunner) Configurator.getSyncEngine(cmafft, Executable.ExecProvider.Cluster); + sexecutor.executeJob(); + ConfiguredExecutable al = sexecutor.waitForResult(); + Alignment align = al.getResults(); + assertNotNull(align); + } catch (JobSubmissionException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (JobExecutionException e) { + e.printStackTrace(); + fail(e.getMessage()); + } catch (ResultNotAvailableException e) { + e.printStackTrace(); + fail(e.getMessage()); + } } }