-/* 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
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 ClustalW extends SkeletalExecutable<ClustalW> {\r
\r
- private static Logger log = Logger.getLogger(ClustalW.class);\r
- private static final String EXEC_STAT_FILE = "stat.log";\r
- private static final String TREE_FILE_EXT = ".dnd";\r
-\r
- public static final String KEY_VALUE_SEPARATOR = "=";\r
-\r
- // Cache for Limits information\r
- private static LimitsManager<ClustalW> limits;\r
-\r
- public ClustalW() {\r
- super(KEY_VALUE_SEPARATOR);\r
- addParameters(Arrays.asList("-OUTORDER=ALIGNED", "-QUIET", "-STATS="\r
- + EXEC_STAT_FILE));\r
- // set default in, outs and err files\r
- this.setInput(super.inputFile);\r
- this.setOutput(super.outputFile);\r
- this.setError(super.errorFile);\r
- }\r
-\r
- @Override\r
- public ClustalW setOutput(String outFile) {\r
- super.setOutput(outFile);\r
- cbuilder.setParam("-OUTFILE=" + outFile);\r
- return this;\r
- }\r
-\r
- @Override\r
- public ClustalW setInput(String inFile) {\r
- super.setInput(inFile);\r
- cbuilder.setParam("-INFILE=" + inFile);\r
- return this;\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
- }\r
- }\r
-\r
- @Override\r
- public List<String> getCreatedFiles() {\r
- return Arrays.asList(getOutput(), EXEC_STAT_FILE,\r
- convertInputNameToTreeName());\r
- }\r
-\r
- /*\r
- * Clustal output tree with same name as input file but .dnd extension e.g.\r
- * this methods do similar conversion TO122.fasta -> TO122.dnd or\r
- * TO122.fasta.in -> TO122.fasta.dnd It does not seems that there is any\r
- * limits on the name length\r
- * \r
- * @return\r
- */\r
- private String convertInputNameToTreeName() {\r
- assert super.getInput() != null;\r
- int dotIdx = getInput().lastIndexOf(".");\r
- String treeFileName = "";\r
- if (dotIdx > 0) {\r
- treeFileName = getInput().substring(0, dotIdx);\r
+ private static Logger log = Logger.getLogger(ClustalW.class);\r
+ private static final String EXEC_STAT_FILE = "stat.log";\r
+ private static final String TREE_FILE_EXT = ".dnd";\r
+\r
+ public static final String KEY_VALUE_SEPARATOR = "=";\r
+\r
+ public ClustalW() {\r
+ super(KEY_VALUE_SEPARATOR);\r
+ addParameters(Arrays.asList("-OUTORDER=ALIGNED", "-QUIET", "-STATS="\r
+ + EXEC_STAT_FILE));\r
+ // set default in, outs and err files\r
+ this.setInput(super.inputFile);\r
+ this.setOutput(super.outputFile);\r
+ this.setError(super.errorFile);\r
}\r
- return treeFileName + TREE_FILE_EXT;\r
- }\r
\r
- public static String getStatFile() {\r
- return EXEC_STAT_FILE;\r
- }\r
+ @Override\r
+ public ClustalW setOutput(String outFile) {\r
+ super.setOutput(outFile);\r
+ cbuilder.setParam("-OUTFILE=" + outFile);\r
+ return this;\r
+ }\r
\r
- @Override\r
- public Limit<ClustalW> getLimit(String presetName) {\r
+ @Override\r
+ public ClustalW setInput(String inFile) {\r
+ super.setInput(inFile);\r
+ cbuilder.setParam("-INFILE=" + inFile);\r
+ return this;\r
+ }\r
\r
- if (limits == null) {\r
- limits = getLimits();\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
+ }\r
}\r
\r
- Limit<ClustalW> limit = null;\r
- if (limits != null) {\r
- // this returns default limit if preset is undefined!\r
- limit = limits.getLimitByName(presetName);\r
+ @Override\r
+ public List<String> getCreatedFiles() {\r
+ return Arrays.asList(getOutput(), EXEC_STAT_FILE,\r
+ convertInputNameToTreeName());\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
+ * Clustal output tree with same name as input file but .dnd extension e.g.\r
+ * this methods do similar conversion TO122.fasta -> TO122.dnd or\r
+ * TO122.fasta.in -> TO122.fasta.dnd It does not seems that there is any\r
+ * limits on the name length\r
+ * \r
+ * @return\r
+ */\r
+ private String convertInputNameToTreeName() {\r
+ assert super.getInput() != null;\r
+ int dotIdx = getInput().lastIndexOf(".");\r
+ String treeFileName = "";\r
+ if (dotIdx > 0) {\r
+ treeFileName = getInput().substring(0, dotIdx);\r
+ }\r
+ return treeFileName + TREE_FILE_EXT;\r
}\r
- return limit;\r
- }\r
-\r
- @Override\r
- public LimitsManager<ClustalW> getLimits() {\r
- // synchronise on static field\r
- synchronized (log) {\r
- if (limits == null) {\r
- limits = Util.getLimits(this.getClass());\r
- }\r
+\r
+ public static String getStatFile() {\r
+ return EXEC_STAT_FILE;\r
}\r
- return limits;\r
- }\r
\r
- @Override\r
- public Class<? extends Executable<?>> getType() {\r
- return this.getClass();\r
- }\r
+ @SuppressWarnings("unchecked")\r
+ @Override\r
+ public Class<ClustalW> getType() {\r
+ return (Class<ClustalW>) this.getClass();\r
+ }\r
\r
}\r