@gmod/cram 4.0.9 → 5.0.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 (246) hide show
  1. package/README.md +6 -6
  2. package/dist/craiIndex.d.ts +1 -1
  3. package/dist/craiIndex.js +7 -7
  4. package/dist/craiIndex.js.map +1 -1
  5. package/dist/cram-bundle.js +1 -2
  6. package/dist/cramFile/codecs/_base.d.ts +3 -3
  7. package/dist/cramFile/codecs/beta.d.ts +5 -5
  8. package/dist/cramFile/codecs/beta.js +7 -7
  9. package/dist/cramFile/codecs/beta.js.map +1 -1
  10. package/dist/cramFile/codecs/byteArrayLength.d.ts +5 -5
  11. package/dist/cramFile/codecs/byteArrayLength.js +4 -4
  12. package/dist/cramFile/codecs/byteArrayLength.js.map +1 -1
  13. package/dist/cramFile/codecs/byteArrayStop.d.ts +5 -5
  14. package/dist/cramFile/codecs/byteArrayStop.js +7 -7
  15. package/dist/cramFile/codecs/byteArrayStop.js.map +1 -1
  16. package/dist/cramFile/codecs/dataSeriesTypes.d.ts +1 -1
  17. package/dist/cramFile/codecs/external.d.ts +5 -5
  18. package/dist/cramFile/codecs/external.js +12 -11
  19. package/dist/cramFile/codecs/external.js.map +1 -1
  20. package/dist/cramFile/codecs/gamma.d.ts +5 -5
  21. package/dist/cramFile/codecs/gamma.js +8 -8
  22. package/dist/cramFile/codecs/gamma.js.map +1 -1
  23. package/dist/cramFile/codecs/huffman.d.ts +6 -6
  24. package/dist/cramFile/codecs/huffman.js +9 -9
  25. package/dist/cramFile/codecs/huffman.js.map +1 -1
  26. package/dist/cramFile/codecs/index.d.ts +3 -3
  27. package/dist/cramFile/codecs/index.js +16 -16
  28. package/dist/cramFile/codecs/index.js.map +1 -1
  29. package/dist/cramFile/codecs/subexp.d.ts +5 -5
  30. package/dist/cramFile/codecs/subexp.js +9 -9
  31. package/dist/cramFile/codecs/subexp.js.map +1 -1
  32. package/dist/cramFile/container/compressionScheme.d.ts +4 -4
  33. package/dist/cramFile/container/compressionScheme.js +5 -5
  34. package/dist/cramFile/container/compressionScheme.js.map +1 -1
  35. package/dist/cramFile/container/index.d.ts +8 -8
  36. package/dist/cramFile/container/index.js +15 -16
  37. package/dist/cramFile/container/index.js.map +1 -1
  38. package/dist/cramFile/file.d.ts +3 -3
  39. package/dist/cramFile/file.js +29 -38
  40. package/dist/cramFile/file.js.map +1 -1
  41. package/dist/cramFile/index.d.ts +2 -2
  42. package/dist/cramFile/index.js +4 -4
  43. package/dist/cramFile/index.js.map +1 -1
  44. package/dist/cramFile/record.d.ts +2 -2
  45. package/dist/cramFile/record.js +17 -17
  46. package/dist/cramFile/record.js.map +1 -1
  47. package/dist/cramFile/sectionParsers.d.ts +3 -3
  48. package/dist/cramFile/sectionParsers.js +56 -56
  49. package/dist/cramFile/sectionParsers.js.map +1 -1
  50. package/dist/cramFile/slice/decodeRecord.d.ts +6 -6
  51. package/dist/cramFile/slice/decodeRecord.js +17 -17
  52. package/dist/cramFile/slice/decodeRecord.js.map +1 -1
  53. package/dist/cramFile/slice/index.d.ts +5 -5
  54. package/dist/cramFile/slice/index.js +46 -52
  55. package/dist/cramFile/slice/index.js.map +1 -1
  56. package/dist/htscodecs/arith_gen.d.ts +1 -1
  57. package/dist/htscodecs/arith_gen.js +17 -17
  58. package/dist/htscodecs/arith_gen.js.map +1 -1
  59. package/dist/htscodecs/fqzcomp.js +10 -10
  60. package/dist/htscodecs/fqzcomp.js.map +1 -1
  61. package/dist/htscodecs/index.js +6 -6
  62. package/dist/htscodecs/index.js.map +1 -1
  63. package/dist/htscodecs/rans.js +2 -2
  64. package/dist/htscodecs/rans.js.map +1 -1
  65. package/dist/htscodecs/rans4x16.js +7 -7
  66. package/dist/htscodecs/rans4x16.js.map +1 -1
  67. package/dist/htscodecs/tok3.js +9 -9
  68. package/dist/htscodecs/tok3.js.map +1 -1
  69. package/dist/index.d.ts +3 -3
  70. package/dist/index.js +7 -7
  71. package/dist/index.js.map +1 -1
  72. package/dist/indexedCramFile.d.ts +4 -4
  73. package/dist/indexedCramFile.js +5 -5
  74. package/dist/indexedCramFile.js.map +1 -1
  75. package/dist/{io/index.js → io.js} +1 -1
  76. package/dist/io.js.map +1 -0
  77. package/dist/rans/d04.js +28 -28
  78. package/dist/rans/d04.js.map +1 -1
  79. package/dist/rans/d14.js +16 -16
  80. package/dist/rans/d14.js.map +1 -1
  81. package/dist/rans/decoding.js +8 -8
  82. package/dist/rans/decoding.js.map +1 -1
  83. package/dist/rans/frequencies.js +15 -15
  84. package/dist/rans/frequencies.js.map +1 -1
  85. package/dist/rans/index.js +17 -17
  86. package/dist/rans/index.js.map +1 -1
  87. package/dist/seek-bzip/bitreader.d.ts +27 -0
  88. package/dist/seek-bzip/bitreader.js +101 -0
  89. package/dist/seek-bzip/bitreader.js.map +1 -0
  90. package/dist/seek-bzip/crc32.d.ts +0 -0
  91. package/dist/seek-bzip/crc32.js +113 -0
  92. package/dist/seek-bzip/crc32.js.map +1 -0
  93. package/dist/seek-bzip/index.d.ts +9 -0
  94. package/dist/seek-bzip/index.js +585 -0
  95. package/dist/seek-bzip/index.js.map +1 -0
  96. package/dist/seek-bzip/stream.d.ts +1 -0
  97. package/dist/seek-bzip/stream.js +41 -0
  98. package/dist/seek-bzip/stream.js.map +1 -0
  99. package/dist/seek-bzip/toHex.d.ts +1 -0
  100. package/dist/seek-bzip/toHex.js +36 -0
  101. package/dist/seek-bzip/toHex.js.map +1 -0
  102. package/esm/craiIndex.d.ts +1 -1
  103. package/esm/craiIndex.js +3 -3
  104. package/esm/craiIndex.js.map +1 -1
  105. package/esm/cramFile/codecs/_base.d.ts +3 -3
  106. package/esm/cramFile/codecs/beta.d.ts +5 -5
  107. package/esm/cramFile/codecs/beta.js +4 -4
  108. package/esm/cramFile/codecs/beta.js.map +1 -1
  109. package/esm/cramFile/codecs/byteArrayLength.d.ts +5 -5
  110. package/esm/cramFile/codecs/byteArrayLength.js +2 -2
  111. package/esm/cramFile/codecs/byteArrayLength.js.map +1 -1
  112. package/esm/cramFile/codecs/byteArrayStop.d.ts +5 -5
  113. package/esm/cramFile/codecs/byteArrayStop.js +4 -4
  114. package/esm/cramFile/codecs/byteArrayStop.js.map +1 -1
  115. package/esm/cramFile/codecs/dataSeriesTypes.d.ts +1 -1
  116. package/esm/cramFile/codecs/external.d.ts +5 -5
  117. package/esm/cramFile/codecs/external.js +8 -7
  118. package/esm/cramFile/codecs/external.js.map +1 -1
  119. package/esm/cramFile/codecs/gamma.d.ts +5 -5
  120. package/esm/cramFile/codecs/gamma.js +4 -4
  121. package/esm/cramFile/codecs/gamma.js.map +1 -1
  122. package/esm/cramFile/codecs/huffman.d.ts +6 -6
  123. package/esm/cramFile/codecs/huffman.js +5 -5
  124. package/esm/cramFile/codecs/huffman.js.map +1 -1
  125. package/esm/cramFile/codecs/index.d.ts +3 -3
  126. package/esm/cramFile/codecs/index.js +8 -8
  127. package/esm/cramFile/codecs/index.js.map +1 -1
  128. package/esm/cramFile/codecs/subexp.d.ts +5 -5
  129. package/esm/cramFile/codecs/subexp.js +4 -4
  130. package/esm/cramFile/codecs/subexp.js.map +1 -1
  131. package/esm/cramFile/container/compressionScheme.d.ts +4 -4
  132. package/esm/cramFile/container/compressionScheme.js +2 -2
  133. package/esm/cramFile/container/compressionScheme.js.map +1 -1
  134. package/esm/cramFile/container/index.d.ts +8 -8
  135. package/esm/cramFile/container/index.js +5 -6
  136. package/esm/cramFile/container/index.js.map +1 -1
  137. package/esm/cramFile/file.d.ts +3 -3
  138. package/esm/cramFile/file.js +12 -21
  139. package/esm/cramFile/file.js.map +1 -1
  140. package/esm/cramFile/index.d.ts +2 -2
  141. package/esm/cramFile/index.js +2 -2
  142. package/esm/cramFile/index.js.map +1 -1
  143. package/esm/cramFile/record.d.ts +2 -2
  144. package/esm/cramFile/record.js +1 -1
  145. package/esm/cramFile/record.js.map +1 -1
  146. package/esm/cramFile/sectionParsers.d.ts +3 -3
  147. package/esm/cramFile/sectionParsers.js +1 -1
  148. package/esm/cramFile/sectionParsers.js.map +1 -1
  149. package/esm/cramFile/slice/decodeRecord.d.ts +6 -6
  150. package/esm/cramFile/slice/decodeRecord.js +3 -3
  151. package/esm/cramFile/slice/decodeRecord.js.map +1 -1
  152. package/esm/cramFile/slice/index.d.ts +5 -5
  153. package/esm/cramFile/slice/index.js +18 -24
  154. package/esm/cramFile/slice/index.js.map +1 -1
  155. package/esm/htscodecs/arith_gen.d.ts +1 -1
  156. package/esm/htscodecs/arith_gen.js +5 -5
  157. package/esm/htscodecs/arith_gen.js.map +1 -1
  158. package/esm/htscodecs/fqzcomp.js +3 -3
  159. package/esm/htscodecs/fqzcomp.js.map +1 -1
  160. package/esm/htscodecs/index.js +5 -5
  161. package/esm/htscodecs/index.js.map +1 -1
  162. package/esm/htscodecs/rans.js +1 -1
  163. package/esm/htscodecs/rans.js.map +1 -1
  164. package/esm/htscodecs/rans4x16.js +1 -1
  165. package/esm/htscodecs/rans4x16.js.map +1 -1
  166. package/esm/htscodecs/tok3.js +4 -4
  167. package/esm/htscodecs/tok3.js.map +1 -1
  168. package/esm/index.d.ts +3 -3
  169. package/esm/index.js +3 -3
  170. package/esm/index.js.map +1 -1
  171. package/esm/indexedCramFile.d.ts +4 -4
  172. package/esm/indexedCramFile.js +2 -2
  173. package/esm/indexedCramFile.js.map +1 -1
  174. package/esm/{io/index.js → io.js} +1 -1
  175. package/esm/io.js.map +1 -0
  176. package/esm/rans/d04.js +3 -3
  177. package/esm/rans/d04.js.map +1 -1
  178. package/esm/rans/d14.js +2 -2
  179. package/esm/rans/d14.js.map +1 -1
  180. package/esm/rans/decoding.js +2 -2
  181. package/esm/rans/decoding.js.map +1 -1
  182. package/esm/rans/frequencies.js +3 -3
  183. package/esm/rans/frequencies.js.map +1 -1
  184. package/esm/rans/index.js +5 -5
  185. package/esm/rans/index.js.map +1 -1
  186. package/esm/seek-bzip/bitreader.d.ts +27 -0
  187. package/esm/seek-bzip/bitreader.js +98 -0
  188. package/esm/seek-bzip/bitreader.js.map +1 -0
  189. package/esm/seek-bzip/crc32.d.ts +0 -0
  190. package/esm/seek-bzip/crc32.js +113 -0
  191. package/esm/seek-bzip/crc32.js.map +1 -0
  192. package/esm/seek-bzip/index.d.ts +9 -0
  193. package/esm/seek-bzip/index.js +579 -0
  194. package/esm/seek-bzip/index.js.map +1 -0
  195. package/esm/seek-bzip/stream.d.ts +1 -0
  196. package/esm/seek-bzip/stream.js +41 -0
  197. package/esm/seek-bzip/stream.js.map +1 -0
  198. package/esm/seek-bzip/toHex.d.ts +1 -0
  199. package/esm/seek-bzip/toHex.js +33 -0
  200. package/esm/seek-bzip/toHex.js.map +1 -0
  201. package/package.json +15 -10
  202. package/src/craiIndex.ts +4 -4
  203. package/src/cramFile/codecs/_base.ts +3 -3
  204. package/src/cramFile/codecs/beta.ts +8 -8
  205. package/src/cramFile/codecs/byteArrayLength.ts +6 -6
  206. package/src/cramFile/codecs/byteArrayStop.ts +8 -8
  207. package/src/cramFile/codecs/dataSeriesTypes.ts +1 -1
  208. package/src/cramFile/codecs/external.ts +15 -12
  209. package/src/cramFile/codecs/gamma.ts +8 -8
  210. package/src/cramFile/codecs/huffman.ts +8 -8
  211. package/src/cramFile/codecs/index.ts +11 -11
  212. package/src/cramFile/codecs/subexp.ts +8 -8
  213. package/src/cramFile/container/compressionScheme.ts +6 -6
  214. package/src/cramFile/container/index.ts +6 -7
  215. package/src/cramFile/file.ts +13 -24
  216. package/src/cramFile/index.ts +2 -2
  217. package/src/cramFile/record.ts +3 -3
  218. package/src/cramFile/sectionParsers.ts +4 -4
  219. package/src/cramFile/slice/decodeRecord.ts +8 -8
  220. package/src/cramFile/slice/index.ts +23 -29
  221. package/src/htscodecs/arith_gen.ts +6 -6
  222. package/src/htscodecs/fqzcomp.ts +3 -3
  223. package/src/htscodecs/index.ts +5 -5
  224. package/src/htscodecs/rans.ts +1 -1
  225. package/src/htscodecs/rans4x16.ts +1 -1
  226. package/src/htscodecs/tok3.ts +4 -4
  227. package/src/index.ts +3 -3
  228. package/src/indexedCramFile.ts +5 -5
  229. package/src/rans/d04.ts +3 -3
  230. package/src/rans/d14.ts +2 -2
  231. package/src/rans/decoding.ts +2 -2
  232. package/src/rans/frequencies.ts +3 -3
  233. package/src/rans/index.ts +5 -5
  234. package/src/seek-bzip/README.md +6 -0
  235. package/src/seek-bzip/bitreader.ts +113 -0
  236. package/src/seek-bzip/crc32.ts +116 -0
  237. package/src/seek-bzip/index.ts +615 -0
  238. package/src/seek-bzip/stream.ts +42 -0
  239. package/src/seek-bzip/toHex.ts +33 -0
  240. package/dist/cram-bundle.js.LICENSE.txt +0 -12
  241. package/dist/io/index.js.map +0 -1
  242. package/esm/io/index.js.map +0 -1
  243. package/src/cramFile/declare.d.ts +0 -1
  244. /package/dist/{io/index.d.ts → io.d.ts} +0 -0
  245. /package/esm/{io/index.d.ts → io.d.ts} +0 -0
  246. /package/src/{io/index.ts → io.ts} +0 -0
@@ -0,0 +1,33 @@
1
+ // from https://www.xaymar.com/articles/2020/12/08/fastest-uint8array-to-hex-string-conversion-in-javascript/
2
+ // Pre-Init
3
+ const LUT_HEX_4b = [
4
+ '0',
5
+ '1',
6
+ '2',
7
+ '3',
8
+ '4',
9
+ '5',
10
+ '6',
11
+ '7',
12
+ '8',
13
+ '9',
14
+ 'A',
15
+ 'B',
16
+ 'C',
17
+ 'D',
18
+ 'E',
19
+ 'F',
20
+ ];
21
+ const LUT_HEX_8b = new Array(0x100);
22
+ for (let n = 0; n < 0x100; n++) {
23
+ LUT_HEX_8b[n] = `${LUT_HEX_4b[(n >>> 4) & 0xf]}${LUT_HEX_4b[n & 0xf]}`;
24
+ }
25
+ // End Pre-Init
26
+ export function toHex(buffer) {
27
+ let out = '';
28
+ for (let idx = 0, edx = buffer.length; idx < edx; idx++) {
29
+ out += LUT_HEX_8b[buffer[idx]];
30
+ }
31
+ return out;
32
+ }
33
+ //# sourceMappingURL=toHex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toHex.js","sourceRoot":"","sources":["../../src/seek-bzip/toHex.ts"],"names":[],"mappings":"AAAA,6GAA6G;AAE7G,WAAW;AACX,MAAM,UAAU,GAAG;IACjB,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;CACJ,CAAA;AACD,MAAM,UAAU,GAAG,IAAI,KAAK,CAAC,KAAK,CAAC,CAAA;AACnC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;IAC/B,UAAU,CAAC,CAAC,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,UAAU,CAAC,CAAC,GAAG,GAAG,CAAC,EAAE,CAAA;AACxE,CAAC;AACD,eAAe;AACf,MAAM,UAAU,KAAK,CAAC,MAAkB;IACtC,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;QACxD,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,GAAG,CAAE,CAAC,CAAA;IACjC,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,19 @@
1
1
  {
2
2
  "name": "@gmod/cram",
3
- "version": "4.0.9",
3
+ "version": "5.0.0",
4
4
  "description": "read CRAM files with pure Javascript",
5
5
  "license": "MIT",
6
6
  "repository": "GMOD/cram-js",
7
- "main": "dist/index.js",
8
- "module": "esm/index.js",
7
+ "type": "module",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ "import": {
11
+ "import": "./esm/index.js"
12
+ },
13
+ "require": {
14
+ "require": "./dist/index.js"
15
+ }
16
+ },
9
17
  "author": {
10
18
  "name": "Robert Buels",
11
19
  "email": "rbuels@gmail.com",
@@ -41,32 +49,29 @@
41
49
  ],
42
50
  "dependencies": {
43
51
  "crc": "^4.3.2",
44
- "generic-filehandle2": "^1.0.0",
52
+ "generic-filehandle2": "^2.0.1",
45
53
  "md5": "^2.2.1",
46
54
  "pako": "^1.0.4",
47
55
  "quick-lru": "^4.0.1",
48
- "seek-bzip": "^2.0.0",
49
56
  "xz-decompress": "^0.2.1"
50
57
  },
51
58
  "devDependencies": {
52
59
  "@gmod/indexedfasta": "^3.0.0",
53
60
  "@types/md5": "^2.3.2",
54
61
  "@types/pako": "^1.0.3",
55
- "@typescript-eslint/eslint-plugin": "^8.0.0",
56
- "@typescript-eslint/parser": "^8.0.0",
57
62
  "@vitest/coverage-v8": "^3.0.1",
58
63
  "buffer": "^6.0.3",
59
64
  "documentation": "^14.0.3",
60
65
  "eslint": "^9.9.0",
61
66
  "eslint-plugin-import": "^2.31.0",
62
- "eslint-plugin-unicorn": "^56.0.1",
67
+ "eslint-plugin-unicorn": "^59.0.0",
63
68
  "mock-fs": "^5.2.0",
64
69
  "prettier": "^3.2.5",
65
70
  "rimraf": "^6.0.1",
66
71
  "typescript": "^5.7.0",
67
- "typescript-eslint": "^8.0.1",
72
+ "typescript-eslint": "^8.31.1",
68
73
  "vitest": "^3.0.1",
69
- "webpack": "^5.90.3",
74
+ "webpack": "^5.99.7",
70
75
  "webpack-cli": "^6.0.1"
71
76
  },
72
77
  "publishConfig": {
package/src/craiIndex.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { CramFileSource } from './cramFile/file'
2
- import { CramMalformedError } from './errors'
3
- import { open } from './io'
4
- import { unzip } from './unzip'
1
+ import { CramFileSource } from './cramFile/file.ts'
2
+ import { CramMalformedError } from './errors.ts'
3
+ import { open } from './io.ts'
4
+ import { unzip } from './unzip.ts'
5
5
 
6
6
  import type { GenericFilehandle } from 'generic-filehandle2'
7
7
 
@@ -1,6 +1,6 @@
1
- import { CramFileBlock } from '../file'
2
- import CramSlice from '../slice'
3
- import { DataType } from './dataSeriesTypes'
1
+ import { CramFileBlock } from '../file.ts'
2
+ import { DataType } from './dataSeriesTypes.ts'
3
+ import CramSlice from '../slice/index.ts'
4
4
 
5
5
  export interface DataTypeMapping {
6
6
  byte: number
@@ -1,9 +1,9 @@
1
- import CramCodec, { Cursors } from './_base'
2
- import { getBits } from './getBits'
3
- import { CramUnimplementedError } from '../../errors'
4
- import { BetaEncoding } from '../encoding'
5
- import { CramFileBlock } from '../file'
6
- import CramSlice from '../slice'
1
+ import CramCodec, { Cursors } from './_base.ts'
2
+ import { getBits } from './getBits.ts'
3
+ import { CramUnimplementedError } from '../../errors.ts'
4
+ import { BetaEncoding } from '../encoding.ts'
5
+ import { CramFileBlock } from '../file.ts'
6
+ import CramSlice from '../slice/index.ts'
7
7
 
8
8
  export default class BetaCodec extends CramCodec<
9
9
  'int',
@@ -19,9 +19,9 @@ export default class BetaCodec extends CramCodec<
19
19
  }
20
20
 
21
21
  decode(
22
- slice: CramSlice,
22
+ _slice: CramSlice,
23
23
  coreDataBlock: CramFileBlock,
24
- blocksByContentId: Record<number, CramFileBlock>,
24
+ _blocksByContentId: Record<number, CramFileBlock>,
25
25
  cursors: Cursors,
26
26
  ) {
27
27
  const fromBits = getBits(
@@ -1,9 +1,9 @@
1
- import CramCodec, { Cursors } from './_base'
2
- import { ByteArrayLengthEncoding, CramEncoding } from '../encoding'
3
- import { CramFileBlock } from '../file'
4
- import CramSlice from '../slice'
5
- import { DataType } from './dataSeriesTypes'
6
- import { tinyMemoize } from '../util'
1
+ import CramCodec, { Cursors } from './_base.ts'
2
+ import { ByteArrayLengthEncoding, CramEncoding } from '../encoding.ts'
3
+ import { CramFileBlock } from '../file.ts'
4
+ import { DataType } from './dataSeriesTypes.ts'
5
+ import CramSlice from '../slice/index.ts'
6
+ import { tinyMemoize } from '../util.ts'
7
7
 
8
8
  type CramCodecFactory = <TData extends DataType = DataType>(
9
9
  encodingData: CramEncoding,
@@ -1,17 +1,17 @@
1
- import CramCodec, { Cursor, Cursors } from './_base'
2
- import { CramMalformedError } from '../../errors'
3
- import { ByteArrayStopCramEncoding } from '../encoding'
4
- import { CramFileBlock } from '../file'
5
- import CramSlice from '../slice'
6
- import { CramBufferOverrunError } from './getBits'
1
+ import CramCodec, { Cursor, Cursors } from './_base.ts'
2
+ import { CramMalformedError } from '../../errors.ts'
3
+ import { ByteArrayStopCramEncoding } from '../encoding.ts'
4
+ import { CramFileBlock } from '../file.ts'
5
+ import { CramBufferOverrunError } from './getBits.ts'
6
+ import CramSlice from '../slice/index.ts'
7
7
 
8
8
  export default class ByteArrayStopCodec extends CramCodec<
9
9
  'byteArray',
10
10
  ByteArrayStopCramEncoding['parameters']
11
11
  > {
12
12
  decode(
13
- slice: CramSlice,
14
- coreDataBlock: CramFileBlock,
13
+ _slice: CramSlice,
14
+ _coreDataBlock: CramFileBlock,
15
15
  blocksByContentId: Record<number, CramFileBlock>,
16
16
  cursors: Cursors,
17
17
  ) {
@@ -1,4 +1,4 @@
1
- import { CramEncoding } from '../encoding'
1
+ import { CramEncoding } from '../encoding.ts'
2
2
 
3
3
  export type DataType = 'int' | 'byte' | 'long' | 'byteArray'
4
4
 
@@ -1,10 +1,10 @@
1
- import CramCodec, { Cursor, Cursors } from './_base'
2
- import { CramUnimplementedError } from '../../errors'
3
- import { CramFileBlock } from '../file'
4
- import CramSlice from '../slice'
5
- import { parseItf8 } from '../util'
6
- import { CramBufferOverrunError } from './getBits'
7
- import { ExternalCramEncoding } from '../encoding'
1
+ import CramCodec, { Cursor, Cursors } from './_base.ts'
2
+ import { CramUnimplementedError } from '../../errors.ts'
3
+ import { CramFileBlock } from '../file.ts'
4
+ import CramSlice from '../slice/index.ts'
5
+ import { parseItf8 } from '../util.ts'
6
+ import { CramBufferOverrunError } from './getBits.ts'
7
+ import { ExternalCramEncoding } from '../encoding.ts'
8
8
 
9
9
  export default class ExternalCodec extends CramCodec<
10
10
  'int' | 'byte',
@@ -32,16 +32,19 @@ export default class ExternalCodec extends CramCodec<
32
32
  }
33
33
 
34
34
  decode(
35
- slice: CramSlice,
36
- coreDataBlock: CramFileBlock,
35
+ _slice: CramSlice,
36
+ _coreDataBlock: CramFileBlock,
37
37
  blocksByContentId: Record<number, CramFileBlock>,
38
38
  cursors: Cursors,
39
39
  ) {
40
40
  const { blockContentId } = this.parameters
41
41
  const contentBlock = blocksByContentId[blockContentId]
42
-
43
- const cursor = cursors.externalBlocks.getCursor(blockContentId)
44
- return contentBlock ? this._decodeData(contentBlock, cursor) : undefined
42
+ return contentBlock
43
+ ? this._decodeData(
44
+ contentBlock,
45
+ cursors.externalBlocks.getCursor(blockContentId),
46
+ )
47
+ : undefined
45
48
  }
46
49
 
47
50
  _decodeInt(contentBlock: CramFileBlock, cursor: Cursor) {
@@ -1,9 +1,9 @@
1
- import CramCodec, { Cursors } from './_base'
2
- import { getBits } from './getBits'
3
- import { CramUnimplementedError } from '../../errors'
4
- import { GammaEncoding } from '../encoding'
5
- import { CramFileBlock } from '../file'
6
- import CramSlice from '../slice'
1
+ import CramCodec, { Cursors } from './_base.ts'
2
+ import { getBits } from './getBits.ts'
3
+ import { CramUnimplementedError } from '../../errors.ts'
4
+ import { GammaEncoding } from '../encoding.ts'
5
+ import { CramFileBlock } from '../file.ts'
6
+ import CramSlice from '../slice/index.ts'
7
7
 
8
8
  export default class GammaCodec extends CramCodec<
9
9
  'int',
@@ -19,9 +19,9 @@ export default class GammaCodec extends CramCodec<
19
19
  }
20
20
 
21
21
  decode(
22
- slice: CramSlice,
22
+ _slice: CramSlice,
23
23
  coreDataBlock: CramFileBlock,
24
- blocksByContentId: Record<number, CramFileBlock>,
24
+ _blocksByContentId: Record<number, CramFileBlock>,
25
25
  cursors: Cursors,
26
26
  ) {
27
27
  let length = 1
@@ -1,9 +1,9 @@
1
- import CramCodec, { Cursor, Cursors } from './_base'
2
- import { getBits } from './getBits'
3
- import { CramMalformedError } from '../../errors'
4
- import { HuffmanEncoding } from '../encoding'
5
- import { CramFileBlock } from '../file'
6
- import CramSlice from '../slice'
1
+ import CramCodec, { Cursor, Cursors } from './_base.ts'
2
+ import { getBits } from './getBits.ts'
3
+ import { CramMalformedError } from '../../errors.ts'
4
+ import { HuffmanEncoding } from '../encoding.ts'
5
+ import { CramFileBlock } from '../file.ts'
6
+ import CramSlice from '../slice/index.ts'
7
7
 
8
8
  function numberOfSetBits(ii: number) {
9
9
  let i = (ii - (ii >> 1)) & 0x55555555
@@ -122,7 +122,7 @@ export default class HuffmanIntCodec extends CramCodec<
122
122
  decode(
123
123
  slice: CramSlice,
124
124
  coreDataBlock: CramFileBlock,
125
- blocksByContentId: Record<number, CramFileBlock>,
125
+ _blocksByContentId: Record<number, CramFileBlock>,
126
126
  cursors: Cursors,
127
127
  ) {
128
128
  return this._decode(slice, coreDataBlock, cursors.coreBlock)
@@ -137,7 +137,7 @@ export default class HuffmanIntCodec extends CramCodec<
137
137
  return this.sortedCodes[0]!.value
138
138
  }
139
139
 
140
- _decode(slice: CramSlice, coreDataBlock: CramFileBlock, coreCursor: Cursor) {
140
+ _decode(_slice: CramSlice, coreDataBlock: CramFileBlock, coreCursor: Cursor) {
141
141
  const input = coreDataBlock.content
142
142
 
143
143
  let prevLen = 0
@@ -1,14 +1,14 @@
1
- import CramCodec from './_base'
2
- import BetaCodec from './beta'
3
- import ByteArrayLengthCodec from './byteArrayLength'
4
- import ByteArrayStopCodec from './byteArrayStop'
5
- import { DataType } from './dataSeriesTypes'
6
- import ExternalCodec from './external'
7
- import GammaCodec from './gamma'
8
- import HuffmanIntCodec from './huffman'
9
- import SubexpCodec from './subexp'
10
- import { CramUnimplementedError } from '../../errors'
11
- import { CramEncoding } from '../encoding'
1
+ import CramCodec from './_base.ts'
2
+ import BetaCodec from './beta.ts'
3
+ import ByteArrayLengthCodec from './byteArrayLength.ts'
4
+ import ByteArrayStopCodec from './byteArrayStop.ts'
5
+ import { DataType } from './dataSeriesTypes.ts'
6
+ import ExternalCodec from './external.ts'
7
+ import GammaCodec from './gamma.ts'
8
+ import HuffmanIntCodec from './huffman.ts'
9
+ import SubexpCodec from './subexp.ts'
10
+ import { CramUnimplementedError } from '../../errors.ts'
11
+ import { CramEncoding } from '../encoding.ts'
12
12
 
13
13
  const codecClasses = {
14
14
  1: ExternalCodec,
@@ -1,9 +1,9 @@
1
- import CramCodec, { Cursors } from './_base'
2
- import { getBits } from './getBits'
3
- import { CramUnimplementedError } from '../../errors'
4
- import { SubexpEncoding } from '../encoding'
5
- import { CramFileBlock } from '../file'
6
- import CramSlice from '../slice'
1
+ import CramCodec, { Cursors } from './_base.ts'
2
+ import { getBits } from './getBits.ts'
3
+ import { CramUnimplementedError } from '../../errors.ts'
4
+ import { SubexpEncoding } from '../encoding.ts'
5
+ import { CramFileBlock } from '../file.ts'
6
+ import CramSlice from '../slice/index.ts'
7
7
 
8
8
  export default class SubexpCodec extends CramCodec<
9
9
  'int',
@@ -19,9 +19,9 @@ export default class SubexpCodec extends CramCodec<
19
19
  }
20
20
 
21
21
  decode(
22
- slice: CramSlice,
22
+ _slice: CramSlice,
23
23
  coreDataBlock: CramFileBlock,
24
- blocksByContentId: Record<number, CramFileBlock>,
24
+ _blocksByContentId: Record<number, CramFileBlock>,
25
25
  cursors: Cursors,
26
26
  ) {
27
27
  let numLeadingOnes = 0
@@ -1,12 +1,12 @@
1
- import { CramMalformedError } from '../../errors'
2
- import { instantiateCodec } from '../codecs'
3
- import CramCodec from '../codecs/_base'
1
+ import { CramMalformedError } from '../../errors.ts'
2
+ import CramCodec from '../codecs/_base.ts'
4
3
  import {
5
4
  DataSeriesEncodingKey,
6
5
  DataSeriesEncodingMap,
7
- } from '../codecs/dataSeriesTypes'
8
- import { CramEncoding } from '../encoding'
9
- import { CramCompressionHeader } from '../sectionParsers'
6
+ } from '../codecs/dataSeriesTypes.ts'
7
+ import { instantiateCodec } from '../codecs/index.ts'
8
+ import { CramEncoding } from '../encoding.ts'
9
+ import { CramCompressionHeader } from '../sectionParsers.ts'
10
10
 
11
11
  // the hardcoded data type to be decoded for each core
12
12
  // data field
@@ -1,10 +1,9 @@
1
- import { CramMalformedError } from '../../errors'
2
- // locals
3
- import CramSlice from '../slice'
4
- import { itf8Size, parseItem, tinyMemoize } from '../util'
5
- import CramContainerCompressionScheme from './compressionScheme'
6
- import CramFile from '../file'
7
- import { getSectionParsers } from '../sectionParsers'
1
+ import { CramMalformedError } from '../../errors.ts'
2
+ import CramSlice from '../slice/index.ts'
3
+ import { itf8Size, parseItem, tinyMemoize } from '../util.ts'
4
+ import CramContainerCompressionScheme from './compressionScheme.ts'
5
+ import CramFile from '../file.ts'
6
+ import { getSectionParsers } from '../sectionParsers.ts'
8
7
 
9
8
  export default class CramContainer {
10
9
  constructor(
@@ -1,28 +1,23 @@
1
- // import bzip2 from 'bzip2'
2
- // import BZip2 from 'bzip2-wasm'
3
- // import { decompress } from 'bz2'
4
-
5
-
6
1
  import crc32 from 'crc/calculators/crc32'
7
2
  import QuickLRU from 'quick-lru'
8
- import Bunzip from 'seek-bzip'
9
3
  import { XzReadableStream } from 'xz-decompress'
10
4
 
11
- import { CramMalformedError, CramUnimplementedError } from '../errors'
12
- import * as htscodecs from '../htscodecs'
13
- import { open } from '../io'
14
- import ransuncompress from '../rans'
15
- import { parseHeaderText } from '../sam'
16
- import { unzip } from '../unzip'
17
- import CramContainer from './container'
18
- import CramRecord from './record'
5
+ import { CramMalformedError, CramUnimplementedError } from '../errors.ts'
6
+ import * as htscodecs from '../htscodecs/index.ts'
7
+ import { open } from '../io.ts'
8
+ import ransuncompress from '../rans/index.ts'
9
+ import { parseHeaderText } from '../sam.ts'
10
+ import { decode } from '../seek-bzip/index.ts'
11
+ import { unzip } from '../unzip.ts'
12
+ import CramContainer from './container/index.ts'
13
+ import CramRecord from './record.ts'
19
14
  import {
20
15
  BlockHeader,
21
16
  CompressionMethod,
22
17
  cramFileDefinition,
23
18
  getSectionParsers,
24
- } from './sectionParsers'
25
- import { parseItem, tinyMemoize } from './util'
19
+ } from './sectionParsers.ts'
20
+ import { parseItem, tinyMemoize } from './util.ts'
26
21
 
27
22
  import type { GenericFilehandle } from 'generic-filehandle2'
28
23
 
@@ -287,13 +282,9 @@ export default class CramFile {
287
282
  ) {
288
283
  // console.log({ compressionMethod })
289
284
  if (compressionMethod === 'gzip') {
290
- const ret = unzip(inputBuffer)
291
- if (ret[0] === 24) {
292
- // console.log(ret.slice(0, 500).join(','))
293
- }
294
- return ret
285
+ return unzip(inputBuffer)
295
286
  } else if (compressionMethod === 'bzip2') {
296
- return Bunzip.decode(inputBuffer)
287
+ return decode(inputBuffer)
297
288
  } else if (compressionMethod === 'lzma') {
298
289
  const decompressedResponse = new Response(
299
290
  new XzReadableStream(bufferToStream(inputBuffer)),
@@ -303,8 +294,6 @@ export default class CramFile {
303
294
  const outputBuffer = new Uint8Array(uncompressedSize)
304
295
  ransuncompress(inputBuffer, outputBuffer)
305
296
  return outputBuffer
306
- // htscodecs r4x8 is slower, but compatible.
307
- // htscodecs.r4x8_uncompress(inputBuffer, outputBuffer);
308
297
  } else if (compressionMethod === 'rans4x16') {
309
298
  return htscodecs.r4x16_uncompress(inputBuffer)
310
299
  } else if (compressionMethod === 'arith') {
@@ -1,3 +1,3 @@
1
- export { default as CramRecord } from './record'
1
+ export { default as CramRecord } from './record.ts'
2
2
 
3
- export { default } from './file'
3
+ export { default } from './file.ts'
@@ -1,7 +1,7 @@
1
- import Constants from './constants'
2
- import CramContainerCompressionScheme from './container/compressionScheme'
1
+ import Constants from './constants.ts'
2
+ import CramContainerCompressionScheme from './container/compressionScheme.ts'
3
3
 
4
- import type decodeRecord from './slice/decodeRecord'
4
+ import type decodeRecord from './slice/decodeRecord.ts'
5
5
 
6
6
  export interface RefRegion {
7
7
  start: number
@@ -1,7 +1,7 @@
1
- import { TupleOf } from '../typescript'
2
- import { DataSeriesEncodingMap } from './codecs/dataSeriesTypes'
3
- import { CramEncoding } from './encoding'
4
- import { parseItf8, parseLtf8 } from './util'
1
+ import { TupleOf } from '../typescript.ts'
2
+ import { DataSeriesEncodingMap } from './codecs/dataSeriesTypes.ts'
3
+ import { CramEncoding } from './encoding.ts'
4
+ import { parseItf8, parseLtf8 } from './util.ts'
5
5
 
6
6
  export function cramFileDefinition() {
7
7
  return {
@@ -1,18 +1,18 @@
1
- import { CramMalformedError } from '../../errors'
2
- import { Cursors, DataTypeMapping } from '../codecs/_base'
3
- import { DataSeriesEncodingKey } from '../codecs/dataSeriesTypes'
1
+ import { CramMalformedError } from '../../errors.ts'
2
+ import { Cursors, DataTypeMapping } from '../codecs/_base.ts'
3
+ import { DataSeriesEncodingKey } from '../codecs/dataSeriesTypes.ts'
4
4
  import CramContainerCompressionScheme, {
5
5
  DataSeriesTypes,
6
- } from '../container/compressionScheme'
6
+ } from '../container/compressionScheme.ts'
7
7
  import {
8
8
  BamFlagsDecoder,
9
9
  CramFlagsDecoder,
10
10
  MateFlagsDecoder,
11
11
  ReadFeature,
12
- } from '../record'
13
- import CramSlice, { SliceHeader } from './index'
14
- import { CramFileBlock } from '../file'
15
- import { isMappedSliceHeader } from '../sectionParsers'
12
+ } from '../record.ts'
13
+ import CramSlice, { SliceHeader } from './index.ts'
14
+ import { CramFileBlock } from '../file.ts'
15
+ import { isMappedSliceHeader } from '../sectionParsers.ts'
16
16
 
17
17
  /**
18
18
  * given a Buffer, read a string up to the first null character
@@ -1,20 +1,20 @@
1
- import { CramArgumentError, CramMalformedError } from '../../errors'
2
- import { Cursors, DataTypeMapping } from '../codecs/_base'
3
- import { CramBufferOverrunError } from '../codecs/getBits'
4
- import Constants from '../constants'
5
- import decodeRecord, { DataSeriesDecoder } from './decodeRecord'
6
- import { DataSeriesEncodingKey } from '../codecs/dataSeriesTypes'
7
- import CramContainer from '../container'
8
- import { DataSeriesTypes } from '../container/compressionScheme'
9
- import CramFile, { CramFileBlock } from '../file'
10
- import CramRecord from '../record'
1
+ import { CramArgumentError, CramMalformedError } from '../../errors.ts'
2
+ import { Cursors, DataTypeMapping } from '../codecs/_base.ts'
3
+ import { CramBufferOverrunError } from '../codecs/getBits.ts'
4
+ import Constants from '../constants.ts'
5
+ import decodeRecord, { DataSeriesDecoder } from './decodeRecord.ts'
6
+ import { DataSeriesEncodingKey } from '../codecs/dataSeriesTypes.ts'
7
+ import { DataSeriesTypes } from '../container/compressionScheme.ts'
8
+ import CramContainer from '../container/index.ts'
9
+ import CramFile, { CramFileBlock } from '../file.ts'
10
+ import CramRecord from '../record.ts'
11
11
  import {
12
12
  MappedSliceHeader,
13
13
  UnmappedSliceHeader,
14
14
  getSectionParsers,
15
15
  isMappedSliceHeader,
16
- } from '../sectionParsers'
17
- import { parseItem, sequenceMD5, tinyMemoize } from '../util'
16
+ } from '../sectionParsers.ts'
17
+ import { parseItem, sequenceMD5, tinyMemoize } from '../util.ts'
18
18
 
19
19
  export type SliceHeader = CramFileBlock & {
20
20
  parsedContent: MappedSliceHeader | UnmappedSliceHeader
@@ -28,15 +28,12 @@ interface RefRegion {
28
28
  }
29
29
 
30
30
  /**
31
- * @private
32
- * Try to estimate the template length from a bunch of interrelated multi-segment reads.
33
- * @param {Array[CramRecord]} allRecords
34
- * @param {number} currentRecordNumber
35
- * @param {CramRecord} thisRecord
31
+ * Try to estimate the template length from a bunch of interrelated
32
+ * multi-segment reads.
36
33
  */
37
34
  function calculateMultiSegmentMatedTemplateLength(
38
35
  allRecords: CramRecord[],
39
- currentRecordNumber: number,
36
+ _currentRecordNumber: number,
40
37
  thisRecord: CramRecord,
41
38
  ) {
42
39
  function getAllMatedRecords(startRecord: CramRecord) {
@@ -73,18 +70,16 @@ function calculateMultiSegmentMatedTemplateLength(
73
70
  }
74
71
 
75
72
  /**
76
- * @private
77
- * Attempt to calculate the `templateLength` for a pair of intra-slice paired reads.
78
- * Ported from htslib. Algorithm is imperfect.
79
- * @param {CramRecord} thisRecord
80
- * @param {CramRecord} mateRecord
73
+ * Attempt to calculate the `templateLength` for a pair of intra-slice paired
74
+ * reads. Ported from htslib. Algorithm is imperfect.
81
75
  */
82
76
  function calculateIntraSliceMatePairTemplateLength(
83
77
  thisRecord: CramRecord,
84
78
  mateRecord: CramRecord,
85
79
  ) {
86
- // this just estimates the template length by using the simple (non-gapped) end coordinate of each
87
- // read, because gapping in the alignment doesn't mean the template is longer or shorter
80
+ // this just estimates the template length by using the simple (non-gapped)
81
+ // end coordinate of each read, because gapping in the alignment doesn't mean
82
+ // the template is longer or shorter
88
83
  const start = Math.min(thisRecord.alignmentStart, mateRecord.alignmentStart)
89
84
  const end = Math.max(
90
85
  thisRecord.alignmentStart + thisRecord.readLength - 1,
@@ -96,10 +91,9 @@ function calculateIntraSliceMatePairTemplateLength(
96
91
  }
97
92
 
98
93
  /**
99
- * @private establishes a mate-pair relationship between two records in the
100
- * same slice. CRAM compresses mate-pair relationships between records in the
101
- * same slice down into just one record having the index in the slice of its
102
- * mate
94
+ * establishes a mate-pair relationship between two records in the same slice.
95
+ * CRAM compresses mate-pair relationships between records in the same slice
96
+ * down into just one record having the index in the slice of its mate
103
97
  */
104
98
  function associateIntraSliceMate(
105
99
  allRecords: CramRecord[],
@@ -34,12 +34,12 @@
34
34
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
35
  */
36
36
 
37
- import Bunzip from 'seek-bzip'
37
+ import { decode } from '../seek-bzip/index.ts'
38
38
 
39
- import RangeCoder from './arith_sh'
40
- import ByteModel from './byte_model'
41
- import IOStream from './iostream'
42
- import { concatUint8Array } from '../util'
39
+ import RangeCoder from './arith_sh.ts'
40
+ import ByteModel from './byte_model.ts'
41
+ import IOStream from './iostream.ts'
42
+ import { concatUint8Array } from '../util.ts'
43
43
 
44
44
  const ARITH_ORDER = 1
45
45
  const ARITH_EXT = 4
@@ -154,7 +154,7 @@ export default class RangeCoderGen {
154
154
  // ----------------------------------------------------------------------
155
155
  // External codec
156
156
  decodeExt(stream, n_out) {
157
- return Bunzip.decode(stream.buf.slice(stream.pos))
157
+ return decode(stream.buf.slice(stream.pos))
158
158
  }
159
159
 
160
160
  // ----------------------------------------------------------------------