Remove Annotated and MuptiAnnotated Sequence use Score instead
authorpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 2 Feb 2011 16:30:22 +0000 (16:30 +0000)
committerpvtroshin <pvtroshin@e3abac25-378b-4346-85de-24260fe3988d>
Wed, 2 Feb 2011 16:30:22 +0000 (16:30 +0000)
git-svn-id: link to svn.lifesci.dundee.ac.uk/svn/barton/ptroshin/JABA2@3660 e3abac25-378b-4346-85de-24260fe3988d

16 files changed:
TODO.txt
datamodel/compbio/data/sequence/AnnotatedSequence.java [deleted file]
datamodel/compbio/data/sequence/DisorderMethod.java [new file with mode: 0644]
datamodel/compbio/data/sequence/MultiAnnotatedSequence.java [deleted file]
datamodel/compbio/data/sequence/Score.java
datamodel/compbio/data/sequence/SequenceUtil.java
runner/compbio/runner/Util.java
runner/compbio/runner/disorder/Disembl.java
runner/compbio/runner/disorder/Jronn.java
testsrc/compbio/data/sequence/SequenceUtilTester.java
testsrc/compbio/runner/conservation/AAConTester.java
testsrc/compbio/runner/disorder/DisemblTester.java
testsrc/compbio/runner/disorder/JronnTester.java
webservices/compbio/ws/client/IOHelper.java
webservices/compbio/ws/client/Jws2Client.java
webservices/compbio/ws/server/JronnWS.java [new file with mode: 0644]

index 66b5984..f25cd0d 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -28,7 +28,7 @@ new parsers for the above programmes output (Stockholm MSA format?)
 \r
 Think hard on what to do with large output files? \r
 e.g. serve the hits table in full, but retrieve alignments on demand.\r
-What actually neeeds to be sent?   \r
+What actually needs to be sent?   \r
 \r
 Add facility to distribute other results of the calculations like the trees and \r
 annotation file for probcons. \r
diff --git a/datamodel/compbio/data/sequence/AnnotatedSequence.java b/datamodel/compbio/data/sequence/AnnotatedSequence.java
deleted file mode 100644 (file)
index 65dbce9..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-package compbio.data.sequence;\r
-\r
-import java.util.Arrays;\r
-\r
-public class AnnotatedSequence extends FastaSequence {\r
-\r
-       private float[] annotation;\r
-\r
-       private AnnotatedSequence() {\r
-               super();\r
-               // JAXB default constructor\r
-       }\r
-\r
-       public AnnotatedSequence(String id, String sequence, float[] annotation) {\r
-               super(id, sequence);\r
-               this.annotation = annotation;\r
-               if (annotation == null || annotation.length != sequence.length()) {\r
-                       throw new IllegalArgumentException("The length of the annotation ("\r
-                                       + ((annotation != null) ? annotation.length : "0")\r
-                                       + ") does not match the length of the sequence ("\r
-                                       + sequence.length() + ")!");\r
-               }\r
-       }\r
-\r
-       public AnnotatedSequence(FastaSequence fsequence, float[] annotation) {\r
-               this(fsequence.getId(), fsequence.getSequence(), annotation);\r
-       }\r
-\r
-       public float[] getAnnotation() {\r
-               return annotation;\r
-       }\r
-\r
-       @Override\r
-       public int hashCode() {\r
-               final int prime = 7;\r
-               int result = super.hashCode();\r
-               result = prime * result + Arrays.hashCode(annotation);\r
-               return result;\r
-       }\r
-\r
-       @Override\r
-       public boolean equals(Object obj) {\r
-               if (this == obj)\r
-                       return true;\r
-               if (!super.equals(obj))\r
-                       return false;\r
-               if (getClass() != obj.getClass())\r
-                       return false;\r
-               AnnotatedSequence other = (AnnotatedSequence) obj;\r
-               if (!Arrays.equals(annotation, other.annotation))\r
-                       return false;\r
-               return true;\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               return super.toString() + "Annotation:\n "\r
-                               + Arrays.toString(annotation) + "\n";\r
-       }\r
-\r
-}\r
diff --git a/datamodel/compbio/data/sequence/DisorderMethod.java b/datamodel/compbio/data/sequence/DisorderMethod.java
new file mode 100644 (file)
index 0000000..521d9a3
--- /dev/null
@@ -0,0 +1,6 @@
+package compbio.data.sequence;\r
+\r
+public enum DisorderMethod {\r
+\r
+       JRonn, Disembl\r
+}\r
diff --git a/datamodel/compbio/data/sequence/MultiAnnotatedSequence.java b/datamodel/compbio/data/sequence/MultiAnnotatedSequence.java
deleted file mode 100644 (file)
index 1212a7d..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-package compbio.data.sequence;\r
-\r
-import java.util.ArrayList;\r
-import java.util.EnumMap;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import compbio.util.annotation.NotThreadSafe;\r
-\r
-/**\r
- * TODO complete\r
- * \r
- * @author pvtroshin\r
- * \r
- * @param <T>\r
- *            enum type\r
- */\r
-@NotThreadSafe\r
-// @XmlAccessorType(XmlAccessType.FIELD)\r
-public class MultiAnnotatedSequence<T extends Enum<T>> {\r
-\r
-       private EnumMap<T, ArrayList<Float>> annotations;\r
-\r
-       MultiAnnotatedSequence() {\r
-               // default constructor for JAXB\r
-       }\r
-\r
-       public MultiAnnotatedSequence(Class<T> enumeration) {\r
-               this.annotations = new EnumMap<T, ArrayList<Float>>(enumeration);\r
-       }\r
-\r
-       public void addAnnotation(T type, ArrayList<Float> annotation) {\r
-               assert type != null : "Type is expected";\r
-               assert annotation != null : "Not empty value is expected!";\r
-               if (!annotations.isEmpty()) {\r
-                       assert annotations.values().iterator().next().size() == annotation\r
-                                       .size() : "Annotations must contain the same number of elements!";\r
-               }\r
-               this.annotations.put(type, annotation);\r
-       }\r
-\r
-       public Map<T, List<Float>> getAnnotations() {\r
-               return new EnumMap<T, List<Float>>(this.annotations);\r
-       }\r
-\r
-       @Override\r
-       public int hashCode() {\r
-               final int prime = 31;\r
-               int result = 1;\r
-               result = prime * result\r
-                               + ((annotations == null) ? 0 : annotations.hashCode());\r
-               return result;\r
-       }\r
-\r
-       @Override\r
-       public boolean equals(Object obj) {\r
-               if (this == obj)\r
-                       return true;\r
-               if (obj == null)\r
-                       return false;\r
-               if (getClass() != obj.getClass())\r
-                       return false;\r
-               MultiAnnotatedSequence other = (MultiAnnotatedSequence) obj;\r
-               if (annotations == null) {\r
-                       if (other.annotations != null)\r
-                               return false;\r
-               } else if (!annotations.equals(other.annotations))\r
-                       return false;\r
-               return true;\r
-       }\r
-\r
-       @Override\r
-       public String toString() {\r
-               String value = "";\r
-               for (Map.Entry<T, ArrayList<Float>> annt : annotations.entrySet()) {\r
-                       value += annt.getKey() + " ";\r
-                       value += annt.getValue() + "\n";\r
-               }\r
-               return value;\r
-       }\r
-\r
-}\r
index 98ba06a..8a110ee 100644 (file)
@@ -34,7 +34,7 @@ public class Score {
                NUMBER_FORMAT.setMaximumFractionDigits(3);\r
        }\r
 \r
-       private ConservationMethod method;\r
+       private Enum<?> method;\r
 \r
        private List<Float> scores;\r
 \r
@@ -52,17 +52,29 @@ public class Score {
         *            the actual conservation values for each column of the\r
         *            alignment\r
         */\r
-       public Score(ConservationMethod method, List<Float> scores) {\r
+       public Score(Enum<?> method, List<Float> scores) {\r
                this.method = method;\r
                this.scores = new ArrayList<Float>(scores);\r
        }\r
 \r
+       public Score(Enum<?> method, float[] scores) {\r
+               this.method = method;\r
+               this.scores = toList(scores);\r
+       }\r
+\r
+       private List<Float> toList(float[] values) {\r
+               List<Float> vlist = new ArrayList<Float>();\r
+               for (float v : values) {\r
+                       vlist.add(new Float(v));\r
+               }\r
+               return vlist;\r
+       }\r
        /**\r
         * Returns the ConservationMethod\r
         * \r
         * @return the ConservationMethod\r
         */\r
-       public ConservationMethod getMethod() {\r
+       public Enum<?> getMethod() {\r
                return method;\r
        }\r
 \r
index f061ac7..85ae95f 100644 (file)
@@ -25,9 +25,12 @@ import java.io.InputStreamReader;
 import java.io.OutputStream;\r
 import java.io.OutputStreamWriter;\r
 import java.util.ArrayList;\r
+import java.util.HashMap;\r
 import java.util.HashSet;\r
 import java.util.List;\r
+import java.util.Map;\r
 import java.util.Scanner;\r
+import java.util.Set;\r
 import java.util.logging.Level;\r
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
@@ -294,10 +297,10 @@ public final class SequenceUtil {
                outWriter.close();\r
        }\r
 \r
-       public static List<AnnotatedSequence> readJRonn(final File result)\r
+       public static Map<String, Score> readJRonn(final File result)\r
                        throws IOException, UnknownFileFormatException {\r
                InputStream input = new FileInputStream(result);\r
-               List<AnnotatedSequence> sequences = readJRonn(input);\r
+               Map<String, Score> sequences = readJRonn(input);\r
                input.close();\r
                return sequences;\r
        }\r
@@ -321,9 +324,9 @@ public final class SequenceUtil {
         *             is thrown if the inStream represents an unknown source of\r
         * data, i.e. not a JRonn output\r
         */\r
-       public static List<AnnotatedSequence> readJRonn(final InputStream inStream)\r
+       public static Map<String, Score> readJRonn(final InputStream inStream)\r
                        throws IOException, UnknownFileFormatException {\r
-               final List<AnnotatedSequence> seqs = new ArrayList<AnnotatedSequence>();\r
+               final Map<String, Score> seqs = new HashMap<String, Score>();\r
 \r
                final BufferedReader infasta = new BufferedReader(\r
                                new InputStreamReader(inStream, "UTF8"), 16000);\r
@@ -351,14 +354,13 @@ public final class SequenceUtil {
                                                        "File does not look like Jronn horizontally formatted output file!\n"\r
                                                                        + JRONN_WRONG_FORMAT_MESSAGE);\r
                                }\r
-                               seqs.add(new AnnotatedSequence(sname, sequence, annotation));\r
+                               seqs.put(sname, new Score(DisorderMethod.JRonn, annotation));\r
                        }\r
                } while (line != null);\r
 \r
                infasta.close();\r
                return seqs;\r
        }\r
-\r
        private static float[] convertToNumber(String[] annotValues)\r
                        throws UnknownFileFormatException {\r
                float[] annotation = new float[annotValues.length];\r
@@ -404,18 +406,24 @@ public final class SequenceUtil {
         * \r
         * TODO complete!\r
         * \r
-        * # RESIDUE COILS REM465 HOTLOOPS M 0.86010 0.88512 0.37094 T 0.79983\r
-        * 0.85864 0.44331 .... # RESIDUE COILS REM465 HOTLOOPS M 0.86010 0.88512\r
-        * 0.37094\r
+        * RESIDUE COILS REM465 HOTLOOPS\r
+        * \r
+        * M 0.86010 0.88512 0.37094\r
+        * \r
+        * T 0.79983 0.85864 0.44331 ....\r
+        * \r
+        * RESIDUE COILS REM465 HOTLOOPS\r
+        * \r
+        * M 0.86010 0.88512 0.37094\r
+        * \r
         * \r
         * @param input\r
         * @return\r
         * @throws IOException\r
         * @throws UnknownFileFormatException\r
         */\r
-       static List<MultiAnnotatedSequence<DisemblResultAnnot>> readDisembl(\r
-                       final InputStream input) throws IOException,\r
-                       UnknownFileFormatException {\r
+       static Map<FastaSequence, Set<Score>> readDisembl(final InputStream input)\r
+                       throws IOException, UnknownFileFormatException {\r
                Scanner scan = new Scanner(input);\r
                scan.useDelimiter("# RESIDUE COILS REM465 HOTLOOPS\n");\r
                if (!scan.hasNext()) {\r
@@ -425,7 +433,7 @@ public final class SequenceUtil {
                                                        + " No such line was found!");\r
                }\r
 \r
-               List<MultiAnnotatedSequence<DisemblResultAnnot>> results = new ArrayList<MultiAnnotatedSequence<DisemblResultAnnot>>();\r
+               Map<FastaSequence, Set<Score>> results = new HashMap<FastaSequence, Set<Score>>();\r
                int seqCounter = 0;\r
                while (scan.hasNext()) {\r
                        seqCounter++;\r
@@ -435,10 +443,8 @@ public final class SequenceUtil {
                        ArrayList<Float> coils = new ArrayList<Float>();\r
                        ArrayList<Float> rem = new ArrayList<Float>();\r
                        ArrayList<Float> hotloops = new ArrayList<Float>();\r
-\r
-                       MultiAnnotatedSequence<DisemblResultAnnot> disemblRes = new MultiAnnotatedSequence<DisemblResultAnnot>(\r
-                                       DisemblResultAnnot.class);\r
-\r
+                       FastaSequence fs = new FastaSequence(Integer.toString(seqCounter),\r
+                                       singleSeq);\r
                        while (scansingle.hasNextLine()) {\r
                                String valueLine = scansingle.nextLine();\r
                                Scanner values = new Scanner(valueLine);\r
@@ -448,19 +454,18 @@ public final class SequenceUtil {
                                hotloops.add(values.nextFloat());\r
                                values.close();\r
                        }\r
-                       disemblRes.addAnnotation(DisemblResultAnnot.COILS, coils);\r
-                       disemblRes.addAnnotation(DisemblResultAnnot.REM465, rem);\r
-                       disemblRes.addAnnotation(DisemblResultAnnot.HOTLOOPS, hotloops);\r
-                       // TODO\r
-                       // disemblRes.sequence = seqbuffer.toString();\r
+                       Set<Score> scores = new HashSet<Score>();\r
+                       scores.add(new Score(DisemblResultAnnot.COILS, coils));\r
+                       scores.add(new Score(DisemblResultAnnot.HOTLOOPS, hotloops));\r
+                       scores.add(new Score(DisemblResultAnnot.REM465, rem));\r
+                       results.put(fs, scores);\r
+\r
                        scansingle.close();\r
-                       results.add(disemblRes);\r
                }\r
 \r
                input.close();\r
                return results;\r
        }\r
-\r
        /**\r
         * Read AACon result with no alignment files. This method leaves incoming\r
         * the InputStream results open!\r
index 9475a0b..2f040aa 100644 (file)
@@ -23,13 +23,14 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;\r
 import java.io.IOException;\r
 import java.util.List;\r
+import java.util.Map;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
 import compbio.data.sequence.Alignment;\r
-import compbio.data.sequence.AnnotatedSequence;\r
 import compbio.data.sequence.ClustalAlignmentUtil;\r
 import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.Score;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.data.sequence.UnknownFileFormatException;\r
 import compbio.engine.client.ConfExecutable;\r
@@ -43,125 +44,127 @@ import compbio.util.PropertyHelper;
 \r
 public final class Util {\r
 \r
-    private static Logger log = Logger.getLogger(Util.class);\r
-\r
-    private static final PropertyHelper ph = PropertyHelperManager\r
-           .getPropertyHelper();\r
-\r
-    public static final String SPACE = " ";\r
-\r
-    /**\r
-     * For now just assume that all parameters which came in needs setting it\r
-     * will be a client responsibility to prepare RunnerConfig object then\r
-     * \r
-     * @param rconfig\r
-     * @return\r
-     * \r
-     *         public static List<String> toOptionString(RunnerConfig<?>\r
-     *         rconfig) { String option = ""; List<String> options = new\r
-     *         ArrayList<String>(); for (Parameter<?> par :\r
-     *         rconfig.getParameters()) { if (par.getPossibleValues().isEmpty())\r
-     *         { option = par.getOptionName(); } else { option =\r
-     *         par.getOptionName() + "=" + par.getPossibleValues().get(0); } //\r
-     *         separate options options.add(option); } return options; }\r
-     */\r
-\r
-    public static <T> LimitsManager<T> getLimits(\r
-           Class<? extends Executable<T>> clazz) {\r
-       LimitsManager<T> limits = null;\r
-       try {\r
-           limits = ConfExecutable.getRunnerLimits(clazz);\r
-           if (limits == null) {\r
-               return null;\r
-           }\r
-       } catch (FileNotFoundException e) {\r
-           log.warn("No limits are found for " + clazz + " executable! "\r
-                   + e.getLocalizedMessage(), e.getCause());\r
-           return null;\r
-       } catch (IOException e) {\r
-           log.warn("IO exception while attempting to read limits for "\r
-                   + clazz + " executable! " + e.getLocalizedMessage(), e\r
-                   .getCause());\r
-           return null;\r
+       private static Logger log = Logger.getLogger(Util.class);\r
+\r
+       private static final PropertyHelper ph = PropertyHelperManager\r
+                       .getPropertyHelper();\r
+\r
+       public static final String SPACE = " ";\r
+\r
+       /**\r
+        * For now just assume that all parameters which came in needs setting it\r
+        * will be a client responsibility to prepare RunnerConfig object then\r
+        * \r
+        * @param rconfig\r
+        * @return\r
+        * \r
+        *         public static List<String> toOptionString(RunnerConfig<?>\r
+        *         rconfig) { String option = ""; List<String> options = new\r
+        *         ArrayList<String>(); for (Parameter<?> par :\r
+        *         rconfig.getParameters()) { if (par.getPossibleValues().isEmpty())\r
+        *         { option = par.getOptionName(); } else { option =\r
+        *         par.getOptionName() + "=" + par.getPossibleValues().get(0); } //\r
+        *         separate options options.add(option); } return options; }\r
+        */\r
+\r
+       public static <T> LimitsManager<T> getLimits(\r
+                       Class<? extends Executable<T>> clazz) {\r
+               LimitsManager<T> limits = null;\r
+               try {\r
+                       limits = ConfExecutable.getRunnerLimits(clazz);\r
+                       if (limits == null) {\r
+                               return null;\r
+                       }\r
+               } catch (FileNotFoundException e) {\r
+                       log.warn(\r
+                                       "No limits are found for " + clazz + " executable! "\r
+                                                       + e.getLocalizedMessage(), e.getCause());\r
+                       return null;\r
+               } catch (IOException e) {\r
+                       log.warn("IO exception while attempting to read limits for "\r
+                                       + clazz + " executable! " + e.getLocalizedMessage(),\r
+                                       e.getCause());\r
+                       return null;\r
+               }\r
+               return limits;\r
        }\r
-       return limits;\r
-    }\r
-\r
-    public static synchronized <T> RunnerConfig<T> getSupportedOptions(\r
-           Class<? extends Executable<T>> clazz) {\r
-       try {\r
-           return ConfExecutable.getRunnerOptions(clazz);\r
-       } catch (FileNotFoundException e) {\r
-           log.error("Could not load " + clazz + " Parameters !"\r
-                   + e.getMessage(), e.getCause());\r
-       } catch (IOException e) {\r
-           log.error("IO exception while reading " + clazz + " Parameters !"\r
-                   + e.getMessage(), e.getCause());\r
+\r
+       public static synchronized <T> RunnerConfig<T> getSupportedOptions(\r
+                       Class<? extends Executable<T>> clazz) {\r
+               try {\r
+                       return ConfExecutable.getRunnerOptions(clazz);\r
+               } catch (FileNotFoundException e) {\r
+                       log.error(\r
+                                       "Could not load " + clazz + " Parameters !"\r
+                                                       + e.getMessage(), e.getCause());\r
+               } catch (IOException e) {\r
+                       log.error("IO exception while reading " + clazz + " Parameters !"\r
+                                       + e.getMessage(), e.getCause());\r
+               }\r
+               return null;\r
        }\r
-       return null;\r
-    }\r
-\r
-    public static <T> PresetManager<T> getPresets(\r
-           Class<? extends Executable<T>> clazz) {\r
-       try {\r
-           return ConfExecutable.getRunnerPresets(clazz);\r
-       } catch (FileNotFoundException e) {\r
-           log.warn("No presets are found for " + clazz + " executable! "\r
-                   + e.getLocalizedMessage(), e.getCause());\r
-       } catch (IOException e) {\r
-           log.warn("IO exception while reading presents! for " + clazz\r
-                   + " executable! " + e.getLocalizedMessage(), e.getCause());\r
+\r
+       public static <T> PresetManager<T> getPresets(\r
+                       Class<? extends Executable<T>> clazz) {\r
+               try {\r
+                       return ConfExecutable.getRunnerPresets(clazz);\r
+               } catch (FileNotFoundException e) {\r
+                       log.warn(\r
+                                       "No presets are found for " + clazz + " executable! "\r
+                                                       + e.getLocalizedMessage(), e.getCause());\r
+               } catch (IOException e) {\r
+                       log.warn("IO exception while reading presents! for " + clazz\r
+                                       + " executable! " + e.getLocalizedMessage(), e.getCause());\r
+               }\r
+               return null;\r
        }\r
-       return null;\r
-    }\r
-\r
-    public static final Alignment readClustalFile(String workDirectory,\r
-           String clustFile) throws UnknownFileFormatException, IOException,\r
-           FileNotFoundException, NullPointerException {\r
-       assert !compbio.util.Util.isEmpty(workDirectory);\r
-       assert !compbio.util.Util.isEmpty(clustFile);\r
-       File cfile = new File(compbio.engine.client.Util.getFullPath(\r
-               workDirectory, clustFile));\r
-       log.trace("CLUSTAL OUTPUT FILE PATH: " + cfile.getAbsolutePath());\r
-       if (!(cfile.exists() && cfile.length() > 0)) {\r
-           throw new FileNotFoundException("Result for the jobId "\r
-                   + workDirectory + " with file name " + clustFile\r
-                   + " is not found!");\r
+\r
+       public static final Alignment readClustalFile(String workDirectory,\r
+                       String clustFile) throws UnknownFileFormatException, IOException,\r
+                       FileNotFoundException, NullPointerException {\r
+               assert !compbio.util.Util.isEmpty(workDirectory);\r
+               assert !compbio.util.Util.isEmpty(clustFile);\r
+               File cfile = new File(compbio.engine.client.Util.getFullPath(\r
+                               workDirectory, clustFile));\r
+               log.trace("CLUSTAL OUTPUT FILE PATH: " + cfile.getAbsolutePath());\r
+               if (!(cfile.exists() && cfile.length() > 0)) {\r
+                       throw new FileNotFoundException("Result for the jobId "\r
+                                       + workDirectory + " with file name " + clustFile\r
+                                       + " is not found!");\r
+               }\r
+               return ClustalAlignmentUtil.readClustalFile(cfile);\r
        }\r
-       return ClustalAlignmentUtil.readClustalFile(cfile);\r
-    }\r
-\r
-    public static final List<AnnotatedSequence> readJronnFile(\r
-           String workDirectory, String clustFile)\r
-           throws UnknownFileFormatException, IOException,\r
-           FileNotFoundException, NullPointerException {\r
-       assert !compbio.util.Util.isEmpty(workDirectory);\r
-       assert !compbio.util.Util.isEmpty(clustFile);\r
-       File cfile = new File(compbio.engine.client.Util.getFullPath(\r
-               workDirectory, clustFile));\r
-       log.trace("Jronn OUTPUT FILE PATH: " + cfile.getAbsolutePath());\r
-       if (!(cfile.exists() && cfile.length() > 0)) {\r
-           throw new FileNotFoundException("Result for the jobId "\r
-                   + workDirectory + " with file name " + clustFile\r
-                   + " is not found!");\r
+\r
+       public static final Map<String, Score> readJronnFile(String workDirectory,\r
+                       String clustFile) throws UnknownFileFormatException, IOException,\r
+                       FileNotFoundException, NullPointerException {\r
+               assert !compbio.util.Util.isEmpty(workDirectory);\r
+               assert !compbio.util.Util.isEmpty(clustFile);\r
+               File cfile = new File(compbio.engine.client.Util.getFullPath(\r
+                               workDirectory, clustFile));\r
+               log.trace("Jronn OUTPUT FILE PATH: " + cfile.getAbsolutePath());\r
+               if (!(cfile.exists() && cfile.length() > 0)) {\r
+                       throw new FileNotFoundException("Result for the jobId "\r
+                                       + workDirectory + " with file name " + clustFile\r
+                                       + " is not found!");\r
+               }\r
+               return SequenceUtil.readJRonn(cfile);\r
        }\r
-       return SequenceUtil.readJRonn(cfile);\r
-    }\r
-\r
-    public static void writeInput(List<FastaSequence> sequences,\r
-           ConfiguredExecutable<?> exec) {\r
-\r
-       File filein = new File(exec.getInput());\r
-       try {\r
-           FileOutputStream fout = new FileOutputStream(filein);\r
-           log.debug("File path: " + filein.getAbsolutePath());\r
-           SequenceUtil.writeFasta(fout, sequences);\r
-           fout.close();\r
-       } catch (FileNotFoundException e) {\r
-           e.printStackTrace();\r
-       } catch (IOException e) {\r
-           e.printStackTrace();\r
+\r
+       public static void writeInput(List<FastaSequence> sequences,\r
+                       ConfiguredExecutable<?> exec) {\r
+\r
+               File filein = new File(exec.getInput());\r
+               try {\r
+                       FileOutputStream fout = new FileOutputStream(filein);\r
+                       log.debug("File path: " + filein.getAbsolutePath());\r
+                       SequenceUtil.writeFasta(fout, sequences);\r
+                       fout.close();\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+               }\r
        }\r
-    }\r
 \r
 }\r
index c6b278f..716859f 100644 (file)
 \r
 package compbio.runner.disorder;\r
 \r
-import java.io.FileNotFoundException;\r
-import java.io.IOException;\r
 import java.util.Arrays;\r
+import java.util.Map;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
-import compbio.data.sequence.Alignment;\r
-import compbio.data.sequence.UnknownFileFormatException;\r
+import compbio.data.sequence.Score;\r
 import compbio.engine.client.Executable;\r
 import compbio.engine.client.PipedExecutable;\r
 import compbio.engine.client.SkeletalExecutable;\r
@@ -46,8 +44,9 @@ import compbio.runner.Util;
  *      print 'Mode: "default"(nothing) or "scores" which will give scores per\r
  *      residue in TAB separated format'\r
  */\r
-public class Disembl extends SkeletalExecutable<Disembl> implements\r
-               PipedExecutable<Disembl> {\r
+public class Disembl extends SkeletalExecutable<Disembl>\r
+               implements\r
+                       PipedExecutable<Disembl> {\r
 \r
        private static Logger log = Logger.getLogger(Disembl.class);\r
 \r
@@ -65,23 +64,10 @@ public class Disembl extends SkeletalExecutable<Disembl> implements
        }\r
 \r
        @SuppressWarnings("unchecked")\r
-       public Alignment getResults(String workDirectory)\r
+       public Map<String, Score> 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
+               return null;\r
        }\r
 \r
        @Override\r
index 57cf9f6..a436456 100644 (file)
@@ -25,10 +25,11 @@ import java.io.IOException;
 import java.io.InputStream;\r
 import java.util.Arrays;\r
 import java.util.List;\r
+import java.util.Map;\r
 \r
 import org.apache.log4j.Logger;\r
 \r
-import compbio.data.sequence.AnnotatedSequence;\r
+import compbio.data.sequence.Score;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.data.sequence.UnknownFileFormatException;\r
 import compbio.engine.client.CommandBuilder;\r
@@ -49,156 +50,157 @@ import compbio.runner.Util;
  */\r
 public class Jronn extends SkeletalExecutable<Jronn> {\r
 \r
-    private static Logger log = Logger.getLogger(Jronn.class);\r
-\r
-    /**\r
-     * Number of cores to use, defaults to 1 for local execution or the value of\r
-     * "jronn.cluster.cpunum" property for cluster execution\r
-     */\r
-    private int ncoreNumber = 0;\r
-\r
-    private final String ncorePrm = "-n=";\r
-\r
-    // Cache for Limits information\r
-    private static LimitsManager<Jronn> limits;\r
-\r
-    public static final String KEY_VALUE_SEPARATOR = Util.SPACE;\r
-    public static final String STAT_FILE = "stat.txt";\r
-\r
-    public Jronn() {\r
-       addParameters(Arrays.asList("-jar", getLibPath(), "-s=" + STAT_FILE,\r
-               "-f=H"));\r
-    }\r
-\r
-    @SuppressWarnings("unchecked")\r
-    @Override\r
-    public List<AnnotatedSequence> getResults(String workDirectory)\r
-           throws ResultNotAvailableException {\r
-       List<AnnotatedSequence> sequences = null;\r
-       try {\r
-           InputStream inStream = new FileInputStream(new File(workDirectory,\r
-                   getOutput()));\r
-           sequences = SequenceUtil.readJRonn(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
+       private static Logger log = Logger.getLogger(Jronn.class);\r
+\r
+       /**\r
+        * Number of cores to use, defaults to 1 for local execution or the value of\r
+        * "jronn.cluster.cpunum" property for cluster execution\r
+        */\r
+       private int ncoreNumber = 0;\r
+\r
+       private final String ncorePrm = "-n=";\r
+\r
+       // Cache for Limits information\r
+       private static LimitsManager<Jronn> limits;\r
+\r
+       public static final String KEY_VALUE_SEPARATOR = Util.SPACE;\r
+       public static final String STAT_FILE = "stat.txt";\r
+\r
+       public Jronn() {\r
+               addParameters(Arrays.asList("-jar", getLibPath(), "-s=" + STAT_FILE,\r
+                               "-f=H"));\r
+       }\r
+\r
+       @SuppressWarnings("unchecked")\r
+       @Override\r
+       public Map<String, Score> getResults(String workDirectory)\r
+                       throws ResultNotAvailableException {\r
+               Map<String, Score> sequences = null;\r
+               try {\r
+                       InputStream inStream = new FileInputStream(new File(workDirectory,\r
+                                       getOutput()));\r
+                       sequences = SequenceUtil.readJRonn(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
+               return sequences;\r
+       }\r
+\r
+       private static String getLibPath() {\r
+\r
+               String settings = ph.getProperty("jronn.jar.file");\r
+               if (compbio.util.Util.isEmpty(settings)) {\r
+                       throw new NullPointerException(\r
+                                       "Please define jronn.jar.file property in Executable.properties file"\r
+                                                       + "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
+                       // no further actions is necessary\r
+                       return settings;\r
+               }\r
+               return compbio.engine.client.Util.convertToAbsolute(settings);\r
+       }\r
+\r
+       @Override\r
+       public List<String> getCreatedFiles() {\r
+               return Arrays.asList(getOutput(), getError());\r
        }\r
-       return sequences;\r
-    }\r
 \r
-    private static String getLibPath() {\r
+       @Override\r
+       public Jronn setInput(String inFile) {\r
+               super.setInput(inFile);\r
+               cbuilder.setParam("-i=" + inFile);\r
+               return this;\r
+       }\r
 \r
-       String settings = ph.getProperty("jronn.jar.file");\r
-       if (compbio.util.Util.isEmpty(settings)) {\r
-           throw new NullPointerException(\r
-                   "Please define jronn.jar.file property in Executable.properties file"\r
-                           + "and initialize it with the location of jronn jar file");\r
+       @Override\r
+       public Jronn setOutput(String outFile) {\r
+               super.setOutput(outFile);\r
+               cbuilder.setParam("-o=" + outFile);\r
+               return this;\r
        }\r
-       if (new File(settings).isAbsolute()) {\r
-           // Jronn jar can be found so no actions necessary\r
-           // no further actions is necessary\r
-           return settings;\r
+\r
+       @Override\r
+       public Limit<Jronn> getLimit(String presetName) {\r
+               if (limits == null) {\r
+                       limits = getLimits();\r
+               }\r
+               Limit<Jronn> 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<Jronn> 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
-       return compbio.engine.client.Util.convertToAbsolute(settings);\r
-    }\r
-\r
-    @Override\r
-    public List<String> getCreatedFiles() {\r
-       return Arrays.asList(getOutput(), getError());\r
-    }\r
-\r
-    @Override\r
-    public Jronn setInput(String inFile) {\r
-       super.setInput(inFile);\r
-       cbuilder.setParam("-i=" + inFile);\r
-       return this;\r
-    }\r
-\r
-    @Override\r
-    public Jronn setOutput(String outFile) {\r
-       super.setOutput(outFile);\r
-       cbuilder.setParam("-o=" + outFile);\r
-       return this;\r
-    }\r
-\r
-    @Override\r
-    public Limit<Jronn> getLimit(String presetName) {\r
-       if (limits == null) {\r
-           limits = getLimits();\r
+\r
+       @Override\r
+       public Class<? extends Executable<?>> getType() {\r
+               return this.getClass();\r
        }\r
-       Limit<Jronn> limit = null;\r
-       if (limits != null) {\r
-           // this returns default limit if preset is undefined!\r
-           limit = limits.getLimitByName(presetName);\r
+\r
+       public static String getStatFile() {\r
+               return STAT_FILE;\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
+       public void setNCore(int ncoreNumber) {\r
+               if (ncoreNumber < 1 || ncoreNumber > 100) {\r
+                       throw new IndexOutOfBoundsException(\r
+                                       "Number of cores must be within 1 and 100 ");\r
+               }\r
+               this.ncoreNumber = ncoreNumber;\r
+               cbuilder.setParam(ncorePrm + Integer.toString(getNCore()));\r
        }\r
-       return limit;\r
-    }\r
-\r
-    @Override\r
-    public LimitsManager<Jronn> getLimits() {\r
-       // synchronise on static field\r
-       synchronized (log) {\r
-           if (limits == null) {\r
-               limits = Util.getLimits(this.getClass());\r
-           }\r
+\r
+       int getNCore() {\r
+               return ncoreNumber;\r
        }\r
-       return limits;\r
-    }\r
-\r
-    @Override\r
-    public Class<? extends Executable<?>> getType() {\r
-       return this.getClass();\r
-    }\r
-\r
-    public static String getStatFile() {\r
-       return STAT_FILE;\r
-    }\r
-\r
-    public void setNCore(int ncoreNumber) {\r
-       if (ncoreNumber < 1 || ncoreNumber > 100) {\r
-           throw new IndexOutOfBoundsException(\r
-                   "Number of cores must be within 1 and 100 ");\r
+\r
+       @Override\r
+       public CommandBuilder<Jronn> getParameters(ExecProvider provider) {\r
+               // If number of cores is provided, set it for the cluster execution\r
+               // only!\r
+               if (provider == Executable.ExecProvider.Cluster) {\r
+                       int cpunum = SkeletalExecutable.getClusterCpuNum(getType());\r
+                       cpunum = (cpunum == 0) ? 1 : cpunum;\r
+                       setNCore(cpunum);\r
+               } else {\r
+                       // Limit number of cores to 1 for ANY execution which does not set\r
+                       // Ncores explicitly using setNCore method or is run on local VM\r
+                       if (ncoreNumber == 0) {\r
+                               setNCore(1);\r
+                       }\r
+               }\r
+               return super.getParameters(provider);\r
        }\r
-       this.ncoreNumber = ncoreNumber;\r
-       cbuilder.setParam(ncorePrm + Integer.toString(getNCore()));\r
-    }\r
-\r
-    int getNCore() {\r
-       return ncoreNumber;\r
-    }\r
-\r
-    @Override\r
-    public CommandBuilder<Jronn> getParameters(ExecProvider provider) {\r
-       // If number of cores is provided, set it for the cluster execution only!\r
-       if (provider == Executable.ExecProvider.Cluster) {\r
-               int cpunum = SkeletalExecutable.getClusterCpuNum(getType());\r
-               cpunum = (cpunum==0) ? 1 : cpunum; \r
-                       setNCore(cpunum);\r
-       } else { \r
-               // Limit number of cores to 1 for ANY execution which does not set\r
-               // Ncores explicitly using setNCore method or is run on local VM\r
-               if(ncoreNumber==0) {\r
-                       setNCore(1);\r
-               }\r
-       }\r
-       return super.getParameters(provider);\r
-    }\r
 \r
 }\r
index f526578..1460b52 100644 (file)
@@ -26,6 +26,8 @@ import java.io.IOException;
 import java.io.InputStream;\r
 import java.util.HashSet;\r
 import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
 \r
 import org.testng.annotations.Test;\r
 \r
@@ -118,15 +120,14 @@ public class SequenceUtilTester {
                FileInputStream fio;\r
                try {\r
                        fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH + "jronn.out");\r
-                       List<AnnotatedSequence> aseqs = SequenceUtil.readJRonn(fio);\r
+                       Map<String, Score> aseqs = SequenceUtil.readJRonn(fio);\r
                        assertNotNull(aseqs);\r
                        assertEquals(aseqs.size(), 3);\r
-                       AnnotatedSequence aseq = aseqs.get(0);\r
+                       Score aseq = aseqs.get(0);\r
                        assertNotNull(aseq);\r
-                       assertNotNull(aseq.getAnnotation());\r
+                       assertNotNull(aseq.getScores());\r
                        // System.out.println(aseq);\r
-                       assertEquals(aseq.getAnnotation().length, aseq.getSequence()\r
-                                       .length());\r
+                       assertEquals(aseq.getScores().size(), aseq.getScores().size());\r
                        fio.close();\r
                } catch (FileNotFoundException e) {\r
                        e.printStackTrace();\r
@@ -156,7 +157,7 @@ public class SequenceUtilTester {
                try {\r
                        fio = new FileInputStream(AllTestSuit.TEST_DATA_PATH\r
                                        + "disembl.out");\r
-                       List<MultiAnnotatedSequence<DisemblResultAnnot>> aseqs = SequenceUtil\r
+                       Map<FastaSequence, Set<Score>> aseqs = SequenceUtil\r
                                        .readDisembl(fio);\r
                        assertNotNull(aseqs);\r
 \r
index fd3749b..859c4ae 100644 (file)
@@ -29,6 +29,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;\r
 import java.text.ParseException;\r
 import java.util.Arrays;\r
+import java.util.HashSet;\r
 \r
 import javax.xml.bind.ValidationException;\r
 \r
@@ -37,8 +38,7 @@ import org.ggf.drmaa.JobInfo;
 import org.testng.annotations.BeforeMethod;\r
 import org.testng.annotations.Test;\r
 \r
-import compbio.data.sequence.ConservationMethod;\r
-import compbio.data.sequence.MultiAnnotatedSequence;\r
+import compbio.data.sequence.Score;\r
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.FilePuller;\r
@@ -188,9 +188,9 @@ public class AAConTester {
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       MultiAnnotatedSequence<ConservationMethod> annotations = confAAcon.getResults();\r
+                       HashSet<Score> annotations = confAAcon.getResults();\r
                        assertNotNull(annotations);\r
-                       assertEquals(annotations.getAnnotations().size(), 1);\r
+                       assertEquals(annotations.size(), 1);\r
                        assertEquals(al1.getResults(), annotations);\r
                } catch (JobSubmissionException e) {\r
                        e.printStackTrace();\r
@@ -219,9 +219,9 @@ public class AAConTester {
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       MultiAnnotatedSequence<ConservationMethod> annotations = confAAcon.getResults();\r
+                       HashSet<Score> annotations = confAAcon.getResults();\r
                        assertNotNull(annotations);\r
-                       assertEquals(annotations.getAnnotations().size(), 13);\r
+                       assertEquals(annotations.size(), 13);\r
                        assertEquals(al1.getResults(), annotations);\r
                } catch (JobSubmissionException e) {\r
                        e.printStackTrace();\r
@@ -252,9 +252,9 @@ public class AAConTester {
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       MultiAnnotatedSequence<ConservationMethod> annotations = confAAcon.getResults();\r
+                       HashSet<Score> annotations = confAAcon.getResults();\r
                        assertNotNull(annotations);\r
-                       assertEquals(annotations.getAnnotations().size(), 3);\r
+                       assertEquals(annotations.size(), 3);\r
                        assertEquals(al1.getResults(), annotations);\r
 \r
                } catch (JobSubmissionException e) {\r
index 85d5e91..d77648e 100644 (file)
@@ -30,7 +30,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
 import java.text.ParseException;\r
-import java.util.List;\r
+import java.util.HashSet;\r
 \r
 import javax.xml.bind.ValidationException;\r
 \r
@@ -39,7 +39,7 @@ import org.ggf.drmaa.JobInfo;
 import org.testng.annotations.BeforeMethod;\r
 import org.testng.annotations.Test;\r
 \r
-import compbio.data.sequence.AnnotatedSequence;\r
+import compbio.data.sequence.Score;\r
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.FilePuller;\r
@@ -66,287 +66,289 @@ import compbio.util.SysPrefs;
 \r
 public class DisemblTester {\r
 \r
-    public static String test_outfile = "TO1381.disembl.out";\r
+       public static String test_outfile = "TO1381.disembl.out";\r
 \r
-    private Disembl disembl;\r
+       private Disembl disembl;\r
 \r
-    @BeforeMethod(alwaysRun = true)\r
-    void init() {\r
-       disembl = new Disembl();\r
-       disembl.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
-    }\r
+       @BeforeMethod(alwaysRun = true)\r
+       void init() {\r
+               disembl = new Disembl();\r
+               disembl.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
+       }\r
 \r
-    @Test(groups = { AllTestSuit.test_group_cluster,\r
-           AllTestSuit.test_group_runner })\r
-    public void testRunOnCluster() {\r
-       assertFalse(SysPrefs.isWindows,\r
-               "Cluster execution can only be in unix environment");\r
-       try {\r
-           ConfiguredExecutable<Disembl> confDisembl = Configurator\r
-                   .configureExecutable(disembl,\r
-                           Executable.ExecProvider.Cluster);\r
-           JobRunner runner = JobRunner.getInstance(confDisembl);\r
+       @Test(groups = {AllTestSuit.test_group_cluster,\r
+                       AllTestSuit.test_group_runner})\r
+       public void testRunOnCluster() {\r
+               assertFalse(SysPrefs.isWindows,\r
+                               "Cluster execution can only be in unix environment");\r
+               try {\r
+                       ConfiguredExecutable<Disembl> confDisembl = Configurator\r
+                                       .configureExecutable(disembl,\r
+                                                       Executable.ExecProvider.Cluster);\r
+                       JobRunner runner = JobRunner.getInstance(confDisembl);\r
 \r
-           assertNotNull(runner, "Runner is NULL");\r
-           runner.executeJob();\r
-           // assertNotNull("JobId is null", jobId1);\r
-           JobStatus status = runner.getJobStatus();\r
-           assertTrue(status == JobStatus.PENDING\r
-                   || status == JobStatus.RUNNING,\r
-                   "Status of the process is wrong!");\r
-           JobInfo info = runner.getJobInfo();\r
-           assertNotNull(info, "JobInfo is null");\r
-           StatisticManager sm = new StatisticManager(info);\r
-           assertNotNull(sm, "Statictic manager is null");\r
-           try {\r
+                       assertNotNull(runner, "Runner is NULL");\r
+                       runner.executeJob();\r
+                       // assertNotNull("JobId is null", jobId1);\r
+                       JobStatus status = runner.getJobStatus();\r
+                       assertTrue(status == JobStatus.PENDING\r
+                                       || status == JobStatus.RUNNING,\r
+                                       "Status of the process is wrong!");\r
+                       JobInfo info = runner.getJobInfo();\r
+                       assertNotNull(info, "JobInfo is null");\r
+                       StatisticManager sm = new StatisticManager(info);\r
+                       assertNotNull(sm, "Statictic manager is null");\r
+                       try {\r
 \r
-               String exits = sm.getExitStatus();\r
-               assertNotNull("Exit status is null", exits);\r
-               // cut 4 trailing zeros from the number\r
-               int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits)\r
-                       .intValue();\r
-               assertEquals(0, exitsInt);\r
-               System.out.println(sm.getAllStats());\r
+                               String exits = sm.getExitStatus();\r
+                               assertNotNull("Exit status is null", exits);\r
+                               // cut 4 trailing zeros from the number\r
+                               int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits)\r
+                                               .intValue();\r
+                               assertEquals(0, exitsInt);\r
+                               System.out.println(sm.getAllStats());\r
 \r
-           } catch (ParseException e) {\r
-               e.printStackTrace();\r
-               fail("Parse Exception: " + e.getMessage());\r
-           }\r
-           //assertFalse(runner.cleanup());\r
-           assertTrue(sm.hasExited());\r
-           assertFalse(sm.wasAborted());\r
-           assertFalse(sm.hasDump());\r
-           assertFalse(sm.hasSignaled());\r
+                       } catch (ParseException e) {\r
+                               e.printStackTrace();\r
+                               fail("Parse Exception: " + e.getMessage());\r
+                       }\r
+                       // assertFalse(runner.cleanup());\r
+                       assertTrue(sm.hasExited());\r
+                       assertFalse(sm.wasAborted());\r
+                       assertFalse(sm.hasDump());\r
+                       assertFalse(sm.hasSignaled());\r
 \r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail("DrmaaException caught:" + e.getMessage());\r
-       } catch (JobExecutionException e) {\r
-           e.printStackTrace();\r
-           fail("DrmaaException caught:" + e.getMessage());\r
-       } catch (DrmaaException e) {\r
-           e.printStackTrace();\r
-           fail("DrmaaException caught:" + e.getMessage());\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail("DrmaaException caught:" + e.getMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail("DrmaaException caught:" + e.getMessage());\r
+               } catch (DrmaaException e) {\r
+                       e.printStackTrace();\r
+                       fail("DrmaaException caught:" + e.getMessage());\r
+               }\r
        }\r
-    }\r
 \r
-    /**\r
-     * This tests fails from time to time depending on the cluster load or some\r
-     * other factors. Any client code has to adjust for this issue\r
-     */\r
-    @Test(groups = { AllTestSuit.test_group_cluster,\r
-           AllTestSuit.test_group_runner })\r
-    public void testRunOnClusterAsync() {\r
-       assertFalse(SysPrefs.isWindows,\r
-               "Cluster execution can only be in unix environment");\r
-       try {\r
-           ConfiguredExecutable<Disembl> confDisembl = Configurator\r
-                   .configureExecutable(disembl,\r
-                           Executable.ExecProvider.Cluster);\r
-           AsyncExecutor aengine = Configurator.getAsyncEngine(confDisembl);\r
-           String jobId = aengine.submitJob(confDisembl);\r
-           assertNotNull(jobId, "Runner is NULL");\r
-           // let drmaa to start\r
-           Thread.sleep(500);\r
-           JobStatus status = aengine.getJobStatus(jobId);\r
-           while (status != JobStatus.FINISHED) {\r
-               System.out.println("Job Status: " + status);\r
-               Thread.sleep(1000);\r
-               status = aengine.getJobStatus(jobId);\r
-               ConfiguredExecutable<Jronn> result = (ConfiguredExecutable<Jronn>) aengine\r
-                       .getResults(jobId);\r
-               assertNotNull(result);\r
-               System.out.println("RES:" + result);\r
-               // Some times the job could be removed from the cluster accounting \r
-               // before it has been reported to finish. Make sure \r
-               // to stop waiting in such case\r
-               if (status == JobStatus.UNDEFINED) {\r
-                   break;\r
+       /**\r
+        * This tests fails from time to time depending on the cluster load or some\r
+        * other factors. Any client code has to adjust for this issue\r
+        */\r
+       @Test(groups = {AllTestSuit.test_group_cluster,\r
+                       AllTestSuit.test_group_runner})\r
+       public void testRunOnClusterAsync() {\r
+               assertFalse(SysPrefs.isWindows,\r
+                               "Cluster execution can only be in unix environment");\r
+               try {\r
+                       ConfiguredExecutable<Disembl> confDisembl = Configurator\r
+                                       .configureExecutable(disembl,\r
+                                                       Executable.ExecProvider.Cluster);\r
+                       AsyncExecutor aengine = Configurator.getAsyncEngine(confDisembl);\r
+                       String jobId = aengine.submitJob(confDisembl);\r
+                       assertNotNull(jobId, "Runner is NULL");\r
+                       // let drmaa to start\r
+                       Thread.sleep(500);\r
+                       JobStatus status = aengine.getJobStatus(jobId);\r
+                       while (status != JobStatus.FINISHED) {\r
+                               System.out.println("Job Status: " + status);\r
+                               Thread.sleep(1000);\r
+                               status = aengine.getJobStatus(jobId);\r
+                               ConfiguredExecutable<Jronn> result = (ConfiguredExecutable<Jronn>) aengine\r
+                                               .getResults(jobId);\r
+                               assertNotNull(result);\r
+                               System.out.println("RES:" + result);\r
+                               // Some times the job could be removed from the cluster\r
+                               // accounting\r
+                               // before it has been reported to finish. Make sure\r
+                               // to stop waiting in such case\r
+                               if (status == JobStatus.UNDEFINED) {\r
+                                       break;\r
+                               }\r
+                       }\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail("DrmaaException caught:" + e.getMessage());\r
+               } catch (InterruptedException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
                }\r
-           }\r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail("DrmaaException caught:" + e.getMessage());\r
-       } catch (InterruptedException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (ResultNotAvailableException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
        }\r
-    }\r
 \r
-    @Test(groups = { AllTestSuit.test_group_runner })\r
-    public void testRunLocally() {\r
-       try {\r
-           ConfiguredExecutable<Disembl> confDisembl = Configurator\r
-                   .configureExecutable(disembl, Executable.ExecProvider.Local);\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
+       public void testRunLocally() {\r
+               try {\r
+                       ConfiguredExecutable<Disembl> confDisembl = Configurator\r
+                                       .configureExecutable(disembl, Executable.ExecProvider.Local);\r
 \r
-           // For local execution use relative\r
-           LocalRunner lr = new LocalRunner(confDisembl);\r
-           lr.executeJob();\r
-           ConfiguredExecutable<?> al1 = lr.waitForResult();\r
-           assertNotNull(al1.getResults());\r
-           List<AnnotatedSequence> al2 = confDisembl.getResults();\r
-           assertNotNull(al2);\r
-           assertEquals(al2.size(), 3);\r
-           assertEquals(al1.getResults(), al2);\r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
-       } catch (ResultNotAvailableException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
-       } catch (JobExecutionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
+                       // For local execution use relative\r
+                       LocalRunner lr = new LocalRunner(confDisembl);\r
+                       lr.executeJob();\r
+                       ConfiguredExecutable<?> al1 = lr.waitForResult();\r
+                       assertNotNull(al1.getResults());\r
+                       HashSet<Score> al2 = confDisembl.getResults();\r
+                       assertNotNull(al2);\r
+                       assertEquals(al2.size(), 3);\r
+                       assertEquals(al1.getResults(), al2);\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
        }\r
-    }\r
 \r
-    @Test(groups = { AllTestSuit.test_group_runner })\r
-    public void readStatistics() {\r
-       try {\r
-           ConfiguredExecutable<Disembl> confDisembl = Configurator\r
-                   .configureExecutable(disembl, Executable.ExecProvider.Local);\r
-           // For local execution use relavive\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
+       public void readStatistics() {\r
+               try {\r
+                       ConfiguredExecutable<Disembl> confDisembl = Configurator\r
+                                       .configureExecutable(disembl, Executable.ExecProvider.Local);\r
+                       // For local execution use relavive\r
 \r
-           AsyncExecutor sexec = Configurator.getAsyncEngine(confDisembl);\r
-           String jobId = sexec.submitJob(confDisembl);\r
-           FilePuller fw = FilePuller.newFilePuller(confDisembl\r
-                   .getWorkDirectory()\r
-                   + File.separator + Jronn.getStatFile(),\r
-                   FileWatcher.MIN_CHUNK_SIZE_BYTES);\r
-           int count = 0;\r
-           long position = 0;\r
-           fw.waitForFile(4);\r
-           JobStatus status = sexec.getJobStatus(jobId);\r
-           while (status != JobStatus.FINISHED) {\r
-               if (fw.hasMoreData()) {\r
-                   ChunkHolder ch = fw.pull(position);\r
-                   String chunk = ch.getChunk();\r
-                   position = ch.getNextPosition();\r
+                       AsyncExecutor sexec = Configurator.getAsyncEngine(confDisembl);\r
+                       String jobId = sexec.submitJob(confDisembl);\r
+                       FilePuller fw = FilePuller.newFilePuller(\r
+                                       confDisembl.getWorkDirectory() + File.separator\r
+                                                       + Jronn.getStatFile(),\r
+                                       FileWatcher.MIN_CHUNK_SIZE_BYTES);\r
+                       int count = 0;\r
+                       long position = 0;\r
+                       fw.waitForFile(4);\r
+                       JobStatus status = sexec.getJobStatus(jobId);\r
+                       while (status != JobStatus.FINISHED) {\r
+                               if (fw.hasMoreData()) {\r
+                                       ChunkHolder ch = fw.pull(position);\r
+                                       String chunk = ch.getChunk();\r
+                                       position = ch.getNextPosition();\r
+                               }\r
+                               count++;\r
+                               // Make sure the loop is terminated if the job fails\r
+                               if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) {\r
+                                       break;\r
+                               }\r
+                               Thread.sleep(300);\r
+                               status = sexec.getJobStatus(jobId);\r
+                       }\r
+                       assertTrue(count > 1);\r
+                       ConfiguredExecutable<?> al = sexec.getResults(jobId);\r
+                       assertNotNull(al.getResults());\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (InterruptedException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
                }\r
-               count++;\r
-               // Make sure the loop is terminated if the job fails\r
-               if ((status == JobStatus.UNDEFINED || status == JobStatus.FAILED)) {\r
-                   break;\r
-               }\r
-               Thread.sleep(300);\r
-               status = sexec.getJobStatus(jobId);\r
-           }\r
-           assertTrue(count > 1);\r
-           ConfiguredExecutable<?> al = sexec.getResults(jobId);\r
-           assertNotNull(al.getResults());\r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (ResultNotAvailableException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (IOException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (InterruptedException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
        }\r
-    }\r
 \r
-    @Test(groups = { AllTestSuit.test_group_runner })\r
-    public void testPersistance() {\r
-       try {\r
-           Disembl disembl = new Disembl();\r
-           disembl.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
-                   .setOutput("outtt.txt");\r
-           assertEquals(disembl.getInput(), AllTestSuit.test_input);\r
-           assertEquals(disembl.getError(), "errrr.txt");\r
-           assertEquals(disembl.getOutput(), "outtt.txt");\r
-           ConfiguredExecutable<Disembl> cDisembl = Configurator\r
-                   .configureExecutable(disembl, Executable.ExecProvider.Local);\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
+       public void testPersistance() {\r
+               try {\r
+                       Disembl disembl = new Disembl();\r
+                       disembl.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
+                                       .setOutput("outtt.txt");\r
+                       assertEquals(disembl.getInput(), AllTestSuit.test_input);\r
+                       assertEquals(disembl.getError(), "errrr.txt");\r
+                       assertEquals(disembl.getOutput(), "outtt.txt");\r
+                       ConfiguredExecutable<Disembl> cDisembl = Configurator\r
+                                       .configureExecutable(disembl, Executable.ExecProvider.Local);\r
 \r
-           SyncExecutor sexec = Configurator.getSyncEngine(cDisembl);\r
-           sexec.executeJob();\r
-           ConfiguredExecutable<?> al = sexec.waitForResult();\r
-           assertNotNull(al.getResults());\r
-           // Save run configuration\r
-           assertTrue(cDisembl.saveRunConfiguration());\r
+                       SyncExecutor sexec = Configurator.getSyncEngine(cDisembl);\r
+                       sexec.executeJob();\r
+                       ConfiguredExecutable<?> al = sexec.waitForResult();\r
+                       assertNotNull(al.getResults());\r
+                       // Save run configuration\r
+                       assertTrue(cDisembl.saveRunConfiguration());\r
 \r
-           // See if loaded configuration is the same as saved\r
-           RunConfiguration loadedRun = RunConfiguration\r
-                   .load(new FileInputStream(new File(cDisembl\r
-                           .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
-           assertEquals(((ConfExecutable<Disembl>) cDisembl)\r
-                   .getRunConfiguration(), loadedRun);\r
-           // Load run configuration as ConfExecutable\r
-           ConfiguredExecutable<Disembl> resurrectedCDisembl = (ConfiguredExecutable<Disembl>) cDisembl\r
-                   .loadRunConfiguration(new FileInputStream(new File(cDisembl\r
-                           .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
-           assertNotNull(resurrectedCDisembl);\r
-           assertEquals(resurrectedCDisembl.getExecutable().getInput(),\r
-                   AllTestSuit.test_input);\r
-           assertEquals(resurrectedCDisembl.getExecutable().getError(),\r
-                   "errrr.txt");\r
-           assertEquals(resurrectedCDisembl.getExecutable().getOutput(),\r
-                   "outtt.txt");\r
-           // See in details whether executables are the same\r
-           assertEquals(resurrectedCDisembl.getExecutable(), disembl);\r
+                       // See if loaded configuration is the same as saved\r
+                       RunConfiguration loadedRun = RunConfiguration\r
+                                       .load(new FileInputStream(new File(cDisembl\r
+                                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
+                       assertEquals(\r
+                                       ((ConfExecutable<Disembl>) cDisembl).getRunConfiguration(),\r
+                                       loadedRun);\r
+                       // Load run configuration as ConfExecutable\r
+                       ConfiguredExecutable<Disembl> resurrectedCDisembl = (ConfiguredExecutable<Disembl>) cDisembl\r
+                                       .loadRunConfiguration(new FileInputStream(new File(cDisembl\r
+                                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
+                       assertNotNull(resurrectedCDisembl);\r
+                       assertEquals(resurrectedCDisembl.getExecutable().getInput(),\r
+                                       AllTestSuit.test_input);\r
+                       assertEquals(resurrectedCDisembl.getExecutable().getError(),\r
+                                       "errrr.txt");\r
+                       assertEquals(resurrectedCDisembl.getExecutable().getOutput(),\r
+                                       "outtt.txt");\r
+                       // See in details whether executables are the same\r
+                       assertEquals(resurrectedCDisembl.getExecutable(), disembl);\r
 \r
-           ConfiguredExecutable<Disembl> resJronn = Configurator\r
-                   .configureExecutable(resurrectedCDisembl.getExecutable(),\r
-                           Executable.ExecProvider.Local);\r
+                       ConfiguredExecutable<Disembl> resJronn = Configurator\r
+                                       .configureExecutable(resurrectedCDisembl.getExecutable(),\r
+                                                       Executable.ExecProvider.Local);\r
 \r
-           sexec = Configurator.getSyncEngine(resJronn,\r
-                   Executable.ExecProvider.Local);\r
-           sexec.executeJob();\r
-           al = sexec.waitForResult();\r
-           assertNotNull(al);\r
+                       sexec = Configurator.getSyncEngine(resJronn,\r
+                                       Executable.ExecProvider.Local);\r
+                       sexec.executeJob();\r
+                       al = sexec.waitForResult();\r
+                       assertNotNull(al);\r
 \r
-       } catch (JobSubmissionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (JobExecutionException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (FileNotFoundException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (IOException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
-       } catch (ResultNotAvailableException e) {\r
-           e.printStackTrace();\r
-           fail(e.getMessage());\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               }\r
        }\r
-    }\r
 \r
-    @Test(groups = { AllTestSuit.test_group_runner })\r
-    public void testConfigurationLoading() {\r
-       try {\r
-           RunnerConfig<Disembl> disemblConfig = ConfExecutable\r
-                   .getRunnerOptions(Disembl.class);\r
-           assertNotNull(disemblConfig);\r
-           assertTrue(disemblConfig.getArguments().size() > 0);\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
+       public void testConfigurationLoading() {\r
+               try {\r
+                       RunnerConfig<Disembl> disemblConfig = ConfExecutable\r
+                                       .getRunnerOptions(Disembl.class);\r
+                       assertNotNull(disemblConfig);\r
+                       assertTrue(disemblConfig.getArguments().size() > 0);\r
 \r
-           PresetManager<Disembl> disemblPresets = ConfExecutable\r
-                   .getRunnerPresets(Disembl.class);\r
-           assertNull(disemblPresets); // there is no presets\r
+                       PresetManager<Disembl> disemblPresets = ConfExecutable\r
+                                       .getRunnerPresets(Disembl.class);\r
+                       assertNull(disemblPresets); // there is no presets\r
 \r
-           LimitsManager<Disembl> disemblLimits = ConfExecutable\r
-                   .getRunnerLimits(Disembl.class);\r
-           assertNotNull(disemblLimits);\r
-           assertTrue(disemblLimits.getLimits().size() > 0);\r
-           disemblLimits.validate(disemblPresets);\r
+                       LimitsManager<Disembl> disemblLimits = ConfExecutable\r
+                                       .getRunnerLimits(Disembl.class);\r
+                       assertNotNull(disemblLimits);\r
+                       assertTrue(disemblLimits.getLimits().size() > 0);\r
+                       disemblLimits.validate(disemblPresets);\r
 \r
-       } catch (FileNotFoundException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
-       } catch (IOException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
-       } catch (ValidationException e) {\r
-           e.printStackTrace();\r
-           fail(e.getLocalizedMessage());\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (ValidationException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
        }\r
-    }\r
 \r
 }\r
index 9385eb6..d784387 100644 (file)
@@ -30,7 +30,7 @@ import java.io.FileInputStream;
 import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
 import java.text.ParseException;\r
-import java.util.List;\r
+import java.util.Map;\r
 \r
 import javax.xml.bind.ValidationException;\r
 \r
@@ -39,7 +39,7 @@ import org.ggf.drmaa.JobInfo;
 import org.testng.annotations.BeforeMethod;\r
 import org.testng.annotations.Test;\r
 \r
-import compbio.data.sequence.AnnotatedSequence;\r
+import compbio.data.sequence.Score;\r
 import compbio.engine.AsyncExecutor;\r
 import compbio.engine.Configurator;\r
 import compbio.engine.FilePuller;\r
@@ -76,14 +76,14 @@ public class JronnTester {
                jronn.setInput(AllTestSuit.test_input).setOutput(test_outfile);\r
        }\r
 \r
-       @Test(groups = { AllTestSuit.test_group_cluster,\r
-                       AllTestSuit.test_group_runner })\r
-                       public void testRunOnCluster() {\r
+       @Test(groups = {AllTestSuit.test_group_cluster,\r
+                       AllTestSuit.test_group_runner})\r
+       public void testRunOnCluster() {\r
                assertFalse(SysPrefs.isWindows,\r
                                "Cluster execution can only be in unix environment");\r
                try {\r
                        ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                       .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
+                                       .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
                        JobRunner runner = JobRunner.getInstance(confJronn);\r
 \r
                        assertNotNull(runner, "Runner is NULL");\r
@@ -103,7 +103,7 @@ public class JronnTester {
                                assertNotNull("Exit status is null", exits);\r
                                // cut 4 trailing zeros from the number\r
                                int exitsInt = ClusterUtil.CLUSTER_STAT_IN_SEC.parse(exits)\r
-                               .intValue();\r
+                                               .intValue();\r
                                assertEquals(0, exitsInt);\r
                                System.out.println(sm.getAllStats());\r
 \r
@@ -111,7 +111,7 @@ public class JronnTester {
                                e.printStackTrace();\r
                                fail("Parse Exception: " + e.getMessage());\r
                        }\r
-                       //assertFalse(runner.cleanup());\r
+                       // assertFalse(runner.cleanup());\r
                        assertTrue(sm.hasExited());\r
                        assertFalse(sm.wasAborted());\r
                        assertFalse(sm.hasDump());\r
@@ -133,14 +133,14 @@ public class JronnTester {
         * This tests fails from time to time depending on the cluster load or some\r
         * other factors. Any client code has to adjust for this issue\r
         */\r
-       @Test(groups = { AllTestSuit.test_group_cluster,\r
-                       AllTestSuit.test_group_runner })\r
-                       public void testRunOnClusterAsync() {\r
+       @Test(groups = {AllTestSuit.test_group_cluster,\r
+                       AllTestSuit.test_group_runner})\r
+       public void testRunOnClusterAsync() {\r
                assertFalse(SysPrefs.isWindows,\r
-               "Cluster execution can only be in unix environment");\r
+                               "Cluster execution can only be in unix environment");\r
                try {\r
                        ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                       .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
+                                       .configureExecutable(jronn, Executable.ExecProvider.Cluster);\r
                        AsyncExecutor aengine = Configurator.getAsyncEngine(confJronn);\r
                        String jobId = aengine.submitJob(confJronn);\r
                        assertNotNull(jobId, "Runner is NULL");\r
@@ -152,11 +152,12 @@ public class JronnTester {
                                Thread.sleep(1000);\r
                                status = aengine.getJobStatus(jobId);\r
                                ConfiguredExecutable<Jronn> result = (ConfiguredExecutable<Jronn>) aengine\r
-                               .getResults(jobId);\r
+                                               .getResults(jobId);\r
                                assertNotNull(result);\r
                                System.out.println("RES:" + result);\r
-                               // Some times the job could be removed from the cluster accounting \r
-                               // before it has been reported to finish. Make sure \r
+                               // Some times the job could be removed from the cluster\r
+                               // accounting\r
+                               // before it has been reported to finish. Make sure\r
                                // to stop waiting in such case\r
                                if (status == JobStatus.UNDEFINED) {\r
                                        break;\r
@@ -174,18 +175,18 @@ public class JronnTester {
                }\r
        }\r
 \r
-       @Test(groups = { AllTestSuit.test_group_runner })\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
        public void testRunLocally() {\r
                try {\r
                        ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+                                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
 \r
                        // For local execution use relative\r
                        LocalRunner lr = new LocalRunner(confJronn);\r
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       List<AnnotatedSequence> al2 = confJronn.getResults();\r
+                       Map<String, Score> al2 = confJronn.getResults();\r
                        assertNotNull(al2);\r
                        assertEquals(al2.size(), 3);\r
                        assertEquals(al1.getResults(), al2);\r
@@ -201,19 +202,19 @@ public class JronnTester {
                }\r
        }\r
 \r
-       @Test(groups = { AllTestSuit.test_group_runner })\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
        public void testRunLocallyOnTwoCpu() {\r
                try {\r
                        jronn.setNCore(2);\r
                        ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
-                       \r
+                                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+\r
                        // For local execution use relative\r
                        LocalRunner lr = new LocalRunner(confJronn);\r
                        lr.executeJob();\r
                        ConfiguredExecutable<?> al1 = lr.waitForResult();\r
                        assertNotNull(al1.getResults());\r
-                       List<AnnotatedSequence> al2 = confJronn.getResults();\r
+                       Map<String, Score> al2 = confJronn.getResults();\r
                        assertNotNull(al2);\r
                        assertEquals(al2.size(), 3);\r
                        assertEquals(al1.getResults(), al2);\r
@@ -229,19 +230,18 @@ public class JronnTester {
                }\r
        }\r
 \r
-       \r
-       @Test(groups = { AllTestSuit.test_group_runner })\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
        public void readStatistics() {\r
                try {\r
                        ConfiguredExecutable<Jronn> confJronn = Configurator\r
-                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+                                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
                        // For local execution use relavive\r
 \r
                        AsyncExecutor sexec = Configurator.getAsyncEngine(confJronn);\r
                        String jobId = sexec.submitJob(confJronn);\r
-                       FilePuller fw = FilePuller.newFilePuller(confJronn\r
-                                       .getWorkDirectory()\r
-                                       + File.separator + Jronn.getStatFile(),\r
+                       FilePuller fw = FilePuller.newFilePuller(\r
+                                       confJronn.getWorkDirectory() + File.separator\r
+                                                       + Jronn.getStatFile(),\r
                                        FileWatcher.MIN_CHUNK_SIZE_BYTES);\r
                        int count = 0;\r
                        long position = 0;\r
@@ -279,17 +279,17 @@ public class JronnTester {
                }\r
        }\r
 \r
-       @Test(groups = { AllTestSuit.test_group_runner })\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
        public void testPersistance() {\r
                try {\r
                        Jronn jronn = new Jronn();\r
                        jronn.setError("errrr.txt").setInput(AllTestSuit.test_input)\r
-                       .setOutput("outtt.txt");\r
+                                       .setOutput("outtt.txt");\r
                        assertEquals(jronn.getInput(), AllTestSuit.test_input);\r
                        assertEquals(jronn.getError(), "errrr.txt");\r
                        assertEquals(jronn.getOutput(), "outtt.txt");\r
                        ConfiguredExecutable<Jronn> cJronn = Configurator\r
-                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
+                                       .configureExecutable(jronn, Executable.ExecProvider.Local);\r
 \r
                        SyncExecutor sexec = Configurator.getSyncEngine(cJronn);\r
                        sexec.executeJob();\r
@@ -300,28 +300,28 @@ public class JronnTester {
 \r
                        // See if loaded configuration is the same as saved\r
                        RunConfiguration loadedRun = RunConfiguration\r
-                       .load(new FileInputStream(new File(cJronn\r
-                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
+                                       .load(new FileInputStream(new File(cJronn\r
+                                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
                        assertEquals(\r
                                        ((ConfExecutable<Jronn>) cJronn).getRunConfiguration(),\r
                                        loadedRun);\r
                        // Load run configuration as ConfExecutable\r
                        ConfiguredExecutable<Jronn> resurrectedCMuscle = (ConfiguredExecutable<Jronn>) cJronn\r
-                       .loadRunConfiguration(new FileInputStream(new File(cJronn\r
-                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
+                                       .loadRunConfiguration(new FileInputStream(new File(cJronn\r
+                                                       .getWorkDirectory(), RunConfiguration.rconfigFile)));\r
                        assertNotNull(resurrectedCMuscle);\r
                        assertEquals(resurrectedCMuscle.getExecutable().getInput(),\r
                                        AllTestSuit.test_input);\r
                        assertEquals(resurrectedCMuscle.getExecutable().getError(),\r
                                        "errrr.txt");\r
                        assertEquals(resurrectedCMuscle.getExecutable().getOutput(),\r
-                       "outtt.txt");\r
+                                       "outtt.txt");\r
                        // See in details whether executables are the same\r
                        assertEquals(resurrectedCMuscle.getExecutable(), jronn);\r
 \r
                        ConfiguredExecutable<Jronn> resJronn = Configurator\r
-                       .configureExecutable(resurrectedCMuscle.getExecutable(),\r
-                                       Executable.ExecProvider.Local);\r
+                                       .configureExecutable(resurrectedCMuscle.getExecutable(),\r
+                                                       Executable.ExecProvider.Local);\r
 \r
                        sexec = Configurator.getSyncEngine(resJronn,\r
                                        Executable.ExecProvider.Local);\r
@@ -347,20 +347,20 @@ public class JronnTester {
                }\r
        }\r
 \r
-       @Test(groups = { AllTestSuit.test_group_runner })\r
+       @Test(groups = {AllTestSuit.test_group_runner})\r
        public void testConfigurationLoading() {\r
                try {\r
                        RunnerConfig<Jronn> jronnConfig = ConfExecutable\r
-                       .getRunnerOptions(Jronn.class);\r
+                                       .getRunnerOptions(Jronn.class);\r
                        assertNotNull(jronnConfig);\r
                        assertTrue(jronnConfig.getArguments().size() > 0);\r
 \r
                        PresetManager<Jronn> jronnPresets = ConfExecutable\r
-                       .getRunnerPresets(Jronn.class);\r
+                                       .getRunnerPresets(Jronn.class);\r
                        assertNull(jronnPresets); // there is no presets\r
 \r
                        LimitsManager<Jronn> jronnLimits = ConfExecutable\r
-                       .getRunnerLimits(Jronn.class);\r
+                                       .getRunnerLimits(Jronn.class);\r
                        assertNotNull(jronnLimits);\r
                        assertTrue(jronnLimits.getLimits().size() > 0);\r
                        jronnLimits.validate(jronnPresets);\r
index af9a52c..79357e5 100644 (file)
@@ -11,9 +11,11 @@ import java.io.IOException;
 import java.io.OutputStream;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
+import java.util.Set;\r
 \r
 import compbio.data.sequence.Alignment;\r
 import compbio.data.sequence.ClustalAlignmentUtil;\r
+import compbio.data.sequence.Score;\r
 \r
 public class IOHelper {\r
 \r
@@ -109,4 +111,29 @@ public class IOHelper {
                }\r
        }\r
 \r
+       /**\r
+        * Outputs AAcon results into the file represented by the outStream\r
+        * \r
+        * @param outStream\r
+        * @param result\r
+        *            the AACon scores to output\r
+        */\r
+       static void writeOut(OutputStream outStream, Set<Score> result) {\r
+               try {\r
+                       Score.write(result, outStream);\r
+               } catch (IOException e) {\r
+                       System.err\r
+                                       .println("Problems writing output file! Stack trace is below: ");\r
+                       e.printStackTrace();\r
+               } finally {\r
+                       if (outStream != null) {\r
+                               try {\r
+                                       outStream.close();\r
+                               } catch (IOException ignored) {\r
+                                       // e.printStackTrace();\r
+                               }\r
+                       }\r
+               }\r
+       }\r
+\r
 }\r
index 9da8abe..1673e18 100644 (file)
@@ -38,18 +38,22 @@ import java.net.MalformedURLException;
 import java.net.URL;\r
 import java.util.Arrays;\r
 import java.util.List;\r
+import java.util.Set;\r
 import java.util.logging.Level;\r
 import java.util.logging.Logger;\r
 \r
 import javax.xml.ws.Service;\r
 import javax.xml.ws.WebServiceException;\r
 \r
+import compbio.data.msa.Annotation;\r
 import compbio.data.msa.JABAService;\r
 import compbio.data.msa.Metadata;\r
 import compbio.data.msa.MsaWS;\r
 import compbio.data.sequence.Alignment;\r
 import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.Score;\r
 import compbio.data.sequence.SequenceUtil;\r
+import compbio.data.sequence.UnknownFileFormatException;\r
 import compbio.metadata.JobSubmissionException;\r
 import compbio.metadata.Option;\r
 import compbio.metadata.Preset;\r
@@ -147,23 +151,25 @@ public class Jws2Client {
                }\r
                Alignment alignment = null;\r
                if (inputFile != null) {\r
+                       OutputStream outStream = null;\r
+                       if (outFile != null) {\r
+                               outStream = IOHelper.getOutStream(outFile);\r
+                       } else {\r
+                               // this stream is going to be closed later which is fine as\r
+                               // std.out will not be\r
+                               outStream = System.out;\r
+                       }\r
                        if (service == Services.AAConWS) {\r
-                               System.out.println("calc conserv!");\r
+                               Set<Score> result = analize(inputFile, ((Annotation<T>) msaws),\r
+                                               preset, customOptions);\r
+                               IOHelper.writeOut(outStream, result);\r
                        } else {\r
-\r
                                alignment = align(inputFile, (MsaWS<T>) msaws, preset,\r
                                                customOptions);\r
-                               OutputStream outStream = null;\r
-                               if (outFile != null) {\r
-                                       outStream = IOHelper.getOutStream(outFile);\r
-                               } else {\r
-                                       // this stream is going to be closed later which is fine as\r
-                                       // std.out will not be\r
-                                       outStream = System.out;\r
-                               }\r
                                IOHelper.writeOut(outStream, alignment);\r
-                               // stream is closed in the method no need to close it here\r
                        }\r
+\r
+                       // stream is closed in the method no need to close it here\r
                }\r
 \r
                boolean listParameters = CmdHelper.listParameters(cmd);\r
@@ -182,6 +188,75 @@ public class Jws2Client {
                ((Closeable) msaws).close();\r
                log.fine("Disconnected successfully!");\r
        }\r
+       /**\r
+        * Calculate conservation for sequences loaded from the file\r
+        * \r
+        * @param wsproxy\r
+        *            a web service proxy\r
+        * @param file\r
+        *            the file to read the results from\r
+        * @param preset\r
+        *            Preset to use optional\r
+        * @param customOptions\r
+        *            the list of options\r
+        * @return Set<Score> the conservation scores\r
+        * @throws UnknownFileFormatException\r
+        */\r
+       <T> Set<Score> analize(File file, Annotation<T> wsproxy, Preset<T> preset,\r
+                       List<Option<T>> customOptions) {\r
+\r
+               List<FastaSequence> fastalist = null;\r
+               Set<Score> scores = null;\r
+               try {\r
+                       fastalist = SequenceUtil.openInputStream(file.getAbsolutePath());\r
+\r
+                       String jobId = null;\r
+                       if (customOptions != null && preset != null) {\r
+                               System.out\r
+                                               .println("WARN: Parameters (-f) are defined together with a preset (-r) ignoring preset!");\r
+                       }\r
+                       if (customOptions != null) {\r
+                               jobId = wsproxy.customAnalize(fastalist, customOptions);\r
+                       } else if (preset != null) {\r
+                               jobId = wsproxy.presetAnalize(fastalist, preset);\r
+                       } else {\r
+                               jobId = wsproxy.analize(fastalist);\r
+                       }\r
+                       Thread.sleep(1000);\r
+                       scores = wsproxy.getAnnotation(jobId);\r
+\r
+               } catch (IOException e) {\r
+                       System.err\r
+                                       .println("Exception while reading the input file. "\r
+                                                       + "Check that the input file contains a list of fasta formatted sequences! "\r
+                                                       + "Exception details are below:");\r
+                       e.printStackTrace();\r
+               } catch (JobSubmissionException e) {\r
+                       System.err\r
+                                       .println("Exception while submitting job to a web server. "\r
+                                                       + "Exception details are below:");\r
+                       e.printStackTrace();\r
+               } catch (ResultNotAvailableException e) {\r
+                       System.err.println("Exception while waiting for results. "\r
+                                       + "Exception details are below:");\r
+                       e.printStackTrace();\r
+               } catch (InterruptedException ignored) {\r
+                       // ignore and propagate an interruption\r
+                       Thread.currentThread().interrupt();\r
+               } catch (WrongParameterException e) {\r
+                       System.err\r
+                                       .println("Exception while parsing the web method input parameters. "\r
+                                                       + "Exception details are below:");\r
+                       e.printStackTrace();\r
+               } catch (UnknownFileFormatException e) {\r
+                       System.err\r
+                                       .println("Exception while attempting to read the input file "\r
+                                                       + "Exception details are below:");\r
+                       System.out.println(e.getMessage());\r
+                       e.printStackTrace();\r
+               }\r
+               return scores;\r
+       }\r
 \r
        /**\r
         * Connects to a web service by the host and the service name\r
diff --git a/webservices/compbio/ws/server/JronnWS.java b/webservices/compbio/ws/server/JronnWS.java
new file mode 100644 (file)
index 0000000..bcb6af5
--- /dev/null
@@ -0,0 +1,177 @@
+package compbio.ws.server;\r
+\r
+import java.io.File;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+\r
+import javax.annotation.Resource;\r
+import javax.jws.WebService;\r
+import javax.xml.ws.WebServiceContext;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.data.msa.Annotation;\r
+import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.Score;\r
+import compbio.engine.AsyncExecutor;\r
+import compbio.engine.Configurator;\r
+import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.metadata.ChunkHolder;\r
+import compbio.metadata.JobStatus;\r
+import compbio.metadata.JobSubmissionException;\r
+import compbio.metadata.Limit;\r
+import compbio.metadata.LimitExceededException;\r
+import compbio.metadata.LimitsManager;\r
+import compbio.metadata.Option;\r
+import compbio.metadata.Preset;\r
+import compbio.metadata.PresetManager;\r
+import compbio.metadata.ResultNotAvailableException;\r
+import compbio.metadata.RunnerConfig;\r
+import compbio.metadata.UnsupportedRuntimeException;\r
+import compbio.metadata.WrongParameterException;\r
+import compbio.runner.Util;\r
+import compbio.runner.conservation.AACon;\r
+import compbio.runner.disorder.Jronn;\r
+\r
+@WebService(endpointInterface = "compbio.data.msa.Annotation", targetNamespace = "http://msa.data.compbio/01/12/2010/", serviceName = "JronnWS")\r
+public class JronnWS implements Annotation<Jronn> {\r
+\r
+       // Ask for resource injection\r
+       @Resource\r
+       WebServiceContext wsContext;\r
+\r
+       private static Logger statLog = Logger.getLogger("JronnWS-stats");\r
+\r
+       private static Logger log = Logger.getLogger(JronnWS.class);\r
+\r
+       private static final RunnerConfig<Jronn> aaconOptions = Util\r
+                       .getSupportedOptions(Jronn.class);\r
+\r
+       private static final PresetManager<Jronn> aaconPresets = Util\r
+                       .getPresets(Jronn.class);\r
+\r
+       ConfiguredExecutable<Jronn> init(List<FastaSequence> sequences)\r
+                       throws JobSubmissionException {\r
+               Jronn jronn = new Jronn();\r
+               jronn.setInput("fasta.in").setOutput("aacon.out");\r
+               return Configurator.configureExecutable(jronn, sequences);\r
+       }\r
+\r
+       @Override\r
+       public HashSet<Score> getAnnotation(String jobId)\r
+                       throws ResultNotAvailableException {\r
+               WSUtil.validateJobId(jobId);\r
+               AsyncExecutor asyncEngine = Configurator.getAsyncEngine(jobId);\r
+               ConfiguredExecutable<AACon> aacon = (ConfiguredExecutable<AACon>) asyncEngine\r
+                               .getResults(jobId);\r
+               HashSet<Score> mas = aacon.getResults();\r
+               log.trace(jobId + " getConservation : " + mas);\r
+               return mas;\r
+       }\r
+       /*\r
+        * @SuppressWarnings("unchecked") public JalviewAnnotation\r
+        * getJalviewAnnotation(String jobId) throws ResultNotAvailableException {\r
+        * MultiAnnotatedSequence<Method> result = getResult(jobId); // TODO //\r
+        * log(jobId, "getResults"); return result.toJalviewAnnotation(); }\r
+        */\r
+\r
+       @Override\r
+       public Limit<Jronn> getLimit(String presetName) {\r
+               return new Jronn().getLimit(presetName);\r
+       }\r
+\r
+       @Override\r
+       public LimitsManager<Jronn> getLimits() {\r
+               return new Jronn().getLimits();\r
+       }\r
+\r
+       @Override\r
+       public ChunkHolder pullExecStatistics(String jobId, long position) {\r
+               WSUtil.validateJobId(jobId);\r
+               String file = Configurator.getWorkDirectory(jobId) + File.separator\r
+                               + Jronn.getStatFile();\r
+               return WSUtil.pullFile(file, position);\r
+       }\r
+\r
+       @Override\r
+       public boolean cancelJob(String jobId) {\r
+               WSUtil.validateJobId(jobId);\r
+               return WSUtil.cancelJob(jobId);\r
+       }\r
+\r
+       @Override\r
+       public JobStatus getJobStatus(String jobId) {\r
+               WSUtil.validateJobId(jobId);\r
+               return WSUtil.getJobStatus(jobId);\r
+       }\r
+\r
+       @Override\r
+       public PresetManager<Jronn> getPresets() {\r
+               return aaconPresets;\r
+       }\r
+\r
+       @Override\r
+       public RunnerConfig<Jronn> getRunnerOptions() {\r
+               return aaconOptions;\r
+       }\r
+\r
+       String analize(List<FastaSequence> sequences,\r
+                       ConfiguredExecutable<Jronn> confExec, Logger log, String method,\r
+                       Limit<Jronn> limit) throws JobSubmissionException {\r
+               if (limit != null && limit.isExceeded(sequences)) {\r
+                       throw LimitExceededException.newLimitExceeded(limit, sequences);\r
+               }\r
+\r
+               compbio.runner.Util.writeInput(sequences, confExec);\r
+               AsyncExecutor engine = Configurator.getAsyncEngine(confExec);\r
+               String jobId = engine.submitJob(confExec);\r
+               return jobId;\r
+       }\r
+\r
+       @Override\r
+       public String analize(List<FastaSequence> sequences)\r
+                       throws UnsupportedRuntimeException, LimitExceededException,\r
+                       JobSubmissionException {\r
+               WSUtil.validateFastaInput(sequences);\r
+               ConfiguredExecutable<Jronn> confAAcon = init(sequences);\r
+\r
+               // set default conservation method to fastest - SHENKIN\r
+               // TODO: This violates encapsulation, should be moved to the runners\r
+               // level.\r
+               // confAAcon.addParameters(Arrays.asList("-m=SHENKIN"));\r
+               return analize(sequences, confAAcon, null, "analize", getLimit(""));\r
+       }\r
+\r
+       @Override\r
+       public String customAnalize(List<FastaSequence> sequences,\r
+                       List<Option<Jronn>> options) throws UnsupportedRuntimeException,\r
+                       LimitExceededException, JobSubmissionException,\r
+                       WrongParameterException {\r
+               WSUtil.validateFastaInput(sequences);\r
+               ConfiguredExecutable<Jronn> confJronn = init(sequences);\r
+               // Could not do that! Space separated values\r
+               // will all be treated as keys! thus duplicates removed\r
+               // String params = cbuilder.getCommand();\r
+               List<String> params = WSUtil.getCommands(options,\r
+                               AACon.KEY_VALUE_SEPARATOR);\r
+               confJronn.addParameters(params);\r
+               return analize(sequences, confJronn, null, "customAnalize",\r
+                               getLimit(""));\r
+       }\r
+\r
+       @Override\r
+       public String presetAnalize(List<FastaSequence> sequences,\r
+                       Preset<Jronn> preset) throws UnsupportedRuntimeException,\r
+                       LimitExceededException, JobSubmissionException,\r
+                       WrongParameterException {\r
+               WSUtil.validateFastaInput(sequences);\r
+               if (preset == null) {\r
+                       throw new WrongParameterException("Preset must be provided!");\r
+               }\r
+               ConfiguredExecutable<Jronn> confJronn = init(sequences);\r
+               confJronn.addParameters(preset.getOptions());\r
+               Limit<Jronn> limit = getLimit(preset.getName());\r
+               return WSUtil.align(sequences, confJronn, null, "presetAnalize", limit);\r
+       }\r
+\r
+}\r