Webservice which implements FoldWS and returns String. Parameters.xml file
[jabaws.git] / runner / compbio / runner / disorder / Disembl.java
index 337395c..7c54af1 100644 (file)
@@ -20,45 +20,37 @@ import java.io.FileNotFoundException;
 import java.io.IOException;\r
 import java.io.InputStream;\r
 \r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
 import org.apache.log4j.Logger;\r
 \r
-\r
-import compbio.data.sequence.Score;\r
+import compbio.data.sequence.ScoreManager;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.data.sequence.UnknownFileFormatException;\r
-\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
 \r
 /**\r
- *      DisEMBL.py smooth_frame peak_frame join_frame fold_coils fold_hotloops\r
- *      fold_rem465 sequence_file print \r
- *      \r
- *      'A default run would be: ./DisEMBL.py 8 8 4 1.2 1.4 1.2 fasta_file > out' \r
- *             \r
- *             This version of DisEMBL is 1.4 (latest available for download in Feb 2011)\r
- *             capable of outputting raw values      \r
- *      \r
- *      The values of the parameters are hard coded in DisEMBL.py script. \r
- *      smooth_frame=8 peak_frame=8 join_frame=4 fold_coils=1.2 fold_hotloops=1.4\r
- *      fold_rem465=1.2 \r
- *      \r
- *       Changing these values are not recommended by developers, apart from smoothing window. \r
- *       However, 5 orders of magnitude changes in this parameter does not change the output\r
- *       so allowing this change also seems pointless. Finally, the binary, DisEMBL depends on\r
- *       - Tisean is not happy with arbitruary changes to these values, so changing them can \r
- *       lead to problems.\r
- *        \r
+ * DisEMBL.py smooth_frame peak_frame join_frame fold_coils fold_hotloops\r
+ * fold_rem465 sequence_file print\r
+ * \r
+ * 'A default run would be: ./DisEMBL.py 8 8 4 1.2 1.4 1.2 fasta_file > out'\r
+ * \r
+ * This version of DisEMBL is 1.4 (latest available for download in Feb 2011)\r
+ * capable of outputting raw values\r
+ * \r
+ * The values of the parameters are hard coded in DisEMBL.py script.\r
+ * smooth_frame=8 peak_frame=8 join_frame=4 fold_coils=1.2 fold_hotloops=1.4\r
+ * fold_rem465=1.2\r
+ * \r
+ * Changing these values are not recommended by developers, apart from smoothing\r
+ * window. However, 5 orders of magnitude changes in this parameter does not\r
+ * change the output so allowing this change also seems pointless. Finally, the\r
+ * binary, DisEMBL depends on - Tisean is not happy with arbitruary changes to\r
+ * these values, so changing them can lead to problems.\r
  * \r
- *      This is not a standard DisEMBL! The script has been modified! \r
+ * \r
+ * This is not a standard DisEMBL! The script has been modified!\r
  * \r
  */\r
 public class Disembl extends SkeletalExecutable<Disembl>\r
@@ -67,11 +59,15 @@ public class Disembl extends SkeletalExecutable<Disembl>
 \r
        private static Logger log = Logger.getLogger(Disembl.class);\r
 \r
-       // Cache for Limits information\r
-       private static LimitsManager<Disembl> limits;\r
-\r
        public static final String KEY_VALUE_SEPARATOR = Util.SPACE;\r
 \r
+       /**\r
+        * For the region to be considered disordered the values must exceed these\r
+        */\r
+       public final double COILS_EXPECTATION_THRESHOLD = 0.43;\r
+       public final double REM_EXPECTATION_THRESHOLD = 0.5;\r
+       public final double LOOPS_EXPECTATION_THRESHOLD = 0.086;\r
+\r
        /* The parameter list there must not contain same values! */\r
        public Disembl() {\r
                // remove default input to prevent it to appear in the parameters list\r
@@ -80,33 +76,34 @@ public class Disembl extends SkeletalExecutable<Disembl>
        }\r
 \r
        @SuppressWarnings("unchecked")\r
-       public Map<String, Set<Score>> getResults(String workDirectory)\r
+       @Override\r
+       public ScoreManager getResults(String workDirectory)\r
                        throws ResultNotAvailableException {\r
 \r
                InputStream inStream = null;\r
-               Map<String, Set<Score>> results= null; \r
-                       try {\r
-                               inStream = new FileInputStream(new File(workDirectory,\r
-                                               getOutput()));\r
-                               results = SequenceUtil.removeSequences(SequenceUtil.readDisembl(inStream));\r
-                               inStream.close();\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
+               ScoreManager results = null;\r
+\r
+               try {\r
+                       inStream = new FileInputStream(new File(workDirectory, getOutput()));\r
+                       results = ScoreManager.newInstance(SequenceUtil\r
+                                       .readDisembl(inStream));\r
+                       inStream.close();\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
+               log.trace("DRESULTS: " + results);\r
                return results;\r
        }\r
-\r
        @Override\r
        public Disembl setInput(String inFile) {\r
                super.setInput(inFile);\r
@@ -114,41 +111,10 @@ public class Disembl extends SkeletalExecutable<Disembl>
                return this;\r
        }\r
 \r
+       @SuppressWarnings("unchecked")\r
        @Override\r
-       public Limit<Disembl> getLimit(String presetName) {\r
-               if (limits == null) {\r
-                       limits = getLimits();\r
-               }\r
-\r
-               Limit<Disembl> 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
-               return limit;\r
-       }\r
-\r
-       @Override\r
-       public LimitsManager<Disembl> getLimits() {\r
-               // synchronise on static field\r
-               synchronized (log) {\r
-                       if (limits == null) {\r
-                               limits = Util.getLimits(this.getClass());\r
-                       }\r
-               }\r
-               return limits;\r
-       }\r
-\r
-       @Override\r
-       public Class<? extends Executable<?>> getType() {\r
-               return this.getClass();\r
+       public Class<Disembl> getType() {\r
+               return (Class<Disembl>) this.getClass();\r
        }\r
 \r
 }\r