Comparing version 1.1.8 to 1.1.9
@@ -0,1 +1,9 @@ | ||
<a name="1.1.9"></a> | ||
## [1.1.9](https://github.com/GMOD/bam-js/compare/v1.1.8...v1.1.9) (2021-12-14) | ||
- Add ESM module export in package.json (smaller bundle size for consumers) | ||
- Cache BAI readFile result for compatibility with node.js native filehandles (which otherwise fail if re-reading the filehandle twice) | ||
<a name="1.1.8"></a> | ||
@@ -2,0 +10,0 @@ ## [1.1.8](https://github.com/GMOD/bam-js/compare/v1.1.7...v1.1.8) (2021-05-21) |
@@ -6,2 +6,3 @@ /// <reference types="node" /> | ||
export default class BAI extends IndexFile { | ||
baiP?: Promise<Buffer>; | ||
parsePseudoBin(bytes: Buffer, offset: number): { | ||
@@ -11,2 +12,3 @@ lineCount: number; | ||
lineCount(refId: number, opts?: BaseOpts): Promise<any>; | ||
fetchBai(opts?: BaseOpts): Promise<Buffer>; | ||
_parse(opts?: BaseOpts): Promise<{ | ||
@@ -13,0 +15,0 @@ [key: string]: any; |
848
dist/bai.js
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty2(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _getIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/get-iterator")); | ||
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array")); | ||
var _getIteratorMethod2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/get-iterator-method")); | ||
var _symbol = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/symbol")); | ||
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property")); | ||
var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-properties")); | ||
var _getOwnPropertyDescriptors = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors")); | ||
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each")); | ||
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor")); | ||
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter")); | ||
var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols")); | ||
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys")); | ||
var _construct = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/reflect/construct")); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray")); | ||
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty")); | ||
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map")); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator")); | ||
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf")); | ||
var _long = _interopRequireDefault(require("long")); | ||
var _virtualOffset = require("./virtualOffset"); | ||
var _chunk = _interopRequireDefault(require("./chunk")); | ||
var _indexFile = _interopRequireDefault(require("./indexFile")); | ||
var _util = require("./util"); | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof _symbol.default === "undefined" || (0, _getIteratorMethod2.default)(o) == null) { if ((0, _isArray.default)(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = (0, _getIterator2.default)(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { var _context7; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = (0, _slice.default)(_context7 = Object.prototype.toString.call(o)).call(_context7, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return (0, _from.default)(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function ownKeys(object, enumerableOnly) { var keys = (0, _keys.default)(object); if (_getOwnPropertySymbols.default) { var symbols = (0, _getOwnPropertySymbols.default)(object); if (enumerableOnly) symbols = (0, _filter.default)(symbols).call(symbols, function (sym) { return (0, _getOwnPropertyDescriptor.default)(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context5; (0, _forEach.default)(_context5 = ownKeys(Object(source), true)).call(_context5, function (key) { (0, _defineProperty3.default)(target, key, source[key]); }); } else if (_getOwnPropertyDescriptors.default) { (0, _defineProperties.default)(target, (0, _getOwnPropertyDescriptors.default)(source)); } else { var _context6; (0, _forEach.default)(_context6 = ownKeys(Object(source))).call(_context6, function (key) { (0, _defineProperty2.default)(target, key, (0, _getOwnPropertyDescriptor.default)(source, key)); }); } } return target; } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = (0, _construct.default)(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_construct.default) return false; if (_construct.default.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call((0, _construct.default)(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var long_1 = __importDefault(require("long")); | ||
var virtualOffset_1 = require("./virtualOffset"); | ||
var chunk_1 = __importDefault(require("./chunk")); | ||
var indexFile_1 = __importDefault(require("./indexFile")); | ||
var util_1 = require("./util"); | ||
var BAI_MAGIC = 21578050; // BAI\1 | ||
function roundDown(n, multiple) { | ||
return n - n % multiple; | ||
return n - (n % multiple); | ||
} | ||
function roundUp(n, multiple) { | ||
return n - n % multiple + multiple; | ||
return n - (n % multiple) + multiple; | ||
} | ||
var BAI = /*#__PURE__*/function (_IndexFile) { | ||
(0, _inherits2.default)(BAI, _IndexFile); | ||
var _super = _createSuper(BAI); | ||
function BAI() { | ||
(0, _classCallCheck2.default)(this, BAI); | ||
return _super.apply(this, arguments); | ||
} | ||
(0, _createClass2.default)(BAI, [{ | ||
key: "parsePseudoBin", | ||
value: function parsePseudoBin(bytes, offset) { | ||
var lineCount = (0, _util.longToNumber)(_long.default.fromBytesLE((0, _slice.default)(Array.prototype).call(bytes, offset + 16, offset + 24), true)); | ||
return { | ||
lineCount: lineCount | ||
}; | ||
var BAI = /** @class */ (function (_super) { | ||
__extends(BAI, _super); | ||
function BAI() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
}, { | ||
key: "lineCount", | ||
value: function () { | ||
var _lineCount = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(refId) { | ||
var opts, | ||
prom, | ||
index, | ||
ret, | ||
_args = arguments; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
opts = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
_context.next = 3; | ||
return this.parse(opts); | ||
case 3: | ||
prom = _context.sent; | ||
index = prom.indices[refId]; | ||
if (index) { | ||
_context.next = 7; | ||
break; | ||
BAI.prototype.parsePseudoBin = function (bytes, offset) { | ||
var lineCount = (0, util_1.longToNumber)(long_1.default.fromBytesLE(Array.prototype.slice.call(bytes, offset + 16, offset + 24), true)); | ||
return { lineCount: lineCount }; | ||
}; | ||
BAI.prototype.lineCount = function (refId, opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var prom, index, ret; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.parse(opts)]; | ||
case 1: | ||
prom = _a.sent(); | ||
index = prom.indices[refId]; | ||
if (!index) { | ||
return [2 /*return*/, -1]; | ||
} | ||
ret = index.stats || {}; | ||
return [2 /*return*/, ret.lineCount === undefined ? -1 : ret.lineCount]; | ||
} | ||
return _context.abrupt("return", -1); | ||
case 7: | ||
ret = index.stats || {}; | ||
return _context.abrupt("return", ret.lineCount === undefined ? -1 : ret.lineCount); | ||
case 9: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
function lineCount(_x) { | ||
return _lineCount.apply(this, arguments); | ||
} | ||
return lineCount; | ||
}() // fetch and parse the index | ||
}, { | ||
key: "_parse", | ||
value: function () { | ||
var _parse2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() { | ||
var opts, | ||
data, | ||
bytes, | ||
depth, | ||
binLimit, | ||
currOffset, | ||
i, | ||
binCount, | ||
stats, | ||
binIndex, | ||
j, | ||
bin, | ||
chunkCount, | ||
chunks, | ||
k, | ||
u, | ||
v, | ||
linearCount, | ||
linearIndex, | ||
_k, | ||
_args2 = arguments; | ||
return _regenerator.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
opts = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}; | ||
data = { | ||
bai: true, | ||
maxBlockSize: 1 << 16 | ||
}; | ||
_context2.next = 4; | ||
return this.filehandle.readFile(opts); | ||
case 4: | ||
bytes = _context2.sent; | ||
if (!(bytes.readUInt32LE(0) !== BAI_MAGIC)) { | ||
_context2.next = 7; | ||
break; | ||
}); | ||
}); | ||
}; | ||
BAI.prototype.fetchBai = function (opts) { | ||
var _this = this; | ||
if (opts === void 0) { opts = {}; } | ||
if (!this.baiP) { | ||
this.baiP = this.filehandle.readFile(opts).catch(function (e) { | ||
_this.baiP = undefined; | ||
throw e; | ||
}); | ||
} | ||
return this.baiP; | ||
}; | ||
// fetch and parse the index | ||
BAI.prototype._parse = function (opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, bytes, depth, binLimit, currOffset, i, binCount, stats, binIndex, j, bin, chunkCount, chunks, k, u, v, linearCount, linearIndex, k; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
data = { bai: true, maxBlockSize: 1 << 16 }; | ||
return [4 /*yield*/, this.fetchBai() | ||
// check BAI magic numbers | ||
]; | ||
case 1: | ||
bytes = _a.sent(); | ||
// check BAI magic numbers | ||
if (bytes.readUInt32LE(0) !== BAI_MAGIC) { | ||
throw new Error('Not a BAI file'); | ||
} | ||
data.refCount = bytes.readInt32LE(4); | ||
depth = 5; | ||
binLimit = ((1 << ((depth + 1) * 3)) - 1) / 7; | ||
// read the indexes for each reference sequence | ||
data.indices = new Array(data.refCount); | ||
currOffset = 8; | ||
i = 0; | ||
_a.label = 2; | ||
case 2: | ||
if (!(i < data.refCount)) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, (0, util_1.abortBreakPoint)(opts.signal) | ||
// the binning index | ||
]; | ||
case 3: | ||
_a.sent(); | ||
binCount = bytes.readInt32LE(currOffset); | ||
stats = void 0; | ||
currOffset += 4; | ||
binIndex = {}; | ||
for (j = 0; j < binCount; j += 1) { | ||
bin = bytes.readUInt32LE(currOffset); | ||
currOffset += 4; | ||
if (bin === binLimit + 1) { | ||
currOffset += 4; | ||
stats = this.parsePseudoBin(bytes, currOffset); | ||
currOffset += 32; | ||
} | ||
else if (bin > binLimit + 1) { | ||
throw new Error('bai index contains too many bins, please use CSI'); | ||
} | ||
else { | ||
chunkCount = bytes.readInt32LE(currOffset); | ||
currOffset += 4; | ||
chunks = new Array(chunkCount); | ||
for (k = 0; k < chunkCount; k += 1) { | ||
u = (0, virtualOffset_1.fromBytes)(bytes, currOffset); | ||
v = (0, virtualOffset_1.fromBytes)(bytes, currOffset + 8); | ||
currOffset += 16; | ||
this._findFirstData(data, u); | ||
chunks[k] = new chunk_1.default(u, v, bin); | ||
} | ||
binIndex[bin] = chunks; | ||
} | ||
} | ||
linearCount = bytes.readInt32LE(currOffset); | ||
currOffset += 4; | ||
linearIndex = new Array(linearCount); | ||
for (k = 0; k < linearCount; k += 1) { | ||
linearIndex[k] = (0, virtualOffset_1.fromBytes)(bytes, currOffset); | ||
currOffset += 8; | ||
this._findFirstData(data, linearIndex[k]); | ||
} | ||
data.indices[i] = { binIndex: binIndex, linearIndex: linearIndex, stats: stats }; | ||
_a.label = 4; | ||
case 4: | ||
i += 1; | ||
return [3 /*break*/, 2]; | ||
case 5: return [2 /*return*/, data]; | ||
} | ||
throw new Error('Not a BAI file'); | ||
case 7: | ||
data.refCount = bytes.readInt32LE(4); | ||
depth = 5; | ||
binLimit = ((1 << (depth + 1) * 3) - 1) / 7; // read the indexes for each reference sequence | ||
data.indices = new Array(data.refCount); | ||
currOffset = 8; | ||
i = 0; | ||
case 13: | ||
if (!(i < data.refCount)) { | ||
_context2.next = 50; | ||
break; | ||
}); | ||
}); | ||
}; | ||
BAI.prototype.indexCov = function (seqId, start, end, opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var v, range, indexData, seqIdx, _a, linearIndex, stats, e, s, depths, totalSize, currentPos, i, j; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
v = 16384; | ||
range = start !== undefined; | ||
return [4 /*yield*/, this.parse(opts)]; | ||
case 1: | ||
indexData = _b.sent(); | ||
seqIdx = indexData.indices[seqId]; | ||
if (!seqIdx) { | ||
return [2 /*return*/, []]; | ||
} | ||
_a = seqIdx.linearIndex, linearIndex = _a === void 0 ? [] : _a, stats = seqIdx.stats; | ||
if (!linearIndex.length) { | ||
return [2 /*return*/, []]; | ||
} | ||
e = end !== undefined ? roundUp(end, v) : (linearIndex.length - 1) * v; | ||
s = start !== undefined ? roundDown(start, v) : 0; | ||
if (range) { | ||
depths = new Array((e - s) / v); | ||
} | ||
else { | ||
depths = new Array(linearIndex.length - 1); | ||
} | ||
totalSize = linearIndex[linearIndex.length - 1].blockPosition; | ||
if (e > (linearIndex.length - 1) * v) { | ||
throw new Error('query outside of range of linear index'); | ||
} | ||
currentPos = linearIndex[s / v].blockPosition; | ||
for (i = s / v, j = 0; i < e / v; i++, j++) { | ||
depths[j] = { | ||
score: linearIndex[i + 1].blockPosition - currentPos, | ||
start: i * v, | ||
end: i * v + v, | ||
}; | ||
currentPos = linearIndex[i + 1].blockPosition; | ||
} | ||
return [2 /*return*/, depths.map(function (d) { | ||
return __assign(__assign({}, d), { score: (d.score * stats.lineCount) / totalSize }); | ||
})]; | ||
} | ||
_context2.next = 16; | ||
return (0, _util.abortBreakPoint)(opts.signal); | ||
case 16: | ||
// the binning index | ||
binCount = bytes.readInt32LE(currOffset); | ||
stats = void 0; | ||
currOffset += 4; | ||
binIndex = {}; | ||
j = 0; | ||
case 21: | ||
if (!(j < binCount)) { | ||
_context2.next = 42; | ||
break; | ||
} | ||
bin = bytes.readUInt32LE(currOffset); | ||
currOffset += 4; | ||
if (!(bin === binLimit + 1)) { | ||
_context2.next = 30; | ||
break; | ||
} | ||
currOffset += 4; | ||
stats = this.parsePseudoBin(bytes, currOffset); | ||
currOffset += 32; | ||
_context2.next = 39; | ||
break; | ||
case 30: | ||
if (!(bin > binLimit + 1)) { | ||
_context2.next = 34; | ||
break; | ||
} | ||
throw new Error('bai index contains too many bins, please use CSI'); | ||
case 34: | ||
chunkCount = bytes.readInt32LE(currOffset); | ||
currOffset += 4; | ||
chunks = new Array(chunkCount); | ||
for (k = 0; k < chunkCount; k += 1) { | ||
u = (0, _virtualOffset.fromBytes)(bytes, currOffset); | ||
v = (0, _virtualOffset.fromBytes)(bytes, currOffset + 8); | ||
currOffset += 16; | ||
this._findFirstData(data, u); | ||
chunks[k] = new _chunk.default(u, v, bin); | ||
} | ||
binIndex[bin] = chunks; | ||
case 39: | ||
j += 1; | ||
_context2.next = 21; | ||
break; | ||
case 42: | ||
linearCount = bytes.readInt32LE(currOffset); | ||
currOffset += 4; // as we're going through the linear index, figure out | ||
// the smallest virtual offset in the indexes, which | ||
// tells us where the BAM header ends | ||
linearIndex = new Array(linearCount); | ||
for (_k = 0; _k < linearCount; _k += 1) { | ||
linearIndex[_k] = (0, _virtualOffset.fromBytes)(bytes, currOffset); | ||
currOffset += 8; | ||
this._findFirstData(data, linearIndex[_k]); | ||
} | ||
data.indices[i] = { | ||
binIndex: binIndex, | ||
linearIndex: linearIndex, | ||
stats: stats | ||
}; | ||
case 47: | ||
i += 1; | ||
_context2.next = 13; | ||
break; | ||
case 50: | ||
return _context2.abrupt("return", data); | ||
case 51: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
})); | ||
function _parse() { | ||
return _parse2.apply(this, arguments); | ||
} | ||
return _parse; | ||
}() | ||
}, { | ||
key: "indexCov", | ||
value: function () { | ||
var _indexCov = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(seqId, start, end) { | ||
var opts, | ||
v, | ||
range, | ||
indexData, | ||
seqIdx, | ||
_seqIdx$linearIndex, | ||
linearIndex, | ||
stats, | ||
e, | ||
s, | ||
depths, | ||
totalSize, | ||
currentPos, | ||
i, | ||
j, | ||
_args3 = arguments; | ||
return _regenerator.default.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
opts = _args3.length > 3 && _args3[3] !== undefined ? _args3[3] : {}; | ||
v = 16384; | ||
range = start !== undefined; | ||
_context3.next = 5; | ||
return this.parse(opts); | ||
case 5: | ||
indexData = _context3.sent; | ||
seqIdx = indexData.indices[seqId]; | ||
if (seqIdx) { | ||
_context3.next = 9; | ||
break; | ||
} | ||
return _context3.abrupt("return", []); | ||
case 9: | ||
_seqIdx$linearIndex = seqIdx.linearIndex, linearIndex = _seqIdx$linearIndex === void 0 ? [] : _seqIdx$linearIndex, stats = seqIdx.stats; | ||
if (linearIndex.length) { | ||
_context3.next = 12; | ||
break; | ||
} | ||
return _context3.abrupt("return", []); | ||
case 12: | ||
e = end !== undefined ? roundUp(end, v) : (linearIndex.length - 1) * v; | ||
s = start !== undefined ? roundDown(start, v) : 0; | ||
if (range) { | ||
depths = new Array((e - s) / v); | ||
} else { | ||
depths = new Array(linearIndex.length - 1); | ||
} | ||
totalSize = linearIndex[linearIndex.length - 1].blockPosition; | ||
if (!(e > (linearIndex.length - 1) * v)) { | ||
_context3.next = 18; | ||
break; | ||
} | ||
throw new Error('query outside of range of linear index'); | ||
case 18: | ||
currentPos = linearIndex[s / v].blockPosition; | ||
for (i = s / v, j = 0; i < e / v; i++, j++) { | ||
depths[j] = { | ||
score: linearIndex[i + 1].blockPosition - currentPos, | ||
start: i * v, | ||
end: i * v + v | ||
}; | ||
currentPos = linearIndex[i + 1].blockPosition; | ||
} | ||
return _context3.abrupt("return", (0, _map.default)(depths).call(depths, function (d) { | ||
return _objectSpread(_objectSpread({}, d), {}, { | ||
score: d.score * stats.lineCount / totalSize | ||
}); | ||
})); | ||
case 21: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
})); | ||
function indexCov(_x2, _x3, _x4) { | ||
return _indexCov.apply(this, arguments); | ||
} | ||
return indexCov; | ||
}() | ||
}); | ||
}); | ||
}; | ||
/** | ||
@@ -436,131 +251,68 @@ * calculate the list of bins that may overlap with region [beg,end) (zero-based half-open) | ||
*/ | ||
}, { | ||
key: "reg2bins", | ||
value: function reg2bins(beg, end) { | ||
end -= 1; | ||
return [[0, 0], [1 + (beg >> 26), 1 + (end >> 26)], [9 + (beg >> 23), 9 + (end >> 23)], [73 + (beg >> 20), 73 + (end >> 20)], [585 + (beg >> 17), 585 + (end >> 17)], [4681 + (beg >> 14), 4681 + (end >> 14)]]; | ||
} | ||
}, { | ||
key: "blocksForRange", | ||
value: function () { | ||
var _blocksForRange = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(refId, min, max) { | ||
var opts, | ||
indexData, | ||
ba, | ||
overlappingBins, | ||
chunks, | ||
_iterator, | ||
_step, | ||
_step$value, | ||
start, | ||
end, | ||
bin, | ||
binChunks, | ||
c, | ||
nintv, | ||
lowest, | ||
minLin, | ||
maxLin, | ||
i, | ||
vp, | ||
_args4 = arguments; | ||
return _regenerator.default.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
opts = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : {}; | ||
if (min < 0) { | ||
min = 0; | ||
} | ||
_context4.next = 4; | ||
return this.parse(opts); | ||
case 4: | ||
indexData = _context4.sent; | ||
if (indexData) { | ||
_context4.next = 7; | ||
break; | ||
} | ||
return _context4.abrupt("return", []); | ||
case 7: | ||
ba = indexData.indices[refId]; | ||
if (ba) { | ||
_context4.next = 10; | ||
break; | ||
} | ||
return _context4.abrupt("return", []); | ||
case 10: | ||
overlappingBins = this.reg2bins(min, max); // List of bin #s that overlap min, max | ||
chunks = []; // Find chunks in overlapping bins. Leaf bins (< 4681) are not pruned | ||
_iterator = _createForOfIteratorHelper(overlappingBins); | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
_step$value = (0, _slicedToArray2.default)(_step.value, 2), start = _step$value[0], end = _step$value[1]; | ||
for (bin = start; bin <= end; bin++) { | ||
if (ba.binIndex[bin]) { | ||
binChunks = ba.binIndex[bin]; | ||
for (c = 0; c < binChunks.length; ++c) { | ||
chunks.push(new _chunk.default(binChunks[c].minv, binChunks[c].maxv, bin)); | ||
BAI.prototype.reg2bins = function (beg, end) { | ||
end -= 1; | ||
return [ | ||
[0, 0], | ||
[1 + (beg >> 26), 1 + (end >> 26)], | ||
[9 + (beg >> 23), 9 + (end >> 23)], | ||
[73 + (beg >> 20), 73 + (end >> 20)], | ||
[585 + (beg >> 17), 585 + (end >> 17)], | ||
[4681 + (beg >> 14), 4681 + (end >> 14)], | ||
]; | ||
}; | ||
BAI.prototype.blocksForRange = function (refId, min, max, opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var indexData, ba, overlappingBins, chunks, _i, overlappingBins_1, _a, start, end, bin, binChunks, c, nintv, lowest, minLin, maxLin, i, vp; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (min < 0) { | ||
min = 0; | ||
} | ||
} | ||
} | ||
} // Use the linear index to find minimum file position of chunks that could contain alignments in the region | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
return [4 /*yield*/, this.parse(opts)]; | ||
case 1: | ||
indexData = _b.sent(); | ||
if (!indexData) { | ||
return [2 /*return*/, []]; | ||
} | ||
ba = indexData.indices[refId]; | ||
if (!ba) { | ||
return [2 /*return*/, []]; | ||
} | ||
overlappingBins = this.reg2bins(min, max) // List of bin #s that overlap min, max | ||
; | ||
chunks = []; | ||
// Find chunks in overlapping bins. Leaf bins (< 4681) are not pruned | ||
for (_i = 0, overlappingBins_1 = overlappingBins; _i < overlappingBins_1.length; _i++) { | ||
_a = overlappingBins_1[_i], start = _a[0], end = _a[1]; | ||
for (bin = start; bin <= end; bin++) { | ||
if (ba.binIndex[bin]) { | ||
binChunks = ba.binIndex[bin]; | ||
for (c = 0; c < binChunks.length; ++c) { | ||
chunks.push(new chunk_1.default(binChunks[c].minv, binChunks[c].maxv, bin)); | ||
} | ||
} | ||
} | ||
} | ||
nintv = ba.linearIndex.length; | ||
lowest = null; | ||
minLin = Math.min(min >> 14, nintv - 1); | ||
maxLin = Math.min(max >> 14, nintv - 1); | ||
for (i = minLin; i <= maxLin; ++i) { | ||
vp = ba.linearIndex[i]; | ||
if (vp) { | ||
if (!lowest || vp.compareTo(lowest) < 0) { | ||
lowest = vp; | ||
} | ||
} | ||
} | ||
return [2 /*return*/, (0, util_1.optimizeChunks)(chunks, lowest)]; | ||
} | ||
nintv = ba.linearIndex.length; | ||
lowest = null; | ||
minLin = Math.min(min >> 14, nintv - 1); | ||
maxLin = Math.min(max >> 14, nintv - 1); | ||
for (i = minLin; i <= maxLin; ++i) { | ||
vp = ba.linearIndex[i]; | ||
if (vp) { | ||
if (!lowest || vp.compareTo(lowest) < 0) { | ||
lowest = vp; | ||
} | ||
} | ||
} | ||
return _context4.abrupt("return", (0, _util.optimizeChunks)(chunks, lowest)); | ||
case 20: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
})); | ||
function blocksForRange(_x5, _x6, _x7) { | ||
return _blocksForRange.apply(this, arguments); | ||
} | ||
return blocksForRange; | ||
}() | ||
}]); | ||
return BAI; | ||
}(_indexFile.default); | ||
}); | ||
}); | ||
}; | ||
return BAI; | ||
}(indexFile_1.default)); | ||
exports.default = BAI; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9iYWkudHMiXSwibmFtZXMiOlsiQkFJX01BR0lDIiwicm91bmREb3duIiwibiIsIm11bHRpcGxlIiwicm91bmRVcCIsIkJBSSIsImJ5dGVzIiwib2Zmc2V0IiwibGluZUNvdW50IiwiTG9uZyIsImZyb21CeXRlc0xFIiwiQ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vciAobGV0IGogPSAwOyBqIDwgYmluQ291bnQ7IGogKz0gMSkge1xuICAgICAgICBjb25zdCBiaW4gPSBieXRlcy5yZWFkVUludDMyTEUoY3Vyck9mZnNldClcbiAgICAgICAgY3Vyck9mZnNldCArPSA0XG4gICAgICAgIGlmIChiaW4gPT09IGJpbkxpbWl0ICsgMSkge1xuICAgICAgICAgIGN1cnJPZmZzZXQgKz0gNFxuICAgICAgICAgIHN0YXRzID0gdGhpcy5wYXJzZVBzZXVkb0JpbihieXRlcywgY3Vyck9mZnNldClcbiAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDMyXG4gICAgICAgIH0gZWxzZSBpZiAoYmluID4gYmluTGltaXQgKyAxKSB7XG4gICAgICAgICAgdGhyb3cgbmV3IEVycm9yKCdiYWkgaW5kZXggY29udGFpbnMgdG9vIG1hbnkgYmlucywgcGxlYXNlIHVzZSBDU0knKVxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbnN0IGNodW5rQ291bnQgPSBieXRlcy5yZWFkSW50MzJMRShjdXJyT2Zmc2V0KVxuICAgICAgICAgIGN1cnJPZmZzZXQgKz0gNFxuICAgICAgICAgIGNvbnN0IGNodW5rcyA9IG5ldyBBcnJheShjaHVua0NvdW50KVxuICAgICAgICAgIGZvciAobGV0IGsgPSAwOyBrIDwgY2h1bmtDb3VudDsgayArPSAxKSB7XG4gICAgICAgICAgICBjb25zdCB1ID0gZnJvbUJ5dGVzKGJ5dGVzLCBjdXJyT2Zmc2V0KVxuICAgICAgICAgICAgY29uc3QgdiA9IGZyb21CeXRlcyhieXRlcywgY3Vyck9mZnNldCArIDgpXG4gICAgICAgICAgICBjdXJyT2Zmc2V0ICs9IDE2XG4gICAgICAgICAgICB0aGlzLl9maW5kRmlyc3REYXRhKGRhdGEsIHUpXG4gICAgICAgICAgICBjaHVua3Nba10gPSBuZXcgQ2h1bmsodSwgdiwgYmluKVxuICAgICAgICAgIH1cbiAgICAgICAgICBiaW5JbmRleFtiaW5dID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ICAgfVxuICAgIH1cblxuICAgIC8vIFVzZSB0aGUgbGluZWFyIGluZGV4IHRvIGZpbmQgbWluaW11bSBmaWxlIHBvc2l0aW9uIG9mIGNodW5rcyB0aGF0IGNvdWxkIGNvbnRhaW4gYWxpZ25tZW50cyBpbiB0aGUgcmVnaW9uXG4gICAgY29uc3QgbmludHYgPSBiYS5saW5lYXJJbmRleC5sZW5ndGhcbiAgICBsZXQgbG93ZXN0ID0gbnVsbFxuICAgIGNvbnN0IG1pbkxpbiA9IE1hdGgubWluKG1pbiA+PiAxNCwgbmludHYgLSAxKVxuICAgIGNvbnN0IG1heExpbiA9IE1hdGgubWluKG1heCA+PiAxNCwgbmludHYgLSAxKVxuICAgIGZvciAobGV0IGkgPSBtaW5MaW47IGkgPD0gbWF4TGluOyArK2kpIHtcbiAgICAgIGNvbnN0IHZwID0gYmEubGluZWFySW5kZXhbaV1cbiAgICAgIGlmICh2cCkge1xuICAgICAgICBpZiAoIWxvd2VzdCB8fCB2cC5jb21wYXJlVG8obG93ZXN0KSA8IDApIHtcbiAgICAgICAgICBsb3dlc3QgPSB2cFxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIG9wdGltaXplQ2h1bmtzKGNodW5rcywgbG93ZXN0KVxuICB9XG59XG4iXX0= | ||
//# sourceMappingURL=bai.js.map |
@@ -14,3 +14,2 @@ /// <reference types="node" /> | ||
private header; | ||
protected featureCache: any; | ||
protected chrToIndex: any; | ||
@@ -26,3 +25,3 @@ protected indexToChr: any; | ||
*/ | ||
constructor({ bamFilehandle, bamPath, bamUrl, baiPath, baiFilehandle, baiUrl, csiPath, csiFilehandle, csiUrl, cacheSize, fetchSizeLimit, chunkSizeLimit, yieldThreadTime, renameRefSeqs, }: { | ||
constructor({ bamFilehandle, bamPath, bamUrl, baiPath, baiFilehandle, baiUrl, csiPath, csiFilehandle, csiUrl, fetchSizeLimit, chunkSizeLimit, yieldThreadTime, renameRefSeqs, }: { | ||
bamFilehandle?: GenericFilehandle; | ||
@@ -37,3 +36,2 @@ bamPath?: string; | ||
csiUrl?: string; | ||
cacheSize?: number; | ||
fetchSizeLimit?: number; | ||
@@ -66,9 +64,9 @@ chunkSizeLimit?: number; | ||
_readChunk({ chunk, opts }: { | ||
chunk: unknown; | ||
chunk: Chunk; | ||
opts: BaseOpts; | ||
}, abortSignal?: AbortSignal): Promise<never[] | { | ||
}): Promise<{ | ||
data: any; | ||
cpositions: any; | ||
dpositions: any; | ||
chunk: unknown; | ||
chunk: Chunk; | ||
}>; | ||
@@ -75,0 +73,0 @@ readBamFeatures(ba: Buffer, cpositions: number[], dpositions: number[], chunk: Chunk): Promise<BAMFeature[]>; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// little class representing a chunk in the index | ||
var Chunk = /*#__PURE__*/function () { | ||
/** | ||
* @param {VirtualOffset} minv | ||
* @param {VirtualOffset} maxv | ||
* @param {number} bin | ||
* @param {number} [fetchedSize] | ||
*/ | ||
function Chunk(minv, maxv, bin) { | ||
var fetchedSize = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : undefined; | ||
(0, _classCallCheck2.default)(this, Chunk); | ||
(0, _defineProperty2.default)(this, "minv", void 0); | ||
(0, _defineProperty2.default)(this, "maxv", void 0); | ||
(0, _defineProperty2.default)(this, "bin", void 0); | ||
(0, _defineProperty2.default)(this, "_fetchedSize", void 0); | ||
this.minv = minv; | ||
this.maxv = maxv; | ||
this.bin = bin; | ||
this._fetchedSize = fetchedSize; | ||
} | ||
(0, _createClass2.default)(Chunk, [{ | ||
key: "toUniqueString", | ||
value: function toUniqueString() { | ||
var _context, _context2, _context3; | ||
return (0, _concat.default)(_context = (0, _concat.default)(_context2 = (0, _concat.default)(_context3 = "".concat(this.minv, "..")).call(_context3, this.maxv, " (bin ")).call(_context2, this.bin, ", fetchedSize ")).call(_context, this.fetchedSize(), ")"); | ||
var Chunk = /** @class */ (function () { | ||
/** | ||
* @param {VirtualOffset} minv | ||
* @param {VirtualOffset} maxv | ||
* @param {number} bin | ||
* @param {number} [fetchedSize] | ||
*/ | ||
function Chunk(minv, maxv, bin, fetchedSize) { | ||
if (fetchedSize === void 0) { fetchedSize = undefined; } | ||
this.minv = minv; | ||
this.maxv = maxv; | ||
this.bin = bin; | ||
this._fetchedSize = fetchedSize; | ||
} | ||
}, { | ||
key: "toString", | ||
value: function toString() { | ||
return this.toUniqueString(); | ||
} | ||
}, { | ||
key: "compareTo", | ||
value: function compareTo(b) { | ||
return this.minv.compareTo(b.minv) || this.maxv.compareTo(b.maxv) || this.bin - b.bin; | ||
} | ||
}, { | ||
key: "fetchedSize", | ||
value: function fetchedSize() { | ||
if (this._fetchedSize !== undefined) { | ||
return this._fetchedSize; | ||
} | ||
return this.maxv.blockPosition + (1 << 16) - this.minv.blockPosition; | ||
} | ||
}]); | ||
return Chunk; | ||
}(); | ||
Chunk.prototype.toUniqueString = function () { | ||
return "".concat(this.minv, "..").concat(this.maxv, " (bin ").concat(this.bin, ", fetchedSize ").concat(this.fetchedSize(), ")"); | ||
}; | ||
Chunk.prototype.toString = function () { | ||
return this.toUniqueString(); | ||
}; | ||
Chunk.prototype.compareTo = function (b) { | ||
return (this.minv.compareTo(b.minv) || | ||
this.maxv.compareTo(b.maxv) || | ||
this.bin - b.bin); | ||
}; | ||
Chunk.prototype.fetchedSize = function () { | ||
if (this._fetchedSize !== undefined) { | ||
return this._fetchedSize; | ||
} | ||
return this.maxv.blockPosition + (1 << 16) - this.minv.blockPosition; | ||
}; | ||
return Chunk; | ||
}()); | ||
exports.default = Chunk; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jaHVuay50cyJdLCJuYW1lcyI6WyJDaHVuayIsIm1pbnYiLCJtYXh2IiwiYmluIiwiZmV0Y2hlZFNpemUiLCJ1bmRlZmluZWQiLCJfZmV0Y2hlZFNpemUiLCJ0b1VuaXF1ZVN0cmluZyIsImIiLCJjb21wYXJlVG8iLCJibG9ja1Bvc2l0aW9uIl0sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUVBO0lBQ3FCQSxLO0FBTW5COzs7Ozs7QUFNQSxpQkFBWUMsSUFBWixFQUFpQ0MsSUFBakMsRUFBc0RDLEdBQXRELEVBQTRGO0FBQUEsUUFBekJDLFdBQXlCLHVFQUFYQyxTQUFXO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFBQTtBQUMxRixTQUFLSixJQUFMLEdBQVlBLElBQVo7QUFDQSxTQUFLQyxJQUFMLEdBQVlBLElBQVo7QUFDQSxTQUFLQyxHQUFMLEdBQVdBLEdBQVg7QUFDQSxTQUFLRyxZQUFMLEdBQW9CRixXQUFwQjtBQUNEOzs7O3FDQUVnQjtBQUFBOztBQUNmLHlIQUFVLEtBQUtILElBQWYseUJBQXdCLEtBQUtDLElBQTdCLDZCQUEwQyxLQUFLQyxHQUEvQyxvQ0FBbUUsS0FBS0MsV0FBTCxFQUFuRTtBQUNEOzs7K0JBRVU7QUFDVCxhQUFPLEtBQUtHLGNBQUwsRUFBUDtBQUNEOzs7OEJBRVNDLEMsRUFBVTtBQUNsQixhQUFPLEtBQUtQLElBQUwsQ0FBVVEsU0FBVixDQUFvQkQsQ0FBQyxDQUFDUCxJQUF0QixLQ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tYXh2ID0gbWF4dlxuICAgIHRoaXMuYmluID0gYmluXG4gICAgdGhpcy5fZmV0Y2hlZFNpemUgPSBmZXRjaGVkU2l6ZVxuICB9XG5cbiAgdG9VbmlxdWVTdHJpbmcoKSB7XG4gICAgcmV0dXJuIGAke3RoaXMubWludn0uLiR7dGhpcy5tYXh2fSAoYmluICR7dGhpcy5iaW59LCBmZXRjaGVkU2l6ZSAke3RoaXMuZmV0Y2hlZFNpemUoKX0pYFxuICB9XG5cbiAgdG9TdHJpbmcoKSB7XG4gICAgcmV0dXJuIHRoaXMudG9VbmlxdWVTdHJpbmcoKVxuICB9XG5cbiAgY29tcGFyZVRvKGI6IENodW5rKSB7XG4gICAgcmV0dXJuIHRoaXMubWludi5jb21wYXJlVG8oYi5taW52KSB8fCB0aGlzLm1heHYuY29tcGFyZVRvKGIubWF4dikgfHwgdGhpcy5iaW4gLSBiLmJpblxuICB9XG5cbiAgZmV0Y2hlZFNpemUoKSB7XG4gICAgaWYgKHRoaXMuX2ZldGNoZWRTaXplICE9PSB1bmRlZmluZWQpIHtcbiAgICAgIHJldHVybiB0aGlzLl9mZXRjaGVkU2l6ZVxuICAgIH1cbiAgICByZXR1cm4gdGhpcy5tYXh2LmJsb2NrUG9zaXRpb24gKyAoMSA8PCAxNikgLSB0aGlzLm1pbnYuYmxvY2tQb3NpdGlvblxuICB9XG59XG4iXX0= | ||
//# sourceMappingURL=chunk.js.map |
"use strict"; | ||
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _default = { | ||
// the read is paired in sequencing, no matter whether it is mapped in a pair | ||
BAM_FPAIRED: 1, | ||
// the read is mapped in a proper pair | ||
BAM_FPROPER_PAIR: 2, | ||
// the read itself is unmapped; conflictive with BAM_FPROPER_PAIR | ||
BAM_FUNMAP: 4, | ||
// the mate is unmapped | ||
BAM_FMUNMAP: 8, | ||
// the read is mapped to the reverse strand | ||
BAM_FREVERSE: 16, | ||
// the mate is mapped to the reverse strand | ||
BAM_FMREVERSE: 32, | ||
// this is read1 | ||
BAM_FREAD1: 64, | ||
// this is read2 | ||
BAM_FREAD2: 128, | ||
// not primary alignment | ||
BAM_FSECONDARY: 256, | ||
// QC failure | ||
BAM_FQCFAIL: 512, | ||
// optical or PCR duplicate | ||
BAM_FDUP: 1024, | ||
// supplementary alignment | ||
BAM_FSUPPLEMENTARY: 2048 | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = { | ||
// the read is paired in sequencing, no matter whether it is mapped in a pair | ||
BAM_FPAIRED: 1, | ||
// the read is mapped in a proper pair | ||
BAM_FPROPER_PAIR: 2, | ||
// the read itself is unmapped; conflictive with BAM_FPROPER_PAIR | ||
BAM_FUNMAP: 4, | ||
// the mate is unmapped | ||
BAM_FMUNMAP: 8, | ||
// the read is mapped to the reverse strand | ||
BAM_FREVERSE: 16, | ||
// the mate is mapped to the reverse strand | ||
BAM_FMREVERSE: 32, | ||
// this is read1 | ||
BAM_FREAD1: 64, | ||
// this is read2 | ||
BAM_FREAD2: 128, | ||
// not primary alignment | ||
BAM_FSECONDARY: 256, | ||
// QC failure | ||
BAM_FQCFAIL: 512, | ||
// optical or PCR duplicate | ||
BAM_FDUP: 1024, | ||
// supplementary alignment | ||
BAM_FSUPPLEMENTARY: 2048, | ||
}; | ||
exports.default = _default; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jb25zdGFudHMudHMiXSwibmFtZXMiOlsiQkFNX0ZQQUlSRUQiLCJCQU1fRlBST1BFUl9QQUlSIiwiQkFNX0ZVTk1BUCIsIkJBTV9GTVVOTUFQIiwiQkFNX0ZSRVZFUlNFIiwiQkFNX0ZNUkVWRVJTRSIsIkJBTV9GUkVBRDEiLCJCQU1fRlJFQUQyIiwiQkFNX0ZTRUNPTkRBUlkiLCJCQU1fRlFD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0ZSBpcyB1bm1hcHBlZFxuICBCQU1fRk1VTk1BUDogOCxcbiAgLy8gIHRoZSByZWFkIGlzIG1hcHBlZCB0byB0aGUgcmV2ZXJzZSBzdHJhbmRcbiAgQkFNX0ZSRVZFUlNFOiAxNixcbiAgLy8gIHRoZSBtYXRlIGlzIG1hcHBlZCB0byB0aGUgcmV2ZXJzZSBzdHJhbmRcbiAgQkFNX0ZNUkVWRVJTRTogMzIsXG4gIC8vICB0aGlzIGlzIHJlYWQxXG4gIEJBTV9GUkVBRDE6IDY0LFxuICAvLyAgdGhpcyBpcyByZWFkMlxuICBCQU1fRlJFQUQyOiAxMjgsXG4gIC8vICBub3QgcHJpbWFyeSBhbGlnbm1lbnRcbiAgQkFNX0ZTRUNPTkRBUlk6IDI1NixcbiAgLy8gIFFDIGZhaWx1cmVcbiAgQkFNX0ZRQ0ZBSUw6IDUxMixcbiAgLy8gIG9wdGljYWwgb3IgUENSIGR1cGxpY2F0ZVxuICBCQU1fRkRVUDogMTAyNCxcbiAgLy8gIHN1cHBsZW1lbnRhcnkgYWxpZ25tZW50XG4gIEJBTV9GU1VQUExFTUVOVEFSWTogMjA0OCxcbn1cbiJdfQ== | ||
//# sourceMappingURL=constants.js.map |
832
dist/csi.js
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty(exports, "__esModule", { | ||
value: true | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
exports.default = void 0; | ||
var _getIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/get-iterator")); | ||
var _isArray = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/is-array")); | ||
var _getIteratorMethod2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js/get-iterator-method")); | ||
var _symbol = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/symbol")); | ||
var _from = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/array/from")); | ||
var _construct = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/reflect/construct")); | ||
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat")); | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray")); | ||
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice")); | ||
var _assign = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/assign")); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty")); | ||
var _long = _interopRequireDefault(require("long")); | ||
var _bgzfFilehandle = require("@gmod/bgzf-filehandle"); | ||
var _virtualOffset = _interopRequireWildcard(require("./virtualOffset")); | ||
var _chunk = _interopRequireDefault(require("./chunk")); | ||
var _util = require("./util"); | ||
var _indexFile = _interopRequireDefault(require("./indexFile")); | ||
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof _symbol.default === "undefined" || (0, _getIteratorMethod2.default)(o) == null) { if ((0, _isArray.default)(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = (0, _getIterator2.default)(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; } | ||
function _unsupportedIterableToArray(o, minLen) { var _context8; if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = (0, _slice.default)(_context8 = Object.prototype.toString.call(o)).call(_context8, 8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return (0, _from.default)(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = (0, _construct.default)(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_construct.default) return false; if (_construct.default.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call((0, _construct.default)(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var long_1 = __importDefault(require("long")); | ||
var bgzf_filehandle_1 = require("@gmod/bgzf-filehandle"); | ||
var virtualOffset_1 = __importStar(require("./virtualOffset")); | ||
var chunk_1 = __importDefault(require("./chunk")); | ||
var util_1 = require("./util"); | ||
var indexFile_1 = __importDefault(require("./indexFile")); | ||
var CSI1_MAGIC = 21582659; // CSI\1 | ||
var CSI2_MAGIC = 38359875; // CSI\2 | ||
function lshift(num, bits) { | ||
return num * Math.pow(2, bits); | ||
return num * Math.pow(2, bits); | ||
} | ||
function rshift(num, bits) { | ||
return Math.floor(num / Math.pow(2, bits)); | ||
return Math.floor(num / Math.pow(2, bits)); | ||
} | ||
var CSI = /*#__PURE__*/function (_IndexFile) { | ||
(0, _inherits2.default)(CSI, _IndexFile); | ||
var _super = _createSuper(CSI); | ||
function CSI(args) { | ||
var _this; | ||
(0, _classCallCheck2.default)(this, CSI); | ||
_this = _super.call(this, args); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "maxBinNumber", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "depth", void 0); | ||
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "minShift", void 0); | ||
_this.maxBinNumber = 0; | ||
_this.depth = 0; | ||
_this.minShift = 0; | ||
return _this; | ||
} | ||
(0, _createClass2.default)(CSI, [{ | ||
key: "lineCount", | ||
value: function () { | ||
var _lineCount = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(refId) { | ||
var indexData, idx, stats; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return this.parse(); | ||
case 2: | ||
indexData = _context.sent; | ||
if (indexData) { | ||
_context.next = 5; | ||
break; | ||
var CSI = /** @class */ (function (_super) { | ||
__extends(CSI, _super); | ||
function CSI(args) { | ||
var _this = _super.call(this, args) || this; | ||
_this.maxBinNumber = 0; | ||
_this.depth = 0; | ||
_this.minShift = 0; | ||
return _this; | ||
} | ||
CSI.prototype.lineCount = function (refId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var indexData, idx, stats; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.parse()]; | ||
case 1: | ||
indexData = _a.sent(); | ||
if (!indexData) { | ||
return [2 /*return*/, -1]; | ||
} | ||
idx = indexData.indices[refId]; | ||
if (!idx) { | ||
return [2 /*return*/, -1]; | ||
} | ||
stats = indexData.indices[refId].stats; | ||
if (stats) { | ||
return [2 /*return*/, stats.lineCount]; | ||
} | ||
return [2 /*return*/, -1]; | ||
} | ||
return _context.abrupt("return", -1); | ||
case 5: | ||
idx = indexData.indices[refId]; | ||
if (idx) { | ||
_context.next = 8; | ||
break; | ||
}); | ||
}); | ||
}; | ||
CSI.prototype.indexCov = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, []]; | ||
}); | ||
}); | ||
}; | ||
CSI.prototype.parseAuxData = function (bytes, offset, auxLength) { | ||
if (auxLength < 30) { | ||
return {}; | ||
} | ||
var data = {}; | ||
data.formatFlags = bytes.readInt32LE(offset); | ||
data.coordinateType = | ||
data.formatFlags & 0x10000 ? 'zero-based-half-open' : '1-based-closed'; | ||
data.format = { 0: 'generic', 1: 'SAM', 2: 'VCF' }[data.formatFlags & 0xf]; | ||
if (!data.format) { | ||
throw new Error("invalid Tabix preset format flags ".concat(data.formatFlags)); | ||
} | ||
data.columnNumbers = { | ||
ref: bytes.readInt32LE(offset + 4), | ||
start: bytes.readInt32LE(offset + 8), | ||
end: bytes.readInt32LE(offset + 12), | ||
}; | ||
data.metaValue = bytes.readInt32LE(offset + 16); | ||
data.metaChar = data.metaValue ? String.fromCharCode(data.metaValue) : ''; | ||
data.skipLines = bytes.readInt32LE(offset + 20); | ||
var nameSectionLength = bytes.readInt32LE(offset + 24); | ||
Object.assign(data, this._parseNameBytes(bytes.slice(offset + 28, offset + 28 + nameSectionLength))); | ||
return data; | ||
}; | ||
CSI.prototype._parseNameBytes = function (namesBytes) { | ||
var currRefId = 0; | ||
var currNameStart = 0; | ||
var refIdToName = []; | ||
var refNameToId = {}; | ||
for (var i = 0; i < namesBytes.length; i += 1) { | ||
if (!namesBytes[i]) { | ||
if (currNameStart < i) { | ||
var refName = namesBytes.toString('utf8', currNameStart, i); | ||
refName = this.renameRefSeq(refName); | ||
refIdToName[currRefId] = refName; | ||
refNameToId[refName] = currRefId; | ||
} | ||
return _context.abrupt("return", -1); | ||
case 8: | ||
stats = indexData.indices[refId].stats; | ||
if (!stats) { | ||
_context.next = 11; | ||
break; | ||
} | ||
return _context.abrupt("return", stats.lineCount); | ||
case 11: | ||
return _context.abrupt("return", -1); | ||
case 12: | ||
case "end": | ||
return _context.stop(); | ||
currNameStart = i + 1; | ||
currRefId += 1; | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
function lineCount(_x) { | ||
return _lineCount.apply(this, arguments); | ||
} | ||
return lineCount; | ||
}() | ||
}, { | ||
key: "indexCov", | ||
value: function () { | ||
var _indexCov = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() { | ||
return _regenerator.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
return _context2.abrupt("return", []); | ||
case 1: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2); | ||
})); | ||
function indexCov() { | ||
return _indexCov.apply(this, arguments); | ||
} | ||
return indexCov; | ||
}() | ||
}, { | ||
key: "parseAuxData", | ||
value: function parseAuxData(bytes, offset, auxLength) { | ||
if (auxLength < 30) { | ||
return {}; | ||
} | ||
var data = {}; | ||
data.formatFlags = bytes.readInt32LE(offset); | ||
data.coordinateType = data.formatFlags & 0x10000 ? 'zero-based-half-open' : '1-based-closed'; | ||
data.format = { | ||
0: 'generic', | ||
1: 'SAM', | ||
2: 'VCF' | ||
}[data.formatFlags & 0xf]; | ||
if (!data.format) { | ||
throw new Error("invalid Tabix preset format flags ".concat(data.formatFlags)); | ||
} | ||
data.columnNumbers = { | ||
ref: bytes.readInt32LE(offset + 4), | ||
start: bytes.readInt32LE(offset + 8), | ||
end: bytes.readInt32LE(offset + 12) | ||
}; | ||
data.metaValue = bytes.readInt32LE(offset + 16); | ||
data.metaChar = data.metaValue ? String.fromCharCode(data.metaValue) : ''; | ||
data.skipLines = bytes.readInt32LE(offset + 20); | ||
var nameSectionLength = bytes.readInt32LE(offset + 24); | ||
(0, _assign.default)(data, this._parseNameBytes((0, _slice.default)(bytes).call(bytes, offset + 28, offset + 28 + nameSectionLength))); | ||
return data; | ||
} | ||
}, { | ||
key: "_parseNameBytes", | ||
value: function _parseNameBytes(namesBytes) { | ||
var currRefId = 0; | ||
var currNameStart = 0; | ||
var refIdToName = []; | ||
var refNameToId = {}; | ||
for (var i = 0; i < namesBytes.length; i += 1) { | ||
if (!namesBytes[i]) { | ||
if (currNameStart < i) { | ||
var refName = namesBytes.toString('utf8', currNameStart, i); | ||
refName = this.renameRefSeq(refName); | ||
refIdToName[currRefId] = refName; | ||
refNameToId[refName] = currRefId; | ||
} | ||
currNameStart = i + 1; | ||
currRefId += 1; | ||
} | ||
} | ||
return { | ||
refNameToId: refNameToId, | ||
refIdToName: refIdToName | ||
}; | ||
} // fetch and parse the index | ||
}, { | ||
key: "_parse", | ||
value: function () { | ||
var _parse2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(opts) { | ||
var data, buffer, bytes, auxLength, currOffset, i, binCount, binIndex, stats, j, bin, loffset, chunkCount, chunks, k, u, v; | ||
return _regenerator.default.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
data = { | ||
csi: true, | ||
maxBlockSize: 1 << 16 | ||
}; | ||
_context3.next = 3; | ||
return this.filehandle.readFile(opts); | ||
case 3: | ||
buffer = _context3.sent; | ||
_context3.next = 6; | ||
return (0, _bgzfFilehandle.unzip)(buffer); | ||
case 6: | ||
bytes = _context3.sent; | ||
if (!(bytes.readUInt32LE(0) === CSI1_MAGIC)) { | ||
_context3.next = 11; | ||
break; | ||
return { refNameToId: refNameToId, refIdToName: refIdToName }; | ||
}; | ||
// fetch and parse the index | ||
CSI.prototype._parse = function (opts) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var data, buffer, bytes, auxLength, currOffset, i, binCount, binIndex, stats // < provided by parsing a pseudo-bin, if present | ||
, j, bin, loffset, chunkCount, chunks, k, u, v; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
data = { csi: true, maxBlockSize: 1 << 16 }; | ||
return [4 /*yield*/, this.filehandle.readFile(opts)]; | ||
case 1: | ||
buffer = (_a.sent()); | ||
return [4 /*yield*/, (0, bgzf_filehandle_1.unzip)(buffer) | ||
// check TBI magic numbers | ||
]; | ||
case 2: | ||
bytes = _a.sent(); | ||
// check TBI magic numbers | ||
if (bytes.readUInt32LE(0) === CSI1_MAGIC) { | ||
data.csiVersion = 1; | ||
} | ||
else if (bytes.readUInt32LE(0) === CSI2_MAGIC) { | ||
data.csiVersion = 2; | ||
} | ||
else { | ||
throw new Error('Not a CSI file'); | ||
// TODO: do we need to support big-endian CSI files? | ||
} | ||
this.minShift = bytes.readInt32LE(4); | ||
this.depth = bytes.readInt32LE(8); | ||
this.maxBinNumber = ((1 << ((this.depth + 1) * 3)) - 1) / 7; | ||
auxLength = bytes.readInt32LE(12); | ||
if (auxLength) { | ||
Object.assign(data, this.parseAuxData(bytes, 16, auxLength)); | ||
} | ||
data.refCount = bytes.readInt32LE(16 + auxLength); | ||
// read the indexes for each reference sequence | ||
data.indices = new Array(data.refCount); | ||
currOffset = 16 + auxLength + 4; | ||
i = 0; | ||
_a.label = 3; | ||
case 3: | ||
if (!(i < data.refCount)) return [3 /*break*/, 6]; | ||
return [4 /*yield*/, (0, util_1.abortBreakPoint)(opts.signal) | ||
// the binning index | ||
]; | ||
case 4: | ||
_a.sent(); | ||
binCount = bytes.readInt32LE(currOffset); | ||
currOffset += 4; | ||
binIndex = {}; | ||
stats = void 0; | ||
for (j = 0; j < binCount; j += 1) { | ||
bin = bytes.readUInt32LE(currOffset); | ||
if (bin > this.maxBinNumber) { | ||
// this is a fake bin that actually has stats information | ||
// about the reference sequence in it | ||
stats = this.parsePseudoBin(bytes, currOffset + 4); | ||
currOffset += 4 + 8 + 4 + 16 + 16; | ||
} | ||
else { | ||
loffset = (0, virtualOffset_1.fromBytes)(bytes, currOffset + 4); | ||
this._findFirstData(data, loffset); | ||
chunkCount = bytes.readInt32LE(currOffset + 12); | ||
currOffset += 16; | ||
chunks = new Array(chunkCount); | ||
for (k = 0; k < chunkCount; k += 1) { | ||
u = (0, virtualOffset_1.fromBytes)(bytes, currOffset); | ||
v = (0, virtualOffset_1.fromBytes)(bytes, currOffset + 8); | ||
currOffset += 16; | ||
// this._findFirstData(data, u) | ||
chunks[k] = new chunk_1.default(u, v, bin); | ||
} | ||
binIndex[bin] = chunks; | ||
} | ||
} | ||
data.indices[i] = { binIndex: binIndex, stats: stats }; | ||
_a.label = 5; | ||
case 5: | ||
i += 1; | ||
return [3 /*break*/, 3]; | ||
case 6: return [2 /*return*/, data]; | ||
} | ||
data.csiVersion = 1; | ||
_context3.next = 16; | ||
break; | ||
case 11: | ||
if (!(bytes.readUInt32LE(0) === CSI2_MAGIC)) { | ||
_context3.next = 15; | ||
break; | ||
} | ||
data.csiVersion = 2; | ||
_context3.next = 16; | ||
break; | ||
case 15: | ||
throw new Error('Not a CSI file'); | ||
case 16: | ||
this.minShift = bytes.readInt32LE(4); | ||
this.depth = bytes.readInt32LE(8); | ||
this.maxBinNumber = ((1 << (this.depth + 1) * 3) - 1) / 7; | ||
auxLength = bytes.readInt32LE(12); | ||
if (auxLength) { | ||
(0, _assign.default)(data, this.parseAuxData(bytes, 16, auxLength)); | ||
} | ||
data.refCount = bytes.readInt32LE(16 + auxLength); // read the indexes for each reference sequence | ||
data.indices = new Array(data.refCount); | ||
currOffset = 16 + auxLength + 4; | ||
i = 0; | ||
case 25: | ||
if (!(i < data.refCount)) { | ||
_context3.next = 37; | ||
break; | ||
} | ||
_context3.next = 28; | ||
return (0, _util.abortBreakPoint)(opts.signal); | ||
case 28: | ||
// the binning index | ||
binCount = bytes.readInt32LE(currOffset); | ||
currOffset += 4; | ||
binIndex = {}; | ||
stats = void 0; // < provided by parsing a pseudo-bin, if present | ||
for (j = 0; j < binCount; j += 1) { | ||
bin = bytes.readUInt32LE(currOffset); | ||
if (bin > this.maxBinNumber) { | ||
// this is a fake bin that actually has stats information | ||
// about the reference sequence in it | ||
stats = this.parsePseudoBin(bytes, currOffset + 4); | ||
currOffset += 4 + 8 + 4 + 16 + 16; | ||
} else { | ||
loffset = (0, _virtualOffset.fromBytes)(bytes, currOffset + 4); | ||
this._findFirstData(data, loffset); | ||
chunkCount = bytes.readInt32LE(currOffset + 12); | ||
currOffset += 16; | ||
chunks = new Array(chunkCount); | ||
for (k = 0; k < chunkCount; k += 1) { | ||
u = (0, _virtualOffset.fromBytes)(bytes, currOffset); | ||
v = (0, _virtualOffset.fromBytes)(bytes, currOffset + 8); | ||
currOffset += 16; // this._findFirstData(data, u) | ||
chunks[k] = new _chunk.default(u, v, bin); | ||
} | ||
binIndex[bin] = chunks; | ||
} | ||
} | ||
data.indices[i] = { | ||
binIndex: binIndex, | ||
stats: stats | ||
}; | ||
case 34: | ||
i += 1; | ||
_context3.next = 25; | ||
break; | ||
case 37: | ||
return _context3.abrupt("return", data); | ||
case 38: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
})); | ||
function _parse(_x2) { | ||
return _parse2.apply(this, arguments); | ||
} | ||
return _parse; | ||
}() | ||
}, { | ||
key: "parsePseudoBin", | ||
value: function parsePseudoBin(bytes, offset) { | ||
// const one = Long.fromBytesLE(bytes.slice(offset + 4, offset + 12), true) | ||
// const two = Long.fromBytesLE(bytes.slice(offset + 12, offset + 20), true) | ||
// const three = longToNumber( | ||
// Long.fromBytesLE(bytes.slice(offset + 20, offset + 28), true), | ||
// ) | ||
var lineCount = (0, _util.longToNumber)(_long.default.fromBytesLE((0, _slice.default)(Array.prototype).call(bytes, offset + 28, offset + 36), true)); | ||
return { | ||
lineCount: lineCount | ||
}; | ||
} | ||
}, { | ||
key: "blocksForRange", | ||
value: function () { | ||
var _blocksForRange = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(refId, min, max) { | ||
var opts, | ||
indexData, | ||
ba, | ||
overlappingBins, | ||
chunks, | ||
_iterator, | ||
_step, | ||
_step$value, | ||
start, | ||
end, | ||
bin, | ||
binChunks, | ||
c, | ||
_args4 = arguments; | ||
return _regenerator.default.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
opts = _args4.length > 3 && _args4[3] !== undefined ? _args4[3] : {}; | ||
if (min < 0) { | ||
min = 0; | ||
} | ||
_context4.next = 4; | ||
return this.parse(opts); | ||
case 4: | ||
indexData = _context4.sent; | ||
if (indexData) { | ||
_context4.next = 7; | ||
break; | ||
} | ||
return _context4.abrupt("return", []); | ||
case 7: | ||
ba = indexData.indices[refId]; | ||
if (ba) { | ||
_context4.next = 10; | ||
break; | ||
} | ||
return _context4.abrupt("return", []); | ||
case 10: | ||
overlappingBins = this.reg2bins(min, max); // List of bin #s that overlap min, max | ||
chunks = []; // Find chunks in overlapping bins. Leaf bins (< 4681) are not pruned | ||
_iterator = _createForOfIteratorHelper(overlappingBins); | ||
try { | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
_step$value = (0, _slicedToArray2.default)(_step.value, 2), start = _step$value[0], end = _step$value[1]; | ||
for (bin = start; bin <= end; bin++) { | ||
if (ba.binIndex[bin]) { | ||
binChunks = ba.binIndex[bin]; | ||
for (c = 0; c < binChunks.length; ++c) { | ||
chunks.push(new _chunk.default(binChunks[c].minv, binChunks[c].maxv, bin)); | ||
}); | ||
}); | ||
}; | ||
CSI.prototype.parsePseudoBin = function (bytes, offset) { | ||
// const one = Long.fromBytesLE(bytes.slice(offset + 4, offset + 12), true) | ||
// const two = Long.fromBytesLE(bytes.slice(offset + 12, offset + 20), true) | ||
// const three = longToNumber( | ||
// Long.fromBytesLE(bytes.slice(offset + 20, offset + 28), true), | ||
// ) | ||
var lineCount = (0, util_1.longToNumber)(long_1.default.fromBytesLE(Array.prototype.slice.call(bytes, offset + 28, offset + 36), true)); | ||
return { lineCount: lineCount }; | ||
}; | ||
CSI.prototype.blocksForRange = function (refId, min, max, opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var indexData, ba, overlappingBins, chunks, _i, overlappingBins_1, _a, start, end, bin, binChunks, c; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (min < 0) { | ||
min = 0; | ||
} | ||
} | ||
} | ||
} | ||
} catch (err) { | ||
_iterator.e(err); | ||
} finally { | ||
_iterator.f(); | ||
return [4 /*yield*/, this.parse(opts)]; | ||
case 1: | ||
indexData = _b.sent(); | ||
if (!indexData) { | ||
return [2 /*return*/, []]; | ||
} | ||
ba = indexData.indices[refId]; | ||
if (!ba) { | ||
return [2 /*return*/, []]; | ||
} | ||
overlappingBins = this.reg2bins(min, max) // List of bin #s that overlap min, max | ||
; | ||
chunks = []; | ||
// Find chunks in overlapping bins. Leaf bins (< 4681) are not pruned | ||
for (_i = 0, overlappingBins_1 = overlappingBins; _i < overlappingBins_1.length; _i++) { | ||
_a = overlappingBins_1[_i], start = _a[0], end = _a[1]; | ||
for (bin = start; bin <= end; bin++) { | ||
if (ba.binIndex[bin]) { | ||
binChunks = ba.binIndex[bin]; | ||
for (c = 0; c < binChunks.length; ++c) { | ||
chunks.push(new chunk_1.default(binChunks[c].minv, binChunks[c].maxv, bin)); | ||
} | ||
} | ||
} | ||
} | ||
return [2 /*return*/, (0, util_1.optimizeChunks)(chunks, new virtualOffset_1.default(0, 0))]; | ||
} | ||
return _context4.abrupt("return", (0, _util.optimizeChunks)(chunks, new _virtualOffset.default(0, 0))); | ||
case 15: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
}, _callee4, this); | ||
})); | ||
function blocksForRange(_x3, _x4, _x5) { | ||
return _blocksForRange.apply(this, arguments); | ||
} | ||
return blocksForRange; | ||
}() | ||
}); | ||
}); | ||
}; | ||
/** | ||
@@ -495,43 +312,28 @@ * calculate the list of bins that may overlap with region [beg,end) (zero-based half-open) | ||
*/ | ||
}, { | ||
key: "reg2bins", | ||
value: function reg2bins(beg, end) { | ||
beg -= 1; // < convert to 1-based closed | ||
if (beg < 1) { | ||
beg = 1; | ||
} | ||
if (end > Math.pow(2, 50)) { | ||
end = Math.pow(2, 34); | ||
} // 17 GiB ought to be enough for anybody | ||
end -= 1; | ||
var l = 0; | ||
var t = 0; | ||
var s = this.minShift + this.depth * 3; | ||
var bins = []; | ||
for (; l <= this.depth; s -= 3, t += lshift(1, l * 3), l += 1) { | ||
var b = t + rshift(beg, s); | ||
var e = t + rshift(end, s); | ||
if (e - b + bins.length > this.maxBinNumber) { | ||
var _context5, _context6, _context7; | ||
throw new Error((0, _concat.default)(_context5 = (0, _concat.default)(_context6 = (0, _concat.default)(_context7 = "query ".concat(beg, "-")).call(_context7, end, " is too large for current binning scheme (shift ")).call(_context6, this.minShift, ", depth ")).call(_context5, this.depth, "), try a smaller query or a coarser index binning scheme")); | ||
CSI.prototype.reg2bins = function (beg, end) { | ||
beg -= 1; // < convert to 1-based closed | ||
if (beg < 1) { | ||
beg = 1; | ||
} | ||
bins.push([b, e]); | ||
} | ||
return bins; | ||
} | ||
}]); | ||
return CSI; | ||
}(_indexFile.default); | ||
if (end > Math.pow(2, 50)) { | ||
end = Math.pow(2, 34); | ||
} // 17 GiB ought to be enough for anybody | ||
end -= 1; | ||
var l = 0; | ||
var t = 0; | ||
var s = this.minShift + this.depth * 3; | ||
var bins = []; | ||
for (; l <= this.depth; s -= 3, t += lshift(1, l * 3), l += 1) { | ||
var b = t + rshift(beg, s); | ||
var e = t + rshift(end, s); | ||
if (e - b + bins.length > this.maxBinNumber) { | ||
throw new Error("query ".concat(beg, "-").concat(end, " is too large for current binning scheme (shift ").concat(this.minShift, ", depth ").concat(this.depth, "), try a smaller query or a coarser index binning scheme")); | ||
} | ||
bins.push([b, e]); | ||
} | ||
return bins; | ||
}; | ||
return CSI; | ||
}(indexFile_1.default)); | ||
exports.default = CSI; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jc2kudHMiXSwibmFtZXMiOlsiQ1NJMV9NQUdJQyIsIkNTSTJfTUFHSUMiLCJsc2hpZnQiLCJudW0iLCJiaXRzIiwicnNoaWZ0IiwiTWF0aCIsImZsb29yIiwiQ1NJIiwiYXJncyIsIm1heEJpbk51bWJlciIsImRlcHRoIiwibWluU2hpZnQiLCJyZWZJZCIsInBhcnNlIiwiaW5kZXhEYXRhIiwiaWR4IiwiaW5kaWNlcyIsInN0YXRzIiwibGluZUNvdW50IiwiYnl0ZXMiLCJvZmZzZXQiLCJhdXhMZW5ndGgiLCJkYXRhIiwiZm9ybWF0RmxhZ3MiLCJyZWFkSW50MzJMRSIsImNvb3JkaW5hdGVUeXBlIiwiZm9ybWF0IiwiRXJyb3IiLCJjb2x1bW5OdW1iZXJzIiwicmVmIiwic3RhcnQiLCJlbmQiLCJtZXRhVmFsdWUiLCJtZXRhQ2hhciIsIlN0cmluZyIsImZyb21DaGFyQ29kZSIsInNraXBMaW5lcyIsIm5hbWVTZWN0aW9uTGVuZ3RoIiwiX3BhcnNlTmFtZUJ5dGVzIiwibmFtZXNCeXRlcyIsImN1cnJSZWZJZCIsImN1cnJOYW1lU3RhcnQiLCJyZWZJZFRvTmFtZSIsInJlZk5hbWVUb0lkIiwiaSIsImxlbmd0aCIsInJlZk5hbWUiLCJ0b1N0cmluZyIsInJlbmFtZVJlZlNlcSIsIm9wdHMiLCJjc2kiLCJtYXhCbG9ja1NpemUiLCJmaWxlaGFuZGxlIiwicmVhZEZpbGUiLCJidWZmZXIiLCJyZWFkVUludDMyTEUiLCJjc2lWZXJzaW9uIiwicGFyc2VBdXh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B0aGlzLmRlcHRoOyBzIC09IDMsIHQgKz0gbHNoaWZ0KDEsIGwgKiAzKSwgbCArPSAxKSB7XG4gICAgICBjb25zdCBiID0gdCArIHJzaGlmdChiZWcsIHMpXG4gICAgICBjb25zdCBlID0gdCArIHJzaGlmdChlbmQsIHMpXG4gICAgICBpZiAoZSAtIGIgKyBiaW5zLmxlbmd0aCA+IHRoaXMubWF4QmluTnVtYmVyKSB7XG4gICAgICAgIHRocm93IG5ldyBFcnJvcihcbiAgICAgICAgICBgcXVlcnkgJHtiZWd9LSR7ZW5kfSBpcyB0b28gbGFyZ2UgZm9yIGN1cnJlbnQgYmlubmluZyBzY2hlbWUgKHNoaWZ0ICR7dGhpcy5taW5TaGlmdH0sIGRlcHRoICR7dGhpcy5kZXB0aH0pLCB0cnkgYSBzbWFsbGVyIHF1ZXJ5IG9yIGEgY29hcnNlciBpbmRleCBiaW5uaW5nIHNjaGVtZWAsXG4gICAgICAgIClcbiAgICAgIH1cbiAgICAgIGJpbnMucHVzaChbYiwgZV0pXG4gICAgfVxuICAgIHJldHVybiBiaW5zXG4gIH1cbn1cbiJdfQ== | ||
//# sourceMappingURL=csi.js.map |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BamArgumentError = exports.BamSizeLimitError = exports.BamBufferOverrunError = exports.BamMalformedError = exports.BamUnimplementedError = exports.BamError = void 0; | ||
var _construct = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/reflect/construct")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf")); | ||
var _wrapNativeSuper2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapNativeSuper")); | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = (0, _construct.default)(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_construct.default) return false; if (_construct.default.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call((0, _construct.default)(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
var BamError = /*#__PURE__*/function (_Error) { | ||
(0, _inherits2.default)(BamError, _Error); | ||
var _super = _createSuper(BamError); | ||
function BamError() { | ||
(0, _classCallCheck2.default)(this, BamError); | ||
return _super.apply(this, arguments); | ||
} | ||
return BamError; | ||
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error)); | ||
var BamError = /** @class */ (function (_super) { | ||
__extends(BamError, _super); | ||
function BamError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return BamError; | ||
}(Error)); | ||
exports.BamError = BamError; | ||
/** Error caused by encountering a part of the BAM spec that has not yet been implemented */ | ||
exports.BamError = BamError; | ||
var BamUnimplementedError = /*#__PURE__*/function (_Error2) { | ||
(0, _inherits2.default)(BamUnimplementedError, _Error2); | ||
var _super2 = _createSuper(BamUnimplementedError); | ||
function BamUnimplementedError() { | ||
(0, _classCallCheck2.default)(this, BamUnimplementedError); | ||
return _super2.apply(this, arguments); | ||
} | ||
return BamUnimplementedError; | ||
}( /*#__PURE__*/(0, _wrapNativeSuper2.default)(Error)); | ||
var BamUnimplementedError = /** @class */ (function (_super) { | ||
__extends(BamUnimplementedError, _super); | ||
function BamUnimplementedError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return BamUnimplementedError; | ||
}(Error)); | ||
exports.BamUnimplementedError = BamUnimplementedError; | ||
/** An error caused by malformed data. */ | ||
exports.BamUnimplementedError = BamUnimplementedError; | ||
var BamMalformedError = /*#__PURE__*/function (_BamError) { | ||
(0, _inherits2.default)(BamMalformedError, _BamError); | ||
var _super3 = _createSuper(BamMalformedError); | ||
function BamMalformedError() { | ||
(0, _classCallCheck2.default)(this, BamMalformedError); | ||
return _super3.apply(this, arguments); | ||
} | ||
return BamMalformedError; | ||
}(BamError); | ||
var BamMalformedError = /** @class */ (function (_super) { | ||
__extends(BamMalformedError, _super); | ||
function BamMalformedError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return BamMalformedError; | ||
}(BamError)); | ||
exports.BamMalformedError = BamMalformedError; | ||
/** | ||
* An error caused by attempting to read beyond the end of the defined data. | ||
*/ | ||
exports.BamMalformedError = BamMalformedError; | ||
var BamBufferOverrunError = /*#__PURE__*/function (_BamMalformedError) { | ||
(0, _inherits2.default)(BamBufferOverrunError, _BamMalformedError); | ||
var _super4 = _createSuper(BamBufferOverrunError); | ||
function BamBufferOverrunError() { | ||
(0, _classCallCheck2.default)(this, BamBufferOverrunError); | ||
return _super4.apply(this, arguments); | ||
} | ||
return BamBufferOverrunError; | ||
}(BamMalformedError); | ||
var BamBufferOverrunError = /** @class */ (function (_super) { | ||
__extends(BamBufferOverrunError, _super); | ||
function BamBufferOverrunError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return BamBufferOverrunError; | ||
}(BamMalformedError)); | ||
exports.BamBufferOverrunError = BamBufferOverrunError; | ||
/** | ||
* An error caused by data being too big, exceeding a size limit. | ||
*/ | ||
exports.BamBufferOverrunError = BamBufferOverrunError; | ||
var BamSizeLimitError = /*#__PURE__*/function (_BamError2) { | ||
(0, _inherits2.default)(BamSizeLimitError, _BamError2); | ||
var _super5 = _createSuper(BamSizeLimitError); | ||
function BamSizeLimitError() { | ||
(0, _classCallCheck2.default)(this, BamSizeLimitError); | ||
return _super5.apply(this, arguments); | ||
} | ||
return BamSizeLimitError; | ||
}(BamError); | ||
var BamSizeLimitError = /** @class */ (function (_super) { | ||
__extends(BamSizeLimitError, _super); | ||
function BamSizeLimitError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return BamSizeLimitError; | ||
}(BamError)); | ||
exports.BamSizeLimitError = BamSizeLimitError; | ||
/** | ||
* An invalid argument was supplied to a bam-js method or object. | ||
*/ | ||
exports.BamSizeLimitError = BamSizeLimitError; | ||
var BamArgumentError = /*#__PURE__*/function (_BamError3) { | ||
(0, _inherits2.default)(BamArgumentError, _BamError3); | ||
var _super6 = _createSuper(BamArgumentError); | ||
function BamArgumentError() { | ||
(0, _classCallCheck2.default)(this, BamArgumentError); | ||
return _super6.apply(this, arguments); | ||
} | ||
return BamArgumentError; | ||
}(BamError); | ||
var BamArgumentError = /** @class */ (function (_super) { | ||
__extends(BamArgumentError, _super); | ||
function BamArgumentError() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return BamArgumentError; | ||
}(BamError)); | ||
exports.BamArgumentError = BamArgumentError; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64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IGNhdXNlZCBieSBhdHRlbXB0aW5nIHRvIHJlYWQgYmV5b25kIHRoZSBlbmQgb2YgdGhlIGRlZmluZWQgZGF0YS5cbiAqL1xuZXhwb3J0IGNsYXNzIEJhbUJ1ZmZlck92ZXJydW5FcnJvciBleHRlbmRzIEJhbU1hbGZvcm1lZEVycm9yIHt9XG5cbi8qKlxuICogQW4gZXJyb3IgY2F1c2VkIGJ5IGRhdGEgYmVpbmcgdG9vIGJpZywgZXhjZWVkaW5nIGEgc2l6ZSBsaW1pdC5cbiAqL1xuZXhwb3J0IGNsYXNzIEJhbVNpemVMaW1pdEVycm9yIGV4dGVuZHMgQmFtRXJyb3Ige31cblxuLyoqXG4gKiBBbiBpbnZhbGlkIGFyZ3VtZW50IHdhcyBzdXBwbGllZCB0byBhIGJhbS1qcyBtZXRob2Qgb3Igb2JqZWN0LlxuICovXG5leHBvcnQgY2xhc3MgQmFtQXJndW1lbnRFcnJvciBleHRlbmRzIEJhbUVycm9yIHt9XG4iXX0= | ||
//# sourceMappingURL=errors.js.map |
"use strict"; | ||
var _interopRequireWildcard = require("@babel/runtime-corejs3/helpers/interopRequireWildcard"); | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty2(exports, "__esModule", { | ||
value: true | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { | ||
Object.defineProperty(o, "default", { enumerable: true, value: v }); | ||
}) : function(o, v) { | ||
o["default"] = v; | ||
}); | ||
exports.default = void 0; | ||
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/objectWithoutProperties")); | ||
var _startsWith = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/starts-with")); | ||
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map")); | ||
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property")); | ||
var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-properties")); | ||
var _getOwnPropertyDescriptors = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors")); | ||
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor")); | ||
var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols")); | ||
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys")); | ||
var _construct = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/reflect/construct")); | ||
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each")); | ||
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter")); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator")); | ||
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice")); | ||
var _concat2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass")); | ||
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/assertThisInitialized")); | ||
var _inherits2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/inherits")); | ||
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/possibleConstructorReturn")); | ||
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/getPrototypeOf")); | ||
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator")); | ||
var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/wrapAsyncGenerator")); | ||
var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/awaitAsyncGenerator")); | ||
var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncIterator")); | ||
var _asyncGeneratorDelegate2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncGeneratorDelegate")); | ||
var _bamFile = _interopRequireWildcard(require("./bamFile")); | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); | ||
__setModuleDefault(result, mod); | ||
return result; | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } | ||
var __asyncValues = (this && this.__asyncValues) || function (o) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var m = o[Symbol.asyncIterator], i; | ||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); | ||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } | ||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } | ||
}; | ||
var __asyncDelegator = (this && this.__asyncDelegator) || function (o) { | ||
var i, p; | ||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; | ||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } | ||
}; | ||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { | ||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
var g = generator.apply(thisArg, _arguments || []), i, q = []; | ||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; | ||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } | ||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } | ||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } | ||
function fulfill(value) { resume("next", value); } | ||
function reject(value) { resume("throw", value); } | ||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } | ||
}; | ||
var __values = (this && this.__values) || function(o) { | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
if (o && i >= o.length) o = void 0; | ||
return { value: o && o[i++], done: !o }; | ||
} | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var bamFile_1 = __importStar(require("./bamFile")); | ||
require("cross-fetch/polyfill"); | ||
var _bgzfFilehandle = require("@gmod/bgzf-filehandle"); | ||
var _sam = require("./sam"); | ||
function ownKeys(object, enumerableOnly) { var keys = (0, _keys.default)(object); if (_getOwnPropertySymbols.default) { var symbols = (0, _getOwnPropertySymbols.default)(object); if (enumerableOnly) symbols = (0, _filter.default)(symbols).call(symbols, function (sym) { return (0, _getOwnPropertyDescriptor.default)(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context13; (0, _forEach.default)(_context13 = ownKeys(Object(source), true)).call(_context13, function (key) { (0, _defineProperty3.default)(target, key, source[key]); }); } else if (_getOwnPropertyDescriptors.default) { (0, _defineProperties.default)(target, (0, _getOwnPropertyDescriptors.default)(source)); } else { var _context14; (0, _forEach.default)(_context14 = ownKeys(Object(source))).call(_context14, function (key) { (0, _defineProperty2.default)(target, key, (0, _getOwnPropertyDescriptor.default)(source, key)); }); } } return target; } | ||
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = (0, _construct.default)(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; } | ||
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !_construct.default) return false; if (_construct.default.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call((0, _construct.default)(Date, [], function () {})); return true; } catch (e) { return false; } } | ||
function concat(_x, _x2) { | ||
return _concat.apply(this, arguments); | ||
var bgzf_filehandle_1 = require("@gmod/bgzf-filehandle"); | ||
var sam_1 = require("./sam"); | ||
function concat(arr, opts) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var res, _a, _b; | ||
var _this = this; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: return [4 /*yield*/, Promise.all(arr.map(function (chunk) { return __awaiter(_this, void 0, void 0, function () { | ||
var url, headers, referer, rest, res_1, _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
url = chunk.url, headers = chunk.headers; | ||
if (!url.startsWith('data:')) return [3 /*break*/, 1]; | ||
return [2 /*return*/, Buffer.from(url.split(',')[1], 'base64')]; | ||
case 1: | ||
referer = headers.referer, rest = __rest(headers, ["referer"]); | ||
return [4 /*yield*/, fetch(url, __assign(__assign({}, opts), { headers: __assign(__assign({}, opts.headers), rest) }))]; | ||
case 2: | ||
res_1 = _c.sent(); | ||
if (!res_1.ok) { | ||
throw new Error("Failed to fetch ".concat(res_1.statusText)); | ||
} | ||
_b = (_a = Buffer).from; | ||
return [4 /*yield*/, res_1.arrayBuffer()]; | ||
case 3: return [2 /*return*/, _b.apply(_a, [_c.sent()])]; | ||
} | ||
}); | ||
}); }))]; | ||
case 1: | ||
res = _c.sent(); | ||
_b = (_a = Buffer).concat; | ||
return [4 /*yield*/, Promise.all(res.map(function (elt) { return (0, bgzf_filehandle_1.unzip)(elt); }))]; | ||
case 2: return [2 /*return*/, _b.apply(_a, [_c.sent()])]; | ||
} | ||
}); | ||
}); | ||
} | ||
function _concat() { | ||
_concat = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(arr, opts) { | ||
var res; | ||
return _regenerator.default.wrap(function _callee5$(_context16) { | ||
while (1) { | ||
switch (_context16.prev = _context16.next) { | ||
case 0: | ||
_context16.next = 2; | ||
return _promise.default.all((0, _map.default)(arr).call(arr, /*#__PURE__*/function () { | ||
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(chunk) { | ||
var url, headers, referer, rest, _res; | ||
return _regenerator.default.wrap(function _callee4$(_context15) { | ||
while (1) { | ||
switch (_context15.prev = _context15.next) { | ||
case 0: | ||
url = chunk.url, headers = chunk.headers; | ||
if (!(0, _startsWith.default)(url).call(url, 'data:')) { | ||
_context15.next = 5; | ||
break; | ||
var HtsgetFile = /** @class */ (function (_super) { | ||
__extends(HtsgetFile, _super); | ||
function HtsgetFile(args) { | ||
var _this = | ||
// @ts-ignore override bam defaults | ||
_super.call(this, { bamFilehandle: '?', baiFilehandle: '?' }) || this; | ||
_this.baseUrl = args.baseUrl; | ||
_this.trackId = args.trackId; | ||
return _this; | ||
} | ||
HtsgetFile.prototype.streamRecordsForRange = function (chr, min, max, opts) { | ||
if (opts === void 0) { opts = { | ||
viewAsPairs: false, | ||
pairAcrossChr: false, | ||
maxInsertSize: 200000, | ||
}; } | ||
return __asyncGenerator(this, arguments, function streamRecordsForRange_1() { | ||
var base, url, chrId, result, data, uncba, chunk; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
base = "".concat(this.baseUrl, "/").concat(this.trackId); | ||
url = "".concat(base, "?referenceName=").concat(chr, "&start=").concat(min, "&end=").concat(max, "&format=BAM"); | ||
chrId = this.chrToIndex && this.chrToIndex[chr]; | ||
return [4 /*yield*/, __await(fetch(url, __assign({}, opts)))]; | ||
case 1: | ||
result = _a.sent(); | ||
if (!result.ok) { | ||
throw new Error(result.statusText); | ||
} | ||
return _context15.abrupt("return", Buffer.from(url.split(',')[1], 'base64')); | ||
case 5: | ||
//remove referer header, it is not even allowed to be specified | ||
//@ts-ignore | ||
//eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
referer = headers.referer, rest = (0, _objectWithoutProperties2.default)(headers, ["referer"]); | ||
_context15.next = 8; | ||
return fetch(url, _objectSpread(_objectSpread({}, opts), {}, { | ||
headers: _objectSpread(_objectSpread({}, opts.headers), rest) | ||
})); | ||
case 8: | ||
_res = _context15.sent; | ||
if (_res.ok) { | ||
_context15.next = 11; | ||
break; | ||
} | ||
throw new Error("Failed to fetch ".concat(_res.statusText)); | ||
case 11: | ||
_context15.t0 = Buffer; | ||
_context15.next = 14; | ||
return _res.arrayBuffer(); | ||
case 14: | ||
_context15.t1 = _context15.sent; | ||
return _context15.abrupt("return", _context15.t0.from.call(_context15.t0, _context15.t1)); | ||
case 16: | ||
case "end": | ||
return _context15.stop(); | ||
} | ||
} | ||
}, _callee4); | ||
})); | ||
return function (_x4) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}())); | ||
case 2: | ||
res = _context16.sent; | ||
_context16.t0 = (0, _concat2.default)(Buffer); | ||
_context16.t1 = Buffer; | ||
_context16.next = 7; | ||
return _promise.default.all((0, _map.default)(res).call(res, function (elt) { | ||
return (0, _bgzfFilehandle.unzip)(elt); | ||
})); | ||
case 7: | ||
_context16.t2 = _context16.sent; | ||
return _context16.abrupt("return", _context16.t0.call.call(_context16.t0, _context16.t1, _context16.t2)); | ||
case 9: | ||
case "end": | ||
return _context16.stop(); | ||
} | ||
} | ||
}, _callee5); | ||
})); | ||
return _concat.apply(this, arguments); | ||
} | ||
var HtsgetFile = /*#__PURE__*/function (_BamFile) { | ||
(0, _inherits2.default)(HtsgetFile, _BamFile); | ||
var _super = _createSuper(HtsgetFile); | ||
function HtsgetFile(args) { | ||
var _this2; | ||
(0, _classCallCheck2.default)(this, HtsgetFile); | ||
// @ts-ignore override bam defaults | ||
_this2 = _super.call(this, { | ||
bamFilehandle: '?', | ||
baiFilehandle: '?' | ||
}); | ||
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this2), "baseUrl", void 0); | ||
(0, _defineProperty3.default)((0, _assertThisInitialized2.default)(_this2), "trackId", void 0); | ||
_this2.baseUrl = args.baseUrl; | ||
_this2.trackId = args.trackId; | ||
return _this2; | ||
} | ||
(0, _createClass2.default)(HtsgetFile, [{ | ||
key: "streamRecordsForRange", | ||
value: function streamRecordsForRange(chr, min, max) { | ||
var _this = this; | ||
var opts = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : { | ||
viewAsPairs: false, | ||
pairAcrossChr: false, | ||
maxInsertSize: 200000 | ||
}; | ||
return (0, _wrapAsyncGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() { | ||
var _context, _context2, _context3, _context4, _context5; | ||
var base, url, chrId, result, data, uncba, chunk; | ||
return _regenerator.default.wrap(function _callee$(_context8) { | ||
while (1) { | ||
switch (_context8.prev = _context8.next) { | ||
case 0: | ||
base = (0, _concat2.default)(_context = "".concat(_this.baseUrl, "/")).call(_context, _this.trackId); | ||
url = (0, _concat2.default)(_context2 = (0, _concat2.default)(_context3 = (0, _concat2.default)(_context4 = "".concat(base, "?referenceName=")).call(_context4, chr, "&start=")).call(_context3, min, "&end=")).call(_context2, max, "&format=BAM"); | ||
chrId = _this.chrToIndex && _this.chrToIndex[chr]; | ||
_context8.next = 5; | ||
return (0, _awaitAsyncGenerator2.default)(fetch(url, _objectSpread({}, opts))); | ||
case 5: | ||
result = _context8.sent; | ||
if (result.ok) { | ||
_context8.next = 8; | ||
break; | ||
return [4 /*yield*/, __await(result.json())]; | ||
case 2: | ||
data = _a.sent(); | ||
return [4 /*yield*/, __await(concat(data.htsget.urls.slice(1), opts))]; | ||
case 3: | ||
uncba = _a.sent(); | ||
chunk = { | ||
buffer: uncba, | ||
chunk: { minv: { dataPosition: 0 } }, | ||
toString: function () { | ||
return "".concat(chr, "_").concat(min, "_").concat(max); | ||
}, | ||
}; | ||
return [5 /*yield**/, __values(__asyncDelegator(__asyncValues(this._fetchChunkFeatures( | ||
// @ts-ignore | ||
[chunk], chrId, min, max, opts))))]; | ||
case 4: return [4 /*yield*/, __await.apply(void 0, [_a.sent()])]; | ||
case 5: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
throw new Error(result.statusText); | ||
case 8: | ||
_context8.next = 10; | ||
return (0, _awaitAsyncGenerator2.default)(result.json()); | ||
case 10: | ||
data = _context8.sent; | ||
_context8.next = 13; | ||
return (0, _awaitAsyncGenerator2.default)(concat((0, _slice.default)(_context5 = data.htsget.urls).call(_context5, 1), opts)); | ||
case 13: | ||
uncba = _context8.sent; | ||
chunk = { | ||
buffer: uncba, | ||
chunk: { | ||
minv: { | ||
dataPosition: 0 | ||
} | ||
}, | ||
toString: function toString() { | ||
var _context6, _context7; | ||
return (0, _concat2.default)(_context6 = (0, _concat2.default)(_context7 = "".concat(chr, "_")).call(_context7, min, "_")).call(_context6, max); | ||
} | ||
}; | ||
return _context8.delegateYield((0, _asyncGeneratorDelegate2.default)((0, _asyncIterator2.default)(_this._fetchChunkFeatures( // @ts-ignore | ||
[chunk], chrId, min, max, opts)), _awaitAsyncGenerator2.default), "t0", 16); | ||
case 16: | ||
case "end": | ||
return _context8.stop(); | ||
} | ||
} | ||
}, _callee); | ||
}))(); | ||
} //@ts-ignore | ||
}, { | ||
key: "_readChunk", | ||
value: function () { | ||
var _readChunk2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(params) { | ||
var chunk, buffer, c2; | ||
return _regenerator.default.wrap(function _callee2$(_context9) { | ||
while (1) { | ||
switch (_context9.prev = _context9.next) { | ||
case 0: | ||
}); | ||
}); | ||
}; | ||
//@ts-ignore | ||
HtsgetFile.prototype._readChunk = function (params) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var chunk, buffer, c2; | ||
return __generator(this, function (_a) { | ||
chunk = params.chunk; | ||
buffer = chunk.buffer, c2 = chunk.chunk; | ||
return _context9.abrupt("return", { | ||
data: buffer, | ||
cpositions: null, | ||
dpositions: null, | ||
chunk: c2 | ||
}); | ||
case 3: | ||
case "end": | ||
return _context9.stop(); | ||
} | ||
} | ||
}, _callee2); | ||
})); | ||
function _readChunk(_x3) { | ||
return _readChunk2.apply(this, arguments); | ||
} | ||
return _readChunk; | ||
}() | ||
}, { | ||
key: "getHeader", | ||
value: function () { | ||
var _getHeader = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() { | ||
var _context10; | ||
var opts, | ||
url, | ||
result, | ||
data, | ||
uncba, | ||
headLen, | ||
headerText, | ||
samHeader, | ||
idToName, | ||
nameToId, | ||
sqLines, | ||
_args3 = arguments; | ||
return _regenerator.default.wrap(function _callee3$(_context12) { | ||
while (1) { | ||
switch (_context12.prev = _context12.next) { | ||
case 0: | ||
opts = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {}; | ||
url = (0, _concat2.default)(_context10 = "".concat(this.baseUrl, "/")).call(_context10, this.trackId, "?referenceName=na&class=header"); | ||
_context12.next = 4; | ||
return fetch(url, opts); | ||
case 4: | ||
result = _context12.sent; | ||
if (result.ok) { | ||
_context12.next = 7; | ||
break; | ||
return [2 /*return*/, { data: buffer, cpositions: null, dpositions: null, chunk: c2 }]; | ||
}); | ||
}); | ||
}; | ||
HtsgetFile.prototype.getHeader = function (opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var url, result, data, uncba, headLen, headerText, samHeader, idToName, nameToId, sqLines; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
url = "".concat(this.baseUrl, "/").concat(this.trackId, "?referenceName=na&class=header"); | ||
return [4 /*yield*/, fetch(url, opts)]; | ||
case 1: | ||
result = _a.sent(); | ||
if (!result.ok) { | ||
throw new Error("Failed to fetch ".concat(result.statusText)); | ||
} | ||
return [4 /*yield*/, result.json()]; | ||
case 2: | ||
data = _a.sent(); | ||
return [4 /*yield*/, concat(data.htsget.urls, opts)]; | ||
case 3: | ||
uncba = _a.sent(); | ||
if (uncba.readInt32LE(0) !== bamFile_1.BAM_MAGIC) { | ||
throw new Error('Not a BAM file'); | ||
} | ||
headLen = uncba.readInt32LE(4); | ||
headerText = uncba.toString('utf8', 8, 8 + headLen); | ||
samHeader = (0, sam_1.parseHeaderText)(headerText); | ||
idToName = []; | ||
nameToId = {}; | ||
sqLines = samHeader.filter(function (l) { return l.tag === 'SQ'; }); | ||
sqLines.forEach(function (sqLine, refId) { | ||
sqLine.data.forEach(function (item) { | ||
if (item.tag === 'SN') { | ||
// this is the ref name | ||
var refName = item.value; | ||
nameToId[refName] = refId; | ||
idToName[refId] = refName; | ||
} | ||
}); | ||
}); | ||
this.chrToIndex = nameToId; | ||
this.indexToChr = idToName; | ||
return [2 /*return*/, samHeader]; | ||
} | ||
throw new Error("Failed to fetch ".concat(result.statusText)); | ||
case 7: | ||
_context12.next = 9; | ||
return result.json(); | ||
case 9: | ||
data = _context12.sent; | ||
_context12.next = 12; | ||
return concat(data.htsget.urls, opts); | ||
case 12: | ||
uncba = _context12.sent; | ||
if (!(uncba.readInt32LE(0) !== _bamFile.BAM_MAGIC)) { | ||
_context12.next = 15; | ||
break; | ||
} | ||
throw new Error('Not a BAM file'); | ||
case 15: | ||
headLen = uncba.readInt32LE(4); | ||
headerText = uncba.toString('utf8', 8, 8 + headLen); | ||
samHeader = (0, _sam.parseHeaderText)(headerText); // use the @SQ lines in the header to figure out the | ||
// mapping between ref ref ID numbers and names | ||
idToName = []; | ||
nameToId = {}; | ||
sqLines = (0, _filter.default)(samHeader).call(samHeader, function (l) { | ||
return l.tag === 'SQ'; | ||
}); | ||
(0, _forEach.default)(sqLines).call(sqLines, function (sqLine, refId) { | ||
var _context11; | ||
(0, _forEach.default)(_context11 = sqLine.data).call(_context11, function (item) { | ||
if (item.tag === 'SN') { | ||
// this is the ref name | ||
var refName = item.value; | ||
nameToId[refName] = refId; | ||
idToName[refId] = refName; | ||
} | ||
}); | ||
}); | ||
this.chrToIndex = nameToId; | ||
this.indexToChr = idToName; | ||
return _context12.abrupt("return", samHeader); | ||
case 25: | ||
case "end": | ||
return _context12.stop(); | ||
} | ||
} | ||
}, _callee3, this); | ||
})); | ||
function getHeader() { | ||
return _getHeader.apply(this, arguments); | ||
} | ||
return getHeader; | ||
}() | ||
}]); | ||
return HtsgetFile; | ||
}(_bamFile.default); | ||
}); | ||
}); | ||
}; | ||
return HtsgetFile; | ||
}(bamFile_1.default)); | ||
exports.default = HtsgetFile; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9odHNnZXQudHMiXSwibmFtZXMiOlsiY29uY2F0IiwiYXJyIiwib3B0cyIsImFsbCIsImNodW5rIiwidXJsIiwiaGVhZGVycyIsIkJ1ZmZlciIsImZyb20iLCJzcGxpdCIsInJlZmVyZXIiLCJyZXN0IiwiZmV0Y2giLCJyZXMiLCJvayIsIkVycm9yIiwic3RhdHVzVGV4dCIsImFycmF5QnVmZmVyIiwiZWx0IiwiSHRzZ2V0RmlsZSIsImFyZ3MiLCJiYW1GaWxlaGFuZGxlIiwiYmFpRmlsZWhhbmRsZSIsImJhc2VVcmwiLCJ0cmFja0lkIiwiY2hyIiwibWluIiw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h0KVxuXG4gICAgLy8gdXNlIHRoZSBAU1EgbGluZXMgaW4gdGhlIGhlYWRlciB0byBmaWd1cmUgb3V0IHRoZVxuICAgIC8vIG1hcHBpbmcgYmV0d2VlbiByZWYgcmVmIElEIG51bWJlcnMgYW5kIG5hbWVzXG4gICAgY29uc3QgaWRUb05hbWU6IHN0cmluZ1tdID0gW11cbiAgICBjb25zdCBuYW1lVG9JZDogUmVjb3JkPHN0cmluZywgbnVtYmVyPiA9IHt9XG4gICAgY29uc3Qgc3FMaW5lcyA9IHNhbUhlYWRlci5maWx0ZXIoKGw6IHsgdGFnOiBzdHJpbmcgfSkgPT4gbC50YWcgPT09ICdTUScpXG4gICAgc3FMaW5lcy5mb3JFYWNoKChzcUxpbmU6IHsgZGF0YTogSGVhZGVyTGluZVtdIH0sIHJlZklkOiBudW1iZXIpID0+IHtcbiAgICAgIHNxTGluZS5kYXRhLmZvckVhY2goKGl0ZW06IEhlYWRlckxpbmUpID0+IHtcbiAgICAgICAgaWYgKGl0ZW0udGFnID09PSAnU04nKSB7XG4gICAgICAgICAgLy8gdGhpcyBpcyB0aGUgcmVmIG5hbWVcbiAgICAgICAgICBjb25zdCByZWZOYW1lID0gaXRlbS52YWx1ZVxuICAgICAgICAgIG5hbWVUb0lkW3JlZk5hbWVdID0gcmVmSWRcbiAgICAgICAgICBpZFRvTmFtZVtyZWZJZF0gPSByZWZOYW1lXG4gICAgICAgIH1cbiAgICAgIH0pXG4gICAgfSlcbiAgICB0aGlzLmNoclRvSW5kZXggPSBuYW1lVG9JZFxuICAgIHRoaXMuaW5kZXhUb0NociA9IGlkVG9OYW1lXG4gICAgcmV0dXJuIHNhbUhlYWRlclxuICB9XG59XG4iXX0= | ||
//# sourceMappingURL=htsget.js.map |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
_Object$defineProperty(exports, "BAI", { | ||
enumerable: true, | ||
get: function get() { | ||
return _bai.default; | ||
} | ||
}); | ||
_Object$defineProperty(exports, "CSI", { | ||
enumerable: true, | ||
get: function get() { | ||
return _csi.default; | ||
} | ||
}); | ||
_Object$defineProperty(exports, "BamFile", { | ||
enumerable: true, | ||
get: function get() { | ||
return _bamFile.default; | ||
} | ||
}); | ||
_Object$defineProperty(exports, "HtsgetFile", { | ||
enumerable: true, | ||
get: function get() { | ||
return _htsget.default; | ||
} | ||
}); | ||
_Object$defineProperty(exports, "BamRecord", { | ||
enumerable: true, | ||
get: function get() { | ||
return _record.default; | ||
} | ||
}); | ||
var _bai = _interopRequireDefault(require("./bai")); | ||
var _csi = _interopRequireDefault(require("./csi")); | ||
var _bamFile = _interopRequireDefault(require("./bamFile")); | ||
var _htsget = _interopRequireDefault(require("./htsget")); | ||
var _record = _interopRequireDefault(require("./record")); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTs7QUFDQTs7QUFDQTs7QUFDQTs7QUFDQSIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBCQUkgZnJvbSAnLi9iYWknXG5pbXBvcnQgQ1NJIGZyb20gJy4vY3NpJ1xuaW1wb3J0IEJhbUZpbGUgZnJvbSAnLi9iYW1GaWxlJ1xuaW1wb3J0IEh0c2dldEZpbGUgZnJvbSAnLi9odHNnZXQnXG5pbXBvcnQgQmFtUmVjb3JkIGZyb20gJy4vcmVjb3JkJ1xuXG5leHBvcnQgeyBCQUksIENTSSwgQmFtRmlsZSwgQmFtUmVjb3JkLCBIdHNnZXRGaWxlIH1cbiJdfQ== | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HtsgetFile = exports.BamRecord = exports.BamFile = exports.CSI = exports.BAI = void 0; | ||
var bai_1 = __importDefault(require("./bai")); | ||
exports.BAI = bai_1.default; | ||
var csi_1 = __importDefault(require("./csi")); | ||
exports.CSI = csi_1.default; | ||
var bamFile_1 = __importDefault(require("./bamFile")); | ||
exports.BamFile = bamFile_1.default; | ||
var htsget_1 = __importDefault(require("./htsget")); | ||
exports.HtsgetFile = htsget_1.default; | ||
var record_1 = __importDefault(require("./record")); | ||
exports.BamRecord = record_1.default; | ||
//# sourceMappingURL=index.js.map |
@@ -7,4 +7,3 @@ import { GenericFilehandle } from 'generic-filehandle'; | ||
filehandle: GenericFilehandle; | ||
renameRefSeq: Function; | ||
private _parseCache; | ||
renameRefSeq: (s: string) => string; | ||
/** | ||
@@ -11,0 +10,0 @@ * @param {filehandle} filehandle |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty2(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property")); | ||
var _defineProperties = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-properties")); | ||
var _getOwnPropertyDescriptors = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors")); | ||
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each")); | ||
var _getOwnPropertyDescriptor = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor")); | ||
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter")); | ||
var _getOwnPropertySymbols = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols")); | ||
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys")); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass")); | ||
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty")); | ||
var _abortablePromiseCache = _interopRequireDefault(require("abortable-promise-cache")); | ||
var _quickLru = _interopRequireDefault(require("quick-lru")); | ||
function ownKeys(object, enumerableOnly) { var keys = (0, _keys.default)(object); if (_getOwnPropertySymbols.default) { var symbols = (0, _getOwnPropertySymbols.default)(object); if (enumerableOnly) symbols = (0, _filter.default)(symbols).call(symbols, function (sym) { return (0, _getOwnPropertyDescriptor.default)(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { var _context3; (0, _forEach.default)(_context3 = ownKeys(Object(source), true)).call(_context3, function (key) { (0, _defineProperty3.default)(target, key, source[key]); }); } else if (_getOwnPropertyDescriptors.default) { (0, _defineProperties.default)(target, (0, _getOwnPropertyDescriptors.default)(source)); } else { var _context4; (0, _forEach.default)(_context4 = ownKeys(Object(source))).call(_context4, function (key) { (0, _defineProperty2.default)(target, key, (0, _getOwnPropertyDescriptor.default)(source, key)); }); } } return target; } | ||
var IndexFile = /*#__PURE__*/function () { | ||
/** | ||
* @param {filehandle} filehandle | ||
* @param {function} [renameRefSeqs] | ||
*/ | ||
function IndexFile(_ref) { | ||
var filehandle = _ref.filehandle, | ||
_ref$renameRefSeq = _ref.renameRefSeq, | ||
renameRefSeq = _ref$renameRefSeq === void 0 ? function (n) { | ||
return n; | ||
} : _ref$renameRefSeq; | ||
(0, _classCallCheck2.default)(this, IndexFile); | ||
(0, _defineProperty3.default)(this, "filehandle", void 0); | ||
(0, _defineProperty3.default)(this, "renameRefSeq", void 0); | ||
(0, _defineProperty3.default)(this, "_parseCache", void 0); | ||
this.filehandle = filehandle; | ||
this.renameRefSeq = renameRefSeq; | ||
} | ||
(0, _createClass2.default)(IndexFile, [{ | ||
key: "_findFirstData", | ||
value: function _findFirstData(data, virtualOffset) { | ||
var currentFdl = data.firstDataLine; | ||
if (currentFdl) { | ||
data.firstDataLine = currentFdl.compareTo(virtualOffset) > 0 ? virtualOffset : currentFdl; | ||
} else { | ||
data.firstDataLine = virtualOffset; | ||
} | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}, { | ||
key: "parse", | ||
value: function () { | ||
var _parse2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() { | ||
var _this = this; | ||
var opts, | ||
_args = arguments; | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
opts = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}; | ||
if (!this._parseCache) { | ||
this._parseCache = new _abortablePromiseCache.default({ | ||
cache: new _quickLru.default({ | ||
maxSize: 1 | ||
}), | ||
fill: function fill(opts, signal) { | ||
return _this._parse(_objectSpread(_objectSpread({}, opts), {}, { | ||
signal: signal | ||
})); | ||
} | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var IndexFile = /** @class */ (function () { | ||
/** | ||
* @param {filehandle} filehandle | ||
* @param {function} [renameRefSeqs] | ||
*/ | ||
function IndexFile(_a) { | ||
var filehandle = _a.filehandle, _b = _a.renameRefSeq, renameRefSeq = _b === void 0 ? function (n) { return n; } : _b; | ||
this.filehandle = filehandle; | ||
this.renameRefSeq = renameRefSeq; | ||
} | ||
IndexFile.prototype._findFirstData = function (data, virtualOffset) { | ||
var currentFdl = data.firstDataLine; | ||
if (currentFdl) { | ||
data.firstDataLine = | ||
currentFdl.compareTo(virtualOffset) > 0 ? virtualOffset : currentFdl; | ||
} | ||
else { | ||
data.firstDataLine = virtualOffset; | ||
} | ||
}; | ||
IndexFile.prototype.parse = function (opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this._parse(opts)]; | ||
}); | ||
}); | ||
}; | ||
IndexFile.prototype.hasRefSeq = function (seqId, opts) { | ||
if (opts === void 0) { opts = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.parse(opts)]; | ||
case 1: return [2 /*return*/, !!((_a.sent()).indices[seqId] || {}).binIndex]; | ||
} | ||
return _context.abrupt("return", this._parseCache.get('index', opts, opts.signal)); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee, this); | ||
})); | ||
function parse() { | ||
return _parse2.apply(this, arguments); | ||
} | ||
return parse; | ||
}() | ||
}, { | ||
key: "hasRefSeq", | ||
value: function () { | ||
var _hasRefSeq = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(seqId) { | ||
var opts, | ||
_args2 = arguments; | ||
return _regenerator.default.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
opts = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : {}; | ||
_context2.next = 3; | ||
return this.parse(opts); | ||
case 3: | ||
_context2.t1 = seqId; | ||
_context2.t0 = _context2.sent.indices[_context2.t1]; | ||
if (_context2.t0) { | ||
_context2.next = 7; | ||
break; | ||
} | ||
_context2.t0 = {}; | ||
case 7: | ||
return _context2.abrupt("return", !!_context2.t0.binIndex); | ||
case 8: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
}, _callee2, this); | ||
})); | ||
function hasRefSeq(_x) { | ||
return _hasRefSeq.apply(this, arguments); | ||
} | ||
return hasRefSeq; | ||
}() | ||
}]); | ||
return IndexFile; | ||
}(); | ||
}); | ||
}); | ||
}; | ||
return IndexFile; | ||
}()); | ||
exports.default = IndexFile; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleEZpbGUudHMiXSwibmFtZXMiOlsiSW5kZXhGaWxlIiwiZmlsZWhhbmRsZSIsInJlbmFtZVJlZlNlcSIsIm4iLCJkYXRhIiwidmlydHVhbE9mZnNldCIsImN1cnJlbnRGZGwiLCJmaXJzdERhdGFMaW5lIiwiY29tcGFyZVRvIiwib3B0cyIsIl9wYXJzZUNhY2hlIiwiQWJvcnRhYmxlUHJvbWlzZUNhY2hlIiwiY2FjaGUiLCJRdWlja0xSVSIsIm1heFNpemUiLCJmaWxsIiwic2lnbmFsIiwiX3BhcnNlIiwiZ2V0Iiwic2VxSWQiLCJwYXJzZSIsImluZGljZXMiLCJiaW5JbmRleCJdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBQTs7QUFDQTs7Ozs7O0lBTThCQSxTO0FBSzVCOzs7O0FBSUEsMkJBTUc7QUFBQSxRQUxEQyxVQUtDLFFBTERBLFVBS0M7QUFBQSxpQ0FKREMsWUFJQztBQUFBLFFBSkRBLFlBSUMsa0NBSmMsVUFBQ0MsQ0FBRDtBQUFBLGFBQWVBLENBQWY7QUFBQSxLQUlkO0FBQUE7QUFBQTtBQUFBO0FBQUE7QUFDRCxTQUFLRixVQUFMLEdBQWtCQSxVQUFsQjtBQUNBLFNBQUtDLFlBQUwsR0FBb0JBLFlBQXBCO0FBQ0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KSB7XG4gICAgICB0aGlzLl9wYXJzZUNhY2hlID0gbmV3IEFib3J0YWJsZVByb21pc2VDYWNoZSh7XG4gICAgICAgIGNhY2hlOiBuZXcgUXVpY2tMUlUoeyBtYXhTaXplOiAxIH0pLFxuICAgICAgICBmaWxsOiAob3B0czogQmFzZU9wdHMsIHNpZ25hbD86IEFib3J0U2lnbmFsKSA9PiB7XG4gICAgICAgICAgcmV0dXJuIHRoaXMuX3BhcnNlKHsgLi4ub3B0cywgc2lnbmFsIH0pXG4gICAgICAgIH0sXG4gICAgICB9KVxuICAgIH1cbiAgICByZXR1cm4gdGhpcy5fcGFyc2VDYWNoZS5nZXQoJ2luZGV4Jywgb3B0cywgb3B0cy5zaWduYWwpXG4gIH1cblxuICBhc3luYyBoYXNSZWZTZXEoc2VxSWQ6IG51bWJlciwgb3B0czogQmFzZU9wdHMgPSB7fSkge1xuICAgIHJldHVybiAhISgoYXdhaXQgdGhpcy5wYXJzZShvcHRzKSkuaW5kaWNlc1tzZXFJZF0gfHwge30pLmJpbkluZGV4XG4gIH1cbn1cbiJdfQ== | ||
//# sourceMappingURL=indexFile.js.map |
1203
dist/record.js
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = void 0; | ||
var _flags2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/flags")); | ||
var _parseInt2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/parse-int")); | ||
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter")); | ||
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys")); | ||
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each")); | ||
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty")); | ||
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map")); | ||
var _constants = _interopRequireDefault(require("./constants")); | ||
var _context; | ||
var SEQRET_DECODER = (0, _map.default)(_context = '=ACMGRSVTWYHKDBN'.split('')).call(_context, function (s) { | ||
return s.charCodeAt(0); | ||
}); | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-empty-function */ | ||
var constants_1 = __importDefault(require("./constants")); | ||
var SEQRET_DECODER = '=ACMGRSVTWYHKDBN'.split('').map(function (s) { return s.charCodeAt(0); }); | ||
var CIGAR_DECODER = 'MIDNSHP=X???????'.split(''); | ||
@@ -44,186 +13,135 @@ /** | ||
*/ | ||
var BamRecord = /*#__PURE__*/function () { | ||
function BamRecord(args) { | ||
(0, _classCallCheck2.default)(this, BamRecord); | ||
(0, _defineProperty2.default)(this, "data", void 0); | ||
(0, _defineProperty2.default)(this, "bytes", void 0); | ||
(0, _defineProperty2.default)(this, "flags", void 0); | ||
(0, _defineProperty2.default)(this, "_id", void 0); | ||
(0, _defineProperty2.default)(this, "_refID", void 0); | ||
(0, _defineProperty2.default)(this, "_tagOffset", undefined); | ||
(0, _defineProperty2.default)(this, "_tagList", []); | ||
(0, _defineProperty2.default)(this, "_allTagsParsed", false); | ||
this.data = {}; | ||
this.bytes = { | ||
start: args.bytes.start, | ||
end: args.bytes.end, | ||
byteArray: args.bytes.byteArray | ||
var BamRecord = /** @class */ (function () { | ||
function BamRecord(args) { | ||
this._tagOffset = undefined; | ||
this._tagList = []; | ||
this._allTagsParsed = false; | ||
this.data = {}; | ||
this.bytes = { | ||
start: args.bytes.start, | ||
end: args.bytes.end, | ||
byteArray: args.bytes.byteArray, | ||
}; | ||
this._id = args.fileOffset; | ||
var _a = this.bytes, start = _a.start, byteArray = _a.byteArray; | ||
this._refID = byteArray.readInt32LE(start + 4); | ||
this.data.start = byteArray.readInt32LE(start + 8); | ||
this.flags = (byteArray.readInt32LE(start + 16) & 0xffff0000) >> 16; | ||
} | ||
BamRecord.prototype.get = function (field) { | ||
//@ts-ignore | ||
if (this[field]) { | ||
//@ts-ignore | ||
if (this.data[field]) { | ||
return this.data[field]; | ||
} | ||
//@ts-ignore | ||
this.data[field] = this[field](); | ||
return this.data[field]; | ||
} | ||
return this._get(field.toLowerCase()); | ||
}; | ||
this._id = args.fileOffset; | ||
var _this$bytes = this.bytes, | ||
start = _this$bytes.start, | ||
byteArray = _this$bytes.byteArray; | ||
this._refID = byteArray.readInt32LE(start + 4); | ||
this.data.start = byteArray.readInt32LE(start + 8); | ||
this.flags = (byteArray.readInt32LE(start + 16) & 0xffff0000) >> 16; | ||
} | ||
(0, _createClass2.default)(BamRecord, [{ | ||
key: "get", | ||
value: function get(field) { | ||
//@ts-ignore | ||
if (this[field]) { | ||
//@ts-ignore | ||
if (this.data[field]) { | ||
return this.data[field]; | ||
} //@ts-ignore | ||
this.data[field] = this[field](); | ||
return this.data[field]; | ||
} | ||
return this._get(field.toLowerCase()); | ||
} | ||
}, { | ||
key: "end", | ||
value: function end() { | ||
return this.get('start') + (this.get('length_on_ref') || this.get('seq_length') || undefined); | ||
} | ||
}, { | ||
key: "seq_id", | ||
value: function seq_id() { | ||
return this._refID; | ||
} // same as get(), except requires lower-case arguments. used | ||
BamRecord.prototype.end = function () { | ||
return (this.get('start') + | ||
(this.get('length_on_ref') || this.get('seq_length') || undefined)); | ||
}; | ||
BamRecord.prototype.seq_id = function () { | ||
return this._refID; | ||
}; | ||
// same as get(), except requires lower-case arguments. used | ||
// internally to save lots of calls to field.toLowerCase() | ||
}, { | ||
key: "_get", | ||
value: function _get(field) { | ||
if (field in this.data) { | ||
BamRecord.prototype._get = function (field) { | ||
if (field in this.data) { | ||
return this.data[field]; | ||
} | ||
this.data[field] = this._parseTag(field); | ||
return this.data[field]; | ||
} | ||
this.data[field] = this._parseTag(field); | ||
return this.data[field]; | ||
} | ||
}, { | ||
key: "_tags", | ||
value: function _tags() { | ||
var _context2, | ||
_this = this; | ||
this._parseAllTags(); | ||
var tags = ['seq']; | ||
if (!this.isSegmentUnmapped()) { | ||
tags.push('start', 'end', 'strand', 'score', 'qual', 'MQ', 'CIGAR', 'length_on_ref', 'template_length'); | ||
} | ||
if (this.isPaired()) { | ||
tags.push('next_segment_position', 'pair_orientation'); | ||
} | ||
tags = (0, _concat.default)(tags).call(tags, this._tagList || []); | ||
(0, _forEach.default)(_context2 = (0, _keys.default)(this.data)).call(_context2, function (k) { | ||
if (k[0] !== '_' && k !== 'next_seq_id') { | ||
tags.push(k); | ||
}; | ||
BamRecord.prototype._tags = function () { | ||
var _this = this; | ||
this._parseAllTags(); | ||
var tags = ['seq']; | ||
if (!this.isSegmentUnmapped()) { | ||
tags.push('start', 'end', 'strand', 'score', 'qual', 'MQ', 'CIGAR', 'length_on_ref', 'template_length'); | ||
} | ||
}); | ||
var seen = {}; | ||
tags = (0, _filter.default)(tags).call(tags, function (t) { | ||
if (t in _this.data && _this.data[t] === undefined || t === 'CG' || t === 'cg') { | ||
return false; | ||
if (this.isPaired()) { | ||
tags.push('next_segment_position', 'pair_orientation'); | ||
} | ||
var lt = t.toLowerCase(); | ||
var s = seen[lt]; | ||
seen[lt] = true; | ||
return !s; | ||
}); | ||
return tags; | ||
} | ||
}, { | ||
key: "parent", | ||
value: function parent() { | ||
return undefined; | ||
} | ||
}, { | ||
key: "children", | ||
value: function children() { | ||
return this.get('subfeatures'); | ||
} | ||
}, { | ||
key: "id", | ||
value: function id() { | ||
return this._id; | ||
} // special parsers | ||
tags = tags.concat(this._tagList || []); | ||
Object.keys(this.data).forEach(function (k) { | ||
if (k[0] !== '_' && k !== 'next_seq_id') { | ||
tags.push(k); | ||
} | ||
}); | ||
var seen = {}; | ||
tags = tags.filter(function (t) { | ||
if ((t in _this.data && _this.data[t] === undefined) || | ||
t === 'CG' || | ||
t === 'cg') { | ||
return false; | ||
} | ||
var lt = t.toLowerCase(); | ||
var s = seen[lt]; | ||
seen[lt] = true; | ||
return !s; | ||
}); | ||
return tags; | ||
}; | ||
BamRecord.prototype.parent = function () { | ||
return undefined; | ||
}; | ||
BamRecord.prototype.children = function () { | ||
return this.get('subfeatures'); | ||
}; | ||
BamRecord.prototype.id = function () { | ||
return this._id; | ||
}; | ||
// special parsers | ||
/** | ||
* Mapping quality score. | ||
*/ | ||
}, { | ||
key: "mq", | ||
value: function mq() { | ||
var mq = (this.get('_bin_mq_nl') & 0xff00) >> 8; | ||
return mq === 255 ? undefined : mq; | ||
} | ||
}, { | ||
key: "score", | ||
value: function score() { | ||
return this.get('mq'); | ||
} | ||
}, { | ||
key: "qual", | ||
value: function qual() { | ||
var _this$qualRaw; | ||
return (_this$qualRaw = this.qualRaw()) === null || _this$qualRaw === void 0 ? void 0 : _this$qualRaw.join(' '); | ||
} | ||
}, { | ||
key: "qualRaw", | ||
value: function qualRaw() { | ||
if (this.isSegmentUnmapped()) { | ||
return undefined; | ||
} | ||
var byteArray = this.bytes.byteArray; | ||
var p = this.bytes.start + 36 + this.get('_l_read_name') + this.get('_n_cigar_op') * 4 + this.get('_seq_bytes'); | ||
var lseq = this.get('seq_length'); | ||
var qseq = Buffer.allocUnsafe(lseq); | ||
for (var j = 0; j < lseq; ++j) { | ||
qseq[j] = byteArray[p + j]; | ||
} | ||
return qseq; | ||
} | ||
}, { | ||
key: "strand", | ||
value: function strand() { | ||
return this.isReverseComplemented() ? -1 : 1; | ||
} | ||
}, { | ||
key: "multi_segment_next_segment_strand", | ||
value: function multi_segment_next_segment_strand() { | ||
if (this.isMateUnmapped()) { | ||
return undefined; | ||
} | ||
return this.isMateReverseComplemented() ? -1 : 1; | ||
} | ||
}, { | ||
key: "name", | ||
value: function name() { | ||
return this.get('_read_name'); | ||
} | ||
}, { | ||
key: "_read_name", | ||
value: function _read_name() { | ||
var nl = this.get('_l_read_name'); | ||
return this.bytes.byteArray.toString('ascii', this.bytes.start + 36, this.bytes.start + 36 + nl - 1); | ||
} | ||
BamRecord.prototype.mq = function () { | ||
var mq = (this.get('_bin_mq_nl') & 0xff00) >> 8; | ||
return mq === 255 ? undefined : mq; | ||
}; | ||
BamRecord.prototype.score = function () { | ||
return this.get('mq'); | ||
}; | ||
BamRecord.prototype.qual = function () { | ||
var _a; | ||
return (_a = this.qualRaw()) === null || _a === void 0 ? void 0 : _a.join(' '); | ||
}; | ||
BamRecord.prototype.qualRaw = function () { | ||
if (this.isSegmentUnmapped()) { | ||
return undefined; | ||
} | ||
var byteArray = this.bytes.byteArray; | ||
var p = this.bytes.start + | ||
36 + | ||
this.get('_l_read_name') + | ||
this.get('_n_cigar_op') * 4 + | ||
this.get('_seq_bytes'); | ||
var lseq = this.get('seq_length'); | ||
var qseq = Buffer.allocUnsafe(lseq); | ||
for (var j = 0; j < lseq; ++j) { | ||
qseq[j] = byteArray[p + j]; | ||
} | ||
return qseq; | ||
}; | ||
BamRecord.prototype.strand = function () { | ||
return this.isReverseComplemented() ? -1 : 1; | ||
}; | ||
BamRecord.prototype.multi_segment_next_segment_strand = function () { | ||
if (this.isMateUnmapped()) { | ||
return undefined; | ||
} | ||
return this.isMateReverseComplemented() ? -1 : 1; | ||
}; | ||
BamRecord.prototype.name = function () { | ||
return this.get('_read_name'); | ||
}; | ||
BamRecord.prototype._read_name = function () { | ||
var nl = this.get('_l_read_name'); | ||
return this.bytes.byteArray.toString('ascii', this.bytes.start + 36, this.bytes.start + 36 + nl - 1); | ||
}; | ||
/** | ||
@@ -233,524 +151,395 @@ * Get the value of a tag, parsing the tags as far as necessary. | ||
*/ | ||
}, { | ||
key: "_parseTag", | ||
value: function _parseTag(tagName) { | ||
// if all of the tags have been parsed and we're still being | ||
// called, we already know that we have no such tag, because | ||
// it would already have been cached. | ||
if (this._allTagsParsed) { | ||
return undefined; | ||
} | ||
var byteArray = this.bytes.byteArray; | ||
var p = this._tagOffset || this.bytes.start + 36 + this.get('_l_read_name') + this.get('_n_cigar_op') * 4 + this.get('_seq_bytes') + this.get('seq_length'); | ||
var blockEnd = this.bytes.end; | ||
var lcTag; | ||
while (p < blockEnd && lcTag !== tagName) { | ||
var tag = String.fromCharCode(byteArray[p], byteArray[p + 1]); | ||
lcTag = tag.toLowerCase(); | ||
var type = String.fromCharCode(byteArray[p + 2]); | ||
p += 3; | ||
var value = void 0; | ||
switch (type) { | ||
case 'A': | ||
value = String.fromCharCode(byteArray[p]); | ||
p += 1; | ||
break; | ||
case 'i': | ||
value = byteArray.readInt32LE(p); | ||
p += 4; | ||
break; | ||
case 'I': | ||
value = byteArray.readUInt32LE(p); | ||
p += 4; | ||
break; | ||
case 'c': | ||
value = byteArray.readInt8(p); | ||
p += 1; | ||
break; | ||
case 'C': | ||
value = byteArray.readUInt8(p); | ||
p += 1; | ||
break; | ||
case 's': | ||
value = byteArray.readInt16LE(p); | ||
p += 2; | ||
break; | ||
case 'S': | ||
value = byteArray.readUInt16LE(p); | ||
p += 2; | ||
break; | ||
case 'f': | ||
value = byteArray.readFloatLE(p); | ||
p += 4; | ||
break; | ||
case 'Z': | ||
case 'H': | ||
value = ''; | ||
while (p <= blockEnd) { | ||
var cc = byteArray[p++]; | ||
if (cc === 0) { | ||
break; | ||
} else { | ||
value += String.fromCharCode(cc); | ||
} | ||
} | ||
break; | ||
case 'B': | ||
{ | ||
value = ''; | ||
var _cc = byteArray[p++]; | ||
var Btype = String.fromCharCode(_cc); | ||
var limit = byteArray.readInt32LE(p); | ||
p += 4; | ||
if (Btype === 'i') { | ||
if (tag === 'CG') { | ||
for (var k = 0; k < limit; k++) { | ||
var cigop = byteArray.readInt32LE(p); | ||
var lop = cigop >> 4; | ||
var op = CIGAR_DECODER[cigop & 0xf]; | ||
value += lop + op; | ||
BamRecord.prototype._parseTag = function (tagName) { | ||
// if all of the tags have been parsed and we're still being | ||
// called, we already know that we have no such tag, because | ||
// it would already have been cached. | ||
if (this._allTagsParsed) { | ||
return undefined; | ||
} | ||
var byteArray = this.bytes.byteArray; | ||
var p = this._tagOffset || | ||
this.bytes.start + | ||
36 + | ||
this.get('_l_read_name') + | ||
this.get('_n_cigar_op') * 4 + | ||
this.get('_seq_bytes') + | ||
this.get('seq_length'); | ||
var blockEnd = this.bytes.end; | ||
var lcTag; | ||
while (p < blockEnd && lcTag !== tagName) { | ||
var tag = String.fromCharCode(byteArray[p], byteArray[p + 1]); | ||
lcTag = tag.toLowerCase(); | ||
var type = String.fromCharCode(byteArray[p + 2]); | ||
p += 3; | ||
var value = void 0; | ||
switch (type) { | ||
case 'A': | ||
value = String.fromCharCode(byteArray[p]); | ||
p += 1; | ||
break; | ||
case 'i': | ||
value = byteArray.readInt32LE(p); | ||
p += 4; | ||
} | ||
} else { | ||
for (var _k = 0; _k < limit; _k++) { | ||
value += byteArray.readInt32LE(p); | ||
if (_k + 1 < limit) { | ||
value += ','; | ||
} | ||
break; | ||
case 'I': | ||
value = byteArray.readUInt32LE(p); | ||
p += 4; | ||
} | ||
} | ||
} | ||
if (Btype === 'I') { | ||
if (tag === 'CG') { | ||
for (var _k2 = 0; _k2 < limit; _k2++) { | ||
var _cigop = byteArray.readUInt32LE(p); | ||
var _lop = _cigop >> 4; | ||
var _op = CIGAR_DECODER[_cigop & 0xf]; | ||
value += _lop + _op; | ||
break; | ||
case 'c': | ||
value = byteArray.readInt8(p); | ||
p += 1; | ||
break; | ||
case 'C': | ||
value = byteArray.readUInt8(p); | ||
p += 1; | ||
break; | ||
case 's': | ||
value = byteArray.readInt16LE(p); | ||
p += 2; | ||
break; | ||
case 'S': | ||
value = byteArray.readUInt16LE(p); | ||
p += 2; | ||
break; | ||
case 'f': | ||
value = byteArray.readFloatLE(p); | ||
p += 4; | ||
} | ||
} else { | ||
for (var _k3 = 0; _k3 < limit; _k3++) { | ||
value += byteArray.readUInt32LE(p); | ||
if (_k3 + 1 < limit) { | ||
value += ','; | ||
break; | ||
case 'Z': | ||
case 'H': | ||
value = ''; | ||
while (p <= blockEnd) { | ||
var cc = byteArray[p++]; | ||
if (cc === 0) { | ||
break; | ||
} | ||
else { | ||
value += String.fromCharCode(cc); | ||
} | ||
} | ||
break; | ||
case 'B': { | ||
value = ''; | ||
var cc = byteArray[p++]; | ||
var Btype = String.fromCharCode(cc); | ||
var limit = byteArray.readInt32LE(p); | ||
p += 4; | ||
} | ||
if (Btype === 'i') { | ||
if (tag === 'CG') { | ||
for (var k = 0; k < limit; k++) { | ||
var cigop = byteArray.readInt32LE(p); | ||
var lop = cigop >> 4; | ||
var op = CIGAR_DECODER[cigop & 0xf]; | ||
value += lop + op; | ||
p += 4; | ||
} | ||
} | ||
else { | ||
for (var k = 0; k < limit; k++) { | ||
value += byteArray.readInt32LE(p); | ||
if (k + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 4; | ||
} | ||
} | ||
} | ||
if (Btype === 'I') { | ||
if (tag === 'CG') { | ||
for (var k = 0; k < limit; k++) { | ||
var cigop = byteArray.readUInt32LE(p); | ||
var lop = cigop >> 4; | ||
var op = CIGAR_DECODER[cigop & 0xf]; | ||
value += lop + op; | ||
p += 4; | ||
} | ||
} | ||
else { | ||
for (var k = 0; k < limit; k++) { | ||
value += byteArray.readUInt32LE(p); | ||
if (k + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 4; | ||
} | ||
} | ||
} | ||
if (Btype === 's') { | ||
for (var k = 0; k < limit; k++) { | ||
value += byteArray.readInt16LE(p); | ||
if (k + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 2; | ||
} | ||
} | ||
if (Btype === 'S') { | ||
for (var k = 0; k < limit; k++) { | ||
value += byteArray.readUInt16LE(p); | ||
if (k + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 2; | ||
} | ||
} | ||
if (Btype === 'c') { | ||
for (var k = 0; k < limit; k++) { | ||
value += byteArray.readInt8(p); | ||
if (k + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 1; | ||
} | ||
} | ||
if (Btype === 'C') { | ||
for (var k = 0; k < limit; k++) { | ||
value += byteArray.readUInt8(p); | ||
if (k + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 1; | ||
} | ||
} | ||
if (Btype === 'f') { | ||
for (var k = 0; k < limit; k++) { | ||
value += byteArray.readFloatLE(p); | ||
if (k + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 4; | ||
} | ||
} | ||
break; | ||
} | ||
} | ||
if (Btype === 's') { | ||
for (var _k4 = 0; _k4 < limit; _k4++) { | ||
value += byteArray.readInt16LE(p); | ||
if (_k4 + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 2; | ||
} | ||
} | ||
if (Btype === 'S') { | ||
for (var _k5 = 0; _k5 < limit; _k5++) { | ||
value += byteArray.readUInt16LE(p); | ||
if (_k5 + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 2; | ||
} | ||
} | ||
if (Btype === 'c') { | ||
for (var _k6 = 0; _k6 < limit; _k6++) { | ||
value += byteArray.readInt8(p); | ||
if (_k6 + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 1; | ||
} | ||
} | ||
if (Btype === 'C') { | ||
for (var _k7 = 0; _k7 < limit; _k7++) { | ||
value += byteArray.readUInt8(p); | ||
if (_k7 + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 1; | ||
} | ||
} | ||
if (Btype === 'f') { | ||
for (var _k8 = 0; _k8 < limit; _k8++) { | ||
value += byteArray.readFloatLE(p); | ||
if (_k8 + 1 < limit) { | ||
value += ','; | ||
} | ||
p += 4; | ||
} | ||
} | ||
break; | ||
default: | ||
console.warn("Unknown BAM tag type '".concat(type, "', tags may be incomplete")); | ||
value = undefined; | ||
p = blockEnd; // stop parsing tags | ||
} | ||
default: | ||
console.warn("Unknown BAM tag type '".concat(type, "', tags may be incomplete")); | ||
value = undefined; | ||
p = blockEnd; | ||
// stop parsing tags | ||
this._tagOffset = p; | ||
this._tagList.push(tag); | ||
if (lcTag === tagName) { | ||
return value; | ||
} | ||
this.data[lcTag] = value; | ||
} | ||
this._tagOffset = p; | ||
this._tagList.push(tag); | ||
if (lcTag === tagName) { | ||
return value; | ||
} | ||
this.data[lcTag] = value; | ||
} | ||
this._allTagsParsed = true; | ||
return undefined; | ||
} | ||
}, { | ||
key: "_parseAllTags", | ||
value: function _parseAllTags() { | ||
this._parseTag(''); | ||
} | ||
}, { | ||
key: "_parseCigar", | ||
value: function _parseCigar(cigar) { | ||
var _context3; | ||
return (//@ts-ignore | ||
(0, _map.default)(_context3 = cigar.match(/\d+\D/g)).call(_context3, function (op) { | ||
return [op.match(/\D/)[0].toUpperCase(), (0, _parseInt2.default)(op, 10)]; | ||
}) | ||
); | ||
} | ||
this._allTagsParsed = true; | ||
return undefined; | ||
}; | ||
BamRecord.prototype._parseAllTags = function () { | ||
this._parseTag(''); | ||
}; | ||
BamRecord.prototype._parseCigar = function (cigar) { | ||
return ( | ||
//@ts-ignore | ||
cigar | ||
.match(/\d+\D/g) | ||
//@ts-ignore | ||
.map(function (op) { return [op.match(/\D/)[0].toUpperCase(), parseInt(op, 10)]; })); | ||
}; | ||
/** | ||
* @returns {boolean} true if the read is paired, regardless of whether both segments are mapped | ||
*/ | ||
}, { | ||
key: "isPaired", | ||
value: function isPaired() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FPAIRED); | ||
} | ||
BamRecord.prototype.isPaired = function () { | ||
return !!(this.flags & constants_1.default.BAM_FPAIRED); | ||
}; | ||
/** @returns {boolean} true if the read is paired, and both segments are mapped */ | ||
}, { | ||
key: "isProperlyPaired", | ||
value: function isProperlyPaired() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FPROPER_PAIR); | ||
} | ||
BamRecord.prototype.isProperlyPaired = function () { | ||
return !!(this.flags & constants_1.default.BAM_FPROPER_PAIR); | ||
}; | ||
/** @returns {boolean} true if the read itself is unmapped; conflictive with isProperlyPaired */ | ||
}, { | ||
key: "isSegmentUnmapped", | ||
value: function isSegmentUnmapped() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FUNMAP); | ||
} | ||
BamRecord.prototype.isSegmentUnmapped = function () { | ||
return !!(this.flags & constants_1.default.BAM_FUNMAP); | ||
}; | ||
/** @returns {boolean} true if the read itself is unmapped; conflictive with isProperlyPaired */ | ||
}, { | ||
key: "isMateUnmapped", | ||
value: function isMateUnmapped() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FMUNMAP); | ||
} | ||
BamRecord.prototype.isMateUnmapped = function () { | ||
return !!(this.flags & constants_1.default.BAM_FMUNMAP); | ||
}; | ||
/** @returns {boolean} true if the read is mapped to the reverse strand */ | ||
}, { | ||
key: "isReverseComplemented", | ||
value: function isReverseComplemented() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FREVERSE); | ||
} | ||
BamRecord.prototype.isReverseComplemented = function () { | ||
return !!(this.flags & constants_1.default.BAM_FREVERSE); | ||
}; | ||
/** @returns {boolean} true if the mate is mapped to the reverse strand */ | ||
}, { | ||
key: "isMateReverseComplemented", | ||
value: function isMateReverseComplemented() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FMREVERSE); | ||
} | ||
BamRecord.prototype.isMateReverseComplemented = function () { | ||
return !!(this.flags & constants_1.default.BAM_FMREVERSE); | ||
}; | ||
/** @returns {boolean} true if this is read number 1 in a pair */ | ||
}, { | ||
key: "isRead1", | ||
value: function isRead1() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FREAD1); | ||
} | ||
BamRecord.prototype.isRead1 = function () { | ||
return !!(this.flags & constants_1.default.BAM_FREAD1); | ||
}; | ||
/** @returns {boolean} true if this is read number 2 in a pair */ | ||
}, { | ||
key: "isRead2", | ||
value: function isRead2() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FREAD2); | ||
} | ||
BamRecord.prototype.isRead2 = function () { | ||
return !!(this.flags & constants_1.default.BAM_FREAD2); | ||
}; | ||
/** @returns {boolean} true if this is a secondary alignment */ | ||
}, { | ||
key: "isSecondary", | ||
value: function isSecondary() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FSECONDARY); | ||
} | ||
BamRecord.prototype.isSecondary = function () { | ||
return !!(this.flags & constants_1.default.BAM_FSECONDARY); | ||
}; | ||
/** @returns {boolean} true if this read has failed QC checks */ | ||
}, { | ||
key: "isFailedQc", | ||
value: function isFailedQc() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FQCFAIL); | ||
} | ||
BamRecord.prototype.isFailedQc = function () { | ||
return !!(this.flags & constants_1.default.BAM_FQCFAIL); | ||
}; | ||
/** @returns {boolean} true if the read is an optical or PCR duplicate */ | ||
}, { | ||
key: "isDuplicate", | ||
value: function isDuplicate() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FDUP); | ||
} | ||
BamRecord.prototype.isDuplicate = function () { | ||
return !!(this.flags & constants_1.default.BAM_FDUP); | ||
}; | ||
/** @returns {boolean} true if this is a supplementary alignment */ | ||
}, { | ||
key: "isSupplementary", | ||
value: function isSupplementary() { | ||
return !!((0, _flags2.default)(this) & _constants.default.BAM_FSUPPLEMENTARY); | ||
} | ||
}, { | ||
key: "cigar", | ||
value: function cigar() { | ||
if (this.isSegmentUnmapped()) { | ||
return undefined; | ||
} | ||
var _this$bytes2 = this.bytes, | ||
byteArray = _this$bytes2.byteArray, | ||
start = _this$bytes2.start; | ||
var numCigarOps = this.get('_n_cigar_op'); | ||
var p = start + 36 + this.get('_l_read_name'); | ||
var seqLen = this.get('seq_length'); | ||
var cigar = ''; | ||
var lref = 0; // check for CG tag by inspecting whether the CIGAR field | ||
// contains a clip that consumes entire seqLen | ||
var cigop = byteArray.readInt32LE(p); | ||
var lop = cigop >> 4; | ||
var op = CIGAR_DECODER[cigop & 0xf]; | ||
if (op === 'S' && lop === seqLen) { | ||
// if there is a CG the second CIGAR field will | ||
// be a N tag the represents the length on ref | ||
p += 4; | ||
cigop = byteArray.readInt32LE(p); | ||
lop = cigop >> 4; | ||
op = CIGAR_DECODER[cigop & 0xf]; | ||
if (op !== 'N') { | ||
console.warn('CG tag with no N tag'); | ||
BamRecord.prototype.isSupplementary = function () { | ||
return !!(this.flags & constants_1.default.BAM_FSUPPLEMENTARY); | ||
}; | ||
BamRecord.prototype.cigar = function () { | ||
if (this.isSegmentUnmapped()) { | ||
return undefined; | ||
} | ||
this.data.length_on_ref = lop; | ||
return this.get('CG'); | ||
} else { | ||
for (var c = 0; c < numCigarOps; ++c) { | ||
cigop = byteArray.readInt32LE(p); | ||
lop = cigop >> 4; | ||
op = CIGAR_DECODER[cigop & 0xf]; | ||
cigar += lop + op; // soft clip, hard clip, and insertion don't count toward | ||
// the length on the reference | ||
if (op !== 'H' && op !== 'S' && op !== 'I') { | ||
lref += lop; | ||
} | ||
p += 4; | ||
var _a = this.bytes, byteArray = _a.byteArray, start = _a.start; | ||
var numCigarOps = this.get('_n_cigar_op'); | ||
var p = start + 36 + this.get('_l_read_name'); | ||
var seqLen = this.get('seq_length'); | ||
var cigar = ''; | ||
var lref = 0; | ||
// check for CG tag by inspecting whether the CIGAR field | ||
// contains a clip that consumes entire seqLen | ||
var cigop = byteArray.readInt32LE(p); | ||
var lop = cigop >> 4; | ||
var op = CIGAR_DECODER[cigop & 0xf]; | ||
if (op === 'S' && lop === seqLen) { | ||
// if there is a CG the second CIGAR field will | ||
// be a N tag the represents the length on ref | ||
p += 4; | ||
cigop = byteArray.readInt32LE(p); | ||
lop = cigop >> 4; | ||
op = CIGAR_DECODER[cigop & 0xf]; | ||
if (op !== 'N') { | ||
console.warn('CG tag with no N tag'); | ||
} | ||
this.data.length_on_ref = lop; | ||
return this.get('CG'); | ||
} | ||
this.data.length_on_ref = lref; | ||
return cigar; | ||
} | ||
} | ||
}, { | ||
key: "_flags", | ||
value: function _flags() {} | ||
}, { | ||
key: "length_on_ref", | ||
value: function length_on_ref() { | ||
this.get('cigar'); // the length_on_ref is set as a | ||
// side effect of the CIGAR parsing | ||
return this.data.length_on_ref; | ||
} | ||
}, { | ||
key: "_n_cigar_op", | ||
value: function _n_cigar_op() { | ||
return this.get('_flag_nc') & 0xffff; | ||
} | ||
}, { | ||
key: "_l_read_name", | ||
value: function _l_read_name() { | ||
return this.get('_bin_mq_nl') & 0xff; | ||
} | ||
else { | ||
for (var c = 0; c < numCigarOps; ++c) { | ||
cigop = byteArray.readInt32LE(p); | ||
lop = cigop >> 4; | ||
op = CIGAR_DECODER[cigop & 0xf]; | ||
cigar += lop + op; | ||
// soft clip, hard clip, and insertion don't count toward | ||
// the length on the reference | ||
if (op !== 'H' && op !== 'S' && op !== 'I') { | ||
lref += lop; | ||
} | ||
p += 4; | ||
} | ||
this.data.length_on_ref = lref; | ||
return cigar; | ||
} | ||
}; | ||
BamRecord.prototype._flags = function () { }; | ||
BamRecord.prototype.length_on_ref = function () { | ||
this.get('cigar'); // the length_on_ref is set as a | ||
// side effect of the CIGAR parsing | ||
return this.data.length_on_ref; | ||
}; | ||
BamRecord.prototype._n_cigar_op = function () { | ||
return this.get('_flag_nc') & 0xffff; | ||
}; | ||
BamRecord.prototype._l_read_name = function () { | ||
return this.get('_bin_mq_nl') & 0xff; | ||
}; | ||
/** | ||
* number of bytes in the sequence field | ||
*/ | ||
}, { | ||
key: "_seq_bytes", | ||
value: function _seq_bytes() { | ||
return this.get('seq_length') + 1 >> 1; | ||
} | ||
}, { | ||
key: "getReadBases", | ||
value: function getReadBases() { | ||
return this.seq(); | ||
} | ||
}, { | ||
key: "seq", | ||
value: function seq() { | ||
var byteArray = this.bytes.byteArray; | ||
var p = this.bytes.start + 36 + this.get('_l_read_name') + this.get('_n_cigar_op') * 4; | ||
var seqBytes = this.get('_seq_bytes'); | ||
var len = this.get('seq_length'); | ||
var buf = ''; | ||
var i = 0; | ||
for (var j = 0; j < seqBytes; ++j) { | ||
var sb = byteArray[p + j]; | ||
buf += String.fromCharCode(SEQRET_DECODER[(sb & 0xf0) >> 4]); | ||
i++; | ||
if (i < len) { | ||
buf += String.fromCharCode(SEQRET_DECODER[sb & 0x0f]); | ||
i++; | ||
BamRecord.prototype._seq_bytes = function () { | ||
return (this.get('seq_length') + 1) >> 1; | ||
}; | ||
BamRecord.prototype.getReadBases = function () { | ||
return this.seq(); | ||
}; | ||
BamRecord.prototype.seq = function () { | ||
var byteArray = this.bytes.byteArray; | ||
var p = this.bytes.start + | ||
36 + | ||
this.get('_l_read_name') + | ||
this.get('_n_cigar_op') * 4; | ||
var seqBytes = this.get('_seq_bytes'); | ||
var len = this.get('seq_length'); | ||
var buf = ''; | ||
var i = 0; | ||
for (var j = 0; j < seqBytes; ++j) { | ||
var sb = byteArray[p + j]; | ||
buf += String.fromCharCode(SEQRET_DECODER[(sb & 0xf0) >> 4]); | ||
i++; | ||
if (i < len) { | ||
buf += String.fromCharCode(SEQRET_DECODER[sb & 0x0f]); | ||
i++; | ||
} | ||
} | ||
} | ||
return buf; | ||
} // adapted from igv.js | ||
}, { | ||
key: "getPairOrientation", | ||
value: function getPairOrientation() { | ||
if (!this.isSegmentUnmapped() && !this.isMateUnmapped() && this._refID === this._next_refid()) { | ||
var s1 = this.isReverseComplemented() ? 'R' : 'F'; | ||
var s2 = this.isMateReverseComplemented() ? 'R' : 'F'; | ||
var o1 = ' '; | ||
var o2 = ' '; | ||
if (this.isRead1()) { | ||
o1 = '1'; | ||
o2 = '2'; | ||
} else if (this.isRead2()) { | ||
o1 = '2'; | ||
o2 = '1'; | ||
return buf; | ||
}; | ||
// adapted from igv.js | ||
BamRecord.prototype.getPairOrientation = function () { | ||
if (!this.isSegmentUnmapped() && | ||
!this.isMateUnmapped() && | ||
this._refID === this._next_refid()) { | ||
var s1 = this.isReverseComplemented() ? 'R' : 'F'; | ||
var s2 = this.isMateReverseComplemented() ? 'R' : 'F'; | ||
var o1 = ' '; | ||
var o2 = ' '; | ||
if (this.isRead1()) { | ||
o1 = '1'; | ||
o2 = '2'; | ||
} | ||
else if (this.isRead2()) { | ||
o1 = '2'; | ||
o2 = '1'; | ||
} | ||
var tmp = []; | ||
var isize = this.template_length(); | ||
if (isize > 0) { | ||
tmp[0] = s1; | ||
tmp[1] = o1; | ||
tmp[2] = s2; | ||
tmp[3] = o2; | ||
} | ||
else { | ||
tmp[2] = s1; | ||
tmp[3] = o1; | ||
tmp[0] = s2; | ||
tmp[1] = o2; | ||
} | ||
return tmp.join(''); | ||
} | ||
var tmp = []; | ||
var isize = this.template_length(); | ||
if (isize > 0) { | ||
tmp[0] = s1; | ||
tmp[1] = o1; | ||
tmp[2] = s2; | ||
tmp[3] = o2; | ||
} else { | ||
tmp[2] = s1; | ||
tmp[3] = o1; | ||
tmp[0] = s2; | ||
tmp[1] = o2; | ||
} | ||
return tmp.join(''); | ||
} | ||
return null; | ||
} | ||
}, { | ||
key: "_bin_mq_nl", | ||
value: function _bin_mq_nl() { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 12); | ||
} | ||
}, { | ||
key: "_flag_nc", | ||
value: function _flag_nc() { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 16); | ||
} | ||
}, { | ||
key: "seq_length", | ||
value: function seq_length() { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 20); | ||
} | ||
}, { | ||
key: "_next_refid", | ||
value: function _next_refid() { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 24); | ||
} | ||
}, { | ||
key: "_next_pos", | ||
value: function _next_pos() { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 28); | ||
} | ||
}, { | ||
key: "template_length", | ||
value: function template_length() { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 32); | ||
} | ||
}, { | ||
key: "toJSON", | ||
value: function toJSON() { | ||
var _context4, | ||
_this2 = this; | ||
var data = {}; | ||
(0, _forEach.default)(_context4 = (0, _keys.default)(this)).call(_context4, function (k) { | ||
if (k.charAt(0) === '_' || k === 'bytes') { | ||
return; | ||
} //@ts-ignore | ||
data[k] = _this2[k]; | ||
}); | ||
return data; | ||
} | ||
}]); | ||
return BamRecord; | ||
}(); | ||
return null; | ||
}; | ||
BamRecord.prototype._bin_mq_nl = function () { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 12); | ||
}; | ||
BamRecord.prototype._flag_nc = function () { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 16); | ||
}; | ||
BamRecord.prototype.seq_length = function () { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 20); | ||
}; | ||
BamRecord.prototype._next_refid = function () { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 24); | ||
}; | ||
BamRecord.prototype._next_pos = function () { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 28); | ||
}; | ||
BamRecord.prototype.template_length = function () { | ||
return this.bytes.byteArray.readInt32LE(this.bytes.start + 32); | ||
}; | ||
BamRecord.prototype.toJSON = function () { | ||
var _this = this; | ||
var data = {}; | ||
Object.keys(this).forEach(function (k) { | ||
if (k.charAt(0) === '_' || k === 'bytes') { | ||
return; | ||
} | ||
//@ts-ignore | ||
data[k] = _this[k]; | ||
}); | ||
return data; | ||
}; | ||
return BamRecord; | ||
}()); | ||
exports.default = BamRecord; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9yZWNvcmQudHMiXSwibmFtZXMiOlsiU0VRUkVUX0RFQ09ERVIiLCJzcGxpdCIsInMiLCJjaGFyQ29kZUF0IiwiQ0lHQVJfREVDT0RFUiIsIkJhbVJlY29yZCIsImFyZ3MiLCJ1bmRlZmluZWQiLCJkYXRhIiwiYnl0ZXMiLCJzdGFydCIsImVuZCIsImJ5dGVBcnJheSIsIl9pZCIsImZpbGVPZmZzZXQiLCJfcmVmSUQiLCJyZWFkSW50MzJMRSIsImZsYWdzIiwiZmllbGQiLCJfZ2V0IiwidG9Mb3dlckNhc2UiLCJnZXQiLCJfcGFy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ICAgYnJlYWtcbiAgICAgICAgY2FzZSAnYyc6XG4gICAgICAgICAgdmFsdWUgPSBieXRlQXJyYXkucmVhZEludDgocClcbiAgICAgICAgICBwICs9IDFcbiAgICAgICAgICBicmVha1xuICAgICAgICBjYXNlICdDJzpcbiAgICAgICAgICB2YWx1ZSA9IGJ5dGVBcnJheS5yZWFkVUludDgocClcbiAgICAgICAgICBwICs9IDFcbiAgICAgICAgICBicmVha1xuICAgICAgICBjYXNlICdzJzpcbiAgICAgICAgICB2YWx1ZSA9IGJ5dGVBcnJheS5yZWFkSW50MTZMRShwKVxuICAgICAgICAgIHAgKz0gMlxuICAgICAgICAgIGJyZWFrXG4gICAgICAgIGNhc2UgJ1MnOlxuICAgICAgICAgIHZhbHVlID0gYnl0ZUFycmF5LnJlYWRVSW50MTZMRShwKVxuICAgICAgICAgIHAgKz0gMlxuICAgICAgICAgIGJyZWFrXG4gICAgICAgIGNhc2UgJ2YnOlxuICAgICAgICAgIHZhbHVlID0gYnl0ZUFycmF5LnJlYWRGbG9hdExFKHApXG4gICAgICAgICAgcCArPSA0XG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgY2FzZSAnWic6XG4gICAgICAgIGNhc2UgJ0gnOlxuICAgICAgICAgIHZhbHVlID0gJydcbiAgICAgICAgICB3aGlsZSAocCA8PSBibG9ja0VuZCkge1xuICAgICAgICAgICAgY29uc3QgY2MgPSBieXRlQXJyYXlbcCsrXVxuICAgICAgICAgICAgaWYgKGNjID09PSAwKSB7XG4gICAgICAgICAgICAgIGJyZWFrXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICB2YWx1ZSArPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGNjKVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBicmVha1xuICAgICAgICBjYXNlICdCJzoge1xuICAgICAgICAgIHZhbHVlID0gJydcbiAgICAgICAgICBjb25zdCBjYyA9IGJ5dGVBcnJheVtwKytdXG4gICAgICAgICAgY29uc3QgQnR5cGUgPSBTdHJpbmcuZnJvbUNoYXJDb2RlKGNjKVxuICAgICAgICAgIGNvbnN0IGxpbWl0ID0gYnl0ZUFycmF5LnJlYWRJbnQzMkxFKHApXG4gICAgICAgICAgcCArPSA0XG4gICAgICAgICAgaWYgKEJ0eXBlID09PSAnaScpIHtcbiAgICAgICAgICAgIGlmICh0YWcgPT09ICdDRycpIHtcbiAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBsaW1pdDsgaysrKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgY2lnb3AgPSBieXRlQXJyYXkucmVhZEludDMyTEUocClcbiAgICAgICAgICAgICAgICBjb25zdCBsb3AgPSBjaWdvcCA+PiA0XG4gICAgICAgICAgICAgICAgY29uc3Qgb3AgPSBDSUdBUl9ERUNPREVSW2NpZ29wICYgMHhmXVxuICAgICAgICAgICAgICAgIHZhbHVlICs9IGxvcCArIG9wXG4gICAgICAgICAgICAgICAgcCArPSA0XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIGZvciAobGV0IGsgPSAwOyBrIDwgbGltaXQ7IGsrKykge1xuICAgICAgICAgICAgICAgIHZhbHVlICs9IGJ5dGVBcnJheS5yZWFkSW50MzJMRShwKVxuICAgICAgICAgICAgICAgIGlmIChrICsgMSA8IGxpbWl0KSB7XG4gICAgICAgICAgICAgICAgICB2YWx1ZSArPSAnLCdcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgcCArPSA0XG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKEJ0eXBlID09PSAnSScpIHtcbiAgICAgICAgICAgIGlmICh0YWcgPT09ICdDRycpIHtcbiAgICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBsaW1pdDsgaysrKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgY2lnb3AgPSBieXRlQXJyYXkucmVhZFVJbnQzMkxFKHApXG4gICAgICAgICAgICAgICAgY29uc3QgbG9wID0gY2lnb3AgPj4gNFxuICAgICAgICAgICAgICAgIGNvbnN0IG9wID0gQ0lHQVJfREVDT0RFUltjaWdvcCAmIDB4Zl1cbiAgICAgICAgICAgICAgICB2YWx1ZSArPSBsb3AgKyBvcFxuICAgICAgICAgICAgICAgIHAgKz0gNFxuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGxpbWl0OyBrKyspIHtcbiAgICAgICAgICAgICAgICB2YWx1ZSArPSBieXRlQXJyYXkucmVhZFVJbnQzMkxFKHApXG4gICAgICAgICAgICAgICAgaWYgKGsgKyAxIDwgbGltaXQpIHtcbiAgICAgICAgICAgICAgICAgIHZhbHVlICs9ICcsJ1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBwICs9IDRcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoQnR5cGUgPT09ICdzJykge1xuICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBsaW1pdDsgaysrKSB7XG4gICAgICAgICAgICAgIHZhbHVlICs9IGJ5dGVBcnJheS5yZWFkSW50MTZMRShwKVxuICAgICAgICAgICAgICBpZiAoayArIDEgPCBsaW1pdCkge1xuICAgICAgICAgICAgICAgIHZhbHVlICs9ICcsJ1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgIHAgKz0gMlxuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAoQnR5cGUgPT09ICdTJykge1xuICAgICAgICAgICAgZm9yIChsZXQgayA9IDA7IGsgPCBsaW1pdDsgaysrKSB7XG4gICAgICAgICAgICAgIHZhbHVlICs9IGJ5dGVBcnJheS5yZWFkVUludDE2TEUocClcbiAgICAgICAgICAgICAgaWYgKGsgKyAxIDwgbGltaXQpIHtcbiAgICAgICAgICAgICAgICB2YWx1ZSArPSAnLCdcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBwICs9IDJcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKEJ0eXBlID09PSAnYycpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGsgPSAwOyBrIDwgbGltaXQ7IGsrKykge1xuICAgICAgICAgICAgICB2YWx1ZSArPSBieXRlQXJyYXkucmVhZEludDgocClcbiAgICAgICAgICAgICAgaWYgKGsgKyAxIDwgbGltaXQpIHtcbiAgICAgICAgICAgICAgICB2YWx1ZSArPSAnLCdcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBwICs9IDFcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgICAgaWYgKEJ0eXBlID09PSAnQycpIHtcbiAgICAgICAgICAgIGZvciAobGV0IGsgPSAwOyBrIDwgbGltaXQ7IGsrKykge1xuICAgICAgICAgICAgICB2YWx1ZSArPSBieXRlQXJyYXkucmVhZFVJbnQ4KHApXG4gICAgICAgICAgICAgIGlmIChrICsgMSA8IGxpbWl0KSB7XG4gICAgICAgICAgICAgICAgdmFsdWUgKz0gJywnXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgcCArPSAxXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIGlmIChCdHlwZSA9PT0gJ2YnKSB7XG4gICAgICAgICAgICBmb3IgKGxldCBrID0gMDsgayA8IGxpbWl0OyBrKyspIHtcbiAgICAgICAgICAgICAgdmFsdWUgKz0gYnl0ZUFycmF5LnJlYWRGbG9hdExFKHApXG4gICAgICAgICAgICAgIGlmIChrICsgMSA8IGxpbWl0KSB7XG4gICAgICAgICAgICAgICAgdmFsdWUgKz0gJywnXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgcCArPSA0XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxu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WNoKGsgPT4ge1xuICAgICAgaWYgKGsuY2hhckF0KDApID09PSAnXycgfHwgayA9PT0gJ2J5dGVzJykge1xuICAgICAgICByZXR1cm5cbiAgICAgIH1cbiAgICAgIC8vQHRzLWlnbm9yZVxuICAgICAgZGF0YVtrXSA9IHRoaXNba11cbiAgICB9KVxuXG4gICAgcmV0dXJuIGRhdGFcbiAgfVxufVxuIl19 | ||
//# sourceMappingURL=record.js.map |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.parseHeaderText = parseHeaderText; | ||
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray")); | ||
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map")); | ||
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice")); | ||
var _toArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toArray")); | ||
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each")); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseHeaderText = void 0; | ||
function parseHeaderText(text) { | ||
var lines = text.split(/\r?\n/); | ||
var data = []; | ||
(0, _forEach.default)(lines).call(lines, function (line) { | ||
var _line$split = line.split(/\t/), | ||
_line$split2 = (0, _toArray2.default)(_line$split), | ||
tag = _line$split2[0], | ||
fields = (0, _slice.default)(_line$split2).call(_line$split2, 1); | ||
var parsedFields = (0, _map.default)(fields).call(fields, function (f) { | ||
var _f$split = f.split(':', 2), | ||
_f$split2 = (0, _slicedToArray2.default)(_f$split, 2), | ||
fieldTag = _f$split2[0], | ||
value = _f$split2[1]; | ||
return { | ||
tag: fieldTag, | ||
value: value | ||
}; | ||
var lines = text.split(/\r?\n/); | ||
var data = []; | ||
lines.forEach(function (line) { | ||
var _a = line.split(/\t/), tag = _a[0], fields = _a.slice(1); | ||
var parsedFields = fields.map(function (f) { | ||
var _a = f.split(':', 2), fieldTag = _a[0], value = _a[1]; | ||
return { tag: fieldTag, value: value }; | ||
}); | ||
if (tag) { | ||
data.push({ tag: tag.substr(1), data: parsedFields }); | ||
} | ||
}); | ||
if (tag) { | ||
data.push({ | ||
tag: tag.substr(1), | ||
data: parsedFields | ||
}); | ||
} | ||
}); | ||
return data; | ||
return data; | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9zYW0udHMiXSwibmFtZXMiOlsicGFyc2VIZWFkZXJUZXh0IiwidGV4dCIsImxpbmVzIiwic3BsaXQiLCJkYXRhIiwibGluZSIsInRhZyIsImZpZWxkcyIsInBhcnNlZEZpZWxkcyIsImYiLCJmaWVsZFRhZyIsInZhbHVlIiwicHVzaCIsInN1YnN0ciJdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUFPLFNBQVNBLGVBQVQsQ0FBeUJDLElBQXpCLEVBQXVDO0FBQzVDLE1BQU1DLEtBQUssR0FBR0QsSUFBSSxDQUFDRSxLQUFMLENBQVcsT0FBWCxDQUFkO0FBQ0EsTUFBTUMsSUFBK0QsR0FBRyxFQUF4RTtBQUNBLHdCQUFBRixLQUFLLE1BQUwsQ0FBQUEsS0FBSyxFQUFTLFVBQUFHLElBQUksRUFBSTtBQUFBLHNCQUNLQSxJQUFJLENBQUNGLEtBQUwsQ0FBVyxJQUFYLENBREw7QUFBQTtBQUFBLFFBQ2JHLEdBRGE7QUFBQSxRQUNMQyxNQURLOztBQUVwQixRQUFNQyxZQUFZLEdBQUcsa0JBQUFELE1BQU0sTUFBTixDQUFBQSxNQUFNLEVBQUssVUFBQUUsQ0FBQyxFQUFJO0FBQUEscUJBQ1RBLENBQUMsQ0FBQ04sS0FBRixDQ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BwYXJzZWRGaWVsZHMgfSlcbiAgICB9XG4gIH0pXG4gIHJldHVybiBkYXRhXG59XG4iXX0= | ||
exports.parseHeaderText = parseHeaderText; | ||
//# sourceMappingURL=sam.js.map |
@@ -1,2 +0,1 @@ | ||
/// <reference types="long" /> | ||
import Chunk from './chunk'; | ||
@@ -3,0 +2,0 @@ import VirtualOffset from './virtualOffset'; |
241
dist/util.js
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.timeout = timeout; | ||
exports.longToNumber = longToNumber; | ||
exports.checkAbortSignal = checkAbortSignal; | ||
exports.abortBreakPoint = abortBreakPoint; | ||
exports.canMergeBlocks = canMergeBlocks; | ||
exports.makeOpts = makeOpts; | ||
exports.optimizeChunks = optimizeChunks; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime-corejs3/regenerator")); | ||
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each")); | ||
var _sort = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/sort")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator")); | ||
var _minSafeInteger = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/min-safe-integer")); | ||
var _maxSafeInteger = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/number/max-safe-integer")); | ||
var _setTimeout2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set-timeout")); | ||
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise")); | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.optimizeChunks = exports.makeOpts = exports.canMergeBlocks = exports.abortBreakPoint = exports.checkAbortSignal = exports.longToNumber = exports.timeout = void 0; | ||
function timeout(ms) { | ||
return new _promise.default(function (resolve) { | ||
return (0, _setTimeout2.default)(resolve, ms); | ||
}); | ||
return new Promise(function (resolve) { return setTimeout(resolve, ms); }); | ||
} | ||
exports.timeout = timeout; | ||
function longToNumber(long) { | ||
if (long.greaterThan(_maxSafeInteger.default) || long.lessThan(_minSafeInteger.default)) { | ||
throw new Error('integer overflow'); | ||
} | ||
return long.toNumber(); | ||
if (long.greaterThan(Number.MAX_SAFE_INTEGER) || | ||
long.lessThan(Number.MIN_SAFE_INTEGER)) { | ||
throw new Error('integer overflow'); | ||
} | ||
return long.toNumber(); | ||
} | ||
exports.longToNumber = longToNumber; | ||
/** | ||
@@ -59,21 +63,20 @@ * Properly check if the given AbortSignal is aborted. | ||
*/ | ||
function checkAbortSignal(signal) { | ||
if (!signal) { | ||
return; | ||
} | ||
if (signal.aborted) { | ||
// console.log('bam aborted!') | ||
if (typeof DOMException !== 'undefined') { | ||
throw new DOMException('aborted', 'AbortError'); | ||
} else { | ||
var e = new Error('aborted'); //@ts-ignore | ||
e.code = 'ERR_ABORTED'; | ||
throw e; | ||
if (!signal) { | ||
return; | ||
} | ||
} | ||
if (signal.aborted) { | ||
// console.log('bam aborted!') | ||
if (typeof DOMException !== 'undefined') { | ||
throw new DOMException('aborted', 'AbortError'); | ||
} | ||
else { | ||
var e = new Error('aborted'); | ||
//@ts-ignore | ||
e.code = 'ERR_ABORTED'; | ||
throw e; | ||
} | ||
} | ||
} | ||
exports.checkAbortSignal = checkAbortSignal; | ||
/** | ||
@@ -85,77 +88,63 @@ * Skips to the next tick, then runs `checkAbortSignal`. | ||
*/ | ||
function abortBreakPoint(_x) { | ||
return _abortBreakPoint.apply(this, arguments); | ||
function abortBreakPoint(signal) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, Promise.resolve()]; | ||
case 1: | ||
_a.sent(); | ||
checkAbortSignal(signal); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
function _abortBreakPoint() { | ||
_abortBreakPoint = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(signal) { | ||
return _regenerator.default.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_context.next = 2; | ||
return _promise.default.resolve(); | ||
case 2: | ||
checkAbortSignal(signal); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
return _abortBreakPoint.apply(this, arguments); | ||
} | ||
exports.abortBreakPoint = abortBreakPoint; | ||
function canMergeBlocks(chunk1, chunk2) { | ||
return chunk2.minv.blockPosition - chunk1.maxv.blockPosition < 65000 && chunk2.maxv.blockPosition - chunk1.minv.blockPosition < 5000000; | ||
return (chunk2.minv.blockPosition - chunk1.maxv.blockPosition < 65000 && | ||
chunk2.maxv.blockPosition - chunk1.minv.blockPosition < 5000000); | ||
} | ||
function makeOpts() { | ||
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
return 'aborted' in obj ? { | ||
signal: obj | ||
} : obj; | ||
exports.canMergeBlocks = canMergeBlocks; | ||
function makeOpts(obj) { | ||
if (obj === void 0) { obj = {}; } | ||
return 'aborted' in obj ? { signal: obj } : obj; | ||
} | ||
exports.makeOpts = makeOpts; | ||
function optimizeChunks(chunks, lowest) { | ||
var mergedChunks = []; | ||
var lastChunk = null; | ||
if (chunks.length === 0) { | ||
return chunks; | ||
} | ||
(0, _sort.default)(chunks).call(chunks, function (c0, c1) { | ||
var dif = c0.minv.blockPosition - c1.minv.blockPosition; | ||
if (dif !== 0) { | ||
return dif; | ||
} else { | ||
return c0.minv.dataPosition - c1.minv.dataPosition; | ||
var mergedChunks = []; | ||
var lastChunk = null; | ||
if (chunks.length === 0) { | ||
return chunks; | ||
} | ||
}); | ||
(0, _forEach.default)(chunks).call(chunks, function (chunk) { | ||
if (!lowest || chunk.maxv.compareTo(lowest) > 0) { | ||
if (lastChunk === null) { | ||
mergedChunks.push(chunk); | ||
lastChunk = chunk; | ||
} else { | ||
if (canMergeBlocks(lastChunk, chunk)) { | ||
if (chunk.maxv.compareTo(lastChunk.maxv) > 0) { | ||
lastChunk.maxv = chunk.maxv; | ||
} | ||
} else { | ||
mergedChunks.push(chunk); | ||
lastChunk = chunk; | ||
chunks.sort(function (c0, c1) { | ||
var dif = c0.minv.blockPosition - c1.minv.blockPosition; | ||
if (dif !== 0) { | ||
return dif; | ||
} | ||
} | ||
} | ||
}); | ||
return mergedChunks; | ||
else { | ||
return c0.minv.dataPosition - c1.minv.dataPosition; | ||
} | ||
}); | ||
chunks.forEach(function (chunk) { | ||
if (!lowest || chunk.maxv.compareTo(lowest) > 0) { | ||
if (lastChunk === null) { | ||
mergedChunks.push(chunk); | ||
lastChunk = chunk; | ||
} | ||
else { | ||
if (canMergeBlocks(lastChunk, chunk)) { | ||
if (chunk.maxv.compareTo(lastChunk.maxv) > 0) { | ||
lastChunk.maxv = chunk.maxv; | ||
} | ||
} | ||
else { | ||
mergedChunks.push(chunk); | ||
lastChunk = chunk; | ||
} | ||
} | ||
} | ||
}); | ||
return mergedChunks; | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy91dGlsLnRzIl0sIm5hbWVzIjpbInRpbWVvdXQiLCJtcyIsInJlc29sdmUiLCJsb25nVG9OdW1iZXIiLCJsb25nIiwiZ3JlYXRlclRoYW4iLCJsZXNzVGhhbiIsIkVycm9yIiwidG9OdW1iZXIiLCJjaGVja0Fib3J0U2lnbmFsIiwic2lnbmFsIiwiYWJvcnRlZCIsIkRPTUV4Y2VwdGlvbiIsImUiLCJjb2RlIiwiYWJvcnRCcmVha1BvaW50IiwiY2FuTWVyZ2VCbG9ja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| ||
exports.optimizeChunks = optimizeChunks; | ||
//# sourceMappingURL=util.js.map |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault"); | ||
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property"); | ||
_Object$defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.fromBytes = fromBytes; | ||
exports.default = void 0; | ||
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat")); | ||
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck")); | ||
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty")); | ||
var VirtualOffset = /*#__PURE__*/function () { | ||
function VirtualOffset(blockPosition, dataPosition) { | ||
(0, _classCallCheck2.default)(this, VirtualOffset); | ||
(0, _defineProperty2.default)(this, "blockPosition", void 0); | ||
(0, _defineProperty2.default)(this, "dataPosition", void 0); | ||
this.blockPosition = blockPosition; // < offset of the compressed data block | ||
this.dataPosition = dataPosition; // < offset into the uncompressed data | ||
} | ||
(0, _createClass2.default)(VirtualOffset, [{ | ||
key: "toString", | ||
value: function toString() { | ||
var _context; | ||
return (0, _concat.default)(_context = "".concat(this.blockPosition, ":")).call(_context, this.dataPosition); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fromBytes = void 0; | ||
var VirtualOffset = /** @class */ (function () { | ||
function VirtualOffset(blockPosition, dataPosition) { | ||
this.blockPosition = blockPosition; // < offset of the compressed data block | ||
this.dataPosition = dataPosition; // < offset into the uncompressed data | ||
} | ||
}, { | ||
key: "compareTo", | ||
value: function compareTo(b) { | ||
return this.blockPosition - b.blockPosition || this.dataPosition - b.dataPosition; | ||
} | ||
}], [{ | ||
key: "min", | ||
value: function min() { | ||
var min; | ||
var i = 0; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
for (; !min; i += 1) { | ||
min = args[i]; | ||
} | ||
for (; i < args.length; i += 1) { | ||
if (min.compareTo(args[i]) > 0) { | ||
min = args[i]; | ||
VirtualOffset.prototype.toString = function () { | ||
return "".concat(this.blockPosition, ":").concat(this.dataPosition); | ||
}; | ||
VirtualOffset.prototype.compareTo = function (b) { | ||
return (this.blockPosition - b.blockPosition || this.dataPosition - b.dataPosition); | ||
}; | ||
VirtualOffset.min = function () { | ||
var args = []; | ||
for (var _i = 0; _i < arguments.length; _i++) { | ||
args[_i] = arguments[_i]; | ||
} | ||
} | ||
return min; | ||
var min; | ||
var i = 0; | ||
for (; !min; i += 1) { | ||
min = args[i]; | ||
} | ||
for (; i < args.length; i += 1) { | ||
if (min.compareTo(args[i]) > 0) { | ||
min = args[i]; | ||
} | ||
} | ||
return min; | ||
}; | ||
return VirtualOffset; | ||
}()); | ||
exports.default = VirtualOffset; | ||
function fromBytes(bytes, offset, bigendian) { | ||
if (offset === void 0) { offset = 0; } | ||
if (bigendian === void 0) { bigendian = false; } | ||
if (bigendian) { | ||
throw new Error('big-endian virtual file offsets not implemented'); | ||
} | ||
}]); | ||
return VirtualOffset; | ||
}(); | ||
exports.default = VirtualOffset; | ||
function fromBytes(bytes) { | ||
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0; | ||
var bigendian = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; | ||
if (bigendian) { | ||
throw new Error('big-endian virtual file offsets not implemented'); | ||
} | ||
return new VirtualOffset(bytes[offset + 7] * 0x10000000000 + bytes[offset + 6] * 0x100000000 + bytes[offset + 5] * 0x1000000 + bytes[offset + 4] * 0x10000 + bytes[offset + 3] * 0x100 + bytes[offset + 2], bytes[offset + 1] << 8 | bytes[offset]); | ||
return new VirtualOffset(bytes[offset + 7] * 0x10000000000 + | ||
bytes[offset + 6] * 0x100000000 + | ||
bytes[offset + 5] * 0x1000000 + | ||
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lVG8oYXJnc1tpXSkgPiAwKSB7XG4gICAgICAgIG1pbiA9IGFyZ3NbaV1cbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIG1pblxuICB9XG59XG5leHBvcnQgZnVuY3Rpb24gZnJvbUJ5dGVzKGJ5dGVzOiBCdWZmZXIsIG9mZnNldCA9IDAsIGJpZ2VuZGlhbiA9IGZhbHNlKSB7XG4gIGlmIChiaWdlbmRpYW4pIHtcbiAgICB0aHJvdyBuZXcgRXJyb3IoJ2JpZy1lbmRpYW4gdmlydHVhbCBmaWxlIG9mZnNldHMgbm90IGltcGxlbWVudGVkJylcbiAgfVxuXG4gIHJldHVybiBuZXcgVmlydHVhbE9mZnNldChcbiAgICBieXRlc1tvZmZzZXQgKyA3XSAqIDB4MTAwMDAwMDAwMDAgK1xuICAgICAgYnl0ZXNbb2Zmc2V0ICsgNl0gKiAweDEwMDAwMDAwMCArXG4gICAgICBieXRlc1tvZmZzZXQgKyA1XSAqIDB4MTAwMDAwMCArXG4gICAgICBieXRlc1tvZmZzZXQgKyA0XSAqIDB4MTAwMDAgK1xuICAgICAgYnl0ZXNbb2Zmc2V0ICsgM10gKiAweDEwMCArXG4gICAgICBieXRlc1tvZmZzZXQgKyAyXSxcbiAgICAoYnl0ZXNbb2Zmc2V0ICsgMV0gPDwgOCkgfCBieXRlc1tvZmZzZXRdLFxuICApXG59XG4iXX0= | ||
exports.fromBytes = fromBytes; | ||
//# sourceMappingURL=virtualOffset.js.map |
{ | ||
"name": "@gmod/bam", | ||
"version": "1.1.8", | ||
"version": "1.1.9", | ||
"description": "Parser for BAM and BAM index (bai) files", | ||
@@ -8,2 +8,3 @@ "license": "MIT", | ||
"main": "dist/index.js", | ||
"module": "esm/index.js", | ||
"author": { | ||
@@ -18,3 +19,4 @@ "name": "Colin Diesh", | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"esm" | ||
], | ||
@@ -25,7 +27,7 @@ "scripts": { | ||
"lint": "eslint --report-unused-disable-directives --max-warnings 0 --ext .js,.ts src test", | ||
"clean": "rimraf dist", | ||
"clean": "rimraf dist esm", | ||
"build:esm": "tsc --target es2018 --outDir esm", | ||
"build:es5": "tsc --target es5 --outDir dist", | ||
"build": "npm run build:esm && npm run build:es5", | ||
"prebuild": "npm run clean && npm run lint", | ||
"build:types": "tsc --emitDeclarationOnly", | ||
"build:js": "babel src --out-dir dist --extensions \".ts,.tsx\" --source-maps inline", | ||
"build": "npm run build:types && npm run build:js", | ||
"preversion": "npm run lint && npm test && npm run build", | ||
@@ -35,5 +37,2 @@ "version": "standard-changelog && git add CHANGELOG.md", | ||
}, | ||
"jest": { | ||
"testEnvironment": "node" | ||
}, | ||
"keywords": [ | ||
@@ -46,3 +45,2 @@ "bionode", | ||
"dependencies": { | ||
"@babel/runtime-corejs3": "^7.5.5", | ||
"@gmod/bgzf-filehandle": "^1.3.3", | ||
@@ -60,26 +58,20 @@ "abortable-promise-cache": "^1.4.0", | ||
"devDependencies": { | ||
"@babel/cli": "^7.2.3", | ||
"@babel/core": "^7.3.3", | ||
"@babel/plugin-proposal-class-properties": "^7.5.5", | ||
"@babel/plugin-transform-runtime": "^7.2.0", | ||
"@babel/preset-env": "^7.3.1", | ||
"@babel/preset-typescript": "^7.6.0", | ||
"@types/buffer-crc32": "^0.2.0", | ||
"@types/jest": "^27.0.2", | ||
"@types/long": "^4.0.0", | ||
"@types/node": "^12.7.8", | ||
"@types/range-parser": "^1.2.3", | ||
"@typescript-eslint/eslint-plugin": "^2.3.1", | ||
"@typescript-eslint/parser": "^2.3.1", | ||
"babel-jest": "^24.1.0", | ||
"eslint": "^5.12.0", | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-plugin-import": "^2.10.0", | ||
"eslint-plugin-jest": "^22.17.0", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"jest": "^24.3.1", | ||
"prettier": "^1.11.1", | ||
"rimraf": "^2.6.2", | ||
"@typescript-eslint/eslint-plugin": "^5.7.0", | ||
"@typescript-eslint/parser": "^5.7.0", | ||
"eslint": "^7.0.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.25.3", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"jest": "^27.3.1", | ||
"prettier": "^2.4.1", | ||
"rimraf": "^3.0.2", | ||
"standard-changelog": "^1.0.0", | ||
"typescript": "^3.6.3" | ||
"ts-jest": "^27.0.7", | ||
"typescript": "^4.4.4" | ||
}, | ||
@@ -86,0 +78,0 @@ "publishConfig": { |
@@ -1,5 +0,4 @@ | ||
[![Generated with nod](https://img.shields.io/badge/generator-nod-2196F3.svg?style=flat-square)](https://github.com/diegohaz/nod) | ||
[![NPM version](https://img.shields.io/npm/v/@gmod/bam.svg?style=flat-square)](https://npmjs.org/package/@gmod/bam) | ||
[![Build Status](https://img.shields.io/travis/GMOD/bam-js/master.svg?style=flat-square)](https://travis-ci.org/GMOD/bam-js) | ||
[![Coverage Status](https://img.shields.io/codecov/c/github/GMOD/bam-js/master.svg?style=flat-square)](https://codecov.io/gh/GMOD/bam-js/branch/master) | ||
[![Build Status](https://img.shields.io/github/workflow/status/GMOD/bam-js/Push/master?logo=github&style=flat-query)](https://github.com/GMOD/bam-js/actions?query=branch%3Amaster+workflow%3APush+) | ||
@@ -50,3 +49,3 @@ ## Install | ||
- bamPath/baiUrl/bamFilehandle - a string file path to a local file or a class object with a read method | ||
- bamPath/bamUrl/bamFilehandle - a string file path to a local file or a class object with a read method | ||
- csiPath/csiUrl/csiFilehandle - a CSI index for the BAM file, required for long chromosomes greater than 2^29 in length | ||
@@ -53,0 +52,0 @@ - baiPath/baiUrl/baiFilehandle - a BAI index for the BAM file |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
351714
10
18
82
5098
149
7
- Removed@babel/runtime-corejs3@^7.5.5
- Removed@babel/runtime-corejs3@7.26.0(transitive)
- Removedcore-js-pure@3.39.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)