htsjdk.variant.vcf
Class VCFFileReader

java.lang.Object
  extended by htsjdk.variant.vcf.VCFFileReader
All Implemented Interfaces:
java.io.Closeable, java.lang.Iterable<VariantContext>

public class VCFFileReader
extends java.lang.Object
implements java.io.Closeable, java.lang.Iterable<VariantContext>

Simplified interface for reading from VCF/BCF files.


Constructor Summary
VCFFileReader(java.io.File file)
          Constructs a VCFFileReader that requires the index to be present.
VCFFileReader(java.io.File file, boolean requireIndex)
          Allows construction of a VCFFileReader that will or will not assert the presence of an index as desired.
VCFFileReader(java.io.File file, java.io.File indexFile)
          Constructs a VCFFileReader with a specified index.
VCFFileReader(java.io.File file, java.io.File indexFile, boolean requireIndex)
          Allows construction of a VCFFileReader with a specified index file.
 
Method Summary
 void close()
           
static IntervalList fromVcf(java.io.File file)
          Parse a VCF file and convert to an IntervalList The name field of the IntervalList is taken from the ID field of the variant, if it exists.
static IntervalList fromVcf(java.io.File file, boolean includeFiltered)
           
static IntervalList fromVcf(VCFFileReader vcf)
          Converts a vcf to an IntervalList.
static IntervalList fromVcf(VCFFileReader vcf, boolean includeFiltered)
           
 VCFHeader getFileHeader()
          Returns the VCFHeader associated with this VCF/BCF file.
static SAMSequenceDictionary getSequenceDictionary(java.io.File file)
          Returns the SAMSequenceDictionary from the provided VCF file.
static boolean isBCF(java.io.File file)
          Returns true if the given file appears to be a BCF file.
 CloseableIterator<VariantContext> iterator()
          Returns an iterator over all records in this VCF/BCF file.
 CloseableIterator<VariantContext> query(java.lang.String chrom, int start, int end)
          Queries for records within the region specified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VCFFileReader

public VCFFileReader(java.io.File file)
Constructs a VCFFileReader that requires the index to be present.


VCFFileReader

public VCFFileReader(java.io.File file,
                     java.io.File indexFile)
Constructs a VCFFileReader with a specified index.


VCFFileReader

public VCFFileReader(java.io.File file,
                     boolean requireIndex)
Allows construction of a VCFFileReader that will or will not assert the presence of an index as desired.


VCFFileReader

public VCFFileReader(java.io.File file,
                     java.io.File indexFile,
                     boolean requireIndex)
Allows construction of a VCFFileReader with a specified index file.

Method Detail

isBCF

public static boolean isBCF(java.io.File file)
Returns true if the given file appears to be a BCF file.


getSequenceDictionary

public static SAMSequenceDictionary getSequenceDictionary(java.io.File file)
Returns the SAMSequenceDictionary from the provided VCF file.


fromVcf

public static IntervalList fromVcf(java.io.File file)
Parse a VCF file and convert to an IntervalList The name field of the IntervalList is taken from the ID field of the variant, if it exists. if not, creates a name of the format interval-n where n is a running number that increments only on un-named intervals

Parameters:
file -
Returns:

fromVcf

public static IntervalList fromVcf(java.io.File file,
                                   boolean includeFiltered)

fromVcf

public static IntervalList fromVcf(VCFFileReader vcf)
Converts a vcf to an IntervalList. The name field of the IntervalList is taken from the ID field of the variant, if it exists. If not, creates a name of the format interval-n where n is a running number that increments only on un-named intervals Will use a "END" tag in the info field as the end of the interval (if exists).

Parameters:
vcf - the vcfReader to be used for the conversion
Returns:
an IntervalList constructed from input vcf

fromVcf

public static IntervalList fromVcf(VCFFileReader vcf,
                                   boolean includeFiltered)

getFileHeader

public VCFHeader getFileHeader()
Returns the VCFHeader associated with this VCF/BCF file.


iterator

public CloseableIterator<VariantContext> iterator()
Returns an iterator over all records in this VCF/BCF file.

Specified by:
iterator in interface java.lang.Iterable<VariantContext>

query

public CloseableIterator<VariantContext> query(java.lang.String chrom,
                                               int start,
                                               int end)
Queries for records within the region specified.


close

public void close()
Specified by:
close in interface java.io.Closeable