# 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 AbstractFeatureReader

`AbstractFeatureReader.ComponentMethods`

## Field Summary

### Fields inherited from class 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

Modifier and Type
Method
Description
`void`
`close()`
Closes the reader
`List<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 false
`boolean`
`isQueryable()`
`CloseableTribbleIterator<T>`
`iterator()`
Provides access to all the features in the reader
`CloseableTribbleIterator<T>`
`query(String chr, int start, int end)`
Return an iterator to iterate over features overlapping the specified interval

### Methods inherited from class AbstractFeatureReader

`getFeatureReader, getFeatureReader, getFeatureReader, getFeatureReader, getFeatureReader, getHeader, hasBlockCompressedExtension, hasBlockCompressedExtension, hasBlockCompressedExtension, isTabix, setComponentMethods`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface FeatureReader

`query`

## Constructor Details

### 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 url
  `codec` - - codec to decode the features
  `requireIndex` - - 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 url
  `indexFile` - - path to the index file
  `codec` - - codec to decode the features
  `requireIndex` - - 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 a `Path` plugin
  `indexFile` - - path to the index file
  `codec` - - codec to decode the features
  `requireIndex` - - 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 url
  `codec` - - codec to decode the features
  `index` - - a tribble Index object
Throws:
  `IOException`

## Method Details

### 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 class `AbstractFeatureReader<T extends Feature, SOURCE>`
Returns:
  false

### isQueryable

public boolean isQueryable()

Specified by:
  `isQueryable` in interface `FeatureReader<T extends Feature>`
Overrides:
  `isQueryable` in class `AbstractFeatureReader<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` - contig
  `start` - start position
  `end` - 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`