@gmod/cram 4.0.6 → 4.0.8
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/dist/cram-bundle.js +1 -1
- package/dist/cramFile/file.d.ts +1 -0
- package/dist/cramFile/file.js +25 -20
- package/dist/cramFile/file.js.map +1 -1
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/htscodecs/arith_gen.d.ts +1 -1
- package/dist/htscodecs/arith_gen.js +2 -14
- package/dist/htscodecs/arith_gen.js.map +1 -1
- package/esm/cramFile/file.d.ts +1 -0
- package/esm/cramFile/file.js +21 -16
- package/esm/cramFile/file.js.map +1 -1
- package/esm/cramFile/slice/decodeRecord.js.map +1 -1
- package/esm/htscodecs/arith_gen.d.ts +1 -1
- package/esm/htscodecs/arith_gen.js +2 -14
- package/esm/htscodecs/arith_gen.js.map +1 -1
- package/package.json +8 -4
- package/src/cramFile/declare.d.ts +1 -1
- package/src/cramFile/file.ts +32 -16
- package/src/cramFile/slice/decodeRecord.ts +1 -0
- package/src/htscodecs/arith_gen.ts +2 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmod/cram",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.8",
|
|
4
4
|
"description": "read CRAM files with pure Javascript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "GMOD/cram-js",
|
|
@@ -40,12 +40,16 @@
|
|
|
40
40
|
"biojs"
|
|
41
41
|
],
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@foxglove/wasm-bz2": "^0.1.1",
|
|
44
|
+
"bz2": "^1.0.1",
|
|
43
45
|
"bzip2": "^0.1.1",
|
|
46
|
+
"bzip2-wasm": "^1.0.1",
|
|
44
47
|
"crc": "^4.3.2",
|
|
45
48
|
"generic-filehandle2": "^1.0.0",
|
|
46
49
|
"md5": "^2.2.1",
|
|
47
50
|
"pako": "^1.0.4",
|
|
48
51
|
"quick-lru": "^4.0.1",
|
|
52
|
+
"seek-bzip": "^2.0.0",
|
|
49
53
|
"xz-decompress": "^0.2.1"
|
|
50
54
|
},
|
|
51
55
|
"devDependencies": {
|
|
@@ -54,7 +58,7 @@
|
|
|
54
58
|
"@types/pako": "^1.0.3",
|
|
55
59
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
56
60
|
"@typescript-eslint/parser": "^8.0.0",
|
|
57
|
-
"@vitest/coverage-v8": "^
|
|
61
|
+
"@vitest/coverage-v8": "^3.0.1",
|
|
58
62
|
"buffer": "^6.0.3",
|
|
59
63
|
"documentation": "^14.0.3",
|
|
60
64
|
"eslint": "^9.9.0",
|
|
@@ -65,9 +69,9 @@
|
|
|
65
69
|
"rimraf": "^6.0.1",
|
|
66
70
|
"typescript": "^5.7.0",
|
|
67
71
|
"typescript-eslint": "^8.0.1",
|
|
68
|
-
"vitest": "^
|
|
72
|
+
"vitest": "^3.0.1",
|
|
69
73
|
"webpack": "^5.90.3",
|
|
70
|
-
"webpack-cli": "^
|
|
74
|
+
"webpack-cli": "^6.0.1"
|
|
71
75
|
},
|
|
72
76
|
"publishConfig": {
|
|
73
77
|
"access": "public"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
declare module '
|
|
1
|
+
declare module 'seek-bzip'
|
package/src/cramFile/file.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
import bzip2 from 'bzip2'
|
|
1
|
+
// import bzip2 from 'bzip2'
|
|
2
|
+
// import BZip2 from 'bzip2-wasm'
|
|
3
|
+
// import { decompress } from 'bz2'
|
|
4
|
+
|
|
5
|
+
|
|
2
6
|
import crc32 from 'crc/calculators/crc32'
|
|
3
7
|
import QuickLRU from 'quick-lru'
|
|
8
|
+
import Bunzip from 'seek-bzip'
|
|
4
9
|
import { XzReadableStream } from 'xz-decompress'
|
|
5
10
|
|
|
6
11
|
import { CramMalformedError, CramUnimplementedError } from '../errors'
|
|
@@ -9,7 +14,6 @@ import { open } from '../io'
|
|
|
9
14
|
import ransuncompress from '../rans'
|
|
10
15
|
import { parseHeaderText } from '../sam'
|
|
11
16
|
import { unzip } from '../unzip'
|
|
12
|
-
import { concatUint8Array } from '../util'
|
|
13
17
|
import CramContainer from './container'
|
|
14
18
|
import CramRecord from './record'
|
|
15
19
|
import {
|
|
@@ -276,26 +280,20 @@ export default class CramFile {
|
|
|
276
280
|
return data
|
|
277
281
|
}
|
|
278
282
|
|
|
279
|
-
async
|
|
283
|
+
async _uncompressPre(
|
|
280
284
|
compressionMethod: CompressionMethod,
|
|
281
285
|
inputBuffer: Uint8Array,
|
|
282
286
|
uncompressedSize: number,
|
|
283
287
|
) {
|
|
288
|
+
// console.log({ compressionMethod })
|
|
284
289
|
if (compressionMethod === 'gzip') {
|
|
285
|
-
|
|
290
|
+
const ret = unzip(inputBuffer)
|
|
291
|
+
if (ret[0] === 24) {
|
|
292
|
+
// console.log(ret.slice(0, 500).join(','))
|
|
293
|
+
}
|
|
294
|
+
return ret
|
|
286
295
|
} else if (compressionMethod === 'bzip2') {
|
|
287
|
-
|
|
288
|
-
let size = bzip2.header(bits)
|
|
289
|
-
let chunk: Uint8Array | -1
|
|
290
|
-
const chunks = []
|
|
291
|
-
do {
|
|
292
|
-
chunk = bzip2.decompress(bits, size)
|
|
293
|
-
if (chunk !== -1) {
|
|
294
|
-
chunks.push(chunk)
|
|
295
|
-
size -= chunk.length
|
|
296
|
-
}
|
|
297
|
-
} while (chunk !== -1)
|
|
298
|
-
return concatUint8Array(chunks)
|
|
296
|
+
return Bunzip.decode(inputBuffer)
|
|
299
297
|
} else if (compressionMethod === 'lzma') {
|
|
300
298
|
const decompressedResponse = new Response(
|
|
301
299
|
new XzReadableStream(bufferToStream(inputBuffer)),
|
|
@@ -322,6 +320,24 @@ export default class CramFile {
|
|
|
322
320
|
}
|
|
323
321
|
}
|
|
324
322
|
|
|
323
|
+
async _uncompress(
|
|
324
|
+
compressionMethod: CompressionMethod,
|
|
325
|
+
inputBuffer: Uint8Array,
|
|
326
|
+
uncompressedSize: number,
|
|
327
|
+
) {
|
|
328
|
+
const buf = await this._uncompressPre(
|
|
329
|
+
compressionMethod,
|
|
330
|
+
inputBuffer,
|
|
331
|
+
uncompressedSize,
|
|
332
|
+
)
|
|
333
|
+
if (buf.length !== uncompressedSize) {
|
|
334
|
+
const ret = new Uint8Array(uncompressedSize)
|
|
335
|
+
ret.set(buf, 0)
|
|
336
|
+
return ret
|
|
337
|
+
}
|
|
338
|
+
return buf
|
|
339
|
+
}
|
|
340
|
+
|
|
325
341
|
async readBlock(position: number) {
|
|
326
342
|
const { majorVersion } = await this.getDefinition()
|
|
327
343
|
const sectionParsers = getSectionParsers(majorVersion)
|
|
@@ -371,6 +371,7 @@ export default function decodeRecord(
|
|
|
371
371
|
|
|
372
372
|
// mapping quality
|
|
373
373
|
mappingQuality = decodeDataSeries('MQ')!
|
|
374
|
+
|
|
374
375
|
if (CramFlagsDecoder.isPreservingQualityScores(cramFlags)) {
|
|
375
376
|
qualityScores = new Array(readLength)
|
|
376
377
|
for (let i = 0; i < qualityScores.length; i++) {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
|
-
import
|
|
37
|
+
import Bunzip from 'seek-bzip'
|
|
38
38
|
|
|
39
39
|
import RangeCoder from './arith_sh'
|
|
40
40
|
import ByteModel from './byte_model'
|
|
@@ -154,18 +154,7 @@ export default class RangeCoderGen {
|
|
|
154
154
|
// ----------------------------------------------------------------------
|
|
155
155
|
// External codec
|
|
156
156
|
decodeExt(stream, n_out) {
|
|
157
|
-
|
|
158
|
-
let size = bzip2.header(bits)
|
|
159
|
-
let chunk
|
|
160
|
-
const chunks = []
|
|
161
|
-
do {
|
|
162
|
-
chunk = bzip2.decompress(bits, size)
|
|
163
|
-
if (chunk !== -1) {
|
|
164
|
-
chunks.push(chunk)
|
|
165
|
-
size -= chunk.length
|
|
166
|
-
}
|
|
167
|
-
} while (chunk !== -1)
|
|
168
|
-
return concatUint8Array(chunks)
|
|
157
|
+
return Bunzip.decode(stream.buf.slice(stream.pos))
|
|
169
158
|
}
|
|
170
159
|
|
|
171
160
|
// ----------------------------------------------------------------------
|