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.RNAstruct;
16 import compbio.data.sequence.UnknownFileFormatException;
17 import compbio.engine.client.PipedExecutable;
18 import compbio.engine.client.SkeletalExecutable;
19 import compbio.metadata.ResultNotAvailableException;
20 import compbio.runner.Util;
23 import compbio.engine.client.CommandBuilder;
25 public class RNAalifold extends SkeletalExecutable<RNAalifold>
26 implements PipedExecutable<RNAalifold> {
29 private static Logger log = Logger.getLogger(RNAalifold.class);
31 // May not be necessary as defult is "<space>" but still dont know
32 // How to deal with different key value separators for different params
33 public static final String KEY_VALUE_SEPARATOR = " ";
36 super(KEY_VALUE_SEPARATOR);
40 public RNAalifold setOutput(String outFile) {
41 super.setOutput(outFile);
46 public RNAalifold setInput(String inFile) {
47 cbuilder.setLast(inFile);
48 super.setInput(inFile);
52 @SuppressWarnings("unchecked")
54 public Class<RNAalifold> getType() {
55 return (Class<RNAalifold>) this.getClass();
58 @SuppressWarnings("unchecked")
61 public String getResults(String workDirectory)
62 throws ResultNotAvailableException {
64 return Util.readRNAStruct(workDirectory, getOutput());
66 } catch (FileNotFoundException e) {
67 log.error(e.getMessage(), e.getCause());
68 throw new ResultNotAvailableException(e);
69 } catch (IOException e) {
70 log.error(e.getMessage(), e.getCause());
71 throw new ResultNotAvailableException(e);
76 // the new currently used methods for reading are found in
77 // - compbio.data.sequence.SequenceUtil and
78 // - compbio.runner.Util
80 // Simple and generic methods for reading a whole file
81 // private static String readRNAStruct(String workDirectory,
82 // String structFile) throws IOException, FileNotFoundException {
83 // assert !compbio.util.Util.isEmpty(workDirectory);
84 // assert !compbio.util.Util.isEmpty(structFile);
85 // File sfile = new File(compbio.engine.client.Util.getFullPath(
86 // workDirectory, structFile));
87 // log.trace("RNAALIFOLD OUTPUT FILE PATH: " + sfile.getAbsolutePath());
88 // if(!(sfile.exists() && sfile.length() > 0)) {
89 // throw new FileNotFoundException("Result for the jobId "
90 // + workDirectory + "with file name " + structFile
91 // + " is not found!");
93 // return readFile(sfile);
96 // private static BufferedReader input;
97 // public static String readFile(File inputFile) throws
98 // FileNotFoundException, IOException {
100 // input = new BufferedReader(new FileReader(inputFile));
102 // String file = new String();
103 // String line = new String();
106 // line = input.readLine();
108 // if (line != null) {
109 // file = file + line + "\r\n";