Search in sources :

Example 31 with VariantContextWriter

use of htsjdk.variant.variantcontext.writer.VariantContextWriter in project gatk by broadinstitute.

the class GVCFWriterUnitTest method writeGVCFToDisk.

@Test(dataProvider = "toWriteToDisk")
public void writeGVCFToDisk(List<VariantContext> variants, List<MinimalData> expected) {
    final List<Integer> gqPartitions = Arrays.asList(1, 10, 30);
    final File outputFile = createTempFile("generated", ".g.vcf");
    try (VariantContextWriter writer = GATKVariantContextUtils.createVCFWriter(outputFile, null, false);
        GVCFWriter gvcfWriter = new GVCFWriter(writer, gqPartitions, HomoSapiensConstants.DEFAULT_PLOIDY)) {
        gvcfWriter.writeHeader(getMinimalVCFHeader());
        variants.forEach(gvcfWriter::add);
    }
    assertGVCFIsParseableAndVariantsMatch(outputFile, expected);
}
Also used : VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) File(java.io.File) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)31 File (java.io.File)19 VariantContext (htsjdk.variant.variantcontext.VariantContext)13 VariantContextWriterBuilder (htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder)12 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)12 Test (org.testng.annotations.Test)12 VCFHeader (htsjdk.variant.vcf.VCFHeader)9 VCFFileReader (htsjdk.variant.vcf.VCFFileReader)8 UserException (org.broadinstitute.hellbender.exceptions.UserException)8 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)7 Options (htsjdk.variant.variantcontext.writer.Options)6 ProgressLogger (org.broadinstitute.hellbender.utils.runtime.ProgressLogger)6 IOException (java.io.IOException)5 IndexedFastaSequenceFile (htsjdk.samtools.reference.IndexedFastaSequenceFile)4 ReferenceSequenceFile (htsjdk.samtools.reference.ReferenceSequenceFile)4 VariantContextComparator (htsjdk.variant.variantcontext.VariantContextComparator)4 CloseableIterator (htsjdk.samtools.util.CloseableIterator)3 MergingIterator (htsjdk.samtools.util.MergingIterator)3 Function (java.util.function.Function)3 Collectors (java.util.stream.Collectors)3