@gmod/cram 1.7.1 → 1.7.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 +9 -0
- package/README.md +19 -240
- package/dist/craiIndex.d.ts +2 -2
- package/dist/cram-bundle.js +1 -1
- package/dist/cramFile/codecs/_base.d.ts +3 -3
- package/dist/cramFile/codecs/byteArrayLength.d.ts +1 -1
- package/dist/cramFile/codecs/dataSeriesTypes.d.ts +3 -3
- package/dist/cramFile/container/compressionScheme.d.ts +2 -2
- package/dist/cramFile/encoding.d.ts +11 -11
- package/dist/cramFile/file.d.ts +4 -4
- package/dist/cramFile/record.d.ts +5 -5
- package/dist/cramFile/record.js +1 -2
- package/dist/cramFile/record.js.map +1 -1
- package/dist/cramFile/sectionParsers.d.ts +7 -7
- package/dist/cramFile/slice/decodeRecord.d.ts +1 -1
- package/dist/cramFile/slice/decodeRecord.js +5 -1
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/cramFile/slice/index.d.ts +1 -1
- package/dist/cramFile/util.d.ts +1 -1
- package/dist/indexedCramFile.d.ts +2 -2
- package/dist/sam.d.ts +1 -1
- package/dist/typescript.d.ts +2 -2
- package/esm/craiIndex.d.ts +2 -2
- package/esm/cramFile/codecs/_base.d.ts +3 -3
- package/esm/cramFile/codecs/byteArrayLength.d.ts +1 -1
- package/esm/cramFile/codecs/dataSeriesTypes.d.ts +3 -3
- package/esm/cramFile/container/compressionScheme.d.ts +2 -2
- package/esm/cramFile/encoding.d.ts +11 -11
- package/esm/cramFile/file.d.ts +4 -4
- package/esm/cramFile/record.d.ts +5 -5
- package/esm/cramFile/record.js +1 -2
- package/esm/cramFile/record.js.map +1 -1
- package/esm/cramFile/sectionParsers.d.ts +7 -7
- package/esm/cramFile/slice/decodeRecord.d.ts +1 -1
- package/esm/cramFile/slice/decodeRecord.js +5 -1
- package/esm/cramFile/slice/decodeRecord.js.map +1 -1
- package/esm/cramFile/slice/index.d.ts +1 -1
- package/esm/cramFile/util.d.ts +1 -1
- package/esm/indexedCramFile.d.ts +2 -2
- package/esm/sam.d.ts +1 -1
- package/esm/typescript.d.ts +2 -2
- package/package.json +14 -14
- package/src/cramFile/record.ts +1 -2
- package/src/cramFile/slice/decodeRecord.ts +5 -1
package/CHANGELOG.md
CHANGED
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
|
|
|
@@ -122,139 +122,18 @@ You can use cram-js without NPM also with the cram-bundle.js. See the example di
|
|
|
122
122
|
|
|
123
123
|
## API (auto-generated)
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
|
131
131
|
|
|
132
132
|
### CramRecord
|
|
133
133
|
|
|
134
134
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
135
135
|
|
|
136
|
-
|
|
137
|
-
|
|
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)
|
|
159
|
-
|
|
160
|
-
#### CramRecord
|
|
161
|
-
|
|
162
|
-
Class of each CRAM record returned by this API.
|
|
163
|
-
|
|
164
|
-
##### isPaired
|
|
165
|
-
|
|
166
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read is paired, regardless of whether both segments are mapped
|
|
167
|
-
|
|
168
|
-
##### isProperlyPaired
|
|
169
|
-
|
|
170
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read is paired, and both segments are mapped
|
|
171
|
-
|
|
172
|
-
##### isSegmentUnmapped
|
|
173
|
-
|
|
174
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read itself is unmapped; conflictive with isProperlyPaired
|
|
175
|
-
|
|
176
|
-
##### isMateUnmapped
|
|
177
|
-
|
|
178
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read itself is unmapped; conflictive with isProperlyPaired
|
|
179
|
-
|
|
180
|
-
##### isReverseComplemented
|
|
181
|
-
|
|
182
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read is mapped to the reverse strand
|
|
183
|
-
|
|
184
|
-
##### isMateReverseComplemented
|
|
185
|
-
|
|
186
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the mate is mapped to the reverse strand
|
|
187
|
-
|
|
188
|
-
##### isRead1
|
|
189
|
-
|
|
190
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if this is read number 1 in a pair
|
|
191
|
-
|
|
192
|
-
##### isRead2
|
|
193
|
-
|
|
194
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if this is read number 2 in a pair
|
|
195
|
-
|
|
196
|
-
##### isSecondary
|
|
197
|
-
|
|
198
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if this is a secondary alignment
|
|
199
|
-
|
|
200
|
-
##### isFailedQc
|
|
201
|
-
|
|
202
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if this read has failed QC checks
|
|
203
|
-
|
|
204
|
-
##### isDuplicate
|
|
205
|
-
|
|
206
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read is an optical or PCR duplicate
|
|
207
|
-
|
|
208
|
-
##### isSupplementary
|
|
209
|
-
|
|
210
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if this is a supplementary alignment
|
|
211
|
-
|
|
212
|
-
##### isDetached
|
|
213
|
-
|
|
214
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read is detached
|
|
215
|
-
|
|
216
|
-
##### hasMateDownStream
|
|
217
|
-
|
|
218
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read has a mate in this same CRAM segment
|
|
219
|
-
|
|
220
|
-
##### isPreservingQualityScores
|
|
221
|
-
|
|
222
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read contains qual scores
|
|
223
|
-
|
|
224
|
-
##### isUnknownBases
|
|
225
|
-
|
|
226
|
-
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** true if the read has no sequence bases
|
|
227
|
-
|
|
228
|
-
##### getReadBases
|
|
229
|
-
|
|
230
|
-
Get the original sequence of this read.
|
|
231
|
-
|
|
232
|
-
Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** sequence basepairs
|
|
233
|
-
|
|
234
|
-
##### getPairOrientation
|
|
235
|
-
|
|
236
|
-
Get the pair orientation of a paired read. Adapted from igv.js
|
|
237
|
-
|
|
238
|
-
Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** of paired orientatin
|
|
239
|
-
|
|
240
|
-
##### addReferenceSequence
|
|
241
|
-
|
|
242
|
-
Annotates this feature with the given reference sequence basepair
|
|
243
|
-
information. This will add a `sub` and a `ref` item to base
|
|
244
|
-
subsitution read features given the actual substituted and reference
|
|
245
|
-
base pairs, and will make the `getReadSequence()` method work.
|
|
246
|
-
|
|
247
|
-
###### Parameters
|
|
248
|
-
|
|
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)**
|
|
254
|
-
|
|
255
|
-
- `compressionScheme` **CramContainerCompressionScheme**
|
|
256
|
-
|
|
257
|
-
Returns **[undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)** nothing
|
|
136
|
+
#### Table of Contents
|
|
258
137
|
|
|
259
138
|
### ReadFeatures
|
|
260
139
|
|
|
@@ -262,128 +141,28 @@ The feature objects appearing in the `readFeatures` member of CramRecord objects
|
|
|
262
141
|
|
|
263
142
|
#### Static fields
|
|
264
143
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
144
|
+
* **code** (`character`): One of "bqBXIDiQNSPH". See page 15 of the CRAM v3 spec for their meanings.
|
|
145
|
+
* **data** (`any`): the data associated with the feature. The format of this varies depending on the feature code.
|
|
146
|
+
* **pos** (`number`): location relative to the read (1-based)
|
|
147
|
+
* **refPos** (`number`): location relative to the reference (1-based)
|
|
269
148
|
|
|
270
149
|
### IndexedCramFile
|
|
271
150
|
|
|
272
151
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
273
152
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
- [constructor](#constructor)
|
|
277
|
-
- [Parameters](#parameters)
|
|
278
|
-
- [getRecordsForRange](#getrecordsforrange)
|
|
279
|
-
- [Parameters](#parameters-1)
|
|
280
|
-
- [hasDataForReferenceSequence](#hasdataforreferencesequence)
|
|
281
|
-
- [Parameters](#parameters-2)
|
|
282
|
-
|
|
283
|
-
#### constructor
|
|
284
|
-
|
|
285
|
-
##### Parameters
|
|
286
|
-
|
|
287
|
-
- `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
288
|
-
|
|
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.
|
|
295
|
-
|
|
296
|
-
#### getRecordsForRange
|
|
297
|
-
|
|
298
|
-
##### Parameters
|
|
299
|
-
|
|
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 `{}`)
|
|
304
|
-
|
|
305
|
-
#### hasDataForReferenceSequence
|
|
306
|
-
|
|
307
|
-
##### Parameters
|
|
308
|
-
|
|
309
|
-
- `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
310
|
-
|
|
311
|
-
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** true if the CRAM file contains data for the given
|
|
312
|
-
reference sequence numerical ID
|
|
153
|
+
#### Table of Contents
|
|
313
154
|
|
|
314
155
|
### CramFile
|
|
315
156
|
|
|
316
157
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
317
158
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
- [constructor](#constructor)
|
|
321
|
-
- [Parameters](#parameters)
|
|
322
|
-
- [containerCount](#containercount)
|
|
323
|
-
|
|
324
|
-
#### constructor
|
|
325
|
-
|
|
326
|
-
##### Parameters
|
|
327
|
-
|
|
328
|
-
- `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
329
|
-
|
|
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.
|
|
339
|
-
|
|
340
|
-
#### containerCount
|
|
159
|
+
#### Table of Contents
|
|
341
160
|
|
|
342
161
|
### CraiIndex
|
|
343
162
|
|
|
344
163
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
345
164
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
- [constructor](#constructor)
|
|
349
|
-
- [Parameters](#parameters)
|
|
350
|
-
- [hasDataForReferenceSequence](#hasdataforreferencesequence)
|
|
351
|
-
- [Parameters](#parameters-1)
|
|
352
|
-
- [getEntriesForRange](#getentriesforrange)
|
|
353
|
-
- [Parameters](#parameters-2)
|
|
354
|
-
|
|
355
|
-
#### constructor
|
|
356
|
-
|
|
357
|
-
##### Parameters
|
|
358
|
-
|
|
359
|
-
- `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
360
|
-
|
|
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?**
|
|
364
|
-
|
|
365
|
-
#### hasDataForReferenceSequence
|
|
366
|
-
|
|
367
|
-
##### Parameters
|
|
368
|
-
|
|
369
|
-
- `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
370
|
-
|
|
371
|
-
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** true if the index contains entries for
|
|
372
|
-
the given reference sequence ID, false otherwise
|
|
373
|
-
|
|
374
|
-
#### getEntriesForRange
|
|
375
|
-
|
|
376
|
-
fetch index entries for the given range
|
|
377
|
-
|
|
378
|
-
##### Parameters
|
|
379
|
-
|
|
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)**
|
|
383
|
-
|
|
384
|
-
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise for
|
|
385
|
-
an array of objects of the form
|
|
386
|
-
`{start, span, containerStart, sliceStart, sliceBytes }`
|
|
165
|
+
#### Table of Contents
|
|
387
166
|
|
|
388
167
|
### CramUnimplementedError
|
|
389
168
|
|
package/dist/craiIndex.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { CramFileSource } from './cramFile/file';
|
|
2
|
-
export
|
|
2
|
+
export type Slice = {
|
|
3
3
|
start: number;
|
|
4
4
|
span: number;
|
|
5
5
|
containerStart: number;
|
|
6
6
|
sliceStart: number;
|
|
7
7
|
sliceBytes: number;
|
|
8
8
|
};
|
|
9
|
-
|
|
9
|
+
type ParsedIndex = Record<string, Slice[]>;
|
|
10
10
|
export default class CraiIndex {
|
|
11
11
|
private _parseCache;
|
|
12
12
|
private filehandle;
|