# Class CompressionHeader

java.lang.Object
htsjdk.samtools.cram.structure.CompressionHeader

public class CompressionHeader extends Object

## Constructor Summary

Constructors
Constructor
Description
`CompressionHeader()`
Create a CompressionHeader using the default `CRAMEncodingStrategy`
`CompressionHeader(CRAMVersion cramVersion, InputStream blockStream)`
Read a COMPRESSION_HEADER Block from an InputStream and populate this CompressionHeader from its contents.
`CompressionHeader(CompressionHeaderEncodingMap encodingMap)`
Create a compression header using the given `CompressionHeaderEncodingMap`.
`CompressionHeader(CompressionHeaderEncodingMap encodingMap, boolean isAPDelta, boolean isPreserveReadNames, boolean isReferenceRequired)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addTagEncoding(int tagId, ExternalCompressor compressor, EncodingDescriptor params)`
`CompressionHeaderEncodingMap`
`getEncodingMap()`
Get the `CompressionHeaderEncodingMap` for this compression header.
`SubstitutionMatrix`
`getSubstitutionMatrix()`
`Map<Integer, EncodingDescriptor>`
`getTagEncodingMap()`
`byte[][][]`
`getTagIDDictionary()`
`TagKeyCache`
`getTagKeyCache()`
Returns the `TagKeyCache` for looking up pre-computed tag key metadata.
`boolean`
`isAPDelta()`
Return true if the header has APDelta set.
`boolean`
`isPreserveReadNames()`
`boolean`
`isReferenceRequired()`
`void`
`setSubstitutionMatrix(SubstitutionMatrix substitutionMatrix)`
`void`
`setTagIdDictionary(byte[][][] dictionary)`
`void`
`write(CRAMVersion cramVersion, OutputStream blockStream)`
Write this CompressionHeader out to an internal OutputStream, wrap it in a Block, and write that Block out to the passed-in OutputStream.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CompressionHeader

public CompressionHeader()
Create a CompressionHeader using the default `CRAMEncodingStrategy`

### CompressionHeader

public CompressionHeader(CompressionHeaderEncodingMap encodingMap, boolean isAPDelta, boolean isPreserveReadNames, boolean isReferenceRequired)

### CompressionHeader

public CompressionHeader(CompressionHeaderEncodingMap encodingMap)
Create a compression header using the given `CompressionHeaderEncodingMap`.

Parameters:
  `encodingMap` - the encoding map to use for this compression header

### CompressionHeader

public CompressionHeader(CRAMVersion cramVersion, InputStream blockStream)
Read a COMPRESSION_HEADER Block from an InputStream and populate this CompressionHeader from its contents.

Parameters:
  `cramVersion` - the CRAM version
  `blockStream` - the stream to read from

## Method Details

### getEncodingMap

public CompressionHeaderEncodingMap getEncodingMap()
Get the `CompressionHeaderEncodingMap` for this compression header.

Returns:
  `CompressionHeaderEncodingMap` for this `CompressionHeader`

### write

public void write(CRAMVersion cramVersion, OutputStream blockStream)
Write this CompressionHeader out to an internal OutputStream, wrap it in a Block, and write that Block out to the passed-in OutputStream.

Parameters:
  `cramVersion` - the CRAM version
  `blockStream` - the stream to write to

### isAPDelta

public boolean isAPDelta()
Return true if the header has APDelta set. Coordinate sorted input will use APDelta=true, but it is also permitted for other sort orders to use APDelta=true.

Returns:
  the value of the APDelta flag

### isPreserveReadNames

public boolean isPreserveReadNames()

### getTagEncodingMap

public Map<Integer, EncodingDescriptor> getTagEncodingMap()

### getSubstitutionMatrix

public SubstitutionMatrix getSubstitutionMatrix()

### getTagIDDictionary

public byte[][][] getTagIDDictionary()

### setTagIdDictionary

public void setTagIdDictionary(byte[][][] dictionary)

### getTagKeyCache

public TagKeyCache getTagKeyCache()
Returns the `TagKeyCache` for looking up pre-computed tag key metadata. Built from the tag ID dictionary when the compression header is parsed.

### setSubstitutionMatrix

public void setSubstitutionMatrix(SubstitutionMatrix substitutionMatrix)

### isReferenceRequired

public boolean isReferenceRequired()

Returns:
  true if RR is set on this compression header

### addTagEncoding

public void addTagEncoding(int tagId, ExternalCompressor compressor, EncodingDescriptor params)