Package htsjdk.samtools
Class IndexMerger<T>
- java.lang.Object
-
- htsjdk.samtools.IndexMerger<T>
-
- Type Parameters:
T
- the type of the index (e.g.AbstractBAMFileIndex
for a BAM index).
- Direct Known Subclasses:
BAMIndexMerger
,CRAIIndexMerger
,SBIIndexMerger
,TabixIndexMerger
public abstract class IndexMerger<T> extends Object
Merges index files for (headerless) parts of a partitioned main file into a single index file. The file and directory structure for the partitioned file is defined in subclasses, but the general pattern is as follows. A partitioned file (e.g BAM, CRAM, or VCF) is a directory containing the following files:- A file named header containing all header bytes.
- Zero or more files named part-00000, part-00001, ... etc, containing file records, with no header.
- A file named terminator containing a file terminator. (This may be absent if it is not required by the format.)
-
-
Field Summary
Fields Modifier and Type Field Description protected OutputStream
out
protected List<Long>
partLengths
-
Constructor Summary
Constructors Constructor Description IndexMerger(OutputStream out, long headerLength)
Create an index merger.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract void
finish(long dataFileLength)
Finish merging the indexes, and close the output stream.abstract void
processIndex(T index, long partLength)
Process the next index and add to the merged index.
-
-
-
Field Detail
-
out
protected final OutputStream out
-
-
Constructor Detail
-
IndexMerger
public IndexMerger(OutputStream out, long headerLength)
Create an index merger.- Parameters:
out
- the output stream to write the merged index to. Must be uncompressed since the implementation of this class will provide appropriate compression.headerLength
- the length of the header file, in bytes.
-
-
Method Detail
-
processIndex
public abstract void processIndex(T index, long partLength)
Process the next index and add to the merged index.- Parameters:
index
- the index to mergepartLength
- the length of the part file corresponding to the index, in bytes.
-
finish
public abstract void finish(long dataFileLength) throws IOException
Finish merging the indexes, and close the output stream.- Parameters:
dataFileLength
- the length of the total data file, in bytes.- Throws:
IOException
- if an error occurs
-
-