diff --git a/java/src/org/broadinstitute/sting/gatk/io/storage/VCFWriterStorage.java b/java/src/org/broadinstitute/sting/gatk/io/storage/VCFWriterStorage.java index d1f8edbbf..51a8e424f 100644 --- a/java/src/org/broadinstitute/sting/gatk/io/storage/VCFWriterStorage.java +++ b/java/src/org/broadinstitute/sting/gatk/io/storage/VCFWriterStorage.java @@ -6,11 +6,9 @@ import org.broad.tribble.vcf.VCFHeaderLine; import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFWriter; import org.broadinstitute.sting.utils.StingException; -import org.broadinstitute.sting.utils.SampleUtils; import org.broadinstitute.sting.gatk.io.stubs.VCFWriterStub; import java.io.*; -import java.util.Set; import net.sf.samtools.util.BlockCompressedOutputStream; @@ -68,8 +66,7 @@ public class VCFWriterStorage implements Storage, VCFWriter { throw new StingException("Unable to open target output stream",ex); } writer = new StandardVCFWriter(this.stream); - Set samples = SampleUtils.getSAMFileSamples(stub.getSAMFileHeader()); - writer.writeHeader(new VCFHeader(null, samples)); + writer.writeHeader(stub.getVCFHeader()); } public void add(VariantContext vc, byte ref) { @@ -109,7 +106,7 @@ public class VCFWriterStorage implements Storage, VCFWriter { reader.close(); } catch (IOException e) { - throw new StingException("Error reading file " + file + " in GATKVCFWriter: ", e); + throw new StingException("Error reading file " + file + " in VCFWriterStorage: ", e); } } } diff --git a/java/src/org/broadinstitute/sting/gatk/io/stubs/VCFWriterArgumentTypeDescriptor.java b/java/src/org/broadinstitute/sting/gatk/io/stubs/VCFWriterArgumentTypeDescriptor.java index 5d5adda7c..237b3c734 100644 --- a/java/src/org/broadinstitute/sting/gatk/io/stubs/VCFWriterArgumentTypeDescriptor.java +++ b/java/src/org/broadinstitute/sting/gatk/io/stubs/VCFWriterArgumentTypeDescriptor.java @@ -98,7 +98,7 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor { @Override public Object createTypeDefault(ArgumentSource source,Class type) { - VCFWriterStub stub = new VCFWriterStub(engine, defaultOutputStream, false); + VCFWriterStub stub = new VCFWriterStub(defaultOutputStream, false); engine.addOutput(stub); return stub; } @@ -120,7 +120,7 @@ public class VCFWriterArgumentTypeDescriptor extends ArgumentTypeDescriptor { boolean compress = writerFileName != null && SUPPORTED_ZIPPED_SUFFIXES.contains(getFileSuffix(writerFileName)); // Create a stub for the given object. - VCFWriterStub stub = (writerFile != null) ? new VCFWriterStub(engine, writerFile, compress) : new VCFWriterStub(engine, System.out, compress); + VCFWriterStub stub = (writerFile != null) ? new VCFWriterStub(writerFile, compress) : new VCFWriterStub(System.out, compress); // WARNING: Side effects required by engine! parsingEngine.addTags(stub,getArgumentTags(matches)); diff --git a/java/src/org/broadinstitute/sting/gatk/io/stubs/VCFWriterStub.java b/java/src/org/broadinstitute/sting/gatk/io/stubs/VCFWriterStub.java index 1842e3d40..7cc4a77e8 100755 --- a/java/src/org/broadinstitute/sting/gatk/io/stubs/VCFWriterStub.java +++ b/java/src/org/broadinstitute/sting/gatk/io/stubs/VCFWriterStub.java @@ -33,8 +33,6 @@ import org.broad.tribble.util.variantcontext.VariantContext; import org.broad.tribble.vcf.VCFHeader; import org.broad.tribble.vcf.VCFWriter; import org.broadinstitute.sting.gatk.io.OutputTracker; -import org.broadinstitute.sting.gatk.GenomeAnalysisEngine; -import net.sf.samtools.SAMFileHeader; /** * A stub for routing and management of genotype reading and writing. @@ -44,11 +42,6 @@ import net.sf.samtools.SAMFileHeader; */ public class VCFWriterStub implements Stub, VCFWriter { - /** - * Engine to use for collecting attributes for the output SAM file. - */ - private final GenomeAnalysisEngine engine; - /** * The file that this stub should write to. Should be mutually * exclusive with genotypeStream. @@ -61,6 +54,11 @@ public class VCFWriterStub implements Stub, VCFWriter { */ private final PrintStream genotypeStream; + /** + * The cached VCF header (initilized to null) + */ + private VCFHeader vcfHeader = null; + /** * Should we emit a compressed output stream? */ @@ -74,12 +72,10 @@ public class VCFWriterStub implements Stub, VCFWriter { /** * Create a new stub given the requested file. - * @param engine GATK engine. * @param genotypeFile file to (ultimately) create. * @param isCompressed should we compress the output stream? */ - public VCFWriterStub(GenomeAnalysisEngine engine, File genotypeFile, boolean isCompressed) { - this.engine = engine; + public VCFWriterStub(File genotypeFile, boolean isCompressed) { this.genotypeFile = genotypeFile; this.genotypeStream = null; this.isCompressed = isCompressed; @@ -87,12 +83,10 @@ public class VCFWriterStub implements Stub, VCFWriter { /** * Create a new stub given the requested file. - * @param engine GATK engine. * @param genotypeStream stream to (ultimately) write. * @param isCompressed should we compress the output stream? */ - public VCFWriterStub(GenomeAnalysisEngine engine, OutputStream genotypeStream, boolean isCompressed) { - this.engine = engine; + public VCFWriterStub(OutputStream genotypeStream, boolean isCompressed) { this.genotypeFile = null; this.genotypeStream = new PrintStream(genotypeStream); this.isCompressed = isCompressed; @@ -126,8 +120,8 @@ public class VCFWriterStub implements Stub, VCFWriter { * Retrieves the header to use when creating the new file. * @return header to use when creating the new file. */ - public SAMFileHeader getSAMFileHeader() { - return engine.getSAMFileHeader(); + public VCFHeader getVCFHeader() { + return vcfHeader; } /** @@ -139,6 +133,7 @@ public class VCFWriterStub implements Stub, VCFWriter { } public void writeHeader(VCFHeader header) { + vcfHeader = header; outputTracker.getStorage(this).writeHeader(header); }