Check and correct several runner testers
authorSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 8 Aug 2013 13:12:07 +0000 (14:12 +0100)
committerSasha Sherstnev <a.sherstnev@dundee.ac.uk>
Thu, 8 Aug 2013 13:12:07 +0000 (14:12 +0100)
testsrc/compbio/runner/conservation/AAConTester.java
testsrc/compbio/runner/disorder/JronnTester.java
testsrc/compbio/runner/msa/ClustalOTester.java
testsrc/compbio/runner/msa/ClustalWTester.java
testsrc/compbio/runner/msa/TcoffeeTester.java

index 353509a..b453eb7 100644 (file)
@@ -1,6 +1,8 @@
-/*\r
- * Copyright (c) 2010 Peter Troshin JAva Bioinformatics Analysis Web Services\r
- * (JABAWS) @version: 2.0 \r
+/* 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
@@ -29,7 +31,6 @@ import java.io.FileNotFoundException;
 import java.io.IOException;\r
 import java.text.ParseException;\r
 import java.util.Arrays;\r
-import java.util.HashSet;\r
 \r
 import javax.xml.bind.ValidationException;\r
 \r
@@ -38,7 +39,6 @@ import org.ggf.drmaa.JobInfo;
 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
@@ -68,12 +68,9 @@ import compbio.util.SysPrefs;
 \r
 public class AAConTester {\r
 \r
-       public static final String CURRENT_DIRECTORY = SysPrefs\r
-                       .getCurrentDirectory() + File.separator;\r
-\r
-       public static String test_outfile = "TO1381.aacon.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out\r
-       public static String test_alignment_input = CURRENT_DIRECTORY + "testsrc"\r
-                       + File.separator + "testdata" + File.separator + "TO1381.fasta.aln";\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
@@ -83,32 +80,25 @@ public class AAConTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testRunOnCluster() {\r
-               assertFalse(SysPrefs.isWindows,\r
-                               "Cluster execution can only be in unix environment");\r
+       public void RunOnCluster() {\r
+               assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment");\r
                try {\r
-                       ConfiguredExecutable<AACon> confAAcon = Configurator\r
-                                       .configureExecutable(aacon, Executable.ExecProvider.Cluster);\r
+                       ConfiguredExecutable<AACon> confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Cluster);\r
                        JobRunner runner = JobRunner.getInstance(confAAcon);\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
+                       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
-\r
                                String exits = sm.getExitStatus();\r
                                assertNotNull("Exit status is null", exits);\r
                                // cut 4 trailing zeros from the number\r
-                               int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits)\r
-                                               .intValue();\r
+                               int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits).intValue();\r
                                assertEquals(0, exitsInt);\r
                                System.out.println(sm.getAllStats());\r
 \r
@@ -116,12 +106,10 @@ public class AAConTester {
                                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
@@ -135,16 +123,14 @@ public class AAConTester {
        }\r
 \r
        /**\r
-        * This tests fails from time to time depending on the cluster load or some\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 testRunOnClusterAsync() {\r
-               assertFalse(SysPrefs.isWindows,\r
-                               "Cluster execution can only be in unix environment");\r
+       public void RunOnClusterAsync() {\r
+               assertFalse(SysPrefs.isWindows, "Cluster execution can only be in unix environment");\r
                try {\r
-                       ConfiguredExecutable<AACon> confAAcon = Configurator\r
-                                       .configureExecutable(aacon, Executable.ExecProvider.Cluster);\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
@@ -155,14 +141,11 @@ public class AAConTester {
                                System.out.println("Job Status: " + status);\r
                                Thread.sleep(1000);\r
                                status = aengine.getJobStatus(jobId);\r
-                               ConfiguredExecutable<AACon> result = (ConfiguredExecutable<AACon>) aengine\r
-                                               .getResults(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\r
-                               // accounting\r
-                               // before it has been reported to finish. Make sure\r
-                               // to stop waiting in such case\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
@@ -180,10 +163,9 @@ public class AAConTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testRunLocally() {\r
+       public void RunLocally() {\r
                try {\r
-                       ConfiguredExecutable<AACon> confAAcon = Configurator\r
-                                       .configureExecutable(aacon, Executable.ExecProvider.Local);\r
+                       ConfiguredExecutable<AACon> confAAcon = Configurator.configureExecutable(aacon, Executable.ExecProvider.Local);\r
 \r
                        // For local execution use relative\r
                        LocalRunner lr = new LocalRunner(confAAcon);\r
@@ -207,14 +189,12 @@ public class AAConTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testRunLocallyWithPreset() {\r
+       public void RunLocallyWithPreset() {\r
                try {\r
                        PresetManager<AACon> aaconPresets = Util.getPresets(AACon.class);\r
                        assert aaconPresets != null;\r
-                       ConfiguredExecutable<AACon> confAAcon = Configurator\r
-                                       .configureExecutable(aacon, Executable.ExecProvider.Local);\r
-                       Preset<AACon> quick = aaconPresets\r
-                                       .getPresetByName("Quick conservation");\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
@@ -238,14 +218,13 @@ public class AAConTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testRunLocallyOnTwoCpu() {\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\r
-                                       .configureExecutable(aacon, Executable.ExecProvider.Local);\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
@@ -258,7 +237,6 @@ public class AAConTester {
                        assertNotNull(annotations);\r
                        assertEquals(annotations.asSet().size(), 3);\r
                        assertEquals(al1.getResults(), annotations);\r
-\r
                } catch (JobSubmissionException e) {\r
                        e.printStackTrace();\r
                        fail(e.getLocalizedMessage());\r
@@ -274,25 +252,23 @@ public class AAConTester {
        @Test(groups = {AllTestSuit.test_group_runner})\r
        public void readStatistics() {\r
                try {\r
-                       ConfiguredExecutable<AACon> confAAcon = Configurator\r
-                                       .configureExecutable(aacon, Executable.ExecProvider.Local);\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
-                       FilePuller fw = FilePuller.newFilePuller(\r
-                                       confAAcon.getWorkDirectory() + File.separator\r
-                                                       + AACon.getStatFile(),\r
-                                       FileWatcher.MIN_CHUNK_SIZE_BYTES);\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
-                               ChunkHolder ch = fw.pull(position);\r
-                               String chunk = ch.getChunk();\r
-                               position = ch.getNextPosition();\r
-                               // System.out.println(chunk);\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
@@ -302,7 +278,6 @@ public class AAConTester {
                                Thread.sleep(300);\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
@@ -322,21 +297,22 @@ public class AAConTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testPersistance() {\r
+       public void Persistance() {\r
                try {\r
                        AACon aacon = new AACon();\r
-                       aacon.setError("errrr.txt").setInput(test_alignment_input)\r
-                                       .setOutput("outtt.txt");\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\r
-                                       .configureExecutable(aacon, Executable.ExecProvider.Local);\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
@@ -344,33 +320,27 @@ public class AAConTester {
                        RunConfiguration loadedRun = RunConfiguration\r
                                        .load(new FileInputStream(new File(cAAcon\r
                                                        .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
-                       assertEquals(\r
-                                       ((ConfExecutable<AACon>) cAAcon).getRunConfiguration(),\r
-                                       loadedRun);\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(),\r
-                                       test_alignment_input);\r
-                       assertEquals(resurrectedCAAcon.getExecutable().getError(),\r
-                                       "errrr.txt");\r
-                       assertEquals(resurrectedCAAcon.getExecutable().getOutput(),\r
-                                       "outtt.txt");\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\r
-                                       .configureExecutable(resurrectedCAAcon.getExecutable(),\r
+                       ConfiguredExecutable<AACon> resAAcon = Configurator.configureExecutable(resurrectedCAAcon.getExecutable(),\r
                                                        Executable.ExecProvider.Local);\r
 \r
-                       sexec = Configurator.getSyncEngine(resAAcon,\r
-                                       Executable.ExecProvider.Local);\r
+                       sexec = Configurator.getSyncEngine(resAAcon, 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
@@ -390,23 +360,19 @@ public class AAConTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testConfigurationLoading() {\r
+       public void ConfigurationLoading() {\r
                try {\r
-                       RunnerConfig<AACon> aaconConfig = ConfExecutable\r
-                                       .getRunnerOptions(AACon.class);\r
+                       RunnerConfig<AACon> aaconConfig = ConfExecutable.getRunnerOptions(AACon.class);\r
                        assertNotNull(aaconConfig);\r
                        assertTrue(aaconConfig.getArguments().size() > 0);\r
 \r
-                       PresetManager<AACon> aaconPresets = ConfExecutable\r
-                                       .getRunnerPresets(AACon.class);\r
+                       PresetManager<AACon> aaconPresets = ConfExecutable.getRunnerPresets(AACon.class);\r
                        assertNotNull(aaconPresets);\r
 \r
-                       LimitsManager<AACon> jronnLimits = ConfExecutable\r
-                                       .getRunnerLimits(AACon.class);\r
-                       assertNotNull(jronnLimits);\r
-                       assertTrue(jronnLimits.getLimits().size() > 0);\r
-                       jronnLimits.validate(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
@@ -418,5 +384,4 @@ public class AAConTester {
                        fail(e.getLocalizedMessage());\r
                }\r
        }\r
-\r
 }\r
index 4635d10..a3e0905 100644 (file)
@@ -1,6 +1,8 @@
 /* Copyright (c) 2009 Peter Troshin\r
+ * Copyright (c) 2013 Alexander Sherstnev\r
  *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \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
@@ -30,7 +32,6 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
 import java.text.ParseException;\r
-import java.util.Map;\r
 \r
 import javax.xml.bind.ValidationException;\r
 \r
@@ -39,7 +40,6 @@ import org.ggf.drmaa.JobInfo;
 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
@@ -67,8 +67,7 @@ import compbio.util.SysPrefs;
 \r
 public class JronnTester {\r
 \r
-       public static String test_outfile = "TO1381.jronn.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out\r
-\r
+       public static String test_outfile = "TO1381.jronn.out";\r
        private Jronn jronn;\r
 \r
        @BeforeMethod(alwaysRun = true)\r
@@ -77,47 +76,36 @@ public class JronnTester {
                jronn.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
+       @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\r
-                                       .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
+                       ConfiguredExecutable<Jronn> confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
                        JobRunner runner = JobRunner.getInstance(confJronn);\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
+                       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
-\r
                                String exits = sm.getExitStatus();\r
                                assertNotNull("Exit status is null", exits);\r
                                // cut 4 trailing zeros from the number\r
-                               int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits)\r
-                                               .intValue();\r
+                               int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits).intValue();\r
                                assertEquals(0, exitsInt);\r
-                               System.out.println(sm.getAllStats());\r
-\r
+                               //System.out.println(sm.getAllStats());\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
@@ -134,14 +122,11 @@ public class JronnTester {
         * 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
+       @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\r
-                                       .configureExecutable(jronn, Executable.ExecProvider.Cluster);\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
@@ -152,14 +137,11 @@ public class JronnTester {
                                System.out.println("Job Status: " + status);\r
                                Thread.sleep(1000);\r
                                status = aengine.getJobStatus(jobId);\r
-                               ConfiguredExecutable<Jronn> result = (ConfiguredExecutable<Jronn>) aengine\r
-                                               .getResults(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\r
-                               // accounting\r
-                               // before it has been reported to finish. Make sure\r
-                               // to stop waiting in such case\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
@@ -177,10 +159,9 @@ public class JronnTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testRunLocally() {\r
+       public void RunLocally() {\r
                try {\r
-                       ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+                       ConfiguredExecutable<Jronn> confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Local);\r
 \r
                        // For local execution use relative\r
                        LocalRunner lr = new LocalRunner(confJronn);\r
@@ -204,11 +185,10 @@ public class JronnTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testRunLocallyOnTwoCpu() {\r
+       public void RunLocallyOnTwoCpu() {\r
                try {\r
                        jronn.setNCore(2);\r
-                       ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+                       ConfiguredExecutable<Jronn> confJronn = Configurator.configureExecutable(jronn, Executable.ExecProvider.Local);\r
 \r
                        // For local execution use relative\r
                        LocalRunner lr = new LocalRunner(confJronn);\r
@@ -234,16 +214,13 @@ public class JronnTester {
        @Test(groups = {AllTestSuit.test_group_runner})\r
        public void readStatistics() {\r
                try {\r
-                       ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                                       .configureExecutable(jronn, Executable.ExecProvider.Local);\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
-                       FilePuller fw = FilePuller.newFilePuller(\r
-                                       confJronn.getWorkDirectory() + File.separator\r
-                                                       + Jronn.getStatFile(),\r
-                                       FileWatcher.MIN_CHUNK_SIZE_BYTES);\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
@@ -281,17 +258,16 @@ public class JronnTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testPersistance() {\r
+       public void Persistance() {\r
                try {\r
                        Jronn jronn = new Jronn();\r
-                       jronn.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
-                                       .setOutput("outtt.txt");\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\r
-                                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
-\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
@@ -308,8 +284,7 @@ public class JronnTester {
                                        loadedRun);\r
                        // Load run configuration as ConfExecutable\r
                        ConfiguredExecutable<Jronn> resurrectedCMuscle = (ConfiguredExecutable<Jronn>) cJronn\r
-                                       .loadRunConfiguration(new FileInputStream(new File(cJronn\r
-                                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
+                                       .loadRunConfiguration(new FileInputStream(new File(cJronn.getWorkDirectory(), RunConfiguration.rconfigFile)));\r
                        assertNotNull(resurrectedCMuscle);\r
                        assertEquals(resurrectedCMuscle.getExecutable().getInput(),\r
                                        AllTestSuit.test_input);\r
@@ -324,12 +299,10 @@ public class JronnTester {
                                        .configureExecutable(resurrectedCMuscle.getExecutable(),\r
                                                        Executable.ExecProvider.Local);\r
 \r
-                       sexec = Configurator.getSyncEngine(resJronn,\r
-                                       Executable.ExecProvider.Local);\r
+                       sexec = Configurator.getSyncEngine(resJronn, 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
@@ -349,19 +322,15 @@ public class JronnTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testConfigurationLoading() {\r
+       public void ConfigurationLoading() {\r
                try {\r
-                       RunnerConfig<Jronn> jronnConfig = ConfExecutable\r
-                                       .getRunnerOptions(Jronn.class);\r
-                       // There is not supported parameters for Jronn\r
-                       assertNull(jronnConfig);\r
+                       RunnerConfig<Jronn> jronnConfig = ConfExecutable.getRunnerOptions(Jronn.class);\r
+                       assertNull(jronnConfig);  // There is no supported parameters for Jronn\r
 \r
-                       PresetManager<Jronn> jronnPresets = ConfExecutable\r
-                                       .getRunnerPresets(Jronn.class);\r
+                       PresetManager<Jronn> jronnPresets = ConfExecutable.getRunnerPresets(Jronn.class);\r
                        assertNull(jronnPresets); // there is no presets\r
 \r
-                       LimitsManager<Jronn> jronnLimits = ConfExecutable\r
-                                       .getRunnerLimits(Jronn.class);\r
+                       LimitsManager<Jronn> jronnLimits = ConfExecutable.getRunnerLimits(Jronn.class);\r
                        assertNotNull(jronnLimits);\r
                        assertTrue(jronnLimits.getLimits().size() > 0);\r
                        jronnLimits.validate(jronnPresets);\r
@@ -377,5 +346,4 @@ public class JronnTester {
                        fail(e.getLocalizedMessage());\r
                }\r
        }\r
-\r
 }\r
index 663b81a..9712ef8 100644 (file)
@@ -1,6 +1,8 @@
 /* Copyright (c) 2009 Peter Troshin\r
+ * Copyright (c) 2013 Alexander Sherstnev\r
  *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \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
@@ -29,22 +31,20 @@ import java.io.FileInputStream;
 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.Util;\r
 import compbio.engine.client.ConfExecutable;\r
 import compbio.engine.client.ConfiguredExecutable;\r
 import compbio.engine.client.Executable;\r
@@ -63,89 +63,25 @@ import compbio.metadata.JobExecutionException;
 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.Util;\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\r
-                       + "ClustaloParameters.xml";\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_cluster,\r
-                       AllTestSuit.test_group_runner})\r
-       public void testRunOnCluster() {\r
-               ClustalO clustal = new ClustalO();\r
-               assertFalse(SysPrefs.isWindows,\r
-                               "Cluster execution can only be in unix environment");\r
-               clustal.setInput(AllTestSuit.test_input)\r
-                               .setOutput(cluster_test_outfile);\r
-\r
-               try {\r
-\r
-                       ConfiguredExecutable<ClustalO> confClustal = Configurator\r
-                                       .configureExecutable(clustal);\r
-                       JobRunner runner = JobRunner.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\r
-                                       || 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 = ClusterUtil.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
-                       // At present the task directory could not be completely removed\r
-                       // @see JobRunner.cleanup()\r
-                       assertFalse(runner.cleanup(),\r
-                                       "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
-\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_runner})\r
-       public void testRunLocally() {\r
+       public void RunLocally() {\r
                ClustalO clustal = new ClustalO();\r
                clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
                try {\r
-\r
                        // For local execution use relavive\r
-                       ConfiguredExecutable<ClustalO> confClustal = Configurator\r
-                                       .configureExecutable(clustal, Executable.ExecProvider.Local);\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
@@ -163,26 +99,15 @@ public class ClustalOTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testConfigurationLoading() {\r
+       public void ConfigurationLoading() {\r
                try {\r
-                       RunnerConfig<ClustalO> clustalConfig = ConfExecutable\r
-                                       .getRunnerOptions(ClustalO.class);\r
+                       RunnerConfig<ClustalO> clustalConfig = ConfExecutable.getRunnerOptions(ClustalO.class);\r
                        assertNotNull(clustalConfig);\r
                        assertTrue(clustalConfig.getArguments().size() > 0);\r
 \r
-                       /* Unsupported\r
-                       PresetManager<ClustalO> clustalPresets = ConfExecutable\r
-                                       .getRunnerPresets(ClustalO.class);\r
-                       assertNotNull(clustalPresets);\r
-                       assertTrue(clustalPresets.getPresets().size() > 0);\r
-                       clustalPresets.validate(clustalConfig);\r
-                        */\r
-                       LimitsManager<ClustalO> clustalLimits = ConfExecutable\r
-                                       .getRunnerLimits(ClustalO.class);\r
+                       LimitsManager<ClustalO> clustalLimits = ConfExecutable.getRunnerLimits(ClustalO.class);\r
                        assertNotNull(clustalLimits);\r
                        assertTrue(clustalLimits.getLimits().size() > 0);\r
-                       //clustalLimits.validate(clustalPresets);\r
-\r
                } catch (FileNotFoundException e) {\r
                        e.printStackTrace();\r
                        fail(e.getLocalizedMessage());\r
@@ -193,35 +118,28 @@ public class ClustalOTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testOptionsLocally() {\r
+       public void OptionsLocally() {\r
                try {\r
-\r
-                       RunnerConfigMarshaller<ClustalO> clustalmarsh = new RunnerConfigMarshaller<ClustalO>(\r
-                                       RunnerConfig.class);\r
-\r
-                       RunnerConfig<ClustalO> clustalConfig = clustalmarsh.read(\r
-                                       new FileInputStream(new File(clustalConfigFile)),\r
-                                       RunnerConfig.class);\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
-                                               .setOutput(test_outfile);\r
+                               clustal.setInput(AllTestSuit.test_input);\r
+                               clustal.setOutput(test_outfile);\r
 \r
                                // For local execution use relavive\r
-                               ConfiguredExecutable<ClustalO> confClustal = Configurator\r
-                                               .configureExecutable(clustal, ExecProvider.Local);\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\r
-                                               .waitForResult();\r
+                               confClustal = (ConfiguredExecutable<ClustalO>) lr.waitForResult();\r
                                assertNotNull(confClustal.getResults());\r
                                Collections.shuffle(options);\r
                        }\r
@@ -244,13 +162,12 @@ public class ClustalOTester {
                }\r
        }\r
 \r
-       public static final void main(String[] args) throws JobSubmissionException,\r
-                       JobExecutionException, InterruptedException {\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\r
-                               .configureExecutable(clustal);\r
+               ConfiguredExecutable<ClustalO> confClustal = Configurator.configureExecutable(clustal);\r
                AsyncExecutor lr = new AsyncLocalRunner();\r
                lr.submitJob(confClustal);\r
                Thread.sleep(3000);\r
@@ -258,16 +175,16 @@ public class ClustalOTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void testPersistance() {\r
+       public void Persistance() {\r
                try {\r
                        ClustalO clustal = new ClustalO();\r
-                       clustal.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
-                                       .setOutput("outtt.txt");\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\r
-                                       .configureExecutable(clustal, Executable.ExecProvider.Local);\r
+                       ConfiguredExecutable<ClustalO> cClustal = Configurator.configureExecutable(clustal, Executable.ExecProvider.Local);\r
 \r
                        SyncExecutor sexec = Configurator.getSyncEngine(cClustal);\r
                        sexec.executeJob();\r
@@ -277,9 +194,7 @@ public class ClustalOTester {
                        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
+                       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
@@ -295,8 +210,7 @@ public class ClustalOTester {
                                        .configureExecutable(resurrectedCclustal.getExecutable(),\r
                                                        Executable.ExecProvider.Local);\r
 \r
-                       sexec = Configurator.getSyncEngine(resclustal,\r
-                                       Executable.ExecProvider.Local);\r
+                       sexec = Configurator.getSyncEngine(resclustal, Executable.ExecProvider.Local);\r
                        sexec.executeJob();\r
                        cClustal = (ConfiguredExecutable<ClustalO>) sexec.waitForResult();\r
                        assertNotNull(cClustal.getResults());\r
@@ -320,35 +234,40 @@ public class ClustalOTester {
        }\r
 \r
        @Test(groups = {AllTestSuit.test_group_runner})\r
-       public void readStatistics() {\r
+       public void readStatistics()\r
+                       throws InterruptedException {\r
                try {\r
-                       ClustalO clustal = new ClustalO().setInput(AllTestSuit.test_input)\r
-                                       .setOutput(test_outfile);\r
-                       ConfiguredExecutable<ClustalO> confClustal = Configurator\r
-                                       .configureExecutable(clustal, Executable.ExecProvider.Local);\r
-\r
-                       AsyncExecutor sexec = Configurator.getAsyncEngine(confClustal);\r
-                       String jobId = sexec.submitJob(confClustal);\r
-                       FilePuller fw = FilePuller.newFilePuller(\r
-                                       confClustal.getWorkDirectory() + File.separator\r
-                                                       + ClustalW.getStatFile(),\r
-                                       FileWatcher.MIN_CHUNK_SIZE_BYTES);\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 = Util.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
-                       while (!(sexec.getJobStatus(jobId) == JobStatus.FINISHED\r
-                                       || sexec.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
+                       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<?> al = sexec.getResults(jobId);\r
-                       assertNotNull(al.getResults());\r
+                       ConfiguredExecutable<?> al2 = sexec.getResults(jobId);\r
+                       assertNotNull(al2.getResults());\r
                } catch (JobSubmissionException e) {\r
                        e.printStackTrace();\r
                        fail(e.getMessage());\r
@@ -361,32 +280,74 @@ public class ClustalOTester {
                }\r
        }\r
 \r
-       @Test(groups = {AllTestSuit.test_group_cluster,\r
-                       AllTestSuit.test_group_runner})\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
+                       JobRunner runner = JobRunner.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 = ClusterUtil.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)\r
-                                       .setOutput(test_outfile);\r
-                       ConfiguredExecutable<ClustalO> confClustal = Configurator\r
-                                       .configureExecutable(clustal,\r
-                                                       Executable.ExecProvider.Cluster);\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
-                       FilePuller fw = FilePuller.newFilePuller(\r
-                                       confClustal.getWorkDirectory() + File.separator\r
-                                                       + ClustalW.getStatFile(),\r
-                                       FileWatcher.MIN_CHUNK_SIZE_BYTES);\r
+                       String file = Util.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 TODO deal with this!\r
+                        * thus this loop never ends. maxloopcount ensures hard stop of the loop...\r
                         */\r
-                       while (!(sexec.getJobStatus(jobId) == JobStatus.FINISHED || sexec\r
-                                       .getJobStatus(jobId) == JobStatus.FAILED)\r
-                                       || fw.hasMoreData()) {\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
@@ -394,8 +355,7 @@ public class ClustalOTester {
                                count++;\r
                                Thread.sleep(200);\r
                                if (sexec.getJobStatus(jobId) == JobStatus.UNDEFINED) {\r
-                                       System.out.println("DRMAA reported wrong status for job + "\r
-                                                       + jobId + " continue anyway!");\r
+                                       System.out.println("DRMAA reported wrong status for job + " + jobId + " continue anyway!");\r
                                        break;\r
                                }\r
                        }\r
index 562919e..44f5ec0 100644 (file)
@@ -1,6 +1,8 @@
 /* Copyright (c) 2009 Peter Troshin\r
+ * Copyright (c) 2013 Alexander Sherstnev\r
  *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \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
@@ -74,79 +76,18 @@ import compbio.util.SysPrefs;
 \r
 public class ClustalWTester {\r
 \r
-       static final String clustalConfigFile = AllTestSuit.TEST_DATA_PATH\r
-                       + "ClustalParameters.xml";\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_cluster,\r
-                       AllTestSuit.test_group_runner })\r
-       public void testRunOnCluster() {\r
-               ClustalW clustal = new ClustalW();\r
-               assertFalse(SysPrefs.isWindows,\r
-                               "Cluster execution can only be in unix environment");\r
-               clustal.setInput(AllTestSuit.test_input)\r
-                               .setOutput(cluster_test_outfile);\r
-\r
-               try {\r
-\r
-                       ConfiguredExecutable<ClustalW> confClustal = Configurator\r
-                                       .configureExecutable(clustal);\r
-                       JobRunner runner = JobRunner.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\r
-                                       || 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 = ClusterUtil.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
-                       // At present the task directory could not be completely removed\r
-                       // @see JobRunner.cleanup()\r
-                       assertFalse(runner.cleanup(),\r
-                                       "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
-\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_runner })\r
-       public void testRunLocally() {\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\r
-                                       .configureExecutable(clustal, Executable.ExecProvider.Local);\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
@@ -164,7 +105,7 @@ public class ClustalWTester {
        }\r
 \r
        @Test(groups = { AllTestSuit.test_group_runner })\r
-       public void testRunWithMatrix() {\r
+       public void RunWithMatrix() {\r
                ClustalW clustal = new ClustalW();\r
                clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
                clustal.setParameter("-matrix=BLOSUM62");\r
@@ -189,26 +130,22 @@ public class ClustalWTester {
                }\r
        }\r
 \r
-       @Test(groups = { AllTestSuit.test_group_runner })\r
-       public void testConfigurationLoading() {\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
+       public void ConfigurationLoading() {\r
                try {\r
-                       RunnerConfig<ClustalW> clustalConfig = ConfExecutable\r
-                                       .getRunnerOptions(ClustalW.class);\r
+                       RunnerConfig<ClustalW> clustalConfig = ConfExecutable.getRunnerOptions(ClustalW.class);\r
                        assertNotNull(clustalConfig);\r
                        assertTrue(clustalConfig.getArguments().size() > 0);\r
 \r
-                       PresetManager<ClustalW> clustalPresets = ConfExecutable\r
-                                       .getRunnerPresets(ClustalW.class);\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\r
-                                       .getRunnerLimits(ClustalW.class);\r
+                       LimitsManager<ClustalW> clustalLimits = ConfExecutable.getRunnerLimits(ClustalW.class);\r
                        assertNotNull(clustalLimits);\r
                        assertTrue(clustalLimits.getLimits().size() > 0);\r
                        clustalLimits.validate(clustalPresets);\r
-\r
                } catch (FileNotFoundException e) {\r
                        e.printStackTrace();\r
                        fail(e.getLocalizedMessage());\r
@@ -222,39 +159,30 @@ public class ClustalWTester {
        }\r
 \r
        @Test(groups = { AllTestSuit.test_group_runner })\r
-       public void testOptionsLocally() {\r
+       public void OptionsLocally() {\r
                try {\r
-\r
-                       RunnerConfigMarshaller<ClustalW> clustalmarsh = new RunnerConfigMarshaller<ClustalW>(\r
-                                       RunnerConfig.class);\r
-\r
-                       RunnerConfig<ClustalW> clustalConfig = clustalmarsh.read(\r
-                                       new FileInputStream(new File(clustalConfigFile)),\r
-                                       RunnerConfig.class);\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)\r
-                                               .setOutput(test_outfile);\r
+                               clustal.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
 \r
                                // For local execution use relavive\r
-                               ConfiguredExecutable<ClustalW> confClustal = Configurator\r
-                                               .configureExecutable(clustal, ExecProvider.Local);\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\r
-                                               .waitForResult();\r
+                               confClustal = (ConfiguredExecutable<ClustalW>) lr.waitForResult();\r
                                assertNotNull(confClustal.getResults());\r
                                Collections.shuffle(options);\r
                        }\r
-\r
                } catch (JobSubmissionException e) {\r
                        e.printStackTrace();\r
                        fail(e.getLocalizedMessage());\r
@@ -273,28 +201,25 @@ public class ClustalWTester {
                }\r
        }\r
 \r
-       public static final void main(String[] args) throws JobSubmissionException,\r
-                       JobExecutionException, InterruptedException {\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\r
-                               .configureExecutable(clustal);\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 testAddParameters() {\r
+       public void AddParameters() {\r
                ArrayList<FastaSequence> seqs = new ArrayList<FastaSequence>();\r
-               FastaSequence fs = new FastaSequence("tests1",\r
-                               "aqtctcatcatctcatctgcccccgggttatgagtagtacgcatctacg");\r
-               FastaSequence fs2 = new FastaSequence("tests2",\r
-                               "aqtctcatcatctcatctgcccccgggttatgagtagtacgcatctacg");\r
-               FastaSequence fs3 = new FastaSequence("tests3",\r
-                               "aqtctcatcatctcatctgcccccgggttatgagtagtacgcatctacg");\r
+               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
@@ -342,16 +267,16 @@ public class ClustalWTester {
        }\r
 \r
        @Test(groups = { AllTestSuit.test_group_runner })\r
-       public void testPersistance() {\r
+       public void Persistance() {\r
                try {\r
                        ClustalW clustal = new ClustalW();\r
-                       clustal.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
-                                       .setOutput("outtt.txt");\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\r
-                                       .configureExecutable(clustal, Executable.ExecProvider.Local);\r
+                       ConfiguredExecutable<ClustalW> cClustal = Configurator.configureExecutable(clustal, Executable.ExecProvider.Local);\r
 \r
                        SyncExecutor sexec = Configurator.getSyncEngine(cClustal);\r
                        sexec.executeJob();\r
@@ -379,12 +304,10 @@ public class ClustalWTester {
                                        .configureExecutable(resurrectedCclustal.getExecutable(),\r
                                                        Executable.ExecProvider.Local);\r
 \r
-                       sexec = Configurator.getSyncEngine(resclustal,\r
-                                       Executable.ExecProvider.Local);\r
+                       sexec = Configurator.getSyncEngine(resclustal, Executable.ExecProvider.Local);\r
                        sexec.executeJob();\r
                        cClustal = (ConfiguredExecutable<ClustalW>) sexec.waitForResult();\r
                        assertNotNull(cClustal.getResults());\r
-\r
                } catch (JobSubmissionException e) {\r
                        e.printStackTrace();\r
                        fail(e.getMessage());\r
@@ -406,17 +329,13 @@ public class ClustalWTester {
        @Test(groups = { AllTestSuit.test_group_runner })\r
        public void readStatistics() {\r
                try {\r
-                       ClustalW clustal = new ClustalW().setInput(AllTestSuit.test_input)\r
-                                       .setOutput(test_outfile);\r
-                       ConfiguredExecutable<ClustalW> confClustal = Configurator\r
-                                       .configureExecutable(clustal, Executable.ExecProvider.Local);\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
-                       FilePuller fw = FilePuller.newFilePuller(confClustal\r
-                                       .getWorkDirectory()\r
-                                       + File.separator + ClustalW.getStatFile(),\r
-                                       FileWatcher.MIN_CHUNK_SIZE_BYTES);\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
@@ -445,22 +364,67 @@ public class ClustalWTester {
                }\r
        }\r
 \r
-       @Test(groups = { AllTestSuit.test_group_cluster,\r
-                       AllTestSuit.test_group_runner })\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
+                       JobRunner runner = JobRunner.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 = ClusterUtil.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().setInput(AllTestSuit.test_input)\r
-                                       .setOutput(test_outfile);\r
-                       ConfiguredExecutable<ClustalW> confClustal = Configurator\r
-                                       .configureExecutable(clustal,\r
-                                                       Executable.ExecProvider.Cluster);\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
-                       FilePuller fw = FilePuller.newFilePuller(confClustal\r
-                                       .getWorkDirectory()\r
-                                       + File.separator + ClustalW.getStatFile(),\r
-                                       FileWatcher.MIN_CHUNK_SIZE_BYTES);\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
index 659103d..f0f07bf 100644 (file)
@@ -1,6 +1,8 @@
 /* Copyright (c) 2009 Peter Troshin\r
+ * Copyright (c) 2013 Alexander Sherstnev\r
  *  \r
- *  JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0     \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
@@ -27,6 +29,7 @@ import java.io.File;
 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
@@ -43,6 +46,7 @@ import compbio.engine.client.ConfiguredExecutable;
 import compbio.engine.client.Executable;\r
 import compbio.engine.client.RunConfiguration;\r
 import compbio.engine.cluster.drmaa.JobRunner;\r
+import compbio.engine.local.LocalRunner;\r
 import compbio.metadata.AllTestSuit;\r
 import compbio.metadata.ChunkHolder;\r
 import compbio.metadata.JobExecutionException;\r
@@ -53,35 +57,45 @@ import compbio.metadata.PresetManager;
 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,\r
-                       AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows })\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(AllTestSuit.test_input).setOutput("tcoffee.out")\r
-                               .setError("tcoffee.progress");\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,\r
-                       AllTestSuit.test_group_non_windows })\r
-       public void testExecute() {\r
+       @Test(groups = { AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows })\r
+       public void RunLocally() {\r
                try {\r
-                       ConfiguredExecutable<Tcoffee> ctcoffee = Configurator\r
-                                       .configureExecutable(tcoffee, Executable.ExecProvider.Local);\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
-                       // System.out.println("Tcoffee stat file: " + tcoffee.getError());\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
@@ -94,31 +108,28 @@ public class TcoffeeTester {
                }\r
        }\r
 \r
-       @Test(groups = { AllTestSuit.test_group_runner,\r
-                       AllTestSuit.test_group_non_windows })\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\r
-                                       .configureExecutable(tcoffee, Executable.ExecProvider.Local);\r
+                       ConfiguredExecutable<Tcoffee> confTcoffee = Configurator.configureExecutable(tcoffee, Executable.ExecProvider.Local);\r
 \r
                        AsyncExecutor sexec = Configurator.getAsyncEngine(confTcoffee);\r
                        String jobId = sexec.submitJob(confTcoffee);\r
-                       FilePuller fw = FilePuller.newFilePuller(confTcoffee\r
-                                       .getWorkDirectory()\r
-                                       + File.separator + tcoffee.getError(),\r
-                                       FileWatcher.MIN_CHUNK_SIZE_BYTES);\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 || 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
+                       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
@@ -136,36 +147,9 @@ public class TcoffeeTester {
                }\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<Tcoffee> cmafft = Configurator\r
-                                       .configureExecutable(tcoffee,\r
-                                                       Executable.ExecProvider.Cluster);\r
-                       JobRunner sexecutor = (JobRunner) Configurator.getSyncEngine(\r
-                                       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
-       @Test(groups = { AllTestSuit.test_group_runner,\r
-                       AllTestSuit.test_group_non_windows })\r
-       public void testNcore() {\r
+       @Test(groups = { AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows })\r
+       public void SetNcore() {\r
                Tcoffee tc = new Tcoffee();\r
-               // System.out.println("TCPRM:" + tc.getParameters(null));\r
                assertEquals(tc.getParameters(null).size(), 3);\r
                tc.setNCore(2);\r
                assertEquals(2, tc.getNCore());\r
@@ -175,19 +159,18 @@ public class TcoffeeTester {
                assertEquals(tc.getParameters(null).size(), 3);\r
        }\r
 \r
-       @Test(groups = { AllTestSuit.test_group_cluster,\r
-                       AllTestSuit.test_group_runner, AllTestSuit.test_group_non_windows })\r
-       public void testPersistance() {\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").setInput(AllTestSuit.test_input)\r
-                                       .setOutput("outtt.txt");\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
-                       ConfiguredExecutable<Tcoffee> ctcofee = Configurator\r
-                                       .configureExecutable(tcoffee, Executable.ExecProvider.Local);\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
@@ -196,26 +179,21 @@ public class TcoffeeTester {
                        assertTrue(ctcofee.saveRunConfiguration());\r
 \r
                        // See if loaded configuration is the same as saved\r
-                       RunConfiguration loadedRun = RunConfiguration\r
-                                       .load(new FileInputStream(new File(ctcofee\r
-                                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
-                       assertEquals(((ConfExecutable<Tcoffee>) ctcofee)\r
-                                       .getRunConfiguration(), loadedRun);\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\r
-                                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\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\r
-                                       .configureExecutable(resurrectedCTcoffee.getExecutable(),\r
-                                                       Executable.ExecProvider.Local);\r
+                       ConfiguredExecutable<Tcoffee> restcoffee = Configurator.configureExecutable(resurrectedCTcoffee.getExecutable(), Executable.ExecProvider.Local);\r
 \r
-                       sexec = Configurator.getSyncEngine(restcoffee,\r
-                                       Executable.ExecProvider.Local);\r
+                       sexec = Configurator.getSyncEngine(restcoffee,Executable.ExecProvider.Local);\r
                        sexec.executeJob();\r
                        al = sexec.waitForResult();\r
                        assertNotNull(al);\r
@@ -239,21 +217,18 @@ public class TcoffeeTester {
        }\r
 \r
        @Test(groups = { AllTestSuit.test_group_runner })\r
-       public void testConfigurationLoading() {\r
+       public void ConfigurationLoading() {\r
                try {\r
-                       RunnerConfig<Tcoffee> tcoffeeConfig = ConfExecutable\r
-                                       .getRunnerOptions(Tcoffee.class);\r
+                       RunnerConfig<Tcoffee> tcoffeeConfig = ConfExecutable.getRunnerOptions(Tcoffee.class);\r
                        assertNotNull(tcoffeeConfig);\r
                        assertTrue(tcoffeeConfig.getArguments().size() > 0);\r
 \r
-                       PresetManager<Tcoffee> tcoffeePresets = ConfExecutable\r
-                                       .getRunnerPresets(Tcoffee.class);\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\r
-                                       .getRunnerLimits(Tcoffee.class);\r
+                       LimitsManager<Tcoffee> tcoffeeLimits = ConfExecutable.getRunnerLimits(Tcoffee.class);\r
                        assertNotNull(tcoffeeLimits);\r
                        assertTrue(tcoffeeLimits.getLimits().size() > 0);\r
                        tcoffeeLimits.validate(tcoffeePresets);\r
@@ -267,6 +242,27 @@ public class TcoffeeTester {
                        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
+                       JobRunner sexecutor = (JobRunner) 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