Package htsjdk.samtools.cram.encoding
Class CRAMEncoding<T>
- java.lang.Object
-
- htsjdk.samtools.cram.encoding.CRAMEncoding<T>
-
- Type Parameters:
T
- the (source) data eries value type for this encoding. There is no way to express the type constraint on this type using Java type bounds, since the legitimate values are drawn from a set of Java types that correspond to the allowable types defined byDataSeriesType
, but logically it must be a type that corresponds to one of theDataSeriesType
"types", i.e., it must one of be Byte, Integer, Long or byte[].
- Direct Known Subclasses:
BetaIntegerEncoding
,ByteArrayLenEncoding
,ByteArrayStopEncoding
,CanonicalHuffmanByteEncoding
,CanonicalHuffmanIntegerEncoding
,ExternalEncoding
,GammaIntegerEncoding
,GolombIntegerEncoding
,GolombLongEncoding
,GolombRiceIntegerEncoding
,SubexponentialIntegerEncoding
public abstract class CRAMEncoding<T> extends Object
A base class for the various CRAM encodings. This class serves as a (typed) bridge between anEncodingDescriptor
, which only describes an encoding, and the variousCRAMCodec
classes, which can be used to read and write typed values to a stream. Has methods to serialize/deserialize its parameters to/from a byte array and a method to construct a read or writeCRAMCodec
instance.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CRAMEncoding(EncodingID encodingId)
Create a new encoding.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract CRAMCodec<T>
buildCodec(SliceBlocksReadStreams sliceBlocksReadStreams, SliceBlocksWriteStreams sliceBlocksWriteStreams)
Instantiate the codec represented by this encoding by supplying it with the appropriate streamsCRAMCodec<T>
buildReadCodec(SliceBlocksReadStreams sliceBlocksReadStreams)
Convenience initializer method for read codecsCRAMCodec<T>
buildWriteCodec(SliceBlocksWriteStreams sliceBlocksWriteStreams)
Convenience initializer method for write codecsEncodingID
id()
EncodingDescriptor
toEncodingDescriptor()
abstract byte[]
toSerializedEncodingParams()
Serialize encoding parameters to an ITF8-encoded byte array.
-
-
-
Constructor Detail
-
CRAMEncoding
protected CRAMEncoding(EncodingID encodingId)
Create a new encoding. Concrete implementation constructors will specify their parameters- Parameters:
encodingId
- the EncodingID associated with the concrete implementation
-
-
Method Detail
-
id
public EncodingID id()
-
toEncodingDescriptor
public EncodingDescriptor toEncodingDescriptor()
-
toSerializedEncodingParams
public abstract byte[] toSerializedEncodingParams()
Serialize encoding parameters to an ITF8-encoded byte array. By convention, each subclass should have a corresponding and symmetric "fromSerializedEncodingParams" that returns a new instance of that encoding populated with values from the serialized encoding params.- Returns:
- a byte array containing the encoding's parameter values encoded as an ITF8 stream.
-
buildCodec
public abstract CRAMCodec<T> buildCodec(SliceBlocksReadStreams sliceBlocksReadStreams, SliceBlocksWriteStreams sliceBlocksWriteStreams)
Instantiate the codec represented by this encoding by supplying it with the appropriate streams
-
buildReadCodec
public CRAMCodec<T> buildReadCodec(SliceBlocksReadStreams sliceBlocksReadStreams)
Convenience initializer method for read codecs- Parameters:
sliceBlocksReadStreams
- the core block bit stream aCoreCodec
will read from- Returns:
-
buildWriteCodec
public CRAMCodec<T> buildWriteCodec(SliceBlocksWriteStreams sliceBlocksWriteStreams)
Convenience initializer method for write codecs- Parameters:
sliceBlocksWriteStreams
- the core block bit stream aCoreCodec
will write to- Returns:
-
-