Change header template for a new version
[jabaws.git] / runner / compbio / runner / conservation / AACon.java
index ce4d293..0f96077 100644 (file)
@@ -1,15 +1,19 @@
-/*\r
- * Copyright (c) 2009 Peter Troshin JAva Bioinformatics Analysis Web Services\r
- * (JABAWS) @version: 1.0 This library is free software; you can redistribute it\r
- * and/or modify it under the terms of the Apache License version 2 as published\r
- * by the Apache Software Foundation This library is distributed in the hope\r
- * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\r
- * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * Apache License for more details. A copy of the license is in\r
- * apache_license.txt. It is also available here:\r
- * @see: http://www.apache.org/licenses/LICENSE-2.0.txt Any republication or\r
- * derived work distributed in source code form must include this copyright and\r
- * license notice.\r
+/* Copyright (c) 2011 Peter Troshin\r
+ *  \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
+ *  This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without\r
+ *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache \r
+ *  License for more details.\r
+ * \r
+ *  A copy of the license is in apache_license.txt. It is also available here:\r
+ * @see: http://www.apache.org/licenses/LICENSE-2.0.txt\r
+ * \r
+ * Any republication or derived work distributed in source code form\r
+ * must include this copyright and license notice.\r
  */\r
 \r
 package compbio.runner.conservation;\r
@@ -20,20 +24,17 @@ import java.io.FileNotFoundException;
 import java.io.IOException;\r
 import java.io.InputStream;\r
 import java.util.Arrays;\r
-import java.util.HashSet;\r
 import java.util.List;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
-import compbio.data.sequence.Score;\r
+import compbio.data.sequence.SMERFSConstraints;\r
+import compbio.data.sequence.ScoreManager;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.engine.client.CommandBuilder;\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
 /**\r
  * Command line\r
@@ -53,27 +54,29 @@ public class AACon extends SkeletalExecutable<AACon> {
         */\r
        private int ncoreNumber = 0;\r
 \r
-       private final String ncorePrm = "-n=";\r
-\r
-       // Cache for Limits information\r
-       private static LimitsManager<AACon> limits;\r
+       private final String ncorePrm = "-t=";\r
 \r
-       public static final String KEY_VALUE_SEPARATOR = Util.SPACE;\r
+       public static final String KEY_VALUE_SEPARATOR = "=";\r
        public static final String STAT_FILE = "stat.txt";\r
 \r
+       private final int windowWidth = SMERFSConstraints.DEFAULT_WINDOW_SIZE;\r
+       private final SMERFSConstraints colScoreMethod = SMERFSConstraints.MID_SCORE;\r
+       private final double gapTreshold = SMERFSConstraints.DEFAULT_GAP_THRESHOLD;\r
+\r
        public AACon() {\r
                addParameters(Arrays.asList("-jar", getLibPath(), "-d=" + STAT_FILE,\r
                                "-f=RESULT_NO_ALIGNMENT"));\r
        }\r
        // HashMap<Method, float[]>\r
        @Override\r
-       public HashSet<Score> getResults(String workDirectory)\r
+       public ScoreManager getResults(String workDirectory)\r
                        throws ResultNotAvailableException {\r
-               HashSet<Score> annotations = null;\r
+               ScoreManager annotations = null;\r
                try {\r
                        InputStream inStream = new FileInputStream(new File(workDirectory,\r
                                        getOutput()));\r
-                       annotations = SequenceUtil.readAAConResults(inStream);\r
+                       annotations = ScoreManager.newInstanceSingleSequence(SequenceUtil\r
+                                       .readAAConResults(inStream));\r
                        inStream.close();\r
                } catch (FileNotFoundException e) {\r
                        log.error(e.getMessage(), e.getCause());\r
@@ -97,7 +100,7 @@ public class AACon extends SkeletalExecutable<AACon> {
                                                        + "and initialize it with the location of jronn jar file");\r
                }\r
                if (new File(settings).isAbsolute()) {\r
-                       // Jronn jar can be found so no actions necessary\r
+                       // the jar can be found so no actions necessary\r
                        // no further actions is necessary\r
                        return settings;\r
                }\r
@@ -123,40 +126,10 @@ public class AACon extends SkeletalExecutable<AACon> {
                return this;\r
        }\r
 \r
+       @SuppressWarnings("unchecked")\r
        @Override\r
-       public Limit<AACon> getLimit(String presetName) {\r
-               if (limits == null) {\r
-                       limits = getLimits();\r
-               }\r
-               Limit<AACon> 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<AACon> 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<AACon> getType() {\r
+               return (Class<AACon>) this.getClass();\r
        }\r
 \r
        public static String getStatFile() {\r