X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=runner%2Fcompbio%2Frunner%2FUtil.java;h=f033bf01d616434001a3225f990d5d25ac478627;hb=a966c1a63f4365f34a0567514dee6d1bc4d3af91;hp=8d778644f8f3e5f9431a4649c5c398e5c76f6763;hpb=c97b1954611988b2b1d2e9aeec6e4b0696a0ab66;p=jabaws.git diff --git a/runner/compbio/runner/Util.java b/runner/compbio/runner/Util.java index 8d77864..f033bf0 100644 --- a/runner/compbio/runner/Util.java +++ b/runner/compbio/runner/Util.java @@ -19,6 +19,7 @@ package compbio.runner; import java.io.File; +import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; @@ -30,6 +31,7 @@ import org.apache.log4j.Logger; import compbio.data.sequence.Alignment; import compbio.data.sequence.ClustalAlignmentUtil; import compbio.data.sequence.FastaSequence; +import compbio.data.sequence.RNAstruct; import compbio.data.sequence.Score; import compbio.data.sequence.SequenceUtil; import compbio.data.sequence.UnknownFileFormatException; @@ -130,5 +132,41 @@ public final class Util { + e.getLocalizedMessage(), e); } } + + public static void writeClustalInput(List sequences, + ConfiguredExecutable exec, char gapChar) throws JobSubmissionException { + + try { + File filein = new File(exec.getInput()); + FileOutputStream fout = new FileOutputStream(filein); + log.debug("File path: " + filein.getAbsolutePath()); + SequenceUtil.writeClustal(fout, sequences, gapChar); + fout.close(); + } catch (IOException e) { + log.error("IOException while writing input file into the disk: " + + e.getLocalizedMessage(), e); + throw new JobSubmissionException( + "We are sorry but JABAWS server seems to have a problem! " + + e.getLocalizedMessage(), e); + } + } + + public static final RNAstruct readRNAStructFile(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 compbio.data.sequence.SequenceUtil.readRNAalifoldResults( + new FileInputStream(sfile)); + } + + }