1 package compbio.runner.structure;
4 import java.io.FileNotFoundException;
5 import java.io.IOException;
6 import java.util.Arrays;
9 //imports for filereader method
10 import java.io.FileReader;
11 import java.io.BufferedReader;
16 import org.apache.log4j.Logger;
18 import compbio.data.sequence.RNAstruct;
19 import compbio.data.sequence.UnknownFileFormatException;
20 import compbio.engine.client.PipedExecutable;
21 import compbio.engine.client.SkeletalExecutable;
22 import compbio.metadata.ResultNotAvailableException;
23 import compbio.runner.Util;
26 import compbio.engine.client.CommandBuilder;
28 public class RNAalifold extends SkeletalExecutable<RNAalifold>
29 implements PipedExecutable<RNAalifold> {
32 private static Logger log = Logger.getLogger(RNAalifold.class);
34 // May not be necessary as defult is "<space>" but still dont know
35 // How to deal with different key value separators for different params
36 public static final String KEY_VALUE_SEPARATOR = " ";
39 super(KEY_VALUE_SEPARATOR);
43 public RNAalifold setOutput(String outFile) {
44 super.setOutput(outFile);
49 public RNAalifold setInput(String inFile) {
50 cbuilder.setLast(inFile);
51 super.setInput(inFile);
55 @SuppressWarnings("unchecked")
57 public Class<RNAalifold> getType() {
58 return (Class<RNAalifold>) this.getClass();
61 @SuppressWarnings("unchecked")
64 public RNAstruct getResults(String workDirectory)
65 throws ResultNotAvailableException {
67 // System.out.println("Specialread " + Util.readRNAStructFile(workDirectory, getOutput()).toString());
68 return Util.readRNAStructFile(workDirectory, getOutput());
70 } catch (FileNotFoundException e) {
71 log.error(e.getMessage(), e.getCause());
72 throw new ResultNotAvailableException(e);
73 } catch (IOException e) {
74 log.error(e.getMessage(), e.getCause());
75 throw new ResultNotAvailableException(e);
80 // the new currently used methods for reading are found in
81 // - compbio.data.sequence.SequenceUtil and
82 // - compbio.runner.Util
84 // Simple and generic methods for reading a whole file
85 // private static String readRNAStruct(String workDirectory,
86 // String structFile) throws IOException, FileNotFoundException {
87 // assert !compbio.util.Util.isEmpty(workDirectory);
88 // assert !compbio.util.Util.isEmpty(structFile);
89 // File sfile = new File(compbio.engine.client.Util.getFullPath(
90 // workDirectory, structFile));
91 // log.trace("RNAALIFOLD OUTPUT FILE PATH: " + sfile.getAbsolutePath());
92 // if(!(sfile.exists() && sfile.length() > 0)) {
93 // throw new FileNotFoundException("Result for the jobId "
94 // + workDirectory + "with file name " + structFile
95 // + " is not found!");
97 // return readFile(sfile);
100 // private static BufferedReader input;
101 // public static String readFile(File inputFile) throws
102 // FileNotFoundException, IOException {
104 // input = new BufferedReader(new FileReader(inputFile));
106 // String file = new String();
107 // String line = new String();
110 // line = input.readLine();
112 // if (line != null) {
113 // file = file + line + "\r\n";