@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.
Files changed (209) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/README.md +126 -154
  3. package/dist/craiIndex.d.ts +37 -0
  4. package/dist/craiIndex.js +198 -365
  5. package/dist/craiIndex.js.map +1 -0
  6. package/dist/cram-bundle.js +8 -6
  7. package/dist/cramFile/codecs/_base.d.ts +6 -0
  8. package/dist/cramFile/codecs/_base.js +44 -53
  9. package/dist/cramFile/codecs/_base.js.map +1 -0
  10. package/dist/cramFile/codecs/beta.d.ts +4 -0
  11. package/dist/cramFile/codecs/beta.js +38 -48
  12. package/dist/cramFile/codecs/beta.js.map +1 -0
  13. package/dist/cramFile/codecs/byteArrayLength.d.ts +8 -0
  14. package/dist/cramFile/codecs/byteArrayLength.js +58 -78
  15. package/dist/cramFile/codecs/byteArrayLength.js.map +1 -0
  16. package/dist/cramFile/codecs/byteArrayStop.d.ts +6 -0
  17. package/dist/cramFile/codecs/byteArrayStop.js +62 -76
  18. package/dist/cramFile/codecs/byteArrayStop.js.map +1 -0
  19. package/dist/cramFile/codecs/external.d.ts +7 -0
  20. package/dist/cramFile/codecs/external.js +63 -81
  21. package/dist/cramFile/codecs/external.js.map +1 -0
  22. package/dist/cramFile/codecs/gamma.d.ts +4 -0
  23. package/dist/cramFile/codecs/gamma.js +43 -56
  24. package/dist/cramFile/codecs/gamma.js.map +1 -0
  25. package/dist/cramFile/codecs/huffman.d.ts +17 -0
  26. package/dist/cramFile/codecs/huffman.js +126 -199
  27. package/dist/cramFile/codecs/huffman.js.map +1 -0
  28. package/dist/cramFile/codecs/index.d.ts +2 -0
  29. package/dist/cramFile/codecs/index.js +31 -38
  30. package/dist/cramFile/codecs/index.js.map +1 -0
  31. package/dist/cramFile/codecs/subexp.d.ts +4 -0
  32. package/dist/cramFile/codecs/subexp.js +51 -64
  33. package/dist/cramFile/codecs/subexp.js.map +1 -0
  34. package/dist/cramFile/constants.d.ts +36 -0
  35. package/dist/cramFile/constants.js +52 -50
  36. package/dist/cramFile/constants.js.map +1 -0
  37. package/dist/cramFile/container/compressionScheme.d.ts +23 -0
  38. package/dist/cramFile/container/compressionScheme.js +115 -153
  39. package/dist/cramFile/container/compressionScheme.js.map +1 -0
  40. package/dist/cramFile/container/index.d.ts +13 -0
  41. package/dist/cramFile/container/index.js +169 -283
  42. package/dist/cramFile/container/index.js.map +1 -0
  43. package/dist/cramFile/file.d.ts +63 -0
  44. package/dist/cramFile/file.js +440 -735
  45. package/dist/cramFile/file.js.map +1 -0
  46. package/dist/cramFile/index.d.ts +2 -0
  47. package/dist/cramFile/index.js +7 -4
  48. package/dist/cramFile/index.js.map +1 -0
  49. package/dist/cramFile/record.d.ts +79 -0
  50. package/dist/cramFile/record.js +253 -308
  51. package/dist/cramFile/record.js.map +1 -0
  52. package/dist/cramFile/sectionParsers.d.ts +18 -0
  53. package/dist/cramFile/sectionParsers.js +324 -362
  54. package/dist/cramFile/sectionParsers.js.map +1 -0
  55. package/dist/cramFile/slice/decodeRecord.d.ts +2 -0
  56. package/dist/cramFile/slice/decodeRecord.js +278 -298
  57. package/dist/cramFile/slice/decodeRecord.js.map +1 -0
  58. package/dist/cramFile/slice/index.d.ts +20 -0
  59. package/dist/cramFile/slice/index.js +488 -789
  60. package/dist/cramFile/slice/index.js.map +1 -0
  61. package/dist/cramFile/util.d.ts +5 -0
  62. package/dist/cramFile/util.js +158 -144
  63. package/dist/cramFile/util.js.map +1 -0
  64. package/dist/errors.d.ts +23 -0
  65. package/dist/errors.js +66 -103
  66. package/dist/errors.js.map +1 -0
  67. package/dist/index.d.ts +4 -0
  68. package/dist/index.js +12 -12
  69. package/dist/index.js.map +1 -0
  70. package/dist/indexedCramFile.d.ts +39 -0
  71. package/dist/indexedCramFile.js +213 -315
  72. package/dist/indexedCramFile.js.map +1 -0
  73. package/dist/io/bufferCache.d.ts +12 -0
  74. package/dist/io/bufferCache.js +108 -128
  75. package/dist/io/bufferCache.js.map +1 -0
  76. package/dist/io/index.d.ts +5 -0
  77. package/dist/io/index.js +29 -27
  78. package/dist/io/index.js.map +1 -0
  79. package/dist/io/localFile.d.ts +10 -0
  80. package/dist/io/localFile.js +105 -162
  81. package/dist/io/localFile.js.map +1 -0
  82. package/dist/io/remoteFile.d.ts +16 -0
  83. package/dist/io/remoteFile.js +137 -206
  84. package/dist/io/remoteFile.js.map +1 -0
  85. package/dist/rans/constants.d.ts +3 -0
  86. package/dist/rans/constants.js +6 -6
  87. package/dist/rans/constants.js.map +1 -0
  88. package/dist/rans/d04.d.ts +1 -0
  89. package/dist/rans/d04.js +70 -99
  90. package/dist/rans/d04.js.map +1 -0
  91. package/dist/rans/d14.d.ts +1 -0
  92. package/dist/rans/d14.js +55 -93
  93. package/dist/rans/d14.js.map +1 -0
  94. package/dist/rans/decoding.d.ts +30 -0
  95. package/dist/rans/decoding.js +112 -159
  96. package/dist/rans/decoding.js.map +1 -0
  97. package/dist/rans/frequencies.d.ts +2 -0
  98. package/dist/rans/frequencies.js +110 -119
  99. package/dist/rans/frequencies.js.map +1 -0
  100. package/dist/rans/index.d.ts +1 -0
  101. package/dist/rans/index.js +111 -174
  102. package/dist/rans/index.js.map +1 -0
  103. package/dist/sam.d.ts +1 -0
  104. package/dist/sam.js +16 -41
  105. package/dist/sam.js.map +1 -0
  106. package/errors.js +66 -103
  107. package/esm/craiIndex.d.ts +37 -0
  108. package/esm/craiIndex.js +160 -0
  109. package/esm/craiIndex.js.map +1 -0
  110. package/esm/cramFile/codecs/_base.d.ts +6 -0
  111. package/esm/cramFile/codecs/_base.js +42 -0
  112. package/esm/cramFile/codecs/_base.js.map +1 -0
  113. package/esm/cramFile/codecs/beta.d.ts +4 -0
  114. package/esm/cramFile/codecs/beta.js +15 -0
  115. package/esm/cramFile/codecs/beta.js.map +1 -0
  116. package/esm/cramFile/codecs/byteArrayLength.d.ts +8 -0
  117. package/esm/cramFile/codecs/byteArrayLength.js +35 -0
  118. package/esm/cramFile/codecs/byteArrayLength.js.map +1 -0
  119. package/esm/cramFile/codecs/byteArrayStop.d.ts +6 -0
  120. package/esm/cramFile/codecs/byteArrayStop.js +40 -0
  121. package/esm/cramFile/codecs/byteArrayStop.js.map +1 -0
  122. package/esm/cramFile/codecs/external.d.ts +7 -0
  123. package/esm/cramFile/codecs/external.js +40 -0
  124. package/esm/cramFile/codecs/external.js.map +1 -0
  125. package/esm/cramFile/codecs/gamma.d.ts +4 -0
  126. package/esm/cramFile/codecs/gamma.js +20 -0
  127. package/esm/cramFile/codecs/gamma.js.map +1 -0
  128. package/esm/cramFile/codecs/huffman.d.ts +17 -0
  129. package/esm/cramFile/codecs/huffman.js +107 -0
  130. package/esm/cramFile/codecs/huffman.js.map +1 -0
  131. package/esm/cramFile/codecs/index.d.ts +2 -0
  132. package/esm/cramFile/codecs/index.js +30 -0
  133. package/esm/cramFile/codecs/index.js.map +1 -0
  134. package/esm/cramFile/codecs/subexp.d.ts +4 -0
  135. package/esm/cramFile/codecs/subexp.js +28 -0
  136. package/esm/cramFile/codecs/subexp.js.map +1 -0
  137. package/esm/cramFile/constants.d.ts +36 -0
  138. package/esm/cramFile/constants.js +51 -0
  139. package/esm/cramFile/constants.js.map +1 -0
  140. package/esm/cramFile/container/compressionScheme.d.ts +23 -0
  141. package/esm/cramFile/container/compressionScheme.js +123 -0
  142. package/esm/cramFile/container/compressionScheme.js.map +1 -0
  143. package/esm/cramFile/container/index.d.ts +13 -0
  144. package/esm/cramFile/container/index.js +84 -0
  145. package/esm/cramFile/container/index.js.map +1 -0
  146. package/esm/cramFile/file.d.ts +63 -0
  147. package/esm/cramFile/file.js +281 -0
  148. package/esm/cramFile/file.js.map +1 -0
  149. package/esm/cramFile/index.d.ts +2 -0
  150. package/esm/cramFile/index.js +3 -0
  151. package/esm/cramFile/index.js.map +1 -0
  152. package/esm/cramFile/record.d.ts +79 -0
  153. package/esm/cramFile/record.js +297 -0
  154. package/esm/cramFile/record.js.map +1 -0
  155. package/esm/cramFile/sectionParsers.d.ts +18 -0
  156. package/esm/cramFile/sectionParsers.js +347 -0
  157. package/esm/cramFile/sectionParsers.js.map +1 -0
  158. package/esm/cramFile/slice/decodeRecord.d.ts +2 -0
  159. package/esm/cramFile/slice/decodeRecord.js +299 -0
  160. package/esm/cramFile/slice/decodeRecord.js.map +1 -0
  161. package/esm/cramFile/slice/index.d.ts +20 -0
  162. package/esm/cramFile/slice/index.js +364 -0
  163. package/esm/cramFile/slice/index.js.map +1 -0
  164. package/esm/cramFile/util.d.ts +5 -0
  165. package/esm/cramFile/util.js +161 -0
  166. package/esm/cramFile/util.js.map +1 -0
  167. package/esm/errors.d.ts +23 -0
  168. package/esm/errors.js +24 -0
  169. package/esm/errors.js.map +1 -0
  170. package/esm/index.d.ts +4 -0
  171. package/esm/index.js +5 -0
  172. package/esm/index.js.map +1 -0
  173. package/esm/indexedCramFile.d.ts +39 -0
  174. package/esm/indexedCramFile.js +155 -0
  175. package/esm/indexedCramFile.js.map +1 -0
  176. package/esm/io/bufferCache.d.ts +12 -0
  177. package/esm/io/bufferCache.js +54 -0
  178. package/esm/io/bufferCache.js.map +1 -0
  179. package/esm/io/index.d.ts +5 -0
  180. package/esm/io/index.js +24 -0
  181. package/esm/io/index.js.map +1 -0
  182. package/esm/io/localFile.d.ts +10 -0
  183. package/esm/io/localFile.js +31 -0
  184. package/esm/io/localFile.js.map +1 -0
  185. package/esm/io/remoteFile.d.ts +16 -0
  186. package/esm/io/remoteFile.js +64 -0
  187. package/esm/io/remoteFile.js.map +1 -0
  188. package/esm/rans/constants.d.ts +3 -0
  189. package/esm/rans/constants.js +5 -0
  190. package/esm/rans/constants.js.map +1 -0
  191. package/esm/rans/d04.d.ts +1 -0
  192. package/esm/rans/d04.js +67 -0
  193. package/esm/rans/d04.js.map +1 -0
  194. package/esm/rans/d14.d.ts +1 -0
  195. package/esm/rans/d14.js +52 -0
  196. package/esm/rans/d14.js.map +1 -0
  197. package/esm/rans/decoding.d.ts +30 -0
  198. package/esm/rans/decoding.js +118 -0
  199. package/esm/rans/decoding.js.map +1 -0
  200. package/esm/rans/frequencies.d.ts +2 -0
  201. package/esm/rans/frequencies.js +110 -0
  202. package/esm/rans/frequencies.js.map +1 -0
  203. package/esm/rans/index.d.ts +1 -0
  204. package/esm/rans/index.js +195 -0
  205. package/esm/rans/index.js.map +1 -0
  206. package/esm/sam.d.ts +1 -0
  207. package/esm/sam.js +16 -0
  208. package/esm/sam.js.map +1 -0
  209. 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
- [![Generated with nod](https://img.shields.io/badge/generator-nod-2196F3.svg?style=flat-square)](https://github.com/diegohaz/nod)
4
3
  [![NPM version](https://img.shields.io/npm/v/@gmod/cram.svg?style=flat-square)](https://npmjs.org/package/@gmod/cram)
5
- [![Build Status](https://img.shields.io/travis/GMOD/cram-js/master.svg?style=flat-square)](https://travis-ci.org/GMOD/cram-js) [![Coverage Status](https://img.shields.io/codecov/c/github/GMOD/cram-js/master.svg?style=flat-square)](https://codecov.io/gh/GMOD/cram-js/branch/master) [![Greenkeeper badge](https://badges.greenkeeper.io/GMOD/cram-js.svg)](https://greenkeeper.io/)
4
+ [![Coverage Status](https://img.shields.io/codecov/c/github/GMOD/cram-js/master.svg?style=flat-square)](https://codecov.io/gh/GMOD/cram-js/branch/master)
5
+ [![Build Status](https://img.shields.io/github/workflow/status/GMOD/cram-js/Push/master?logo=github\&style=flat-query)](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
- - Reads CRAM 3.x and 2.x
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
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 seq = await t.getSequence(seqId, start-1, end)
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.forEach(({ code, pos, refPos, ref, sub }) => {
64
- // process the "read features". this can be used similar to
65
- // CIGAR/MD strings in SAM. see CRAM specs for more details.
66
- if (code === 'X')
67
- console.log(
68
- `${
69
- record.readName
70
- } shows a base substitution of ${ref}->${sub} at ${refPos}`,
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
- - [CramRecord](#cramrecord) - format of CRAM records returned by this API
86
- - [ReadFeatures](#readfeatures) - format of read features on records
87
- - [IndexedCramFile](#indexedcramfile) - indexed access into a CRAM file
88
- - [CramFile](#cramfile) - .cram API
89
- - [CraiIndex](#craiindex) - .crai index API
90
- - [Error Classes](#error-classes) - special error classes thrown by this API
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
- #### Methods
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
- **Parameters**
210
+ ###### Parameters
211
+
212
+ * `refRegion` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
201
213
 
202
- - `refRegion` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
203
- - `refRegion.start` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
204
- - `refRegion.end` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
205
- - `refRegion.seq` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
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
- - **code** (`character`): One of "bqBXIDiQNSPH". See page 15 of the CRAM v3 spec for their meanings.
217
- - **data** (`any`): the data associated with the feature. The format of this varies depending on the feature code.
218
- - **pos** (`number`): location relative to the read (1-based)
219
- - **refPos** (`number`): location relative to the reference (1-based)
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
- - [constructor](#constructor)
230
- - [getRecordsForRange](#getrecordsforrange)
231
- - [hasDataForReferenceSequence](#hasdataforreferencesequence)
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
- **Parameters**
247
+ ##### Parameters
248
+
249
+ * `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
236
250
 
237
- - `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
238
- - `args.cram` **CramFile**
239
- - `args.index` **Index-like** object that supports getEntriesForRange(seqId,start,end) -> Promise\[Array[index entries]]
240
- - `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
241
- - `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.
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
- **Parameters**
260
+ ##### Parameters
248
261
 
249
- - `seq` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** numeric ID of the reference sequence
250
- - `start` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** start of the range of interest. 1-based closed coordinates.
251
- - `end` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** end of the range of interest. 1-based closed coordinates.
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
- **Parameters**
269
+ ##### Parameters
256
270
 
257
- - `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
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
- - [constructor](#constructor)
269
- - [containerCount](#containercount)
282
+ * [constructor](#constructor)
283
+ * [Parameters](#parameters)
284
+ * [containerCount](#containercount)
270
285
 
271
286
  #### constructor
272
287
 
273
- **Parameters**
288
+ ##### Parameters
289
+
290
+ * `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
274
291
 
275
- - `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
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
- - `args.path` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** path to the cram file
279
- - `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
280
- - `args.seqFetch` **[function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** a function with signature
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
- - `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
283
- - `args.checkSequenceMD5` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** default true. if false, disables verifying the MD5
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
- - [constructor](#constructor)
299
- - [hasDataForReferenceSequence](#hasdataforreferencesequence)
300
- - [getEntriesForRange](#getentriesforrange)
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
- **Parameters**
319
+ ##### Parameters
320
+
321
+ * `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
305
322
 
306
- - `args` **[object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
307
- - `args.path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
308
- - `args.url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
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
- **Parameters**
329
+ ##### Parameters
314
330
 
315
- - `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
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
- **Parameters**
340
+ ##### Parameters
325
341
 
326
- - `seqId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
327
- - `queryStart` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
328
- - `queryEnd` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
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";