Package htsjdk.samtools.cram

# Class CRAIIndexMerger

java.lang.Object
htsjdk.samtools.IndexMerger<CRAIIndex>
htsjdk.samtools.cram.CRAIIndexMerger

public final class CRAIIndexMerger extends IndexMerger<CRAIIndex>
Merges CRAM index files for (headerless) parts of a CRAM file into a single index file. A partitioned CRAM is a directory containing the following files:

1. A file named header containing all header bytes (CRAM header and CRAM container containing the BAM header).
2. Zero or more files named part-00000, part-00001, ... etc, containing CRAM containers.
3. A file named terminator containing a CRAM end-of-file marker container.

If an index is required, a CRAM index can be generated for each (headerless) part file. These files should be named .part-00000.crai, .part-00001.crai, ... etc. Note the leading . to make the files hidden. This format has the following properties:

- Parts and their indexes may be written in parallel, since one part file can be written independently of the others.
- A CRAM file can be created from a partitioned CRAM file by merging all the non-hidden files (header, part-00000, part-00001, ..., terminator).
- A CRAM index can be created from a partitioned CRAM file by merging all of the hidden files with a .crai suffix. Note that this is not a simple file concatenation operation. See `CRAIIndexMerger`.

## Field Summary

### Fields inherited from class htsjdk.samtools.IndexMerger

`out, partLengths`

## Constructor Summary

Constructors
Constructor
Description
`CRAIIndexMerger(OutputStream out, long headerLength)`

## Method Summary

Modifier and Type
Method
Description
`void`
`finish(long dataFileLength)`
Finish merging the indexes, and close the output stream.
`void`
`processIndex(CRAIIndex index, long partLength)`
Process the next index and add to the merged index.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CRAIIndexMerger

public CRAIIndexMerger(OutputStream out, long headerLength) throws IOException

Throws:
  `IOException`

## Method Details

### processIndex

public void processIndex(CRAIIndex index, long partLength)
Description copied from class: `IndexMerger`
Process the next index and add to the merged index.

Specified by:
  `processIndex` in class `IndexMerger<CRAIIndex>`
Parameters:
  `index` - the index to merge
  `partLength` - the length of the part file corresponding to the index, in bytes.

### finish

public void finish(long dataFileLength) throws IOException
Description copied from class: `IndexMerger`
Finish merging the indexes, and close the output stream.

Specified by:
  `finish` in class `IndexMerger<CRAIIndex>`
Parameters:
  `dataFileLength` - the length of the total data file, in bytes.
Throws:
  `IOException` - if an error occurs