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