Package htsjdk.tribble
Class TribbleIndexedFeatureReader<T extends Feature,SOURCE>
- java.lang.Object
-
- htsjdk.tribble.AbstractFeatureReader<T,SOURCE>
-
- htsjdk.tribble.TribbleIndexedFeatureReader<T,SOURCE>
-
- All Implemented Interfaces:
FeatureReader<T>
,Closeable
,AutoCloseable
public class TribbleIndexedFeatureReader<T extends Feature,SOURCE> extends AbstractFeatureReader<T,SOURCE>
A reader for text feature files (i.e. not tabix files). This includes tribble-indexed and non-indexed files. If index both iterate() and query() methods are supported. Note: Non-indexed files can be gzipped, but not bgzipped.- Since:
- 2/11/12
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class htsjdk.tribble.AbstractFeatureReader
AbstractFeatureReader.ComponentMethods
-
-
Field Summary
-
Fields inherited from class htsjdk.tribble.AbstractFeatureReader
BLOCK_COMPRESSED_EXTENSIONS, codec, header
-
-
Constructor Summary
Constructors Constructor Description TribbleIndexedFeatureReader(String featurePath, FeatureCodec<T,SOURCE> codec, boolean requireIndex)
TribbleIndexedFeatureReader(String featurePath, FeatureCodec<T,SOURCE> codec, boolean requireIndex, Function<SeekableByteChannel,SeekableByteChannel> wrapper, Function<SeekableByteChannel,SeekableByteChannel> indexWrapper)
TribbleIndexedFeatureReader(String featureFile, FeatureCodec<T,SOURCE> codec, Index index)
TribbleIndexedFeatureReader(String featureFile, String indexFile, FeatureCodec<T,SOURCE> codec, boolean requireIndex)
TribbleIndexedFeatureReader(String featureFile, String indexFile, FeatureCodec<T,SOURCE> codec, boolean requireIndex, Function<SeekableByteChannel,SeekableByteChannel> wrapper, Function<SeekableByteChannel,SeekableByteChannel> indexWrapper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the readerList<String>
getSequenceNames()
Return the sequence (chromosome/contig) names in this file, if known.boolean
hasIndex()
Whether the reader has an index or not Default implementation returns falseboolean
isQueryable()
CloseableTribbleIterator<T>
iterator()
Provides access to all the features in the readerCloseableTribbleIterator<T>
query(String chr, int start, int end)
Return an iterator to iterate over features overlapping the specified interval-
Methods inherited from class htsjdk.tribble.AbstractFeatureReader
getFeatureReader, getFeatureReader, getFeatureReader, getFeatureReader, getFeatureReader, getHeader, hasBlockCompressedExtension, hasBlockCompressedExtension, hasBlockCompressedExtension, isTabix, setComponentMethods
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface htsjdk.tribble.FeatureReader
query
-
-
-
-
Constructor Detail
-
TribbleIndexedFeatureReader
public TribbleIndexedFeatureReader(String featurePath, FeatureCodec<T,SOURCE> codec, boolean requireIndex) throws IOException
- Parameters:
featurePath
- - path to the feature file, can be a local file path, http url, or ftp urlcodec
- - codec to decode the featuresrequireIndex
- - true if the reader will be queries for specific ranges. An index (idx) file must exist- Throws:
IOException
-
TribbleIndexedFeatureReader
public TribbleIndexedFeatureReader(String featurePath, FeatureCodec<T,SOURCE> codec, boolean requireIndex, Function<SeekableByteChannel,SeekableByteChannel> wrapper, Function<SeekableByteChannel,SeekableByteChannel> indexWrapper) throws IOException
- Throws:
IOException
-
TribbleIndexedFeatureReader
public TribbleIndexedFeatureReader(String featureFile, String indexFile, FeatureCodec<T,SOURCE> codec, boolean requireIndex) throws IOException
- Parameters:
featureFile
- - path to the feature file, can be a local file path, http url, or ftp urlindexFile
- - path to the index filecodec
- - codec to decode the featuresrequireIndex
- - true if the reader will be queries for specific ranges. An index (idx) file must exist- Throws:
IOException
-
TribbleIndexedFeatureReader
public TribbleIndexedFeatureReader(String featureFile, String indexFile, FeatureCodec<T,SOURCE> codec, boolean requireIndex, Function<SeekableByteChannel,SeekableByteChannel> wrapper, Function<SeekableByteChannel,SeekableByteChannel> indexWrapper) throws IOException
- Parameters:
featureFile
- - path to the feature file, can be a local file path, http url, or ftp url, or any other uri supported by aPath
pluginindexFile
- - path to the index filecodec
- - codec to decode the featuresrequireIndex
- - true if the reader will be queries for specific ranges. An index (idx) file must exist- Throws:
IOException
-
TribbleIndexedFeatureReader
public TribbleIndexedFeatureReader(String featureFile, FeatureCodec<T,SOURCE> codec, Index index) throws IOException
- Parameters:
featureFile
- - path to the feature file, can be a local file path, http url, or ftp urlcodec
- - codec to decode the featuresindex
- - a tribble Index object- Throws:
IOException
-
-
Method Detail
-
close
public void close() throws IOException
Description copied from interface:FeatureReader
Closes the reader- Throws:
IOException
-
getSequenceNames
public List<String> getSequenceNames()
Return the sequence (chromosome/contig) names in this file, if known.- Returns:
- list of strings of the contig names
-
hasIndex
public boolean hasIndex()
Description copied from class:AbstractFeatureReader
Whether the reader has an index or not Default implementation returns false- Overrides:
hasIndex
in classAbstractFeatureReader<T extends Feature,SOURCE>
- Returns:
- false
-
isQueryable
public boolean isQueryable()
- Specified by:
isQueryable
in interfaceFeatureReader<T extends Feature>
- Overrides:
isQueryable
in classAbstractFeatureReader<T extends Feature,SOURCE>
- Returns:
- true if the reader has an index, which means that it can be queried.
-
query
public CloseableTribbleIterator<T> query(String chr, int start, int end) throws IOException
Return an iterator to iterate over features overlapping the specified interval Note that TribbleIndexedFeatureReader only supports issuing and manipulating a single query for each reader. That is, the behavior of the following code is undefined: reader = new TribbleIndexedFeatureReader() Iterator it1 = reader.query("x", 10, 20) Iterator it2 = reader.query("x", 1000, 1010) As a consequence of this, the TribbleIndexedFeatureReader are also not thread-safe.- Parameters:
chr
- contigstart
- start positionend
- end position- Returns:
- an iterator of records in this interval
- Throws:
IOException
-
iterator
public CloseableTribbleIterator<T> iterator() throws IOException
Description copied from interface:FeatureReader
Provides access to all the features in the reader- Returns:
- Return an iterator to iterate over the entire file
- Throws:
IOException
-
-