From b69eb208a6081a564995920da4560ec4389c987d Mon Sep 17 00:00:00 2001 From: hanna Date: Tue, 15 Sep 2009 17:58:14 +0000 Subject: [PATCH] Always create output files, even if no output was written to them. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1627 348d0f76-0448-11de-a6fe-93d51630548a --- .../executive/HierarchicalMicroScheduler.java | 2 ++ .../gatk/executive/LinearMicroScheduler.java | 2 ++ .../sting/gatk/io/OutputTracker.java | 23 ++++++++++++++----- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java b/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java index e1366e13e..fa9f7a645 100755 --- a/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java +++ b/java/src/org/broadinstitute/sting/gatk/executive/HierarchicalMicroScheduler.java @@ -142,6 +142,8 @@ public class HierarchicalMicroScheduler extends MicroScheduler implements Hierar printOnTraversalDone(result); + getOutputTracker().close(); + return result; } diff --git a/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java b/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java index d525f3b7c..246472358 100644 --- a/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java +++ b/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java @@ -59,6 +59,8 @@ public class LinearMicroScheduler extends MicroScheduler { printOnTraversalDone(result); + getOutputTracker().close(); + return accumulator; } diff --git a/java/src/org/broadinstitute/sting/gatk/io/OutputTracker.java b/java/src/org/broadinstitute/sting/gatk/io/OutputTracker.java index 69a0be1f7..82c587d73 100755 --- a/java/src/org/broadinstitute/sting/gatk/io/OutputTracker.java +++ b/java/src/org/broadinstitute/sting/gatk/io/OutputTracker.java @@ -65,19 +65,16 @@ public abstract class OutputTracker { // Otherwise, initialize them separately. if( outFileName != null && outFileName.equals(errFileName) ) { outStub = errStub = new OutputStreamStub(new File(outFileName)); - outStub.register(this); - outputs.put(outStub,null); + addOutput(outStub); } else { outStub = (outFileName != null) ? new OutputStreamStub(new File(outFileName)) : new OutputStreamStub(System.out); - outStub.register(this); - outputs.put(outStub,null); + addOutput(outStub); errStub = (errFileName != null) ? new OutputStreamStub(new File(errFileName)) : new OutputStreamStub(System.err); - errStub.register(this); - outputs.put(errStub,null); + addOutput(errStub); } } @@ -127,6 +124,20 @@ public abstract class OutputTracker { outputs.put(stub,null); } + /** + * Close down all existing output streams. + */ + public void close() { + for( Stub stub: outputs.keySet() ) { + // If the stream hasn't yet been created, create it so that there's at least an empty file present. + if( outputs.get(stub) == null ) + getTargetStream(stub); + + // Close down the storage. + outputs.get(stub).close(); + } + } + /** * Collects the target stream for this data. * @param stub The stub for this stream.