Some refactoring
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 22 Jul 2010 12:59:22 +0000 (12:59 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 22 Jul 2010 12:59:22 +0000 (12:59 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@2651 e3abac25-378b-4346-85de-24260fe3988d

engine/compbio/engine/client/SkeletalExecutable.java
runner/compbio/runner/disorder/Jronn.java
runner/compbio/runner/msa/Tcoffee.java
testsrc/compbio/runner/disorder/JronnTester.java
webservices/compbio/ws/server/TcoffeeWS.java

index adc3e0b..dbdb4f5 100644 (file)
@@ -19,6 +19,7 @@
 package compbio.engine.client;\r
 \r
 import java.io.File;\r
+import java.security.InvalidParameterException;\r
 import java.util.Arrays;\r
 import java.util.List;\r
 \r
@@ -258,6 +259,35 @@ public abstract class SkeletalExecutable<T> implements Executable<T> {
        return settings == null ? "" : settings;\r
     }\r
 \r
+    /**\r
+        * \r
+        * @return number of cpus to use on the cluster or 0 if the value is\r
+        *         undefined\r
+        */\r
+       public static int getClusterCpuNum(Class<? extends Executable<?>> type) {\r
+               int cpus = 0;\r
+               String cpuNum = ph.getProperty(type.getSimpleName().toLowerCase()+ ".cluster.cpunum");\r
+               if (compbio.util.Util.isEmpty(cpuNum)) {\r
+                       return 0;\r
+               }\r
+               try {\r
+                       cpus = Integer.parseInt(cpuNum);\r
+               } catch (NumberFormatException e) {\r
+                       // safe to ignore\r
+                       log\r
+                       .debug("Number of cpus to use for cluster execution is defined but could not be parsed as integer! Given value is: "\r
+                                       + cpuNum);\r
+                       return 0;\r
+               }\r
+               if (cpus < 1 || cpus > 100) {\r
+                       throw new InvalidParameterException(\r
+                                       "Number of cpu for cluster execution must be within 1 and 100! "\r
+                                       + "Look at the value of 'tcoffee.cluster.cpunum' property. Given value is "\r
+                                       + cpus);\r
+               }\r
+               return cpus;\r
+       }\r
+\r
     public abstract Class<? extends Executable<?>> getType();\r
 \r
 }\r
index 1b9037e..0bf17e4 100644 (file)
@@ -23,6 +23,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
+import java.security.InvalidParameterException;\r
 import java.util.Arrays;\r
 import java.util.List;\r
 \r
@@ -48,8 +49,18 @@ import compbio.runner.Util;
  */\r
 public class Jronn extends SkeletalExecutable<Jronn> {\r
 \r
+       \r
        private static Logger log = Logger.getLogger(Jronn.class);\r
 \r
+       /**\r
+        * Number of cores to use, defaults to 1 for local execution or the value of\r
+        * "jronn.cluster.cpunum" property for cluster execution\r
+        */\r
+       private int ncoreNumber = 0;\r
+\r
+       private String ncorePrm = "-n";\r
+\r
+       \r
        // Cache for Limits information\r
        private static LimitsManager<Jronn> limits;\r
 \r
@@ -57,7 +68,7 @@ public class Jronn extends SkeletalExecutable<Jronn> {
        public static final String STAT_FILE = "stat.txt";\r
 \r
        public Jronn() {\r
-               addParameters(Arrays.asList("-jar", getLibPath(), "-n=1", "-s="\r
+               addParameters(Arrays.asList("-jar", getLibPath(), "-s="\r
                                + STAT_FILE, "-f=H"));\r
        }\r
 \r
@@ -161,4 +172,19 @@ public class Jronn extends SkeletalExecutable<Jronn> {
        public static String getStatFile() {\r
                return STAT_FILE;\r
        }\r
+       \r
+       public void setNCore(int ncoreNumber) {\r
+               if (ncoreNumber < 1 || ncoreNumber > 100) {\r
+                       throw new IndexOutOfBoundsException(\r
+                                       "Number of cores must be within 1 and 100 ");\r
+               }\r
+               this.ncoreNumber = ncoreNumber;\r
+               cbuilder.setParam(ncorePrm, Integer.toString(getNCore()));\r
+       }\r
+\r
+       int getNCore() {\r
+               return ncoreNumber;\r
+       }\r
+       \r
+    \r
 }\r
index 2fd2283..949c4f1 100644 (file)
@@ -41,173 +41,145 @@ import compbio.runner.Util;
 import compbio.util.PropertyHelper;\r
 \r
 public class Tcoffee extends SkeletalExecutable<Tcoffee> implements\r
-       PipedExecutable<Tcoffee>, ClusterNativeSpecExecutable<Tcoffee> {\r
+PipedExecutable<Tcoffee>, ClusterNativeSpecExecutable<Tcoffee> {\r
 \r
-    private static Logger log = Logger.getLogger(Tcoffee.class);\r
+       private static Logger log = Logger.getLogger(Tcoffee.class);\r
 \r
-    private static PropertyHelper ph = PropertyHelperManager\r
-           .getPropertyHelper();\r
+       private static PropertyHelper ph = PropertyHelperManager\r
+       .getPropertyHelper();\r
 \r
-    // Cache for Limits information\r
-    private static LimitsManager<Tcoffee> limits;\r
+       // Cache for Limits information\r
+       private static LimitsManager<Tcoffee> limits;\r
 \r
-    public static final String KEY_VALUE_SEPARATOR = "=";\r
+       public static final String KEY_VALUE_SEPARATOR = "=";\r
 \r
-    /**\r
-     * Number of cores to use, defaults to 1 for local execution or the value of\r
-     * "tcoffee.cluster.cpunum" property for cluster execution\r
-     */\r
-    private int ncoreNumber = 0;\r
-\r
-    /*\r
-     * Number of cores parameter name\r
-     */\r
-    private final static String ncorePrm = "-n_core";\r
+       /**\r
+        * Number of cores to use, defaults to 1 for local execution or the value of\r
+        * "tcoffee.cluster.cpunum" property for cluster execution\r
+        */\r
+       private int ncoreNumber = 0;\r
 \r
-    /**\r
-     * \r
-     * @param workDirectory\r
-     */\r
-    public Tcoffee() {\r
-       super(KEY_VALUE_SEPARATOR);\r
        /*\r
-        * Use "-quiet" to disable sdtout and progress to stderr inorder=input -\r
-        * prevent t-coffee from sorting sequences\r
+        * Number of cores parameter name\r
         */\r
-       addParameters(Arrays.asList("-output=clustalw"));\r
-       setInput(super.inputFile);\r
-    }\r
-\r
-    @Override\r
-    public Tcoffee setInput(String inFile) {\r
-       super.setInput(inFile);\r
-       cbuilder.setParam("-seq", inFile);\r
-       return this;\r
-    }\r
-\r
-    @SuppressWarnings("unchecked")\r
-    @Override\r
-    public Alignment getResults(String workDirectory)\r
-           throws ResultNotAvailableException {\r
-       try {\r
-           return Util.readClustalFile(workDirectory, getOutput());\r
-       } catch (FileNotFoundException e) {\r
-           log.error(e.getMessage(), e.getCause());\r
-           throw new ResultNotAvailableException(e);\r
-       } catch (IOException e) {\r
-           log.error(e.getMessage(), e.getCause());\r
-           throw new ResultNotAvailableException(e);\r
-       } catch (UnknownFileFormatException e) {\r
-           log.error(e.getMessage(), e.getCause());\r
-           throw new ResultNotAvailableException(e);\r
-       } catch (NullPointerException e) {\r
-           log.error(e.getMessage(), e.getCause());\r
-           throw new ResultNotAvailableException(e);\r
-       }\r
-    }\r
-\r
-    @Override\r
-    public List<String> getCreatedFiles() {\r
-       return Arrays.asList(getOutput());\r
-    }\r
+       private final static String ncorePrm = "-n_core";\r
 \r
-    public void setNCore(int ncoreNumber) {\r
-       if (ncoreNumber < 1 || ncoreNumber > 100) {\r
-           throw new IndexOutOfBoundsException(\r
-                   "Number of cores must be within 1 and 100 ");\r
+       /**\r
+        * \r
+        * @param workDirectory\r
+        */\r
+       public Tcoffee() {\r
+               super(KEY_VALUE_SEPARATOR);\r
+               /*\r
+                * Use "-quiet" to disable sdtout and progress to stderr inorder=input -\r
+                * prevent t-coffee from sorting sequences\r
+                */\r
+               addParameters(Arrays.asList("-output=clustalw"));\r
+               setInput(super.inputFile);\r
        }\r
-       this.ncoreNumber = ncoreNumber;\r
-       cbuilder.setParam(ncorePrm, Integer.toString(getNCore()));\r
-    }\r
-\r
-    int getNCore() {\r
-       return ncoreNumber;\r
-    }\r
-\r
-    @Override\r
-    public CommandBuilder<Tcoffee> getParameters(ExecProvider provider) {\r
-       // Limit number of cores to 1 for ANY execution which does not set\r
-       // Ncores explicitly using setNCore method\r
-       if (ncoreNumber == 0) {\r
-           setNCore(1);\r
+\r
+       @Override\r
+       public Tcoffee setInput(String inFile) {\r
+               super.setInput(inFile);\r
+               cbuilder.setParam("-seq", inFile);\r
+               return this;\r
        }\r
-       if (provider == Executable.ExecProvider.Cluster) {\r
-           int cpunum = getClusterCpuNum();\r
-           if (cpunum != 0) {\r
-               setNCore(cpunum);\r
-           }\r
+\r
+       @SuppressWarnings("unchecked")\r
+       @Override\r
+       public Alignment getResults(String workDirectory)\r
+       throws ResultNotAvailableException {\r
+               try {\r
+                       return Util.readClustalFile(workDirectory, getOutput());\r
+               } catch (FileNotFoundException e) {\r
+                       log.error(e.getMessage(), e.getCause());\r
+                       throw new ResultNotAvailableException(e);\r
+               } catch (IOException e) {\r
+                       log.error(e.getMessage(), e.getCause());\r
+                       throw new ResultNotAvailableException(e);\r
+               } catch (UnknownFileFormatException e) {\r
+                       log.error(e.getMessage(), e.getCause());\r
+                       throw new ResultNotAvailableException(e);\r
+               } catch (NullPointerException e) {\r
+                       log.error(e.getMessage(), e.getCause());\r
+                       throw new ResultNotAvailableException(e);\r
+               }\r
        }\r
-       return super.getParameters(provider);\r
-    }\r
 \r
-    @Override\r
-    public Limit<Tcoffee> getLimit(String presetName) {\r
-       if (limits == null) {\r
-           limits = getLimits();\r
+       @Override\r
+       public List<String> getCreatedFiles() {\r
+               return Arrays.asList(getOutput());\r
        }\r
 \r
-       Limit<Tcoffee> limit = null;\r
-       if (limits != null) {\r
-           // this returns default limit if preset is undefined!\r
-           limit = limits.getLimitByName(presetName);\r
+       public void setNCore(int ncoreNumber) {\r
+               if (ncoreNumber < 1 || ncoreNumber > 100) {\r
+                       throw new IndexOutOfBoundsException(\r
+                                       "Number of cores must be within 1 and 100 ");\r
+               }\r
+               this.ncoreNumber = ncoreNumber;\r
+               cbuilder.setParam(ncorePrm, Integer.toString(getNCore()));\r
        }\r
-       // If limit is not defined for a particular preset, then return default\r
-       // limit\r
-       if (limit == null) {\r
-           log.debug("Limit for the preset " + presetName\r
-                   + " is not found. Using default");\r
-           limit = limits.getDefaultLimit();\r
+\r
+       int getNCore() {\r
+               return ncoreNumber;\r
        }\r
-       return limit;\r
-    }\r
-\r
-    @Override\r
-    public LimitsManager<Tcoffee> getLimits() {\r
-       // synchronise on static field\r
-       synchronized (log) {\r
-           if (limits == null) {\r
-               limits = Util.getLimits(this.getClass());\r
-           }\r
+\r
+       @Override\r
+       public CommandBuilder<Tcoffee> getParameters(ExecProvider provider) {\r
+               // Limit number of cores to 1 for ANY execution which does not set\r
+               // Ncores explicitly using setNCore method\r
+               if (ncoreNumber == 0) {\r
+                       setNCore(1);\r
+               }\r
+               if (provider == Executable.ExecProvider.Cluster) {\r
+                       int cpunum = SkeletalExecutable.getClusterCpuNum(getType());\r
+                       if (cpunum != 0) {\r
+                               setNCore(cpunum);\r
+                       }\r
+               }\r
+               return super.getParameters(provider);\r
        }\r
-       return limits;\r
-    }\r
-\r
-    @Override\r
-    public String getNativeSpecs() {\r
-       return getClusterSettings();\r
-    }\r
-\r
-    /**\r
-     * \r
-     * @return number of cpus to use on the cluster or 0 if the value is\r
-     *         undefined\r
-     */\r
-    public static int getClusterCpuNum() {\r
-       int cpus = 0;\r
-       String cpuNum = ph.getProperty("tcoffee.cluster.cpunum");\r
-       if (compbio.util.Util.isEmpty(cpuNum)) {\r
-           return 0;\r
+\r
+       @Override\r
+       public Limit<Tcoffee> getLimit(String presetName) {\r
+               if (limits == null) {\r
+                       limits = getLimits();\r
+               }\r
+\r
+               Limit<Tcoffee> limit = null;\r
+               if (limits != null) {\r
+                       // this returns default limit if preset is undefined!\r
+                       limit = limits.getLimitByName(presetName);\r
+               }\r
+               // If limit is not defined for a particular preset, then return default\r
+               // limit\r
+               if (limit == null) {\r
+                       log.debug("Limit for the preset " + presetName\r
+                                       + " is not found. Using default");\r
+                       limit = limits.getDefaultLimit();\r
+               }\r
+               return limit;\r
        }\r
-       try {\r
-           cpus = Integer.parseInt(cpuNum);\r
-       } catch (NumberFormatException e) {\r
-           // safe to ignore\r
-           log\r
-                   .debug("Number of cpus to use for cluster execution is defined but could not be parsed as integer! Given value is: "\r
-                           + cpuNum);\r
-           return 0;\r
+\r
+       @Override\r
+       public LimitsManager<Tcoffee> getLimits() {\r
+               // synchronise on static field\r
+               synchronized (log) {\r
+                       if (limits == null) {\r
+                               limits = Util.getLimits(this.getClass());\r
+                       }\r
+               }\r
+               return limits;\r
        }\r
-       if (cpus < 1 || cpus > 100) {\r
-           throw new InvalidParameterException(\r
-                   "Number of cpu for cluster execution must be within 1 and 100! "\r
-                           + "Look at the value of 'tcoffee.cluster.cpunum' property. Given value is "\r
-                           + cpus);\r
+\r
+       @Override\r
+       public String getNativeSpecs() {\r
+               return getClusterSettings();\r
        }\r
-       return cpus;\r
-    }\r
 \r
-    @Override\r
-    public Class<? extends Executable<?>> getType() {\r
-       return this.getClass();\r
-    }\r
+\r
+       @Override\r
+       public Class<? extends Executable<?>> getType() {\r
+               return this.getClass();\r
+       }\r
 }\r
index 0193781..9385eb6 100644 (file)
@@ -66,291 +66,315 @@ 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
+       public static String test_outfile = "TO1381.jronn.out"; // "/homes/pvtroshin/TO1381.clustal.cluster.out\r
 \r
-    private Jronn jronn;\r
+       private Jronn jronn;\r
 \r
-    @BeforeMethod(alwaysRun = true)\r
-    void init() {\r
-       jronn = new Jronn();\r
-       jronn.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
-    }\r
+       @BeforeMethod(alwaysRun = true)\r
+       void init() {\r
+               jronn = new Jronn();\r
+               jronn.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
+       }\r
 \r
-    @Test(groups = { AllTestSuit.test_group_cluster,\r
-           AllTestSuit.test_group_runner })\r
-    public void testRunOnCluster() {\r
-       assertFalse(SysPrefs.isWindows,\r
-               "Cluster execution can only be in unix environment");\r
-       try {\r
-           ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                   .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
-           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
-               assertEquals(0, exitsInt);\r
-               System.out.println(sm.getAllStats());\r
-\r
-           } catch (ParseException e) {\r
-               e.printStackTrace();\r
-               fail("Parse Exception: " + e.getMessage());\r
-           }\r
-           //assertFalse(runner.cleanup());\r
-           assertTrue(sm.hasExited());\r
-           assertFalse(sm.wasAborted());\r
-           assertFalse(sm.hasDump());\r
-           assertFalse(sm.hasSignaled());\r
-\r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail("DrmaaException caught:" + e.getMessage());\r
-       } catch (JobExecutionException e) {\r
-           e.printStackTrace();\r
-           fail("DrmaaException caught:" + e.getMessage());\r
-       } catch (DrmaaException e) {\r
-           e.printStackTrace();\r
-           fail("DrmaaException caught:" + e.getMessage());\r
+       @Test(groups = { AllTestSuit.test_group_cluster,\r
+                       AllTestSuit.test_group_runner })\r
+                       public void testRunOnCluster() {\r
+               assertFalse(SysPrefs.isWindows,\r
+                               "Cluster execution can only be in unix environment");\r
+               try {\r
+                       ConfiguredExecutable<Jronn> confJronn = Configurator\r
+                       .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
+                       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
+                               assertEquals(0, exitsInt);\r
+                               System.out.println(sm.getAllStats());\r
+\r
+                       } catch (ParseException e) {\r
+                               e.printStackTrace();\r
+                               fail("Parse Exception: " + e.getMessage());\r
+                       }\r
+                       //assertFalse(runner.cleanup());\r
+                       assertTrue(sm.hasExited());\r
+                       assertFalse(sm.wasAborted());\r
+                       assertFalse(sm.hasDump());\r
+                       assertFalse(sm.hasSignaled());\r
+\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail("DrmaaException caught:" + e.getMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail("DrmaaException caught:" + e.getMessage());\r
+               } catch (DrmaaException e) {\r
+                       e.printStackTrace();\r
+                       fail("DrmaaException caught:" + e.getMessage());\r
+               }\r
        }\r
-    }\r
-\r
-    /**\r
-     * This tests fails from time to time depending on the cluster load or some\r
-     * other factors. Any client code has to adjust for this issue\r
-     */\r
-    @Test(groups = { AllTestSuit.test_group_cluster,\r
-           AllTestSuit.test_group_runner })\r
-    public void testRunOnClusterAsync() {\r
-       assertFalse(SysPrefs.isWindows,\r
+\r
+       /**\r
+        * This tests fails from time to time depending on the cluster load or some\r
+        * other factors. Any client code has to adjust for this issue\r
+        */\r
+       @Test(groups = { AllTestSuit.test_group_cluster,\r
+                       AllTestSuit.test_group_runner })\r
+                       public void testRunOnClusterAsync() {\r
+               assertFalse(SysPrefs.isWindows,\r
                "Cluster execution can only be in unix environment");\r
-       try {\r
-           ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                   .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
-           AsyncExecutor aengine = Configurator.getAsyncEngine(confJronn);\r
-           String jobId = aengine.submitJob(confJronn);\r
-           assertNotNull(jobId, "Runner is NULL");\r
-           // let drmaa to start\r
-           Thread.sleep(500);\r
-           JobStatus status = aengine.getJobStatus(jobId);\r
-           while (status != JobStatus.FINISHED) {\r
-               System.out.println("Job Status: " + status);\r
-               Thread.sleep(1000);\r
-               status = aengine.getJobStatus(jobId);\r
-               ConfiguredExecutable<Jronn> result = (ConfiguredExecutable<Jronn>) aengine\r
-                       .getResults(jobId);\r
-               assertNotNull(result);\r
-               System.out.println("RES:" + result);\r
-               // Some times the job could be removed from the cluster accounting \r
-               // before it has been reported to finish. Make sure \r
-               // to stop waiting in such case\r
-               if (status == JobStatus.UNDEFINED) {\r
-                   break;\r
+               try {\r
+                       ConfiguredExecutable<Jronn> confJronn = Configurator\r
+                       .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
+                       AsyncExecutor aengine = Configurator.getAsyncEngine(confJronn);\r
+                       String jobId = aengine.submitJob(confJronn);\r
+                       assertNotNull(jobId, "Runner is NULL");\r
+                       // let drmaa to start\r
+                       Thread.sleep(500);\r
+                       JobStatus status = aengine.getJobStatus(jobId);\r
+                       while (status != JobStatus.FINISHED) {\r
+                               System.out.println("Job Status: " + status);\r
+                               Thread.sleep(1000);\r
+                               status = aengine.getJobStatus(jobId);\r
+                               ConfiguredExecutable<Jronn> result = (ConfiguredExecutable<Jronn>) aengine\r
+                               .getResults(jobId);\r
+                               assertNotNull(result);\r
+                               System.out.println("RES:" + result);\r
+                               // Some times the job could be removed from the cluster accounting \r
+                               // before it has been reported to finish. Make sure \r
+                               // to stop waiting in such case\r
+                               if (status == JobStatus.UNDEFINED) {\r
+                                       break;\r
+                               }\r
+                       }\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail("DrmaaException caught:" + e.getMessage());\r
+               } catch (InterruptedException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
                }\r
-           }\r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail("DrmaaException caught:" + e.getMessage());\r
-       } catch (InterruptedException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (ResultNotAvailableException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
        }\r
-    }\r
-\r
-    @Test(groups = { AllTestSuit.test_group_runner })\r
-    public void testRunLocally() {\r
-       try {\r
-           ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                   .configureExecutable(jronn, Executable.ExecProvider.Local);\r
-\r
-           // For local execution use relative\r
-           LocalRunner lr = new LocalRunner(confJronn);\r
-           lr.executeJob();\r
-           ConfiguredExecutable<?> al1 = lr.waitForResult();\r
-           assertNotNull(al1.getResults());\r
-           List<AnnotatedSequence> al2 = confJronn.getResults();\r
-           assertNotNull(al2);\r
-           assertEquals(al2.size(), 3);\r
-           assertEquals(al1.getResults(), al2);\r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
-       } catch (ResultNotAvailableException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
-       } catch (JobExecutionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
+\r
+       @Test(groups = { AllTestSuit.test_group_runner })\r
+       public void testRunLocally() {\r
+               try {\r
+                       ConfiguredExecutable<Jronn> confJronn = Configurator\r
+                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+\r
+                       // For local execution use relative\r
+                       LocalRunner lr = new LocalRunner(confJronn);\r
+                       lr.executeJob();\r
+                       ConfiguredExecutable<?> al1 = lr.waitForResult();\r
+                       assertNotNull(al1.getResults());\r
+                       List<AnnotatedSequence> al2 = confJronn.getResults();\r
+                       assertNotNull(al2);\r
+                       assertEquals(al2.size(), 3);\r
+                       assertEquals(al1.getResults(), al2);\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
        }\r
-    }\r
-\r
-    @Test(groups = { AllTestSuit.test_group_runner })\r
-    public void readStatistics() {\r
-       try {\r
-           ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                   .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(confJronn\r
-                   .getWorkDirectory()\r
-                   + File.separator + Jronn.getStatFile(),\r
-                   FileWatcher.MIN_CHUNK_SIZE_BYTES);\r
-           int count = 0;\r
-           long position = 0;\r
-           fw.waitForFile(4);\r
-           JobStatus status = sexec.getJobStatus(jobId);\r
-           while (status != JobStatus.FINISHED) {\r
-               System.out.println((status != JobStatus.FINISHED) + " d: "\r
-                       + fw.hasMoreData());\r
-               if (fw.hasMoreData()) {\r
-                   ChunkHolder ch = fw.pull(position);\r
-                   System.out.println("p:" + position);\r
-                   String chunk = ch.getChunk();\r
-                   position = ch.getNextPosition();\r
-                   System.out.println("np " + position + " c: " + chunk);\r
+\r
+       @Test(groups = { AllTestSuit.test_group_runner })\r
+       public void testRunLocallyOnTwoCpu() {\r
+               try {\r
+                       jronn.setNCore(2);\r
+                       ConfiguredExecutable<Jronn> confJronn = Configurator\r
+                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+                       \r
+                       // For local execution use relative\r
+                       LocalRunner lr = new LocalRunner(confJronn);\r
+                       lr.executeJob();\r
+                       ConfiguredExecutable<?> al1 = lr.waitForResult();\r
+                       assertNotNull(al1.getResults());\r
+                       List<AnnotatedSequence> al2 = confJronn.getResults();\r
+                       assertNotNull(al2);\r
+                       assertEquals(al2.size(), 3);\r
+                       assertEquals(al1.getResults(), al2);\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
                }\r
-               count++;\r
-               // Make sure the loop is terminated if the job fails\r
-               if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) {\r
-                   break;\r
+       }\r
+\r
+       \r
+       @Test(groups = { AllTestSuit.test_group_runner })\r
+       public void readStatistics() {\r
+               try {\r
+                       ConfiguredExecutable<Jronn> confJronn = Configurator\r
+                       .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(confJronn\r
+                                       .getWorkDirectory()\r
+                                       + File.separator + Jronn.getStatFile(),\r
+                                       FileWatcher.MIN_CHUNK_SIZE_BYTES);\r
+                       int count = 0;\r
+                       long position = 0;\r
+                       fw.waitForFile(4);\r
+                       JobStatus status = sexec.getJobStatus(jobId);\r
+                       while (status != JobStatus.FINISHED) {\r
+                               if (fw.hasMoreData()) {\r
+                                       ChunkHolder ch = fw.pull(position);\r
+                                       String chunk = ch.getChunk();\r
+                                       position = ch.getNextPosition();\r
+                               }\r
+                               count++;\r
+                               // Make sure the loop is terminated if the job fails\r
+                               if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) {\r
+                                       break;\r
+                               }\r
+                               Thread.sleep(300);\r
+                               status = sexec.getJobStatus(jobId);\r
+                       }\r
+                       assertTrue(count > 1);\r
+                       ConfiguredExecutable<?> al = sexec.getResults(jobId);\r
+                       assertNotNull(al.getResults());\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (InterruptedException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
                }\r
-               Thread.sleep(300);\r
-               status = sexec.getJobStatus(jobId);\r
-           }\r
-           System.out.println("\nOut of the LOOP!! ");\r
-           assertTrue(count > 1);\r
-           ConfiguredExecutable<?> al = sexec.getResults(jobId);\r
-           assertNotNull(al.getResults());\r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (ResultNotAvailableException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (IOException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (InterruptedException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
        }\r
-    }\r
-\r
-    @Test(groups = { AllTestSuit.test_group_runner })\r
-    public void testPersistance() {\r
-       try {\r
-           Jronn jronn = new Jronn();\r
-           jronn.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
-                   .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
-           SyncExecutor sexec = Configurator.getSyncEngine(cJronn);\r
-           sexec.executeJob();\r
-           ConfiguredExecutable<?> al = sexec.waitForResult();\r
-           assertNotNull(al.getResults());\r
-           // Save run configuration\r
-           assertTrue(cJronn.saveRunConfiguration());\r
-\r
-           // See if loaded configuration is the same as saved\r
-           RunConfiguration loadedRun = RunConfiguration\r
-                   .load(new FileInputStream(new File(cJronn\r
-                           .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
-           assertEquals(\r
-                   ((ConfExecutable<Jronn>) cJronn).getRunConfiguration(),\r
-                   loadedRun);\r
-           // Load run configuration as ConfExecutable\r
-           ConfiguredExecutable<Jronn> resurrectedCMuscle = (ConfiguredExecutable<Jronn>) cJronn\r
-                   .loadRunConfiguration(new FileInputStream(new File(cJronn\r
-                           .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
-           assertNotNull(resurrectedCMuscle);\r
-           assertEquals(resurrectedCMuscle.getExecutable().getInput(),\r
-                   AllTestSuit.test_input);\r
-           assertEquals(resurrectedCMuscle.getExecutable().getError(),\r
-                   "errrr.txt");\r
-           assertEquals(resurrectedCMuscle.getExecutable().getOutput(),\r
-                   "outtt.txt");\r
-           // See in details whether executables are the same\r
-           assertEquals(resurrectedCMuscle.getExecutable(), jronn);\r
-\r
-           ConfiguredExecutable<Jronn> resJronn = Configurator\r
-                   .configureExecutable(resurrectedCMuscle.getExecutable(),\r
-                           Executable.ExecProvider.Local);\r
-\r
-           sexec = Configurator.getSyncEngine(resJronn,\r
-                   Executable.ExecProvider.Local);\r
-           sexec.executeJob();\r
-           al = sexec.waitForResult();\r
-           assertNotNull(al);\r
-\r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (JobExecutionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (FileNotFoundException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (IOException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (ResultNotAvailableException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
+\r
+       @Test(groups = { AllTestSuit.test_group_runner })\r
+       public void testPersistance() {\r
+               try {\r
+                       Jronn jronn = new Jronn();\r
+                       jronn.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
+                       .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
+                       SyncExecutor sexec = Configurator.getSyncEngine(cJronn);\r
+                       sexec.executeJob();\r
+                       ConfiguredExecutable<?> al = sexec.waitForResult();\r
+                       assertNotNull(al.getResults());\r
+                       // Save run configuration\r
+                       assertTrue(cJronn.saveRunConfiguration());\r
+\r
+                       // See if loaded configuration is the same as saved\r
+                       RunConfiguration loadedRun = RunConfiguration\r
+                       .load(new FileInputStream(new File(cJronn\r
+                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
+                       assertEquals(\r
+                                       ((ConfExecutable<Jronn>) cJronn).getRunConfiguration(),\r
+                                       loadedRun);\r
+                       // Load run configuration as ConfExecutable\r
+                       ConfiguredExecutable<Jronn> resurrectedCMuscle = (ConfiguredExecutable<Jronn>) cJronn\r
+                       .loadRunConfiguration(new FileInputStream(new File(cJronn\r
+                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
+                       assertNotNull(resurrectedCMuscle);\r
+                       assertEquals(resurrectedCMuscle.getExecutable().getInput(),\r
+                                       AllTestSuit.test_input);\r
+                       assertEquals(resurrectedCMuscle.getExecutable().getError(),\r
+                                       "errrr.txt");\r
+                       assertEquals(resurrectedCMuscle.getExecutable().getOutput(),\r
+                       "outtt.txt");\r
+                       // See in details whether executables are the same\r
+                       assertEquals(resurrectedCMuscle.getExecutable(), jronn);\r
+\r
+                       ConfiguredExecutable<Jronn> resJronn = Configurator\r
+                       .configureExecutable(resurrectedCMuscle.getExecutable(),\r
+                                       Executable.ExecProvider.Local);\r
+\r
+                       sexec = Configurator.getSyncEngine(resJronn,\r
+                                       Executable.ExecProvider.Local);\r
+                       sexec.executeJob();\r
+                       al = sexec.waitForResult();\r
+                       assertNotNull(al);\r
+\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               }\r
        }\r
-    }\r
-\r
-    @Test(groups = { AllTestSuit.test_group_runner })\r
-    public void testConfigurationLoading() {\r
-       try {\r
-           RunnerConfig<Jronn> jronnConfig = ConfExecutable\r
-                   .getRunnerOptions(Jronn.class);\r
-           assertNotNull(jronnConfig);\r
-           assertTrue(jronnConfig.getArguments().size() > 0);\r
-\r
-           PresetManager<Jronn> jronnPresets = ConfExecutable\r
-                   .getRunnerPresets(Jronn.class);\r
-           assertNull(jronnPresets); // there is no presets\r
-\r
-           LimitsManager<Jronn> jronnLimits = ConfExecutable\r
-                   .getRunnerLimits(Jronn.class);\r
-           assertNotNull(jronnLimits);\r
-           assertTrue(jronnLimits.getLimits().size() > 0);\r
-           jronnLimits.validate(jronnPresets);\r
-\r
-       } catch (FileNotFoundException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
-       } catch (IOException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
-       } catch (ValidationException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
+\r
+       @Test(groups = { AllTestSuit.test_group_runner })\r
+       public void testConfigurationLoading() {\r
+               try {\r
+                       RunnerConfig<Jronn> jronnConfig = ConfExecutable\r
+                       .getRunnerOptions(Jronn.class);\r
+                       assertNotNull(jronnConfig);\r
+                       assertTrue(jronnConfig.getArguments().size() > 0);\r
+\r
+                       PresetManager<Jronn> jronnPresets = ConfExecutable\r
+                       .getRunnerPresets(Jronn.class);\r
+                       assertNull(jronnPresets); // there is no presets\r
+\r
+                       LimitsManager<Jronn> jronnLimits = ConfExecutable\r
+                       .getRunnerLimits(Jronn.class);\r
+                       assertNotNull(jronnLimits);\r
+                       assertTrue(jronnLimits.getLimits().size() > 0);\r
+                       jronnLimits.validate(jronnPresets);\r
+\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (ValidationException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
        }\r
-    }\r
 \r
 }\r
index afe2cae..07a1f41 100644 (file)
@@ -34,6 +34,7 @@ import compbio.engine.AsyncExecutor;
 import compbio.engine.Configurator;\r
 import compbio.engine.client.ConfiguredExecutable;\r
 import compbio.engine.client.Executable;\r
+import compbio.engine.client.SkeletalExecutable;\r
 import compbio.metadata.ChunkHolder;\r
 import compbio.metadata.JobStatus;\r
 import compbio.metadata.JobSubmissionException;\r
@@ -75,18 +76,18 @@ public class TcoffeeWS implements MsaWS<Tcoffee> {
     }\r
 \r
     ConfiguredExecutable<Tcoffee> init(List<FastaSequence> sequences)\r
-           throws JobSubmissionException {\r
-       Tcoffee tcoffee = new Tcoffee();\r
-       tcoffee.setInput("fasta.in").setOutput("fasta.out");\r
-       ConfiguredExecutable<Tcoffee> confCoffee = Configurator\r
-               .configureExecutable(tcoffee, sequences);\r
-       if (confCoffee.getExecProvider() == Executable.ExecProvider.Cluster) {\r
-           int clusterCpuNum = Tcoffee.getClusterCpuNum();\r
-           if (clusterCpuNum != 0) {\r
-               tcoffee.setNCore(clusterCpuNum);\r
-           }\r
-       }\r
-       return confCoffee;\r
+    throws JobSubmissionException {\r
+       Tcoffee tcoffee = new Tcoffee();\r
+       tcoffee.setInput("fasta.in").setOutput("fasta.out");\r
+       ConfiguredExecutable<Tcoffee> confCoffee = Configurator\r
+       .configureExecutable(tcoffee, sequences);\r
+       if (confCoffee.getExecProvider() == Executable.ExecProvider.Cluster) {\r
+               int clusterCpuNum = SkeletalExecutable.getClusterCpuNum(Tcoffee.class);\r
+               if (clusterCpuNum != 0) {\r
+                       tcoffee.setNCore(clusterCpuNum);\r
+               }\r
+       }\r
+       return confCoffee;\r
     }\r
 \r
     @Override\r