Clean up logging system
[jabaws.git] / runner / compbio / runner / Util.java
index f033bf0..a0123a2 100644 (file)
@@ -31,28 +31,22 @@ import org.apache.log4j.Logger;
 import compbio.data.sequence.Alignment;\r
 import compbio.data.sequence.ClustalAlignmentUtil;\r
 import compbio.data.sequence.FastaSequence;\r
-import compbio.data.sequence.RNAstruct;\r
+import compbio.data.sequence.RNAStructScoreManager;\r
 import compbio.data.sequence.Score;\r
+import compbio.data.sequence.RNAStructReader;\r
 import compbio.data.sequence.SequenceUtil;\r
 import compbio.data.sequence.UnknownFileFormatException;\r
 import compbio.engine.client.ConfExecutable;\r
 import compbio.engine.client.ConfiguredExecutable;\r
 import compbio.engine.client.Executable;\r
-import compbio.engine.conf.PropertyHelperManager;\r
 import compbio.metadata.JobSubmissionException;\r
 import compbio.metadata.PresetManager;\r
 import compbio.metadata.RunnerConfig;\r
-import compbio.util.PropertyHelper;\r
 \r
 public final class Util {\r
 \r
        public static Logger log = Logger.getLogger(Util.class);\r
 \r
-       private static final PropertyHelper ph = PropertyHelperManager\r
-                       .getPropertyHelper();\r
-\r
-       public static final String SPACE = " ";\r
-\r
        public static synchronized <T> RunnerConfig<T> getSupportedOptions(\r
                        Class<? extends Executable<T>> clazz) {\r
                try {\r
@@ -117,7 +111,6 @@ public final class Util {
 \r
        public static void writeInput(List<FastaSequence> sequences,\r
                        ConfiguredExecutable<?> exec) throws JobSubmissionException {\r
-\r
                try {\r
                        File filein = new File(exec.getInput());\r
                        FileOutputStream fout = new FileOutputStream(filein);\r
@@ -132,7 +125,7 @@ public final class Util {
                                                        + e.getLocalizedMessage(), e);\r
                }\r
        }\r
-       \r
+\r
        public static void writeClustalInput(List<FastaSequence> sequences,\r
                        ConfiguredExecutable<?> exec, char gapChar) throws JobSubmissionException {\r
                \r
@@ -150,23 +143,36 @@ public final class Util {
                                                + e.getLocalizedMessage(), e);\r
                }\r
        }\r
-       \r
-       public static final RNAstruct readRNAStructFile(String workDirectory,\r
+\r
+       public static RNAStructScoreManager readRNAStruct(String workDirectory,\r
                        String structFile) throws IOException, FileNotFoundException {\r
+               \r
                assert !compbio.util.Util.isEmpty(workDirectory);\r
                assert !compbio.util.Util.isEmpty(structFile);\r
-               File sfile = new File(compbio.engine.client.Util.getFullPath(\r
+               // The stdout from RNAalifold\r
+               File sFile = new File(compbio.engine.client.Util.getFullPath(\r
                                workDirectory, structFile));\r
-               log.trace("RNAALIFOLD OUTPUT FILE PATH: " + sfile.getAbsolutePath());\r
-               if(!(sfile.exists() && sfile.length() > 0)) {\r
+               // Base pair probability matrix (-p option)\r
+               File aliFile = new File(compbio.engine.client.Util.getFullPath(\r
+                               workDirectory, "alifold.out"));\r
+               // Check that stdout file exists\r
+               if(!(sFile.exists() && sFile.length() > 0)) {\r
                        throw new FileNotFoundException("Result for the jobId "\r
                                        + workDirectory + "with file name " + structFile\r
                                        + " is not found!");\r
                }\r
-               return compbio.data.sequence.SequenceUtil.readRNAalifoldResults(\r
-                               new FileInputStream(sfile));\r
+               // Check that base pair probability file exists\r
+               if(!aliFile.exists()) {\r
+                       log.warn("The file alifold.out is not found for the jobId "\r
+                                       + workDirectory + "Is the -p or --MEA option not specified?");\r
+                       return RNAStructReader.readRNAStructStream(new FileInputStream(sFile));\r
+                       \r
+               } else {\r
+                       return RNAStructReader.readRNAStructStream(new FileInputStream(sFile), \r
+                                       new FileInputStream(aliFile));\r
+               }\r
        }\r
-       \r
-       \r
 \r
 }\r
+\r
+\r