1 package compbio.runner.structure;
4 import java.io.FileNotFoundException;
5 import java.io.IOException;
6 import java.util.Arrays;
13 import org.apache.log4j.Logger;
15 import compbio.data.sequence.ScoreManager;
16 import compbio.data.sequence.RNAStruct;
17 import compbio.data.sequence.UnknownFileFormatException;
18 import compbio.engine.client.PipedExecutable;
19 import compbio.engine.client.SkeletalExecutable;
20 import compbio.metadata.ResultNotAvailableException;
21 import compbio.runner.Util;
24 import compbio.engine.client.CommandBuilder;
26 public class RNAalifold extends SkeletalExecutable<RNAalifold>
27 implements PipedExecutable<RNAalifold> {
30 private static Logger log = Logger.getLogger(RNAalifold.class);
32 // May not be necessary as defult is "<space>" but still dont know
33 // How to deal with different key value separators for different params
34 public static final String KEY_VALUE_SEPARATOR = " ";
37 super(KEY_VALUE_SEPARATOR);
41 public RNAalifold setOutput(String outFile) {
42 super.setOutput(outFile);
47 public RNAalifold setInput(String inFile) {
48 cbuilder.setLast(inFile);
49 super.setInput(inFile);
53 @SuppressWarnings("unchecked")
55 public Class<RNAalifold> getType() {
56 return (Class<RNAalifold>) this.getClass();
59 @SuppressWarnings("unchecked")
62 public ScoreManager getResults(String workDirectory)
63 throws ResultNotAvailableException {
65 return Util.readRNAStruct(workDirectory, getOutput());
67 } catch (FileNotFoundException e) {
68 log.error(e.getMessage(), e.getCause());
69 throw new ResultNotAvailableException(e);
70 } catch (IOException e) {
71 log.error(e.getMessage(), e.getCause());
72 throw new ResultNotAvailableException(e);
77 // the new currently used methods for reading are found in
78 // - compbio.data.sequence.SequenceUtil and
79 // - compbio.runner.Util
81 // Simple and generic methods for reading a whole file
82 // private static String readRNAStruct(String workDirectory,
83 // String structFile) throws IOException, FileNotFoundException {
84 // assert !compbio.util.Util.isEmpty(workDirectory);
85 // assert !compbio.util.Util.isEmpty(structFile);
86 // File sfile = new File(compbio.engine.client.Util.getFullPath(
87 // workDirectory, structFile));
88 // log.trace("RNAALIFOLD OUTPUT FILE PATH: " + sfile.getAbsolutePath());
89 // if(!(sfile.exists() && sfile.length() > 0)) {
90 // throw new FileNotFoundException("Result for the jobId "
91 // + workDirectory + "with file name " + structFile
92 // + " is not found!");
94 // return readFile(sfile);
97 // private static BufferedReader input;
98 // public static String readFile(File inputFile) throws
99 // FileNotFoundException, IOException {
101 // input = new BufferedReader(new FileReader(inputFile));
103 // String file = new String();
104 // String line = new String();
107 // line = input.readLine();
109 // if (line != null) {
110 // file = file + line + "\r\n";