Package htsjdk.samtools
Class CSIIndex
- java.lang.Object
-
- htsjdk.samtools.AbstractBAMFileIndex
-
- htsjdk.samtools.CSIIndex
-
- All Implemented Interfaces:
BAMIndex
,BrowseableBAMIndex
,Closeable
,AutoCloseable
public class CSIIndex extends AbstractBAMFileIndex implements BrowseableBAMIndex
Implementation of the CSI index for BAM files. The CSI index extends the BAI index by allowing a more flexible binning scheme, with variable depth (number of levels) and bin sizes, thus allowing for genomic regions longer than 2^29-1.
-
-
Field Summary
-
Fields inherited from interface htsjdk.samtools.BAMIndex
BAI_INDEX_SUFFIX, BAMIndexSuffix, CSI_INDEX_SUFFIX
-
-
Constructor Summary
Constructors Constructor Description CSIIndex(SeekableStream stream, SAMSequenceDictionary dictionary)
ConstructorsCSIIndex(File file, boolean enableMemoryMapping, SAMSequenceDictionary dictionary)
CSIIndex(Path path, SAMSequenceDictionary dictionary)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getAuxData()
int
getBinDepth()
Bin depth is the number of levels of the index.BinList
getBinsOverlapping(int referenceIndex, int startPos, int endPos)
Get a list of bins in the BAM file that may contain SAMRecords for the given range.int
getFirstBinInLevelForCSI(int levelNumber)
Extends the functionality ofAbstractBAMFileIndex.getFirstBinInLevel(int)
, which cannot be overridden due to its static nature.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)
Computes the number of bins on the given level.int
getMaxBins()
int
getMaxSpan()
BAMIndexMetaData
getMetaData(int reference)
Return meta data for the given reference including information about number of aligned, unaligned, and noCoordinate recordsint
getMinShift()
2^(min shift) is the smallest width of a binLong
getNoCoordinateCount()
Returns count of records unassociated with any reference.int
getNumberOfReferences()
int
getParentBinNumber(int binNumber)
int
getParentBinNumber(Bin bin)
htsjdk.samtools.BAMIndexContent
getQueryResults(int referenceSequence)
BAMFileSpan
getSpanOverlapping(int referenceIndex, int startPos, int endPos)
Gets the compressed chunks which should be searched for the contents of records contained by the span referenceIndex:startPos-endPos, inclusive.BAMFileSpan
getSpanOverlapping(Bin bin)
Perform an overlapping query of all bins bounding the given location.long
getStartOfLastLinearBin()
Use to get close to the unmapped reads at the end of a BAM file.protected void
initParameters()
Initialization method used for simplifying the constructor hierarchy.protected htsjdk.samtools.BAMIndexContent
query(int referenceSequence, int startPos, int endPos)
protected void
skipToSequence(int sequenceIndex)
protected void
verifyIndexMagicNumber(String sourceName)
-
Methods inherited from class htsjdk.samtools.AbstractBAMFileIndex
close, getBamDictionary, getFirstBinInLevel, getMaxAddressibleGenomicLocation, getNumIndexLevels, optimizeChunkList, position, readBytes, readChunks, readInteger, readLong, regionToBins, seek, setSequenceIndexes, skipBytes
-
-
-
-
Constructor Detail
-
CSIIndex
public CSIIndex(SeekableStream stream, SAMSequenceDictionary dictionary)
Constructors
-
CSIIndex
public CSIIndex(Path path, SAMSequenceDictionary dictionary) throws IOException
- Throws:
IOException
-
CSIIndex
public CSIIndex(File file, boolean enableMemoryMapping, SAMSequenceDictionary dictionary)
-
-
Method Detail
-
getBinDepth
public int getBinDepth()
Bin depth is the number of levels of the index. By default, BAI has 6 levels. CSI makes this variable.
-
getMinShift
public int getMinShift()
2^(min shift) is the smallest width of a bin
-
getMaxBins
public int getMaxBins()
-
getMaxSpan
public int getMaxSpan()
-
getAuxData
public byte[] getAuxData()
-
getNumberOfReferences
public int getNumberOfReferences()
- Overrides:
getNumberOfReferences
in classAbstractBAMFileIndex
-
getLevelSize
public int getLevelSize(int levelNumber)
Computes the number of bins on the given level.- Specified by:
getLevelSize
in interfaceBrowseableBAMIndex
- Overrides:
getLevelSize
in classAbstractBAMFileIndex
- Parameters:
levelNumber
- Level for which to compute the size.- Returns:
-
getFirstBinInLevelForCSI
public int getFirstBinInLevelForCSI(int levelNumber)
Extends the functionality ofAbstractBAMFileIndex.getFirstBinInLevel(int)
, which cannot be overridden due to its static nature.
-
getLevelForBin
public int getLevelForBin(Bin bin)
Description copied from class:AbstractBAMFileIndex
Gets the level associated with the given bin number.- Specified by:
getLevelForBin
in interfaceBrowseableBAMIndex
- Overrides:
getLevelForBin
in classAbstractBAMFileIndex
- 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)
Description copied from class:AbstractBAMFileIndex
Gets the first locus that this bin can index into.- Specified by:
getFirstLocusInBin
in interfaceBrowseableBAMIndex
- Overrides:
getFirstLocusInBin
in classAbstractBAMFileIndex
- Parameters:
bin
- The bin to test.- Returns:
- The last position that the given bin can represent.
-
getLastLocusInBin
public int getLastLocusInBin(Bin bin)
Description copied from class:AbstractBAMFileIndex
Gets the last locus that this bin can index into.- Specified by:
getLastLocusInBin
in interfaceBrowseableBAMIndex
- Overrides:
getLastLocusInBin
in classAbstractBAMFileIndex
- Parameters:
bin
- The bin to test.- Returns:
- The last position that the given bin can represent.
-
getBinsOverlapping
public BinList getBinsOverlapping(int referenceIndex, int startPos, int endPos)
Description copied from interface:BrowseableBAMIndex
Get a list of bins in the BAM file that may contain SAMRecords for the given range.- Specified by:
getBinsOverlapping
in interfaceBrowseableBAMIndex
- Parameters:
referenceIndex
- sequence of desired SAMRecordsstartPos
- 1-based start of the desired interval, inclusiveendPos
- 1-based end of the desired interval, inclusive- Returns:
- a list of bins that contain relevant data.
-
getSpanOverlapping
public BAMFileSpan getSpanOverlapping(int referenceIndex, int startPos, int endPos)
Description copied from interface:BAMIndex
Gets the compressed chunks which should be searched for the contents of records contained by the span referenceIndex:startPos-endPos, inclusive. See the BAM spec for more information on how a chunk is represented.- Specified by:
getSpanOverlapping
in interfaceBAMIndex
- Parameters:
referenceIndex
- The contig.startPos
- Genomic start of query.endPos
- Genomic end of query.- Returns:
- A file span listing the chunks in the BAM file.
-
getSpanOverlapping
public BAMFileSpan getSpanOverlapping(Bin bin)
Description copied from interface:BrowseableBAMIndex
Perform an overlapping query of all bins bounding the given location.- Specified by:
getSpanOverlapping
in interfaceBrowseableBAMIndex
- Parameters:
bin
- The bin over which to perform an overlapping query.- Returns:
- The file pointers
-
getStartOfLastLinearBin
public long getStartOfLastLinearBin()
Description copied from class:AbstractBAMFileIndex
Use to get close to the unmapped reads at the end of a BAM file.- Specified by:
getStartOfLastLinearBin
in interfaceBAMIndex
- Overrides:
getStartOfLastLinearBin
in classAbstractBAMFileIndex
- 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).
-
verifyIndexMagicNumber
protected void verifyIndexMagicNumber(String sourceName)
- Overrides:
verifyIndexMagicNumber
in classAbstractBAMFileIndex
-
initParameters
protected final void initParameters()
Description copied from class:AbstractBAMFileIndex
Initialization method used for simplifying the constructor hierarchy.- Overrides:
initParameters
in classAbstractBAMFileIndex
-
getParentBinNumber
public int getParentBinNumber(int binNumber)
-
getParentBinNumber
public int getParentBinNumber(Bin bin)
-
query
protected htsjdk.samtools.BAMIndexContent query(int referenceSequence, int startPos, int endPos)
- Overrides:
query
in classAbstractBAMFileIndex
-
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
- Overrides:
getMetaData
in classAbstractBAMFileIndex
- 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- Overrides:
getNoCoordinateCount
in classAbstractBAMFileIndex
- 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)
-
getQueryResults
public htsjdk.samtools.BAMIndexContent getQueryResults(int referenceSequence)
- Specified by:
getQueryResults
in classAbstractBAMFileIndex
-
skipToSequence
protected void skipToSequence(int sequenceIndex)
- Overrides:
skipToSequence
in classAbstractBAMFileIndex
-
-