-/* Copyright (c) 2009 Peter Troshin\r
+/* Copyright (c) 2011 Peter Troshin\r
* \r
- * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0\r
+ * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 2.0 \r
* \r
* This library is free software; you can redistribute it and/or modify it under the terms of the\r
* Apache License version 2 as published by the Apache Software Foundation\r
\r
import java.io.FileNotFoundException;\r
import java.io.IOException;\r
-import java.security.InvalidParameterException;\r
import java.util.Arrays;\r
import java.util.List;\r
\r
\r
import compbio.data.sequence.Alignment;\r
import compbio.data.sequence.UnknownFileFormatException;\r
-import compbio.engine.client.ClusterNativeSpecExecutable;\r
import compbio.engine.client.CommandBuilder;\r
import compbio.engine.client.Executable;\r
import compbio.engine.client.PipedExecutable;\r
import compbio.engine.client.SkeletalExecutable;\r
import compbio.engine.conf.PropertyHelperManager;\r
-import compbio.metadata.Limit;\r
-import compbio.metadata.LimitsManager;\r
import compbio.metadata.ResultNotAvailableException;\r
import compbio.runner.Util;\r
import compbio.util.PropertyHelper;\r
\r
-public class Tcoffee extends SkeletalExecutable<Tcoffee> implements\r
- PipedExecutable<Tcoffee>, ClusterNativeSpecExecutable<Tcoffee> {\r
+public class Tcoffee extends SkeletalExecutable<Tcoffee>\r
+ implements\r
+ PipedExecutable<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
+ public static final String KEY_VALUE_SEPARATOR = "=";\r
\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
+ private final static String ncorePrm = "-n_core";\r
\r
- @Override\r
- public List<String> getCreatedFiles() {\r
- return Arrays.asList(getOutput());\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
- @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 = getClusterCpuNum();\r
- if (cpunum != 0) {\r
- setNCore(cpunum);\r
- }\r
+ /**\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
- 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 Tcoffee setInput(String inFile) {\r
+ super.setInput(inFile);\r
+ cbuilder.setParam("-seq", inFile);\r
+ return this;\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
+ @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 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 List<String> getCreatedFiles() {\r
+ return Arrays.asList(getOutput());\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
+ 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
- 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
+ int getNCore() {\r
+ return ncoreNumber;\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 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 cpus;\r
- }\r
\r
- @Override\r
- public Class<? extends Executable<?>> getType() {\r
- return this.getClass();\r
- }\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public Class<Tcoffee> getType() {\r
+ return (Class<Tcoffee>) this.getClass();\r
+ }\r
}\r