Class BetaIntegerCodec

java.lang.Object
htsjdk.samtools.cram.encoding.core.CoreCodec<Integer>
htsjdk.samtools.cram.encoding.core.BetaIntegerCodec
All Implemented Interfaces:
CRAMCodec<Integer>

public final class BetaIntegerCodec extends CoreCodec<Integer>
Encodes integers by adding a constant offset value to a range of values in order to reduce the necessary number of bits needed to store each value. As a simple example, consider a data series with values all in the range 10,000 - 10,100. Choosing the offset -10,000 means every encoded value will be stored as 0 - 100, requiring only ceil(log2(100)) = 7 bits per value.
  • Constructor Details

    • BetaIntegerCodec

      public BetaIntegerCodec(BitInputStream coreBlockInputStream, BitOutputStream coreBlockOutputStream, int offset, int bitsPerValue)
      Given integers to encode in the range MIN to MAX:
      Parameters:
      offset - the common value to be added to all values before storage. Setting this to (-MIN) will ensure all stored values will be in the range (0 .. MAX - MIN)
      bitsPerValue - the smallest value which will allow the largest stored value (MAX - MIN)
  • Method Details

    • read

      public final Integer read()
      Description copied from interface: CRAMCodec
      Read a single object from the stream
      Returns:
      an object from the stream
    • read

      public Integer read(int length)
      Description copied from interface: CRAMCodec
      Read a array of specified length from the stream
      Parameters:
      length - the number of elements to read
      Returns:
      an object from the stream
    • write

      public final void write(Integer value)
      Description copied from interface: CRAMCodec
      Write an object to the stream
      Parameters:
      value - the object to write