Package htsjdk.samtools.cram.build
Class CompressionHeaderFactory
java.lang.Object
htsjdk.samtools.cram.build.CompressionHeaderFactory
Factory for creating CRAM compression headers for containers when writing to a CRAM stream. The fixed data
series are generally the same for every container in the stream (this is not required by the spec, but reflects
the current htsjdk implementation), however, the tag data series and encodings can vary across containers
based on which tags are present in the actual records for that container, and the best compressor to use based
on the actual data. This class delegates to a
CRAMEncodingStrategy object to determine which encodings
to use for the fixed CRAM data series, and dynamically chooses the best encoding for tag data series.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final int -
Constructor Summary
ConstructorsConstructorDescriptionCompressionHeaderFactory(CRAMEncodingStrategy encodingStrategy) Create a CompressionHeaderFactory using the provided CRAMEncodingStrategy. -
Method Summary
Modifier and TypeMethodDescriptioncreateCompressionHeader(List<CRAMCompressionRecord> containerCRAMCompressionRecords, boolean coordinateSorted) Creates a compression header for the provided list ofCRAMCompressionRecordobjects.getBestExternalCompressor(byte[] data) Get the best external compressor to use for the given byte array.static htsjdk.samtools.cram.build.CompressionHeaderFactory.ByteSizeRangegetByteSizeRangeOfTagValues(List<CRAMCompressionRecord> records, int tagID)
-
Field Details
-
BYTE_SPACE_SIZE
public static final int BYTE_SPACE_SIZE- See Also:
-
ALL_BYTES_USED
public static final int ALL_BYTES_USED- See Also:
-
-
Constructor Details
-
CompressionHeaderFactory
Create a CompressionHeaderFactory using the provided CRAMEncodingStrategy.- Parameters:
encodingStrategy-CRAMEncodingStrategyto use, may not be null
-
-
Method Details
-
createCompressionHeader
public CompressionHeader createCompressionHeader(List<CRAMCompressionRecord> containerCRAMCompressionRecords, boolean coordinateSorted) Creates a compression header for the provided list ofCRAMCompressionRecordobjects. Resets any internal state (i.e. the tag encoding map state) as preparation for starting the next compression header.- Parameters:
containerCRAMCompressionRecords- all CRAMRecords that will be stored in the containercoordinateSorted- if true the records are assumed to be sorted by alignment position- Returns:
CompressionHeaderfor the container forcontainerCRAMRecords
-
getEncodingStrategy
-
getBestExternalCompressor
Get the best external compressor to use for the given byte array.- Parameters:
data- byte array to compress- Returns:
- best compressor to use for the data
-
getByteSizeRangeOfTagValues
public static htsjdk.samtools.cram.build.CompressionHeaderFactory.ByteSizeRange getByteSizeRangeOfTagValues(List<CRAMCompressionRecord> records, int tagID)
-