Class SBIIndex

  • All Implemented Interfaces:
    Serializable

    public final class SBIIndex
    extends Object
    implements Serializable
    SBI is an index into BGZF-compressed data files, which has an entry for the file position of the start of every nth record. Reads files that were created by BAMSBIIndexer.
    See Also:
    Serialized Form
    • Constructor Detail

      • SBIIndex

        public SBIIndex​(SBIIndex.Header header,
                        long[] virtualOffsets)
        Create an in-memory SBI with the given virtual offsets.
        Parameters:
        virtualOffsets - the offsets in the index
    • Method Detail

      • load

        public static SBIIndex load​(Path path)
                             throws IOException
        Load an SBI into memory from a path.
        Parameters:
        path - the path to the SBI file
        Throws:
        IOException - as per java IO contract
      • load

        public static SBIIndex load​(InputStream in)
        Load an SBI into memory from a stream.
        Parameters:
        in - the stream to read the SBI from
      • getHeader

        public SBIIndex.Header getHeader()
        Returns the index header.
        Returns:
        the header
      • getGranularity

        public long getGranularity()
        Returns the granularity of the index, that is the number of alignments between subsequent entries in the index, or zero if not specified.
        Returns:
        the granularity of the index
      • getVirtualOffsets

        public long[] getVirtualOffsets()
        Returns the entries in the index.
        Returns:
        an array of file pointers for all the alignment offsets in the index, in ascending order. The last virtual file pointer is the position at which the next record would start if it were added to the file.
      • size

        public long size()
        Returns number of entries in the index.
        Returns:
        the number of virtual offsets in the index
      • dataFileLength

        public long dataFileLength()
        Returns the length of the data file in bytes.
        Returns:
        the length of the data file in bytes
      • split

        public List<Chunk> split​(long splitSize)
        Split the data file for this index into non-overlapping chunks of roughly the given size that cover the whole file and that can be read independently of one another.
        Parameters:
        splitSize - the rough size of each split in bytes
        Returns:
        a list of contiguous, non-overlapping, sorted chunks that cover the whole data file
        See Also:
        getChunk(long, long)
      • getChunk

        public Chunk getChunk​(long splitStart,
                              long splitEnd)
        Return a chunk that corresponds to the given range in the data file. Note that the chunk does not necessarily completely cover the given range, however this method will map a set of contiguous, non-overlapping file ranges that cover the whole data file to a set of contiguous, non-overlapping chunks that cover the whole data file.
        Parameters:
        splitStart - the start of the file range (inclusive)
        splitEnd - the start of the file range (exclusive)
        Returns:
        a chunk whose virtual start is at the first alignment start position that is greater than or equal to the given split start position, and whose virtual end is at the first alignment start position that is greater than or equal to the given split end position, or null if the chunk would be empty.
        See Also:
        split(long)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object