@gmod/cram 1.5.9 → 1.6.2
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 +90 -0
- package/README.md +182 -172
- package/dist/craiIndex.d.ts +37 -0
- package/dist/craiIndex.js +196 -301
- package/dist/craiIndex.js.map +1 -0
- package/dist/cram-bundle.js +6 -15
- package/dist/cramFile/codecs/_base.d.ts +6 -0
- package/dist/cramFile/codecs/_base.js +44 -53
- package/dist/cramFile/codecs/_base.js.map +1 -0
- package/dist/cramFile/codecs/beta.d.ts +4 -0
- package/dist/cramFile/codecs/beta.js +38 -48
- package/dist/cramFile/codecs/beta.js.map +1 -0
- package/dist/cramFile/codecs/byteArrayLength.d.ts +8 -0
- package/dist/cramFile/codecs/byteArrayLength.js +58 -78
- package/dist/cramFile/codecs/byteArrayLength.js.map +1 -0
- package/dist/cramFile/codecs/byteArrayStop.d.ts +6 -0
- package/dist/cramFile/codecs/byteArrayStop.js +62 -76
- package/dist/cramFile/codecs/byteArrayStop.js.map +1 -0
- package/dist/cramFile/codecs/external.d.ts +7 -0
- package/dist/cramFile/codecs/external.js +63 -81
- package/dist/cramFile/codecs/external.js.map +1 -0
- package/dist/cramFile/codecs/gamma.d.ts +4 -0
- package/dist/cramFile/codecs/gamma.js +43 -56
- package/dist/cramFile/codecs/gamma.js.map +1 -0
- package/dist/cramFile/codecs/huffman.d.ts +17 -0
- package/dist/cramFile/codecs/huffman.js +126 -199
- package/dist/cramFile/codecs/huffman.js.map +1 -0
- package/dist/cramFile/codecs/index.d.ts +2 -0
- package/dist/cramFile/codecs/index.js +31 -38
- package/dist/cramFile/codecs/index.js.map +1 -0
- package/dist/cramFile/codecs/subexp.d.ts +4 -0
- package/dist/cramFile/codecs/subexp.js +51 -64
- package/dist/cramFile/codecs/subexp.js.map +1 -0
- package/dist/cramFile/constants.d.ts +36 -0
- package/dist/cramFile/constants.js +52 -50
- package/dist/cramFile/constants.js.map +1 -0
- package/dist/cramFile/container/compressionScheme.d.ts +23 -0
- package/dist/cramFile/container/compressionScheme.js +115 -153
- package/dist/cramFile/container/compressionScheme.js.map +1 -0
- package/dist/cramFile/container/index.d.ts +13 -0
- package/dist/cramFile/container/index.js +169 -283
- package/dist/cramFile/container/index.js.map +1 -0
- package/dist/cramFile/file.d.ts +63 -0
- package/dist/cramFile/file.js +440 -766
- package/dist/cramFile/file.js.map +1 -0
- package/dist/cramFile/index.d.ts +2 -0
- package/dist/cramFile/index.js +7 -4
- package/dist/cramFile/index.js.map +1 -0
- package/dist/cramFile/record.d.ts +79 -0
- package/dist/cramFile/record.js +253 -308
- package/dist/cramFile/record.js.map +1 -0
- package/dist/cramFile/sectionParsers.d.ts +18 -0
- package/dist/cramFile/sectionParsers.js +324 -362
- package/dist/cramFile/sectionParsers.js.map +1 -0
- package/dist/cramFile/slice/decodeRecord.d.ts +2 -0
- package/dist/cramFile/slice/decodeRecord.js +278 -298
- package/dist/cramFile/slice/decodeRecord.js.map +1 -0
- package/dist/cramFile/slice/index.d.ts +20 -0
- package/dist/cramFile/slice/index.js +488 -789
- package/dist/cramFile/slice/index.js.map +1 -0
- package/dist/cramFile/util.d.ts +5 -0
- package/dist/cramFile/util.js +158 -144
- package/dist/cramFile/util.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.js +66 -103
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +12 -12
- package/dist/index.js.map +1 -0
- package/dist/indexedCramFile.d.ts +39 -0
- package/dist/indexedCramFile.js +213 -315
- package/dist/indexedCramFile.js.map +1 -0
- package/dist/io/bufferCache.d.ts +12 -0
- package/dist/io/bufferCache.js +108 -128
- package/dist/io/bufferCache.js.map +1 -0
- package/dist/io/index.d.ts +5 -0
- package/dist/io/index.js +29 -27
- package/dist/io/index.js.map +1 -0
- package/dist/io/localFile.d.ts +10 -0
- package/dist/io/localFile.js +105 -162
- package/dist/io/localFile.js.map +1 -0
- package/dist/io/remoteFile.d.ts +16 -0
- package/dist/io/remoteFile.js +137 -206
- package/dist/io/remoteFile.js.map +1 -0
- package/dist/rans/constants.d.ts +3 -0
- package/dist/rans/constants.js +6 -6
- package/dist/rans/constants.js.map +1 -0
- package/dist/rans/d04.d.ts +1 -0
- package/dist/rans/d04.js +70 -99
- package/dist/rans/d04.js.map +1 -0
- package/dist/rans/d14.d.ts +1 -0
- package/dist/rans/d14.js +55 -93
- package/dist/rans/d14.js.map +1 -0
- package/dist/rans/decoding.d.ts +30 -0
- package/dist/rans/decoding.js +112 -159
- package/dist/rans/decoding.js.map +1 -0
- package/dist/rans/frequencies.d.ts +2 -0
- package/dist/rans/frequencies.js +110 -119
- package/dist/rans/frequencies.js.map +1 -0
- package/dist/rans/index.d.ts +1 -0
- package/dist/rans/index.js +111 -174
- package/dist/rans/index.js.map +1 -0
- package/dist/sam.d.ts +1 -0
- package/dist/sam.js +16 -41
- package/dist/sam.js.map +1 -0
- package/dist/unzip-pako.d.ts +2 -0
- package/dist/unzip-pako.js +9 -0
- package/dist/unzip-pako.js.map +1 -0
- package/dist/unzip.d.ts +2 -0
- package/dist/unzip.js +6 -0
- package/dist/unzip.js.map +1 -0
- package/errors.js +66 -103
- package/esm/craiIndex.d.ts +37 -0
- package/esm/craiIndex.js +158 -0
- package/esm/craiIndex.js.map +1 -0
- package/esm/cramFile/codecs/_base.d.ts +6 -0
- package/esm/cramFile/codecs/_base.js +42 -0
- package/esm/cramFile/codecs/_base.js.map +1 -0
- package/esm/cramFile/codecs/beta.d.ts +4 -0
- package/esm/cramFile/codecs/beta.js +15 -0
- package/esm/cramFile/codecs/beta.js.map +1 -0
- package/esm/cramFile/codecs/byteArrayLength.d.ts +8 -0
- package/esm/cramFile/codecs/byteArrayLength.js +35 -0
- package/esm/cramFile/codecs/byteArrayLength.js.map +1 -0
- package/esm/cramFile/codecs/byteArrayStop.d.ts +6 -0
- package/esm/cramFile/codecs/byteArrayStop.js +40 -0
- package/esm/cramFile/codecs/byteArrayStop.js.map +1 -0
- package/esm/cramFile/codecs/external.d.ts +7 -0
- package/esm/cramFile/codecs/external.js +40 -0
- package/esm/cramFile/codecs/external.js.map +1 -0
- package/esm/cramFile/codecs/gamma.d.ts +4 -0
- package/esm/cramFile/codecs/gamma.js +20 -0
- package/esm/cramFile/codecs/gamma.js.map +1 -0
- package/esm/cramFile/codecs/huffman.d.ts +17 -0
- package/esm/cramFile/codecs/huffman.js +107 -0
- package/esm/cramFile/codecs/huffman.js.map +1 -0
- package/esm/cramFile/codecs/index.d.ts +2 -0
- package/esm/cramFile/codecs/index.js +30 -0
- package/esm/cramFile/codecs/index.js.map +1 -0
- package/esm/cramFile/codecs/subexp.d.ts +4 -0
- package/esm/cramFile/codecs/subexp.js +28 -0
- package/esm/cramFile/codecs/subexp.js.map +1 -0
- package/esm/cramFile/constants.d.ts +36 -0
- package/esm/cramFile/constants.js +51 -0
- package/esm/cramFile/constants.js.map +1 -0
- package/esm/cramFile/container/compressionScheme.d.ts +23 -0
- package/esm/cramFile/container/compressionScheme.js +123 -0
- package/esm/cramFile/container/compressionScheme.js.map +1 -0
- package/esm/cramFile/container/index.d.ts +13 -0
- package/esm/cramFile/container/index.js +84 -0
- package/esm/cramFile/container/index.js.map +1 -0
- package/esm/cramFile/file.d.ts +63 -0
- package/esm/cramFile/file.js +281 -0
- package/esm/cramFile/file.js.map +1 -0
- package/esm/cramFile/index.d.ts +2 -0
- package/esm/cramFile/index.js +3 -0
- package/esm/cramFile/index.js.map +1 -0
- package/esm/cramFile/record.d.ts +79 -0
- package/esm/cramFile/record.js +297 -0
- package/esm/cramFile/record.js.map +1 -0
- package/esm/cramFile/sectionParsers.d.ts +18 -0
- package/esm/cramFile/sectionParsers.js +347 -0
- package/esm/cramFile/sectionParsers.js.map +1 -0
- package/esm/cramFile/slice/decodeRecord.d.ts +2 -0
- package/esm/cramFile/slice/decodeRecord.js +299 -0
- package/esm/cramFile/slice/decodeRecord.js.map +1 -0
- package/esm/cramFile/slice/index.d.ts +20 -0
- package/esm/cramFile/slice/index.js +364 -0
- package/esm/cramFile/slice/index.js.map +1 -0
- package/esm/cramFile/util.d.ts +5 -0
- package/esm/cramFile/util.js +161 -0
- package/esm/cramFile/util.js.map +1 -0
- package/esm/errors.d.ts +23 -0
- package/esm/errors.js +24 -0
- package/esm/errors.js.map +1 -0
- package/esm/index.d.ts +4 -0
- package/esm/index.js +5 -0
- package/esm/index.js.map +1 -0
- package/esm/indexedCramFile.d.ts +39 -0
- package/esm/indexedCramFile.js +155 -0
- package/esm/indexedCramFile.js.map +1 -0
- package/esm/io/bufferCache.d.ts +12 -0
- package/esm/io/bufferCache.js +54 -0
- package/esm/io/bufferCache.js.map +1 -0
- package/esm/io/index.d.ts +5 -0
- package/esm/io/index.js +24 -0
- package/esm/io/index.js.map +1 -0
- package/esm/io/localFile.d.ts +10 -0
- package/esm/io/localFile.js +31 -0
- package/esm/io/localFile.js.map +1 -0
- package/esm/io/remoteFile.d.ts +16 -0
- package/esm/io/remoteFile.js +64 -0
- package/esm/io/remoteFile.js.map +1 -0
- package/esm/rans/constants.d.ts +3 -0
- package/esm/rans/constants.js +5 -0
- package/esm/rans/constants.js.map +1 -0
- package/esm/rans/d04.d.ts +1 -0
- package/esm/rans/d04.js +67 -0
- package/esm/rans/d04.js.map +1 -0
- package/esm/rans/d14.d.ts +1 -0
- package/esm/rans/d14.js +52 -0
- package/esm/rans/d14.js.map +1 -0
- package/esm/rans/decoding.d.ts +30 -0
- package/esm/rans/decoding.js +118 -0
- package/esm/rans/decoding.js.map +1 -0
- package/esm/rans/frequencies.d.ts +2 -0
- package/esm/rans/frequencies.js +110 -0
- package/esm/rans/frequencies.js.map +1 -0
- package/esm/rans/index.d.ts +1 -0
- package/esm/rans/index.js +195 -0
- package/esm/rans/index.js.map +1 -0
- package/esm/sam.d.ts +1 -0
- package/esm/sam.js +16 -0
- package/esm/sam.js.map +1 -0
- package/esm/unzip-pako.d.ts +2 -0
- package/esm/unzip-pako.js +5 -0
- package/esm/unzip-pako.js.map +1 -0
- package/esm/unzip.d.ts +2 -0
- package/esm/unzip.js +3 -0
- package/esm/unzip.js.map +1 -0
- package/package.json +38 -35
- package/src/craiIndex.js +180 -0
- package/src/cramFile/codecs/_base.js +49 -0
- package/src/cramFile/codecs/beta.js +23 -0
- package/src/cramFile/codecs/byteArrayLength.js +55 -0
- package/src/cramFile/codecs/byteArrayStop.js +50 -0
- package/src/cramFile/codecs/external.js +54 -0
- package/src/cramFile/codecs/gamma.js +30 -0
- package/src/cramFile/codecs/huffman.js +137 -0
- package/src/cramFile/codecs/index.js +38 -0
- package/src/cramFile/codecs/subexp.js +32 -0
- package/src/cramFile/constants.js +55 -0
- package/src/cramFile/container/compressionScheme.js +144 -0
- package/src/cramFile/container/index.js +119 -0
- package/src/cramFile/file.js +347 -0
- package/src/cramFile/index.js +3 -0
- package/src/cramFile/record.js +337 -0
- package/src/cramFile/sectionParsers.js +379 -0
- package/src/cramFile/slice/decodeRecord.js +362 -0
- package/src/cramFile/slice/index.js +497 -0
- package/src/cramFile/util.js +169 -0
- package/src/errors.js +22 -0
- package/src/index.js +5 -0
- package/src/indexedCramFile.js +191 -0
- package/src/io/bufferCache.js +66 -0
- package/src/io/index.js +26 -0
- package/src/io/localFile.js +35 -0
- package/src/io/remoteFile.js +71 -0
- package/src/rans/README.md +1 -0
- package/src/rans/constants.js +5 -0
- package/src/rans/d04.js +83 -0
- package/src/rans/d14.js +59 -0
- package/src/rans/decoding.js +141 -0
- package/src/rans/frequencies.js +121 -0
- package/src/rans/index.js +249 -0
- package/src/sam.js +15 -0
- package/src/unzip-pako.ts +5 -0
- package/src/unzip.ts +2 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default class IndexedCramFile {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {object} args
|
|
5
|
+
* @param {CramFile} args.cram
|
|
6
|
+
* @param {Index-like} args.index object that supports getEntriesForRange(seqId,start,end) -> Promise[Array[index entries]]
|
|
7
|
+
* @param {number} [args.cacheSize] optional maximum number of CRAM records to cache. default 20,000
|
|
8
|
+
* @param {number} [args.fetchSizeLimit] optional maximum number of bytes to fetch in a single getRecordsForRange call. Default 3 MiB.
|
|
9
|
+
* @param {boolean} [args.checkSequenceMD5] - default true. if false, disables verifying the MD5
|
|
10
|
+
* 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.
|
|
11
|
+
*/
|
|
12
|
+
constructor(args: {
|
|
13
|
+
cram: CramFile;
|
|
14
|
+
});
|
|
15
|
+
cram: CramFile;
|
|
16
|
+
index: any;
|
|
17
|
+
fetchSizeLimit: any;
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {number} seq numeric ID of the reference sequence
|
|
21
|
+
* @param {number} start start of the range of interest. 1-based closed coordinates.
|
|
22
|
+
* @param {number} end end of the range of interest. 1-based closed coordinates.
|
|
23
|
+
* @returns {Promise[Array[CramRecord]]}
|
|
24
|
+
*/
|
|
25
|
+
getRecordsForRange(seq: number, start: number, end: number, opts?: {}): Promise<any>[any[][CramRecord]];
|
|
26
|
+
getRecordsInSlice({ containerStart, sliceStart, sliceBytes }: {
|
|
27
|
+
containerStart: any;
|
|
28
|
+
sliceStart: any;
|
|
29
|
+
sliceBytes: any;
|
|
30
|
+
}, filterFunction: any): Promise<any>;
|
|
31
|
+
/**
|
|
32
|
+
*
|
|
33
|
+
* @param {number} seqId
|
|
34
|
+
* @returns {Promise} true if the CRAM file contains data for the given
|
|
35
|
+
* reference sequence numerical ID
|
|
36
|
+
*/
|
|
37
|
+
hasDataForReferenceSequence(seqId: number): Promise<any>;
|
|
38
|
+
}
|
|
39
|
+
import CramFile from "./cramFile";
|
package/dist/indexedCramFile.js
CHANGED
|
@@ -1,325 +1,223 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _filter = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/filter"));
|
|
10
|
-
|
|
11
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
12
|
-
|
|
13
|
-
var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
|
|
14
|
-
|
|
15
|
-
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
16
|
-
|
|
17
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/toConsumableArray"));
|
|
18
|
-
|
|
19
|
-
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
20
|
-
|
|
21
|
-
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
22
|
-
|
|
23
|
-
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
24
|
-
|
|
25
|
-
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
26
|
-
|
|
27
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
28
|
-
|
|
29
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
30
|
-
|
|
31
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
32
|
-
|
|
33
|
-
var _require = require('./errors'),
|
|
34
|
-
CramUnimplementedError = _require.CramUnimplementedError,
|
|
35
|
-
CramSizeLimitError = _require.CramSizeLimitError;
|
|
36
|
-
|
|
37
|
-
var CramFile = require('./cramFile');
|
|
38
|
-
|
|
39
|
-
var IndexedCramFile =
|
|
40
|
-
/*#__PURE__*/
|
|
41
|
-
function () {
|
|
42
|
-
/**
|
|
43
|
-
*
|
|
44
|
-
* @param {object} args
|
|
45
|
-
* @param {CramFile} args.cram
|
|
46
|
-
* @param {Index-like} args.index object that supports getEntriesForRange(seqId,start,end) -> Promise[Array[index entries]]
|
|
47
|
-
* @param {number} [args.cacheSize] optional maximum number of CRAM records to cache. default 20,000
|
|
48
|
-
* @param {number} [args.fetchSizeLimit] optional maximum number of bytes to fetch in a single getRecordsForRange call. Default 3 MiB.
|
|
49
|
-
* @param {boolean} [args.checkSequenceMD5] - default true. if false, disables verifying the MD5
|
|
50
|
-
* 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.
|
|
51
|
-
*/
|
|
52
|
-
function IndexedCramFile(args) {
|
|
53
|
-
(0, _classCallCheck2.default)(this, IndexedCramFile);
|
|
54
|
-
// { cram, index, seqFetch /* fasta, fastaIndex */ }) {
|
|
55
|
-
if (args.cram) this.cram = args.cram;else this.cram = new CramFile({
|
|
56
|
-
url: args.cramUrl,
|
|
57
|
-
path: args.cramPath,
|
|
58
|
-
filehandle: args.cramFilehandle,
|
|
59
|
-
seqFetch: args.seqFetch,
|
|
60
|
-
checkSequenceMD5: args.checkSequenceMD5,
|
|
61
|
-
cacheSize: args.cacheSize
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
62
9
|
});
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
_this = this,
|
|
86
|
-
_context3,
|
|
87
|
-
_concatInstanceProper,
|
|
88
|
-
_context4;
|
|
89
|
-
|
|
90
|
-
var opts,
|
|
91
|
-
seqId,
|
|
92
|
-
slices,
|
|
93
|
-
totalSize,
|
|
94
|
-
filter,
|
|
95
|
-
sliceResults,
|
|
96
|
-
ret,
|
|
97
|
-
_context5,
|
|
98
|
-
_context6,
|
|
99
|
-
_context7,
|
|
100
|
-
readNames,
|
|
101
|
-
readIds,
|
|
102
|
-
i,
|
|
103
|
-
name,
|
|
104
|
-
id,
|
|
105
|
-
unmatedPairs,
|
|
106
|
-
matePromises,
|
|
107
|
-
_i,
|
|
108
|
-
_name,
|
|
109
|
-
mateSlices,
|
|
110
|
-
mateBlocks,
|
|
111
|
-
mateChunks,
|
|
112
|
-
_i2,
|
|
113
|
-
_mateChunks,
|
|
114
|
-
mateRecordPromises,
|
|
115
|
-
mateFeatPromises,
|
|
116
|
-
mateTotalSize,
|
|
117
|
-
_context8,
|
|
118
|
-
newMateFeats,
|
|
119
|
-
newMates,
|
|
120
|
-
_args = arguments;
|
|
121
|
-
|
|
122
|
-
return _regenerator.default.wrap(function _callee$(_context9) {
|
|
123
|
-
while (1) {
|
|
124
|
-
switch (_context9.prev = _context9.next) {
|
|
125
|
-
case 0:
|
|
126
|
-
opts = _args.length > 3 && _args[3] !== undefined ? _args[3] : {};
|
|
127
|
-
opts.viewAsPairs = opts.viewAsPairs || false;
|
|
128
|
-
opts.pairAcrossChr = opts.pairAcrossChr || false;
|
|
129
|
-
opts.maxInsertSize = opts.maxInsertSize || 200000;
|
|
130
|
-
|
|
131
|
-
if (!(typeof seq === 'string')) {
|
|
132
|
-
_context9.next = 6;
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
throw new CramUnimplementedError('string sequence names not yet supported');
|
|
137
|
-
|
|
138
|
-
case 6:
|
|
139
|
-
seqId = seq;
|
|
140
|
-
_context9.next = 9;
|
|
141
|
-
return this.index.getEntriesForRange(seqId, start, end);
|
|
142
|
-
|
|
143
|
-
case 9:
|
|
144
|
-
slices = _context9.sent;
|
|
145
|
-
totalSize = (0, _reduce.default)(_context = (0, _map.default)(slices).call(slices, function (s) {
|
|
146
|
-
return s.sliceBytes;
|
|
147
|
-
})).call(_context, function (a, b) {
|
|
148
|
-
return a + b;
|
|
149
|
-
}, 0);
|
|
150
|
-
|
|
151
|
-
if (!(totalSize > this.fetchSizeLimit)) {
|
|
152
|
-
_context9.next = 13;
|
|
153
|
-
break;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
throw new CramSizeLimitError((0, _concat.default)(_context2 = "data size of ".concat(totalSize.toLocaleString(), " bytes exceeded fetch size limit of ")).call(_context2, this.fetchSizeLimit.toLocaleString(), " bytes"));
|
|
157
|
-
|
|
158
|
-
case 13:
|
|
159
|
-
// TODO: do we need to merge or de-duplicate the blocks?
|
|
160
|
-
// fetch all the slices and parse the feature data
|
|
161
|
-
filter = function filter(feature) {
|
|
162
|
-
return feature.sequenceId === seq && feature.alignmentStart <= end && feature.alignmentStart + feature.lengthOnRef - 1 >= start;
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
_context9.next = 16;
|
|
166
|
-
return _promise.default.all((0, _map.default)(slices).call(slices, function (slice) {
|
|
167
|
-
return _this.getRecordsInSlice(slice, filter);
|
|
168
|
-
}));
|
|
169
|
-
|
|
170
|
-
case 16:
|
|
171
|
-
sliceResults = _context9.sent;
|
|
172
|
-
ret = (_concatInstanceProper = (0, _concat.default)(_context3 = Array.prototype)).call.apply(_concatInstanceProper, (0, _concat.default)(_context4 = [_context3]).call(_context4, (0, _toConsumableArray2.default)(sliceResults)));
|
|
173
|
-
|
|
174
|
-
if (!opts.viewAsPairs) {
|
|
175
|
-
_context9.next = 42;
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
readNames = {};
|
|
180
|
-
readIds = {};
|
|
181
|
-
|
|
182
|
-
for (i = 0; i < ret.length; i += 1) {
|
|
183
|
-
name = ret[i].readName;
|
|
184
|
-
id = ret[i].uniqueId;
|
|
185
|
-
if (!readNames[name]) readNames[name] = 0;
|
|
186
|
-
readNames[name] += 1;
|
|
187
|
-
readIds[id] = 1;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
unmatedPairs = {};
|
|
191
|
-
(0, _forEach.default)(_context5 = (0, _entries.default)(readNames)).call(_context5, function (_ref) {
|
|
192
|
-
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
193
|
-
k = _ref2[0],
|
|
194
|
-
v = _ref2[1];
|
|
195
|
-
|
|
196
|
-
if (v === 1) unmatedPairs[k] = true;
|
|
197
|
-
});
|
|
198
|
-
matePromises = [];
|
|
199
|
-
|
|
200
|
-
for (_i = 0; _i < ret.length; _i += 1) {
|
|
201
|
-
_name = ret[_i].readName;
|
|
202
|
-
|
|
203
|
-
if (unmatedPairs[_name] && ret[_i].mate && (ret[_i].mate.sequenceId === seqId || opts.pairAcrossChr) && Math.abs(ret[_i].alignmentStart - ret[_i].mate.alignmentStart) < opts.maxInsertSize) {
|
|
204
|
-
mateSlices = this.index.getEntriesForRange(ret[_i].mate.sequenceId, ret[_i].mate.alignmentStart, ret[_i].mate.alignmentStart + 1);
|
|
205
|
-
matePromises.push(mateSlices);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
_context9.next = 28;
|
|
210
|
-
return _promise.default.all(matePromises);
|
|
211
|
-
|
|
212
|
-
case 28:
|
|
213
|
-
mateBlocks = _context9.sent;
|
|
214
|
-
mateChunks = [];
|
|
215
|
-
|
|
216
|
-
for (_i2 = 0; _i2 < mateBlocks.length; _i2 += 1) {
|
|
217
|
-
(_mateChunks = mateChunks).push.apply(_mateChunks, (0, _toConsumableArray2.default)(mateBlocks[_i2]));
|
|
218
|
-
} // filter out duplicates
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
mateChunks = (0, _filter.default)(_context6 = (0, _sort.default)(mateChunks).call(mateChunks, function (a, b) {
|
|
222
|
-
return a.toString().localeCompare(b.toString());
|
|
223
|
-
})).call(_context6, function (item, pos, ary) {
|
|
224
|
-
return !pos || item.toString() !== ary[pos - 1].toString();
|
|
225
|
-
});
|
|
226
|
-
mateRecordPromises = [];
|
|
227
|
-
mateFeatPromises = [];
|
|
228
|
-
mateTotalSize = (0, _reduce.default)(_context7 = (0, _map.default)(mateChunks).call(mateChunks, function (s) {
|
|
229
|
-
return s.sliceBytes;
|
|
230
|
-
})).call(_context7, function (a, b) {
|
|
231
|
-
return a + b;
|
|
232
|
-
}, 0);
|
|
233
|
-
|
|
234
|
-
if (!(mateTotalSize > this.fetchSizeLimit)) {
|
|
235
|
-
_context9.next = 37;
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
throw new Error((0, _concat.default)(_context8 = "mate data size of ".concat(mateTotalSize.toLocaleString(), " bytes exceeded fetch size limit of ")).call(_context8, this.fetchSizeLimit.toLocaleString(), " bytes"));
|
|
240
|
-
|
|
241
|
-
case 37:
|
|
242
|
-
(0, _forEach.default)(mateChunks).call(mateChunks, function (c) {
|
|
243
|
-
var recordPromise = _this.cram.featureCache.get(c.toString());
|
|
244
|
-
|
|
245
|
-
if (!recordPromise) {
|
|
246
|
-
recordPromise = _this.getRecordsInSlice(c, function () {
|
|
247
|
-
return true;
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
_this.cram.featureCache.set(c.toString(), recordPromise);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
mateRecordPromises.push(recordPromise);
|
|
254
|
-
var featPromise = recordPromise.then(function (feats) {
|
|
255
|
-
var mateRecs = [];
|
|
256
|
-
|
|
257
|
-
for (var _i3 = 0; _i3 < feats.length; _i3 += 1) {
|
|
258
|
-
var feature = feats[_i3];
|
|
259
|
-
|
|
260
|
-
if (unmatedPairs[feature.readName] && !readIds[feature.uniqueId]) {
|
|
261
|
-
mateRecs.push(feature);
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return mateRecs;
|
|
266
|
-
});
|
|
267
|
-
mateFeatPromises.push(featPromise);
|
|
268
|
-
});
|
|
269
|
-
_context9.next = 40;
|
|
270
|
-
return _promise.default.all(mateFeatPromises);
|
|
271
|
-
|
|
272
|
-
case 40:
|
|
273
|
-
newMateFeats = _context9.sent;
|
|
274
|
-
|
|
275
|
-
if (newMateFeats.length) {
|
|
276
|
-
newMates = (0, _reduce.default)(newMateFeats).call(newMateFeats, function (result, current) {
|
|
277
|
-
return (0, _concat.default)(result).call(result, current);
|
|
278
|
-
});
|
|
279
|
-
ret = (0, _concat.default)(ret).call(ret, newMates);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
case 42:
|
|
283
|
-
return _context9.abrupt("return", ret);
|
|
284
|
-
|
|
285
|
-
case 43:
|
|
286
|
-
case "end":
|
|
287
|
-
return _context9.stop();
|
|
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;
|
|
288
32
|
}
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var errors_1 = require("./errors");
|
|
43
|
+
var cramFile_1 = __importDefault(require("./cramFile"));
|
|
44
|
+
var IndexedCramFile = /** @class */ (function () {
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @param {object} args
|
|
48
|
+
* @param {CramFile} args.cram
|
|
49
|
+
* @param {Index-like} args.index object that supports getEntriesForRange(seqId,start,end) -> Promise[Array[index entries]]
|
|
50
|
+
* @param {number} [args.cacheSize] optional maximum number of CRAM records to cache. default 20,000
|
|
51
|
+
* @param {number} [args.fetchSizeLimit] optional maximum number of bytes to fetch in a single getRecordsForRange call. Default 3 MiB.
|
|
52
|
+
* @param {boolean} [args.checkSequenceMD5] - default true. if false, disables verifying the MD5
|
|
53
|
+
* 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.
|
|
54
|
+
*/
|
|
55
|
+
function IndexedCramFile(args) {
|
|
56
|
+
// { cram, index, seqFetch /* fasta, fastaIndex */ }) {
|
|
57
|
+
if (args.cram) {
|
|
58
|
+
this.cram = args.cram;
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.cram = new cramFile_1.default({
|
|
62
|
+
url: args.cramUrl,
|
|
63
|
+
path: args.cramPath,
|
|
64
|
+
filehandle: args.cramFilehandle,
|
|
65
|
+
seqFetch: args.seqFetch,
|
|
66
|
+
checkSequenceMD5: args.checkSequenceMD5,
|
|
67
|
+
cacheSize: args.cacheSize,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (!(this.cram instanceof cramFile_1.default)) {
|
|
71
|
+
throw new Error('invalid arguments: no cramfile');
|
|
72
|
+
}
|
|
73
|
+
this.index = args.index;
|
|
74
|
+
if (!this.index.getEntriesForRange) {
|
|
75
|
+
throw new Error('invalid arguments: not an index');
|
|
76
|
+
}
|
|
77
|
+
this.fetchSizeLimit = args.fetchSizeLimit || 3000000;
|
|
308
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param {number} seq numeric ID of the reference sequence
|
|
82
|
+
* @param {number} start start of the range of interest. 1-based closed coordinates.
|
|
83
|
+
* @param {number} end end of the range of interest. 1-based closed coordinates.
|
|
84
|
+
* @returns {Promise[Array[CramRecord]]}
|
|
85
|
+
*/
|
|
86
|
+
IndexedCramFile.prototype.getRecordsForRange = function (seq, start, end, opts) {
|
|
87
|
+
if (opts === void 0) { opts = {}; }
|
|
88
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
+
var seqId, slices, totalSize, filter, sliceResults, ret, readNames, readIds_1, i, name_1, id, unmatedPairs_1, matePromises, i, name_2, mateSlices, mateBlocks, mateChunks, i, mateRecordPromises_1, mateFeatPromises_1, mateTotalSize, newMateFeats, newMates;
|
|
90
|
+
var _a;
|
|
91
|
+
var _this = this;
|
|
92
|
+
return __generator(this, function (_b) {
|
|
93
|
+
switch (_b.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
opts.viewAsPairs = opts.viewAsPairs || false;
|
|
96
|
+
opts.pairAcrossChr = opts.pairAcrossChr || false;
|
|
97
|
+
opts.maxInsertSize = opts.maxInsertSize || 200000;
|
|
98
|
+
if (typeof seq === 'string') {
|
|
99
|
+
// TODO: support string reference sequence names somehow
|
|
100
|
+
throw new errors_1.CramUnimplementedError('string sequence names not yet supported');
|
|
101
|
+
}
|
|
102
|
+
seqId = seq;
|
|
103
|
+
return [4 /*yield*/, this.index.getEntriesForRange(seqId, start, end)];
|
|
104
|
+
case 1:
|
|
105
|
+
slices = _b.sent();
|
|
106
|
+
totalSize = slices.map(function (s) { return s.sliceBytes; }).reduce(function (a, b) { return a + b; }, 0);
|
|
107
|
+
if (totalSize > this.fetchSizeLimit) {
|
|
108
|
+
throw new errors_1.CramSizeLimitError("data size of ".concat(totalSize.toLocaleString(), " bytes exceeded fetch size limit of ").concat(this.fetchSizeLimit.toLocaleString(), " bytes"));
|
|
109
|
+
}
|
|
110
|
+
filter = function (feature) {
|
|
111
|
+
return feature.sequenceId === seq &&
|
|
112
|
+
feature.alignmentStart <= end &&
|
|
113
|
+
feature.alignmentStart + feature.lengthOnRef - 1 >= start;
|
|
114
|
+
};
|
|
115
|
+
return [4 /*yield*/, Promise.all(slices.map(function (slice) { return _this.getRecordsInSlice(slice, filter); }))];
|
|
116
|
+
case 2:
|
|
117
|
+
sliceResults = _b.sent();
|
|
118
|
+
ret = (_a = Array.prototype).concat.apply(_a, sliceResults);
|
|
119
|
+
if (!opts.viewAsPairs) return [3 /*break*/, 5];
|
|
120
|
+
readNames = {};
|
|
121
|
+
readIds_1 = {};
|
|
122
|
+
for (i = 0; i < ret.length; i += 1) {
|
|
123
|
+
name_1 = ret[i].readName;
|
|
124
|
+
id = ret[i].uniqueId;
|
|
125
|
+
if (!readNames[name_1]) {
|
|
126
|
+
readNames[name_1] = 0;
|
|
127
|
+
}
|
|
128
|
+
readNames[name_1] += 1;
|
|
129
|
+
readIds_1[id] = 1;
|
|
130
|
+
}
|
|
131
|
+
unmatedPairs_1 = {};
|
|
132
|
+
Object.entries(readNames).forEach(function (_a) {
|
|
133
|
+
var k = _a[0], v = _a[1];
|
|
134
|
+
if (v === 1) {
|
|
135
|
+
unmatedPairs_1[k] = true;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
matePromises = [];
|
|
139
|
+
for (i = 0; i < ret.length; i += 1) {
|
|
140
|
+
name_2 = ret[i].readName;
|
|
141
|
+
if (unmatedPairs_1[name_2] &&
|
|
142
|
+
ret[i].mate &&
|
|
143
|
+
(ret[i].mate.sequenceId === seqId || opts.pairAcrossChr) &&
|
|
144
|
+
Math.abs(ret[i].alignmentStart - ret[i].mate.alignmentStart) <
|
|
145
|
+
opts.maxInsertSize) {
|
|
146
|
+
mateSlices = this.index.getEntriesForRange(ret[i].mate.sequenceId, ret[i].mate.alignmentStart, ret[i].mate.alignmentStart + 1);
|
|
147
|
+
matePromises.push(mateSlices);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return [4 /*yield*/, Promise.all(matePromises)];
|
|
151
|
+
case 3:
|
|
152
|
+
mateBlocks = _b.sent();
|
|
153
|
+
mateChunks = [];
|
|
154
|
+
for (i = 0; i < mateBlocks.length; i += 1) {
|
|
155
|
+
mateChunks.push.apply(mateChunks, mateBlocks[i]);
|
|
156
|
+
}
|
|
157
|
+
// filter out duplicates
|
|
158
|
+
mateChunks = mateChunks
|
|
159
|
+
.sort(function (a, b) { return a.toString().localeCompare(b.toString()); })
|
|
160
|
+
.filter(function (item, pos, ary) {
|
|
161
|
+
return !pos || item.toString() !== ary[pos - 1].toString();
|
|
162
|
+
});
|
|
163
|
+
mateRecordPromises_1 = [];
|
|
164
|
+
mateFeatPromises_1 = [];
|
|
165
|
+
mateTotalSize = mateChunks
|
|
166
|
+
.map(function (s) { return s.sliceBytes; })
|
|
167
|
+
.reduce(function (a, b) { return a + b; }, 0);
|
|
168
|
+
if (mateTotalSize > this.fetchSizeLimit) {
|
|
169
|
+
throw new Error("mate data size of ".concat(mateTotalSize.toLocaleString(), " bytes exceeded fetch size limit of ").concat(this.fetchSizeLimit.toLocaleString(), " bytes"));
|
|
170
|
+
}
|
|
171
|
+
mateChunks.forEach(function (c) {
|
|
172
|
+
var recordPromise = _this.cram.featureCache.get(c.toString());
|
|
173
|
+
if (!recordPromise) {
|
|
174
|
+
recordPromise = _this.getRecordsInSlice(c, function () { return true; });
|
|
175
|
+
_this.cram.featureCache.set(c.toString(), recordPromise);
|
|
176
|
+
}
|
|
177
|
+
mateRecordPromises_1.push(recordPromise);
|
|
178
|
+
var featPromise = recordPromise.then(function (feats) {
|
|
179
|
+
var mateRecs = [];
|
|
180
|
+
for (var i = 0; i < feats.length; i += 1) {
|
|
181
|
+
var feature = feats[i];
|
|
182
|
+
if (unmatedPairs_1[feature.readName] && !readIds_1[feature.uniqueId]) {
|
|
183
|
+
mateRecs.push(feature);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return mateRecs;
|
|
187
|
+
});
|
|
188
|
+
mateFeatPromises_1.push(featPromise);
|
|
189
|
+
});
|
|
190
|
+
return [4 /*yield*/, Promise.all(mateFeatPromises_1)];
|
|
191
|
+
case 4:
|
|
192
|
+
newMateFeats = _b.sent();
|
|
193
|
+
if (newMateFeats.length) {
|
|
194
|
+
newMates = newMateFeats.reduce(function (result, current) {
|
|
195
|
+
return result.concat(current);
|
|
196
|
+
});
|
|
197
|
+
ret = ret.concat(newMates);
|
|
198
|
+
}
|
|
199
|
+
_b.label = 5;
|
|
200
|
+
case 5: return [2 /*return*/, ret];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
IndexedCramFile.prototype.getRecordsInSlice = function (_a, filterFunction) {
|
|
206
|
+
var containerStart = _a.containerStart, sliceStart = _a.sliceStart, sliceBytes = _a.sliceBytes;
|
|
207
|
+
var container = this.cram.getContainerAtPosition(containerStart);
|
|
208
|
+
var slice = container.getSlice(sliceStart, sliceBytes);
|
|
209
|
+
return slice.getRecords(filterFunction);
|
|
210
|
+
};
|
|
309
211
|
/**
|
|
310
212
|
*
|
|
311
213
|
* @param {number} seqId
|
|
312
214
|
* @returns {Promise} true if the CRAM file contains data for the given
|
|
313
215
|
* reference sequence numerical ID
|
|
314
216
|
*/
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
return IndexedCramFile;
|
|
323
|
-
}();
|
|
324
|
-
|
|
325
|
-
module.exports = IndexedCramFile;
|
|
217
|
+
IndexedCramFile.prototype.hasDataForReferenceSequence = function (seqId) {
|
|
218
|
+
return this.index.hasDataForReferenceSequence(seqId);
|
|
219
|
+
};
|
|
220
|
+
return IndexedCramFile;
|
|
221
|
+
}());
|
|
222
|
+
exports.default = IndexedCramFile;
|
|
223
|
+
//# sourceMappingURL=indexedCramFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexedCramFile.js","sourceRoot":"","sources":["../src/indexedCramFile.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAqE;AAErE,wDAAiC;AAEjC;IACE;;;;;;;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ACxD,IAAI,YAAY,CAAC,MAAM,EAAE;4BACjB,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,UAAC,MAAM,EAAE,OAAO;gCACnD,OAAA,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;4BAAtB,CAAsB,CACvB,CAAA;4BACD,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;yBAC3B;;4BAEH,sBAAO,GAAG,EAAA;;;;KACX;IAED,2CAAiB,GAAjB,UACE,EAA0C,EAC1C,cAAc;YADZ,cAAc,oBAAA,EAAE,UAAU,gBAAA,EAAE,UAAU,gBAAA;QAGxC,IAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAA;QAClE,IAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;QACxD,OAAO,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,CAAA;IACzC,CAAC;IAED;;;;;OAKG;IACH,qDAA2B,GAA3B,UAA4B,KAAK;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,2BAA2B,CAAC,KAAK,CAAC,CAAA;IACtD,CAAC;IACH,sBAAC;AAAD,CAAC,AA1LD,IA0LC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default class BufferCache {
|
|
2
|
+
constructor({ fetch, size, chunkSize }: {
|
|
3
|
+
fetch: any;
|
|
4
|
+
size?: number | undefined;
|
|
5
|
+
chunkSize?: number | undefined;
|
|
6
|
+
});
|
|
7
|
+
fetch: any;
|
|
8
|
+
chunkSize: number;
|
|
9
|
+
lruCache: any;
|
|
10
|
+
get(outputBuffer: any, offset: any, length: any, position: any): Promise<void>;
|
|
11
|
+
_getChunk(chunkNumber: any): any;
|
|
12
|
+
}
|