Package htsjdk.samtools
Class AbstractBAMFileIndex
- java.lang.Object
-
- htsjdk.samtools.AbstractBAMFileIndex
-
- All Implemented Interfaces:
BAMIndex
,Closeable
,AutoCloseable
- Direct Known Subclasses:
DiskBasedBAMFileIndex
public abstract class AbstractBAMFileIndex extends Object implements BAMIndex
Provides basic, generic capabilities to be used reading BAM index files. Users can subclass this class to create new BAM index functionality for adding querying facilities, changing caching behavior, etc. Of particular note: the AbstractBAMFileIndex is, by design, the only class aware of the details of the BAM index file format (other than the four classes representing the data, BAMIndexContent, Bin, Chunk, LinearIndex, and the classes for building the BAM index). Anyone wanting to implement a reader for a differing or extended BAM index format should implement BAMIndex directly.
-
-
Field Summary
-
Fields inherited from interface htsjdk.samtools.BAMIndex
BAMIndexSuffix
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractBAMFileIndex(SeekableStream stream, SAMSequenceDictionary dictionary)
protected
AbstractBAMFileIndex(File file, SAMSequenceDictionary dictionary)
protected
AbstractBAMFileIndex(File file, SAMSequenceDictionary dictionary, boolean useMemoryMapping)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Close this index and release any associated resources.static int
getFirstBinInLevel(int levelNumber)
Gets the first bin in the given level.int
getFirstLocusInBin(Bin bin)
Gets the first locus that this bin can index into.int
getLastLocusInBin(Bin bin)
Gets the last locus that this bin can index into.int
getLevelForBin(Bin bin)
Gets the level associated with the given bin number.int
getLevelSize(int levelNumber)
Gets the number of bins in the given level.protected int
getMaxAddressibleGenomicLocation()
Gets the possible number of bins for a given reference sequence.BAMIndexMetaData
getMetaData(int reference)
Return meta data for the given reference including information about number of aligned, unaligned, and noCoordinate recordsLong
getNoCoordinateCount()
Returns count of records unassociated with any reference.int
getNumberOfReferences()
static int
getNumIndexLevels()
Get the number of levels employed by this index.protected abstract htsjdk.samtools.BAMIndexContent
getQueryResults(int reference)
long
getStartOfLastLinearBin()
Use to get close to the unmapped reads at the end of a BAM file.protected List<Chunk>
optimizeChunkList(List<Chunk> chunks, long minimumOffset)
Deprecated.InvokeChunk.optimizeChunkList(java.util.List<htsjdk.samtools.Chunk>, long)
directly.protected htsjdk.samtools.BAMIndexContent
query(int referenceSequence, int startPos, int endPos)
protected BitSet
regionToBins(int startPos, int endPos)
Get candidate bins for the specified region-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface htsjdk.samtools.BAMIndex
getSpanOverlapping
-
-
-
-
Constructor Detail
-
AbstractBAMFileIndex
protected AbstractBAMFileIndex(SeekableStream stream, SAMSequenceDictionary dictionary)
-
AbstractBAMFileIndex
protected AbstractBAMFileIndex(File file, SAMSequenceDictionary dictionary)
-
AbstractBAMFileIndex
protected AbstractBAMFileIndex(File file, SAMSequenceDictionary dictionary, boolean useMemoryMapping)
-
-
Method Detail
-
close
public void close()
Close this index and release any associated resources.
-
getNumIndexLevels
public static int getNumIndexLevels()
Get the number of levels employed by this index.- Returns:
- Number of levels in this index.
-
getFirstBinInLevel
public static int getFirstBinInLevel(int levelNumber)
Gets the first bin in the given level.- Parameters:
levelNumber
- Level number. 0-based.- Returns:
- The first bin in this level.
-
getLevelSize
public int getLevelSize(int levelNumber)
Gets the number of bins in the given level.- Parameters:
levelNumber
- Level number. 0-based.- Returns:
- The size (number of possible bins) of the given level.
-
getLevelForBin
public int getLevelForBin(Bin bin)
Gets the level associated with the given bin number.- Parameters:
bin
- The bin for which to determine the level.- Returns:
- the level associated with the given bin number.
-
getFirstLocusInBin
public int getFirstLocusInBin(Bin bin)
Gets the first locus that this bin can index into.- Parameters:
bin
- The bin to test.- Returns:
- The last position that the given bin can represent.
-
getLastLocusInBin
public int getLastLocusInBin(Bin bin)
Gets the last locus that this bin can index into.- Parameters:
bin
- The bin to test.- Returns:
- The last position that the given bin can represent.
-
getNumberOfReferences
public int getNumberOfReferences()
-
getStartOfLastLinearBin
public long getStartOfLastLinearBin()
Use to get close to the unmapped reads at the end of a BAM file.- Specified by:
getStartOfLastLinearBin
in interfaceBAMIndex
- Returns:
- The file offset of the first record in the last linear bin, or -1 if there are no elements in linear bins (i.e. no mapped reads).
-
getMetaData
public BAMIndexMetaData getMetaData(int reference)
Return meta data for the given reference including information about number of aligned, unaligned, and noCoordinate records- Specified by:
getMetaData
in interfaceBAMIndex
- Parameters:
reference
- the reference of interest- Returns:
- meta data for the reference
-
getNoCoordinateCount
public Long getNoCoordinateCount()
Returns count of records unassociated with any reference. Call before the index file is closed- Returns:
- meta data at the end of the bam index that indicates count of records holding no coordinates or null if no meta data (old index format)
-
query
protected htsjdk.samtools.BAMIndexContent query(int referenceSequence, int startPos, int endPos)
-
getQueryResults
protected abstract htsjdk.samtools.BAMIndexContent getQueryResults(int reference)
-
getMaxAddressibleGenomicLocation
protected int getMaxAddressibleGenomicLocation()
Gets the possible number of bins for a given reference sequence.- Returns:
- How many bins could possibly be used according to this indexing scheme to index a single contig.
-
regionToBins
protected BitSet regionToBins(int startPos, int endPos)
Get candidate bins for the specified region- Parameters:
startPos
- 1-based start of target region, inclusive.endPos
- 1-based end of target region, inclusive.- Returns:
- bit set for each bin that may contain SAMRecords in the target region.
-
optimizeChunkList
@Deprecated protected List<Chunk> optimizeChunkList(List<Chunk> chunks, long minimumOffset)
Deprecated.InvokeChunk.optimizeChunkList(java.util.List<htsjdk.samtools.Chunk>, long)
directly.
-
-