BBM Chromosome Data Encoding (Run-Length Compression)
masterChromosome data is a sequence of individual values, short runs, and long runs. Positions are implicit: the first value starts at position 0 and the sequence ends after chromLength values have been processed.
There are three ways to encode data:
- Individual Value: A single byte (0-100).
- Short Run (length 2-154): Two bytes total. The first byte (
runLength) is an offset:actual_length = runLength - 99. For example, arunLengthof101represents a run of length2. The second byte is therunValue(0-100). - Long Run (length 155-65535): Four bytes total. Starts with a
255flag, followed by a little-endian 16-bitrunLengthand a single-byterunValue(0-100).