@gmod/cram 1.5.6 → 1.6.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 +82 -0
- package/README.md +126 -154
- package/dist/craiIndex.d.ts +37 -0
- package/dist/craiIndex.js +198 -365
- package/dist/craiIndex.js.map +1 -0
- package/dist/cram-bundle.js +8 -6
- 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 -735
- 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/errors.js +66 -103
- package/esm/craiIndex.d.ts +37 -0
- package/esm/craiIndex.js +160 -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/package.json +34 -35
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# v1.6.0
|
|
2
|
+
|
|
3
|
+
- Support CRAMv3.1
|
|
4
|
+
- Support bzip codex
|
|
5
|
+
- Remove localFile from the browser bundle using "browser" package.json field
|
|
6
|
+
- Add esm module field in package.json
|
|
7
|
+
|
|
8
|
+
# v1.5.9
|
|
9
|
+
|
|
10
|
+
- Fix CRAM not downloading proper records for long reads (pt2, PR #84)
|
|
11
|
+
|
|
12
|
+
# v1.5.8
|
|
13
|
+
|
|
14
|
+
- Fix CRAM not downloading proper records for long reads (pt1, PR #85)
|
|
15
|
+
|
|
16
|
+
# v1.5.7
|
|
17
|
+
|
|
18
|
+
- Add getHeaderText to CRAM to get SAM header
|
|
19
|
+
|
|
20
|
+
# v1.5.6
|
|
21
|
+
|
|
22
|
+
- Remove unnecessary rethor win tinyMemoize error handler
|
|
23
|
+
- Avoid uncaught promise from constructor
|
|
24
|
+
|
|
25
|
+
# v1.5.5
|
|
26
|
+
|
|
27
|
+
- Fix ability to reload CRAM file after failure
|
|
28
|
+
- Check if BAI file incorrectly submitted as index for CRAM
|
|
29
|
+
|
|
30
|
+
# v1.5.4
|
|
31
|
+
|
|
32
|
+
- Fix handling of hard clipping
|
|
33
|
+
|
|
34
|
+
# v1.5.3
|
|
35
|
+
|
|
36
|
+
- Improved README
|
|
37
|
+
- Upgrade to babel 7
|
|
38
|
+
- Upgrade @gmod/binary-parser
|
|
39
|
+
- Add fix for 'b', 'q', and 'Q' readFeatures
|
|
40
|
+
|
|
41
|
+
# v1.5.2
|
|
42
|
+
|
|
43
|
+
- Fix off-by-one error in range query
|
|
44
|
+
- Add webpack cram-bundle.js
|
|
45
|
+
|
|
46
|
+
# v1.5.1
|
|
47
|
+
|
|
48
|
+
- Add fix for when mate is unmapped
|
|
49
|
+
|
|
50
|
+
# v1.5.0
|
|
51
|
+
|
|
52
|
+
- Add lossy-names support
|
|
53
|
+
- Fix for mate strand
|
|
54
|
+
|
|
55
|
+
# v1.4.3
|
|
56
|
+
|
|
57
|
+
- Make sure mate exists for unmated pair, can exist when coordinate slices of cram file are made via samtools view
|
|
58
|
+
|
|
59
|
+
# v1.4.2
|
|
60
|
+
|
|
61
|
+
- Switch to es6-promisify for ie11
|
|
62
|
+
- Switch to quick-lru instead of lru-cache for ie11
|
|
63
|
+
|
|
64
|
+
# v1.4.1
|
|
65
|
+
|
|
66
|
+
- Add maxInsertSize for viewAsPairs
|
|
67
|
+
|
|
68
|
+
# v1.4.0
|
|
69
|
+
|
|
70
|
+
- Add viewAsPairs implementation
|
|
71
|
+
|
|
72
|
+
# v1.3.0
|
|
73
|
+
|
|
74
|
+
- Fix tests in node 6
|
|
75
|
+
- Make cram record unique IDs start at 1 instead of 0 to always be truthy
|
|
76
|
+
- Implement gamma and subexp codecs
|
|
77
|
+
|
|
78
|
+
# v1.2.0
|
|
79
|
+
|
|
80
|
+
- Add `getReadBases` docs
|
|
81
|
+
- Rewrite seq calculation to be much faster
|
|
82
|
+
- Implement ref fetching for multi-ref slices
|
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# @gmod/cram
|
|
2
2
|
|
|
3
|
-
[](https://github.com/diegohaz/nod)
|
|
4
3
|
[](https://npmjs.org/package/@gmod/cram)
|
|
5
|
-
[](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 included)
|
|
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 not implement bzip2 or lzma codecs (yet), as these are rarely used in-the-wild; if this is important to your use case, please file an issue
|
|
13
13
|
|
|
14
14
|
## Install
|
|
15
15
|
|
|
@@ -25,7 +25,7 @@ $ yarn add @gmod/cram
|
|
|
25
25
|
const { IndexedCramFile, CramFile, CraiIndex } = require('@gmod/cram')
|
|
26
26
|
|
|
27
27
|
//Use indexedfasta library for seqFetch, if using local file (see below)
|
|
28
|
-
const { IndexedFasta, BgzipIndexedFasta } = require('@gmod/indexedfasta')
|
|
28
|
+
const { IndexedFasta, BgzipIndexedFasta } = require('@gmod/indexedfasta')
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
const t = new IndexedFasta({
|
|
@@ -38,21 +38,21 @@ const t = new IndexedFasta({
|
|
|
38
38
|
const indexedFile = new IndexedCramFile({
|
|
39
39
|
cramPath: '/filesystem/yourfile.cram',
|
|
40
40
|
index: new CraiIndex({
|
|
41
|
-
path: '/filesystem/yourfile.cram.crai'
|
|
41
|
+
path: '/filesystem/yourfile.cram.crai',
|
|
42
42
|
}),
|
|
43
43
|
seqFetch: async (seqId, start, end) => {
|
|
44
|
-
// note:
|
|
44
|
+
// note:
|
|
45
45
|
// * seqFetch should return a promise for a string, in this instance retrieved from IndexedFasta
|
|
46
46
|
// * we use start-1 because cram-js uses 1-based but IndexedFasta uses 0-based coordinates
|
|
47
47
|
// * the seqId is a numeric identifier
|
|
48
|
-
return
|
|
49
|
-
|
|
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
50
|
},
|
|
51
51
|
checkSequenceMD5: false,
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
// example of fetching records from an indexed CRAM file.
|
|
55
|
-
// NOTE: only numeric IDs for the reference sequence are accepted.
|
|
55
|
+
// NOTE: only numeric IDs for the reference sequence are accepted.
|
|
56
56
|
// For indexedfasta the numeric ID is the order in which the sequence names appear in the header
|
|
57
57
|
|
|
58
58
|
// Wrap in an async and then run
|
|
@@ -60,16 +60,19 @@ run = async() => {
|
|
|
60
60
|
const records = await indexedFile.getRecordsForRange(0, 10000, 20000)
|
|
61
61
|
records.forEach(record => {
|
|
62
62
|
console.log(`got a record named ${record.readName}`)
|
|
63
|
-
record.readFeatures
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
if(record.readFeatures != undefined) {
|
|
64
|
+
record.readFeatures.forEach(({ code, pos, refPos, ref, sub }) => {
|
|
65
|
+
// process the read features. this can be used similar to
|
|
66
|
+
// CIGAR/MD strings in SAM. see CRAM specs for more details.
|
|
67
|
+
if (code === 'X') {
|
|
68
|
+
console.log(
|
|
69
|
+
`${
|
|
70
|
+
record.readName
|
|
71
|
+
} shows a base substitution of ${ref}->${sub} at ${refPos}`,
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
}
|
|
73
76
|
})
|
|
74
77
|
}
|
|
75
78
|
|
|
@@ -82,43 +85,44 @@ run()
|
|
|
82
85
|
|
|
83
86
|
## API (auto-generated)
|
|
84
87
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
* [CramRecord](#cramrecord) - format of CRAM records returned by this API
|
|
89
|
+
* [ReadFeatures](#readfeatures) - format of read features on records
|
|
90
|
+
* [IndexedCramFile](#indexedcramfile) - indexed access into a CRAM file
|
|
91
|
+
* [CramFile](#cramfile) - .cram API
|
|
92
|
+
* [CraiIndex](#craiindex) - .crai index API
|
|
93
|
+
* [Error Classes](#error-classes) - special error classes thrown by this API
|
|
91
94
|
|
|
92
95
|
### CramRecord
|
|
93
96
|
|
|
94
|
-
These are the record objects returned by this API. Much of the data
|
|
95
|
-
is stored in them as simple object entries, but there are some accessor
|
|
96
|
-
methods used for conveniently getting the values of each of the flags in
|
|
97
|
-
the `flags` and `cramFlags` fields.
|
|
98
|
-
|
|
99
|
-
#### Static fields
|
|
100
|
-
|
|
101
|
-
- **flags** (`number`): the SAM bit-flags field, see the SAM spec for interpretation. Some of the `is*` methods below interpret this field.
|
|
102
|
-
- **cramFlags** (`number`): the CRAM-specific bit-flags field, see the CRAM spec for interpretation. Some of the `is*` methods below interpret this field.
|
|
103
|
-
- **sequenceId** (`number`): the ID number of the record's reference sequence
|
|
104
|
-
- **readLength** (`number`): length of the read in bases
|
|
105
|
-
- **alignmentStart** (`number`): start coordinate of the alignment on the reference in 1-based closed coordinates
|
|
106
|
-
- **readGroupId** (`number`): ID number of the read group, or -1 if none
|
|
107
|
-
- **readName** (`number`): name of the read (string)
|
|
108
|
-
- **templateSize** (`number`): for paired sequencing, the total size of the template
|
|
109
|
-
- **readFeatures** (`array[ReadFeature]`): array of read features showing insertions, deletions, mismatches, etc. See [ReadFeatures](#readfeatures) for their format.
|
|
110
|
-
- **lengthOnRef** (`number`): span of the alignment along the reference sequence
|
|
111
|
-
- **mappingQuality** (`number`): SAM mapping quality
|
|
112
|
-
- **qualityScores** (`array[number]`): array of numeric quality scores
|
|
113
|
-
- **uniqueId** (`number`): unique ID number of the record within the file
|
|
114
|
-
- **mate** (`object`)
|
|
115
|
-
- **flags** (`number`): CRAM mapping flags for the mate. See CRAM spec for interpretation. Some of the `is*` methods below interpret this field.
|
|
116
|
-
- **sequenceId** (`number`): reference sequence ID for the mate mapping
|
|
117
|
-
- **alignmentStart** (`number`): start coordinate of the mate mapping. 1-based coordinates.
|
|
118
|
-
|
|
119
97
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
120
98
|
|
|
121
|
-
|
|
99
|
+
##### Table of Contents
|
|
100
|
+
|
|
101
|
+
* [CramRecord](#cramrecord)
|
|
102
|
+
* [isPaired](#ispaired)
|
|
103
|
+
* [isProperlyPaired](#isproperlypaired)
|
|
104
|
+
* [isSegmentUnmapped](#issegmentunmapped)
|
|
105
|
+
* [isMateUnmapped](#ismateunmapped)
|
|
106
|
+
* [isReverseComplemented](#isreversecomplemented)
|
|
107
|
+
* [isMateReverseComplemented](#ismatereversecomplemented)
|
|
108
|
+
* [isRead1](#isread1)
|
|
109
|
+
* [isRead2](#isread2)
|
|
110
|
+
* [isSecondary](#issecondary)
|
|
111
|
+
* [isFailedQc](#isfailedqc)
|
|
112
|
+
* [isDuplicate](#isduplicate)
|
|
113
|
+
* [isSupplementary](#issupplementary)
|
|
114
|
+
* [isDetached](#isdetached)
|
|
115
|
+
* [hasMateDownStream](#hasmatedownstream)
|
|
116
|
+
* [isPreservingQualityScores](#ispreservingqualityscores)
|
|
117
|
+
* [isUnknownBases](#isunknownbases)
|
|
118
|
+
* [getReadBases](#getreadbases)
|
|
119
|
+
* [getPairOrientation](#getpairorientation)
|
|
120
|
+
* [addReferenceSequence](#addreferencesequence)
|
|
121
|
+
* [Parameters](#parameters)
|
|
122
|
+
|
|
123
|
+
#### CramRecord
|
|
124
|
+
|
|
125
|
+
Class of each CRAM record returned by this API.
|
|
122
126
|
|
|
123
127
|
##### isPaired
|
|
124
128
|
|
|
@@ -190,6 +194,12 @@ Get the original sequence of this read.
|
|
|
190
194
|
|
|
191
195
|
Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** sequence basepairs
|
|
192
196
|
|
|
197
|
+
##### getPairOrientation
|
|
198
|
+
|
|
199
|
+
Get the pair orientation of a paired read. Adapted from igv.js
|
|
200
|
+
|
|
201
|
+
Returns **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** of paired orientatin
|
|
202
|
+
|
|
193
203
|
##### addReferenceSequence
|
|
194
204
|
|
|
195
205
|
Annotates this feature with the given reference sequence basepair
|
|
@@ -197,13 +207,14 @@ information. This will add a `sub` and a `ref` item to base
|
|
|
197
207
|
subsitution read features given the actual substituted and reference
|
|
198
208
|
base pairs, and will make the `getReadSequence()` method work.
|
|
199
209
|
|
|
200
|
-
|
|
210
|
+
###### Parameters
|
|
211
|
+
|
|
212
|
+
* `refRegion` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
201
213
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
- `compressionScheme` **CramContainerCompressionScheme**
|
|
214
|
+
* `refRegion.start` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
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**
|
|
207
218
|
|
|
208
219
|
Returns **[undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)** nothing
|
|
209
220
|
|
|
@@ -213,48 +224,51 @@ The feature objects appearing in the `readFeatures` member of CramRecord objects
|
|
|
213
224
|
|
|
214
225
|
#### Static fields
|
|
215
226
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
227
|
+
* **code** (`character`): One of "bqBXIDiQNSPH". See page 15 of the CRAM v3 spec for their meanings.
|
|
228
|
+
* **data** (`any`): the data associated with the feature. The format of this varies depending on the feature code.
|
|
229
|
+
* **pos** (`number`): location relative to the read (1-based)
|
|
230
|
+
* **refPos** (`number`): location relative to the reference (1-based)
|
|
220
231
|
|
|
221
232
|
### IndexedCramFile
|
|
222
233
|
|
|
223
|
-
The pairing of an index and a CramFile. Supports efficient fetching of records for sections of reference sequences.
|
|
224
|
-
|
|
225
234
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
226
235
|
|
|
227
236
|
##### Table of Contents
|
|
228
237
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
238
|
+
* [constructor](#constructor)
|
|
239
|
+
* [Parameters](#parameters)
|
|
240
|
+
* [getRecordsForRange](#getrecordsforrange)
|
|
241
|
+
* [Parameters](#parameters-1)
|
|
242
|
+
* [hasDataForReferenceSequence](#hasdataforreferencesequence)
|
|
243
|
+
* [Parameters](#parameters-2)
|
|
232
244
|
|
|
233
245
|
#### constructor
|
|
234
246
|
|
|
235
|
-
|
|
247
|
+
##### Parameters
|
|
248
|
+
|
|
249
|
+
* `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
236
250
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
- `args.checkSequenceMD5` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** default true. if false, disables verifying the MD5
|
|
251
|
+
* `args.cram` **CramFile**
|
|
252
|
+
* `args.index` **Index-like** object that supports getEntriesForRange(seqId,start,end) -> Promise\[Array\[index entries]]
|
|
253
|
+
* `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
|
|
254
|
+
* `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.
|
|
255
|
+
* `args.checkSequenceMD5` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** default true. if false, disables verifying the MD5
|
|
243
256
|
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.
|
|
244
257
|
|
|
245
258
|
#### getRecordsForRange
|
|
246
259
|
|
|
247
|
-
|
|
260
|
+
##### Parameters
|
|
248
261
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
262
|
+
* `seq` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** numeric ID of the reference sequence
|
|
263
|
+
* `start` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** start of the range of interest. 1-based closed coordinates.
|
|
264
|
+
* `end` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** end of the range of interest. 1-based closed coordinates.
|
|
265
|
+
* `opts` (optional, default `{}`)
|
|
252
266
|
|
|
253
267
|
#### hasDataForReferenceSequence
|
|
254
268
|
|
|
255
|
-
|
|
269
|
+
##### Parameters
|
|
256
270
|
|
|
257
|
-
|
|
271
|
+
* `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
258
272
|
|
|
259
273
|
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** true if the CRAM file contains data for the given
|
|
260
274
|
reference sequence numerical ID
|
|
@@ -265,54 +279,56 @@ reference sequence numerical ID
|
|
|
265
279
|
|
|
266
280
|
##### Table of Contents
|
|
267
281
|
|
|
268
|
-
|
|
269
|
-
|
|
282
|
+
* [constructor](#constructor)
|
|
283
|
+
* [Parameters](#parameters)
|
|
284
|
+
* [containerCount](#containercount)
|
|
270
285
|
|
|
271
286
|
#### constructor
|
|
272
287
|
|
|
273
|
-
|
|
288
|
+
##### Parameters
|
|
289
|
+
|
|
290
|
+
* `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
274
291
|
|
|
275
|
-
|
|
276
|
-
- `args.filehandle` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** a filehandle that implements the stat() and
|
|
292
|
+
* `args.filehandle` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** a filehandle that implements the stat() and
|
|
277
293
|
read() methods of the Node filehandle API <https://nodejs.org/api/fs.html#fs_class_filehandle>
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
294
|
+
* `args.path` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** path to the cram file
|
|
295
|
+
* `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
|
|
296
|
+
* `args.seqFetch` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** a function with signature
|
|
281
297
|
`(seqId, startCoordinate, endCoordinate)` that returns a promise for a string of sequence bases
|
|
282
|
-
|
|
283
|
-
|
|
298
|
+
* `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
|
|
299
|
+
* `args.checkSequenceMD5` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** default true. if false, disables verifying the MD5
|
|
284
300
|
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.
|
|
285
301
|
|
|
286
302
|
#### containerCount
|
|
287
303
|
|
|
288
|
-
Returns **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** the number of containers in the file
|
|
289
|
-
|
|
290
304
|
### CraiIndex
|
|
291
305
|
|
|
292
|
-
Represents a .crai index.
|
|
293
|
-
|
|
294
306
|
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
295
307
|
|
|
296
308
|
##### Table of Contents
|
|
297
309
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
310
|
+
* [constructor](#constructor)
|
|
311
|
+
* [Parameters](#parameters)
|
|
312
|
+
* [hasDataForReferenceSequence](#hasdataforreferencesequence)
|
|
313
|
+
* [Parameters](#parameters-1)
|
|
314
|
+
* [getEntriesForRange](#getentriesforrange)
|
|
315
|
+
* [Parameters](#parameters-2)
|
|
301
316
|
|
|
302
317
|
#### constructor
|
|
303
318
|
|
|
304
|
-
|
|
319
|
+
##### Parameters
|
|
320
|
+
|
|
321
|
+
* `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
|
|
305
322
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
- `args.filehandle` **FileHandle?**
|
|
323
|
+
* `args.path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
|
|
324
|
+
* `args.url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
|
|
325
|
+
* `args.filehandle` **FileHandle?**
|
|
310
326
|
|
|
311
327
|
#### hasDataForReferenceSequence
|
|
312
328
|
|
|
313
|
-
|
|
329
|
+
##### Parameters
|
|
314
330
|
|
|
315
|
-
|
|
331
|
+
* `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
316
332
|
|
|
317
333
|
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** true if the index contains entries for
|
|
318
334
|
the given reference sequence ID, false otherwise
|
|
@@ -321,60 +337,16 @@ the given reference sequence ID, false otherwise
|
|
|
321
337
|
|
|
322
338
|
fetch index entries for the given range
|
|
323
339
|
|
|
324
|
-
|
|
340
|
+
##### Parameters
|
|
325
341
|
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
342
|
+
* `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
343
|
+
* `queryStart` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
344
|
+
* `queryEnd` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
|
|
329
345
|
|
|
330
346
|
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** promise for
|
|
331
347
|
an array of objects of the form
|
|
332
348
|
`{start, span, containerStart, sliceStart, sliceBytes }`
|
|
333
349
|
|
|
334
|
-
#### Error Classes
|
|
335
|
-
|
|
336
|
-
`@gmod/cram/errors` contains some special error classes thrown by cram-js. A list of the error classes is below.
|
|
337
|
-
|
|
338
|
-
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
339
|
-
|
|
340
|
-
##### Table of Contents
|
|
341
|
-
|
|
342
|
-
- [CramUnimplementedError](#cramunimplementederror)
|
|
343
|
-
- [CramMalformedError](#crammalformederror)
|
|
344
|
-
- [CramBufferOverrunError](#crambufferoverrunerror)
|
|
345
|
-
- [CramSizeLimitError](#cramsizelimiterror)
|
|
346
|
-
- [CramArgumentError](#cramargumenterror)
|
|
347
|
-
|
|
348
|
-
#### CramUnimplementedError
|
|
349
|
-
|
|
350
|
-
**Extends Error**
|
|
351
|
-
|
|
352
|
-
Error caused by encountering a part of the CRAM spec that has not yet been implemented
|
|
353
|
-
|
|
354
|
-
#### CramMalformedError
|
|
355
|
-
|
|
356
|
-
**Extends CramError**
|
|
357
|
-
|
|
358
|
-
An error caused by malformed data.
|
|
359
|
-
|
|
360
|
-
#### CramBufferOverrunError
|
|
361
|
-
|
|
362
|
-
**Extends CramMalformedError**
|
|
363
|
-
|
|
364
|
-
An error caused by attempting to read beyond the end of the defined data.
|
|
365
|
-
|
|
366
|
-
#### CramSizeLimitError
|
|
367
|
-
|
|
368
|
-
**Extends CramError**
|
|
369
|
-
|
|
370
|
-
An error caused by data being too big, exceeding a size limit.
|
|
371
|
-
|
|
372
|
-
#### CramArgumentError
|
|
373
|
-
|
|
374
|
-
**Extends CramError**
|
|
375
|
-
|
|
376
|
-
An invalid argument was supplied to a cram-js method or object.
|
|
377
|
-
|
|
378
350
|
### CramUnimplementedError
|
|
379
351
|
|
|
380
352
|
**Extends Error**
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export default class CraiIndex {
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {object} args
|
|
5
|
+
* @param {string} [args.path]
|
|
6
|
+
* @param {string} [args.url]
|
|
7
|
+
* @param {FileHandle} [args.filehandle]
|
|
8
|
+
*/
|
|
9
|
+
constructor(args: {
|
|
10
|
+
path?: string | undefined;
|
|
11
|
+
url?: string | undefined;
|
|
12
|
+
filehandle?: any;
|
|
13
|
+
});
|
|
14
|
+
_parseCache: AbortablePromiseCache<any, any>;
|
|
15
|
+
readFile: any;
|
|
16
|
+
parseIndex(): any;
|
|
17
|
+
getIndex(opts?: {}): Promise<any>;
|
|
18
|
+
/**
|
|
19
|
+
* @param {number} seqId
|
|
20
|
+
* @returns {Promise} true if the index contains entries for
|
|
21
|
+
* the given reference sequence ID, false otherwise
|
|
22
|
+
*/
|
|
23
|
+
hasDataForReferenceSequence(seqId: number): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* fetch index entries for the given range
|
|
26
|
+
*
|
|
27
|
+
* @param {number} seqId
|
|
28
|
+
* @param {number} queryStart
|
|
29
|
+
* @param {number} queryEnd
|
|
30
|
+
*
|
|
31
|
+
* @returns {Promise} promise for
|
|
32
|
+
* an array of objects of the form
|
|
33
|
+
* `{start, span, containerStart, sliceStart, sliceBytes }`
|
|
34
|
+
*/
|
|
35
|
+
getEntriesForRange(seqId: number, queryStart: number, queryEnd: number): Promise<any>;
|
|
36
|
+
}
|
|
37
|
+
import AbortablePromiseCache from "abortable-promise-cache";
|