@gmod/cram
Version:
read CRAM files with pure Javascript
21 lines • 867 B
JavaScript
import CramCodec from "./_base.js";
import { getBits } from "./getBits.js";
import { CramUnimplementedError } from "../../errors.js";
export default class GammaCodec extends CramCodec {
constructor(parameters, dataType) {
super(parameters, dataType);
if (this.dataType !== 'int') {
throw new CramUnimplementedError(`${this.dataType} decoding not yet implemented by GAMMA codec`);
}
}
decode(_slice, coreDataBlock, _blocksByContentId, cursors) {
let length = 1;
while (getBits(coreDataBlock.content, cursors.coreBlock, 1) === 0) {
length = length + 1;
}
const readBits = getBits(coreDataBlock.content, cursors.coreBlock, length - 1);
const value = readBits | (1 << (length - 1));
return value - this.parameters.offset;
}
}
//# sourceMappingURL=gamma.js.map