Simple datamodel for RNAalifold.exe output and method to convert from
[jabaws.git] / runner / compbio / runner / structure / RNAalifold.java
index 4ec1ec7..acb4a9e 100644 (file)
@@ -11,9 +11,11 @@ import java.io.FileReader;
 import java.io.BufferedReader;
 import java.io.File;
 
+
+
 import org.apache.log4j.Logger;
 
-import compbio.data.sequence.Alignment;
+import compbio.data.sequence.RNAstruct;
 import compbio.data.sequence.UnknownFileFormatException;
 import compbio.engine.client.PipedExecutable;
 import compbio.engine.client.SkeletalExecutable;
@@ -54,11 +56,12 @@ public class RNAalifold extends SkeletalExecutable<RNAalifold>
        @SuppressWarnings("unchecked")
        @Override
        // PlaceHolder method
-       public String getResults(String workDirectory)
+       public RNAstruct getResults(String workDirectory)
                        throws ResultNotAvailableException {
                try {
-                       // System.out.print(readRNAStruct(workDirectory, getOutput()));
-                       return readRNAStruct(workDirectory, getOutput());
+                       // System.out.println("Specialread " + Util.readRNAStructFile(workDirectory, getOutput()).toString());
+                       return Util.readRNAStructFile(workDirectory, getOutput());
+                       
                } catch (FileNotFoundException e) {
                        log.error(e.getMessage(), e.getCause());
                        throw new ResultNotAvailableException(e);
@@ -68,43 +71,47 @@ public class RNAalifold extends SkeletalExecutable<RNAalifold>
                }
        }
 
+
+       // OLD :- the new methods for reading are found in 
+       // - compbio.data.sequence.SequenceUtil and 
+       // - compbio.runner.Util
        
        // Simple and generic methods for reading a whole file
        // Should surfice until a more detailed datamodel and parser are developed
-       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;
-       }
+//     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;
+//     }
        
 }