Class SBIIndex

java.lang.Object
htsjdk.samtools.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:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Deprecated.
    since June 2019 Use FileExtensions.SBI instead.
  • Constructor Summary

    Constructors
    Constructor
    Description
    SBIIndex(SBIIndex.Header header, long[] virtualOffsets)
    Create an in-memory SBI with the given virtual offsets.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the length of the data file in bytes.
    boolean
     
    getChunk(long splitStart, long splitEnd)
    Return a chunk that corresponds to the given range in the data file.
    long
    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 index header.
    long[]
    Returns the entries in the index.
    int
     
    static SBIIndex
    Load an SBI into memory from a stream.
    static SBIIndex
    load(Path path)
    Load an SBI into memory from a path.
    long
    Returns number of entries in the index.
    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.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • 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 Details

    • 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

      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:
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object