-/* 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 compbio.data.sequence.Alignment;\r
import compbio.data.sequence.UnknownFileFormatException;\r
-import compbio.engine.client.Executable;\r
+\r
import compbio.engine.client.PipedExecutable;\r
import compbio.engine.client.SkeletalExecutable;\r
-import compbio.metadata.Limit;\r
-import compbio.metadata.LimitsManager;\r
import compbio.metadata.ResultNotAvailableException;\r
-import compbio.runner.Util;\r
-\r
-public class Mafft extends SkeletalExecutable<Mafft> implements\r
- PipedExecutable<Mafft> {\r
-\r
- private static Logger log = Logger.getLogger(Mafft.class);\r
-\r
- // Cache for Limits information\r
- private static LimitsManager<Mafft> limits;\r
-\r
- private static String autoOption = "--auto";\r
-\r
- private final String MATRIX_PAR_NAME = "--aamatrix";\r
-\r
- public static final String KEY_VALUE_SEPARATOR = Util.SPACE;\r
-\r
- public Mafft() {\r
- // remove default input to prevent it to appear in the parameters list\r
- // that could happen if the parameters are set first\r
- // super.setInput("");\r
- addParameters(Arrays.asList("--clustalout", autoOption));\r
- }\r
-\r
- @SuppressWarnings("unchecked")\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
+import compbio.runner.RunnerUtil;\r
+\r
+/**\r
+ * \r
+ * @author pvtroshin\r
+ *\r
+ */\r
+public class Mafft extends SkeletalExecutable<Mafft> implements PipedExecutable<Mafft> {\r
+/*\r
+ * TODO get rid of piping: Mafft now supports --out option for output file. \r
+ * Multi-threading supported with e.g. "thread 4" only for Linux, so JABAWS \r
+ * will not support it for now, it also need editing of mafft makefile \r
+ */\r
+\r
+ private static Logger log = Logger.getLogger(Mafft.class);\r
+\r
+ private static String autoOption = "--auto";\r
+\r
+ private final String MATRIX_PAR_NAME = "--aamatrix";\r
+\r
+ public static final String KEY_VALUE_SEPARATOR = " ";\r
+\r
+ public Mafft() {\r
+ // remove default input to prevent it to appear in the parameters list\r
+ // that could happen if the parameters are set first\r
+ // super.setInput("");\r
+ addParameters(Arrays.asList("--clustalout", autoOption));\r
}\r
- }\r
-\r
- @Override\r
- public Mafft setInput(String inFile) {\r
- super.setInput(inFile);\r
- cbuilder.setLast(inFile);\r
- return this;\r
- }\r
-\r
- /**\r
- * Mafft input must always be the last parameter!\r
- */\r
- @Override\r
- public Mafft addParameters(List<String> parameters) {\r
- cbuilder.addParams(parameters);\r
- cbuilder.removeParam(autoOption);\r
- return this;\r
- }\r
-\r
- @Override\r
- public Limit<Mafft> getLimit(String presetName) {\r
- if (limits == null) {\r
- limits = getLimits();\r
+\r
+ @SuppressWarnings("unchecked")\r
+ public Alignment getResults(String workDirectory)\r
+ throws ResultNotAvailableException {\r
+ try {\r
+ return RunnerUtil.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
- Limit<Mafft> limit = null;\r
- if (limits != null) {\r
- // this returns default limit if preset is undefined!\r
- limit = limits.getLimitByName(presetName);\r
+ @Override\r
+ public Mafft setInput(String inFile) {\r
+ super.setInput(inFile);\r
+ cbuilder.setLast(inFile);\r
+ return this;\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
+ /**\r
+ * Mafft input must always be the last parameter!\r
+ */\r
+ @Override\r
+ public Mafft addParameters(List<String> parameters) {\r
+ cbuilder.addParams(parameters);\r
+ cbuilder.removeParam(autoOption);\r
+ return this;\r
}\r
- return limit;\r
- }\r
-\r
- @Override\r
- public LimitsManager<Mafft> getLimits() {\r
- // synchronise on static field\r
- synchronized (log) {\r
- if (limits == null) {\r
- limits = Util.getLimits(this.getClass());\r
- }\r
+\r
+\r
+ \r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public Class<Mafft> getType() {\r
+ return (Class<Mafft>) this.getClass();\r
}\r
- return limits;\r
- }\r
-\r
- @Override\r
- public Class<? extends Executable<?>> getType() {\r
- return this.getClass();\r
- }\r
-\r
- /*\r
- * @Override public List<String> getParameters(\r
- * compbio.runner.Executable.ExecProvider provider) { for (int i = 0; i <\r
- * param.size(); i++) { String par = param.get(i); if\r
- * (isMatrixParameter(par)) { String matrixName = getValue(i); if (new\r
- * File(matrixName).isAbsolute()) { // Matrix can be found so no actions\r
- * necessary // This method has been called already and the matrix name //\r
- * is modified to contain full path // no further actions is necessary\r
- * break; } String matrixPath = Util.getExecProperty("matrix.path", this);\r
- * String absMatrixPath = Util.convertToAbsolute(matrixPath); param.remove(i\r
- * + 1); param.remove(i); super.addParameter(MATRIX_PAR_NAME);\r
- * super.addParameter(absMatrixPath + File.separator + matrixName); break; }\r
- * } return super.getParameters(provider); }\r
- * \r
- * boolean isMatrixParameter(String parameter) { assert\r
- * !compbio.util.Util.isEmpty(parameter); if\r
- * (parameter.toUpperCase().startsWith(MATRIX_PAR_NAME)) { return true; }\r
- * return false; }\r
- * \r
- * String getValue(int i) { return param.get(i + 1); }\r
- */\r
}\r