@Hidden --also_generate_bcf engine argument produces both VCF and BCF files for -o my.vcf
-- Going to be useful going forward for integration tests so they will generate both VCF and BCF files automatically
This commit is contained in:
parent
bb0d87666a
commit
4846bf5c8e
|
|
@ -324,5 +324,16 @@ public class GATKArgumentCollection {
|
||||||
@Argument(fullName="allow_intervals_with_unindexed_bam",doc="Allow interval processing with an unsupported BAM. NO INTEGRATION TESTS are available. Use at your own risk.",required=false)
|
@Argument(fullName="allow_intervals_with_unindexed_bam",doc="Allow interval processing with an unsupported BAM. NO INTEGRATION TESTS are available. Use at your own risk.",required=false)
|
||||||
@Hidden
|
@Hidden
|
||||||
public boolean allowIntervalsWithUnindexedBAM = false;
|
public boolean allowIntervalsWithUnindexedBAM = false;
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// testing BCF2
|
||||||
|
//
|
||||||
|
// --------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@Argument(fullName="also_generate_bcf",doc="If provided, whenever we create a VCFWriter we will also write out a BCF file alongside it, for testing purposes",required=false)
|
||||||
|
@Hidden
|
||||||
|
public boolean alsoGenerateBCF = false;
|
||||||
|
// TODO -- remove all code tagged with TODO -- remove me when argument alsoGenerateBCF is removed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import org.broadinstitute.sting.utils.codecs.vcf.VCFHeader;
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
|
||||||
|
import org.broadinstitute.sting.utils.variantcontext.writer.Options;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.writer.VariantContextWriter;
|
import org.broadinstitute.sting.utils.variantcontext.writer.VariantContextWriter;
|
||||||
import org.broadinstitute.sting.utils.variantcontext.writer.VariantContextWriterFactory;
|
import org.broadinstitute.sting.utils.variantcontext.writer.VariantContextWriterFactory;
|
||||||
|
|
||||||
|
|
@ -40,6 +41,9 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides temporary and permanent storage for genotypes in VCF format.
|
* Provides temporary and permanent storage for genotypes in VCF format.
|
||||||
|
|
@ -95,7 +99,41 @@ public class VariantContextWriterStorage implements Storage<VariantContextWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
// The GATK/Tribble can't currently index block-compressed files on the fly. Disable OTF indexing even if the user explicitly asked for it.
|
// The GATK/Tribble can't currently index block-compressed files on the fly. Disable OTF indexing even if the user explicitly asked for it.
|
||||||
return VariantContextWriterFactory.create(file, this.stream, stub.getMasterSequenceDictionary(), stub.getWriterOptions(indexOnTheFly));
|
EnumSet<Options> options = stub.getWriterOptions(indexOnTheFly);
|
||||||
|
VariantContextWriter writer = VariantContextWriterFactory.create(file, this.stream, stub.getMasterSequenceDictionary(), options);
|
||||||
|
|
||||||
|
// if the stub says to test BCF, create a secondary writer to BCF and an 2 way out writer to send to both
|
||||||
|
// TODO -- remove me when argument alsoGenerateBCF is removed
|
||||||
|
if ( stub.alsoWriteBCFForTest() && ! VariantContextWriterFactory.isBCFOutput(file, options)) {
|
||||||
|
final File bcfFile = new File(file.getAbsolutePath() + ".bcf");
|
||||||
|
VariantContextWriter bcfWriter = VariantContextWriterFactory.create(bcfFile, stub.getMasterSequenceDictionary(), options);
|
||||||
|
writer = new TestWriter(writer, bcfWriter);
|
||||||
|
}
|
||||||
|
|
||||||
|
return writer;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final static class TestWriter implements VariantContextWriter {
|
||||||
|
final List<VariantContextWriter> writers;
|
||||||
|
|
||||||
|
private TestWriter(final VariantContextWriter ... writers) {
|
||||||
|
this.writers = Arrays.asList(writers);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeHeader(final VCFHeader header) {
|
||||||
|
for ( final VariantContextWriter writer : writers ) writer.writeHeader(header);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() {
|
||||||
|
for ( final VariantContextWriter writer : writers ) writer.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(final VariantContext vc) {
|
||||||
|
for ( final VariantContextWriter writer : writers ) writer.add(vc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -248,6 +248,17 @@ public class VariantContextWriterStub implements Stub<VariantContextWriter>, Var
|
||||||
return getClass().getName();
|
return getClass().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Should we also write a BCF file alongside our VCF file for testing
|
||||||
|
*
|
||||||
|
* TODO -- remove me when argument alsoGenerateBCF is removed
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean alsoWriteBCFForTest() {
|
||||||
|
return ! isCompressed() && getFile() != null && engine.getArguments().alsoGenerateBCF;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the appropriately formatted header for a VCF file
|
* Gets the appropriately formatted header for a VCF file
|
||||||
* @return VCF file header.
|
* @return VCF file header.
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ public class VariantContextWriterFactory {
|
||||||
final OutputStream output,
|
final OutputStream output,
|
||||||
final SAMSequenceDictionary refDict,
|
final SAMSequenceDictionary refDict,
|
||||||
final EnumSet<Options> options) {
|
final EnumSet<Options> options) {
|
||||||
final boolean enableBCF = options.contains(Options.FORCE_BCF) || (location != null && location.getName().contains(".bcf"));
|
final boolean enableBCF = isBCFOutput(location, options);
|
||||||
|
|
||||||
if ( enableBCF )
|
if ( enableBCF )
|
||||||
return new BCF2Writer(location, output, refDict,
|
return new BCF2Writer(location, output, refDict,
|
||||||
|
|
@ -83,6 +83,10 @@ public class VariantContextWriterFactory {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isBCFOutput(final File location, final EnumSet<Options> options) {
|
||||||
|
return options.contains(Options.FORCE_BCF) || (location != null && location.getName().contains(".bcf"));
|
||||||
|
}
|
||||||
|
|
||||||
public static VariantContextWriter sortOnTheFly(final VariantContextWriter innerWriter, int maxCachingStartDistance) {
|
public static VariantContextWriter sortOnTheFly(final VariantContextWriter innerWriter, int maxCachingStartDistance) {
|
||||||
return sortOnTheFly(innerWriter, maxCachingStartDistance, false);
|
return sortOnTheFly(innerWriter, maxCachingStartDistance, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue