Define path to UNIREF database in conf/Executable.properties
[jabaws.git] / runner / compbio / runner / msa / Probcons.java
index ea9fa1d..872a5f8 100644 (file)
@@ -1,6 +1,6 @@
-/* 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
@@ -27,105 +27,69 @@ import org.apache.log4j.Logger;
 \r
 import compbio.data.sequence.Alignment;\r
 import compbio.data.sequence.UnknownFileFormatException;\r
-import compbio.engine.client.Executable;\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
+import compbio.runner.RunnerUtil;\r
 \r
-public class Probcons extends SkeletalExecutable<Probcons> implements\r
-       PipedExecutable<Probcons> {\r
+public class Probcons extends SkeletalExecutable<Probcons>\r
+               implements\r
+                       PipedExecutable<Probcons> {\r
 \r
-    private static Logger log = Logger.getLogger(Probcons.class);\r
+       private static Logger log = Logger.getLogger(Probcons.class);\r
 \r
-    // Cache for Limits information\r
-    private static LimitsManager<Probcons> limits;\r
-    private final static String ANNOTATION = "annotation.txt";\r
+       private final static String ANNOTATION = "annotation.txt";\r
 \r
-    public static final String KEY_VALUE_SEPARATOR = Util.SPACE;\r
+       public static final String KEY_VALUE_SEPARATOR = " ";\r
 \r
-    /**\r
-     * \r
-     * @param workDirectory\r
-     */\r
-    public Probcons() {\r
-       addParameters(Arrays.asList("-v", "-clustalw", "-annot", ANNOTATION));\r
-       /*\r
-        * Could either have probabilities or the alignment, but not both "-t",\r
-        * "probabilities"\r
+       /**\r
         */\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
+       public Probcons() {\r
+               addParameters(Arrays.asList("-v", "-clustalw", "-annot", ANNOTATION));\r
+               /*\r
+                * Could either have probabilities or the alignment, but not both "-t",\r
+                * "probabilities"\r
+                */\r
        }\r
-    }\r
-\r
-    @Override\r
-    public List<String> getCreatedFiles() {\r
-       return Arrays.asList(getOutput(), ANNOTATION, getError());\r
-    }\r
-\r
-    @Override\r
-    public Probcons setInput(String inFile) {\r
-       String input = getInput();\r
-       super.setInput(inFile);\r
-       // TODO replace with setLast\r
-       cbuilder.setParam(inFile);\r
-       return this;\r
-    }\r
 \r
-    @Override\r
-    public Limit<Probcons> getLimit(String presetName) {\r
-       if (limits == null) {\r
-           limits = getLimits();\r
+       @SuppressWarnings("unchecked")\r
+       @Override\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
-       Limit<Probcons> 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
+\r
+       @Override\r
+       public List<String> getCreatedFiles() {\r
+               return Arrays.asList(getOutput(), ANNOTATION, getError());\r
        }\r
-       return limit;\r
-    }\r
 \r
-    @Override\r
-    public LimitsManager<Probcons> getLimits() {\r
-       // synchronise on static field\r
-       synchronized (log) {\r
-           if (limits == null) {\r
-               limits = Util.getLimits(this.getClass());\r
-           }\r
+       @Override\r
+       public Probcons setInput(String inFile) {\r
+               String input = getInput();\r
+               super.setInput(inFile);\r
+               // TODO replace with setLast\r
+               cbuilder.setParam(inFile);\r
+               return this;\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<Probcons> getType() {\r
+               return (Class<Probcons>) this.getClass();\r
+       }\r
 }\r