Package htsjdk.samtools
Class SBIIndex
java.lang.Object
htsjdk.samtools.SBIIndex
- All Implemented Interfaces:
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
-
Field Summary
-
Constructor Summary
ConstructorDescriptionSBIIndex
(SBIIndex.Header header, long[] virtualOffsets) Create an in-memory SBI with the given virtual offsets. -
Method Summary
Modifier and TypeMethodDescriptionlong
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
hashCode()
static SBIIndex
load
(InputStream in) Load an SBI into memory from a stream.static SBIIndex
Load an SBI into memory from a path.long
size()
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.toString()
-
Field Details
-
FILE_EXTENSION
Deprecated.since June 2019 UseFileExtensions.SBI
instead.- See Also:
-
-
Constructor Details
-
SBIIndex
Create an in-memory SBI with the given virtual offsets.- Parameters:
virtualOffsets
- the offsets in the index
-
-
Method Details
-
load
Load an SBI into memory from a path.- Parameters:
path
- the path to the SBI file- Throws:
IOException
- as per java IO contract
-
load
Load an SBI into memory from a stream.- Parameters:
in
- the stream to read the SBI from
-
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
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
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
-
hashCode
public int hashCode() -
toString
-
FileExtensions.SBI
instead.