Class TabixReader

    • 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/uri
        indexPath - Full path to the index file. Auto-generated if null
        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 Detail

      • getSource

        public String getSource()
        return the source (filename/URL) of that reader
      • 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,
                                          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)