Package htsjdk.samtools.cram.build
Class CompressionHeaderFactory
- java.lang.Object
-
- htsjdk.samtools.cram.build.CompressionHeaderFactory
-
public final class CompressionHeaderFactory extends Object
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 aCRAMEncodingStrategyobject to determine which encodings to use for the fixed CRAM data series, and dynamically chooses the best encoding for tag data series.
-
-
Field Summary
Fields Modifier and Type Field Description static intALL_BYTES_USEDstatic intBYTE_SPACE_SIZE
-
Constructor Summary
Constructors Constructor Description CompressionHeaderFactory(CRAMEncodingStrategy encodingStrategy)Create a CompressionHeaderFactory using the provided CRAMEncodingStrategy.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CompressionHeadercreateCompressionHeader(List<CRAMCompressionRecord> containerCRAMCompressionRecords, boolean coordinateSorted)Creates a compression header for the provided list ofCRAMCompressionRecordobjects.ExternalCompressorgetBestExternalCompressor(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)CRAMEncodingStrategygetEncodingStrategy()
-
-
-
Field Detail
-
BYTE_SPACE_SIZE
public static final int BYTE_SPACE_SIZE
- See Also:
- Constant Field Values
-
ALL_BYTES_USED
public static final int ALL_BYTES_USED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CompressionHeaderFactory
public CompressionHeaderFactory(CRAMEncodingStrategy encodingStrategy)
Create a CompressionHeaderFactory using the provided CRAMEncodingStrategy.- Parameters:
encodingStrategy-CRAMEncodingStrategyto use, may not be null
-
-
Method Detail
-
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
public CRAMEncodingStrategy getEncodingStrategy()
-
getBestExternalCompressor
public ExternalCompressor getBestExternalCompressor(byte[] data)
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)
-
-