From 8720df2243a64c5f2fffbaf436724883fd897f99 Mon Sep 17 00:00:00 2001 From: Sasha Sherstnev Date: Thu, 24 Oct 2013 15:13:39 +0100 Subject: [PATCH] Remove JABAWS testing code --- .../compbio/casscode/conservation/AAConTester.java | 387 ---------------- .../compbio/casscode/disorder/DisemblTester.java | 317 -------------- .../compbio/casscode/disorder/GlobPlotTester.java | 312 ------------- .../compbio/casscode/disorder/IUPredTester.java | 383 ---------------- testsrc/compbio/casscode/disorder/JronnTester.java | 349 --------------- testsrc/compbio/casscode/msa/ClustalOTester.java | 379 ---------------- .../casscode/msa/ClustalWParametersTester.java | 265 ----------- testsrc/compbio/casscode/msa/ClustalWTester.java | 461 -------------------- testsrc/compbio/casscode/msa/LimitTester.java | 146 ------- .../casscode/msa/MafftParametersTester.java | 268 ------------ testsrc/compbio/casscode/msa/MafftTester.java | 356 --------------- .../casscode/msa/MuscleParametersTester.java | 268 ------------ testsrc/compbio/casscode/msa/MuscleTester.java | 334 -------------- .../casscode/msa/ProbconsParametersTester.java | 248 ----------- testsrc/compbio/casscode/msa/ProbconsTester.java | 262 ----------- .../casscode/msa/TcoffeeParametersTester.java | 243 ----------- testsrc/compbio/casscode/msa/TcoffeeTester.java | 268 ------------ .../msa/mafftParams_modification_for_testing.txt | 3 - .../compbio/casscode/predictors/JpredTester.java | 362 --------------- .../structure/RNAalifoldParametersTester.java | 448 ------------------- .../casscode/structure/RNAalifoldTester.java | 119 ----- 21 files changed, 6178 deletions(-) delete mode 100644 testsrc/compbio/casscode/conservation/AAConTester.java delete mode 100644 testsrc/compbio/casscode/disorder/DisemblTester.java delete mode 100644 testsrc/compbio/casscode/disorder/GlobPlotTester.java delete mode 100644 testsrc/compbio/casscode/disorder/IUPredTester.java delete mode 100644 testsrc/compbio/casscode/disorder/JronnTester.java delete mode 100644 testsrc/compbio/casscode/msa/ClustalOTester.java delete mode 100644 testsrc/compbio/casscode/msa/ClustalWParametersTester.java delete mode 100644 testsrc/compbio/casscode/msa/ClustalWTester.java delete mode 100644 testsrc/compbio/casscode/msa/LimitTester.java delete mode 100644 testsrc/compbio/casscode/msa/MafftParametersTester.java delete mode 100644 testsrc/compbio/casscode/msa/MafftTester.java delete mode 100644 testsrc/compbio/casscode/msa/MuscleParametersTester.java delete mode 100644 testsrc/compbio/casscode/msa/MuscleTester.java delete mode 100644 testsrc/compbio/casscode/msa/ProbconsParametersTester.java delete mode 100644 testsrc/compbio/casscode/msa/ProbconsTester.java delete mode 100644 testsrc/compbio/casscode/msa/TcoffeeParametersTester.java delete mode 100644 testsrc/compbio/casscode/msa/TcoffeeTester.java delete mode 100644 testsrc/compbio/casscode/msa/mafftParams_modification_for_testing.txt delete mode 100644 testsrc/compbio/casscode/predictors/JpredTester.java delete mode 100644 testsrc/compbio/casscode/structure/RNAalifoldParametersTester.java delete mode 100644 testsrc/compbio/casscode/structure/RNAalifoldTester.java diff --git a/testsrc/compbio/casscode/conservation/AAConTester.java b/testsrc/compbio/casscode/conservation/AAConTester.java deleted file mode 100644 index 37f50cd..0000000 --- a/testsrc/compbio/casscode/conservation/AAConTester.java +++ /dev/null @@ -1,387 +0,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 - * by the Apache Software Foundation This library is distributed in the hope - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Apache License for more details. A copy of the license is in - * apache_license.txt. It is also available here: - * - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form must include - * this copyright and license notice. - */ -package compbio.runner.conservation; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; -import java.util.Arrays; - -import javax.xml.bind.ValidationException; - -import org.ggf.drmaa.DrmaaException; -import org.ggf.drmaa.JobInfo; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.data.sequence.ScoreManager; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.LimitsManager; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.RunnerUtil; -import compbio.util.FileWatcher; -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"; - public static String test_alignment_input = CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata" + File.separator + "TO1381.fasta.aln"; - private AACon aacon; - - @BeforeMethod(alwaysRun = true) - void init() { - aacon = new AACon(); - aacon.setInput(test_alignment_input).setOutput(test_outfile); - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void RunOnCluster() { - assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); - try { - ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Cluster); - ClusterRunner runner = ClusterRunner.getInstance(confAAcon); - - assertNotNull(runner, "Runner is NULL"); - runner.executeJob(); - JobStatus status = runner.getJobStatus(); - 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 = ClusterEngineUtil.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()); - } - 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()); - } - } - - /** - * 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 RunOnClusterAsync() { - assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); - try { - ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confAAcon); - String jobId = aengine.submitJob(confAAcon); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - System.out.println("Job Status: " + status); - Thread.sleep(1000); - status = aengine.getJobStatus(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 - if (status == JobStatus.UNDEFINED) { - break; - } - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void RunLocally() { - try { - ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Local); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confAAcon); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - ScoreManager annotations = confAAcon.getResults(); - assertNotNull(annotations); - assertEquals(annotations.asSet().size(), 18); - assertEquals(al1.getResults(), annotations); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void RunLocallyWithPreset() { - try { - PresetManager aaconPresets = RunnerUtil.getPresets(AACon.class); - assert aaconPresets != null; - 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); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - ScoreManager annotations = confAAcon.getResults(); - assertNotNull(annotations); - assertEquals(annotations.asSet().size(), 13); - assertEquals(al1.getResults(), annotations); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - 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); - confAAcon.addParameters(Arrays.asList("-m=KABAT,JORES")); - confAAcon.addParameters(Arrays.asList("-m=TAYLOR_GAPS")); - // For local execution use relative - LocalRunner lr = new LocalRunner(confAAcon); - - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - ScoreManager annotations = confAAcon.getResults(); - assertNotNull(annotations); - assertEquals(annotations.asSet().size(), 3); - assertEquals(al1.getResults(), annotations); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void readStatistics() { - try { - ConfiguredExecutable confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Local); - // For local execution use relative - - AsyncExecutor sexec = Configurator.getAsyncEngine(confAAcon); - String jobId = sexec.submitJob(confAAcon); - 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 { - 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)) { - fail("job failed!"); - break; - } - Thread.sleep(300); - status = sexec.getJobStatus(jobId); - } while (status != JobStatus.FINISHED || fw.hasMoreData()); - assertTrue(count >= 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void Persistance() { - try { - AACon aacon = new AACon(); - 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); - - SyncExecutor sexec = Configurator.getSyncEngine(cAAcon); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - - // Save run configuration - assertTrue(cAAcon.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cAAcon - .getWorkDirectory(), RunConfiguration.rconfigFile))); - 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"); - - // See in details whether executables are the same - assertEquals(resurrectedCAAcon.getExecutable(), aacon); - - ConfiguredExecutable resAAcon = Configurator.configureExecutable(resurrectedCAAcon.getExecutable(), - 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()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void ConfigurationLoading() { - try { - RunnerConfig aaconConfig = ConfExecutable.getRunnerOptions(AACon.class); - assertNotNull(aaconConfig); - assertTrue(aaconConfig.getArguments().size() > 0); - - PresetManager aaconPresets = ConfExecutable.getRunnerPresets(AACon.class); - assertNotNull(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()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } -} diff --git a/testsrc/compbio/casscode/disorder/DisemblTester.java b/testsrc/compbio/casscode/disorder/DisemblTester.java deleted file mode 100644 index e358387..0000000 --- a/testsrc/compbio/casscode/disorder/DisemblTester.java +++ /dev/null @@ -1,317 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.disorder; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.ValidationException; - -import org.ggf.drmaa.DrmaaException; -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; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -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.util.FileWatcher; -import compbio.util.SysPrefs; - -public class DisemblTester { - - public static String test_outfile = "TO1381.disembl.out"; - - private Disembl disembl; - - @BeforeMethod(alwaysRun = true) - void init() { - disembl = new Disembl(); - disembl.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"); - try { - ConfiguredExecutable confDisembl = Configurator - .configureExecutable(disembl, - Executable.ExecProvider.Cluster); - ClusterRunner runner = ClusterRunner.getInstance(confDisembl); - - 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!"); - 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 = ClusterEngineUtil.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()); - } - // 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()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (DrmaaException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } - } - - /** - * 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"); - try { - ConfiguredExecutable confDisembl = Configurator - .configureExecutable(disembl, - Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confDisembl); - String jobId = aengine.submitJob(confDisembl); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - System.out.println("Job Status: " + status); - Thread.sleep(1000); - status = aengine.getJobStatus(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 - if (status == JobStatus.UNDEFINED) { - break; - } - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocally() { - try { - ConfiguredExecutable confDisembl = Configurator - .configureExecutable(disembl, Executable.ExecProvider.Local); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confDisembl); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - ScoreManager al2 = confDisembl.getResults(); - assertNotNull(al2); - assertEquals(al2.asMap().size(), 3); - assertEquals(al1.getResults(), al2); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void readStatistics() { - // No execution statistics is available! - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testPersistance() { - try { - Disembl disembl = new Disembl(); - disembl.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); - assertEquals(disembl.getInput(), AllTestSuit.test_input); - assertEquals(disembl.getError(), "errrr.txt"); - assertEquals(disembl.getOutput(), "outtt.txt"); - ConfiguredExecutable cDisembl = Configurator - .configureExecutable(disembl, Executable.ExecProvider.Local); - - SyncExecutor sexec = Configurator.getSyncEngine(cDisembl); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - // Save run configuration - assertTrue(cDisembl.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cDisembl - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals( - ((ConfExecutable) cDisembl).getRunConfiguration(), - loadedRun); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCDisembl = (ConfiguredExecutable) cDisembl - .loadRunConfiguration(new FileInputStream(new File(cDisembl - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCDisembl); - assertEquals(resurrectedCDisembl.getExecutable().getInput(), - AllTestSuit.test_input); - assertEquals(resurrectedCDisembl.getExecutable().getError(), - "errrr.txt"); - assertEquals(resurrectedCDisembl.getExecutable().getOutput(), - "outtt.txt"); - // See in details whether executables are the same - assertEquals(resurrectedCDisembl.getExecutable(), disembl); - - ConfiguredExecutable resDisembl = Configurator - .configureExecutable(resurrectedCDisembl.getExecutable(), - Executable.ExecProvider.Local); - - sexec = Configurator.getSyncEngine(resDisembl, - Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testConfigurationLoading() { - try { - RunnerConfig disemblConfig = ConfExecutable - .getRunnerOptions(Disembl.class); - // There is no disembl parameters - assertNull(disemblConfig); - - //If there were a DisemblParameter.xml file and reference to it, - // it would be like that - // assertTrue(disemblConfig.getArguments().size() == 0); - - PresetManager disemblPresets = ConfExecutable - .getRunnerPresets(Disembl.class); - assertNull(disemblPresets); // there is no presets - - LimitsManager disemblLimits = ConfExecutable - .getRunnerLimits(Disembl.class); - assertNotNull(disemblLimits); - assertTrue(disemblLimits.getLimits().size() > 0); - disemblLimits.validate(disemblPresets); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/casscode/disorder/GlobPlotTester.java b/testsrc/compbio/casscode/disorder/GlobPlotTester.java deleted file mode 100644 index 083142a..0000000 --- a/testsrc/compbio/casscode/disorder/GlobPlotTester.java +++ /dev/null @@ -1,312 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.disorder; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; -import java.util.Map; -import java.util.Set; - -import javax.xml.bind.ValidationException; - -import org.ggf.drmaa.DrmaaException; -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; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -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.util.SysPrefs; - -public class GlobPlotTester { - - public static String test_outfile = "TO1381.globprot.out"; - - private GlobPlot globprot; - - @BeforeMethod(alwaysRun = true) - void init() { - globprot = new GlobPlot(); - globprot.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"); - try { - ConfiguredExecutable confGlobPlot = Configurator - .configureExecutable(globprot, - Executable.ExecProvider.Cluster); - ClusterRunner runner = ClusterRunner.getInstance(confGlobPlot); - - 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!"); - 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 = ClusterEngineUtil.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()); - } - // 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()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (DrmaaException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } - } - - /** - * 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"); - try { - ConfiguredExecutable confGlobPlot = Configurator - .configureExecutable(globprot, - Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confGlobPlot); - String jobId = aengine.submitJob(confGlobPlot); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - System.out.println("Job Status: " + status); - Thread.sleep(1000); - status = aengine.getJobStatus(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 - if (status == JobStatus.UNDEFINED) { - break; - } - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocally() { - try { - ConfiguredExecutable confGlobPlot = Configurator - .configureExecutable(globprot, - Executable.ExecProvider.Local); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confGlobPlot); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - ScoreManager al2 = confGlobPlot.getResults(); - assertNotNull(al2); - assertEquals(al2.asMap().size(), 3); - assertEquals(al1.getResults(), al2); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void readStatistics() { - // No execution statistics is available! - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testPersistance() { - try { - GlobPlot disembl = new GlobPlot(); - disembl.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); - assertEquals(disembl.getInput(), AllTestSuit.test_input); - assertEquals(disembl.getError(), "errrr.txt"); - assertEquals(disembl.getOutput(), "outtt.txt"); - ConfiguredExecutable cGlobPlot = Configurator - .configureExecutable(disembl, Executable.ExecProvider.Local); - - SyncExecutor sexec = Configurator.getSyncEngine(cGlobPlot); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - // Save run configuration - assertTrue(cGlobPlot.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cGlobPlot - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals( - ((ConfExecutable) cGlobPlot) - .getRunConfiguration(), - loadedRun); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCGlobPlot = (ConfiguredExecutable) cGlobPlot - .loadRunConfiguration(new FileInputStream(new File( - cGlobPlot.getWorkDirectory(), - RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCGlobPlot); - assertEquals(resurrectedCGlobPlot.getExecutable().getInput(), - AllTestSuit.test_input); - assertEquals(resurrectedCGlobPlot.getExecutable().getError(), - "errrr.txt"); - assertEquals(resurrectedCGlobPlot.getExecutable().getOutput(), - "outtt.txt"); - // See in details whether executables are the same - assertEquals(resurrectedCGlobPlot.getExecutable(), disembl); - - ConfiguredExecutable resGlobPlot = Configurator - .configureExecutable(resurrectedCGlobPlot.getExecutable(), - Executable.ExecProvider.Local); - - sexec = Configurator.getSyncEngine(resGlobPlot, - Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testConfigurationLoading() { - try { - RunnerConfig globplotConfig = ConfExecutable - .getRunnerOptions(GlobPlot.class); - // There is no GlobPlot parameters - assertNull(globplotConfig); - - PresetManager disemblPresets = ConfExecutable - .getRunnerPresets(GlobPlot.class); - assertNull(disemblPresets); // there is no presets - - LimitsManager disemblLimits = ConfExecutable - .getRunnerLimits(GlobPlot.class); - assertNotNull(disemblLimits); - assertTrue(disemblLimits.getLimits().size() > 0); - disemblLimits.validate(disemblPresets); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/casscode/disorder/IUPredTester.java b/testsrc/compbio/casscode/disorder/IUPredTester.java deleted file mode 100644 index 121aba6..0000000 --- a/testsrc/compbio/casscode/disorder/IUPredTester.java +++ /dev/null @@ -1,383 +0,0 @@ -/* Copyright (c) 2011 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.disorder; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; - -import javax.xml.bind.ValidationException; - -import org.ggf.drmaa.DrmaaException; -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.data.sequence.ScoreManager.ScoreHolder; -import compbio.data.sequence.SequenceUtil; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -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.msa.Mafft; -import compbio.util.SysPrefs; - -public class IUPredTester { - - private IUPred iupred; - - @BeforeMethod(alwaysRun = true) - void init() { - iupred = new IUPred(); - iupred.setInput(AllTestSuit.test_input); - } - - @Test(groups = {AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner}) - public void testRunOnCluster() { - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); - try { - ConfiguredExecutable confIUPred = Configurator - .configureExecutable(iupred, - Executable.ExecProvider.Cluster); - ClusterRunner runner = ClusterRunner.getInstance(confIUPred); - - 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!"); - 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 = ClusterEngineUtil.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()); - } - // 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()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (DrmaaException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } - } - - /** - * 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"); - try { - ConfiguredExecutable confIUPred = Configurator - .configureExecutable(iupred, - Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confIUPred); - String jobId = aengine.submitJob(confIUPred); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - System.out.println("Job Status: " + status); - Thread.sleep(1000); - status = aengine.getJobStatus(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 - if (status == JobStatus.UNDEFINED) { - break; - } - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testSetParameter() { - assertEquals(iupred.getInput(), AllTestSuit.test_input); - assertTrue(iupred.getParameters(null).getCommandString().trim().endsWith(AllTestSuit.test_input)); - iupred.setParameter("long"); - assertEquals(iupred.getInput(), AllTestSuit.test_input); - String cmd = iupred.getParameters(null).getCommandString().trim(); - assertTrue(cmd.endsWith("long")); - assertTrue(cmd.contains(AllTestSuit.test_input)); - } - - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testReadResults() { - ScoreManager scoreMan; - try { - scoreMan = iupred.getResults(AllTestSuit.TEST_DATA_PATH_ABSOLUTE); - System.out.println(scoreMan.asMap()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocally() { - try { - ConfiguredExecutable confIUPred = Configurator - .configureExecutable(iupred, Executable.ExecProvider.Local); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confIUPred); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - ScoreManager al2 = confIUPred.getResults(); - assertNotNull(al2); - assertEquals(al2.asMap().size(), 3); - assertEquals(al2.getNumberOfSeq(),3); - - ScoreHolder sch = al2.getAnnotationForSequence("Foobar"); - assertEquals(sch.getNumberOfScores(), 3); - - Score sc = sch.getScoreByMethod("Long"); - assertEquals(sc.getMethod(), "Long"); - assertTrue(sc.getRanges().isEmpty()); - assertNotNull(sc.getScores()); - assertEquals(sc.getScores().size(), 481); - assertEquals(al1.getResults(), al2); - - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testRunLocallyWithParams() { - try { - iupred.setParameter("short"); - ConfiguredExecutable confIUPred = Configurator - .configureExecutable(iupred, Executable.ExecProvider.Local); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confIUPred); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - ScoreManager al2 = confIUPred.getResults(); - - assertNotNull(al2.asMap()); - assertEquals(al2.asMap().size(), 3); - ScoreHolder sch = al2.getAnnotationForSequence("Foobar"); - assertNotNull(sch); - assertEquals(sch.getNumberOfScores(), 1); - - /* - assertNotNull(al2); - assertEquals(al2.asSet().size(), 1); - assertEquals(al2.getNumberOfSeq(),1); - Score sc = al2.asSet().iterator().next(); - assertEquals(sc.getMethod(), "Long"); - assertTrue(sc.getRanges().isEmpty()); - assertNotNull(sc.getScores()); - assertEquals(sc.getScores().size(), 568); - assertEquals(al1.getResults(), al2); -*/ - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testPersistance() { - try { - IUPred iupred = new IUPred(); - iupred.setError("errrr.txt").setInput(AllTestSuit.test_input); - assertEquals(iupred.getInput(), AllTestSuit.test_input); - assertEquals(iupred.getError(), "errrr.txt"); - - ConfiguredExecutable cIUPred = Configurator - .configureExecutable(iupred, Executable.ExecProvider.Local); - - SyncExecutor sexec = Configurator.getSyncEngine(cIUPred); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - // Save run configuration - assertTrue(cIUPred.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cIUPred - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals( - ((ConfExecutable) cIUPred).getRunConfiguration(), - loadedRun); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCIUPred = (ConfiguredExecutable) cIUPred - .loadRunConfiguration(new FileInputStream(new File(cIUPred - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCIUPred); - assertEquals(resurrectedCIUPred.getExecutable().getInput(), - AllTestSuit.test_input); - assertEquals(resurrectedCIUPred.getExecutable().getError(), - "errrr.txt"); - - // See in details whether executables are the same - assertEquals(resurrectedCIUPred.getExecutable(), iupred); - - ConfiguredExecutable resIUPred = Configurator - .configureExecutable(resurrectedCIUPred.getExecutable(), - Executable.ExecProvider.Local); - - sexec = Configurator.getSyncEngine(resIUPred, - Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void testConfigurationLoading() { - try { - RunnerConfig iupredConfig = ConfExecutable - .getRunnerOptions(IUPred.class); - - assertNotNull(iupredConfig); - - assertTrue(iupredConfig.getArguments().size() != 0); - - PresetManager iupredPresets = ConfExecutable - .getRunnerPresets(IUPred.class); - assertNull(iupredPresets); // there is no presets - - LimitsManager iupredLimits = ConfExecutable - .getRunnerLimits(IUPred.class); - assertNotNull(iupredLimits); - assertTrue(iupredLimits.getLimits().size() > 0); - iupredLimits.validate(iupredPresets); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/casscode/disorder/JronnTester.java b/testsrc/compbio/casscode/disorder/JronnTester.java deleted file mode 100644 index f065f13..0000000 --- a/testsrc/compbio/casscode/disorder/JronnTester.java +++ /dev/null @@ -1,349 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * Copyright (c) 2013 Alexander Sherstnev - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.disorder; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; - -import javax.xml.bind.ValidationException; - -import org.ggf.drmaa.DrmaaException; -import org.ggf.drmaa.JobInfo; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.data.sequence.ScoreManager; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -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.util.FileWatcher; -import compbio.util.SysPrefs; - -public class JronnTester { - - public static String test_outfile = "TO1381.jronn.out"; - private Jronn jronn; - - @BeforeMethod(alwaysRun = true) - void init() { - jronn = new Jronn(); - jronn.setInput(AllTestSuit.test_input).setOutput(test_outfile); - } - - @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); - ClusterRunner runner = ClusterRunner.getInstance(confJronn); - - assertNotNull(runner, "Runner is NULL"); - runner.executeJob(); - JobStatus status = runner.getJobStatus(); - 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 = ClusterEngineUtil.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()); - } - 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()); - } - } - - /** - * 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 RunOnClusterAsync() { - assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); - try { - ConfiguredExecutable confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confJronn); - String jobId = aengine.submitJob(confJronn); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - System.out.println("Job Status: " + status); - Thread.sleep(1000); - status = aengine.getJobStatus(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 - if (status == JobStatus.UNDEFINED) { - break; - } - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void RunLocally() { - try { - ConfiguredExecutable confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Local); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confJronn); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - ScoreManager al2 = confJronn.getResults(); - assertNotNull(al2); - assertEquals(al2.asMap().size(), 3); - assertEquals(al1.getResults(), al2); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void RunLocallyOnTwoCpu() { - try { - jronn.setNCore(2); - ConfiguredExecutable confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Local); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confJronn); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - ScoreManager al2 = confJronn.getResults(); - assertNotNull(al2); - assertEquals(al2.asMap().size(), 3); - assertEquals(al1.getResults(), al2); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void readStatistics() { - try { - ConfiguredExecutable confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Local); - // For local execution use relavive - - AsyncExecutor sexec = Configurator.getAsyncEngine(confJronn); - String jobId = sexec.submitJob(confJronn); - 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); - JobStatus status = sexec.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - 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)) { - break; - } - Thread.sleep(300); - status = sexec.getJobStatus(jobId); - } - assertTrue(count > 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void Persistance() { - try { - Jronn jronn = new Jronn(); - 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); - SyncExecutor sexec = Configurator.getSyncEngine(cJronn); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - // Save run configuration - assertTrue(cJronn.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cJronn - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals( - ((ConfExecutable) cJronn).getRunConfiguration(), - loadedRun); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCMuscle = (ConfiguredExecutable) cJronn - .loadRunConfiguration(new FileInputStream(new File(cJronn.getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCMuscle); - assertEquals(resurrectedCMuscle.getExecutable().getInput(), - AllTestSuit.test_input); - assertEquals(resurrectedCMuscle.getExecutable().getError(), - "errrr.txt"); - assertEquals(resurrectedCMuscle.getExecutable().getOutput(), - "outtt.txt"); - // See in details whether executables are the same - assertEquals(resurrectedCMuscle.getExecutable(), jronn); - - ConfiguredExecutable resJronn = Configurator - .configureExecutable(resurrectedCMuscle.getExecutable(), - 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()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void ConfigurationLoading() { - try { - RunnerConfig jronnConfig = ConfExecutable.getRunnerOptions(Jronn.class); - assertNull(jronnConfig); // There is no supported parameters for Jronn - - PresetManager jronnPresets = ConfExecutable.getRunnerPresets(Jronn.class); - assertNull(jronnPresets); // there is no presets - - LimitsManager jronnLimits = ConfExecutable.getRunnerLimits(Jronn.class); - assertNotNull(jronnLimits); - assertTrue(jronnLimits.getLimits().size() > 0); - jronnLimits.validate(jronnPresets); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } -} diff --git a/testsrc/compbio/casscode/msa/ClustalOTester.java b/testsrc/compbio/casscode/msa/ClustalOTester.java deleted file mode 100644 index 281a50c..0000000 --- a/testsrc/compbio/casscode/msa/ClustalOTester.java +++ /dev/null @@ -1,379 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * Copyright (c) 2013 Alexander Sherstnev - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; -import java.util.Collections; -import java.util.List; - -import javax.xml.bind.JAXBException; - -import org.ggf.drmaa.DrmaaException; -import org.ggf.drmaa.JobInfo; -import org.testng.annotations.Test; - -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.EngineUtil; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.Executable.ExecProvider; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.engine.local.AsyncLocalRunner; -import compbio.engine.local.LocalExecutorService; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.LimitsManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.OptionCombinator; -import compbio.util.FileWatcher; -import compbio.util.SysPrefs; - -public class ClustalOTester { - - 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_runner}) - 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); - LocalRunner lr = new LocalRunner(confClustal); - lr.executeJob(); - confClustal = (ConfiguredExecutable) lr.waitForResult(); - assertNotNull(confClustal.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void ConfigurationLoading() { - try { - RunnerConfig clustalConfig = ConfExecutable.getRunnerOptions(ClustalO.class); - assertNotNull(clustalConfig); - assertTrue(clustalConfig.getArguments().size() > 0); - - LimitsManager clustalLimits = ConfExecutable.getRunnerLimits(ClustalO.class); - assertNotNull(clustalLimits); - assertTrue(clustalLimits.getLimits().size() > 0); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void OptionsLocally() { - try { - 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); - clustal.setOutput(test_outfile); - - // For local execution use relavive - 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(); - assertNotNull(confClustal.getResults()); - Collections.shuffle(options); - } - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - 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); - AsyncExecutor lr = new AsyncLocalRunner(); - lr.submitJob(confClustal); - Thread.sleep(3000); - LocalExecutorService.shutDown(); - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void Persistance() { - try { - ClustalO clustal = new ClustalO(); - 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); - - SyncExecutor sexec = Configurator.getSyncEngine(cClustal); - sexec.executeJob(); - cClustal = (ConfiguredExecutable) sexec.waitForResult(); - assertNotNull(cClustal.getResults()); - // Save run configuration - assertTrue(cClustal.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration.load(new FileInputStream(new File(cClustal.getWorkDirectory(), RunConfiguration.rconfigFile))); - assertTrue(((ConfExecutable) cClustal) - .getRunConfiguration().equals(loadedRun)); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCclustal = (ConfiguredExecutable) cClustal - .loadRunConfiguration(new FileInputStream(new File(cClustal - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCclustal); - // See in details whether executables are the same - assertEquals(resurrectedCclustal.getExecutable(), clustal); - - // Finally rerun the job in the new task directory - ConfiguredExecutable resclustal = Configurator - .configureExecutable(resurrectedCclustal.getExecutable(), - 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()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void readStatistics() - throws InterruptedException { - try { - 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 = EngineUtil.getFullPath(confal.getWorkDirectory(), ClustalW.getStatFile()); - FilePuller fw = FilePuller.newFilePuller(file, FileWatcher.MIN_CHUNK_SIZE_BYTES); - int count = 0; - long position = 0; - fw.waitForFile(4); - 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 al2 = sexec.getResults(jobId); - assertNotNull(al2.getResults()); - } catch (JobSubmissionException 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_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); - ClusterRunner runner = ClusterRunner.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 = ClusterEngineUtil.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); - - AsyncExecutor sexec = Configurator.getAsyncEngine(confClustal); - String jobId = sexec.submitJob(confClustal); - String file = EngineUtil.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. maxloopcount ensures hard stop of the loop... - */ - 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(); - 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!"); - break; - } - } - assertTrue(count > 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } -} diff --git a/testsrc/compbio/casscode/msa/ClustalWParametersTester.java b/testsrc/compbio/casscode/msa/ClustalWParametersTester.java deleted file mode 100644 index 0886e01..0000000 --- a/testsrc/compbio/casscode/msa/ClustalWParametersTester.java +++ /dev/null @@ -1,265 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.ValidationException; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.engine.Configurator; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable.ExecProvider; -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.engine.local.ExecutableWrapper; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.Option; -import compbio.metadata.Parameter; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.OptionCombinator; -import compbio.runner.msa.ClustalW; -import compbio.util.FileUtil; - -@Test(sequential = true) -public class ClustalWParametersTester { - - static final String clustalConfigFile = AllTestSuit.TEST_DATA_PATH - + "ClustalParameters.xml"; - - public static String test_outfile = "TO1381.clustal.out"; - public static String test_error = "TO1381.clustal.error"; - public static String cluster_test_outfile = "TO1381.clustal.cluster.out"; - public static final String input = AllTestSuit.TEST_DATA_PATH - + "ClustalPresets.xml"; - - private static Logger log = Logger - .getLogger(AllTestSuit.RUNNER_TEST_LOGGER); - static { - log.setLevel(Level.INFO); - } - - RunnerConfig clustalConfig = null; - OptionCombinator clustalOpc = null; - PresetManager presets = null; - - @BeforeMethod(groups = { AllTestSuit.test_group_runner }) - public void setup() { - try { - RunnerConfigMarshaller clustalmarsh = new RunnerConfigMarshaller( - RunnerConfig.class); - clustalConfig = clustalmarsh.read(new FileInputStream(new File( - clustalConfigFile)), RunnerConfig.class); - clustalOpc = new OptionCombinator(clustalConfig); - - // Load presets - RunnerConfigMarshaller rconfigPresets = new RunnerConfigMarshaller( - PresetManager.class); - File infile = new File(input); - assertTrue(infile.exists()); - presets = rconfigPresets.read(new FileInputStream(infile), - PresetManager.class); - assertNotNull(presets); - assertFalse(presets.getPresets().isEmpty()); - - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - } - - @Test - public void testConfiguration() { - try { - this.clustalConfig.validate(); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IllegalStateException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testDefaultParameters() { - ClustalW clustal = new ClustalW(); - clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile); - - try { - // For local execution use relavive - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal); - LocalRunner lr = new LocalRunner(confClustal); - lr.executeJob(); - confClustal = (ConfiguredExecutable) lr.waitForResult(); - assertNotNull(confClustal.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testOptions() { - test(clustalOpc.getAllOptions()); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testParameters() { - List> params = clustalOpc.getAllParameters(); - Collections.shuffle(params); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testArguments() { - List> options = clustalOpc.getAllOptions(); - options.addAll(clustalOpc.getAllParameters()); - Collections.shuffle(options); - test(options); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testConstrainedParametersMinValues() { - Map, String> params = clustalOpc - .getAllConstrainedParametersWithBorderValues(true); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testConstrainedParametersMaxValues() { - Map, String> params = clustalOpc - .getAllConstrainedParametersWithBorderValues(false); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testConstrainedParametersRandomValues() { - for (int i = 0; i < 5; i++) { - Map, String> params = clustalOpc - .getAllConstrainedParametersWithRandomValues(); - List> paramList = new ArrayList>(params - .keySet()); - Collections.shuffle(paramList); - List args = clustalOpc.parametersToCommandString(paramList, - params); - singleTest(args); - } - } - - void test(Map, String> paramValue) { - List> paramList = new ArrayList>(paramValue - .keySet()); - for (int i = 0; i < paramValue.size(); i++) { - List args = clustalOpc.parametersToCommandString(paramList, - paramValue); - singleTest(args); - Collections.shuffle(paramList); - } - log.info("NUMBER OF COBINATION TESTED: " + paramValue.size()); - } - - void test(List> params) { - for (int i = 0; i < params.size(); i++) { - List args = clustalOpc.argumentsToCommandString(params); - singleTest(args); - Collections.shuffle(params); - } - log.info("NUMBER OF COBINATION TESTED: " + params.size()); - } - - void singleTest(List params) { - try { - log.info("Using arguments: " + params); - ClustalW clustal = new ClustalW(); - clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile); - - // For local execution use relative - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, ExecProvider.Local); - // Add options to the executable - confClustal.addParameters(params); - LocalRunner lr = new LocalRunner(confClustal); - lr.executeJob(); - confClustal = (ConfiguredExecutable) lr.waitForResult(); - assertNotNull(confClustal.getResults()); - File errors = new File(confClustal.getWorkDirectory(), - ExecutableWrapper.PROC_ERR_FILE); - if (errors.length() != 0) { - log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors)); - } - assertTrue(errors.length() == 0, "Run with arguments : " + params - + " FAILED!"); - Collections.shuffle(params); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testPresets() { - for (Preset p : presets.getPresets()) { - singleTest(p.getOptions()); - } - } - -} diff --git a/testsrc/compbio/casscode/msa/ClustalWTester.java b/testsrc/compbio/casscode/msa/ClustalWTester.java deleted file mode 100644 index d8617cb..0000000 --- a/testsrc/compbio/casscode/msa/ClustalWTester.java +++ /dev/null @@ -1,461 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * Copyright (c) 2013 Alexander Sherstnev - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -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.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.client.Executable.ExecProvider; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.engine.local.AsyncLocalRunner; -import compbio.engine.local.LocalExecutorService; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -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.RunnerUtil; -import compbio.runner.msa.ClustalW; -import compbio.util.FileWatcher; -import compbio.util.SysPrefs; - -public class ClustalWTester { - - 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_runner }) - 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); - LocalRunner lr = new LocalRunner(confClustal); - lr.executeJob(); - confClustal = (ConfiguredExecutable) lr.waitForResult(); - assertNotNull(confClustal.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void RunWithMatrix() { - ClustalW clustal = new ClustalW(); - clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile); - clustal.setParameter("-matrix=BLOSUM62"); - try { - - // For local execution use relavive - ConfiguredExecutable confClustal = Configurator - .configureExecutable(clustal, Executable.ExecProvider.Local); - LocalRunner lr = new LocalRunner(confClustal); - lr.executeJob(); - confClustal = (ConfiguredExecutable) lr.waitForResult(); - assertNotNull(confClustal.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void ConfigurationLoading() { - try { - RunnerConfig clustalConfig = ConfExecutable.getRunnerOptions(ClustalW.class); - assertNotNull(clustalConfig); - assertTrue(clustalConfig.getArguments().size() > 0); - - PresetManager clustalPresets = ConfExecutable.getRunnerPresets(ClustalW.class); - assertNotNull(clustalPresets); - assertTrue(clustalPresets.getPresets().size() > 0); - clustalPresets.validate(clustalConfig); - - LimitsManager clustalLimits = ConfExecutable.getRunnerLimits(ClustalW.class); - assertNotNull(clustalLimits); - assertTrue(clustalLimits.getLimits().size() > 0); - clustalLimits.validate(clustalPresets); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void OptionsLocally() { - try { - 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); - - // For local execution use relavive - 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(); - assertNotNull(confClustal.getResults()); - Collections.shuffle(options); - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - 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); - AsyncExecutor lr = new AsyncLocalRunner(); - lr.submitJob(confClustal); - Thread.sleep(3000); - LocalExecutorService.shutDown(); - } - - // disabled - @Test(enabled = false) - 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"); - 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); - RunnerUtil.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 Persistance() { - try { - ClustalW clustal = new ClustalW(); - 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); - - SyncExecutor sexec = Configurator.getSyncEngine(cClustal); - sexec.executeJob(); - cClustal = (ConfiguredExecutable) sexec.waitForResult(); - assertNotNull(cClustal.getResults()); - // Save run configuration - assertTrue(cClustal.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cClustal - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertTrue(((ConfExecutable) cClustal) - .getRunConfiguration().equals(loadedRun)); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCclustal = (ConfiguredExecutable) cClustal - .loadRunConfiguration(new FileInputStream(new File(cClustal - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCclustal); - // See in details whether executables are the same - assertEquals(resurrectedCclustal.getExecutable(), clustal); - - // Finally rerun the job in the new task directory - ConfiguredExecutable resclustal = Configurator - .configureExecutable(resurrectedCclustal.getExecutable(), - 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()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @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); - - AsyncExecutor sexec = Configurator.getAsyncEngine(confClustal); - String jobId = sexec.submitJob(confClustal); - 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); - 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); - count++; - } - assertTrue(count > 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException 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_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); - ClusterRunner runner = ClusterRunner.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 = ClusterEngineUtil.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(); - 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); - 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); - /* Under certain circumstances DRMAA could report the status wrongly thus this loop never ends - * TODO deal with this! - * */ - while (!(sexec.getJobStatus(jobId) == JobStatus.FINISHED || sexec - .getJobStatus(jobId) == JobStatus.FAILED ) - || fw.hasMoreData()) { - ChunkHolder ch = fw.pull(position); - String chunk = ch.getChunk(); - position = ch.getNextPosition(); - System.out.print(chunk); - count++; - if(sexec.getJobStatus(jobId) == JobStatus.UNDEFINED ) { - System.out.println("DRMAA reported wrong status for job + " + jobId +" continue anyway!"); - break; - } - } - assertTrue(count > 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } -} diff --git a/testsrc/compbio/casscode/msa/LimitTester.java b/testsrc/compbio/casscode/msa/LimitTester.java deleted file mode 100644 index 8a9e56a..0000000 --- a/testsrc/compbio/casscode/msa/LimitTester.java +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.List; - -import javax.xml.bind.JAXBException; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.data.sequence.FastaSequence; -import compbio.data.sequence.SequenceUtil; -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.metadata.AllTestSuit; -import compbio.metadata.Limit; -import compbio.metadata.LimitsManager; -import compbio.metadata.PresetManager; - -public class LimitTester { - - static final String clustalLimitsFile = AllTestSuit.TEST_DATA_PATH - + "ClustalLimits.xml"; - static String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "TO1381.fasta"; // - static final String input = AllTestSuit.TEST_DATA_PATH - + "ClustalPresets.xml"; - - LimitsManager clustalLimitConfig = null; - PresetManager presets = null; - - @BeforeMethod(groups = { AllTestSuit.test_group_runner }) - public void setup() { - try { - RunnerConfigMarshaller clustalmarsh = new RunnerConfigMarshaller( - LimitsManager.class); - clustalLimitConfig = clustalmarsh.read(new FileInputStream( - new File(clustalLimitsFile)), LimitsManager.class); - assertNotNull(clustalLimitConfig.getLimits()); - assertEquals(clustalLimitConfig.getLimits().size(), 3); - // Load presets - RunnerConfigMarshaller rconfigPresets = new RunnerConfigMarshaller( - PresetManager.class); - File infile = new File(input); - assertTrue(infile.exists()); - presets = rconfigPresets.read(new FileInputStream(infile), - PresetManager.class); - assertNotNull(presets); - assertFalse(presets.getPresets().isEmpty()); - - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - } - - @Test - public void testLoadLimits() { - assertNotNull(clustalLimitConfig); - List> limits = clustalLimitConfig.getLimits(); - assertEquals(limits.size(), 3); - Limit limit = limits.get(0); - assertNotNull(limit); - assertEquals(limit.getPreset(), - "Disable gap weighting (Speed-oriented)"); - assertEquals(limit.getSeqNumber(), 400); - assertEquals(limit.getAvgSeqLength(), 600); - assertFalse(limit.isDefault()); - - limit = limits.get(1); - assertNotNull(limit); - assertEquals(limit.getPreset(), null); - assertEquals(limit.getSeqNumber(), 1000); - assertEquals(limit.getAvgSeqLength(), 400); - assertTrue(limit.isDefault()); - } - - @Test - public void testLimitExceeded() { - - String test_input = AllTestSuit.TEST_DATA_PATH_ABSOLUTE - + "testlimit.fasta"; - - FileInputStream fio; - try { - fio = new FileInputStream(test_input); - List data = SequenceUtil.readFasta(fio); - fio.close(); - assertNotNull(data); - assertEquals(data.size(), 6); - assertEquals(Limit.getAvgSequenceLength(data), 20486); - Limit small = new Limit(40, 500, "default"); - - assertTrue(small.isExceeded(data)); - - Limit large = new Limit(500, 500, "default"); - assertFalse(large.isExceeded(data)); - - Limit numSeqOnly = new Limit(6, 0, "default"); - assertFalse(numSeqOnly.isExceeded(data)); - - Limit exnumSeqOnly = new Limit(5, 0, "default"); - assertTrue(exnumSeqOnly.isExceeded(data)); - - Limit numSeq3 = new Limit(5, 1000000, "default"); - assertTrue(numSeq3.isExceeded(data)); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } -} diff --git a/testsrc/compbio/casscode/msa/MafftParametersTester.java b/testsrc/compbio/casscode/msa/MafftParametersTester.java deleted file mode 100644 index 3c60a4b..0000000 --- a/testsrc/compbio/casscode/msa/MafftParametersTester.java +++ /dev/null @@ -1,268 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.ValidationException; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.engine.Configurator; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable.ExecProvider; -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.Option; -import compbio.metadata.Parameter; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.OptionCombinator; -import compbio.runner.msa.Mafft; -import compbio.util.Util; - -public class MafftParametersTester { - - static final String mafftConfigFile = AllTestSuit.TEST_DATA_PATH - + "MafftParameters.xml"; - public static String test_outfile = "TO1381.mafft.out"; - public static final String input = AllTestSuit.TEST_DATA_PATH - + "MafftPresets.xml"; - - private static Logger log = Logger - .getLogger(AllTestSuit.RUNNER_TEST_LOGGER); - static { - log.setLevel(Level.INFO); - } - - PresetManager presets = null; - RunnerConfig mafftConfig = null; - OptionCombinator mafftOpc = null; - - @BeforeMethod(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void setup() { - try { - // Load parameters - RunnerConfigMarshaller mafftmarsh = new RunnerConfigMarshaller( - RunnerConfig.class); - mafftConfig = mafftmarsh.read(new FileInputStream(new File( - mafftConfigFile)), RunnerConfig.class); - mafftOpc = new OptionCombinator(mafftConfig); - // Load presets - RunnerConfigMarshaller rconfigPresets = new RunnerConfigMarshaller( - PresetManager.class); - File infile = new File(input); - assertTrue(infile.exists()); - presets = rconfigPresets.read(new FileInputStream(infile), - PresetManager.class); - assertNotNull(presets); - assertFalse(presets.getPresets().isEmpty()); - - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - } - - @Test - public void testConfiguration() { - try { - this.mafftConfig.validate(); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IllegalStateException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testDefaultParameters() { - Mafft mafft = new Mafft(); - mafft.setInput(AllTestSuit.test_input).setOutput(test_outfile); - - try { - // For local execution use relavive - ConfiguredExecutable confMafft = Configurator - .configureExecutable(mafft, ExecProvider.Cluster); - SyncExecutor sexecutor = Configurator.getSyncEngine(confMafft); - sexecutor.executeJob(); - confMafft = (ConfiguredExecutable) sexecutor.waitForResult(); - assertNotNull(confMafft.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testOptions() { - test(mafftOpc.getAllOptions()); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testParameters() { - List> params = mafftOpc.getAllParameters(); - Collections.shuffle(params); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testArguments() { - List> options = new ArrayList>(mafftConfig - .getOptions()); - options.addAll(mafftOpc.getAllParameters()); - Collections.shuffle(options); - test(options); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testConstrainedParametersMinValues() { - Map, String> params = mafftOpc - .getAllConstrainedParametersWithBorderValues(true); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testConstrainedParametersMaxValues() { - Map, String> params = mafftOpc - .getAllConstrainedParametersWithBorderValues(false); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testConstrainedParametersRandomValues() { - for (int i = 0; i < 20; i++) { - Map, String> params = mafftOpc - .getAllConstrainedParametersWithRandomValues(); - List> paramList = new ArrayList>(params - .keySet()); - Collections.shuffle(paramList); - List> subList = paramList.subList(0, Util - .getRandomNumber(1, paramList.size())); - List args = mafftOpc.parametersToCommandString(subList, - params); - singleTest(args); - } - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testPresets() { - for (Preset p : presets.getPresets()) { - singleTest(p.getOptions()); - } - } - - void test(Map, String> paramValue) { - List> paramList = new ArrayList>(paramValue - .keySet()); - for (int i = 0; i < paramValue.size(); i++) { - List args = mafftOpc.parametersToCommandString(paramList, - paramValue); - singleTest(args); - Collections.shuffle(paramList); - } - log.info("NUMBER OF COBINATION TESTED: " + paramValue.size()); - } - - void test(List> params) { - for (int i = 0; i < params.size(); i++) { - List args = mafftOpc.argumentsToCommandString(params); - singleTest(args); - Collections.shuffle(params); - } - log.info("NUMBER OF COBINATION TESTED: " + params.size()); - } - - void singleTest(List params) { - try { - log.info("Using arguments: " + params); - Mafft mafft = new Mafft(); - mafft.setInput(AllTestSuit.test_input).setOutput(test_outfile); - - // For local execution use relative - ConfiguredExecutable confMafft = Configurator - .configureExecutable(mafft, ExecProvider.Local); - // Add options to the executable - confMafft.addParameters(params); - - SyncExecutor sexecutor = Configurator.getSyncEngine(confMafft); - sexecutor.executeJob(); - ConfiguredExecutable al = sexecutor.waitForResult(); - assertNotNull(al.getResults()); - /* - * TODO File errors = new File(confMafft.getWorkDirectory(), - * ExecutableWrapper.PROC_ERR_FILE); if (errors.length() != 0) { - * log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors)); } - * assertTrue("Run with arguments : " + params + " FAILED!", errors - * .length() == 0); - */ - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/casscode/msa/MafftTester.java b/testsrc/compbio/casscode/msa/MafftTester.java deleted file mode 100644 index 53b8fe3..0000000 --- a/testsrc/compbio/casscode/msa/MafftTester.java +++ /dev/null @@ -1,356 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; - -import javax.xml.bind.ValidationException; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.client.Executable.ExecProvider; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -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.msa.Mafft; -import compbio.util.SysPrefs; - -public class MafftTester { - - private Mafft mafft; - - @BeforeMethod(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) - public void init() { - mafft = new Mafft(); - // mafft.setParameter("--aamatrix"); - // mafft.setParameter("PAM100"); - mafft.setInput(AllTestSuit.test_input); // .setOutput("Mafft.out").setError("mafft.progress"); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testSetInputTester() { - Mafft mf = new Mafft(); - // System.out.println(mf.getParameters(null)); - mf.setInput("INNN"); - // System.out.println(mf.getParameters(null)); - mf.setError("ERRR"); - mf.setInput("INN222"); - mf.setOutput("OUT"); - // System.out.println(mf.getParameters(null)); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testExecute() { - try { - ConfiguredExecutable cmafft = Configurator - .configureExecutable(mafft, Executable.ExecProvider.Local); - cmafft.getParameters().setParam("--aamatrix", "PAM120"); - SyncExecutor sexecutor = Configurator.getSyncEngine(cmafft); - sexecutor.executeJob(); - cmafft = (ConfiguredExecutable) sexecutor.waitForResult(); - assertNotNull(cmafft.getResults()); - } 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 testPersistance() { - try { - Mafft mafft = new Mafft(); - mafft.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); - assertEquals(mafft.getInput(), AllTestSuit.test_input); - assertEquals(mafft.getError(), "errrr.txt"); - assertEquals(mafft.getOutput(), "outtt.txt"); - ConfiguredExecutable cmafft = Configurator - .configureExecutable(mafft, Executable.ExecProvider.Local); - - SyncExecutor sexec = Configurator.getSyncEngine(cmafft); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - // Save run configuration - assertTrue(cmafft.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cmafft - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals( - ((ConfExecutable) cmafft).getRunConfiguration(), - loadedRun); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCMafft = (ConfiguredExecutable) cmafft - .loadRunConfiguration(new FileInputStream(new File(cmafft - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCMafft); - // See in details whether executables are the same - assertEquals(resurrectedCMafft.getExecutable(), mafft); - - // Finally rerun the job in the new task directory - ConfiguredExecutable resmafft = Configurator - .configureExecutable(resurrectedCMafft.getExecutable(), - Executable.ExecProvider.Local); - - sexec = Configurator.getSyncEngine(resmafft, - Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) - public void testClusterExecute() { - try { - - ConfiguredExecutable cmafft = Configurator - .configureExecutable(mafft, Executable.ExecProvider.Cluster); - ClusterRunner sexecutor = (ClusterRunner) Configurator.getSyncEngine( - cmafft, Executable.ExecProvider.Cluster); - sexecutor.executeJob(); - ConfiguredExecutable al = sexecutor.waitForResult(); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - /** - * This test demonstrates the problem with Drmaa which can return UNDEFINED status after Running! - * enable it to see the problem - */ - @Test(enabled=false, groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) - public void testRunOnClusterAsyncCheckStatusShortPoolingTime() { - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); - try { - ConfiguredExecutable confMafft = Configurator - .configureExecutable(mafft, Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confMafft); - String jobId = aengine.submitJob(confMafft); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - boolean run = false; - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - if (status == JobStatus.RUNNING) { - run = true; - } - Thread.sleep(500); - status = aengine.getJobStatus(jobId); - // Once the job was in the RUNNING state UNDEFINED should not - // occur - // Unfortunately with a short pooling time like here - // this problem occurs. There seems to be a bug in DRMAA SGE - // implementation - // Perhaps longer pooling time e.g. 5 second will fix the issue - // see the next test case for this - if (run) { - assertNotSame(status, JobStatus.UNDEFINED); - } - } - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) - public void testRunOnClusterAsyncCheckStatusLongPoolingTime() { - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); - try { - ConfiguredExecutable confMafft = Configurator - .configureExecutable(mafft, Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confMafft); - String jobId = aengine.submitJob(confMafft); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - boolean run = false; - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - if (status == JobStatus.RUNNING) { - run = true; - } - Thread.sleep(5000); - status = aengine.getJobStatus(jobId); - // Once the job was in the RUNNING state UNDEFINED should not - // occur - // Hopefully with a long pooling time like here - // this problem should not occur. There seems to be a bug in - // DRMAA SGE implementation - if (run) { - assertNotSame(status, JobStatus.UNDEFINED); - } - } - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void readStatistics() { - Mafft mafft = new Mafft(); - mafft.setError("errrr.txt").setInput(AllTestSuit.test_input).setOutput( - "outtt.txt"); - ConfiguredExecutable cmafft; - - try { - cmafft = Configurator.configureExecutable(mafft, - Executable.ExecProvider.Local); - AsyncExecutor sexec = Configurator.getAsyncEngine(cmafft, - ExecProvider.Local); - String jobId = sexec.submitJob(cmafft); - FilePuller fw = FilePuller.newFilePuller(compbio.engine.client.EngineUtil - .getFullPath(cmafft.getWorkDirectory(), cmafft.getError()), - 256); - int count = 0; - long position = 0; - fw.waitForFile(4); - while (fw.hasMoreData()) { - ChunkHolder ch = fw.pull(position); - String chunk = ch.getChunk(); - position = ch.getNextPosition(); - System.out.print("CHUNK:" + chunk); - count++; - } - assertTrue(count > 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException 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 testConfigurationLoading() { - try { - RunnerConfig mafftConfig = ConfExecutable - .getRunnerOptions(Mafft.class); - assertNotNull(mafftConfig); - assertTrue(mafftConfig.getArguments().size() > 0); - - PresetManager mafftPresets = ConfExecutable - .getRunnerPresets(Mafft.class); - assertNotNull(mafftPresets); - assertTrue(mafftPresets.getPresets().size() > 0); - mafftPresets.validate(mafftConfig); - - LimitsManager mafftLimits = ConfExecutable - .getRunnerLimits(Mafft.class); - assertNotNull(mafftLimits); - assertTrue(mafftLimits.getLimits().size() > 0); - mafftLimits.validate(mafftPresets); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } -} diff --git a/testsrc/compbio/casscode/msa/MuscleParametersTester.java b/testsrc/compbio/casscode/msa/MuscleParametersTester.java deleted file mode 100644 index eb298c8..0000000 --- a/testsrc/compbio/casscode/msa/MuscleParametersTester.java +++ /dev/null @@ -1,268 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.ValidationException; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.engine.Configurator; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable.ExecProvider; -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.engine.local.ExecutableWrapper; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.Option; -import compbio.metadata.Parameter; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.OptionCombinator; -import compbio.runner.msa.Muscle; -import compbio.util.FileUtil; -import compbio.util.Util; - -public class MuscleParametersTester { - - static final String muscleConfigFile = AllTestSuit.TEST_DATA_PATH - + "MuscleParameters.xml"; - public static String test_outfile = "TO1381.muscle.out"; - public static String cluster_test_outfile = "TO1381.muscle.cluster.out"; - public static final String input = AllTestSuit.TEST_DATA_PATH - + "MusclePresets.xml"; - - private static Logger log = Logger - .getLogger(AllTestSuit.RUNNER_TEST_LOGGER); - static { - log.setLevel(Level.INFO); - } - - RunnerConfig muscleConfig = null; - OptionCombinator muscleOpc = null; - PresetManager presets = null; - - @BeforeMethod(groups = { AllTestSuit.test_group_runner }) - public void setup() { - try { - RunnerConfigMarshaller clustalmarsh = new RunnerConfigMarshaller( - RunnerConfig.class); - muscleConfig = clustalmarsh.read(new FileInputStream(new File( - muscleConfigFile)), RunnerConfig.class); - muscleOpc = new OptionCombinator(muscleConfig); - - // Load presets - RunnerConfigMarshaller rconfigPresets = new RunnerConfigMarshaller( - PresetManager.class); - File infile = new File(input); - assertTrue(infile.exists()); - presets = rconfigPresets.read(new FileInputStream(infile), - PresetManager.class); - assertNotNull(presets); - assertFalse(presets.getPresets().isEmpty()); - - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testDefaultParameters() { - Muscle muscle = new Muscle(); - muscle.setInput(AllTestSuit.test_input).setOutput(test_outfile); - - try { - // For local execution use relavive - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle); - LocalRunner lr = new LocalRunner(confMuscle); - lr.executeJob(); - ConfiguredExecutable al = lr.waitForResult(); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test - public void testConfiguration() { - try { - muscleConfig.validate(); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IllegalStateException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testOptions() { - test(muscleOpc.getAllOptions()); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testParameters() { - List> params = muscleOpc.getAllParameters(); - Collections.shuffle(params); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testArguments() { - List> options = new ArrayList>(muscleConfig - .getOptions()); - options.addAll(muscleOpc.getAllParameters()); - Collections.shuffle(options); - test(options); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testConstrainedParametersMinValues() { - Map, String> params = muscleOpc - .getAllConstrainedParametersWithBorderValues(true); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testConstrainedParametersMaxValues() { - Map, String> params = muscleOpc - .getAllConstrainedParametersWithBorderValues(false); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testConstrainedParametersRandomValues() { - for (int i = 0; i < 20; i++) { - Map, String> params = muscleOpc - .getAllConstrainedParametersWithRandomValues(); - List> paramList = new ArrayList>(params - .keySet()); - Collections.shuffle(paramList); - List> subList = paramList.subList(0, Util - .getRandomNumber(1, paramList.size())); - List args = muscleOpc.parametersToCommandString(subList, - params); - singleTest(args); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testPresets() { - for (Preset p : presets.getPresets()) { - singleTest(p.getOptions()); - } - } - - void test(Map, String> paramValue) { - List> paramList = new ArrayList>(paramValue - .keySet()); - for (int i = 0; i < paramValue.size(); i++) { - List args = muscleOpc.parametersToCommandString(paramList, - paramValue); - singleTest(args); - Collections.shuffle(paramList); - } - log.info("NUMBER OF COBINATION TESTED: " + paramValue.size()); - } - - void test(List> params) { - for (int i = 0; i < params.size(); i++) { - List args = muscleOpc.argumentsToCommandString(params); - singleTest(args); - Collections.shuffle(params); - } - log.info("NUMBER OF COBINATION TESTED: " + params.size()); - } - - void singleTest(List params) { - try { - log.info("Using arguments: " + params); - Muscle muscle = new Muscle(); - muscle.setInput(AllTestSuit.test_input).setOutput(test_outfile); - - // For local execution use relative - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle, ExecProvider.Local); - System.out.println("Using params:" + params); - // Add options to the executable - confMuscle.addParameters(params); - - LocalRunner lr = new LocalRunner(confMuscle); - lr.executeJob(); - ConfiguredExecutable al = lr.waitForResult(); - assertNotNull(al.getResults()); - File errors = new File(confMuscle.getWorkDirectory(), - ExecutableWrapper.PROC_ERR_FILE); - if (errors.length() != 0) { - log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors)); - } - assertTrue(errors.length() == 0, "Run with arguments : " + params - + " FAILED!"); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/casscode/msa/MuscleTester.java b/testsrc/compbio/casscode/msa/MuscleTester.java deleted file mode 100644 index 354246c..0000000 --- a/testsrc/compbio/casscode/msa/MuscleTester.java +++ /dev/null @@ -1,334 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNotSame; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; - -import javax.xml.bind.ValidationException; - -import org.ggf.drmaa.DrmaaException; -import org.ggf.drmaa.JobInfo; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.data.sequence.Alignment; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -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.msa.Muscle; -import compbio.util.FileWatcher; -import compbio.util.SysPrefs; - -public class MuscleTester { - - public static String test_outfile = "TO1381.muscle.out"; // homes/pvtroshin/TO1381.clustal.out - public static String cluster_test_outfile = "TO1381.muscle.cluster.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out - - private Muscle muscle; - - @BeforeMethod(alwaysRun = true) - void init() { - muscle = new Muscle(); - muscle.setInput(AllTestSuit.test_input).setOutput(cluster_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"); - try { - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle, - Executable.ExecProvider.Cluster); - ClusterRunner runner = ClusterRunner.getInstance(confMuscle); - - 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!"); - 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 = ClusterEngineUtil.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()); - } - 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()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (DrmaaException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } - } - - /** - * 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(enabled = false, groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner }) - public void testRunOnClusterAsync() { - assertFalse(SysPrefs.isWindows, - "Cluster execution can only be in unix environment"); - try { - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle, - Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confMuscle); - String jobId = aengine.submitJob(confMuscle); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED || status !=JobStatus.UNDEFINED) { - System.out.println("Job Status: " + status); - Thread.sleep(1000); - status = aengine.getJobStatus(jobId); - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testRunLocally() { - try { - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle, Executable.ExecProvider.Local); - confMuscle.getParameters().setParam("-matrix", "BLOSUM62"); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confMuscle); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - Alignment al2 = confMuscle.getResults(); - assertNotNull(al2); - assertEquals(al1.getResults(), al2); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void readStatistics() { - try { - ConfiguredExecutable confMuscle = Configurator - .configureExecutable(muscle, Executable.ExecProvider.Local); - // For local execution use relavive - - AsyncExecutor sexec = Configurator.getAsyncEngine(confMuscle); - String jobId = sexec.submitJob(confMuscle); - FilePuller fw = FilePuller.newFilePuller(confMuscle - .getWorkDirectory() - + File.separator + Muscle.getStatFile(), - 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); - count++; - } - assertTrue(count > 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException 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 { - Muscle muscle = new Muscle(); - muscle.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); - assertEquals(muscle.getInput(), AllTestSuit.test_input); - assertEquals(muscle.getError(), "errrr.txt"); - assertEquals(muscle.getOutput(), "outtt.txt"); - ConfiguredExecutable cmuscle = Configurator - .configureExecutable(muscle, Executable.ExecProvider.Local); - - SyncExecutor sexec = Configurator.getSyncEngine(cmuscle); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - // Save run configuration - assertTrue(cmuscle.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cmuscle - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals(((ConfExecutable) cmuscle) - .getRunConfiguration(), loadedRun); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCMuscle = (ConfiguredExecutable) cmuscle - .loadRunConfiguration(new FileInputStream(new File(cmuscle - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCMuscle); - assertEquals(resurrectedCMuscle.getExecutable().getInput(), - AllTestSuit.test_input); - assertEquals(resurrectedCMuscle.getExecutable().getError(), - "errrr.txt"); - assertEquals(resurrectedCMuscle.getExecutable().getOutput(), - "outtt.txt"); - // See in details whether executables are the same - assertEquals(resurrectedCMuscle.getExecutable(), muscle); - - ConfiguredExecutable resmuscle = Configurator - .configureExecutable(resurrectedCMuscle.getExecutable(), - Executable.ExecProvider.Local); - - sexec = Configurator.getSyncEngine(resmuscle, - Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testConfigurationLoading() { - try { - RunnerConfig muscleConfig = ConfExecutable - .getRunnerOptions(Muscle.class); - assertNotNull(muscleConfig); - assertTrue(muscleConfig.getArguments().size() > 0); - - PresetManager musclePresets = ConfExecutable - .getRunnerPresets(Muscle.class); - assertNotNull(musclePresets); - assertTrue(musclePresets.getPresets().size() > 0); - musclePresets.validate(muscleConfig); - - LimitsManager muscleLimits = ConfExecutable - .getRunnerLimits(Muscle.class); - assertNotNull(muscleLimits); - assertTrue(muscleLimits.getLimits().size() > 0); - muscleLimits.validate(musclePresets); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/casscode/msa/ProbconsParametersTester.java b/testsrc/compbio/casscode/msa/ProbconsParametersTester.java deleted file mode 100644 index dd9a009..0000000 --- a/testsrc/compbio/casscode/msa/ProbconsParametersTester.java +++ /dev/null @@ -1,248 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.ValidationException; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.engine.Configurator; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable.ExecProvider; -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.Option; -import compbio.metadata.Parameter; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.OptionCombinator; -import compbio.runner.msa.Probcons; -import compbio.util.Util; - -public class ProbconsParametersTester { - - static final String probconsConfigFile = AllTestSuit.TEST_DATA_PATH - + "ProbconsParameters.xml"; - - public static String test_outfile = "TO1381.probcons.out"; - - private static Logger log = Logger - .getLogger(AllTestSuit.RUNNER_TEST_LOGGER); - static { - log.setLevel(Level.INFO); - } - - PresetManager presets = null; - RunnerConfig probconsConfig = null; - OptionCombinator probconsOpc = null; - - @BeforeMethod(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void setup() { - try { - // Load parameters - RunnerConfigMarshaller mafftmarsh = new RunnerConfigMarshaller( - RunnerConfig.class); - probconsConfig = mafftmarsh.read(new FileInputStream(new File( - probconsConfigFile)), RunnerConfig.class); - probconsOpc = new OptionCombinator(probconsConfig); - - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - - } - - @Test - public void testConfiguration() { - try { - this.probconsConfig.validate(); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IllegalStateException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testDefaultParameters() { - Probcons mafft = new Probcons(); - mafft.setInput(AllTestSuit.test_input).setOutput(test_outfile); - - try { - // For local execution use relavive - ConfiguredExecutable confMafft = Configurator - .configureExecutable(mafft, ExecProvider.Cluster); - SyncExecutor sexecutor = Configurator.getSyncEngine(confMafft); - sexecutor.executeJob(); - confMafft = (ConfiguredExecutable) sexecutor - .waitForResult(); - assertNotNull(confMafft.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testOptions() { - test(probconsOpc.getAllOptions()); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testParameters() { - List> params = probconsOpc.getAllParameters(); - Collections.shuffle(params); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testArguments() { - List> options = new ArrayList>(probconsConfig - .getOptions()); - options.addAll(probconsOpc.getAllParameters()); - Collections.shuffle(options); - test(options); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testConstrainedParametersMinValues() { - Map, String> params = probconsOpc - .getAllConstrainedParametersWithBorderValues(true); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testConstrainedParametersMaxValues() { - Map, String> params = probconsOpc - .getAllConstrainedParametersWithBorderValues(false); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testConstrainedParametersRandomValues() { - for (int i = 0; i < 20; i++) { - Map, String> params = probconsOpc - .getAllConstrainedParametersWithRandomValues(); - List> paramList = new ArrayList>(params - .keySet()); - Collections.shuffle(paramList); - List> subList = paramList.subList(0, Util - .getRandomNumber(1, paramList.size())); - List args = probconsOpc.parametersToCommandString(subList, - params); - singleTest(args); - } - } - - void test(Map, String> paramValue) { - List> paramList = new ArrayList>(paramValue - .keySet()); - for (int i = 0; i < paramValue.size(); i++) { - List args = probconsOpc.parametersToCommandString( - paramList, paramValue); - singleTest(args); - Collections.shuffle(paramList); - } - log.info("NUMBER OF COBINATION TESTED: " + paramValue.size()); - } - - void test(List> params) { - for (int i = 0; i < params.size(); i++) { - List args = probconsOpc.argumentsToCommandString(params); - singleTest(args); - Collections.shuffle(params); - } - log.info("NUMBER OF COBINATION TESTED: " + params.size()); - } - - void singleTest(List params) { - try { - log.info("Using arguments: " + params); - Probcons mafft = new Probcons(); - mafft.setInput(AllTestSuit.test_input).setOutput(test_outfile); - - // For local execution use relative - ConfiguredExecutable confMafft = Configurator - .configureExecutable(mafft, ExecProvider.Local); - // Add options to the executable - confMafft.addParameters(params); - - SyncExecutor sexecutor = Configurator.getSyncEngine(confMafft); - sexecutor.executeJob(); - ConfiguredExecutable al = sexecutor.waitForResult(); - assertNotNull(al.getResults()); - /* - * TODO File errors = new File(confMafft.getWorkDirectory(), - * ExecutableWrapper.PROC_ERR_FILE); if (errors.length() != 0) { - * log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors)); } - * assertTrue("Run with arguments : " + params + " FAILED!", errors - * .length() == 0); - */ - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/casscode/msa/ProbconsTester.java b/testsrc/compbio/casscode/msa/ProbconsTester.java deleted file mode 100644 index 36fffba..0000000 --- a/testsrc/compbio/casscode/msa/ProbconsTester.java +++ /dev/null @@ -1,262 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; - -import javax.xml.bind.ValidationException; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.LimitsManager; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; - -public class ProbconsTester { - - private Probcons probc; - - @BeforeMethod(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) - public void init() { - probc = new Probcons(); - probc.setInput(AllTestSuit.test_input); // .setOutput("Mafft.out").setError("mafft.progress"); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testSetInputTester() { - Probcons mf = new Probcons(); - // System.out.println(mf.getParameters(null)); - mf.setInput("INNN"); - // System.out.println(mf.getParameters(null)); - mf.setError("ERRR"); - mf.setInput("INN222"); - mf.setOutput("OUT"); - // System.out.println(mf.getParameters(null)); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testExecute() { - try { - ConfiguredExecutable cmafft = Configurator - .configureExecutable(probc, Executable.ExecProvider.Local); - // option for sub matrix is not supported - // cmafft.getParameters().setParam("--matrixfile", "PAM200"); - SyncExecutor sexecutor = Configurator.getSyncEngine(cmafft); - sexecutor.executeJob(); - cmafft = (ConfiguredExecutable) sexecutor.waitForResult(); - assertNotNull(cmafft.getResults()); - } 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 testPersistance() { - try { - Probcons mafft = new Probcons(); - mafft.setError("errrr.txt").setInput(AllTestSuit.test_input) - .setOutput("outtt.txt"); - assertEquals(mafft.getInput(), AllTestSuit.test_input); - assertEquals(mafft.getError(), "errrr.txt"); - assertEquals(mafft.getOutput(), "outtt.txt"); - ConfiguredExecutable cmafft = Configurator - .configureExecutable(mafft, Executable.ExecProvider.Local); - - SyncExecutor sexec = Configurator.getSyncEngine(cmafft); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - // Save run configuration - assertTrue(cmafft.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration - .load(new FileInputStream(new File(cmafft - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals(((ConfExecutable) cmafft) - .getRunConfiguration(), loadedRun); - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCMafft = (ConfiguredExecutable) cmafft - .loadRunConfiguration(new FileInputStream(new File(cmafft - .getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(resurrectedCMafft); - // See in details whether executables are the same - assertEquals(resurrectedCMafft.getExecutable(), mafft); - - // Finally rerun the job in the new task directory - ConfiguredExecutable resmafft = Configurator - .configureExecutable(resurrectedCMafft.getExecutable(), - Executable.ExecProvider.Local); - - sexec = Configurator.getSyncEngine(resmafft, - Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_cluster, - AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows }) - public void testClusterExecute() { - try { - ConfiguredExecutable cmafft = Configurator - .configureExecutable(probc, Executable.ExecProvider.Cluster); - ClusterRunner sexecutor = (ClusterRunner) Configurator.getSyncEngine( - cmafft, Executable.ExecProvider.Cluster); - sexecutor.executeJob(); - ConfiguredExecutable al = sexecutor.waitForResult(); - assertNotNull(al.getResults()); - } 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 readStatistics() { - Probcons probs = new Probcons(); - probs.setError("errrr.txt").setInput(AllTestSuit.test_input).setOutput( - "outtt.txt"); - ConfiguredExecutable cprobs; - - try { - cprobs = Configurator.configureExecutable(probs, - Executable.ExecProvider.Local); - AsyncExecutor sexec = Configurator.getAsyncEngine(cprobs); - String jobId = sexec.submitJob(cprobs); - FilePuller fw = FilePuller.newFilePuller(compbio.engine.client.EngineUtil - .getFullPath(cprobs.getWorkDirectory(), cprobs.getError()), - 256); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - // Code below is performance dependent - // thus cannot be moved up before the results is obtained - int count = 0; - long position = 0; - fw.waitForFile(6); - while (fw.hasMoreData()) { - ChunkHolder ch = fw.pull(position); - String chunk = ch.getChunk(); - position = ch.getNextPosition(); - System.out.print("CHUNK:" + chunk); - count++; - } - assertTrue(count > 1, "TaskId:" + jobId); - - } catch (JobSubmissionException 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 testConfigurationLoading() { - try { - RunnerConfig probsConfig = ConfExecutable - .getRunnerOptions(Probcons.class); - assertNotNull(probsConfig); - assertTrue(probsConfig.getArguments().size() > 0); - - PresetManager probsPresets = ConfExecutable - .getRunnerPresets(Probcons.class); - assertNull(probsPresets); - - LimitsManager probsLimits = ConfExecutable - .getRunnerLimits(Probcons.class); - assertNotNull(probsLimits); - assertTrue(probsLimits.getLimits().size() > 0); - probsLimits.validate(probsPresets); - - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } -} diff --git a/testsrc/compbio/casscode/msa/TcoffeeParametersTester.java b/testsrc/compbio/casscode/msa/TcoffeeParametersTester.java deleted file mode 100644 index 9565f82..0000000 --- a/testsrc/compbio/casscode/msa/TcoffeeParametersTester.java +++ /dev/null @@ -1,243 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * - * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0 - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.fail; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.ValidationException; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.engine.Configurator; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable.ExecProvider; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.Option; -import compbio.metadata.Parameter; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.OptionCombinator; -import compbio.runner.msa.Tcoffee; -import compbio.util.Util; - - -public class TcoffeeParametersTester { - - public static String test_outfile = "TO1381.tcoffee.out"; - - private static Logger log = Logger - .getLogger(AllTestSuit.RUNNER_TEST_LOGGER); - static { - log.setLevel(Level.INFO); - } - - RunnerConfig tcoffeeConfig = compbio.runner.RunnerUtil.getSupportedOptions(Tcoffee.class); - OptionCombinator tcoffeeOpc = null; - PresetManager presets = compbio.runner.RunnerUtil.getPresets(Tcoffee.class); - - @BeforeMethod(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void setup() { - tcoffeeOpc = new OptionCombinator(tcoffeeConfig); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testDefaultParameters() { - Tcoffee tcoffee = new Tcoffee(); - tcoffee.setInput(AllTestSuit.test_input).setOutput(test_outfile); - - try { - // For local execution use relavive - ConfiguredExecutable confTcoffee = Configurator - .configureExecutable(tcoffee, ExecProvider.Cluster); - SyncExecutor sexecutor = Configurator.getSyncEngine(confTcoffee); - sexecutor.executeJob(); - ConfiguredExecutable al = sexecutor.waitForResult(); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test - public void testConfiguration() { - try { - this.tcoffeeConfig.validate(); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IllegalStateException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testOptions() { - test(tcoffeeOpc.getAllOptions()); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testParameters() { - List> params = tcoffeeOpc.getAllParameters(); - Collections.shuffle(params); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testArguments() { - List> options = new ArrayList>(tcoffeeConfig - .getOptions()); - options.addAll(tcoffeeOpc.getAllParameters()); - Collections.shuffle(options); - test(options); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testConstrainedParametersMinValues() { - Map, String> params = tcoffeeOpc - .getAllConstrainedParametersWithBorderValues(true); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testConstrainedParametersMaxValues() { - Map, String> params = tcoffeeOpc - .getAllConstrainedParametersWithBorderValues(false); - test(params); - } - - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testConstrainedParametersRandomValues() { - for (int i = 0; i < 20; i++) { - Map, String> params = tcoffeeOpc - .getAllConstrainedParametersWithRandomValues(); - List> paramList = new ArrayList>(params - .keySet()); - Collections.shuffle(paramList); - List> subList = paramList.subList(0, Util - .getRandomNumber(1, paramList.size())); - List args = tcoffeeOpc.parametersToCommandString(subList, - params); - singleTest(args); - } - } - - // TODO fix this! - // This is due to incorrect installation of Blast with tcoffee mode - // expresso. - // It is either have to be fixed or removed - @Test(groups = { AllTestSuit.test_group_runner, - AllTestSuit.test_group_non_windows }) - public void testPresets() { - for (Preset p : presets.getPresets()) { - singleTest(p.getOptions()); - } - } - - void test(Map, String> paramValue) { - List> paramList = new ArrayList>(paramValue - .keySet()); - for (int i = 0; i < paramValue.size(); i++) { - List args = tcoffeeOpc.parametersToCommandString(paramList, - paramValue); - singleTest(args); - Collections.shuffle(paramList); - } - log.info("NUMBER OF COBINATION TESTED: " + paramValue.size()); - } - - void test(List> params) { - for (int i = 0; i < params.size(); i++) { - List args = tcoffeeOpc.argumentsToCommandString(params); - singleTest(args); - Collections.shuffle(params); - } - log.info("NUMBER OF COBINATION TESTED: " + params.size()); - } - - void singleTest(List params) { - try { - log.info("Using arguments: " + params); - String input = AllTestSuit.test_input; - if (params.contains("-mode rcoffee")) { - input = AllTestSuit.test_input_dna; - } - Tcoffee tcoffee = new Tcoffee(); - tcoffee.setInput(input).setOutput(test_outfile); - - // For local execution use relative - ConfiguredExecutable confTcoffee = Configurator - .configureExecutable(tcoffee, ExecProvider.Local); - // Add options to the executable - confTcoffee.addParameters(params); - - SyncExecutor sexecutor = Configurator.getSyncEngine(confTcoffee, - ExecProvider.Local); - sexecutor.executeJob(); - ConfiguredExecutable al = sexecutor.waitForResult(); - assertNotNull(al.getResults()); - /* - * TODO File errors = new File(confMafft.getWorkDirectory(), - * ExecutableWrapper.PROC_ERR_FILE); if (errors.length() != 0) { - * log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors)); } - * assertTrue("Run with arguments : " + params + " FAILED!", errors - * .length() == 0); - */ - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/casscode/msa/TcoffeeTester.java b/testsrc/compbio/casscode/msa/TcoffeeTester.java deleted file mode 100644 index 8fc2e99..0000000 --- a/testsrc/compbio/casscode/msa/TcoffeeTester.java +++ /dev/null @@ -1,268 +0,0 @@ -/* Copyright (c) 2009 Peter Troshin - * Copyright (c) 2013 Alexander Sherstnev - * - * 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 - * - * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without - * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache - * License for more details. - * - * A copy of the license is in apache_license.txt. It is also available here: - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form - * must include this copyright and license notice. - */ - -package compbio.runner.msa; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -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; - -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.data.sequence.Alignment; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -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.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}) - public void init() { - tcoffee = new Tcoffee(); - 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 RunLocally() { - try { - 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); - -// 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()); - } 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 readStatistics() { - try { - Tcoffee tcoffee = new Tcoffee().setInput(AllTestSuit.test_input); - ConfiguredExecutable confTcoffee = Configurator.configureExecutable(tcoffee, Executable.ExecProvider.Local); - - AsyncExecutor sexec = Configurator.getAsyncEngine(confTcoffee); - String jobId = sexec.submitJob(confTcoffee); - 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()) { - if (fw.hasMoreData()) { - ChunkHolder ch = fw.pull(position); - String chunk = ch.getChunk(); - position = ch.getNextPosition(); - System.out.print(chunk); - } - count++; - } - assertTrue(count > 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException 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, AllTestSuit.test_group_non_windows }) - public void SetNcore() { - Tcoffee tc = new Tcoffee(); - assertEquals(tc.getParameters(null).size(), 3); - tc.setNCore(2); - assertEquals(2, tc.getNCore()); - assertEquals(tc.getParameters(null).size(), 3); - tc.setNCore(4); - assertEquals(4, tc.getNCore()); - assertEquals(tc.getParameters(null).size(), 3); - } - - @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"); - 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); - SyncExecutor sexec = Configurator.getSyncEngine(ctcofee); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - // Save run configuration - 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); - - // Load run configuration as ConfExecutable - ConfiguredExecutable resurrectedCTcoffee = (ConfiguredExecutable) ctcofee - .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); - - sexec = Configurator.getSyncEngine(restcoffee,Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void ConfigurationLoading() { - try { - RunnerConfig tcoffeeConfig = ConfExecutable.getRunnerOptions(Tcoffee.class); - assertNotNull(tcoffeeConfig); - assertTrue(tcoffeeConfig.getArguments().size() > 0); - - PresetManager tcoffeePresets = ConfExecutable.getRunnerPresets(Tcoffee.class); - assertNotNull(tcoffeePresets); - assertTrue(tcoffeePresets.getPresets().size() > 0); - tcoffeePresets.validate(tcoffeeConfig); - - LimitsManager tcoffeeLimits = ConfExecutable.getRunnerLimits(Tcoffee.class); - assertNotNull(tcoffeeLimits); - assertTrue(tcoffeeLimits.getLimits().size() > 0); - tcoffeeLimits.validate(tcoffeePresets); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - 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); - ClusterRunner sexecutor = (ClusterRunner) 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()); - } - } -} diff --git a/testsrc/compbio/casscode/msa/mafftParams_modification_for_testing.txt b/testsrc/compbio/casscode/msa/mafftParams_modification_for_testing.txt deleted file mode 100644 index ee22041..0000000 --- a/testsrc/compbio/casscode/msa/mafftParams_modification_for_testing.txt +++ /dev/null @@ -1,3 +0,0 @@ - - -nuc option is removed as with protein sequence execution will fail - \ No newline at end of file diff --git a/testsrc/compbio/casscode/predictors/JpredTester.java b/testsrc/compbio/casscode/predictors/JpredTester.java deleted file mode 100644 index f053200..0000000 --- a/testsrc/compbio/casscode/predictors/JpredTester.java +++ /dev/null @@ -1,362 +0,0 @@ -/* Copyright (c) 2013 Alexander Sherstnev - * - * 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 This library is distributed in the hope - * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Apache License for more details. A copy of the license is in - * apache_license.txt. It is also available here: - * - * @see: http://www.apache.org/licenses/LICENSE-2.0.txt - * - * Any republication or derived work distributed in source code form must include - * this copyright and license notice. - */ -package compbio.runner.predictors; - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; -import java.util.Arrays; - -import javax.xml.bind.ValidationException; - -import org.ggf.drmaa.DrmaaException; -import org.ggf.drmaa.JobInfo; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.data.sequence.JpredAlignment; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.FilePuller; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.ChunkHolder; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobStatus; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.LimitsManager; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.RunnerUtil; -import compbio.util.FileWatcher; -import compbio.util.SysPrefs; - -public class JpredTester { - - public static final String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory() + File.separator; - - public static String test_output = "Jpred.test1.out"; - public static String test_input = CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata" + File.separator + "Jpred.test1.fasta"; - private Jpred pred; - - @BeforeMethod(alwaysRun = true) - void init() { - pred = new Jpred(); - pred.setInput(test_input); - pred.setOutput(test_output); - } - - // disabled - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void RunOnCluster() { - assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); - try { - PresetManager jpredPreset = RunnerUtil.getPresets(Jpred.class); - assert jpredPreset != null; - ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Cluster); - Preset conf = jpredPreset.getPresetByName("cluster configuration"); - confpred.addParameters(conf.getOptions()); - ClusterRunner runner = ClusterRunner.getInstance(confpred); - assertNotNull(runner, "Runner is NULL"); - - runner.executeJob(); - JobStatus status = runner.getJobStatus(); - 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, "Statistic manager is null"); - try { - String exits = sm.getExitStatus(); - assertNotNull("Exit status is null", exits); - // cut 4 trailing zeros from the number - int exitsInt = ClusterEngineUtil.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()); - } - 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()); - } - } - - // disabled - @Test(enabled=false,groups = {AllTestSuit.test_group_runner, AllTestSuit.test_group_cluster}) - public void RunOnClusterAsync() { - assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment"); - try { - pred.addParameters(Arrays.asList("-dbname uniref90", "-dbpath /homes/www-jpred/databases/")); - ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Cluster); - AsyncExecutor aengine = Configurator.getAsyncEngine(confpred); - String jobId = aengine.submitJob(confpred); - assertNotNull(jobId, "Runner is NULL"); - // let drmaa to start - Thread.sleep(500); - JobStatus status = aengine.getJobStatus(jobId); - while (status != JobStatus.FINISHED) { - Thread.sleep(1000); - status = aengine.getJobStatus(jobId); - ConfiguredExecutable result = (ConfiguredExecutable) aengine.getResults(jobId); - assertNotNull(result); - if (status == JobStatus.UNDEFINED || status == JobStatus.FAILED) { - fail("job " + jobId +" failed!"); - break; - } - } - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail("DrmaaException caught:" + e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(groups = {AllTestSuit.test_group_runner}) - public void RunLocally() { - try { - ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Local); - confpred.addParameters(Arrays.asList("-dbname ported_db", "-dbpath /data/UNIREFdb/")); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confpred); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - JpredAlignment totalign = (JpredAlignment) confpred.getResults(); - assertNotNull(totalign); - assertEquals(totalign.getSize(), 14); - assertEquals(al1.getResults(), totalign); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void RunLocallyWithPreset() { - try { - ConfiguredExecutable confpred = Configurator.configureExecutable(pred, Executable.ExecProvider.Local); - PresetManager preset = RunnerUtil.getPresets(Jpred.class); - assert preset != null; - Preset conf = preset.getPresetByName("laptop configuration"); - confpred.addParameters(conf.getOptions()); - - // For local execution use relative - LocalRunner lr = new LocalRunner(confpred); - lr.executeJob(); - ConfiguredExecutable al1 = lr.waitForResult(); - assertNotNull(al1.getResults()); - JpredAlignment totalign = (JpredAlignment) confpred.getResults(); - assertNotNull(totalign); - assertEquals(totalign.getSize(), 19); - assertEquals(al1.getResults(), totalign); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void readStatistics() { - try { - Jpred jpred = new Jpred(); - jpred.setInput(test_input); - jpred.setOutput(test_output); - ConfiguredExecutable confpred = Configurator.configureExecutable(jpred, Executable.ExecProvider.Local); - PresetManager preset = RunnerUtil.getPresets(Jpred.class); - assert preset != null; - Preset conf = preset.getPresetByName("laptop configuration"); - confpred.addParameters(conf.getOptions()); - - // For local execution use relative - AsyncExecutor sexec = Configurator.getAsyncEngine(confpred); - String jobId = sexec.submitJob(confpred); - String file = confpred.getWorkDirectory() + File.separator + Jpred.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 { - 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)) { - fail("job " + jobId +" failed!"); - break; - } - Thread.sleep(200); - status = sexec.getJobStatus(jobId); - } while (status != JobStatus.FINISHED || fw.hasMoreData()); - - assertTrue(count >= 1); - ConfiguredExecutable al = sexec.getResults(jobId); - assertNotNull(al.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (InterruptedException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void Persistance() { - try { - Jpred jpred = new Jpred(); - jpred.setError("errrr.txt"); - jpred.setInput(test_input); - jpred.setOutput("outtt.txt"); - assertEquals(jpred.getInput(), test_input); - assertEquals(jpred.getError(), "errrr.txt"); - assertEquals(jpred.getOutput(), "outtt.txt"); - ConfiguredExecutable confpred = Configurator.configureExecutable(jpred, Executable.ExecProvider.Local); - confpred.addParameters(Arrays.asList("-dbname ported_db", "-dbpath /data/UNIREFdb/")); - - SyncExecutor sexec = Configurator.getSyncEngine(confpred); - sexec.executeJob(); - ConfiguredExecutable al = sexec.waitForResult(); - assertNotNull(al.getResults()); - - // Save run configuration - assertTrue(confpred.saveRunConfiguration()); - - // See if loaded configuration is the same as saved - RunConfiguration loadedRun = RunConfiguration.load(new FileInputStream(new File(confpred.getWorkDirectory(), RunConfiguration.rconfigFile))); - assertEquals(((ConfExecutable) confpred).getRunConfiguration(),loadedRun); - - // Load run configuration as ConfExecutable - ConfiguredExecutable jpred2 = (ConfiguredExecutable) confpred.loadRunConfiguration(new FileInputStream(new File(confpred.getWorkDirectory(), RunConfiguration.rconfigFile))); - assertNotNull(jpred2); - assertEquals(jpred2.getExecutable().getInput(), test_input); - assertEquals(jpred2.getExecutable().getError(), "errrr.txt"); - assertEquals(jpred2.getExecutable().getOutput(), "outtt.txt"); - - // See in details whether executables are the same - assertEquals(jpred2.getExecutable(), jpred); - ConfiguredExecutable resjpred2 = Configurator.configureExecutable(jpred2.getExecutable(), Executable.ExecProvider.Local); - - sexec = Configurator.getSyncEngine(resjpred2, Executable.ExecProvider.Local); - sexec.executeJob(); - al = sexec.waitForResult(); - assertNotNull(al); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getMessage()); - } - } - - @Test(enabled=false,groups = {AllTestSuit.test_group_runner}) - public void ConfigurationLoading() { - try { - RunnerConfig jpredConfig = ConfExecutable.getRunnerOptions(Jpred.class); - assertNotNull(jpredConfig); - assertTrue(jpredConfig.getArguments().size() > 0); - - PresetManager jpredPreset = ConfExecutable.getRunnerPresets(Jpred.class); - assertNotNull(jpredPreset); - - LimitsManager jpredLimits = ConfExecutable.getRunnerLimits(Jpred.class); - assertNotNull(jpredLimits); - assertTrue(jpredLimits.getLimits().size() > 0); - jpredLimits.validate(jpredPreset); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - -} diff --git a/testsrc/compbio/casscode/structure/RNAalifoldParametersTester.java b/testsrc/compbio/casscode/structure/RNAalifoldParametersTester.java deleted file mode 100644 index 38fbe8b..0000000 --- a/testsrc/compbio/casscode/structure/RNAalifoldParametersTester.java +++ /dev/null @@ -1,448 +0,0 @@ -package compbio.runner.structure; - -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import javax.xml.bind.JAXBException; -import javax.xml.bind.ValidationException; - -import org.apache.log4j.Level; -import org.apache.log4j.Logger; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.data.sequence.RNAStructScoreManager; -import compbio.data.sequence.ScoreManager; -import compbio.engine.Configurator; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable.ExecProvider; -import compbio.engine.conf.RunnerConfigMarshaller; -import compbio.engine.local.ExecutableWrapper; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -import compbio.metadata.JobExecutionException; -import compbio.metadata.JobSubmissionException; -import compbio.metadata.Option; -import compbio.metadata.Parameter; -import compbio.metadata.Preset; -import compbio.metadata.PresetManager; -import compbio.metadata.ResultNotAvailableException; -import compbio.metadata.RunnerConfig; -import compbio.runner.OptionCombinator; -import compbio.runner.structure.RNAalifold; -import compbio.util.FileUtil; - - -public class RNAalifoldParametersTester { - - - // should be: AllTestSuit.TEST_DATA_PATH + "RNAalifoldParameters.xml" - static final String rnaalifoldConfigFile = - AllTestSuit.TEST_DATA_PATH + "RNAalifoldParameters.xml"; - public static String test_outfile = "rnaalifold.out.txt"; - - private static Logger log = Logger - .getLogger(AllTestSuit.RUNNER_TEST_LOGGER); - - static { - log.setLevel(Level.INFO); - } - - RunnerConfig rnaalifoldConfig = null; - OptionCombinator rnaalifoldOpc = null; - - @BeforeMethod(groups = { AllTestSuit.test_group_runner }) - @SuppressWarnings("unchecked") - public void setup() { - try { - RunnerConfigMarshaller rnaalifoldmarsh = - new RunnerConfigMarshaller(RunnerConfig.class); - rnaalifoldConfig = rnaalifoldmarsh.read(new FileInputStream(new File( - rnaalifoldConfigFile)), RunnerConfig.class); - // set Name value separator - rnaalifoldConfig.setPrmSeparator(" "); - rnaalifoldOpc = new OptionCombinator(rnaalifoldConfig); - - - - } catch (JAXBException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (FileNotFoundException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test - public void testConfiguration() { - try { - this.rnaalifoldConfig.validate(); - } catch (ValidationException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IllegalStateException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testDefaultParameters() { - RNAalifold rnaalifold = new RNAalifold(); - rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile); - - try { - // For local execution use relavive - ConfiguredExecutable confRNAalifold = Configurator - .configureExecutable(rnaalifold); - LocalRunner lr = new LocalRunner(confRNAalifold); - lr.executeJob(); - confRNAalifold = (ConfiguredExecutable) lr.waitForResult(); - assertNotNull(confRNAalifold.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - - - @Test - public void testOptions() { - // populate list of incompatable pairs by their names. todo - List> failPairs = new ArrayList>(); - - - // test the parameters without -g option - test(removeParam(rnaalifoldOpc.getAllOptions(), "G-Quadruplex")); - // now test without -c option - test(removeParam(rnaalifoldOpc.getAllOptions(), "Circular")); - } - - - // Prints all the incompatible option pairs - // (-c, -g) and (-p, -p0) - - @Test - public void testOptionPairs() throws ResultNotAvailableException { - List> pair = new ArrayList>(); - List> options = rnaalifoldOpc.getAllOptions(); - List> failedOptionPairs = new ArrayList>(); - - boolean failed = true; - for (int i = 0; i args = rnaalifoldOpc.argumentsToCommandString(pair); - try { - failed = singleRun(args); - } catch (ResultNotAvailableException e) { - System.out.println("Results not available: " + e.getMessage()); - failed = true; - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - if (failed == true) { - failedOptionPairs.add(args); - } - } - } - } - System.out.println("failedOptionPairs: " + failedOptionPairs); - - } - - // tests for incompatible Pairs of Parameters - // there are none however the --betascale parameter requires -p - - @Test - public void testParameterPairs() throws ResultNotAvailableException { - List> pair = new ArrayList>(); - List> Parameters = rnaalifoldOpc.getAllParameters(); - List> failedParameterPairs = new ArrayList>(); - - - boolean failed = true; - for (int i = 0; i args = rnaalifoldOpc.argumentsToCommandString(pair); - args.add("-p"); // --betascale requires -p - try { - failed = singleRun(args); - } catch (ResultNotAvailableException e) { - System.out.println("Results not available: " + e.getMessage()); - failed = true; - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - if (failed == true) { - failedParameterPairs.add(args); - } - } - } - } - System.out.println("failedParameterPairs: " + failedParameterPairs); - - } - - - // removes an argument from the list by name - public > List removeParam(List optionList, String name) { - List newL = new ArrayList(); - for (int i = 0; i < optionList.size(); i++) { - System.out.println(name.equals(optionList.get(i).getName())); - if (!name.equals(optionList.get(i).getName())) { - - newL.add(optionList.get(i)); - } - - } - return newL; - } - - public > List removeParams(List optionList, List names) { - for (int i = 0; i < names.size(); i++) { - optionList = removeParam(optionList, names.get(i)); - } - return optionList; - } - - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testParameters() { - List> params = rnaalifoldOpc.getAllParameters(); - System.out.println("param list: " + params); - Collections.shuffle(params); - // test with -p for betascale option - List precursor = new ArrayList(); - precursor.add("-p"); - - test(params, precursor); - } - - // incompatible pairs of arguments are - /* - * the -c and -g options - * the -d2 option and the -d option - * the -p and -p0 option - */ - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testArguments() { - List> options = rnaalifoldOpc.getAllOptions(); - options.addAll(rnaalifoldOpc.getAllParameters()); - Collections.shuffle(options); - test(options); - } - - // This test supercedes the testParameterPair() and testOptionPair() - // tests by testing all pairs of arguments - - - @Test - public void testAllPairs() throws ResultNotAvailableException { - List> pair = new ArrayList>(); - List> options = rnaalifoldOpc.getAllOptions(); - - // take out -p options so it can be added to all commands later - // options = removeParam(options, "Partition Function"); - - options.addAll(rnaalifoldOpc.getAllParameters()); - List> failedOptionPairs = new ArrayList>(); - - boolean failed = true; - for (int i = 0; i args = rnaalifoldOpc.argumentsToCommandString(pair); - // add -p - // args.add("-p"); - try { - failed = singleRun(args); - } catch (ResultNotAvailableException e) { - System.out.println("Results not available: " + e.getMessage()); - failed = true; - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - if (failed == true) { - failedOptionPairs.add(args); - } - } - } - } - System.out.println("failedOptionPairs: " + failedOptionPairs); - } - - /* - * This test method stolen from the other parameter testing classes - * the only purpose of the Collections.shuffle(params) and the for loop - * is to test giving the executable the parameters in different orders - * which leads to a lot of (unnecessary?) tests with an argument list - * as long as this one. - * - */ - - - void test(List> params) { - for (int i = 0; i < params.size(); i++) { - List args = rnaalifoldOpc.argumentsToCommandString(params); - singleTest(args); - Collections.shuffle(params); - } - log.info("NUMBER OF COMBINATION TESTED: " + params.size()); - } - - // because some parameters presuppose the -p option - - void test(List> params, List precursor) { - - for (int i = 0; i < params.size(); i++) { - List args = rnaalifoldOpc.argumentsToCommandString(params); - args.addAll(precursor); - singleTest(args); - Collections.shuffle(params); - } - log.info("NUMBER OF COMBINATION TESTED: " + params.size()); - } - @Test - void singleParamTest() { - //List> params = rnaalifoldOpc.getAllParameters(); - //System.out.println("special: params: " + params); - - //List args = rnaalifoldOpc.argumentsToCommandString(params); - List args = new ArrayList(); - //args.add("-T 37"); args.add("-S 1.07"); args.add("--stochBT_en 10"); - // replace "=" with " " to fail test - args.add("--MEA=1"); - args.add("-p"); - singleTest(args); - - } - - void singleTest(List params) { - try { - log.info("Using arguments: " + params); - RNAalifold rnaalifold = new RNAalifold(); - rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile); - - ConfiguredExecutable confRNAalifold = Configurator - .configureExecutable(rnaalifold, ExecProvider.Local); - // Add options to the executable - confRNAalifold.addParameters(params); - LocalRunner lr = new LocalRunner(confRNAalifold); - lr.executeJob(); - confRNAalifold = (ConfiguredExecutable) lr.waitForResult(); - assertNotNull(confRNAalifold.getResults(), "results is null"); - - System.out.println("Results: \n" - + ((RNAStructScoreManager) confRNAalifold.getResults()).toString()); - - File errors = new File(confRNAalifold.getWorkDirectory(), - ExecutableWrapper.PROC_ERR_FILE); - if (errors.length() != 0) { - log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors)); - } - assertTrue(errors.length() == 0, "Run with arguments : " + params - + " FAILED!"); - Collections.shuffle(params); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (IOException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - /* A version of singleTest that continues running instead of calling - * fail() when it encounters a problem - * - * Used to identify incompatible options and parameters - * returns -1 on failure - * - * Bad Progamming practice? - */ - - - boolean singleRun(List params) throws JobSubmissionException, - JobExecutionException, IOException, ResultNotAvailableException { - boolean fail = true; - log.info("Using arguments: " + params); - RNAalifold rnaalifold = new RNAalifold(); - rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile); - - ConfiguredExecutable confRNAalifold = Configurator - .configureExecutable(rnaalifold, ExecProvider.Local); - // Add options to the executable - confRNAalifold.addParameters(params); - LocalRunner lr = new LocalRunner(confRNAalifold); - lr.executeJob(); - confRNAalifold = (ConfiguredExecutable) lr.waitForResult(); - - System.out.println("Results: \n" - + ((RNAStructScoreManager) confRNAalifold.getResults()).toString()); - if (confRNAalifold.getResults() != null) fail = false; - File errors = new File(confRNAalifold.getWorkDirectory(), - ExecutableWrapper.PROC_ERR_FILE); - if (errors.length() != 0) { - log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors)); - } - assertTrue(errors.length() == 0, "Run with arguments : " + params - + " FAILED!"); - Collections.shuffle(params); - return fail; - } -} diff --git a/testsrc/compbio/casscode/structure/RNAalifoldTester.java b/testsrc/compbio/casscode/structure/RNAalifoldTester.java deleted file mode 100644 index 370d040..0000000 --- a/testsrc/compbio/casscode/structure/RNAalifoldTester.java +++ /dev/null @@ -1,119 +0,0 @@ -package compbio.runner.structure; - - -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.text.ParseException; - -import javax.xml.bind.ValidationException; - -import org.apache.log4j.*; -import org.ggf.drmaa.DrmaaException; -import org.ggf.drmaa.JobInfo; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; - -import compbio.data.sequence.RNAStructScoreManager; -import compbio.data.sequence.Score; -import compbio.data.sequence.ScoreManager; -import compbio.data.sequence.ScoreManager.ScoreHolder; -import compbio.data.sequence.SequenceUtil; -import compbio.engine.AsyncExecutor; -import compbio.engine.Configurator; -import compbio.engine.SyncExecutor; -import compbio.engine.client.ConfExecutable; -import compbio.engine.client.ConfiguredExecutable; -import compbio.engine.client.Executable; -import compbio.engine.client.RunConfiguration; -import compbio.engine.cluster.drmaa.ClusterEngineUtil; -import compbio.engine.cluster.drmaa.ClusterRunner; -import compbio.engine.cluster.drmaa.StatisticManager; -import compbio.engine.local.AsyncLocalRunner; -import compbio.engine.local.LocalExecutorService; -import compbio.engine.local.LocalRunner; -import compbio.metadata.AllTestSuit; -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.msa.ClustalW; -import compbio.runner.structure.RNAalifold; - -public class RNAalifoldTester { - - private static Logger log = Logger - .getLogger(AllTestSuit.RUNNER_TEST_LOGGER); - - - private RNAalifold rnaalifold; - - static final String rnaalifoldConfigFile = AllTestSuit.TEST_DATA_PATH - + "RNAalifoldParameters.xml"; - public static String test_outfile = "rnaalifold.out"; - - - @Test(groups = { AllTestSuit.test_group_runner }) - public void testRunLocally() { - RNAalifold rnaalifold = new RNAalifold(); - rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile); - try{ - - ConfiguredExecutable confRNAalifold = Configurator - .configureExecutable(rnaalifold, Executable.ExecProvider.Local); - LocalRunner lr = new LocalRunner(confRNAalifold); - lr.executeJob(); - confRNAalifold = (ConfiguredExecutable) lr.waitForResult(); - - System.out.println("TEST"); - System.out.println(((RNAStructScoreManager) confRNAalifold.getResults()).toString()); - - assertNotNull(confRNAalifold.getResults()); - } catch (JobSubmissionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (JobExecutionException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } catch (ResultNotAvailableException e) { - e.printStackTrace(); - fail(e.getLocalizedMessage()); - } - } - - - public static void main(String[] args) throws JobSubmissionException, - JobExecutionException, InterruptedException, ResultNotAvailableException { - - - log.warn("Logger test :- Run RNAalifold.main()"); - - RNAalifold rnaalifold = new RNAalifold(); - rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput("test_outfile.txt"); - - ConfiguredExecutable confRNAalifold = Configurator - .configureExecutable(rnaalifold); - AsyncExecutor lr = new AsyncLocalRunner(); - lr.submitJob(confRNAalifold); - - - System.out.println(((RNAStructScoreManager) confRNAalifold.getResults()).toString()); - - - Thread.sleep(3000); - LocalExecutorService.shutDown(); - - } - -} -- 1.7.10.2