use of ubic.gemma.core.util.concurrent.GenericStreamConsumer in project Gemma by PavlidisLab.
the class RepeatScan method execRepeatMasker.
/**
* Run a gfClient query, using a call to exec().
*
* @param querySequenceFile file
* @param taxon taxon
*/
private void execRepeatMasker(File querySequenceFile, Taxon taxon) throws IOException {
this.checkForExe();
final String cmd = RepeatScan.REPEAT_MASKER + " -parallel 8 -xsmall -species " + taxon.getCommonName() + " " + querySequenceFile.getAbsolutePath();
RepeatScan.log.info("Running repeatmasker like this: " + cmd);
final Process run = Runtime.getRuntime().exec(cmd);
// to ensure that we aren't left waiting for these streams
GenericStreamConsumer gscErr = new GenericStreamConsumer(run.getErrorStream());
GenericStreamConsumer gscIn = new GenericStreamConsumer(run.getInputStream());
gscErr.start();
gscIn.start();
try {
int exitVal = Integer.MIN_VALUE;
// wait...
StopWatch overallWatch = new StopWatch();
overallWatch.start();
while (exitVal == Integer.MIN_VALUE) {
try {
exitVal = run.exitValue();
} catch (IllegalThreadStateException e) {
// okay, still waiting.
}
Thread.sleep(RepeatScan.UPDATE_INTERVAL_MS);
String minutes = TimeUtil.getMinutesElapsed(overallWatch);
RepeatScan.log.info("Repeatmasker: " + minutes + " minutes elapsed");
}
overallWatch.stop();
String minutes = TimeUtil.getMinutesElapsed(overallWatch);
RepeatScan.log.info("Repeatmasker took a total of " + minutes + " minutes");
// int exitVal = run.waitFor();
RepeatScan.log.debug("Repeatmasker exit value=" + exitVal);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
RepeatScan.log.debug("Repeatmasker Success");
}
use of ubic.gemma.core.util.concurrent.GenericStreamConsumer in project Gemma by PavlidisLab.
the class AffyPowerToolsProbesetSummarize method tryRun.
private Collection<RawExpressionDataVector> tryRun(ExpressionExperiment ee, ArrayDesign targetPlatform, Collection<LocalFile> files, Collection<String> accessionsOfInterest, boolean threePrime, String cdfFileName) {
List<String> celFiles = this.getCelFiles(files, accessionsOfInterest);
AffyPowerToolsProbesetSummarize.log.info("Located " + celFiles.size() + " cel files");
String outputPath = this.getOutputFilePath(ee);
String cmd;
if (threePrime) {
cmd = this.getThreePrimeSummarizationCommand(targetPlatform, cdfFileName, celFiles, outputPath);
} else {
cmd = this.getCommand(targetPlatform, celFiles, outputPath);
}
AffyPowerToolsProbesetSummarize.log.info("Running: " + cmd);
int exitVal = Integer.MIN_VALUE;
StopWatch overallWatch = new StopWatch();
overallWatch.start();
try {
final Process run = Runtime.getRuntime().exec(cmd);
GenericStreamConsumer gscErr = new GenericStreamConsumer(run.getErrorStream());
GenericStreamConsumer gscIn = new GenericStreamConsumer(run.getInputStream());
gscErr.start();
gscIn.start();
while (exitVal == Integer.MIN_VALUE) {
try {
exitVal = run.exitValue();
} catch (IllegalThreadStateException e) {
// okay, still waiting.
}
Thread.sleep(AffyPowerToolsProbesetSummarize.AFFY_UPDATE_INTERVAL_MS);
File outputFile = new File(outputPath + File.separator + "apt-probeset-summarize.log");
Long size = outputFile.length();
String minutes = TimeUtil.getMinutesElapsed(overallWatch);
AffyPowerToolsProbesetSummarize.log.info(String.format("apt-probeset-summarize logging output so far: %.2f", size / 1024.0) + " kb (" + minutes + " minutes elapsed)");
}
overallWatch.stop();
String minutes = TimeUtil.getMinutesElapsed(overallWatch);
AffyPowerToolsProbesetSummarize.log.info("apt-probeset-summarize took a total of " + minutes + " minutes");
return this.processData(ee, outputPath + File.separator + AffyPowerToolsProbesetSummarize.METHOD + ".summary.txt", targetPlatform);
} catch (InterruptedException | IOException e) {
throw new RuntimeException(e);
}
}
use of ubic.gemma.core.util.concurrent.GenericStreamConsumer in project Gemma by PavlidisLab.
the class SimpleFastaCmd method getSequencesFromFastaCmdOutput.
private Collection<BioSequence> getSequencesFromFastaCmdOutput(Process pr) throws IOException {
try (final InputStream is = new BufferedInputStream(pr.getInputStream());
InputStream err = pr.getErrorStream()) {
final FastaParser parser = new FastaParser();
ParsingStreamConsumer<BioSequence> sg = new ParsingStreamConsumer<>(parser, is);
GenericStreamConsumer gsc = new GenericStreamConsumer(err);
sg.start();
gsc.start();
try {
int exitVal = pr.waitFor();
// Makes sure results are flushed.
Thread.sleep(200);
SimpleFastaCmd.log.debug(// often nonzero if some sequences are not found.
"fastacmd exit value=" + exitVal);
return parser.getResults();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
use of ubic.gemma.core.util.concurrent.GenericStreamConsumer in project Gemma by PavlidisLab.
the class ShellDelegatingBlat method execGfClient.
/**
* Run a gfClient query, using a call to exec().
*
* @param querySequenceFile query sequence file
* @param outputPath output path
* @return collection of blat results
*/
private Collection<BlatResult> execGfClient(File querySequenceFile, String outputPath, int portToUse) throws IOException {
final String cmd = gfClientExe + " -nohead -minScore=" + ShellDelegatingBlat.MIN_SCORE + " " + host + " " + portToUse + " " + seqDir + " " + querySequenceFile.getAbsolutePath() + " " + outputPath;
ShellDelegatingBlat.log.info(cmd);
final Process run = Runtime.getRuntime().exec(cmd);
// to ensure that we aren't left waiting for these streams
GenericStreamConsumer gscErr = new GenericStreamConsumer(run.getErrorStream());
GenericStreamConsumer gscIn = new GenericStreamConsumer(run.getInputStream());
gscErr.start();
gscIn.start();
try {
int exitVal = Integer.MIN_VALUE;
// wait...
StopWatch overallWatch = new StopWatch();
overallWatch.start();
while (exitVal == Integer.MIN_VALUE) {
try {
exitVal = run.exitValue();
} catch (IllegalThreadStateException e) {
// okay, still
// waiting.
}
Thread.sleep(ShellDelegatingBlat.BLAT_UPDATE_INTERVAL_MS);
// I hope this is okay...
this.outputFile(outputPath, overallWatch);
}
overallWatch.stop();
String minutes = TimeUtil.getMinutesElapsed(overallWatch);
ShellDelegatingBlat.log.info("Blat took a total of " + minutes + " minutes");
// int exitVal = run.waitFor();
ShellDelegatingBlat.log.debug("blat exit value=" + exitVal);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
ShellDelegatingBlat.log.debug("GfClient Success");
return this.processPsl(outputPath, null);
}
Aggregations