Class TabixReader

java.lang.Object
htsjdk.tribble.readers.TabixReader
All Implemented Interfaces:
AutoCloseable

public class TabixReader extends Object implements AutoCloseable
  • Field Details

  • 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
      indexWrapper - a wrapper to apply to the raw byte stream of the index file if it is a uri representing a Path
      stream - Seekable stream from which the data is read
      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:
    • 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:
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • toString

      public String toString()
      Overrides:
      toString in class Object