Package htsjdk.variant.vcf
Class VCFFileReader
java.lang.Object
htsjdk.variant.vcf.VCFFileReader
- All Implemented Interfaces:
VCFReader,Closeable,AutoCloseable,Iterable<VariantContext>
Simplified interface for reading from VCF/BCF files.
-
Constructor Summary
ConstructorsConstructorDescriptionVCFFileReader(File file) Constructs a VCFFileReader that requires the index to be present.VCFFileReader(File file, boolean requireIndex) Allows construction of a VCFFileReader that will or will not assert the presence of an index as desired.VCFFileReader(File file, File indexFile) Constructs a VCFFileReader with a specified index.VCFFileReader(File file, File indexFile, boolean requireIndex) Allows construction of a VCFFileReader with a specified index file.VCFFileReader(Path path) Constructs a VCFFileReader that requires the index to be present.VCFFileReader(Path path, boolean requireIndex) Allows construction of a VCFFileReader that will or will not assert the presence of an index as desired.VCFFileReader(Path path, Path indexPath) Constructs a VCFFileReader with a specified index.VCFFileReader(Path path, Path indexPath, boolean requireIndex) Allows construction of a VCFFileReader with a specified index path. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()static IntervalListfromVcf(VCFFileReader vcf) Deprecated.static IntervalListfromVcf(VCFFileReader vcf, boolean includeFiltered) Deprecated.since July 2018 since usetoIntervalList(VCFFileReader, boolean)insteadstatic IntervalListDeprecated.since July 2018 usetoIntervalList(Path)insteadstatic IntervalListDeprecated.since July 2018 usetoIntervalList(Path, boolean)insteadfinal VCFHeaderSynonym ofgetHeader()Returns the VCFHeader associated with this VCF/BCF file.static SAMSequenceDictionarygetSequenceDictionary(File file) Returns the SAMSequenceDictionary from the provided VCF file.static SAMSequenceDictionarygetSequenceDictionary(Path path) Returns the SAMSequenceDictionary from the provided VCF file.static booleanReturns true if the given file appears to be a BCF file.static booleanReturns true if the given path appears to be a BCF file.booleanA method to check if the reader is query-able, i.e.iterator()Returns an iterator over all records in this VCF/BCF file.Queries for records overlapping the region specified.Converts the underlying VCFFileReader to an IntervalList.toIntervalList(boolean includeFiltered) static IntervalListConverts a vcf to an IntervalList.static IntervalListtoIntervalList(VCFFileReader vcf, boolean includeFiltered) Converts aVCFFileReaderto an IntervalList.static IntervalListtoIntervalList(Path path) 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 IntervalListtoIntervalList(Path path, boolean includeFiltered) toIntervals(VCFFileReader vcf, boolean includeFiltered) Converts aVCFFileReaderto anIterator<Interval>The name field of the Interval is taken from the ID field of the variant, if it exists.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
VCFFileReader
Constructs a VCFFileReader that requires the index to be present. -
VCFFileReader
Constructs a VCFFileReader with a specified index. -
VCFFileReader
Allows construction of a VCFFileReader that will or will not assert the presence of an index as desired. -
VCFFileReader
Allows construction of a VCFFileReader with a specified index file. -
VCFFileReader
Constructs a VCFFileReader that requires the index to be present. -
VCFFileReader
Constructs a VCFFileReader with a specified index. -
VCFFileReader
Allows construction of a VCFFileReader that will or will not assert the presence of an index as desired. -
VCFFileReader
Allows construction of a VCFFileReader with a specified index path.
-
-
Method Details
-
isBCF
Returns true if the given file appears to be a BCF file. -
isBCF
Returns true if the given path appears to be a BCF file. -
getSequenceDictionary
Returns the SAMSequenceDictionary from the provided VCF file. -
getSequenceDictionary
Returns the SAMSequenceDictionary from the provided VCF file. -
toIntervalList
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:
path- a VCF- Returns:
-
toIntervalList
-
fromVcf
Deprecated.since July 2018 usetoIntervalList(Path)insteadParse 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- a VCF- Returns:
- an
IntervalList
-
fromVcf
Deprecated.since July 2018 usetoIntervalList(Path, boolean)insteadParse 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:
-
toIntervalList
Converts the underlying VCFFileReader 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 on un-named intervals. Will use the "END" tag in the INFO field as the end of the interval (if exists).- Returns:
- an IntervalList constructed from input vcf
-
toIntervalList
-
fromVcf
Deprecated.since July 2018 since usetoIntervalList(VCFFileReader)insteadConverts 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
-
toIntervalList
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
Deprecated.since July 2018 since usetoIntervalList(VCFFileReader, boolean)insteadConverts 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
-
toIntervalList
Converts aVCFFileReaderto an IntervalList. The name field of the Interval 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
-
toIntervals
Converts aVCFFileReaderto anIterator<Interval>The name field of the Interval 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:
- a Iterator
constructed from input vcf
-
getHeader
Returns the VCFHeader associated with this VCF/BCF file. -
getFileHeader
Synonym ofgetHeader() -
iterator
Returns an iterator over all records in this VCF/BCF file.- Specified by:
iteratorin interfaceIterable<VariantContext>- Specified by:
iteratorin interfaceVCFReader
-
query
Queries for records overlapping the region specified. Note that this method requires VCF files with an associated index. If no index exists a TribbleException will be thrown. -
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
isQueryable
public boolean isQueryable()A method to check if the reader is query-able, i.e. if a call toquery(String, int, int)can be successful- Specified by:
isQueryablein interfaceVCFReader- Returns:
- true if the reader can be queried, i.e. if the underlying Tribble reader is queryable.
-
toIntervalList(VCFFileReader)instead