X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=runner%2Fcompbio%2Frunner%2FUtil.java;h=6f0ec09bc576e9475b53ef88e849460be04e68ff;hb=4b647613e686c4edffd44702d86662c6facb2d5a;hp=c6cb33fc6b71f69dc0ee00d94e00071022725648;hpb=9072bd850138bedbd005509e5b14bb5e104574b4;p=jabaws.git diff --git a/runner/compbio/runner/Util.java b/runner/compbio/runner/Util.java index c6cb33f..6f0ec09 100644 --- a/runner/compbio/runner/Util.java +++ b/runner/compbio/runner/Util.java @@ -25,16 +25,30 @@ import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; +import java.util.Arrays; import java.util.List; +import java.util.ArrayList; import java.util.Map; +import java.util.Set; +import java.util.TreeSet; +import java.util.TreeMap; +import java.util.regex.Pattern; +import java.util.regex.Matcher; +import java.util.Scanner; + + + 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.RNAStructScoreManager; import compbio.data.sequence.Score; +import compbio.data.sequence.ScoreManager; +import compbio.data.sequence.Range; +import compbio.data.sequence.RNAStructReader; import compbio.data.sequence.SequenceUtil; import compbio.data.sequence.UnknownFileFormatException; import compbio.engine.client.ConfExecutable; @@ -152,38 +166,39 @@ public final class Util { + e.getLocalizedMessage(), e); } } + - // OUT OF USE - -// 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)); -// 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)); -// } - - public static String readRNAStruct(String workDirectory, + public static RNAStructScoreManager readRNAStruct(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( + // The stdout from RNAalifold + File sFile = new File(compbio.engine.client.Util.getFullPath( workDirectory, structFile)); - if(!(sfile.exists() && sfile.length() > 0)) { + // Base pair probability matrix (-p option) + File aliFile = new File(compbio.engine.client.Util.getFullPath( + workDirectory, "alifold.out")); + // Check that stdout file exists + if(!(sFile.exists() && sFile.length() > 0)) { throw new FileNotFoundException("Result for the jobId " + workDirectory + "with file name " + structFile + " is not found!"); } - return readFile(sfile); + // Check that base pair probability file exists + if(!aliFile.exists()) { + log.warn("The file alifold.out is not found for the jobId " + + workDirectory + "Is the -p or --MEA option not specified?"); + return RNAStructReader.readRNAStructStream(new FileInputStream(sFile)); + + } else { + return RNAStructReader.readRNAStructStream(new FileInputStream(sFile), + new FileInputStream(aliFile)); + } } + + public static String readFile(File inputFile) throws FileNotFoundException, IOException { @@ -203,7 +218,6 @@ public final class Util { input.close(); return file; } - - - } + +