Fixing up the VCFWriter storage code: instead of assuming all samples are coming from the input bam file (they're not), just use the original VCF header for writing the temporary thread files. Now parallelization in e.g. the Genomic Annotator works.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4168 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
69d92fab4f
commit
3c956110f3
|
|
@ -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<VCFWriterStorage>, VCFWriter {
|
|||
throw new StingException("Unable to open target output stream",ex);
|
||||
}
|
||||
writer = new StandardVCFWriter(this.stream);
|
||||
Set<String> 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<VCFWriterStorage>, 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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>, 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>, 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>, 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>, 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>, 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>, VCFWriter {
|
|||
}
|
||||
|
||||
public void writeHeader(VCFHeader header) {
|
||||
vcfHeader = header;
|
||||
outputTracker.getStorage(this).writeHeader(header);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue