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);
36 public RNAalifold setOutput(String outFile) {
37 log.info("Set ouput file: " + outFile.toString());
38 super.setOutput(outFile);
43 public RNAalifold setInput(String inFile) {
44 log.info("Set input file: " + inFile.toString());
45 cbuilder.setLast(inFile);
46 super.setInput(inFile);
50 @SuppressWarnings("unchecked")
52 public Class<RNAalifold> getType() {
53 return (Class<RNAalifold>) this.getClass();
56 @SuppressWarnings("unchecked")
59 public RNAstruct getResults(String workDirectory)
60 throws ResultNotAvailableException {
62 // System.out.println("Specialread " + Util.readRNAStructFile(workDirectory, getOutput()).toString());
63 return Util.readRNAStructFile(workDirectory, getOutput());
65 } catch (FileNotFoundException e) {
66 log.error(e.getMessage(), e.getCause());
67 throw new ResultNotAvailableException(e);
68 } catch (IOException e) {
69 log.error(e.getMessage(), e.getCause());
70 throw new ResultNotAvailableException(e);
75 // OLD :- the new methods for reading are found in
76 // - compbio.data.sequence.SequenceUtil and
77 // - compbio.runner.Util
79 // Simple and generic methods for reading a whole file
80 // Should surfice until a more detailed datamodel and parser are developed
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";