Bugfix for doNotWriteGenotypes mode

-- Was outputing GT ./. in sites only mode.  Fixed
This commit is contained in:
Mark DePristo 2012-05-17 13:20:16 -04:00
parent 64d4238e2f
commit d52bc31a47
2 changed files with 11 additions and 10 deletions

View File

@ -62,8 +62,6 @@ class BCF2Writer extends IndexingVariantContextWriter {
@Override
public void writeHeader(final VCFHeader header) {
this.header = header;
// create the config offsets map
for ( final VCFContigHeaderLine contig : header.getContigLines())
contigDictionary.put(contig.getID(), contig.getContigIndex());
@ -78,7 +76,7 @@ class BCF2Writer extends IndexingVariantContextWriter {
// write out the header into a byte stream, get it's length, and write everything to the file
final ByteArrayOutputStream capture = new ByteArrayOutputStream();
final OutputStreamWriter writer = new OutputStreamWriter(capture);
VCFWriter.writeHeader(header, writer, doNotWriteGenotypes, VCFWriter.getVersionLine(), "BCF2 stream");
this.header = VCFWriter.writeHeader(header, writer, doNotWriteGenotypes, VCFWriter.getVersionLine(), "BCF2 stream");
writer.append('\0'); // the header is null terminated by a byte
writer.close();

View File

@ -90,8 +90,9 @@ class VCFWriter extends IndexingVariantContextWriter {
@Override
public void writeHeader(VCFHeader header) {
mHeader = header;
writeHeader(mHeader, mWriter, doNotWriteGenotypes, getVersionLine(), getStreamName());
// note we need to update the mHeader object after this call because they header
// may have genotypes trimmed out of it, if doNotWriteGenotypes is true
mHeader = writeHeader(header, mWriter, doNotWriteGenotypes, getVersionLine(), getStreamName());
// determine if we use filters, so we should FORCE pass the records
// TODO -- this might not be necessary any longer as we have unfiltered, filtered, and PASS VCs
@ -105,11 +106,11 @@ class VCFWriter extends IndexingVariantContextWriter {
return VERSION_LINE;
}
public static void writeHeader(VCFHeader header,
final Writer writer,
final boolean doNotWriteGenotypes,
final String versionLine,
final String streamNameForError) {
public static VCFHeader writeHeader(VCFHeader header,
final Writer writer,
final boolean doNotWriteGenotypes,
final String versionLine,
final String streamNameForError) {
header = doNotWriteGenotypes ? new VCFHeader(header.getMetaData()) : header;
try {
@ -151,6 +152,8 @@ class VCFWriter extends IndexingVariantContextWriter {
catch (IOException e) {
throw new ReviewedStingException("IOException writing the VCF header to " + streamNameForError, e);
}
return header;
}
/**