@gmod/cram 1.6.0 → 1.6.3
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 +15 -2
- package/README.md +152 -114
- package/dist/craiIndex.js +2 -4
- package/dist/craiIndex.js.map +1 -1
- package/dist/cram-bundle.js +4 -15
- package/dist/cramFile/codecs/byteArrayLength.d.ts +1 -1
- package/dist/cramFile/codecs/byteArrayLength.js +1 -1
- package/dist/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayStop.js +1 -2
- package/dist/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/dist/cramFile/codecs/external.js +1 -3
- package/dist/cramFile/codecs/external.js.map +1 -1
- package/dist/cramFile/container/compressionScheme.d.ts +1 -1
- package/dist/cramFile/container/compressionScheme.js +6 -4
- package/dist/cramFile/container/compressionScheme.js.map +1 -1
- package/dist/cramFile/file.js +19 -2
- package/dist/cramFile/file.js.map +1 -1
- package/dist/cramFile/slice/decodeRecord.js +62 -58
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/cramFile/slice/index.js +8 -5
- package/dist/cramFile/slice/index.js.map +1 -1
- 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/esm/craiIndex.js +2 -4
- package/esm/craiIndex.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayLength.d.ts +1 -1
- package/esm/cramFile/codecs/byteArrayLength.js +1 -1
- package/esm/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayStop.js +1 -2
- package/esm/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/esm/cramFile/codecs/external.js +1 -3
- package/esm/cramFile/codecs/external.js.map +1 -1
- package/esm/cramFile/container/compressionScheme.d.ts +1 -1
- package/esm/cramFile/container/compressionScheme.js +6 -4
- package/esm/cramFile/container/compressionScheme.js.map +1 -1
- package/esm/cramFile/file.js +19 -2
- package/esm/cramFile/file.js.map +1 -1
- package/esm/cramFile/slice/decodeRecord.js +63 -59
- package/esm/cramFile/slice/decodeRecord.js.map +1 -1
- package/esm/cramFile/slice/index.js +11 -7
- package/esm/cramFile/slice/index.js.map +1 -1
- 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 +7 -2
- 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 +49 -0
- package/src/cramFile/codecs/external.js +52 -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 +143 -0
- package/src/cramFile/container/index.js +119 -0
- package/src/cramFile/file.js +363 -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 +359 -0
- package/src/cramFile/slice/index.js +501 -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
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
# v1.6.3
|
|
2
|
+
|
|
3
|
+
- Optimize CRAM parsing slightly (15% improvement on many short reads). This removes support for big endian machines
|
|
4
|
+
- Publish src directory for sourceMap
|
|
5
|
+
|
|
6
|
+
# v1.6.2
|
|
7
|
+
|
|
8
|
+
- Publish src directory for better source maps
|
|
9
|
+
|
|
10
|
+
# v1.6.1
|
|
11
|
+
|
|
12
|
+
- Explicitly use pako for browser bundle to help avoid buggy zlib polyfills
|
|
13
|
+
|
|
1
14
|
# v1.6.0
|
|
2
15
|
|
|
3
|
-
- Support CRAMv3.1
|
|
4
|
-
- Support bzip
|
|
16
|
+
- Support CRAMv3.1 (thanks to @jkbonfield for contributing!)
|
|
17
|
+
- Support bzip codec
|
|
5
18
|
- Remove localFile from the browser bundle using "browser" package.json field
|
|
6
19
|
- Add esm module field in package.json
|
|
7
20
|
|
package/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://npmjs.org/package/@gmod/cram)
|
|
4
4
|
[](https://codecov.io/gh/GMOD/cram-js/branch/master)
|
|
5
|
-
[](https://github.com/GMOD/cram-js/actions?query=branch%3Amaster+workflow%3APush+)
|
|
6
6
|
|
|
7
7
|
Read CRAM files (indexed or unindexed) with pure JS, works in node or in the browser.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
- Reads CRAM 3.x and 2.x (3.1 added in v1.6.0)
|
|
10
|
+
- Does not read CRAM 1.x
|
|
11
|
+
- Can use .crai indexes out of the box, for efficient sequence fetching, but also has an [index API](#craiindex) that would allow use with other index types
|
|
12
|
+
- Does implement bzip2 but not lzma codecs (yet); if this is important to your use case, please file an issue
|
|
13
13
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
@@ -24,51 +24,87 @@ $ yarn add @gmod/cram
|
|
|
24
24
|
```js
|
|
25
25
|
const { IndexedCramFile, CramFile, CraiIndex } = require('@gmod/cram')
|
|
26
26
|
|
|
27
|
-
//Use indexedfasta library for seqFetch, if using local file (see below)
|
|
27
|
+
// Use indexedfasta library for seqFetch, if using local file (see below)
|
|
28
28
|
const { IndexedFasta, BgzipIndexedFasta } = require('@gmod/indexedfasta')
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
// this uses local file paths for node.js for IndexedFasta, for usages using
|
|
31
|
+
// remote URLs see indexedfasta docs for filehandles and
|
|
32
|
+
// https://github.com/gmod/generic-filehandle
|
|
31
33
|
const t = new IndexedFasta({
|
|
32
34
|
path: '/filesystem/yourfile.fa',
|
|
33
35
|
faiPath: '/filesystem/yourfile.fa.fai',
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// open local files
|
|
38
|
-
const indexedFile = new IndexedCramFile({
|
|
39
|
-
cramPath: '/filesystem/yourfile.cram',
|
|
40
|
-
index: new CraiIndex({
|
|
41
|
-
path: '/filesystem/yourfile.cram.crai',
|
|
42
|
-
}),
|
|
43
|
-
seqFetch: async (seqId, start, end) => {
|
|
44
|
-
// note:
|
|
45
|
-
// * seqFetch should return a promise for a string, in this instance retrieved from IndexedFasta
|
|
46
|
-
// * we use start-1 because cram-js uses 1-based but IndexedFasta uses 0-based coordinates
|
|
47
|
-
// * the seqId is a numeric identifier
|
|
48
|
-
// * you can return an empty string for testing if you want, but you may not get proper interpretation of record.readFeatures
|
|
49
|
-
return t.getSequence(seqId, start-1, end)
|
|
50
|
-
},
|
|
51
|
-
checkSequenceMD5: false,
|
|
52
36
|
})
|
|
53
37
|
|
|
54
38
|
// example of fetching records from an indexed CRAM file.
|
|
55
39
|
// NOTE: only numeric IDs for the reference sequence are accepted.
|
|
56
|
-
// For indexedfasta the numeric ID is the order in which the sequence names
|
|
40
|
+
// For indexedfasta the numeric ID is the order in which the sequence names
|
|
41
|
+
// appear in the header
|
|
57
42
|
|
|
58
43
|
// Wrap in an async and then run
|
|
59
|
-
run = async() => {
|
|
60
|
-
const
|
|
44
|
+
run = async () => {
|
|
45
|
+
const idToName = []
|
|
46
|
+
const nameToId = {}
|
|
47
|
+
|
|
48
|
+
// example opening local files on node.js
|
|
49
|
+
// can also pass `cramUrl` (for the IndexedCramFile class), and `url` (for
|
|
50
|
+
// the CraiIndex) params to open remote URLs
|
|
51
|
+
//
|
|
52
|
+
// alternatively `cramFilehandle` (for the IndexedCramFile class) and
|
|
53
|
+
// `filehandle` (for the CraiIndex) can be used, see for examples
|
|
54
|
+
// https://github.com/gmod/generic-filehandle
|
|
55
|
+
|
|
56
|
+
const indexedFile = new IndexedCramFile({
|
|
57
|
+
cramPath: '/filesystem/yourfile.cram',
|
|
58
|
+
//or
|
|
59
|
+
//cramUrl: 'url/to/file.cram'
|
|
60
|
+
//cramFilehandle: a generic-filehandle or similar filehandle
|
|
61
|
+
index: new CraiIndex({
|
|
62
|
+
path: '/filesystem/yourfile.cram.crai',
|
|
63
|
+
// or
|
|
64
|
+
// url: 'url/to/file.cram.crai'
|
|
65
|
+
// filehandle: a generic-filehandle or similar filehandle
|
|
66
|
+
}),
|
|
67
|
+
seqFetch: async (seqId, start, end) => {
|
|
68
|
+
// note:
|
|
69
|
+
// * seqFetch should return a promise for a string, in this instance retrieved from IndexedFasta
|
|
70
|
+
// * we use start-1 because cram-js uses 1-based but IndexedFasta uses 0-based coordinates
|
|
71
|
+
// * the seqId is a numeric identifier, so we convert it back to a name with idToName
|
|
72
|
+
// * you can return an empty string from this function for testing if you want, but you may not get proper interpretation of record.readFeatures
|
|
73
|
+
return t.getSequence(idToName[seqId], start - 1, end)
|
|
74
|
+
},
|
|
75
|
+
checkSequenceMD5: false,
|
|
76
|
+
})
|
|
77
|
+
const samHeader = await indexedFile.cram.getSamHeader()
|
|
78
|
+
|
|
79
|
+
// use the @SQ lines in the header to figure out the
|
|
80
|
+
// mapping between ref ref ID numbers and names
|
|
81
|
+
|
|
82
|
+
const sqLines = samHeader.filter(l => l.tag === 'SQ')
|
|
83
|
+
sqLines.forEach((sqLine, refId) => {
|
|
84
|
+
sqLine.data.forEach(item => {
|
|
85
|
+
if (item.tag === 'SN') {
|
|
86
|
+
// this is the ref name
|
|
87
|
+
const refName = item.value
|
|
88
|
+
nameToId[refName] = refId
|
|
89
|
+
idToName[refId] = refName
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
const records = await indexedFile.getRecordsForRange(
|
|
95
|
+
nameToId['chr1'],
|
|
96
|
+
10000,
|
|
97
|
+
20000,
|
|
98
|
+
)
|
|
61
99
|
records.forEach(record => {
|
|
62
100
|
console.log(`got a record named ${record.readName}`)
|
|
63
|
-
if(record.readFeatures != undefined) {
|
|
101
|
+
if (record.readFeatures != undefined) {
|
|
64
102
|
record.readFeatures.forEach(({ code, pos, refPos, ref, sub }) => {
|
|
65
103
|
// process the read features. this can be used similar to
|
|
66
104
|
// CIGAR/MD strings in SAM. see CRAM specs for more details.
|
|
67
105
|
if (code === 'X') {
|
|
68
106
|
console.log(
|
|
69
|
-
`${
|
|
70
|
-
record.readName
|
|
71
|
-
} shows a base substitution of ${ref}->${sub} at ${refPos}`,
|
|
107
|
+
`${record.readName} shows a base substitution of ${ref}->${sub} at ${refPos}`,
|
|
72
108
|
)
|
|
73
109
|
}
|
|
74
110
|
})
|
|
@@ -78,19 +114,20 @@ run = async() => {
|
|
|
78
114
|
|
|
79
115
|
run()
|
|
80
116
|
|
|
81
|
-
|
|
82
117
|
// can also pass `cramUrl` (for the IndexedCramFile class), and `url` (for the CraiIndex) params to open remote URLs
|
|
83
118
|
// alternatively `cramFilehandle` (for the IndexedCramFile class) and `filehandle` (for the CraiIndex) can be used, see for examples https://github.com/gmod/generic-filehandle
|
|
84
119
|
```
|
|
85
120
|
|
|
121
|
+
You can use cram-js without NPM also with the cram-bundle.js. See the example directory for usage with script tag
|
|
122
|
+
|
|
86
123
|
## API (auto-generated)
|
|
87
124
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
125
|
+
- [CramRecord](#cramrecord) - format of CRAM records returned by this API
|
|
126
|
+
- [ReadFeatures](#readfeatures) - format of read features on records
|
|
127
|
+
- [IndexedCramFile](#indexedcramfile) - indexed access into a CRAM file
|
|
128
|
+
- [CramFile](#cramfile) - .cram API
|
|
129
|
+
- [CraiIndex](#craiindex) - .crai index API
|
|
130
|
+
- [Error Classes](#error-classes) - special error classes thrown by this API
|
|
94
131
|
|
|
95
132
|
### CramRecord
|
|
96
133
|
|
|
@@ -98,27 +135,27 @@ run()
|
|
|
98
135
|
|
|
99
136
|
##### Table of Contents
|
|
100
137
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
138
|
+
- [CramRecord](#cramrecord)
|
|
139
|
+
- [isPaired](#ispaired)
|
|
140
|
+
- [isProperlyPaired](#isproperlypaired)
|
|
141
|
+
- [isSegmentUnmapped](#issegmentunmapped)
|
|
142
|
+
- [isMateUnmapped](#ismateunmapped)
|
|
143
|
+
- [isReverseComplemented](#isreversecomplemented)
|
|
144
|
+
- [isMateReverseComplemented](#ismatereversecomplemented)
|
|
145
|
+
- [isRead1](#isread1)
|
|
146
|
+
- [isRead2](#isread2)
|
|
147
|
+
- [isSecondary](#issecondary)
|
|
148
|
+
- [isFailedQc](#isfailedqc)
|
|
149
|
+
- [isDuplicate](#isduplicate)
|
|
150
|
+
- [isSupplementary](#issupplementary)
|
|
151
|
+
- [isDetached](#isdetached)
|
|
152
|
+
- [hasMateDownStream](#hasmatedownstream)
|
|
153
|
+
- [isPreservingQualityScores](#ispreservingqualityscores)
|
|
154
|
+
- [isUnknownBases](#isunknownbases)
|
|
155
|
+
- [getReadBases](#getreadbases)
|
|
156
|
+
- [getPairOrientation](#getpairorientation)
|
|
157
|
+
- [addReferenceSequence](#addreferencesequence)
|
|
158
|
+
- [Parameters](#parameters)
|
|
122
159
|
|
|
123
160
|
#### CramRecord
|
|
124
161
|
|
|
@@ -209,12 +246,13 @@ base pairs, and will make the `getReadSequence()` method work.
|
|
|
209
246
|
|
|
210
247
|
###### Parameters
|
|
211
248
|
|
|
212
|
-
|
|
249
|
+
- `refRegion` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
250
|
+
|
|
251
|
+
- `refRegion.start` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
252
|
+
- `refRegion.end` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
253
|
+
- `refRegion.seq` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
213
254
|
|
|
214
|
-
|
|
215
|
-
* `refRegion.end` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
216
|
-
* `refRegion.seq` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
217
|
-
* `compressionScheme` **CramContainerCompressionScheme**
|
|
255
|
+
- `compressionScheme` **CramContainerCompressionScheme**
|
|
218
256
|
|
|
219
257
|
Returns **[undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)** nothing
|
|
220
258
|
|
|
@@ -224,10 +262,10 @@ The feature objects appearing in the `readFeatures` member of CramRecord objects
|
|
|
224
262
|
|
|
225
263
|
#### Static fields
|
|
226
264
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
265
|
+
- **code** (`character`): One of "bqBXIDiQNSPH". See page 15 of the CRAM v3 spec for their meanings.
|
|
266
|
+
- **data** (`any`): the data associated with the feature. The format of this varies depending on the feature code.
|
|
267
|
+
- **pos** (`number`): location relative to the read (1-based)
|
|
268
|
+
- **refPos** (`number`): location relative to the reference (1-based)
|
|
231
269
|
|
|
232
270
|
### IndexedCramFile
|
|
233
271
|
|
|
@@ -235,40 +273,40 @@ The feature objects appearing in the `readFeatures` member of CramRecord objects
|
|
|
235
273
|
|
|
236
274
|
##### Table of Contents
|
|
237
275
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
276
|
+
- [constructor](#constructor)
|
|
277
|
+
- [Parameters](#parameters)
|
|
278
|
+
- [getRecordsForRange](#getrecordsforrange)
|
|
279
|
+
- [Parameters](#parameters-1)
|
|
280
|
+
- [hasDataForReferenceSequence](#hasdataforreferencesequence)
|
|
281
|
+
- [Parameters](#parameters-2)
|
|
244
282
|
|
|
245
283
|
#### constructor
|
|
246
284
|
|
|
247
285
|
##### Parameters
|
|
248
286
|
|
|
249
|
-
|
|
287
|
+
- `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
250
288
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
289
|
+
- `args.cram` **CramFile**
|
|
290
|
+
- `args.index` **Index-like** object that supports getEntriesForRange(seqId,start,end) -> Promise\[Array\[index entries]]
|
|
291
|
+
- `args.cacheSize` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** optional maximum number of CRAM records to cache. default 20,000
|
|
292
|
+
- `args.fetchSizeLimit` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** optional maximum number of bytes to fetch in a single getRecordsForRange call. Default 3 MiB.
|
|
293
|
+
- `args.checkSequenceMD5` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** default true. if false, disables verifying the MD5
|
|
294
|
+
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.
|
|
257
295
|
|
|
258
296
|
#### getRecordsForRange
|
|
259
297
|
|
|
260
298
|
##### Parameters
|
|
261
299
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
300
|
+
- `seq` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** numeric ID of the reference sequence
|
|
301
|
+
- `start` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** start of the range of interest. 1-based closed coordinates.
|
|
302
|
+
- `end` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** end of the range of interest. 1-based closed coordinates.
|
|
303
|
+
- `opts` (optional, default `{}`)
|
|
266
304
|
|
|
267
305
|
#### hasDataForReferenceSequence
|
|
268
306
|
|
|
269
307
|
##### Parameters
|
|
270
308
|
|
|
271
|
-
|
|
309
|
+
- `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
272
310
|
|
|
273
311
|
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** true if the CRAM file contains data for the given
|
|
274
312
|
reference sequence numerical ID
|
|
@@ -279,25 +317,25 @@ reference sequence numerical ID
|
|
|
279
317
|
|
|
280
318
|
##### Table of Contents
|
|
281
319
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
320
|
+
- [constructor](#constructor)
|
|
321
|
+
- [Parameters](#parameters)
|
|
322
|
+
- [containerCount](#containercount)
|
|
285
323
|
|
|
286
324
|
#### constructor
|
|
287
325
|
|
|
288
326
|
##### Parameters
|
|
289
327
|
|
|
290
|
-
|
|
328
|
+
- `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
291
329
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
330
|
+
- `args.filehandle` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** a filehandle that implements the stat() and
|
|
331
|
+
read() methods of the Node filehandle API <https://nodejs.org/api/fs.html#fs_class_filehandle>
|
|
332
|
+
- `args.path` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** path to the cram file
|
|
333
|
+
- `args.url` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** url for the cram file. also supports file:// urls for local files
|
|
334
|
+
- `args.seqFetch` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** a function with signature
|
|
335
|
+
`(seqId, startCoordinate, endCoordinate)` that returns a promise for a string of sequence bases
|
|
336
|
+
- `args.cacheSize` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** optional maximum number of CRAM records to cache. default 20,000
|
|
337
|
+
- `args.checkSequenceMD5` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** default true. if false, disables verifying the MD5
|
|
338
|
+
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.
|
|
301
339
|
|
|
302
340
|
#### containerCount
|
|
303
341
|
|
|
@@ -307,28 +345,28 @@ reference sequence numerical ID
|
|
|
307
345
|
|
|
308
346
|
##### Table of Contents
|
|
309
347
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
348
|
+
- [constructor](#constructor)
|
|
349
|
+
- [Parameters](#parameters)
|
|
350
|
+
- [hasDataForReferenceSequence](#hasdataforreferencesequence)
|
|
351
|
+
- [Parameters](#parameters-1)
|
|
352
|
+
- [getEntriesForRange](#getentriesforrange)
|
|
353
|
+
- [Parameters](#parameters-2)
|
|
316
354
|
|
|
317
355
|
#### constructor
|
|
318
356
|
|
|
319
357
|
##### Parameters
|
|
320
358
|
|
|
321
|
-
|
|
359
|
+
- `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
322
360
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
361
|
+
- `args.path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
|
|
362
|
+
- `args.url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
|
|
363
|
+
- `args.filehandle` **FileHandle?**
|
|
326
364
|
|
|
327
365
|
#### hasDataForReferenceSequence
|
|
328
366
|
|
|
329
367
|
##### Parameters
|
|
330
368
|
|
|
331
|
-
|
|
369
|
+
- `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
332
370
|
|
|
333
371
|
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** true if the index contains entries for
|
|
334
372
|
the given reference sequence ID, false otherwise
|
|
@@ -339,9 +377,9 @@ fetch index entries for the given range
|
|
|
339
377
|
|
|
340
378
|
##### Parameters
|
|
341
379
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
380
|
+
- `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
381
|
+
- `queryStart` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
382
|
+
- `queryEnd` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
345
383
|
|
|
346
384
|
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise for
|
|
347
385
|
an array of objects of the form
|
package/dist/craiIndex.js
CHANGED
|
@@ -41,11 +41,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var abortable_promise_cache_1 = __importDefault(require("abortable-promise-cache"));
|
|
43
43
|
var quick_lru_1 = __importDefault(require("quick-lru"));
|
|
44
|
-
var
|
|
45
|
-
var zlib_1 = __importDefault(require("zlib"));
|
|
44
|
+
var unzip_1 = require("./unzip");
|
|
46
45
|
var io_1 = require("./io");
|
|
47
46
|
var errors_1 = require("./errors");
|
|
48
|
-
var gunzip = (0, es6_promisify_1.promisify)(zlib_1.default.gunzip);
|
|
49
47
|
var BAI_MAGIC = 21578050; // BAI\1
|
|
50
48
|
var Slice = /** @class */ (function () {
|
|
51
49
|
function Slice(args) {
|
|
@@ -102,7 +100,7 @@ var CraiIndex = /** @class */ (function () {
|
|
|
102
100
|
return this.readFile()
|
|
103
101
|
.then(function (data) {
|
|
104
102
|
if (data[0] === 31 && data[1] === 139) {
|
|
105
|
-
return
|
|
103
|
+
return (0, unzip_1.unzip)(data);
|
|
106
104
|
}
|
|
107
105
|
return data;
|
|
108
106
|
})
|
package/dist/craiIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"craiIndex.js","sourceRoot":"","sources":["../src/craiIndex.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oFAA2D;AAC3D,wDAAgC;AAChC
|
|
1
|
+
{"version":3,"file":"craiIndex.js","sourceRoot":"","sources":["../src/craiIndex.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oFAA2D;AAC3D,wDAAgC;AAChC,iCAA+B;AAC/B,2BAA2B;AAC3B,mCAA6C;AAE7C,IAAM,SAAS,GAAG,QAAQ,CAAA,CAAC,QAAQ;AAEnC;IACE,eAAY,IAAI;QACd,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IAC3B,CAAC;IAED,wBAAQ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