public final class SliceFactory
extends java.lang.Object
Slices when writing a CRAM stream. Determines when to emit a Slice, based on
a set of rules implemented by this class; the accumulated SliceEntry state objects; and the parameter values in
the provided CRAMEncodingStrategy object.| Constructor and Description |
|---|
SliceFactory(CRAMEncodingStrategy cramEncodingStrategy,
CRAMReferenceSource cramReferenceSource,
SAMFileHeader samFileHeader,
long globalRecordCounter) |
| Modifier and Type | Method and Description |
|---|---|
long |
createNewSliceEntry(int currentReferenceContextID,
java.util.List<SAMRecord> sliceSAMRecords)
Add a new slice entry, and return the number of sliceEntries.
|
java.util.List<Slice> |
createSlices(CompressionHeader compressionHeader,
long containerByteOffset)
Returns a set of Slices using the records accumulated by the factory, and resets the factory state.
|
java.util.List<CRAMCompressionRecord> |
getCRAMRecordsForAllSlices()
Get all CRAM records accumulated by the factory.
|
int |
getNumberOfSliceEntries() |
int |
getUpdatedReferenceContext(int currentReferenceContext,
int nextReferenceIndex,
int numberOfSAMRecords)
Decide if the current records should be flushed based on the current reference context, the reference context
for the next record to be written, and the number of records seen so far.
|
public SliceFactory(CRAMEncodingStrategy cramEncodingStrategy, CRAMReferenceSource cramReferenceSource, SAMFileHeader samFileHeader, long globalRecordCounter)
cramEncodingStrategy - CRAMEncodingStrategy to use for Slices that are createdcramReferenceSource - CRAMReferenceSource to use for Slices that are createdsamFileHeader - for input records, used for finding read groups, sort order, etc.globalRecordCounter - initial global record counter for Slices that are createdpublic long createNewSliceEntry(int currentReferenceContextID,
java.util.List<SAMRecord> sliceSAMRecords)
currentReferenceContextID - sliceSAMRecords - public java.util.List<CRAMCompressionRecord> getCRAMRecordsForAllSlices()
createSlices(htsjdk.samtools.cram.structure.CompressionHeader, long) is called.public int getNumberOfSliceEntries()
public java.util.List<Slice> createSlices(CompressionHeader compressionHeader, long containerByteOffset)
compressionHeader - the compression header to use to create the SlicescontainerByteOffset - the container byte offset to use for the newly created Slicespublic int getUpdatedReferenceContext(int currentReferenceContext,
int nextReferenceIndex,
int numberOfSAMRecords)
nextReferenceIndex - reference index of the next record to be emitted