Class ExternalCompressor
java.lang.Object
htsjdk.samtools.cram.compression.ExternalCompressor
- Direct Known Subclasses:
BZIP2ExternalCompressor, FQZCompExternalCompressor, GZIPExternalCompressor, LZMAExternalCompressor, NameTokeniserExternalCompressor, RangeExternalCompressor, RANS4x8ExternalCompressor, RANSNx16ExternalCompressor, RAWExternalCompressor, TrialCompressor
Abstract base class for CRAM external block compressors. Each subclass wraps a specific
compression algorithm (GZIP, rANS, BZIP2, etc.) and provides compress/uncompress operations
on raw byte arrays. Instances are typically obtained via
getCompressorForMethod(BlockCompressionMethod, int).-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract byte[]compress(byte[] data, CRAMCodecModelContext contextModel) Compress the data using the codec-specific context model.booleanstatic ExternalCompressorgetCompressorForMethod(BlockCompressionMethod compressionMethod, int compressorSpecificArg) Return an ExternalCompressor subclass based on the BlockCompressionMethod.inthashCode()protected voidsetMethod(BlockCompressionMethod method) Set the compression method.toString()abstract byte[]uncompress(byte[] data) Decompress the data.
-
Field Details
-
NO_COMPRESSION_ARG
public static final int NO_COMPRESSION_ARG- See Also:
-
-
Constructor Details
-
ExternalCompressor
- Parameters:
method- the compression method for this compressor, or null if the method will be determined later (e.g., byTrialCompressorafter its first trial)
-
-
Method Details
-
setMethod
Set the compression method. For use by subclasses likeTrialCompressorthat determine their method after construction.- Parameters:
method- the compression method to set
-
compress
Compress the data using the codec-specific context model.- Parameters:
data- the data to compresscontextModel- the context model to use for compression; may be null- Returns:
- the compressed data
-
uncompress
public abstract byte[] uncompress(byte[] data) Decompress the data.- Parameters:
data- the compressed data- Returns:
- the decompressed data
-
getMethod
- Returns:
- the compression method used by this compressor
- Throws:
IllegalStateException- if the method has not been determined yet (compress() must be called first for compressors likeTrialCompressor)
-
toString
-
equals
-
hashCode
-
getCompressorForMethod
public static ExternalCompressor getCompressorForMethod(BlockCompressionMethod compressionMethod, int compressorSpecificArg) Return an ExternalCompressor subclass based on the BlockCompressionMethod. Compressor-specific arguments must be populated by the caller.- Parameters:
compressionMethod- the type of compressor required (BlockCompressionMethod)compressorSpecificArg- the required order for RANS compressors; or the desired write compression level for GZIP- Returns:
- an ExternalCompressor of the requested type, populated with an compressor-specific args
-