From 40f197693d886791ac801db40f28f4e0f0fb805c Mon Sep 17 00:00:00 2001 From: pvtroshin Date: Thu, 4 Aug 2011 13:16:16 +0000 Subject: [PATCH] Clustal Omega web service wrapper and tester 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 | 50 ++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) diff --git a/runner/compbio/runner/msa/ClustalO.java b/runner/compbio/runner/msa/ClustalO.java index e94dead..ae0d8ec 100644 --- a/runner/compbio/runner/msa/ClustalO.java +++ b/runner/compbio/runner/msa/ClustalO.java @@ -26,7 +26,10 @@ import org.apache.log4j.Logger; import compbio.data.sequence.Alignment; import compbio.data.sequence.UnknownFileFormatException; +import compbio.engine.client.CommandBuilder; +import compbio.engine.client.Executable; import compbio.engine.client.SkeletalExecutable; +import compbio.engine.client.Executable.ExecProvider; import compbio.metadata.ResultNotAvailableException; import compbio.runner.Util; @@ -34,14 +37,23 @@ public class ClustalO extends SkeletalExecutable { private static Logger log = Logger.getLogger(ClustalO.class); private static final String EXEC_STAT_FILE = "stat.log"; - private static final String TREE_FILE_EXT = ".dnd"; + public static final String KEY_VALUE_SEPARATOR = "="; + + /* + * Number of cores parameter name + */ + private final static String ncorePrm = "--threads"; /** - * - * --auto Set options automatically (might overwrite some of your options) - * + * Number of cores to use, defaults to 1 for local execution or the value of + * "tcoffee.cluster.cpunum" property for cluster execution + */ + private int ncoreNumber = 0; + + + /** * --threads= Number of processors to use * * -l, --log= Log all non-essential output to this file @@ -99,5 +111,35 @@ public class ClustalO extends SkeletalExecutable { public Class getType() { return (Class) this.getClass(); } + + @Override + public CommandBuilder getParameters(ExecProvider provider) { + // Limit number of cores to 1 for ANY execution which does not set + // Ncores explicitly using setNCore method + if (ncoreNumber == 0) { + setNCore(1); + } + if (provider == Executable.ExecProvider.Cluster) { + int cpunum = SkeletalExecutable.getClusterCpuNum(getType()); + if (cpunum != 0) { + setNCore(cpunum); + } + } + return super.getParameters(provider); + } + + public void setNCore(int ncoreNumber) { + if (ncoreNumber < 1 || ncoreNumber > 100) { + throw new IndexOutOfBoundsException( + "Number of cores must be within 1 and 100 "); + } + this.ncoreNumber = ncoreNumber; + cbuilder.setParam(ncorePrm, Integer.toString(getNCore())); + } + + int getNCore() { + return ncoreNumber; + } + } -- 1.7.10.2