# Class TabixReader

java.lang.Object
htsjdk.tribble.readers.TabixReader

All Implemented Interfaces:
  `AutoCloseable`

public class TabixReader extends Object implements AutoCloseable

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`TabixReader.Iterator`
`protected static class`
`TabixReader.TIndex`
`protected static class`
`TabixReader.TPair64`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected TabixReader.TIndex[]`
`mIndex`

## Constructor Summary

Constructors
Constructor
Description
`TabixReader(String filePath)`
`TabixReader(String filePath, SeekableStream stream)`
`TabixReader(String filePath, String indexPath)`
`TabixReader(String filePath, String indexPath, SeekableStream stream)`
`TabixReader(String filePath, String indexPath, SeekableStream stream, Function<SeekableByteChannel, SeekableByteChannel> indexWrapper)`
`TabixReader(String filePath, String indexPath, Function<SeekableByteChannel, SeekableByteChannel> wrapper, Function<SeekableByteChannel, SeekableByteChannel> indexWrapper)`

## Method Summary

Modifier and Type
Method
Description
`int`
`chr2tid(String chr)`
return chromosome ID or -1 if it is unknown
`void`
`close()`
`Set<String>`
`getChromosomes()`
return the chromosomes in that tabix file
`String`
`getSource()`
return the source (filename/URL) of that reader
`int[]`
`parseReg(String reg)`
Parse a region in the format of "chr1", "chr1:100" or "chr1:100-1000"
`TabixReader.Iterator`
`query(int tid, int beg, int end)`
Get an iterator for an interval specified by the sequence id and begin and end coordinates
`TabixReader.Iterator`
`query(String reg)`
`TabixReader.Iterator`
`query(String reg, int start, int end)`
Get an iterator for an interval specified by the sequence id and begin and end coordinates
`static int`
`readInt(InputStream is)`
`String`
`readLine()`
Read one line from the data file.
`static String`
`readLine(InputStream is)`
`static long`
`readLong(InputStream is)`
`String`
`toString()`

### Methods inherited from class Object

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

## Field Details

### mIndex

protected TabixReader.TIndex[] mIndex

## Constructor Details

### TabixReader

public TabixReader(String filePath) throws IOException

Parameters:
  `filePath` - path to the data file/uri
Throws:
  `IOException`

### TabixReader

public TabixReader(String filePath, String indexPath) throws IOException

Parameters:
  `filePath` - path to the of the data file/uri
  `indexPath` - Full path to the index file. Auto-generated if null
Throws:
  `IOException`

### TabixReader

public TabixReader(String filePath, String indexPath, Function<SeekableByteChannel, SeekableByteChannel> wrapper, Function<SeekableByteChannel, SeekableByteChannel> indexWrapper) throws IOException

Parameters:
  `filePath` - path to the data file/uri
  `indexPath` - Full path to the index file. Auto-generated if null
  `wrapper` - a wrapper to apply to the raw byte stream of the data file if is a uri representing a `Path`
  `indexWrapper` - a wrapper to apply to the raw byte stream of the index file if it is a uri representing a `Path`
Throws:
  `IOException`

### TabixReader

public TabixReader(String filePath, SeekableStream stream) throws IOException

Parameters:
  `filePath` - Path to the data file (used for error messages only)
  `stream` - Seekable stream from which the data is read
Throws:
  `IOException`

### TabixReader

public TabixReader(String filePath, String indexPath, SeekableStream stream) throws IOException

Parameters:
  `filePath` - Path to the data file (used for error messages only)
  `indexPath` - Full path to the index file. Auto-generated if null
  `stream` - Seekable stream from which the data is read
Throws:
  `IOException`

### TabixReader

public TabixReader(String filePath, String indexPath, SeekableStream stream, Function<SeekableByteChannel, SeekableByteChannel> indexWrapper) throws IOException

Parameters:
  `filePath` - Path to the data file (used for error messages only)
  `indexPath` - Full path to the index file. Auto-generated if null
  `stream` - Seekable stream from which the data is read
  `indexWrapper` - a wrapper to apply to the raw byte stream of the index file if it is a uri representing a `Path`
Throws:
  `IOException`

## Method Details

### getSource

public String getSource()
return the source (filename/URL) of that reader

### readInt

public static int readInt(InputStream is) throws IOException

Throws:
  `IOException`

### readLong

public static long readLong(InputStream is) throws IOException

Throws:
  `IOException`

### readLine

public static String readLine(InputStream is) throws IOException

Throws:
  `IOException`

### readLine

public String readLine() throws IOException
Read one line from the data file.

Throws:
  `IOException`

### chr2tid

public int chr2tid(String chr)
return chromosome ID or -1 if it is unknown

### getChromosomes

public Set<String> getChromosomes()
return the chromosomes in that tabix file

### parseReg

public int[] parseReg(String reg)
Parse a region in the format of "chr1", "chr1:100" or "chr1:100-1000"

Parameters:
  `reg` - Region string
Returns:
  An array where the three elements are sequence_id, region_begin and region_end. On failure, sequence_id==-1.

### query

public TabixReader.Iterator query(int tid, int beg, int end)
Get an iterator for an interval specified by the sequence id and begin and end coordinates

Parameters:
  `tid` - Sequence id, if non-existent returns EOF_ITERATOR
  `beg` - beginning of interval, genomic coords (0-based, closed-open)
  `end` - end of interval, genomic coords (0-based, closed-open)
Returns:
  an iterator over the specified interval

### query

public TabixReader.Iterator query(String reg)

Parameters:
  `reg` - A region string of the form acceptable by `parseReg(String)`
Returns:
  an iterator over the specified interval
See Also:
  - `parseReg(String)`

### query

public TabixReader.Iterator query(String reg, int start, int end)
Get an iterator for an interval specified by the sequence id and begin and end coordinates

Parameters:
  `reg` - a chromosome
  `start` - start interval
  `end` - end interval
Returns:
  a tabix iterator over the specified interval
See Also:
  - `parseReg(String)`

### close

public void close()

Specified by:
  `close` in interface `AutoCloseable`

### toString

public String toString()

Overrides:
  `toString` in class `Object`