@gmod/cram 1.6.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/craiIndex.d.ts +19 -12
- package/dist/craiIndex.js +63 -123
- package/dist/craiIndex.js.map +1 -1
- package/dist/cram-bundle.js +2 -17
- package/dist/cram-bundle.js.LICENSE.txt +17 -0
- package/dist/cramFile/codecs/_base.d.ts +26 -5
- package/dist/cramFile/codecs/_base.js +3 -39
- package/dist/cramFile/codecs/_base.js.map +1 -1
- package/dist/cramFile/codecs/beta.d.ts +7 -3
- package/dist/cramFile/codecs/beta.js +13 -31
- package/dist/cramFile/codecs/beta.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayLength.d.ts +13 -7
- package/dist/cramFile/codecs/byteArrayLength.js +22 -41
- package/dist/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayStop.d.ts +9 -5
- package/dist/cramFile/codecs/byteArrayStop.js +25 -46
- package/dist/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/dist/cramFile/codecs/dataSeriesTypes.d.ts +4 -0
- package/dist/cramFile/codecs/dataSeriesTypes.js +3 -0
- package/dist/cramFile/codecs/dataSeriesTypes.js.map +1 -0
- package/dist/cramFile/codecs/external.d.ts +10 -6
- package/dist/cramFile/codecs/external.js +26 -44
- package/dist/cramFile/codecs/external.js.map +1 -1
- package/dist/cramFile/codecs/gamma.d.ts +7 -3
- package/dist/cramFile/codecs/gamma.js +16 -34
- package/dist/cramFile/codecs/gamma.js.map +1 -1
- package/dist/cramFile/codecs/getBits.d.ts +7 -0
- package/dist/cramFile/codecs/getBits.js +26 -0
- package/dist/cramFile/codecs/getBits.js.map +1 -0
- package/dist/cramFile/codecs/huffman.d.ts +17 -13
- package/dist/cramFile/codecs/huffman.js +76 -85
- package/dist/cramFile/codecs/huffman.js.map +1 -1
- package/dist/cramFile/codecs/index.d.ts +4 -2
- package/dist/cramFile/codecs/index.js +12 -13
- package/dist/cramFile/codecs/index.js.map +1 -1
- package/dist/cramFile/codecs/subexp.d.ts +7 -3
- package/dist/cramFile/codecs/subexp.js +19 -36
- package/dist/cramFile/codecs/subexp.js.map +1 -1
- package/dist/cramFile/constants.d.ts +35 -35
- package/dist/cramFile/constants.js +1 -1
- package/dist/cramFile/constants.js.map +1 -1
- package/dist/cramFile/container/compressionScheme.d.ts +57 -11
- package/dist/cramFile/container/compressionScheme.js +37 -32
- package/dist/cramFile/container/compressionScheme.js.map +1 -1
- package/dist/cramFile/container/index.d.ts +23 -9
- package/dist/cramFile/container/index.js +74 -144
- package/dist/cramFile/container/index.js.map +1 -1
- package/dist/cramFile/encoding.d.ts +78 -0
- package/dist/cramFile/encoding.js +3 -0
- package/dist/cramFile/encoding.js.map +1 -0
- package/dist/cramFile/file.d.ts +91 -41
- package/dist/cramFile/file.js +234 -368
- package/dist/cramFile/file.js.map +1 -1
- package/dist/cramFile/filehandle.d.ts +2 -0
- package/dist/cramFile/filehandle.js +3 -0
- package/dist/cramFile/filehandle.js.map +1 -0
- package/dist/cramFile/index.d.ts +1 -1
- package/dist/cramFile/index.js +1 -1
- package/dist/cramFile/index.js.map +1 -1
- package/dist/cramFile/record.d.ts +61 -17
- package/dist/cramFile/record.js +153 -77
- package/dist/cramFile/record.js.map +1 -1
- package/dist/cramFile/sectionParsers.d.ts +99 -8
- package/dist/cramFile/sectionParsers.js +70 -80
- package/dist/cramFile/sectionParsers.js.map +1 -1
- package/dist/cramFile/slice/decodeRecord.d.ts +30 -2
- package/dist/cramFile/slice/decodeRecord.js +148 -118
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/cramFile/slice/index.d.ts +21 -14
- package/dist/cramFile/slice/index.js +286 -381
- package/dist/cramFile/slice/index.js.map +1 -1
- package/dist/cramFile/util.d.ts +11 -5
- package/dist/cramFile/util.js +19 -97
- package/dist/cramFile/util.js.map +1 -1
- package/dist/errors.d.ts +5 -10
- package/dist/errors.js +11 -62
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/indexedCramFile.d.ts +37 -12
- package/dist/indexedCramFile.js +114 -154
- package/dist/indexedCramFile.js.map +1 -1
- package/dist/io/index.d.ts +5 -5
- package/dist/io/index.js +9 -9
- package/dist/io/index.js.map +1 -1
- package/dist/rans/constants.js +3 -3
- package/dist/rans/constants.js.map +1 -1
- package/dist/rans/d04.js +15 -15
- package/dist/rans/d04.js.map +1 -1
- package/dist/rans/d14.js +21 -21
- package/dist/rans/d14.js.map +1 -1
- package/dist/rans/decoding.js +27 -30
- package/dist/rans/decoding.js.map +1 -1
- package/dist/rans/frequencies.js +11 -11
- package/dist/rans/frequencies.js.map +1 -1
- package/dist/rans/index.js +46 -49
- package/dist/rans/index.js.map +1 -1
- package/dist/sam.d.ts +8 -1
- package/dist/sam.js +7 -7
- package/dist/sam.js.map +1 -1
- package/dist/typescript.d.ts +3 -0
- package/dist/typescript.js +11 -0
- package/dist/typescript.js.map +1 -0
- package/dist/unzip-pako.js +1 -1
- package/dist/unzip-pako.js.map +1 -1
- package/dist/unzip.js +1 -1
- package/dist/unzip.js.map +1 -1
- package/errors.js +11 -62
- package/esm/craiIndex.d.ts +19 -12
- package/esm/craiIndex.js +8 -24
- package/esm/craiIndex.js.map +1 -1
- package/esm/cramFile/codecs/_base.d.ts +26 -5
- package/esm/cramFile/codecs/_base.js +1 -35
- package/esm/cramFile/codecs/_base.js.map +1 -1
- package/esm/cramFile/codecs/beta.d.ts +7 -3
- package/esm/cramFile/codecs/beta.js +4 -3
- package/esm/cramFile/codecs/beta.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayLength.d.ts +13 -7
- package/esm/cramFile/codecs/byteArrayLength.js +1 -1
- package/esm/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayStop.d.ts +9 -5
- package/esm/cramFile/codecs/byteArrayStop.js +7 -9
- package/esm/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/esm/cramFile/codecs/dataSeriesTypes.d.ts +4 -0
- package/esm/cramFile/codecs/dataSeriesTypes.js +2 -0
- package/esm/cramFile/codecs/dataSeriesTypes.js.map +1 -0
- package/esm/cramFile/codecs/external.d.ts +10 -6
- package/esm/cramFile/codecs/external.js +4 -3
- package/esm/cramFile/codecs/external.js.map +1 -1
- package/esm/cramFile/codecs/gamma.d.ts +7 -3
- package/esm/cramFile/codecs/gamma.js +5 -4
- package/esm/cramFile/codecs/gamma.js.map +1 -1
- package/esm/cramFile/codecs/getBits.d.ts +7 -0
- package/esm/cramFile/codecs/getBits.js +21 -0
- package/esm/cramFile/codecs/getBits.js.map +1 -0
- package/esm/cramFile/codecs/huffman.d.ts +17 -13
- package/esm/cramFile/codecs/huffman.js +22 -9
- package/esm/cramFile/codecs/huffman.js.map +1 -1
- package/esm/cramFile/codecs/index.d.ts +4 -2
- package/esm/cramFile/codecs/index.js +1 -1
- package/esm/cramFile/codecs/index.js.map +1 -1
- package/esm/cramFile/codecs/subexp.d.ts +7 -3
- package/esm/cramFile/codecs/subexp.js +7 -5
- package/esm/cramFile/codecs/subexp.js.map +1 -1
- package/esm/cramFile/constants.d.ts +35 -35
- package/esm/cramFile/constants.js.map +1 -1
- package/esm/cramFile/container/compressionScheme.d.ts +57 -11
- package/esm/cramFile/container/compressionScheme.js +15 -8
- package/esm/cramFile/container/compressionScheme.js.map +1 -1
- package/esm/cramFile/container/index.d.ts +23 -9
- package/esm/cramFile/container/index.js +11 -9
- package/esm/cramFile/container/index.js.map +1 -1
- package/esm/cramFile/encoding.d.ts +78 -0
- package/esm/cramFile/encoding.js +2 -0
- package/esm/cramFile/encoding.js.map +1 -0
- package/esm/cramFile/file.d.ts +91 -41
- package/esm/cramFile/file.js +59 -47
- package/esm/cramFile/file.js.map +1 -1
- package/esm/cramFile/filehandle.d.ts +2 -0
- package/esm/cramFile/filehandle.js +2 -0
- package/esm/cramFile/filehandle.js.map +1 -0
- package/esm/cramFile/index.d.ts +1 -1
- package/esm/cramFile/index.js.map +1 -1
- package/esm/cramFile/record.d.ts +61 -17
- package/esm/cramFile/record.js +83 -5
- package/esm/cramFile/record.js.map +1 -1
- package/esm/cramFile/sectionParsers.d.ts +99 -8
- package/esm/cramFile/sectionParsers.js +7 -17
- package/esm/cramFile/sectionParsers.js.map +1 -1
- package/esm/cramFile/slice/decodeRecord.d.ts +30 -2
- package/esm/cramFile/slice/decodeRecord.js +102 -70
- package/esm/cramFile/slice/decodeRecord.js.map +1 -1
- package/esm/cramFile/slice/index.d.ts +21 -14
- package/esm/cramFile/slice/index.js +77 -38
- package/esm/cramFile/slice/index.js.map +1 -1
- package/esm/cramFile/util.d.ts +11 -5
- package/esm/cramFile/util.js +11 -82
- package/esm/cramFile/util.js.map +1 -1
- package/esm/errors.d.ts +5 -10
- package/esm/errors.js +0 -5
- package/esm/errors.js.map +1 -1
- package/esm/index.d.ts +3 -3
- package/esm/index.js.map +1 -1
- package/esm/indexedCramFile.d.ts +37 -12
- package/esm/indexedCramFile.js +19 -8
- package/esm/indexedCramFile.js.map +1 -1
- package/esm/io/index.d.ts +5 -5
- package/esm/io/index.js +3 -3
- package/esm/io/index.js.map +1 -1
- package/esm/sam.d.ts +8 -1
- package/esm/sam.js.map +1 -1
- package/esm/typescript.d.ts +3 -0
- package/esm/typescript.js +7 -0
- package/esm/typescript.js.map +1 -0
- package/package.json +18 -11
- package/src/{craiIndex.js → craiIndex.ts} +37 -31
- package/src/cramFile/codecs/_base.ts +45 -0
- package/src/cramFile/codecs/beta.ts +34 -0
- package/src/cramFile/codecs/{byteArrayLength.js → byteArrayLength.ts} +27 -5
- package/src/cramFile/codecs/{byteArrayStop.js → byteArrayStop.ts} +25 -12
- package/src/cramFile/codecs/dataSeriesTypes.ts +39 -0
- package/src/cramFile/codecs/{external.js → external.ts} +28 -12
- package/src/cramFile/codecs/gamma.ts +42 -0
- package/src/cramFile/codecs/getBits.ts +28 -0
- package/src/cramFile/codecs/{huffman.js → huffman.ts} +48 -15
- package/src/cramFile/codecs/{index.js → index.ts} +9 -3
- package/src/cramFile/codecs/subexp.ts +45 -0
- package/src/cramFile/{constants.js → constants.ts} +0 -0
- package/src/cramFile/container/{compressionScheme.js → compressionScheme.ts} +50 -18
- package/src/cramFile/container/{index.js → index.ts} +13 -13
- package/src/cramFile/encoding.ts +98 -0
- package/src/cramFile/{file.js → file.ts} +136 -62
- package/src/cramFile/filehandle.ts +3 -0
- package/src/cramFile/{index.js → index.ts} +0 -0
- package/src/cramFile/{record.js → record.ts} +185 -14
- package/src/cramFile/{sectionParsers.js → sectionParsers.ts} +148 -20
- package/src/cramFile/slice/{decodeRecord.js → decodeRecord.ts} +158 -105
- package/src/cramFile/slice/{index.js → index.ts} +138 -63
- package/src/cramFile/{util.js → util.ts} +28 -17
- package/src/{errors.js → errors.ts} +0 -5
- package/src/{index.js → index.ts} +0 -0
- package/src/{indexedCramFile.js → indexedCramFile.ts} +79 -19
- package/src/io/{index.js → index.ts} +10 -5
- package/src/{sam.js → sam.ts} +7 -2
- package/src/typescript.ts +17 -0
- package/src/typings/binary-parser.d.ts +44 -0
- package/src/typings/bzip2.d.ts +7 -0
- package/src/typings/htscodecs.d.ts +6 -0
- package/dist/io/bufferCache.d.ts +0 -12
- package/dist/io/bufferCache.js +0 -112
- package/dist/io/bufferCache.js.map +0 -1
- package/dist/io/localFile.d.ts +0 -10
- package/dist/io/localFile.js +0 -108
- package/dist/io/localFile.js.map +0 -1
- package/dist/io/remoteFile.d.ts +0 -16
- package/dist/io/remoteFile.js +0 -143
- package/dist/io/remoteFile.js.map +0 -1
- package/esm/io/bufferCache.d.ts +0 -12
- package/esm/io/bufferCache.js +0 -54
- package/esm/io/bufferCache.js.map +0 -1
- package/esm/io/localFile.d.ts +0 -10
- package/esm/io/localFile.js +0 -31
- package/esm/io/localFile.js.map +0 -1
- package/esm/io/remoteFile.d.ts +0 -16
- package/esm/io/remoteFile.js +0 -64
- package/esm/io/remoteFile.js.map +0 -1
- package/src/cramFile/codecs/_base.js +0 -49
- package/src/cramFile/codecs/beta.js +0 -23
- package/src/cramFile/codecs/gamma.js +0 -30
- package/src/cramFile/codecs/subexp.js +0 -32
- package/src/io/bufferCache.js +0 -66
- package/src/io/localFile.js +0 -35
- package/src/io/remoteFile.js +0 -71
package/dist/cramFile/file.js
CHANGED
|
@@ -8,52 +8,25 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
15
|
+
const unzip_1 = require("../unzip");
|
|
16
|
+
const buffer_crc32_1 = __importDefault(require("buffer-crc32"));
|
|
17
|
+
const quick_lru_1 = __importDefault(require("quick-lru"));
|
|
18
|
+
const errors_1 = require("../errors");
|
|
19
|
+
const rans_1 = __importDefault(require("../rans"));
|
|
20
|
+
const sectionParsers_1 = require("./sectionParsers");
|
|
21
|
+
const htscodecs_1 = __importDefault(require("@jkbonfield/htscodecs"));
|
|
22
|
+
const container_1 = __importDefault(require("./container"));
|
|
23
|
+
const io_1 = require("../io");
|
|
24
|
+
const util_1 = require("./util");
|
|
25
|
+
const sam_1 = require("../sam");
|
|
53
26
|
//source:https://abdulapopoola.com/2019/01/20/check-endianness-with-javascript/
|
|
54
27
|
function getEndianness() {
|
|
55
|
-
|
|
56
|
-
|
|
28
|
+
const uInt32 = new Uint32Array([0x11223344]);
|
|
29
|
+
const uInt8 = new Uint8Array(uInt32.buffer);
|
|
57
30
|
if (uInt8[0] === 0x44) {
|
|
58
31
|
return 0; //little-endian
|
|
59
32
|
}
|
|
@@ -64,26 +37,15 @@ function getEndianness() {
|
|
|
64
37
|
return 2; //mixed-endian?
|
|
65
38
|
}
|
|
66
39
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
* @param {object} [args.filehandle] - a filehandle that implements the stat() and
|
|
71
|
-
* read() methods of the Node filehandle API https://nodejs.org/api/fs.html#fs_class_filehandle
|
|
72
|
-
* @param {object} [args.path] - path to the cram file
|
|
73
|
-
* @param {object} [args.url] - url for the cram file. also supports file:// urls for local files
|
|
74
|
-
* @param {function} [args.seqFetch] - a function with signature
|
|
75
|
-
* `(seqId, startCoordinate, endCoordinate)` that returns a promise for a string of sequence bases
|
|
76
|
-
* @param {number} [args.cacheSize] optional maximum number of CRAM records to cache. default 20,000
|
|
77
|
-
* @param {boolean} [args.checkSequenceMD5] - default true. if false, disables verifying the MD5
|
|
78
|
-
* checksum of the reference sequence underlying a slice. In some applications, this check can cause an inconvenient amount (many megabases) of sequences to be fetched.
|
|
79
|
-
*/
|
|
80
|
-
function CramFile(args) {
|
|
40
|
+
class CramFile {
|
|
41
|
+
constructor(args) {
|
|
42
|
+
var _a;
|
|
81
43
|
this.file = (0, io_1.open)(args.url, args.path, args.filehandle);
|
|
82
44
|
this.validateChecksums = true;
|
|
83
45
|
this.fetchReferenceSequenceCallback = args.seqFetch;
|
|
84
46
|
this.options = {
|
|
85
|
-
checkSequenceMD5: args.checkSequenceMD5
|
|
86
|
-
cacheSize: args.cacheSize !==
|
|
47
|
+
checkSequenceMD5: args.checkSequenceMD5,
|
|
48
|
+
cacheSize: (_a = args.cacheSize) !== null && _a !== void 0 ? _a : 20000,
|
|
87
49
|
};
|
|
88
50
|
// cache of features in a slice, keyed by the
|
|
89
51
|
// slice offset. caches all of the features in a slice, or none.
|
|
@@ -96,292 +58,210 @@ var CramFile = /** @class */ (function () {
|
|
|
96
58
|
throw new Error('Detected big-endian machine, may be unable to run');
|
|
97
59
|
}
|
|
98
60
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
61
|
+
// toString() {
|
|
62
|
+
// if (this.file.filename) {
|
|
63
|
+
// return this.file.filename
|
|
64
|
+
// }
|
|
65
|
+
// if (this.file.url) {
|
|
66
|
+
// return this.file.url
|
|
67
|
+
// }
|
|
68
|
+
//
|
|
69
|
+
// return '(cram file)'
|
|
70
|
+
// }
|
|
108
71
|
// can just read this object like a filehandle
|
|
109
|
-
|
|
72
|
+
read(buffer, offset, length, position) {
|
|
110
73
|
return this.file.read(buffer, offset, length, position);
|
|
111
|
-
}
|
|
74
|
+
}
|
|
112
75
|
// can just stat this object like a filehandle
|
|
113
|
-
|
|
76
|
+
stat() {
|
|
114
77
|
return this.file.stat();
|
|
115
|
-
}
|
|
78
|
+
}
|
|
116
79
|
// memoized
|
|
117
|
-
|
|
118
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
definition = sectionParsers_1.cramFileDefinition.parser.parse(headbytes).result;
|
|
128
|
-
if (definition.majorVersion !== 2 && definition.majorVersion !== 3) {
|
|
129
|
-
throw new errors_1.CramUnimplementedError("CRAM version ".concat(definition.majorVersion, " not supported"));
|
|
130
|
-
}
|
|
131
|
-
return [2 /*return*/, definition];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
80
|
+
getDefinition() {
|
|
81
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
82
|
+
const headbytes = Buffer.allocUnsafe(sectionParsers_1.cramFileDefinition.maxLength);
|
|
83
|
+
yield this.file.read(headbytes, 0, sectionParsers_1.cramFileDefinition.maxLength, 0);
|
|
84
|
+
const definition = sectionParsers_1.cramFileDefinition.parser.parse(headbytes)
|
|
85
|
+
.result;
|
|
86
|
+
if (definition.majorVersion !== 2 && definition.majorVersion !== 3) {
|
|
87
|
+
throw new errors_1.CramUnimplementedError(`CRAM version ${definition.majorVersion} not supported`);
|
|
88
|
+
}
|
|
89
|
+
return definition;
|
|
134
90
|
});
|
|
135
|
-
}
|
|
91
|
+
}
|
|
136
92
|
// memoize
|
|
137
|
-
|
|
138
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return [2 /*return*/, (0, sam_1.parseHeaderText)(text)];
|
|
158
|
-
}
|
|
159
|
-
});
|
|
93
|
+
getSamHeader() {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
const firstContainer = yield this.getContainerById(0);
|
|
96
|
+
if (!firstContainer) {
|
|
97
|
+
throw new errors_1.CramMalformedError('file contains no containers');
|
|
98
|
+
}
|
|
99
|
+
const firstBlock = yield firstContainer.getFirstBlock();
|
|
100
|
+
if (firstBlock === undefined) {
|
|
101
|
+
return (0, sam_1.parseHeaderText)('');
|
|
102
|
+
}
|
|
103
|
+
const content = firstBlock.content;
|
|
104
|
+
// find the end of the trailing zeros in the header text
|
|
105
|
+
const headerLength = content.readInt32LE(0);
|
|
106
|
+
const textStart = 4;
|
|
107
|
+
// let textEnd = content.length - 1
|
|
108
|
+
// while (textEnd >= textStart && !content[textEnd]) textEnd -= 1
|
|
109
|
+
// trim off the trailing zeros
|
|
110
|
+
const text = content.toString('utf8', textStart, textStart + headerLength);
|
|
111
|
+
this.header = text;
|
|
112
|
+
return (0, sam_1.parseHeaderText)(text);
|
|
160
113
|
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
case 0: return [4 /*yield*/, this.getSamHeader()];
|
|
167
|
-
case 1:
|
|
168
|
-
_a.sent();
|
|
169
|
-
return [2 /*return*/, this.header];
|
|
170
|
-
}
|
|
171
|
-
});
|
|
114
|
+
}
|
|
115
|
+
getHeaderText() {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
yield this.getSamHeader();
|
|
118
|
+
return this.header;
|
|
172
119
|
});
|
|
173
|
-
}
|
|
120
|
+
}
|
|
174
121
|
// memoize
|
|
175
|
-
|
|
176
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
-
|
|
178
|
-
return
|
|
179
|
-
switch (_a.label) {
|
|
180
|
-
case 0: return [4 /*yield*/, this.getDefinition()];
|
|
181
|
-
case 1:
|
|
182
|
-
majorVersion = (_a.sent()).majorVersion;
|
|
183
|
-
return [2 /*return*/, (0, sectionParsers_1.getSectionParsers)(majorVersion)];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
122
|
+
getSectionParsers() {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
+
const { majorVersion } = yield this.getDefinition();
|
|
125
|
+
return (0, sectionParsers_1.getSectionParsers)(majorVersion);
|
|
186
126
|
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
127
|
+
}
|
|
128
|
+
getContainerById(containerNumber) {
|
|
129
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
130
|
+
const sectionParsers = yield this.getSectionParsers();
|
|
131
|
+
let position = sectionParsers.cramFileDefinition.maxLength;
|
|
132
|
+
const { size: fileSize } = yield this.file.stat();
|
|
133
|
+
const { cramContainerHeader1 } = sectionParsers;
|
|
134
|
+
// skip with a series of reads to the proper container
|
|
135
|
+
let currentContainer;
|
|
136
|
+
for (let i = 0; i <= containerNumber; i += 1) {
|
|
137
|
+
// if we are about to go off the end of the file
|
|
138
|
+
// and have not found that container, it does not exist
|
|
139
|
+
if (position + cramContainerHeader1.maxLength + 8 >= fileSize) {
|
|
140
|
+
return undefined;
|
|
141
|
+
}
|
|
142
|
+
currentContainer = this.getContainerAtPosition(position);
|
|
143
|
+
const currentHeader = yield currentContainer.getHeader();
|
|
144
|
+
if (!currentHeader) {
|
|
145
|
+
throw new errors_1.CramMalformedError(`container ${containerNumber} not found in file`);
|
|
146
|
+
}
|
|
147
|
+
// if this is the first container, read all the blocks in the
|
|
148
|
+
// container to determine its length, because we cannot trust
|
|
149
|
+
// the container header's given length due to a bug somewhere
|
|
150
|
+
// in htslib
|
|
151
|
+
if (i === 0) {
|
|
152
|
+
position = currentHeader._endPosition;
|
|
153
|
+
for (let j = 0; j < currentHeader.numBlocks; j += 1) {
|
|
154
|
+
const block = yield this.readBlock(position);
|
|
155
|
+
if (block === undefined) {
|
|
156
|
+
return undefined;
|
|
216
157
|
}
|
|
217
|
-
if (!(i === 0)) return [3 /*break*/, 9];
|
|
218
|
-
position = currentHeader._endPosition;
|
|
219
|
-
j = 0;
|
|
220
|
-
_a.label = 5;
|
|
221
|
-
case 5:
|
|
222
|
-
if (!(j < currentHeader.numBlocks)) return [3 /*break*/, 8];
|
|
223
|
-
return [4 /*yield*/, this.readBlock(position)];
|
|
224
|
-
case 6:
|
|
225
|
-
block = _a.sent();
|
|
226
158
|
position = block._endPosition;
|
|
227
|
-
|
|
228
|
-
case 7:
|
|
229
|
-
j += 1;
|
|
230
|
-
return [3 /*break*/, 5];
|
|
231
|
-
case 8: return [3 /*break*/, 10];
|
|
232
|
-
case 9:
|
|
233
|
-
// otherwise, just traverse to the next container using the container's length
|
|
234
|
-
position += currentHeader._size + currentHeader.length;
|
|
235
|
-
_a.label = 10;
|
|
236
|
-
case 10:
|
|
237
|
-
i += 1;
|
|
238
|
-
return [3 /*break*/, 3];
|
|
239
|
-
case 11: return [2 /*return*/, currentContainer];
|
|
159
|
+
}
|
|
240
160
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
CramFile.prototype.checkCrc32 = function (position, length, recordedCrc32, description) {
|
|
245
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
-
var b, calculatedCrc32;
|
|
247
|
-
return __generator(this, function (_a) {
|
|
248
|
-
switch (_a.label) {
|
|
249
|
-
case 0:
|
|
250
|
-
b = Buffer.allocUnsafe(length);
|
|
251
|
-
return [4 /*yield*/, this.file.read(b, 0, length, position)];
|
|
252
|
-
case 1:
|
|
253
|
-
_a.sent();
|
|
254
|
-
calculatedCrc32 = buffer_crc32_1.default.unsigned(b);
|
|
255
|
-
if (calculatedCrc32 !== recordedCrc32) {
|
|
256
|
-
throw new errors_1.CramMalformedError("crc mismatch in ".concat(description, ": recorded CRC32 = ").concat(recordedCrc32, ", but calculated CRC32 = ").concat(calculatedCrc32));
|
|
257
|
-
}
|
|
258
|
-
return [2 /*return*/];
|
|
161
|
+
else {
|
|
162
|
+
// otherwise, just traverse to the next container using the container's length
|
|
163
|
+
position += currentHeader._size + currentHeader.length;
|
|
259
164
|
}
|
|
260
|
-
}
|
|
165
|
+
}
|
|
166
|
+
return currentContainer;
|
|
261
167
|
});
|
|
262
|
-
}
|
|
168
|
+
}
|
|
169
|
+
checkCrc32(position, length, recordedCrc32, description) {
|
|
170
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
171
|
+
const b = Buffer.allocUnsafe(length);
|
|
172
|
+
yield this.file.read(b, 0, length, position);
|
|
173
|
+
const calculatedCrc32 = buffer_crc32_1.default.unsigned(b);
|
|
174
|
+
if (calculatedCrc32 !== recordedCrc32) {
|
|
175
|
+
throw new errors_1.CramMalformedError(`crc mismatch in ${description}: recorded CRC32 = ${recordedCrc32}, but calculated CRC32 = ${calculatedCrc32}`);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
}
|
|
263
179
|
/**
|
|
264
180
|
* @returns {Promise[number]} the number of containers in the file
|
|
265
181
|
*/
|
|
266
|
-
|
|
267
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return [3 /*break*/, 11];
|
|
182
|
+
containerCount() {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
184
|
+
const sectionParsers = yield this.getSectionParsers();
|
|
185
|
+
const { size: fileSize } = yield this.file.stat();
|
|
186
|
+
const { cramContainerHeader1 } = sectionParsers;
|
|
187
|
+
let containerCount = 0;
|
|
188
|
+
let position = sectionParsers.cramFileDefinition.maxLength;
|
|
189
|
+
while (position + cramContainerHeader1.maxLength + 8 < fileSize) {
|
|
190
|
+
const currentHeader = yield this.getContainerAtPosition(position).getHeader();
|
|
191
|
+
if (!currentHeader) {
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
// if this is the first container, read all the blocks in the
|
|
195
|
+
// container, because we cannot trust the container
|
|
196
|
+
// header's given length due to a bug somewhere in htslib
|
|
197
|
+
if (containerCount === 0) {
|
|
198
|
+
position = currentHeader._endPosition;
|
|
199
|
+
for (let j = 0; j < currentHeader.numBlocks; j += 1) {
|
|
200
|
+
const block = yield this.readBlock(position);
|
|
201
|
+
if (block === undefined) {
|
|
202
|
+
return undefined;
|
|
288
203
|
}
|
|
289
|
-
if (!(containerCount === 0)) return [3 /*break*/, 9];
|
|
290
|
-
position = currentHeader._endPosition;
|
|
291
|
-
j = 0;
|
|
292
|
-
_a.label = 5;
|
|
293
|
-
case 5:
|
|
294
|
-
if (!(j < currentHeader.numBlocks)) return [3 /*break*/, 8];
|
|
295
|
-
return [4 /*yield*/, this.readBlock(position)];
|
|
296
|
-
case 6:
|
|
297
|
-
block = _a.sent();
|
|
298
204
|
position = block._endPosition;
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
case 9:
|
|
305
|
-
// otherwise, just traverse to the next container using the container's length
|
|
306
|
-
position += currentHeader._size + currentHeader.length;
|
|
307
|
-
_a.label = 10;
|
|
308
|
-
case 10:
|
|
309
|
-
containerCount += 1;
|
|
310
|
-
return [3 /*break*/, 3];
|
|
311
|
-
case 11: return [2 /*return*/, containerCount];
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
// otherwise, just traverse to the next container using the container's length
|
|
209
|
+
position += currentHeader._size + currentHeader.length;
|
|
312
210
|
}
|
|
313
|
-
|
|
211
|
+
containerCount += 1;
|
|
212
|
+
}
|
|
213
|
+
return containerCount;
|
|
314
214
|
});
|
|
315
|
-
}
|
|
316
|
-
|
|
215
|
+
}
|
|
216
|
+
getContainerAtPosition(position) {
|
|
317
217
|
return new container_1.default(this, position);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
fileSize = (_a.sent()).size;
|
|
331
|
-
if (position + cramBlockHeader.maxLength >= fileSize) {
|
|
332
|
-
return [2 /*return*/, undefined];
|
|
333
|
-
}
|
|
334
|
-
buffer = Buffer.allocUnsafe(cramBlockHeader.maxLength);
|
|
335
|
-
return [4 /*yield*/, this.file.read(buffer, 0, cramBlockHeader.maxLength, position)];
|
|
336
|
-
case 3:
|
|
337
|
-
_a.sent();
|
|
338
|
-
return [2 /*return*/, (0, util_1.parseItem)(buffer, cramBlockHeader.parser, 0, position)];
|
|
339
|
-
}
|
|
340
|
-
});
|
|
218
|
+
}
|
|
219
|
+
readBlockHeader(position) {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
const sectionParsers = yield this.getSectionParsers();
|
|
222
|
+
const { cramBlockHeader } = sectionParsers;
|
|
223
|
+
const { size: fileSize } = yield this.file.stat();
|
|
224
|
+
if (position + cramBlockHeader.maxLength >= fileSize) {
|
|
225
|
+
return undefined;
|
|
226
|
+
}
|
|
227
|
+
const buffer = Buffer.allocUnsafe(cramBlockHeader.maxLength);
|
|
228
|
+
yield this.file.read(buffer, 0, cramBlockHeader.maxLength, position);
|
|
229
|
+
return (0, util_1.parseItem)(buffer, cramBlockHeader.parser, 0, position);
|
|
341
230
|
});
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
case 1: return [4 /*yield*/, this.file.stat()];
|
|
354
|
-
case 2:
|
|
355
|
-
fileSize = (_a.sent()).size;
|
|
356
|
-
if (position + size >= fileSize) {
|
|
357
|
-
return [2 /*return*/, undefined];
|
|
358
|
-
}
|
|
359
|
-
buffer = Buffer.allocUnsafe(size);
|
|
360
|
-
return [4 /*yield*/, this.file.read(buffer, 0, size, position)];
|
|
361
|
-
case 3:
|
|
362
|
-
_a.sent();
|
|
363
|
-
_a.label = 4;
|
|
364
|
-
case 4:
|
|
365
|
-
data = (0, util_1.parseItem)(buffer, section.parser, 0, position);
|
|
366
|
-
if (data._size !== size) {
|
|
367
|
-
throw new errors_1.CramMalformedError("section read error: requested size ".concat(size, " does not equal parsed size ").concat(data._size));
|
|
368
|
-
}
|
|
369
|
-
return [2 /*return*/, data];
|
|
231
|
+
}
|
|
232
|
+
_parseSection(section, position, size = section.maxLength, preReadBuffer = undefined) {
|
|
233
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
234
|
+
let buffer;
|
|
235
|
+
if (preReadBuffer) {
|
|
236
|
+
buffer = preReadBuffer;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
const { size: fileSize } = yield this.file.stat();
|
|
240
|
+
if (position + size >= fileSize) {
|
|
241
|
+
return undefined;
|
|
370
242
|
}
|
|
371
|
-
|
|
243
|
+
buffer = Buffer.allocUnsafe(size);
|
|
244
|
+
yield this.file.read(buffer, 0, size, position);
|
|
245
|
+
}
|
|
246
|
+
const data = (0, util_1.parseItem)(buffer, section.parser, 0, position);
|
|
247
|
+
if (data._size !== size) {
|
|
248
|
+
throw new errors_1.CramMalformedError(`section read error: requested size ${size} does not equal parsed size ${data._size}`);
|
|
249
|
+
}
|
|
250
|
+
return data;
|
|
372
251
|
});
|
|
373
|
-
}
|
|
374
|
-
|
|
252
|
+
}
|
|
253
|
+
_uncompress(compressionMethod, inputBuffer, outputBuffer) {
|
|
375
254
|
if (compressionMethod === 'gzip') {
|
|
376
|
-
|
|
255
|
+
const result = (0, unzip_1.unzip)(inputBuffer);
|
|
377
256
|
result.copy(outputBuffer);
|
|
378
257
|
}
|
|
379
258
|
else if (compressionMethod === 'bzip2') {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
259
|
+
const bits = bzip2.array(inputBuffer);
|
|
260
|
+
let size = bzip2.header(bits);
|
|
261
|
+
let j = 0;
|
|
262
|
+
let chunk;
|
|
383
263
|
do {
|
|
384
|
-
|
|
264
|
+
chunk = bzip2.decompress(bits, size);
|
|
385
265
|
if (chunk != -1) {
|
|
386
266
|
Buffer.from(chunk).copy(outputBuffer, j);
|
|
387
267
|
j += chunk.length;
|
|
@@ -407,68 +287,54 @@ var CramFile = /** @class */ (function () {
|
|
|
407
287
|
htscodecs_1.default.tok3_uncompress(inputBuffer, outputBuffer);
|
|
408
288
|
}
|
|
409
289
|
else {
|
|
410
|
-
throw new errors_1.CramUnimplementedError(
|
|
290
|
+
throw new errors_1.CramUnimplementedError(`${compressionMethod} decompression not yet implemented`);
|
|
411
291
|
}
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
case 5: return [4 /*yield*/, this.read(uncompressedData, 0, block.uncompressedSize, blockContentPosition)];
|
|
438
|
-
case 6:
|
|
439
|
-
_a.sent();
|
|
440
|
-
_a.label = 7;
|
|
441
|
-
case 7:
|
|
442
|
-
block.content = uncompressedData;
|
|
443
|
-
if (!(majorVersion >= 3)) return [3 /*break*/, 11];
|
|
444
|
-
return [4 /*yield*/, this._parseSection(sectionParsers.cramBlockCrc32, blockContentPosition + block.compressedSize)];
|
|
445
|
-
case 8:
|
|
446
|
-
crc = _a.sent();
|
|
447
|
-
block.crc32 = crc.crc32;
|
|
448
|
-
if (!this.validateChecksums) return [3 /*break*/, 10];
|
|
449
|
-
return [4 /*yield*/, this.checkCrc32(position, block._size + block.compressedSize, block.crc32, 'block data')];
|
|
450
|
-
case 9:
|
|
451
|
-
_a.sent();
|
|
452
|
-
_a.label = 10;
|
|
453
|
-
case 10:
|
|
454
|
-
// make the endposition and size reflect the whole block
|
|
455
|
-
block._endPosition = crc._endPosition;
|
|
456
|
-
block._size =
|
|
457
|
-
block.compressedSize + sectionParsers.cramBlockCrc32.maxLength;
|
|
458
|
-
return [3 /*break*/, 12];
|
|
459
|
-
case 11:
|
|
460
|
-
block._endPosition = blockContentPosition + block.compressedSize;
|
|
461
|
-
block._size = block.compressedSize;
|
|
462
|
-
_a.label = 12;
|
|
463
|
-
case 12: return [2 /*return*/, block];
|
|
292
|
+
}
|
|
293
|
+
readBlock(position) {
|
|
294
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
295
|
+
const { majorVersion } = yield this.getDefinition();
|
|
296
|
+
const sectionParsers = yield this.getSectionParsers();
|
|
297
|
+
const blockHeader = yield this.readBlockHeader(position);
|
|
298
|
+
if (blockHeader === undefined) {
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
const blockContentPosition = blockHeader._endPosition;
|
|
302
|
+
const uncompressedData = Buffer.allocUnsafe(blockHeader.uncompressedSize);
|
|
303
|
+
const block = Object.assign(Object.assign({}, blockHeader), { _endPosition: blockContentPosition, contentPosition: blockContentPosition, content: uncompressedData });
|
|
304
|
+
if (blockHeader.compressionMethod !== 'raw') {
|
|
305
|
+
const compressedData = Buffer.allocUnsafe(blockHeader.compressedSize);
|
|
306
|
+
yield this.read(compressedData, 0, blockHeader.compressedSize, blockContentPosition);
|
|
307
|
+
this._uncompress(blockHeader.compressionMethod, compressedData, uncompressedData);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
yield this.read(uncompressedData, 0, blockHeader.uncompressedSize, blockContentPosition);
|
|
311
|
+
}
|
|
312
|
+
if (majorVersion >= 3) {
|
|
313
|
+
// parse the crc32
|
|
314
|
+
const crc = yield this._parseSection(sectionParsers.cramBlockCrc32, blockContentPosition + blockHeader.compressedSize);
|
|
315
|
+
if (crc === undefined) {
|
|
316
|
+
return undefined;
|
|
464
317
|
}
|
|
465
|
-
|
|
318
|
+
block.crc32 = crc.crc32;
|
|
319
|
+
// check the block data crc32
|
|
320
|
+
if (this.validateChecksums) {
|
|
321
|
+
yield this.checkCrc32(position, blockHeader._size + blockHeader.compressedSize, crc.crc32, 'block data');
|
|
322
|
+
}
|
|
323
|
+
// make the endposition and size reflect the whole block
|
|
324
|
+
block._endPosition = crc._endPosition;
|
|
325
|
+
block._size =
|
|
326
|
+
block.compressedSize + sectionParsers.cramBlockCrc32.maxLength;
|
|
327
|
+
}
|
|
328
|
+
else {
|
|
329
|
+
block._endPosition = blockContentPosition + block.compressedSize;
|
|
330
|
+
block._size = block.compressedSize;
|
|
331
|
+
}
|
|
332
|
+
return block;
|
|
466
333
|
});
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
}());
|
|
334
|
+
}
|
|
335
|
+
}
|
|
470
336
|
exports.default = CramFile;
|
|
471
337
|
'getDefinition getSectionParsers getSamHeader'
|
|
472
338
|
.split(' ')
|
|
473
|
-
.forEach(
|
|
339
|
+
.forEach(method => (0, util_1.tinyMemoize)(CramFile, method));
|
|
474
340
|
//# sourceMappingURL=file.js.map
|