Package htsjdk.tribble.readers
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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
chr2tid(String chr)
return chromosome ID or -1 if it is unknownvoid
close()
Set<String>
getChromosomes()
return the chromosomes in that tabix fileString
getSource()
return the source (filename/URL) of that readerint[]
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 coordinatesTabixReader.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 coordinatesstatic 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()
-
-
-
Field Detail
-
mIndex
protected TabixReader.TIndex[] mIndex
-
-
Constructor Detail
-
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/uriindexPath
- 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/uriindexPath
- Full path to the index file. Auto-generated if nullwrapper
- a wrapper to apply to the raw byte stream of the data file if is a uri representing aPath
indexWrapper
- a wrapper to apply to the raw byte stream of the index file if it is a uri representing aPath
- 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 nullstream
- 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 nullindexWrapper
- a wrapper to apply to the raw byte stream of the index file if it is a uri representing aPath
stream
- Seekable stream from which the data is read- Throws:
IOException
-
-
Method Detail
-
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
-
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_ITERATORbeg
- 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 byparseReg(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 chromosomestart
- start intervalend
- end interval- Returns:
- a tabix iterator over the specified interval
- See Also:
parseReg(String)
-
close
public void close()
- Specified by:
close
in interfaceAutoCloseable
-
-