Package htsjdk.samtools
Class BAMIndexMerger
- java.lang.Object
-
- htsjdk.samtools.IndexMerger<AbstractBAMFileIndex>
-
- htsjdk.samtools.BAMIndexMerger
-
public final class BAMIndexMerger extends IndexMerger<AbstractBAMFileIndex>
Merges BAM index files for (headerless) parts of a BAM file into a single index file. The index files must have been produced usingBAMIndexerwithfillInUninitializedValuesset 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 Constructor Description BAMIndexMerger(OutputStream out, long headerLength)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfinish(long dataFileLength)Finish merging the indexes, and close the output stream.static BinningIndexContent.BinListmergeBins(List<BinningIndexContent.BinList> binLists, long[] offsets)Merge bins for (headerless) BAM file parts.static LinearIndexmergeLinearIndexes(int referenceSequence, List<LinearIndex> linearIndexes, long[] offsets)Merge linear indexes for (headerless) BAM file parts.static AbstractBAMFileIndexopenIndex(SeekableStream stream, SAMSequenceDictionary dictionary)voidprocessIndex(AbstractBAMFileIndex index, long partLength)Process the next index and add to the merged index.
-
-
-
Constructor Detail
-
BAMIndexMerger
public BAMIndexMerger(OutputStream out, long headerLength)
-
-
Method Detail
-
processIndex
public void processIndex(AbstractBAMFileIndex index, long partLength)
Description copied from class:IndexMergerProcess the next index and add to the merged index.- Specified by:
processIndexin 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:IndexMergerFinish merging the indexes, and close the output stream.- Specified by:
finishin 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
-
-