@gmod/cram
Version:
read CRAM files with pure Javascript
27 lines • 1.17 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const _base_ts_1 = __importDefault(require("./_base.js"));
const getBits_ts_1 = require("./getBits.js");
const errors_ts_1 = require("../../errors.js");
class GammaCodec extends _base_ts_1.default {
constructor(parameters, dataType) {
super(parameters, dataType);
if (this.dataType !== 'int') {
throw new errors_ts_1.CramUnimplementedError(`${this.dataType} decoding not yet implemented by GAMMA codec`);
}
}
decode(_slice, coreDataBlock, _blocksByContentId, cursors) {
let length = 1;
while ((0, getBits_ts_1.getBits)(coreDataBlock.content, cursors.coreBlock, 1) === 0) {
length = length + 1;
}
const readBits = (0, getBits_ts_1.getBits)(coreDataBlock.content, cursors.coreBlock, length - 1);
const value = readBits | (1 << (length - 1));
return value - this.parameters.offset;
}
}
exports.default = GammaCodec;
//# sourceMappingURL=gamma.js.map