Search in sources :

Example 6 with VCFCodec

use of htsjdk.variant.vcf.VCFCodec in project gatk-protected by broadinstitute.

the class GenotypeGVCFsIntegrationTest method getVariantContexts.

/**
     * Returns a list of VariantContext records from a VCF file
     *
     * @param vcfFile VCF file
     * @return list of VariantContext records
     * @throws IOException if the file does not exist or can not be opened
     */
private static List<VariantContext> getVariantContexts(final File vcfFile) throws IOException {
    final VCFCodec codec = new VCFCodec();
    final FileInputStream s = new FileInputStream(vcfFile);
    final LineIterator lineIteratorVCF = codec.makeSourceFromStream(new PositionalBufferedStream(s));
    codec.readHeader(lineIteratorVCF);
    final List<VariantContext> VCs = new ArrayList<>();
    while (lineIteratorVCF.hasNext()) {
        final String line = lineIteratorVCF.next();
        Assert.assertFalse(line == null);
        VCs.add(codec.decode(line));
    }
    return VCs;
}
Also used : VCFCodec(htsjdk.variant.vcf.VCFCodec) PositionalBufferedStream(htsjdk.tribble.readers.PositionalBufferedStream) ArrayList(java.util.ArrayList) VariantContext(htsjdk.variant.variantcontext.VariantContext) LineIterator(htsjdk.tribble.readers.LineIterator) FileInputStream(java.io.FileInputStream)

Aggregations

VariantContext (htsjdk.variant.variantcontext.VariantContext)6 VCFCodec (htsjdk.variant.vcf.VCFCodec)6 LineIterator (htsjdk.tribble.readers.LineIterator)5 PositionalBufferedStream (htsjdk.tribble.readers.PositionalBufferedStream)4 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)3 VCFHeader (htsjdk.variant.vcf.VCFHeader)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 GenomicsDBFeatureReader (com.intel.genomicsdb.GenomicsDBFeatureReader)2 AbstractFeatureReader (htsjdk.tribble.AbstractFeatureReader)2 FeatureReader (htsjdk.tribble.FeatureReader)2 BCF2Codec (htsjdk.variant.bcf2.BCF2Codec)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 SeekableByteChannel (java.nio.channels.SeekableByteChannel)2 Path (java.nio.file.Path)2 java.util (java.util)2 ArrayList (java.util.ArrayList)2 Function (java.util.function.Function)2 Argument (org.broadinstitute.barclay.argparser.Argument)2 CommandLineProgramProperties (org.broadinstitute.barclay.argparser.CommandLineProgramProperties)2