Clustal Omega web service wrapper and tester
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 4 Aug 2011 13:16:16 +0000 (13:16 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Thu, 4 Aug 2011 13:16:16 +0000 (13:16 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@4462 e3abac25-378b-4346-85de-24260fe3988d

runner/compbio/runner/msa/ClustalO.java

index e94dead..ae0d8ec 100644 (file)
@@ -26,7 +26,10 @@ import org.apache.log4j.Logger;
 \r
 import compbio.data.sequence.Alignment;\r
 import compbio.data.sequence.UnknownFileFormatException;\r
+import compbio.engine.client.CommandBuilder;\r
+import compbio.engine.client.Executable;\r
 import compbio.engine.client.SkeletalExecutable;\r
+import compbio.engine.client.Executable.ExecProvider;\r
 import compbio.metadata.ResultNotAvailableException;\r
 import compbio.runner.Util;\r
 \r
@@ -34,14 +37,23 @@ public class ClustalO extends SkeletalExecutable<ClustalO> {
 \r
        private static Logger log = Logger.getLogger(ClustalO.class);\r
        private static final String EXEC_STAT_FILE = "stat.log";\r
-       private static final String TREE_FILE_EXT = ".dnd";\r
+       \r
 \r
        public static final String KEY_VALUE_SEPARATOR = "=";\r
+       \r
+       /*\r
+        * Number of cores parameter name\r
+        */\r
+       private final static String ncorePrm = "--threads";\r
 \r
        /**\r
-        * \r
-        * --auto Set options automatically (might overwrite some of your options)\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
         * --threads=<n> Number of processors to use\r
         * \r
         * -l, --log=<file> Log all non-essential output to this file\r
@@ -99,5 +111,35 @@ public class ClustalO extends SkeletalExecutable<ClustalO> {
        public Class<ClustalO> getType() {\r
                return (Class<ClustalO>) this.getClass();\r
        }\r
+       \r
+       @Override\r
+       public CommandBuilder<ClustalO> 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
+       \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