RNAStruct replaced by RNAStructScoreManager. Why does webservice
authorDaniel Barton <daluke.barton@gmail.com>
Wed, 21 Aug 2013 10:49:43 +0000 (11:49 +0100)
committerDaniel Barton <daluke.barton@gmail.com>
Wed, 21 Aug 2013 10:49:43 +0000 (11:49 +0100)
getAnnotation method still return a ScoreManager Not an
RNAStructScoreManager?!?

datamodel/compbio/data/sequence/RNAStruct.java [deleted file]
datamodel/compbio/data/sequence/RNAStructReader.java
datamodel/compbio/data/sequence/RNAStructScoreManager.java [new file with mode: 0644]
runner/compbio/runner/structure/RNAalifold.java
testsrc/compbio/runner/structure/RNAalifoldParametersTester.java
testsrc/compbio/runner/structure/RNAalifoldTester.java
testsrc/compbio/ws/client/TestRNAalifoldWS.java
webservices/compbio/ws/server/RNAalifoldWS.java

diff --git a/datamodel/compbio/data/sequence/RNAStruct.java b/datamodel/compbio/data/sequence/RNAStruct.java
deleted file mode 100644 (file)
index 65bca75..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-package compbio.data.sequence;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.List;
-import java.util.ArrayList;
-
-import javax.xml.bind.annotation.XmlAccessType;
-import javax.xml.bind.annotation.XmlAccessorType;
-
-import compbio.util.annotation.Immutable;
-import compbio.util.SysPrefs;
-import compbio.data.sequence.Score;
-
-/*
- * RNA secondary structure
- * A class which is essentially just a Pair(List<String>, List<Set<Score>>)
- * For the purpose of creating and retrieving data from ScoreManager Objects
- * which are being used to store RNA folding output
- */
-
-@XmlAccessorType(XmlAccessType.FIELD)
-public final class RNAStruct {
-       
-       private List<String> structs = new ArrayList<String>();
-       private List<TreeSet<Score>> data = new ArrayList<TreeSet<Score>>();
-       
-       
-       public RNAStruct() {
-               // default JaxB Constructor
-       }
-       
-       public RNAStruct(List<String> structs, List<TreeSet<Score>> data) {
-               assert(structs.size() == data.size());
-               this.structs = structs;
-               this.data = data;
-       }
-       
-       public List<String> getStructs() {
-               return structs;
-       }
-       
-       public List<TreeSet<Score>> getData() {
-               return data;
-       }
-       
-       // Send this data Structure back to something approximating the stdoutFile
-       // with extra information from alifold.out
-       @Override
-       public String toString() {
-               String out = "";
-               // The first objects hold the Consensus Alignment and the alifold.out info
-               out += structs.get(0) + SysPrefs.newlinechar;
-               
-               // Now the rest of the structures with energies/frequencies
-               for (int i = 1; i < structs.size(); i++) {
-                       out = out + structs.get(i).toString();
-                       
-                       if (data.get(i).first().getScores().size() > 0) {
-                               List<Float> scores = data.get(i).first().getScores();
-                               if (scores.size() >= 3) {
-                                       out = out + " (" + scores.get(0).toString() + " = " 
-                                                       + scores.get(1).toString() + " + " + scores.get(2).toString()
-                                                       + ")" + SysPrefs.newlinechar;
-                               }
-                               else if (data.get(i).first().getMethod().equals("alifoldMEA")) {
-                                       out = out + " { " + scores.get(0).toString() + " MEA=" 
-                                                       + scores.get(1).toString() + "}" + SysPrefs.newlinechar;
-                               }
-                               else if (scores.size() >= 2) {
-                                       out = out + " [" + scores.get(0).toString() + ", " 
-                                                       + scores.get(1).toString() + "]" + SysPrefs.newlinechar;
-                                       
-                               }
-                       } else out += SysPrefs.newlinechar; 
-               }
-               if (data.get(0).first().getScores().size() > 0) {
-                       Iterator<Score> iScores = data.get(0).iterator();
-                       out += "Base Pairings followed by probability" + SysPrefs.newlinechar;
-                       for (int i = 0; i < data.get(0).size(); i++) {
-                               Score s = iScores.next();
-                               Range r = s.getRanges().first();
-                               Float score = s.getScores().get(0);
-                               out += String.format("%4d  %4d    %.1f%n", r.getFrom(), r.getTo(),
-                                               score);
-                       }
-               }
-               
-               return out;
-       }
-       
-       @Override 
-       public boolean equals(Object obj) {
-               if (obj == null) {
-                       return false;
-               }
-               if (!(obj instanceof RNAStruct)) {
-                       return false;
-               }
-               RNAStruct other = (RNAStruct) obj;
-               if (structs == null) {
-                       if (other.structs != null) {
-                               return false;
-                       }
-               } else if (!structs.equals(other.structs))
-                       return false;
-               if (data == null) {
-                       if (other.data != null)
-                               return false;
-               } else if (!data.equals(other.data))
-                       return false;
-
-               return true;
-       }
-}
-
-
index cfc83ff..7ebba4c 100644 (file)
-package compbio.data.sequence;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Scanner;
-import java.util.TreeSet;
-import java.util.regex.Pattern;
-
-import org.apache.log4j.Logger;
-
-import compbio.runner.structure.RNAalifold;
-
-// Utility class for reading alifold output
-
-public class RNAStructReader {
-
-       private static Logger log = Logger.getLogger(RNAStructReader.class);
-       
-       // Whitespace patterns
-       static String s = "[+\\s=]+";
-       static String bracket = "\\(|\\)|\\{|\\}|\\[|\\]";
-       static String notData = "[\\s=+]+";
-
-       // RNAOut data type patterns 
-       static String seqP = "[_\\-a-zA-Z]{2,}"; // Has to match --mis output aswell (not just ACGU_)
-       static String structP = "[\\.)({}\\[\\],]{2,}";
-       static String floatP = "-?\\d+\\.\\d*(e[+\\-]\\d+)?";
-       static String energyP = "-?[0-9]*\\.?[0-9]{2}";
-       static String freqP = "^-?\\d\\.\\d{6,}(e[+\\-]\\d+)?$";
-       
-       // alifold out line patterns
-       static String ps = "\\s*";
-       static String alignmentP = "^"+seqP+ps+"$";
-       static String stdStructP = "^"+structP+s+"\\("+ps+floatP+s+floatP+s+floatP+ps+"\\)"+ps+"$";
-       static String justStructP = "^"+structP+ps+"$";
-       static String stochBTStructP = "^"+structP+s+floatP+s+floatP+ps+"$";
-       static String PStructP = "^"+structP+s+"\\["+ps+floatP+ps+"\\]"+ps+"$";
-       static String centStructP = "^"+structP+s+floatP+ps+"\\{"+ps+floatP+s+floatP+ps+"\\}"+ps+"$";
-       static String MEAStructP = "^"+structP+s+"\\{"+ps+floatP+s+"MEA="+floatP+ps+"\\}"+ps+"$";
-       static String freeEnergyP = "^"+ps+"free energy of ensemble"+ps+"="+ps+floatP+ps+"kcal/mol"+ps+"$";
-       static String ensembleFreqP = "^"+ps+"frequency of mfe structure in ensemble "+floatP+ps+"$";
-
-       public static ScoreManager readRNAStructStream(InputStream stdout)
-                       throws IOException {
-               
-               String error = "Error in parsing alifold stdout file: ";
-               // The Lists required to construct a ScoreManager Using the new constructor
-               List<String> structs = new ArrayList<String>();
-               List<TreeSet<Score>> data = new ArrayList<TreeSet<Score>>();
-
-               // Allocate necessry data structures for creating Score objects
-               ArrayList<Float> scores = new ArrayList<Float>();
-
-               BufferedReader reader = new BufferedReader(new InputStreamReader(stdout));
-               // The first 2 lines of the alifold stdout file are always the same format
-               String fline = reader.readLine();
-               assert (Pattern.matches(AlifoldLine.alignment.regex, fline)) :
-                       error + "Sequence Alignment Expected";
-               structs.add(fline.trim());
-               data.add(newEmptyScore(AlifoldResult.alifoldSeq));
-               
-               fline = reader.readLine();
-               assert (Pattern.matches(AlifoldLine.stdStruct.regex, fline)) :
-                       error + "Consensus Structure and Energy Expected";
-               Scanner sc = new Scanner(fline);
-               structs.add(sc.next());
-               for (int i = 0; i < 3; i++) {
-                       scores.add(Float.parseFloat(sc.findInLine(floatP)));
-               }
-               data.add(newSetScore(AlifoldResult.alifold, scores));
-               
-               // Now the alifold stdout file formats diverge based on arguments
-               fline = reader.readLine();
-               String sline;
-               Scanner nsc = null;
-               while ( fline != null) {
-                       scores.clear();
-                       AlifoldLine ftype = identifyLine(fline);
-                       sline = reader.readLine(); // Look ahead
-                       sc = new Scanner(fline);
-                       if (sline != null) nsc = new Scanner(sline);
-
-                       if (ftype.equals(AlifoldLine.PStruct)) {
-                               // The -p or --MEA option is specified
-                               // The next line should always be frequency of mfe structure
-                               assert ( sline != null && Pattern.matches(AlifoldLine.ensembleFreq.regex, sline)) :
-                                       error + "Expected frequency of mfe structure";
-                               structs.add(sc.next());
-                               scores.add(Float.parseFloat(sc.findInLine(floatP)));
-                               scores.add(Float.parseFloat(nsc.findInLine(floatP)));
-                               data.add(newSetScore(AlifoldResult.alifoldP, scores));
-                               // Jump line
-                               sline = reader.readLine();
-                       }
-                       else if (ftype.equals(AlifoldLine.centStruct)) {
-                               structs.add(sc.next());
-                               for (int i = 0; i < 3; i++) {
-                                       scores.add(Float.parseFloat(sc.findInLine(floatP)));
-                               }
-                               data.add(newSetScore(AlifoldResult.alifoldCentroid, scores));
-                       }
-                       else if (ftype.equals(AlifoldLine.MEAStruct)) {
-                               structs.add(sc.next());
-                               for (int i = 0; i < 2; i++) {
-                                       scores.add(Float.parseFloat(sc.findInLine(floatP)));
-                               }
-                               data.add(newSetScore(AlifoldResult.alifoldMEA, scores));
-                       }
-                       else if (ftype.equals(AlifoldLine.justStruct)) {
-                               structs.add(sc.next());
-                               data.add(newEmptyScore(AlifoldResult.alifoldStochBT));
-                       }
-                       else if (ftype.equals(AlifoldLine.stochBTStruct)) {
-                               structs.add(sc.next());
-                               scores.add(sc.nextFloat());
-                               scores.add(sc.nextFloat());
-                               data.add(newSetScore(AlifoldResult.alifoldStochBT, scores));
-                       }
-                       else if (ftype.equals(AlifoldLine.freeEnergy)) {
-                               assert (sline != null 
-                                               && Pattern.matches(AlifoldLine.ensembleFreq.regex, sline)) :
-                                               error + "Found 'freeEnergy' line on its own";
-                               structs.add("Free energy of ensemble (kcal/mol) followed by "
-                                               + "frequency of mfe structure in ensemble");
-                               scores.add(Float.parseFloat(sc.findInLine(floatP)));
-                               scores.add(Float.parseFloat(nsc.findInLine(floatP)));
-                               data.add(newSetScore(AlifoldResult.alifoldMetadata, scores));
-                               // jump line
-                               sline = reader.readLine();
-                       }
-                       
-
-                       assert(!ftype.equals(AlifoldLine.ensembleFreq)) :
-                               error + "Wasn't expecting 'frequency of mfe structure'!";
-                       assert(!ftype.equals(AlifoldLine.stdStruct)) :
-                               error + "'Standard output' line at a place other than line 2!";
-                       assert(!ftype.equals(AlifoldLine.alignment)) :
-                               error + "Wasn't expecting an alignment sequence!";
-                       assert(!ftype.equals(AlifoldLine.OTHER)) :
-                               error + "Wasn't expecting this whatever it is: " + fline;
-                       if (Pattern.matches("^\\s*$", fline)) {
-                               log.warn("While parsing alifold stdout: A line is either empty or"
-                                               + " contains only whitespace");
-                       }
-                       
-                       fline = sline;
-               }
-                               
-               sc.close();
-               if (nsc != null) nsc.close();
-               
-               return new ScoreManager(new RNAStruct(structs, data));
-       }
-       
-       // Just for the purpose of creating nee TreeSet<Score> objects of length one
-       // for adding to a 'data' list to make a ScoreManager
-       private static TreeSet<Score> newSetScore(Enum<?> res, List<Float> scores) {
-               // first convert List<Float> to float[]
-               float[] scoresf = new float[scores.size()];
-               Float f;
-               for (int i = 0; i < scoresf.length; i++) {
-                       f = scores.get(i);
-                       scoresf[i] = ( f != null ? f : Float.NaN);
-               }
-               return new TreeSet<Score>(Arrays.asList(new Score(res, scoresf)));
-       }
-
-       // A method just for the purpose of neatly creating Almost Empty score objects
-       // that can't be null
-       public static TreeSet<Score> newEmptyScore(Enum<?> res) {
-               return new TreeSet<Score>(Arrays.asList(new Score(res, new float[0])));
-       }
-
-       public static ScoreManager readRNAStructStream(InputStream stdout, 
-                       InputStream alifold) throws IOException {
-               
-               // The Lists required to construct a ScoreManager Using the new constructor
-               List<String> structs;
-               List<TreeSet<Score>> data; 
-               
-               // Get a ScoreManager that takes the std output but ignores alifold.out (-p)
-               ScoreManager stdSM = readRNAStructStream(stdout);
-               
-               // Unpack this into the structs and data lists
-               structs = stdSM.asRNAStruct().getStructs();
-               data = stdSM.asRNAStruct().getData();
-               
-               // Now parse alifold.out
-               Scanner sc = new Scanner(alifold);
-               sc.useDelimiter("[\\s%]+");
-               
-               // jump two lines to the data 
-               sc.nextLine(); sc.nextLine();
-               
-               // Read the first, second and fourth columns. Ignoring everything else.
-               // Allocate necessry data structures for creating Score objects
-               ArrayList<Float> scores = new ArrayList<Float>();
-               List<Range> rangeHolder = new ArrayList<Range>();
-               String s = "null";
-               while (true) {
-                       s = sc.next();
-                       if (java.util.regex.Pattern.matches("^[\\.)(]{2,}$", s)) break;
-                       if (!sc.hasNextLine()) break;
-                       int t = sc.nextInt();
-                       rangeHolder.add(new Range(Integer.parseInt(s), t));
-                       sc.next();
-                       scores.add(sc.nextFloat());
-                       sc.nextLine();
-               }
-               sc.close();
-               
-               // Update the first ScoreHolder TreeSet<Score> element
-               assert (rangeHolder.size() == scores.size());
-               TreeSet<Score> sHolder = new TreeSet<Score>();
-               for (int i = 0; i < rangeHolder.size(); i++) {
-                       ArrayList<Float> singleS = new ArrayList<Float>(Arrays.asList(scores.get(i)));
-                       TreeSet<Range> singleR = new TreeSet<Range>(Arrays.asList(rangeHolder.get(i)));
-                       sHolder.add(new Score(AlifoldResult.alifoldSeq, singleS, singleR));
-               }
-               
-               data.set(0, sHolder);
-               
-               return new ScoreManager(new RNAStruct(structs, data));
-       }
-
-       private static RNAOut identify(String token) {
-               if (Pattern.matches(seqP, token)) {
-                       return RNAOut.SEQ;
-               } else if (Pattern.matches(structP, token)) {
-                       return RNAOut.STRUCT;
-               } else if (Pattern.matches(energyP, token)) {
-                       return RNAOut.ENERGY;
-               } else if (Pattern.matches(freqP, token)) {
-                       return RNAOut.FREQ;
-               }
-               
-               return RNAOut.OTHER;
-       }
-       
-       private static AlifoldLine identifyLine(String line) {
-               
-               for (AlifoldLine il : AlifoldLine.values()) {
-                       if (Pattern.matches(il.regex, line)) return il;
-               }
-               return AlifoldLine.OTHER;
-       }
-       
-       static enum AlifoldLine {
-               stdStruct (stdStructP),
-               justStruct (justStructP),
-               stochBTStruct (stochBTStructP),
-               PStruct (PStructP),
-               centStruct (centStructP),
-               MEAStruct (MEAStructP),
-               freeEnergy (freeEnergyP),
-               ensembleFreq (ensembleFreqP),
-               alignment (alignmentP), 
-               OTHER (".*");
-               
-               String regex;
-               AlifoldLine(String regex) { this.regex = regex; }
-
-       }
-       
-       //The types of data in an RNAalifold stdout file
-       static enum RNAOut {
-               SEQ, STRUCT, ENERGY, FREQ, OTHER
-       }
-
-       //Something to put in the Score objects of the alifold result which gives information
-       //about what kind of sequence it is holding in its String Id.
-       static enum AlifoldResult {
-               alifold, alifoldP, alifoldMEA, alifoldCentroid, alifoldStochBT, alifoldSeq, alifoldMetadata
-       }
-       
-       
-
-       // Print the full regex Strings for testing 
-       public static void main(String[] args) {
-               for (AlifoldLine l : AlifoldLine.values()) {
-                       System.out.println(l.toString() + ": " + l.regex.replace("^","").replace("$",""));
-               }
-       }
-       
-
-       
-}      
+package compbio.data.sequence;\r
+\r
+import java.io.BufferedReader;\r
+import java.io.InputStream;\r
+import java.io.InputStreamReader;\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+import java.util.Scanner;\r
+import java.util.TreeSet;\r
+import java.util.regex.Pattern;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.runner.structure.RNAalifold;\r
+\r
+// Utility class for reading alifold output\r
+\r
+public class RNAStructReader {\r
+\r
+       private static Logger log = Logger.getLogger(RNAStructReader.class);\r
+       \r
+       // Whitespace patterns\r
+       static String s = "[+\\s=]+";\r
+       static String bracket = "\\(|\\)|\\{|\\}|\\[|\\]";\r
+       static String notData = "[\\s=+]+";\r
+\r
+       // RNAOut data type patterns \r
+       static String seqP = "[_\\-a-zA-Z]{2,}"; // Has to match --mis output aswell (not just ACGU_)\r
+       static String structP = "[\\.)({}\\[\\],]{2,}";\r
+       static String floatP = "-?\\d+\\.\\d*(e[+\\-]\\d+)?";\r
+       static String energyP = "-?[0-9]*\\.?[0-9]{2}";\r
+       static String freqP = "^-?\\d\\.\\d{6,}(e[+\\-]\\d+)?$";\r
+       \r
+       // alifold out line patterns\r
+       static String ps = "\\s*";\r
+       static String alignmentP = "^"+seqP+ps+"$";\r
+       static String stdStructP = "^"+structP+s+"\\("+ps+floatP+s+floatP+s+floatP+ps+"\\)"+ps+"$";\r
+       static String justStructP = "^"+structP+ps+"$";\r
+       static String stochBTStructP = "^"+structP+s+floatP+s+floatP+ps+"$";\r
+       static String PStructP = "^"+structP+s+"\\["+ps+floatP+ps+"\\]"+ps+"$";\r
+       static String centStructP = "^"+structP+s+floatP+ps+"\\{"+ps+floatP+s+floatP+ps+"\\}"+ps+"$";\r
+       static String MEAStructP = "^"+structP+s+"\\{"+ps+floatP+s+"MEA="+floatP+ps+"\\}"+ps+"$";\r
+       static String freeEnergyP = "^"+ps+"free energy of ensemble"+ps+"="+ps+floatP+ps+"kcal/mol"+ps+"$";\r
+       static String ensembleFreqP = "^"+ps+"frequency of mfe structure in ensemble "+floatP+ps+"$";\r
+\r
+       public static RNAStructScoreManager readRNAStructStream(InputStream stdout)\r
+                       throws IOException {\r
+               \r
+               String error = "Error in parsing alifold stdout file: ";\r
+               // The Lists required to construct a ScoreManager Using the new constructor\r
+               List<String> structs = new ArrayList<String>();\r
+               List<TreeSet<Score>> data = new ArrayList<TreeSet<Score>>();\r
+\r
+               // Allocate necessry data structures for creating Score objects\r
+               ArrayList<Float> scores = new ArrayList<Float>();\r
+\r
+               BufferedReader reader = new BufferedReader(new InputStreamReader(stdout));\r
+               // The first 2 lines of the alifold stdout file are always the same format\r
+               String fline = reader.readLine();\r
+               assert (Pattern.matches(AlifoldLine.alignment.regex, fline)) :\r
+                       error + "Sequence Alignment Expected";\r
+               structs.add(fline.trim());\r
+               data.add(newEmptyScore(AlifoldResult.alifoldSeq));\r
+               \r
+               fline = reader.readLine();\r
+               assert (Pattern.matches(AlifoldLine.stdStruct.regex, fline)) :\r
+                       error + "Consensus Structure and Energy Expected";\r
+               Scanner sc = new Scanner(fline);\r
+               structs.add(sc.next());\r
+               for (int i = 0; i < 3; i++) {\r
+                       scores.add(Float.parseFloat(sc.findInLine(floatP)));\r
+               }\r
+               data.add(newSetScore(AlifoldResult.alifold, scores));\r
+               \r
+               // Now the alifold stdout file formats diverge based on arguments\r
+               fline = reader.readLine();\r
+               String sline;\r
+               Scanner nsc = null;\r
+               while ( fline != null) {\r
+                       scores.clear();\r
+                       AlifoldLine ftype = identifyLine(fline);\r
+                       sline = reader.readLine(); // Look ahead\r
+                       sc = new Scanner(fline);\r
+                       if (sline != null) nsc = new Scanner(sline);\r
+\r
+                       if (ftype.equals(AlifoldLine.PStruct)) {\r
+                               // The -p or --MEA option is specified\r
+                               // The next line should always be frequency of mfe structure\r
+                               assert ( sline != null && Pattern.matches(AlifoldLine.ensembleFreq.regex, sline)) :\r
+                                       error + "Expected frequency of mfe structure";\r
+                               structs.add(sc.next());\r
+                               scores.add(Float.parseFloat(sc.findInLine(floatP)));\r
+                               scores.add(Float.parseFloat(nsc.findInLine(floatP)));\r
+                               data.add(newSetScore(AlifoldResult.alifoldP, scores));\r
+                               // Jump line\r
+                               sline = reader.readLine();\r
+                       }\r
+                       else if (ftype.equals(AlifoldLine.centStruct)) {\r
+                               structs.add(sc.next());\r
+                               for (int i = 0; i < 3; i++) {\r
+                                       scores.add(Float.parseFloat(sc.findInLine(floatP)));\r
+                               }\r
+                               data.add(newSetScore(AlifoldResult.alifoldCentroid, scores));\r
+                       }\r
+                       else if (ftype.equals(AlifoldLine.MEAStruct)) {\r
+                               structs.add(sc.next());\r
+                               for (int i = 0; i < 2; i++) {\r
+                                       scores.add(Float.parseFloat(sc.findInLine(floatP)));\r
+                               }\r
+                               data.add(newSetScore(AlifoldResult.alifoldMEA, scores));\r
+                       }\r
+                       else if (ftype.equals(AlifoldLine.justStruct)) {\r
+                               structs.add(sc.next());\r
+                               data.add(newEmptyScore(AlifoldResult.alifoldStochBT));\r
+                       }\r
+                       else if (ftype.equals(AlifoldLine.stochBTStruct)) {\r
+                               structs.add(sc.next());\r
+                               scores.add(sc.nextFloat());\r
+                               scores.add(sc.nextFloat());\r
+                               data.add(newSetScore(AlifoldResult.alifoldStochBT, scores));\r
+                       }\r
+                       else if (ftype.equals(AlifoldLine.freeEnergy)) {\r
+                               assert (sline != null \r
+                                               && Pattern.matches(AlifoldLine.ensembleFreq.regex, sline)) :\r
+                                               error + "Found 'freeEnergy' line on its own";\r
+                               structs.add("Free energy of ensemble (kcal/mol) followed by "\r
+                                               + "frequency of mfe structure in ensemble");\r
+                               scores.add(Float.parseFloat(sc.findInLine(floatP)));\r
+                               scores.add(Float.parseFloat(nsc.findInLine(floatP)));\r
+                               data.add(newSetScore(AlifoldResult.alifoldMetadata, scores));\r
+                               // jump line\r
+                               sline = reader.readLine();\r
+                       }\r
+                       \r
+\r
+                       assert(!ftype.equals(AlifoldLine.ensembleFreq)) :\r
+                               error + "Wasn't expecting 'frequency of mfe structure'!";\r
+                       assert(!ftype.equals(AlifoldLine.stdStruct)) :\r
+                               error + "'Standard output' line at a place other than line 2!";\r
+                       assert(!ftype.equals(AlifoldLine.alignment)) :\r
+                               error + "Wasn't expecting an alignment sequence!";\r
+                       assert(!ftype.equals(AlifoldLine.OTHER)) :\r
+                               error + "Wasn't expecting this whatever it is: " + fline;\r
+                       if (Pattern.matches("^\\s*$", fline)) {\r
+                               log.warn("While parsing alifold stdout: A line is either empty or"\r
+                                               + " contains only whitespace");\r
+                       }\r
+                       \r
+                       fline = sline;\r
+               }\r
+                               \r
+               sc.close();\r
+               if (nsc != null) nsc.close();\r
+               \r
+               return new RNAStructScoreManager(structs, data);\r
+       }\r
+       \r
+       // Just for the purpose of creating nee TreeSet<Score> objects of length one\r
+       // for adding to a 'data' list to make a ScoreManager\r
+       private static TreeSet<Score> newSetScore(Enum<?> res, List<Float> scores) {\r
+               // first convert List<Float> to float[]\r
+               float[] scoresf = new float[scores.size()];\r
+               Float f;\r
+               for (int i = 0; i < scoresf.length; i++) {\r
+                       f = scores.get(i);\r
+                       scoresf[i] = ( f != null ? f : Float.NaN);\r
+               }\r
+               return new TreeSet<Score>(Arrays.asList(new Score(res, scoresf)));\r
+       }\r
+\r
+       // A method just for the purpose of neatly creating Almost Empty score objects\r
+       // that can't be null\r
+       public static TreeSet<Score> newEmptyScore(Enum<?> res) {\r
+               return new TreeSet<Score>(Arrays.asList(new Score(res, new float[0])));\r
+       }\r
+\r
+       public static RNAStructScoreManager readRNAStructStream(InputStream stdout, \r
+                       InputStream alifold) throws IOException {\r
+               \r
+               // The Lists required to construct a ScoreManager Using the new constructor\r
+               List<String> structs;\r
+               List<TreeSet<Score>> data; \r
+               \r
+               // Get a ScoreManager that takes the std output but ignores alifold.out (-p)\r
+               RNAStructScoreManager stdSM = readRNAStructStream(stdout);\r
+               \r
+               // Unpack this into the structs and data lists\r
+               structs = stdSM.getStructs();\r
+               data = stdSM.getData();\r
+               \r
+               // Now parse alifold.out\r
+               Scanner sc = new Scanner(alifold);\r
+               sc.useDelimiter("[\\s%]+");\r
+               \r
+               // jump two lines to the data \r
+               sc.nextLine(); sc.nextLine();\r
+               \r
+               // Read the first, second and fourth columns. Ignoring everything else.\r
+               // Allocate necessry data structures for creating Score objects\r
+               ArrayList<Float> scores = new ArrayList<Float>();\r
+               List<Range> rangeHolder = new ArrayList<Range>();\r
+               String s = "null";\r
+               while (true) {\r
+                       s = sc.next();\r
+                       if (java.util.regex.Pattern.matches("^[\\.)(]{2,}$", s)) break;\r
+                       if (!sc.hasNextLine()) break;\r
+                       int t = sc.nextInt();\r
+                       rangeHolder.add(new Range(Integer.parseInt(s), t));\r
+                       sc.next();\r
+                       scores.add(sc.nextFloat());\r
+                       sc.nextLine();\r
+               }\r
+               sc.close();\r
+               \r
+               // Update the first ScoreHolder TreeSet<Score> element\r
+               assert (rangeHolder.size() == scores.size());\r
+               TreeSet<Score> sHolder = new TreeSet<Score>();\r
+               for (int i = 0; i < rangeHolder.size(); i++) {\r
+                       ArrayList<Float> singleS = new ArrayList<Float>(Arrays.asList(scores.get(i)));\r
+                       TreeSet<Range> singleR = new TreeSet<Range>(Arrays.asList(rangeHolder.get(i)));\r
+                       sHolder.add(new Score(AlifoldResult.alifoldSeq, singleS, singleR));\r
+               }\r
+               \r
+               data.set(0, sHolder);\r
+               \r
+               return new RNAStructScoreManager(structs, data);\r
+       }\r
+\r
+       private static RNAOut identify(String token) {\r
+               if (Pattern.matches(seqP, token)) {\r
+                       return RNAOut.SEQ;\r
+               } else if (Pattern.matches(structP, token)) {\r
+                       return RNAOut.STRUCT;\r
+               } else if (Pattern.matches(energyP, token)) {\r
+                       return RNAOut.ENERGY;\r
+               } else if (Pattern.matches(freqP, token)) {\r
+                       return RNAOut.FREQ;\r
+               }\r
+               \r
+               return RNAOut.OTHER;\r
+       }\r
+       \r
+       private static AlifoldLine identifyLine(String line) {\r
+               \r
+               for (AlifoldLine il : AlifoldLine.values()) {\r
+                       if (Pattern.matches(il.regex, line)) return il;\r
+               }\r
+               return AlifoldLine.OTHER;\r
+       }\r
+       \r
+       static enum AlifoldLine {\r
+               stdStruct (stdStructP),\r
+               justStruct (justStructP),\r
+               stochBTStruct (stochBTStructP),\r
+               PStruct (PStructP),\r
+               centStruct (centStructP),\r
+               MEAStruct (MEAStructP),\r
+               freeEnergy (freeEnergyP),\r
+               ensembleFreq (ensembleFreqP),\r
+               alignment (alignmentP), \r
+               OTHER (".*");\r
+               \r
+               String regex;\r
+               AlifoldLine(String regex) { this.regex = regex; }\r
+\r
+       }\r
+       \r
+       //The types of data in an RNAalifold stdout file\r
+       static enum RNAOut {\r
+               SEQ, STRUCT, ENERGY, FREQ, OTHER\r
+       }\r
+\r
+       //Something to put in the Score objects of the alifold result which gives information\r
+       //about what kind of sequence it is holding in its String Id.\r
+       static enum AlifoldResult {\r
+               alifold, alifoldP, alifoldMEA, alifoldCentroid, alifoldStochBT, alifoldSeq, alifoldMetadata\r
+       }\r
+       \r
+       \r
+\r
+       // Print the full regex Strings for testing \r
+       public static void main(String[] args) {\r
+               for (AlifoldLine l : AlifoldLine.values()) {\r
+                       System.out.println(l.toString() + ": " + l.regex.replace("^","").replace("$",""));\r
+               }\r
+       }\r
+       \r
+\r
+       \r
+}      \r
diff --git a/datamodel/compbio/data/sequence/RNAStructScoreManager.java b/datamodel/compbio/data/sequence/RNAStructScoreManager.java
new file mode 100644 (file)
index 0000000..3fb856c
--- /dev/null
@@ -0,0 +1,131 @@
+package compbio.data.sequence;\r
+\r
+\r
+import java.io.IOException;\r
+import java.io.Writer;\r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+import java.util.TreeMap;\r
+import java.util.TreeSet;\r
+\r
+import javax.xml.bind.annotation.XmlAccessType;\r
+import javax.xml.bind.annotation.XmlAccessorType;\r
+import javax.xml.bind.annotation.XmlTransient;\r
+\r
+import compbio.data.sequence.ScoreManager.ScoreHolder;\r
+import compbio.util.SysPrefs;\r
+\r
+@XmlAccessorType(XmlAccessType.FIELD)\r
+public class RNAStructScoreManager extends ScoreManager {\r
+\r
+       \r
+       private RNAStructScoreManager() {\r
+               //Default JAXB constructor\r
+       }\r
+       \r
+\r
+       public RNAStructScoreManager(List<String> structs, List<TreeSet<Score>> data) {\r
+               assert(structs.size() == data.size());\r
+               \r
+               List<ScoreHolder> seqScores = new ArrayList<ScoreHolder>();\r
+               \r
+               for (int i = 0; i < structs.size(); i++) {\r
+                       seqScores.add(new ScoreHolder(structs.get(i), data.get(i)));\r
+               }\r
+               this.seqScores = seqScores;\r
+       }\r
+       \r
+       // I put this in purely because it mirrors a method in ScoreManager, not because I need it :/\r
+       public static RNAStructScoreManager newInstance(List<String> structs, List<TreeSet<Score>> data) {\r
+               return new RNAStructScoreManager(structs, data);\r
+       }\r
+       \r
+       public List<String> getStructs() {\r
+               List<String> structs = new ArrayList<String>();\r
+               for (ScoreHolder sch : this.seqScores) {\r
+                       structs.add(sch.id);\r
+               }\r
+               return structs;\r
+       }\r
+       \r
+       public List<TreeSet<Score>> getData() {\r
+               List<TreeSet<Score>> data = new ArrayList<TreeSet<Score>>();\r
+               for (ScoreHolder sch : this.seqScores) {\r
+                       data.add(sch.scores);\r
+               }\r
+               return data;\r
+       }\r
+\r
+       // Send this data Structure back to something approximating the stdoutFile\r
+       // with extra information from alifold.out\r
+       @Override\r
+       public String toString() {\r
+               String out = "";\r
+               // The first objects hold the Consensus Alignment and the alifold.out info\r
+               out += this.getStructs().get(0) + SysPrefs.newlinechar;\r
+\r
+               // Now the rest of the structures with energies/frequencies\r
+               for (int i = 1; i < this.getStructs().size(); i++) {\r
+                       out = out + this.getStructs().get(i).toString();\r
+\r
+                       if (this.getData().get(i).first().getScores().size() > 0) {\r
+                               List<Float> scores = this.getData().get(i).first().getScores();\r
+                               if (scores.size() >= 3) {\r
+                                       out = out + " (" + scores.get(0).toString() + " = " \r
+                                                       + scores.get(1).toString() + " + " + scores.get(2).toString()\r
+                                                       + ")" + SysPrefs.newlinechar;\r
+                               }\r
+                               else if (this.getData().get(i).first().getMethod().equals("alifoldMEA")) {\r
+                                       out = out + " { " + scores.get(0).toString() + " MEA=" \r
+                                                       + scores.get(1).toString() + "}" + SysPrefs.newlinechar;\r
+                               }\r
+                               else if (scores.size() >= 2) {\r
+                                       out = out + " [" + scores.get(0).toString() + ", " \r
+                                                       + scores.get(1).toString() + "]" + SysPrefs.newlinechar;\r
+\r
+                               }\r
+                       } else out += SysPrefs.newlinechar; \r
+               }\r
+               if (this.getData().get(0).first().getScores().size() > 0) {\r
+                       Iterator<Score> iScores = this.getData().get(0).iterator();\r
+                       out += "Base Pairings followed by probability" + SysPrefs.newlinechar;\r
+                       for (int i = 0; i < this.getData().get(0).size(); i++) {\r
+                               Score s = iScores.next();\r
+                               Range r = s.getRanges().first();\r
+                               Float score = s.getScores().get(0);\r
+                               out += String.format("%4d  %4d    %.1f%n", r.getFrom(), r.getTo(),\r
+                                               score);\r
+                       }\r
+               }\r
+\r
+\r
+               return out;\r
+       }\r
+\r
+       @Override \r
+       public boolean equals(Object obj) {\r
+               if (obj == null) {\r
+                       return false;\r
+               }\r
+               if (!(obj instanceof RNAStructScoreManager)) {\r
+                       return false;\r
+               }\r
+               RNAStructScoreManager other = (RNAStructScoreManager) obj;\r
+               if (this.getStructs() == null) {\r
+                       if (other.getStructs() != null) {\r
+                               return false;\r
+                       }\r
+               } else if (!this.getStructs().equals(other.getStructs()))\r
+                       return false;\r
+               if (this.getData() == null) {\r
+                       if (other.getData() != null)\r
+                               return false;\r
+               } else if (!this.getData().equals(other.getData()))\r
+                       return false;\r
+\r
+               return true;\r
+       }\r
+}\r
index 0e9e20f..c6c79ec 100644 (file)
-package compbio.runner.structure;
-
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-
-
-
-
-
-import org.apache.log4j.Logger;
-
-import compbio.data.sequence.ScoreManager;
-import compbio.data.sequence.RNAStruct;
-import compbio.data.sequence.UnknownFileFormatException;
-import compbio.engine.client.PipedExecutable;
-import compbio.engine.client.SkeletalExecutable;
-import compbio.metadata.ResultNotAvailableException;
-import compbio.runner.Util;
-
-
-import compbio.engine.client.CommandBuilder;
-
-public class RNAalifold extends SkeletalExecutable<RNAalifold> 
-               implements PipedExecutable<RNAalifold> {
-       
-       
-       private static Logger log = Logger.getLogger(RNAalifold.class);
-
-       // May not be necessary as defult is "<space>" but still dont know
-       // How to deal with different key value separators for different params
-       public static final String KEY_VALUE_SEPARATOR = " ";
-       
-       public RNAalifold() {
-               super(KEY_VALUE_SEPARATOR);
-       }
-       
-       @Override
-       public RNAalifold setOutput(String outFile) {
-               super.setOutput(outFile);
-               return this;
-       }
-       
-       @Override
-       public RNAalifold setInput(String inFile) {
-               cbuilder.setLast(inFile);
-               super.setInput(inFile);
-               return this;
-       }
-       
-       @SuppressWarnings("unchecked")
-       @Override
-       public Class<RNAalifold> getType() {
-               return (Class<RNAalifold>) this.getClass();
-       }
-       
-       @SuppressWarnings("unchecked")
-       @Override
-       // PlaceHolder method
-       public ScoreManager getResults(String workDirectory)
-                       throws ResultNotAvailableException {
-               try {
-                       return Util.readRNAStruct(workDirectory, getOutput());
-                       
-               } catch (FileNotFoundException e) {
-                       log.error(e.getMessage(), e.getCause());
-                       throw new ResultNotAvailableException(e);
-               } catch (IOException e) {
-                       log.error(e.getMessage(), e.getCause());
-                       throw new ResultNotAvailableException(e);
-               }
-       }
-
-
-       // the new currently used methods for reading are found in 
-       // - compbio.data.sequence.SequenceUtil and 
-       // - compbio.runner.Util
-       
-       // Simple and generic methods for reading a whole file
-//     private static String readRNAStruct(String workDirectory,
-//                     String structFile) throws IOException, FileNotFoundException {
-//             assert !compbio.util.Util.isEmpty(workDirectory);
-//             assert !compbio.util.Util.isEmpty(structFile);
-//             File sfile = new File(compbio.engine.client.Util.getFullPath(
-//                             workDirectory, structFile));
-//             log.trace("RNAALIFOLD OUTPUT FILE PATH: " + sfile.getAbsolutePath());
-//             if(!(sfile.exists() && sfile.length() > 0)) {
-//                     throw new FileNotFoundException("Result for the jobId "
-//                                     + workDirectory + "with file name " + structFile
-//                                     + " is not found!");
-//             }
-//             return readFile(sfile);
-//     }
-//     
-//     private static BufferedReader input;
-//     public static String readFile(File inputFile) throws 
-//                     FileNotFoundException, IOException {
-//             
-//             input   = new BufferedReader(new FileReader(inputFile));
-//             
-//             String file = new String();
-//             String line = new String();
-//             
-//             while (true) {
-//                     line = input.readLine();
-//                     
-//                     if (line != null) {
-//                             file = file + line + "\r\n";
-//                     } else break;
-//             }
-//             // Close file
-//             input.close();
-//             return file;
-//     }
-       
-}
+package compbio.runner.structure;\r
+\r
+\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+\r
+\r
+\r
+\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.data.sequence.ScoreManager;\r
+import compbio.data.sequence.RNAStructScoreManager;\r
+import compbio.data.sequence.UnknownFileFormatException;\r
+import compbio.engine.client.PipedExecutable;\r
+import compbio.engine.client.SkeletalExecutable;\r
+import compbio.metadata.ResultNotAvailableException;\r
+import compbio.runner.Util;\r
+\r
+\r
+import compbio.engine.client.CommandBuilder;\r
+\r
+public class RNAalifold extends SkeletalExecutable<RNAalifold> \r
+               implements PipedExecutable<RNAalifold> {\r
+       \r
+       \r
+       private static Logger log = Logger.getLogger(RNAalifold.class);\r
+\r
+       // May not be necessary as defult is "<space>" but still dont know\r
+       // How to deal with different key value separators for different params\r
+       public static final String KEY_VALUE_SEPARATOR = " ";\r
+       \r
+       public RNAalifold() {\r
+               super(KEY_VALUE_SEPARATOR);\r
+       }\r
+       \r
+       @Override\r
+       public RNAalifold setOutput(String outFile) {\r
+               super.setOutput(outFile);\r
+               return this;\r
+       }\r
+       \r
+       @Override\r
+       public RNAalifold setInput(String inFile) {\r
+               cbuilder.setLast(inFile);\r
+               super.setInput(inFile);\r
+               return this;\r
+       }\r
+       \r
+       @SuppressWarnings("unchecked")\r
+       @Override\r
+       public Class<RNAalifold> getType() {\r
+               return (Class<RNAalifold>) this.getClass();\r
+       }\r
+       \r
+       @SuppressWarnings("unchecked")\r
+       @Override\r
+       public RNAStructScoreManager getResults(String workDirectory)\r
+                       throws ResultNotAvailableException {\r
+               try {\r
+                       return Util.readRNAStruct(workDirectory, getOutput());\r
+                       \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
+               }\r
+       }\r
+\r
+}\r
index 2168a6c..38fbe8b 100644 (file)
-package compbio.runner.structure;
-
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.bind.ValidationException;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import compbio.data.sequence.ScoreManager;
-import compbio.engine.Configurator;
-import compbio.engine.client.ConfiguredExecutable;
-import compbio.engine.client.Executable.ExecProvider;
-import compbio.engine.conf.RunnerConfigMarshaller;
-import compbio.engine.local.ExecutableWrapper;
-import compbio.engine.local.LocalRunner;
-import compbio.metadata.AllTestSuit;
-import compbio.metadata.JobExecutionException;
-import compbio.metadata.JobSubmissionException;
-import compbio.metadata.Option;
-import compbio.metadata.Parameter;
-import compbio.metadata.Preset;
-import compbio.metadata.PresetManager;
-import compbio.metadata.ResultNotAvailableException;
-import compbio.metadata.RunnerConfig;
-import compbio.runner.OptionCombinator;
-import compbio.runner.structure.RNAalifold;
-import compbio.util.FileUtil;
-
-
-public class RNAalifoldParametersTester {
-
-       
-       // should be: AllTestSuit.TEST_DATA_PATH + "RNAalifoldParameters.xml"
-       static final String rnaalifoldConfigFile = 
-                       AllTestSuit.TEST_DATA_PATH + "RNAalifoldParameters.xml";
-       public static String test_outfile = "rnaalifold.out.txt";
-
-       private static Logger log = Logger
-                       .getLogger(AllTestSuit.RUNNER_TEST_LOGGER);
-       
-       static {
-               log.setLevel(Level.INFO);
-       }
-       
-       RunnerConfig<RNAalifold> rnaalifoldConfig = null;
-       OptionCombinator rnaalifoldOpc = null;
-       
-       @BeforeMethod(groups = { AllTestSuit.test_group_runner })
-       @SuppressWarnings("unchecked")
-       public void setup() {
-               try {
-                       RunnerConfigMarshaller<RNAalifold> rnaalifoldmarsh = 
-                                       new RunnerConfigMarshaller<RNAalifold>(RunnerConfig.class);
-                       rnaalifoldConfig = rnaalifoldmarsh.read(new FileInputStream(new File(
-                                       rnaalifoldConfigFile)), RunnerConfig.class);
-                       // set Name value separator
-                       rnaalifoldConfig.setPrmSeparator(" ");
-                       rnaalifoldOpc = new OptionCombinator(rnaalifoldConfig);
-                       
-                       
-                       
-               } catch (JAXBException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               } catch (FileNotFoundException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               }
-       }
-       
-       @Test
-       public void testConfiguration() {
-               try {
-                       this.rnaalifoldConfig.validate();
-               } catch (ValidationException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               } catch (IllegalStateException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               }
-       }
-
-       @Test(groups = { AllTestSuit.test_group_runner })
-       public void testDefaultParameters() {
-               RNAalifold rnaalifold = new RNAalifold();
-               rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile);
-
-               try {
-                       // For local execution use relavive
-                       ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator
-                                       .configureExecutable(rnaalifold);
-                       LocalRunner lr = new LocalRunner(confRNAalifold);
-                       lr.executeJob();
-                       confRNAalifold = (ConfiguredExecutable<RNAalifold>) lr.waitForResult();
-                       assertNotNull(confRNAalifold.getResults());
-               } catch (JobSubmissionException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               } catch (JobExecutionException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               } catch (ResultNotAvailableException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               }
-       }
-       
-       
-       
-       @Test
-       public void testOptions() {
-               // populate list of incompatable pairs by their names. todo
-               List<List<String>> failPairs = new ArrayList<List<String>>();
-
-               
-               // test the parameters without -g option
-               test(removeParam(rnaalifoldOpc.getAllOptions(), "G-Quadruplex"));
-               // now test without -c option
-               test(removeParam(rnaalifoldOpc.getAllOptions(), "Circular"));
-       }
-       
-
-       // Prints all the incompatible option pairs 
-       // (-c, -g) and (-p, -p0)
-       
-       @Test
-       public void testOptionPairs() throws ResultNotAvailableException {
-               List<Option<?>> pair = new ArrayList<Option<?>>();
-               List<Option<?>> options = rnaalifoldOpc.getAllOptions();
-               List<List<String>> failedOptionPairs = new ArrayList<List<String>>();
-               
-               boolean failed = true;
-               for (int i = 0; i<options.size(); i++) {
-                       for (int j = i; j<options.size(); j++) {
-                               if (i != j) {
-                                       pair.clear();
-                                       pair.add(options.get(i)); pair.add(options.get(j));
-                                       List<String> args = rnaalifoldOpc.argumentsToCommandString(pair);
-                                       try { 
-                                               failed = singleRun(args);
-                                       } catch (ResultNotAvailableException e) {
-                                               System.out.println("Results not available: " + e.getMessage());
-                                               failed = true;
-                                       } catch (JobSubmissionException e) {
-                                               e.printStackTrace();
-                                               fail(e.getLocalizedMessage());
-                                       } catch (JobExecutionException e) {
-                                               e.printStackTrace();
-                                               fail(e.getLocalizedMessage());
-                                       } catch (IOException e) {
-                                               e.printStackTrace();
-                                               fail(e.getLocalizedMessage());
-                                       }
-                                       if (failed == true) {
-                                               failedOptionPairs.add(args);
-                                       }
-                               }
-                       }
-               }
-               System.out.println("failedOptionPairs: " + failedOptionPairs);
-               
-       }
-       
-       // tests for incompatible Pairs of Parameters 
-       // there are none however the --betascale parameter requires -p
-       
-       @Test
-       public void testParameterPairs() throws ResultNotAvailableException {
-               List<Parameter<?>> pair = new ArrayList<Parameter<?>>();
-               List<Parameter<?>> Parameters = rnaalifoldOpc.getAllParameters();
-               List<List<String>> failedParameterPairs = new ArrayList<List<String>>();
-               
-               
-               boolean failed = true;
-               for (int i = 0; i<Parameters.size(); i++) {
-                       for (int j = i; j<Parameters.size(); j++) {
-                               if (i != j) {
-                                       pair.clear();
-                                       pair.add(Parameters.get(i)); pair.add(Parameters.get(j));
-                                       List<String> args = rnaalifoldOpc.argumentsToCommandString(pair);
-                                       args.add("-p"); // --betascale requires -p
-                                       try { 
-                                               failed = singleRun(args);
-                                       } catch (ResultNotAvailableException e) {
-                                               System.out.println("Results not available: " + e.getMessage());
-                                               failed = true;
-                                       } catch (JobSubmissionException e) {
-                                               e.printStackTrace();
-                                               fail(e.getLocalizedMessage());
-                                       } catch (JobExecutionException e) {
-                                               e.printStackTrace();
-                                               fail(e.getLocalizedMessage());
-                                       } catch (IOException e) {
-                                               e.printStackTrace();
-                                               fail(e.getLocalizedMessage());
-                                       }
-                                       if (failed == true) {
-                                               failedParameterPairs.add(args);
-                                       }
-                               }
-                       }
-               }
-               System.out.println("failedParameterPairs: " + failedParameterPairs);
-               
-       }
-       
-       
-       // removes an argument from the list by name
-       public <U extends Option<?>> List<U> removeParam(List<U> optionList, String name) {
-               List<U> newL = new ArrayList<U>();
-               for (int i = 0; i < optionList.size(); i++) {
-                       System.out.println(name.equals(optionList.get(i).getName()));
-                       if (!name.equals(optionList.get(i).getName())) {
-                               
-                               newL.add(optionList.get(i));
-                       }
-                               
-               }
-               return newL;
-       }
-       
-       public <U extends Option<?>> List<U> removeParams(List<U> optionList, List<String> names) {
-               for (int i = 0; i < names.size(); i++) {
-                       optionList = removeParam(optionList, names.get(i));
-               }
-               return optionList;
-       }
-       
-       
-       @Test(groups = { AllTestSuit.test_group_runner })
-       public void testParameters() {
-               List<Parameter<?>> params = rnaalifoldOpc.getAllParameters();
-               System.out.println("param list: " + params);
-               Collections.shuffle(params);
-               // test with -p for betascale option
-               List<String> precursor = new ArrayList<String>();
-               precursor.add("-p");
-               
-               test(params, precursor);
-       }
-       
-       // incompatible pairs of arguments are
-       /*
-        * the -c and -g options
-        * the -d2 option and the -d option
-        * the -p and -p0 option
-        */
-
-       @Test(groups = { AllTestSuit.test_group_runner })
-       public void testArguments() {
-               List<Option<?>> options = rnaalifoldOpc.getAllOptions();
-               options.addAll(rnaalifoldOpc.getAllParameters());
-               Collections.shuffle(options);
-               test(options);
-       }
-       
-       // This test supercedes the testParameterPair() and testOptionPair()
-       // tests by testing all pairs of arguments
-       
-       
-       @Test
-       public void testAllPairs() throws ResultNotAvailableException {
-               List<Option<?>> pair = new ArrayList<Option<?>>();
-               List<Option<?>> options = rnaalifoldOpc.getAllOptions();
-               
-               // take out -p options so it can be added to all commands later
-               // options = removeParam(options, "Partition Function");
-               
-               options.addAll(rnaalifoldOpc.getAllParameters());
-               List<List<String>> failedOptionPairs = new ArrayList<List<String>>();
-               
-               boolean failed = true;
-               for (int i = 0; i<options.size(); i++) {
-                       for (int j = i; j<options.size(); j++) {
-                               if (i != j) {
-                                       pair.clear();
-                                       pair.add(options.get(i)); pair.add(options.get(j));
-                                       List<String> args = rnaalifoldOpc.argumentsToCommandString(pair);
-                                       // add -p
-                                       // args.add("-p");
-                                       try { 
-                                               failed = singleRun(args);
-                                       } catch (ResultNotAvailableException e) {
-                                               System.out.println("Results not available: " + e.getMessage());
-                                               failed = true;
-                                       } catch (JobSubmissionException e) {
-                                               e.printStackTrace();
-                                               fail(e.getLocalizedMessage());
-                                       } catch (JobExecutionException e) {
-                                               e.printStackTrace();
-                                               fail(e.getLocalizedMessage());
-                                       } catch (IOException e) {
-                                               e.printStackTrace();
-                                               fail(e.getLocalizedMessage());
-                                       }
-                                       if (failed == true) {
-                                               failedOptionPairs.add(args);
-                                       }
-                               }
-                       }
-               }
-               System.out.println("failedOptionPairs: " + failedOptionPairs);
-       }
-       
-       /*
-        *  This test method stolen from the other parameter testing classes
-        *  the only purpose of the Collections.shuffle(params) and the for loop
-        *  is to test giving the executable the parameters in different orders
-        *  which leads to a lot of (unnecessary?) tests with an argument list
-        *  as long as this one.
-        *  
-        */
-       
-       
-       void test(List<? extends Option<?>> params) {
-               for (int i = 0; i < params.size(); i++) {
-                       List<String> args = rnaalifoldOpc.argumentsToCommandString(params);
-                       singleTest(args);
-                       Collections.shuffle(params);
-               }
-               log.info("NUMBER OF COMBINATION TESTED: " + params.size());
-       }
-       
-       // because some parameters presuppose the -p option
-       
-       void test(List<? extends Option<?>> params, List<String> precursor) {
-
-               for (int i = 0; i < params.size(); i++) {
-                       List<String> args = rnaalifoldOpc.argumentsToCommandString(params);
-                       args.addAll(precursor);
-                       singleTest(args);
-                       Collections.shuffle(params);
-               }
-               log.info("NUMBER OF COMBINATION TESTED: " + params.size());
-       }
-       @Test
-       void singleParamTest() {
-               //List<Parameter<?>> params = rnaalifoldOpc.getAllParameters();
-               //System.out.println("special: params: " + params);
-               
-               //List<String> args = rnaalifoldOpc.argumentsToCommandString(params);
-               List<String> args = new ArrayList<String>();
-               //args.add("-T 37"); args.add("-S 1.07"); args.add("--stochBT_en 10");
-               // replace "=" with " " to fail test
-               args.add("--MEA=1");
-               args.add("-p");
-               singleTest(args);
-               
-       }
-       
-       void singleTest(List<String> params) {
-               try {
-                       log.info("Using arguments: " + params);
-                       RNAalifold rnaalifold = new RNAalifold();
-                       rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile);
-                       
-                       ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator
-                                       .configureExecutable(rnaalifold, ExecProvider.Local);
-                       // Add options to the executable
-                       confRNAalifold.addParameters(params);
-                       LocalRunner lr = new LocalRunner(confRNAalifold);
-                       lr.executeJob();
-                       confRNAalifold = (ConfiguredExecutable<RNAalifold>) lr.waitForResult();
-                       assertNotNull(confRNAalifold.getResults(), "results is null");
-                       
-                       System.out.println("Results: \n" 
-                       + ((ScoreManager) confRNAalifold.getResults()).asRNAStruct().toString());
-                       
-                       File errors = new File(confRNAalifold.getWorkDirectory(),
-                                       ExecutableWrapper.PROC_ERR_FILE);
-                       if (errors.length() != 0) {
-                               log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors));
-                       }
-                       assertTrue(errors.length() == 0, "Run with arguments : " + params
-                                       + " FAILED!");
-                       Collections.shuffle(params);
-               } catch (JobSubmissionException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               } catch (JobExecutionException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               } catch (IOException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               } catch (ResultNotAvailableException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               }
-       }
-       
-       /* A version of singleTest that continues running instead of calling
-        * fail() when it encounters a problem
-        * 
-        * Used to identify incompatible options and parameters
-        * returns -1 on failure
-        * 
-        * Bad Progamming practice? 
-        */
-       
-       
-       boolean singleRun(List<String> params) throws JobSubmissionException,
-                       JobExecutionException, IOException, ResultNotAvailableException {
-               boolean fail = true;
-               log.info("Using arguments: " + params);
-               RNAalifold rnaalifold = new RNAalifold();
-               rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile);
-
-               ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator
-                               .configureExecutable(rnaalifold, ExecProvider.Local);
-               // Add options to the executable
-               confRNAalifold.addParameters(params);
-               LocalRunner lr = new LocalRunner(confRNAalifold);
-               lr.executeJob();
-               confRNAalifold = (ConfiguredExecutable<RNAalifold>) lr.waitForResult();
-               
-               System.out.println("Results: \n" 
-                               + ((ScoreManager) confRNAalifold.getResults()).asRNAStruct().toString());
-               if (confRNAalifold.getResults() != null) fail = false;
-               File errors = new File(confRNAalifold.getWorkDirectory(),
-                               ExecutableWrapper.PROC_ERR_FILE);
-               if (errors.length() != 0) {
-                       log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors));
-               }
-               assertTrue(errors.length() == 0, "Run with arguments : " + params
-                               + " FAILED!");
-               Collections.shuffle(params);
-               return fail;
-               }
-}
+package compbio.runner.structure;\r
+\r
+import static org.testng.Assert.assertFalse;\r
+import static org.testng.Assert.assertNotNull;\r
+import static org.testng.Assert.assertTrue;\r
+import static org.testng.Assert.fail;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.Collections;\r
+import java.util.List;\r
+import java.util.Map;\r
+\r
+import javax.xml.bind.JAXBException;\r
+import javax.xml.bind.ValidationException;\r
+\r
+import org.apache.log4j.Level;\r
+import org.apache.log4j.Logger;\r
+import org.testng.annotations.BeforeMethod;\r
+import org.testng.annotations.Test;\r
+\r
+import compbio.data.sequence.RNAStructScoreManager;\r
+import compbio.data.sequence.ScoreManager;\r
+import compbio.engine.Configurator;\r
+import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.Executable.ExecProvider;\r
+import compbio.engine.conf.RunnerConfigMarshaller;\r
+import compbio.engine.local.ExecutableWrapper;\r
+import compbio.engine.local.LocalRunner;\r
+import compbio.metadata.AllTestSuit;\r
+import compbio.metadata.JobExecutionException;\r
+import compbio.metadata.JobSubmissionException;\r
+import compbio.metadata.Option;\r
+import compbio.metadata.Parameter;\r
+import compbio.metadata.Preset;\r
+import compbio.metadata.PresetManager;\r
+import compbio.metadata.ResultNotAvailableException;\r
+import compbio.metadata.RunnerConfig;\r
+import compbio.runner.OptionCombinator;\r
+import compbio.runner.structure.RNAalifold;\r
+import compbio.util.FileUtil;\r
+\r
+\r
+public class RNAalifoldParametersTester {\r
+\r
+       \r
+       // should be: AllTestSuit.TEST_DATA_PATH + "RNAalifoldParameters.xml"\r
+       static final String rnaalifoldConfigFile = \r
+                       AllTestSuit.TEST_DATA_PATH + "RNAalifoldParameters.xml";\r
+       public static String test_outfile = "rnaalifold.out.txt";\r
+\r
+       private static Logger log = Logger\r
+                       .getLogger(AllTestSuit.RUNNER_TEST_LOGGER);\r
+       \r
+       static {\r
+               log.setLevel(Level.INFO);\r
+       }\r
+       \r
+       RunnerConfig<RNAalifold> rnaalifoldConfig = null;\r
+       OptionCombinator rnaalifoldOpc = null;\r
+       \r
+       @BeforeMethod(groups = { AllTestSuit.test_group_runner })\r
+       @SuppressWarnings("unchecked")\r
+       public void setup() {\r
+               try {\r
+                       RunnerConfigMarshaller<RNAalifold> rnaalifoldmarsh = \r
+                                       new RunnerConfigMarshaller<RNAalifold>(RunnerConfig.class);\r
+                       rnaalifoldConfig = rnaalifoldmarsh.read(new FileInputStream(new File(\r
+                                       rnaalifoldConfigFile)), RunnerConfig.class);\r
+                       // set Name value separator\r
+                       rnaalifoldConfig.setPrmSeparator(" ");\r
+                       rnaalifoldOpc = new OptionCombinator(rnaalifoldConfig);\r
+                       \r
+                       \r
+                       \r
+               } catch (JAXBException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
+       }\r
+       \r
+       @Test\r
+       public void testConfiguration() {\r
+               try {\r
+                       this.rnaalifoldConfig.validate();\r
+               } catch (ValidationException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (IllegalStateException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
+       }\r
+\r
+       @Test(groups = { AllTestSuit.test_group_runner })\r
+       public void testDefaultParameters() {\r
+               RNAalifold rnaalifold = new RNAalifold();\r
+               rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile);\r
+\r
+               try {\r
+                       // For local execution use relavive\r
+                       ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator\r
+                                       .configureExecutable(rnaalifold);\r
+                       LocalRunner lr = new LocalRunner(confRNAalifold);\r
+                       lr.executeJob();\r
+                       confRNAalifold = (ConfiguredExecutable<RNAalifold>) lr.waitForResult();\r
+                       assertNotNull(confRNAalifold.getResults());\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
+       }\r
+       \r
+       \r
+       \r
+       @Test\r
+       public void testOptions() {\r
+               // populate list of incompatable pairs by their names. todo\r
+               List<List<String>> failPairs = new ArrayList<List<String>>();\r
+\r
+               \r
+               // test the parameters without -g option\r
+               test(removeParam(rnaalifoldOpc.getAllOptions(), "G-Quadruplex"));\r
+               // now test without -c option\r
+               test(removeParam(rnaalifoldOpc.getAllOptions(), "Circular"));\r
+       }\r
+       \r
+\r
+       // Prints all the incompatible option pairs \r
+       // (-c, -g) and (-p, -p0)\r
+       \r
+       @Test\r
+       public void testOptionPairs() throws ResultNotAvailableException {\r
+               List<Option<?>> pair = new ArrayList<Option<?>>();\r
+               List<Option<?>> options = rnaalifoldOpc.getAllOptions();\r
+               List<List<String>> failedOptionPairs = new ArrayList<List<String>>();\r
+               \r
+               boolean failed = true;\r
+               for (int i = 0; i<options.size(); i++) {\r
+                       for (int j = i; j<options.size(); j++) {\r
+                               if (i != j) {\r
+                                       pair.clear();\r
+                                       pair.add(options.get(i)); pair.add(options.get(j));\r
+                                       List<String> args = rnaalifoldOpc.argumentsToCommandString(pair);\r
+                                       try { \r
+                                               failed = singleRun(args);\r
+                                       } catch (ResultNotAvailableException e) {\r
+                                               System.out.println("Results not available: " + e.getMessage());\r
+                                               failed = true;\r
+                                       } catch (JobSubmissionException e) {\r
+                                               e.printStackTrace();\r
+                                               fail(e.getLocalizedMessage());\r
+                                       } catch (JobExecutionException e) {\r
+                                               e.printStackTrace();\r
+                                               fail(e.getLocalizedMessage());\r
+                                       } catch (IOException e) {\r
+                                               e.printStackTrace();\r
+                                               fail(e.getLocalizedMessage());\r
+                                       }\r
+                                       if (failed == true) {\r
+                                               failedOptionPairs.add(args);\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               System.out.println("failedOptionPairs: " + failedOptionPairs);\r
+               \r
+       }\r
+       \r
+       // tests for incompatible Pairs of Parameters \r
+       // there are none however the --betascale parameter requires -p\r
+       \r
+       @Test\r
+       public void testParameterPairs() throws ResultNotAvailableException {\r
+               List<Parameter<?>> pair = new ArrayList<Parameter<?>>();\r
+               List<Parameter<?>> Parameters = rnaalifoldOpc.getAllParameters();\r
+               List<List<String>> failedParameterPairs = new ArrayList<List<String>>();\r
+               \r
+               \r
+               boolean failed = true;\r
+               for (int i = 0; i<Parameters.size(); i++) {\r
+                       for (int j = i; j<Parameters.size(); j++) {\r
+                               if (i != j) {\r
+                                       pair.clear();\r
+                                       pair.add(Parameters.get(i)); pair.add(Parameters.get(j));\r
+                                       List<String> args = rnaalifoldOpc.argumentsToCommandString(pair);\r
+                                       args.add("-p"); // --betascale requires -p\r
+                                       try { \r
+                                               failed = singleRun(args);\r
+                                       } catch (ResultNotAvailableException e) {\r
+                                               System.out.println("Results not available: " + e.getMessage());\r
+                                               failed = true;\r
+                                       } catch (JobSubmissionException e) {\r
+                                               e.printStackTrace();\r
+                                               fail(e.getLocalizedMessage());\r
+                                       } catch (JobExecutionException e) {\r
+                                               e.printStackTrace();\r
+                                               fail(e.getLocalizedMessage());\r
+                                       } catch (IOException e) {\r
+                                               e.printStackTrace();\r
+                                               fail(e.getLocalizedMessage());\r
+                                       }\r
+                                       if (failed == true) {\r
+                                               failedParameterPairs.add(args);\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               System.out.println("failedParameterPairs: " + failedParameterPairs);\r
+               \r
+       }\r
+       \r
+       \r
+       // removes an argument from the list by name\r
+       public <U extends Option<?>> List<U> removeParam(List<U> optionList, String name) {\r
+               List<U> newL = new ArrayList<U>();\r
+               for (int i = 0; i < optionList.size(); i++) {\r
+                       System.out.println(name.equals(optionList.get(i).getName()));\r
+                       if (!name.equals(optionList.get(i).getName())) {\r
+                               \r
+                               newL.add(optionList.get(i));\r
+                       }\r
+                               \r
+               }\r
+               return newL;\r
+       }\r
+       \r
+       public <U extends Option<?>> List<U> removeParams(List<U> optionList, List<String> names) {\r
+               for (int i = 0; i < names.size(); i++) {\r
+                       optionList = removeParam(optionList, names.get(i));\r
+               }\r
+               return optionList;\r
+       }\r
+       \r
+       \r
+       @Test(groups = { AllTestSuit.test_group_runner })\r
+       public void testParameters() {\r
+               List<Parameter<?>> params = rnaalifoldOpc.getAllParameters();\r
+               System.out.println("param list: " + params);\r
+               Collections.shuffle(params);\r
+               // test with -p for betascale option\r
+               List<String> precursor = new ArrayList<String>();\r
+               precursor.add("-p");\r
+               \r
+               test(params, precursor);\r
+       }\r
+       \r
+       // incompatible pairs of arguments are\r
+       /*\r
+        * the -c and -g options\r
+        * the -d2 option and the -d option\r
+        * the -p and -p0 option\r
+        */\r
+\r
+       @Test(groups = { AllTestSuit.test_group_runner })\r
+       public void testArguments() {\r
+               List<Option<?>> options = rnaalifoldOpc.getAllOptions();\r
+               options.addAll(rnaalifoldOpc.getAllParameters());\r
+               Collections.shuffle(options);\r
+               test(options);\r
+       }\r
+       \r
+       // This test supercedes the testParameterPair() and testOptionPair()\r
+       // tests by testing all pairs of arguments\r
+       \r
+       \r
+       @Test\r
+       public void testAllPairs() throws ResultNotAvailableException {\r
+               List<Option<?>> pair = new ArrayList<Option<?>>();\r
+               List<Option<?>> options = rnaalifoldOpc.getAllOptions();\r
+               \r
+               // take out -p options so it can be added to all commands later\r
+               // options = removeParam(options, "Partition Function");\r
+               \r
+               options.addAll(rnaalifoldOpc.getAllParameters());\r
+               List<List<String>> failedOptionPairs = new ArrayList<List<String>>();\r
+               \r
+               boolean failed = true;\r
+               for (int i = 0; i<options.size(); i++) {\r
+                       for (int j = i; j<options.size(); j++) {\r
+                               if (i != j) {\r
+                                       pair.clear();\r
+                                       pair.add(options.get(i)); pair.add(options.get(j));\r
+                                       List<String> args = rnaalifoldOpc.argumentsToCommandString(pair);\r
+                                       // add -p\r
+                                       // args.add("-p");\r
+                                       try { \r
+                                               failed = singleRun(args);\r
+                                       } catch (ResultNotAvailableException e) {\r
+                                               System.out.println("Results not available: " + e.getMessage());\r
+                                               failed = true;\r
+                                       } catch (JobSubmissionException e) {\r
+                                               e.printStackTrace();\r
+                                               fail(e.getLocalizedMessage());\r
+                                       } catch (JobExecutionException e) {\r
+                                               e.printStackTrace();\r
+                                               fail(e.getLocalizedMessage());\r
+                                       } catch (IOException e) {\r
+                                               e.printStackTrace();\r
+                                               fail(e.getLocalizedMessage());\r
+                                       }\r
+                                       if (failed == true) {\r
+                                               failedOptionPairs.add(args);\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+               System.out.println("failedOptionPairs: " + failedOptionPairs);\r
+       }\r
+       \r
+       /*\r
+        *  This test method stolen from the other parameter testing classes\r
+        *  the only purpose of the Collections.shuffle(params) and the for loop\r
+        *  is to test giving the executable the parameters in different orders\r
+        *  which leads to a lot of (unnecessary?) tests with an argument list\r
+        *  as long as this one.\r
+        *  \r
+        */\r
+       \r
+       \r
+       void test(List<? extends Option<?>> params) {\r
+               for (int i = 0; i < params.size(); i++) {\r
+                       List<String> args = rnaalifoldOpc.argumentsToCommandString(params);\r
+                       singleTest(args);\r
+                       Collections.shuffle(params);\r
+               }\r
+               log.info("NUMBER OF COMBINATION TESTED: " + params.size());\r
+       }\r
+       \r
+       // because some parameters presuppose the -p option\r
+       \r
+       void test(List<? extends Option<?>> params, List<String> precursor) {\r
+\r
+               for (int i = 0; i < params.size(); i++) {\r
+                       List<String> args = rnaalifoldOpc.argumentsToCommandString(params);\r
+                       args.addAll(precursor);\r
+                       singleTest(args);\r
+                       Collections.shuffle(params);\r
+               }\r
+               log.info("NUMBER OF COMBINATION TESTED: " + params.size());\r
+       }\r
+       @Test\r
+       void singleParamTest() {\r
+               //List<Parameter<?>> params = rnaalifoldOpc.getAllParameters();\r
+               //System.out.println("special: params: " + params);\r
+               \r
+               //List<String> args = rnaalifoldOpc.argumentsToCommandString(params);\r
+               List<String> args = new ArrayList<String>();\r
+               //args.add("-T 37"); args.add("-S 1.07"); args.add("--stochBT_en 10");\r
+               // replace "=" with " " to fail test\r
+               args.add("--MEA=1");\r
+               args.add("-p");\r
+               singleTest(args);\r
+               \r
+       }\r
+       \r
+       void singleTest(List<String> params) {\r
+               try {\r
+                       log.info("Using arguments: " + params);\r
+                       RNAalifold rnaalifold = new RNAalifold();\r
+                       rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile);\r
+                       \r
+                       ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator\r
+                                       .configureExecutable(rnaalifold, ExecProvider.Local);\r
+                       // Add options to the executable\r
+                       confRNAalifold.addParameters(params);\r
+                       LocalRunner lr = new LocalRunner(confRNAalifold);\r
+                       lr.executeJob();\r
+                       confRNAalifold = (ConfiguredExecutable<RNAalifold>) lr.waitForResult();\r
+                       assertNotNull(confRNAalifold.getResults(), "results is null");\r
+                       \r
+                       System.out.println("Results: \n" \r
+                       + ((RNAStructScoreManager) confRNAalifold.getResults()).toString());\r
+                       \r
+                       File errors = new File(confRNAalifold.getWorkDirectory(),\r
+                                       ExecutableWrapper.PROC_ERR_FILE);\r
+                       if (errors.length() != 0) {\r
+                               log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors));\r
+                       }\r
+                       assertTrue(errors.length() == 0, "Run with arguments : " + params\r
+                                       + " FAILED!");\r
+                       Collections.shuffle(params);\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (IOException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
+       }\r
+       \r
+       /* A version of singleTest that continues running instead of calling\r
+        * fail() when it encounters a problem\r
+        * \r
+        * Used to identify incompatible options and parameters\r
+        * returns -1 on failure\r
+        * \r
+        * Bad Progamming practice? \r
+        */\r
+       \r
+       \r
+       boolean singleRun(List<String> params) throws JobSubmissionException,\r
+                       JobExecutionException, IOException, ResultNotAvailableException {\r
+               boolean fail = true;\r
+               log.info("Using arguments: " + params);\r
+               RNAalifold rnaalifold = new RNAalifold();\r
+               rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile);\r
+\r
+               ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator\r
+                               .configureExecutable(rnaalifold, ExecProvider.Local);\r
+               // Add options to the executable\r
+               confRNAalifold.addParameters(params);\r
+               LocalRunner lr = new LocalRunner(confRNAalifold);\r
+               lr.executeJob();\r
+               confRNAalifold = (ConfiguredExecutable<RNAalifold>) lr.waitForResult();\r
+               \r
+               System.out.println("Results: \n" \r
+                               + ((RNAStructScoreManager) confRNAalifold.getResults()).toString());\r
+               if (confRNAalifold.getResults() != null) fail = false;\r
+               File errors = new File(confRNAalifold.getWorkDirectory(),\r
+                               ExecutableWrapper.PROC_ERR_FILE);\r
+               if (errors.length() != 0) {\r
+                       log.error("PROBLEMS:\n " + FileUtil.readFileToString(errors));\r
+               }\r
+               assertTrue(errors.length() == 0, "Run with arguments : " + params\r
+                               + " FAILED!");\r
+               Collections.shuffle(params);\r
+               return fail;\r
+               }\r
+}\r
index 4f5b508..0249215 100644 (file)
-package compbio.runner.structure;
-
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.text.ParseException;
-
-import javax.xml.bind.ValidationException;
-
-import org.apache.log4j.*;
-import org.ggf.drmaa.DrmaaException;
-import org.ggf.drmaa.JobInfo;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import compbio.data.sequence.Score;
-import compbio.data.sequence.ScoreManager;
-import compbio.data.sequence.ScoreManager.ScoreHolder;
-import compbio.data.sequence.SequenceUtil;
-import compbio.engine.AsyncExecutor;
-import compbio.engine.Configurator;
-import compbio.engine.SyncExecutor;
-import compbio.engine.client.ConfExecutable;
-import compbio.engine.client.ConfiguredExecutable;
-import compbio.engine.client.Executable;
-import compbio.engine.client.RunConfiguration;
-import compbio.engine.cluster.drmaa.ClusterUtil;
-import compbio.engine.cluster.drmaa.JobRunner;
-import compbio.engine.cluster.drmaa.StatisticManager;
-import compbio.engine.local.AsyncLocalRunner;
-import compbio.engine.local.LocalExecutorService;
-import compbio.engine.local.LocalRunner;
-import compbio.metadata.AllTestSuit;
-import compbio.metadata.JobExecutionException;
-import compbio.metadata.JobStatus;
-import compbio.metadata.JobSubmissionException;
-import compbio.metadata.LimitsManager;
-import compbio.metadata.PresetManager;
-import compbio.metadata.ResultNotAvailableException;
-import compbio.metadata.RunnerConfig;
-import compbio.runner.msa.ClustalW;
-import compbio.runner.structure.RNAalifold;
-
-public class RNAalifoldTester {
-
-       private static Logger log = Logger
-                       .getLogger(AllTestSuit.RUNNER_TEST_LOGGER);
-       
-       
-       private RNAalifold rnaalifold;
-       
-       static final String rnaalifoldConfigFile = AllTestSuit.TEST_DATA_PATH
-                       + "RNAalifoldParameters.xml";
-       public static String test_outfile = "rnaalifold.out";
-       
-       
-       @Test(groups = { AllTestSuit.test_group_runner })
-       public void testRunLocally() {
-               RNAalifold rnaalifold = new RNAalifold();
-               rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile);
-               try{
-                       
-                       ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator
-                                       .configureExecutable(rnaalifold, Executable.ExecProvider.Local);
-                       LocalRunner lr = new LocalRunner(confRNAalifold);
-                       lr.executeJob();
-                       confRNAalifold = (ConfiguredExecutable<RNAalifold>) lr.waitForResult();
-                       
-                       System.out.println("TEST");
-                       System.out.println(((ScoreManager) confRNAalifold.getResults()).asRNAStruct().toString());
-                       
-                       assertNotNull(confRNAalifold.getResults()); 
-               } catch (JobSubmissionException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               } catch (JobExecutionException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               } catch (ResultNotAvailableException e) {
-                       e.printStackTrace();
-                       fail(e.getLocalizedMessage());
-               }
-       }
-       
-       
-       public static void main(String[] args) throws JobSubmissionException,
-                       JobExecutionException, InterruptedException, ResultNotAvailableException {
-
-               
-               log.warn("Logger test :- Run RNAalifold.main()");
-
-               RNAalifold rnaalifold = new RNAalifold();
-               rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput("test_outfile.txt");
-               
-               ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator
-                                       .configureExecutable(rnaalifold);
-               AsyncExecutor lr = new AsyncLocalRunner();
-               lr.submitJob(confRNAalifold);
-               
-               
-               System.out.println(((ScoreManager) confRNAalifold.getResults()).asRNAStruct().toString());
-
-               
-               Thread.sleep(3000);
-               LocalExecutorService.shutDown();
-               
-       }
-       
-}
+package compbio.runner.structure;\r
+\r
+\r
+import static org.testng.Assert.assertEquals;\r
+import static org.testng.Assert.assertFalse;\r
+import static org.testng.Assert.assertNotNull;\r
+import static org.testng.Assert.assertNull;\r
+import static org.testng.Assert.assertTrue;\r
+import static org.testng.Assert.fail;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.text.ParseException;\r
+\r
+import javax.xml.bind.ValidationException;\r
+\r
+import org.apache.log4j.*;\r
+import org.ggf.drmaa.DrmaaException;\r
+import org.ggf.drmaa.JobInfo;\r
+import org.testng.annotations.BeforeMethod;\r
+import org.testng.annotations.Test;\r
+\r
+import compbio.data.sequence.RNAStructScoreManager;\r
+import compbio.data.sequence.Score;\r
+import compbio.data.sequence.ScoreManager;\r
+import compbio.data.sequence.ScoreManager.ScoreHolder;\r
+import compbio.data.sequence.SequenceUtil;\r
+import compbio.engine.AsyncExecutor;\r
+import compbio.engine.Configurator;\r
+import compbio.engine.SyncExecutor;\r
+import compbio.engine.client.ConfExecutable;\r
+import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.engine.client.Executable;\r
+import compbio.engine.client.RunConfiguration;\r
+import compbio.engine.cluster.drmaa.ClusterUtil;\r
+import compbio.engine.cluster.drmaa.JobRunner;\r
+import compbio.engine.cluster.drmaa.StatisticManager;\r
+import compbio.engine.local.AsyncLocalRunner;\r
+import compbio.engine.local.LocalExecutorService;\r
+import compbio.engine.local.LocalRunner;\r
+import compbio.metadata.AllTestSuit;\r
+import compbio.metadata.JobExecutionException;\r
+import compbio.metadata.JobStatus;\r
+import compbio.metadata.JobSubmissionException;\r
+import compbio.metadata.LimitsManager;\r
+import compbio.metadata.PresetManager;\r
+import compbio.metadata.ResultNotAvailableException;\r
+import compbio.metadata.RunnerConfig;\r
+import compbio.runner.msa.ClustalW;\r
+import compbio.runner.structure.RNAalifold;\r
+\r
+public class RNAalifoldTester {\r
+\r
+       private static Logger log = Logger\r
+                       .getLogger(AllTestSuit.RUNNER_TEST_LOGGER);\r
+       \r
+       \r
+       private RNAalifold rnaalifold;\r
+       \r
+       static final String rnaalifoldConfigFile = AllTestSuit.TEST_DATA_PATH\r
+                       + "RNAalifoldParameters.xml";\r
+       public static String test_outfile = "rnaalifold.out";\r
+       \r
+       \r
+       @Test(groups = { AllTestSuit.test_group_runner })\r
+       public void testRunLocally() {\r
+               RNAalifold rnaalifold = new RNAalifold();\r
+               rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput(test_outfile);\r
+               try{\r
+                       \r
+                       ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator\r
+                                       .configureExecutable(rnaalifold, Executable.ExecProvider.Local);\r
+                       LocalRunner lr = new LocalRunner(confRNAalifold);\r
+                       lr.executeJob();\r
+                       confRNAalifold = (ConfiguredExecutable<RNAalifold>) lr.waitForResult();\r
+                       \r
+                       System.out.println("TEST");\r
+                       System.out.println(((RNAStructScoreManager) confRNAalifold.getResults()).toString());\r
+                       \r
+                       assertNotNull(confRNAalifold.getResults()); \r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (JobExecutionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getLocalizedMessage());\r
+               }\r
+       }\r
+       \r
+       \r
+       public static void main(String[] args) throws JobSubmissionException,\r
+                       JobExecutionException, InterruptedException, ResultNotAvailableException {\r
+\r
+               \r
+               log.warn("Logger test :- Run RNAalifold.main()");\r
+\r
+               RNAalifold rnaalifold = new RNAalifold();\r
+               rnaalifold.setInput(AllTestSuit.test_input_aln).setOutput("test_outfile.txt");\r
+               \r
+               ConfiguredExecutable<RNAalifold> confRNAalifold = Configurator\r
+                                       .configureExecutable(rnaalifold);\r
+               AsyncExecutor lr = new AsyncLocalRunner();\r
+               lr.submitJob(confRNAalifold);\r
+               \r
+               \r
+               System.out.println(((RNAStructScoreManager) confRNAalifold.getResults()).toString());\r
+\r
+               \r
+               Thread.sleep(3000);\r
+               LocalExecutorService.shutDown();\r
+               \r
+       }\r
+       \r
+}\r
index c5f3f6d..7a844ea 100644 (file)
-       package compbio.ws.client;
-
-import compbio.metadata.AllTestSuit;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.ConnectException;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.ws.WebServiceException;
-
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import compbio.data.msa.FoldWS;
-import compbio.data.msa.JABAService;
-import compbio.data.msa.SequenceAnnotation;
-import compbio.data.sequence.Alignment;
-import compbio.data.sequence.RNAStruct;
-import compbio.data.sequence.ClustalAlignmentUtil;
-import compbio.data.sequence.ConservationMethod;
-import compbio.data.sequence.FastaSequence;
-import compbio.data.sequence.ScoreManager;
-import compbio.data.sequence.SequenceUtil;
-import compbio.data.sequence.UnknownFileFormatException;
-import compbio.metadata.AllTestSuit;
-import compbio.metadata.JobSubmissionException;
-import compbio.metadata.LimitExceededException;
-import compbio.metadata.Option;
-import compbio.metadata.PresetManager;
-import compbio.metadata.ResultNotAvailableException;
-import compbio.metadata.RunnerConfig;
-import compbio.metadata.UnsupportedRuntimeException;
-import compbio.metadata.WrongParameterException;
-import compbio.runner.conservation.AACon;
-import compbio.util.SysPrefs;
-import compbio.ws.server.RNAalifoldWS;
-
-
-public class TestRNAalifoldWS {
-       
-       SequenceAnnotation<RNAalifoldWS> foldws;
-       
-       @BeforeTest(groups = {AllTestSuit.test_group_webservices})
-       void initConnection() {
-               
-               try {
-                       JABAService client = Jws2Client.connect(
-                                       "http://localhost:8080/jabaws", Services.RNAalifoldWS);
-                       foldws = (SequenceAnnotation<RNAalifoldWS>) client;
-               } catch (ConnectException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } catch (WebServiceException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               }
-       }
-
-       
-       @Test(groups = {AllTestSuit.test_group_webservices})
-       public void testFold() throws FileNotFoundException, IOException,
-                       UnknownFileFormatException {
-               
-//             String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
-//                             + File.separator;
-               
-               Alignment aln = ClustalAlignmentUtil.readClustalFile(new FileInputStream(
-                               AllTestSuit.test_input_aln));
-               
-               List<FastaSequence> fsl = aln.getSequences();
-               
-               try {
-                       List<Option<RNAalifoldWS>> options  = new ArrayList<Option<RNAalifoldWS>>();
-                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("--mis"));
-                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("-p"));
-                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("--MEA"));
-                       
-                       System.out.println("TestRNAalifoldWS: print options: " + options.toString());
-                       
-                       String jobId = foldws.customAnalize(fsl, options);
-                       System.out.println("J: " + jobId);
-                       ScoreManager result = foldws.getAnnotation(jobId);
-                       System.out.println("fold results: \n" + result.asRNAStruct().toString());
-                       assertNotNull(result);
-                       
-               } catch (UnsupportedRuntimeException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } catch (LimitExceededException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } catch (JobSubmissionException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } catch (ResultNotAvailableException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               } catch (WrongParameterException e) {
-                       e.printStackTrace();
-                       fail(e.getMessage());
-               }
-       }
-}
-       
-
-
+       package compbio.ws.client;\r
+\r
+import static org.testng.Assert.assertNotNull;\r
+import static org.testng.Assert.fail;\r
+\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.io.IOException;\r
+import java.io.OutputStreamWriter;\r
+import java.io.Writer;\r
+import java.net.ConnectException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import javax.xml.ws.WebServiceException;\r
+\r
+import org.testng.annotations.BeforeTest;\r
+import org.testng.annotations.Test;\r
+\r
+import compbio.data.msa.JABAService;\r
+import compbio.data.msa.SequenceAnnotation;\r
+import compbio.data.sequence.Alignment;\r
+import compbio.data.sequence.ClustalAlignmentUtil;\r
+import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.RNAStructScoreManager;\r
+import compbio.data.sequence.ScoreManager;\r
+import compbio.data.sequence.UnknownFileFormatException;\r
+import compbio.metadata.AllTestSuit;\r
+import compbio.metadata.JobSubmissionException;\r
+import compbio.metadata.LimitExceededException;\r
+import compbio.metadata.Option;\r
+import compbio.metadata.ResultNotAvailableException;\r
+import compbio.metadata.UnsupportedRuntimeException;\r
+import compbio.metadata.WrongParameterException;\r
+import compbio.runner.structure.RNAalifold;\r
+import compbio.ws.server.RNAalifoldWS;\r
+\r
+\r
+public class TestRNAalifoldWS {\r
+       \r
+//     SequenceAnnotation<RNAalifoldWS> foldws;\r
+       RNAalifoldWS foldws;\r
+       \r
+       @BeforeTest(groups = {AllTestSuit.test_group_webservices})\r
+       void initConnection() {\r
+               \r
+               try {\r
+                       JABAService client = Jws2Client.connect(\r
+                                       "http://localhost:8080/jabaws", Services.RNAalifoldWS);\r
+                       foldws = (RNAalifoldWS) client;\r
+               } catch (ConnectException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (WebServiceException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               }\r
+       }\r
+\r
+       \r
+       @Test(groups = {AllTestSuit.test_group_webservices})\r
+       public void testFold() throws FileNotFoundException, IOException,\r
+                       UnknownFileFormatException {\r
+               \r
+//             String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()\r
+//                             + File.separator;\r
+               \r
+               Alignment aln = ClustalAlignmentUtil.readClustalFile(new FileInputStream(\r
+                               AllTestSuit.test_input_aln));\r
+               \r
+               List<FastaSequence> fsl = aln.getSequences();\r
+               \r
+               try {\r
+                       List<Option<RNAalifold>> options  = new ArrayList<Option<RNAalifold>>();\r
+                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("--mis"));\r
+                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("-p"));\r
+                       options.add(foldws.getRunnerOptions().getArgumentByOptionName("--MEA"));\r
+                       \r
+//                     System.out.println("TestRNAalifoldWS: print options: " + options.toString());\r
+                       \r
+                       String jobId = foldws.customAnalize(fsl, options);\r
+                       System.out.println("J: " + jobId);\r
+                       \r
+                       Writer stdout = new OutputStreamWriter(System.out);\r
+                       \r
+                       System.out.println("results class: " + foldws.getAnnotation(jobId).getClass().getName());\r
+                       RNAStructScoreManager result = (RNAStructScoreManager)foldws.getAnnotation(jobId);\r
+                       \r
+                       \r
+                       result.writeOut(stdout);\r
+                       System.out.println("fold results: \n" + result.toString());\r
+                       assertNotNull(result);\r
+                       \r
+               } catch (UnsupportedRuntimeException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (LimitExceededException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (JobSubmissionException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (ResultNotAvailableException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               } catch (WrongParameterException e) {\r
+                       e.printStackTrace();\r
+                       fail(e.getMessage());\r
+               }\r
+       }\r
+}\r
+       \r
+\r
+\r
index 34f0aaf..beca1dc 100644 (file)
@@ -1,66 +1,83 @@
-package compbio.ws.server;
-
-import java.io.File;
-import java.util.List;
-
-import javax.jws.WebParam;
-import javax.jws.WebService;
-
-import org.apache.log4j.Logger;
-
-import compbio.data.msa.FoldWS;
-import compbio.data.msa.JABAService;
-import compbio.data.msa.JManagement;
-import compbio.data.msa.Metadata;
-import compbio.data.msa.SequenceAnnotation;
-import compbio.data.sequence.Alignment;
-import compbio.data.sequence.RNAStruct;
-import compbio.data.sequence.FastaSequence;
-import compbio.engine.AsyncExecutor;
-import compbio.engine.Configurator;
-import compbio.engine.client.ConfiguredExecutable;
-import compbio.engine.client.SkeletalExecutable;
-import compbio.metadata.ChunkHolder;
-import compbio.metadata.JobStatus;
-import compbio.metadata.JobSubmissionException;
-import compbio.metadata.Limit;
-import compbio.metadata.LimitExceededException;
-import compbio.metadata.LimitsManager;
-import compbio.metadata.Option;
-import compbio.metadata.Preset;
-import compbio.metadata.PresetManager;
-import compbio.metadata.ResultNotAvailableException;
-import compbio.metadata.RunnerConfig;
-import compbio.metadata.UnsupportedRuntimeException;
-import compbio.metadata.WrongParameterException;
-import compbio.runner.Util;
-import compbio.runner.disorder.GlobPlot;
-import compbio.runner.structure.RNAalifold;
-
-@WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "RNAalifoldWS")
-public class RNAalifoldWS extends SequenceAnnotationService<RNAalifold> 
-               implements
-                       SequenceAnnotation<RNAalifold> {
-
-       private static Logger log = Logger.getLogger(ClustalWS.class);
-       
-       public RNAalifoldWS() {
-               super (new RNAalifold(), log);
-       }
-
-
-       /*
-        * No presets are supported, thus the result of this call will be as simple
-        * call to analize without parameters
-        */
-       @Override
-       public String presetAnalize(List<FastaSequence> sequences,
-                       Preset<RNAalifold> preset) throws UnsupportedRuntimeException,
-                       LimitExceededException, JobSubmissionException,
-                       WrongParameterException {
-
-               return analize(sequences);
-       }
-}
-       
-       
+package compbio.ws.server;\r
+\r
+import java.util.List;\r
+\r
+import javax.jws.WebService;\r
+\r
+import org.apache.log4j.Logger;\r
+\r
+import compbio.data.msa.JABAService;\r
+import compbio.data.msa.SequenceAnnotation;\r
+import compbio.data.sequence.FastaSequence;\r
+import compbio.data.sequence.RNAStructScoreManager;\r
+import compbio.engine.client.ConfiguredExecutable;\r
+import compbio.metadata.JobSubmissionException;\r
+import compbio.metadata.LimitExceededException;\r
+import compbio.metadata.Option;\r
+import compbio.metadata.Preset;\r
+import compbio.metadata.ResultNotAvailableException;\r
+import compbio.metadata.UnsupportedRuntimeException;\r
+import compbio.metadata.WrongParameterException;\r
+import compbio.runner.conservation.AACon;\r
+import compbio.runner.structure.RNAalifold;\r
+\r
+@WebService(endpointInterface = "compbio.data.msa.SequenceAnnotation", targetNamespace = JABAService.V2_SERVICE_NAMESPACE, serviceName = "RNAalifoldWS")\r
+public class RNAalifoldWS extends SequenceAnnotationService<RNAalifold> \r
+               implements\r
+                       SequenceAnnotation<RNAalifold> {\r
+\r
+       private static Logger log = Logger.getLogger(RNAalifoldWS.class);\r
+       \r
+       public RNAalifoldWS() {\r
+               super (new RNAalifold(), log);\r
+       }\r
+\r
+       \r
+       // for testing\r
+       @Override\r
+       public RNAStructScoreManager getAnnotation(String jobId) \r
+                       throws ResultNotAvailableException {\r
+               return WSUtil.getAnnotation(jobId, log);\r
+       }\r
+       \r
+       @Override\r
+       public String analize(List<FastaSequence> sequences)\r
+                       throws UnsupportedRuntimeException, LimitExceededException,\r
+                       JobSubmissionException {\r
+               WSUtil.validateFastaInput(sequences);\r
+               ConfiguredExecutable<RNAalifoldWS> confRNAalifold = init(sequences);\r
+               return WSUtil.fold(sequences, confRNAalifold, log, "analize",\r
+                               getLimit(""));\r
+       }\r
+\r
+       @Override\r
+       public String customAnalize(List<FastaSequence> sequences,\r
+                       List<Option<RNAalifold>> options) throws UnsupportedRuntimeException,\r
+                       LimitExceededException, JobSubmissionException,\r
+                       WrongParameterException {\r
+               WSUtil.validateFastaInput(sequences);\r
+               ConfiguredExecutable<RNAalifold> confRNAalifold = init(sequences);\r
+               \r
+               List<String> params = WSUtil.getCommands(options,\r
+                               AACon.KEY_VALUE_SEPARATOR);\r
+               confRNAalifold.addParameters(params);\r
+               return WSUtil.fold(sequences, confRNAalifold, log, "customAnalize",\r
+                               getLimit(""));\r
+       }\r
+       \r
+       \r
+       /*\r
+        * No presets are supported, thus the result of this call will be as simple\r
+        * call to analize without parameters\r
+        */\r
+       @Override\r
+       public String presetAnalize(List<FastaSequence> sequences,\r
+                       Preset<RNAalifold> preset) throws UnsupportedRuntimeException,\r
+                       LimitExceededException, JobSubmissionException,\r
+                       WrongParameterException {\r
+\r
+               return analize(sequences);\r
+       }\r
+}\r
+       \r
+       \r