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 TypeMethodDescriptionvoid
close()
static IntervalList
fromVcf
(VCFFileReader vcf) Deprecated.static IntervalList
fromVcf
(VCFFileReader vcf, boolean includeFiltered) Deprecated.since July 2018 since usetoIntervalList(VCFFileReader, boolean)
insteadstatic IntervalList
Deprecated.since July 2018 usetoIntervalList(Path)
insteadstatic IntervalList
Deprecated.since July 2018 usetoIntervalList(Path, boolean)
insteadfinal VCFHeader
Synonym ofgetHeader()
Returns the VCFHeader associated with this VCF/BCF file.static SAMSequenceDictionary
getSequenceDictionary
(File file) Returns the SAMSequenceDictionary from the provided VCF file.static SAMSequenceDictionary
getSequenceDictionary
(Path path) Returns the SAMSequenceDictionary from the provided VCF file.static boolean
Returns true if the given file appears to be a BCF file.static boolean
Returns true if the given path appears to be a BCF file.boolean
A 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 IntervalList
Converts a vcf to an IntervalList.static IntervalList
toIntervalList
(VCFFileReader vcf, boolean includeFiltered) Converts aVCFFileReader
to an IntervalList.static IntervalList
toIntervalList
(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 IntervalList
toIntervalList
(Path path, boolean includeFiltered) toIntervals
(VCFFileReader vcf, boolean includeFiltered) Converts aVCFFileReader
to 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, wait
Methods 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 aVCFFileReader
to 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 aVCFFileReader
to 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:
iterator
in interfaceIterable<VariantContext>
- Specified by:
iterator
in 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:
close
in interfaceAutoCloseable
- Specified by:
close
in 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:
isQueryable
in interfaceVCFReader
- Returns:
- true if the reader can be queried, i.e. if the underlying Tribble reader is queryable.
-
toIntervalList(VCFFileReader)
instead