Package htsjdk.tribble.readers
Class TabixReader
- java.lang.Object
-
- htsjdk.tribble.readers.TabixReader
-
public class TabixReader extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceTabixReader.Iteratorprotected static classTabixReader.TIndexprotected static classTabixReader.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 intchr2tid(String chr)return chromosome ID or -1 if it is unknownvoidclose()Set<String>getChromosomes()return the chromosomes in that tabix fileStringgetSource()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.Iteratorquery(int tid, int beg, int end)ReturnTabixReader.Iteratorquery(String reg)TabixReader.Iteratorquery(String reg, int start, int end)static intreadInt(InputStream is)StringreadLine()Read one line from the data file.static StringreadLine(InputStream is)static longreadLong(InputStream is)StringtoString()
-
-
-
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 aPathindexWrapper- 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 aPathstream- 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)
Return- Parameters:
tid- Sequence idbeg- beginning of interval, genomic coordsend- end of interval, genomic coords- Returns:
- an iterator over the lines within the specified interval
-
query
public TabixReader.Iterator query(String reg)
- Parameters:
reg- A region string of the form acceptable byparseReg(String)- Returns:
- See Also:
parseReg(String)
-
query
public TabixReader.Iterator query(String reg, int start, int end)
- Parameters:
reg- a chromosomestart- start intervalend- end interval- Returns:
- a tabix iterator
- See Also:
parseReg(String)
-
close
public void close()
-
-