Package htsjdk.samtools
Class BAMIndexMerger
Merges BAM index files for (headerless) parts of a BAM file into a single
index file. The index files must have been produced using
BAMIndexer
with fillInUninitializedValues
set to false.
A partitioned BAM is a directory containing the following files:
- A file named header containing all header bytes in BAM format.
- Zero or more files named part-00000, part-00001, ... etc, containing a list of alignments in BAM format.
- A file named terminator containing a BGZF end-of-file marker block.
- Parts and their indexes may be written in parallel, since one part file can be written independently of the others.
- A BAM file can be created from a partitioned BAM file by concatenating all the non-hidden files (header, part-00000, part-00001, ..., terminator).
- A BAM index can be created from a partitioned BAM file by merging all of the hidden files with a .bai suffix. Note that this is not a simple file concatenation operation. See
BAMIndexMerger
.
-
Field Summary
Fields inherited from class htsjdk.samtools.IndexMerger
out, partLengths
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
finish
(long dataFileLength) Finish merging the indexes, and close the output stream.static BinningIndexContent.BinList
mergeBins
(List<BinningIndexContent.BinList> binLists, long[] offsets) Merge bins for (headerless) BAM file parts.static LinearIndex
mergeLinearIndexes
(int referenceSequence, List<LinearIndex> linearIndexes, long[] offsets) Merge linear indexes for (headerless) BAM file parts.static AbstractBAMFileIndex
openIndex
(SeekableStream stream, SAMSequenceDictionary dictionary) void
processIndex
(AbstractBAMFileIndex index, long partLength) Process the next index and add to the merged index.
-
Constructor Details
-
BAMIndexMerger
-
-
Method Details
-
processIndex
Description copied from class:IndexMerger
Process the next index and add to the merged index.- Specified by:
processIndex
in classIndexMerger<AbstractBAMFileIndex>
- Parameters:
index
- the index to mergepartLength
- the length of the part file corresponding to the index, in bytes.
-
finish
public void finish(long dataFileLength) Description copied from class:IndexMerger
Finish merging the indexes, and close the output stream.- Specified by:
finish
in classIndexMerger<AbstractBAMFileIndex>
- Parameters:
dataFileLength
- the length of the total data file, in bytes.
-
openIndex
public static AbstractBAMFileIndex openIndex(SeekableStream stream, SAMSequenceDictionary dictionary) -
mergeBins
public static BinningIndexContent.BinList mergeBins(List<BinningIndexContent.BinList> binLists, long[] offsets) Merge bins for (headerless) BAM file parts.- Parameters:
binLists
- the bins to mergeoffsets
- bin i will be shifted by offset i- Returns:
- the merged bins
-
mergeLinearIndexes
public static LinearIndex mergeLinearIndexes(int referenceSequence, List<LinearIndex> linearIndexes, long[] offsets) Merge linear indexes for (headerless) BAM file parts.- Parameters:
referenceSequence
- the reference sequence number for the linear indexes being mergedlinearIndexes
- the linear indexes to mergeoffsets
- linear index i will be shifted by offset i- Returns:
- the merged linear index
-