@gmod/cram 2.0.4 → 3.0.1
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 +10 -0
- package/dist/cram-bundle.js +1 -1
- package/dist/cramFile/codecs/byteArrayLength.js +1 -1
- package/dist/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayStop.js +1 -1
- package/dist/cramFile/codecs/external.js +1 -1
- package/dist/cramFile/codecs/external.js.map +1 -1
- package/dist/cramFile/codecs/huffman.js +3 -2
- package/dist/cramFile/codecs/huffman.js.map +1 -1
- package/dist/cramFile/codecs/subexp.js.map +1 -1
- package/dist/cramFile/container/compressionScheme.d.ts +0 -3
- package/dist/cramFile/container/compressionScheme.js +0 -4
- package/dist/cramFile/container/compressionScheme.js.map +1 -1
- package/dist/cramFile/container/index.d.ts +57 -3
- package/dist/cramFile/container/index.js +21 -12
- package/dist/cramFile/container/index.js.map +1 -1
- package/dist/cramFile/file.d.ts +25 -59
- package/dist/cramFile/file.js +33 -37
- package/dist/cramFile/file.js.map +1 -1
- package/dist/cramFile/record.d.ts +1 -1
- package/dist/cramFile/record.js +2 -2
- package/dist/cramFile/record.js.map +1 -1
- package/dist/cramFile/sectionParsers.d.ts +195 -48
- package/dist/cramFile/sectionParsers.js +621 -303
- package/dist/cramFile/sectionParsers.js.map +1 -1
- package/dist/cramFile/slice/decodeRecord.js +5 -4
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/cramFile/slice/index.d.ts +23 -1
- package/dist/cramFile/slice/index.js +11 -8
- package/dist/cramFile/slice/index.js.map +1 -1
- package/dist/cramFile/util.d.ts +6 -4
- package/dist/cramFile/util.js +88 -6
- package/dist/cramFile/util.js.map +1 -1
- package/dist/rans/d04.js.map +1 -1
- package/dist/rans/decoding.d.ts +4 -4
- package/dist/rans/decoding.js +5 -6
- package/dist/rans/decoding.js.map +1 -1
- package/dist/rans/index.js +4 -3
- package/dist/rans/index.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayLength.js +1 -1
- package/esm/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayStop.js +1 -1
- package/esm/cramFile/codecs/external.js +1 -1
- package/esm/cramFile/codecs/external.js.map +1 -1
- package/esm/cramFile/codecs/huffman.js +3 -2
- package/esm/cramFile/codecs/huffman.js.map +1 -1
- package/esm/cramFile/codecs/subexp.js.map +1 -1
- package/esm/cramFile/container/compressionScheme.d.ts +0 -3
- package/esm/cramFile/container/compressionScheme.js +0 -4
- package/esm/cramFile/container/compressionScheme.js.map +1 -1
- package/esm/cramFile/container/index.d.ts +57 -3
- package/esm/cramFile/container/index.js +19 -10
- package/esm/cramFile/container/index.js.map +1 -1
- package/esm/cramFile/file.d.ts +25 -59
- package/esm/cramFile/file.js +27 -29
- package/esm/cramFile/file.js.map +1 -1
- package/esm/cramFile/record.d.ts +1 -1
- package/esm/cramFile/record.js +2 -2
- package/esm/cramFile/record.js.map +1 -1
- package/esm/cramFile/sectionParsers.d.ts +195 -48
- package/esm/cramFile/sectionParsers.js +620 -303
- package/esm/cramFile/sectionParsers.js.map +1 -1
- package/esm/cramFile/slice/decodeRecord.js +5 -4
- package/esm/cramFile/slice/decodeRecord.js.map +1 -1
- package/esm/cramFile/slice/index.d.ts +23 -1
- package/esm/cramFile/slice/index.js +12 -9
- package/esm/cramFile/slice/index.js.map +1 -1
- package/esm/cramFile/util.d.ts +6 -4
- package/esm/cramFile/util.js +87 -6
- package/esm/cramFile/util.js.map +1 -1
- package/esm/rans/d04.js.map +1 -1
- package/esm/rans/decoding.d.ts +4 -4
- package/esm/rans/decoding.js +5 -6
- package/esm/rans/decoding.js.map +1 -1
- package/esm/rans/index.js +3 -2
- package/esm/rans/index.js.map +1 -1
- package/package.json +7 -8
- package/src/cramFile/codecs/byteArrayLength.ts +1 -2
- package/src/cramFile/codecs/byteArrayStop.ts +1 -1
- package/src/cramFile/codecs/external.ts +1 -1
- package/src/cramFile/codecs/huffman.ts +3 -2
- package/src/cramFile/codecs/subexp.ts +2 -2
- package/src/cramFile/container/compressionScheme.ts +1 -8
- package/src/cramFile/container/index.ts +23 -12
- package/src/cramFile/declare.d.ts +1 -0
- package/src/cramFile/file.ts +37 -53
- package/src/cramFile/record.ts +4 -7
- package/src/cramFile/sectionParsers.ts +668 -390
- package/src/cramFile/slice/decodeRecord.ts +20 -12
- package/src/cramFile/slice/index.ts +13 -7
- package/src/cramFile/util.ts +91 -92
- package/src/rans/d04.ts +1 -1
- package/src/rans/decoding.ts +5 -7
- package/src/rans/index.ts +3 -2
- package/src/typings/binary-parser.d.ts +0 -44
package/esm/rans/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/rans/index.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE9C,OAAO,QAAQ,MAAM,YAAY,CAAA;AACjC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAExD,OAAO,GAAG,MAAM,OAAO,CAAA;AACvB,OAAO,GAAG,MAAM,OAAO,CAAA;AAEvB,wCAAwC;AACxC,6CAA6C;AAC7C,MAAM,SAAS,CAAC,eAAe,GAAG,CAAC,CAAA;AACnC,uCAAuC;AACvC,iEAAiE;AAEjE,eAAe;AACf,iBAAiB;AAEjB,oDAAoD;AACpD,gBAAgB;AAChB,4CAA4C;AAC5C,6DAA6D;AAC7D,0EAA0E;AAC1E,YAAY;AACZ,QAAQ;AACR,IAAI;AAEJ,gGAAgG;AAChG,kCAAkC;AAClC,+BAA+B;AAE/B,iCAAiC;AACjC,iDAAiD;AAEjD,uBAAuB;AACvB,qBAAqB;AACrB,qDAAqD;AACrD,oBAAoB;AACpB,qDAAqD;AAErD,mBAAmB;AACnB,0EAA0E;AAC1E,QAAQ;AACR,IAAI;AAEJ,oEAAoE;AACpE,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AC,CAAA;IAC7D,CAAC;IAED,MAAM,SAAS,CAAC,SAAS,GAAG,KAAK,CAAC,MAAM,EAAE,CAAA;IAC1C,IAAI,SAAS,KAAK,KAAK,CAAC,SAAS,EAAE,GAAG,eAAe,EAAE,CAAC;QACtD,MAAM,IAAI,kBAAkB,CAAC,yBAAyB,CAAC,CAAA;IACzD,CAAC;IAED,MAAM,SAAS,CAAC,UAAU,GAAG,KAAK,CAAC,MAAM,EAAE,CAAA;IAC3C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,YAAY,IAAI,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAA;IAC7E,gCAAgC;IAEhC,IAAI,MAAM,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;QAC/B,MAAM,IAAI,kBAAkB,CAC1B,kCAAkC,UAAU,SAAS,CACtD,CAAA;IACH,CAAC;IAED,QAAQ,KAAK,EAAE,CAAC;QACd,KAAK,CAAC;YACJ,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAE5C,KAAK,CAAC;YACJ,OAAO,oBAAoB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAE5C;YACE,MAAM,IAAI,kBAAkB,CAAC,uBAAuB,KAAK,EAAE,CAAC,CAAA;IAChE,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gmod/cram",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "read CRAM files with pure Javascript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "GMOD/cram-js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"test": "jest",
|
|
25
|
-
"lint": "eslint src test",
|
|
25
|
+
"lint": "eslint --report-unused-disable-directives --max-warnings 0 src test",
|
|
26
26
|
"docs": "documentation readme --shallow src/indexedCramFile.ts --section=IndexedCramFile; documentation readme --shallow src/cramFile/file.ts --section=CramFile; documentation readme --shallow src/craiIndex.ts --section=CraiIndex; documentation readme --shallow errors.ts '--section=Exception Classes'; documentation readme --shallow src/cramFile/file.ts --section=CramFile; documentation readme --shallow src/cramFile/record.ts --section=CramRecord",
|
|
27
27
|
"prebuild": "npm run clean",
|
|
28
28
|
"clean": "rimraf dist esm",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@gmod/abortable-promise-cache": "^2.0.0",
|
|
46
|
-
"@gmod/binary-parser": "^1.3.5",
|
|
47
46
|
"@jkbonfield/htscodecs": "^0.5.1",
|
|
48
47
|
"buffer-crc32": "^1.0.0",
|
|
49
48
|
"bzip2": "^0.1.1",
|
|
@@ -59,18 +58,18 @@
|
|
|
59
58
|
"@types/long": "^4.0.0",
|
|
60
59
|
"@types/md5": "^2.3.2",
|
|
61
60
|
"@types/pako": "^1.0.3",
|
|
62
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
63
|
-
"@typescript-eslint/parser": "^
|
|
61
|
+
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
62
|
+
"@typescript-eslint/parser": "^8.0.0",
|
|
64
63
|
"buffer": "^6.0.3",
|
|
65
64
|
"documentation": "^14.0.3",
|
|
66
|
-
"eslint": "^9.
|
|
65
|
+
"eslint": "^9.8.0",
|
|
67
66
|
"eslint-config-prettier": "^9.0.0",
|
|
68
67
|
"eslint-plugin-prettier": "^5.1.3",
|
|
69
|
-
"eslint-plugin-unicorn": "^
|
|
68
|
+
"eslint-plugin-unicorn": "^55.0.0",
|
|
70
69
|
"jest": "^29.3.1",
|
|
71
70
|
"mock-fs": "^5.2.0",
|
|
72
71
|
"prettier": "^3.2.5",
|
|
73
|
-
"rimraf": "^
|
|
72
|
+
"rimraf": "^6.0.1",
|
|
74
73
|
"ts-jest": "^29.1.2",
|
|
75
74
|
"typescript": "^5.0.3",
|
|
76
75
|
"webpack": "^5.90.3",
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { tinyMemoize } from '../util'
|
|
2
|
-
|
|
3
1
|
import CramCodec, { Cursors } from './_base'
|
|
4
2
|
import { ByteArrayLengthEncoding, CramEncoding } from '../encoding'
|
|
5
3
|
import CramSlice from '../slice'
|
|
6
4
|
import { CramFileBlock } from '../file'
|
|
7
5
|
import { DataType } from './dataSeriesTypes'
|
|
6
|
+
import { tinyMemoize } from '../util'
|
|
8
7
|
|
|
9
8
|
type CramCodecFactory = <TData extends DataType = DataType>(
|
|
10
9
|
encodingData: CramEncoding,
|
|
@@ -51,7 +51,7 @@ export default class ByteArrayStopCodec extends CramCodec<
|
|
|
51
51
|
) {
|
|
52
52
|
if (stopPosition === dataBuffer.length) {
|
|
53
53
|
throw new CramBufferOverrunError(
|
|
54
|
-
|
|
54
|
+
'byteArrayStop reading beyond length of data buffer?',
|
|
55
55
|
)
|
|
56
56
|
}
|
|
57
57
|
stopPosition = stopPosition + 1
|
|
@@ -42,7 +42,7 @@ export default class ExternalCodec extends CramCodec<
|
|
|
42
42
|
const contentBlock = blocksByContentId[blockContentId]
|
|
43
43
|
if (!contentBlock) {
|
|
44
44
|
throw new CramMalformedError(
|
|
45
|
-
`no block found with content ID ${blockContentId}`,
|
|
45
|
+
`no block found with content ID ${blockContentId}}`,
|
|
46
46
|
)
|
|
47
47
|
}
|
|
48
48
|
const cursor = cursors.externalBlocks.getCursor(blockContentId)
|
|
@@ -46,7 +46,8 @@ export default class HuffmanIntCodec extends CramCodec<
|
|
|
46
46
|
this.buildCodes()
|
|
47
47
|
this.buildCaches()
|
|
48
48
|
|
|
49
|
-
// if this is a degenerate zero-length huffman code, special-case the
|
|
49
|
+
// if this is a degenerate zero-length huffman code, special-case the
|
|
50
|
+
// decoding
|
|
50
51
|
if (this.sortedCodes[0].bitLength === 0) {
|
|
51
52
|
this._decode = this._decodeZeroLengthCode
|
|
52
53
|
}
|
|
@@ -82,7 +83,7 @@ export default class HuffmanIntCodec extends CramCodec<
|
|
|
82
83
|
let codeLength = 0
|
|
83
84
|
let codeValue = -1
|
|
84
85
|
Object.entries(this.codeBook).forEach(([bitLength, symbols]) => {
|
|
85
|
-
const bitLengthInt = parseInt(bitLength, 10)
|
|
86
|
+
const bitLengthInt = Number.parseInt(bitLength, 10)
|
|
86
87
|
symbols.forEach(symbol => {
|
|
87
88
|
const code = {
|
|
88
89
|
bitLength: bitLengthInt,
|
|
@@ -29,8 +29,8 @@ export default class SubexpCodec extends CramCodec<
|
|
|
29
29
|
numLeadingOnes = numLeadingOnes + 1
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
let b
|
|
33
|
-
let n
|
|
32
|
+
let b: number
|
|
33
|
+
let n: number
|
|
34
34
|
if (numLeadingOnes === 0) {
|
|
35
35
|
b = this.parameters.K
|
|
36
36
|
n = getBits(coreDataBlock.content, cursors.coreBlock, b)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { instantiateCodec } from '../codecs'
|
|
2
2
|
import CramCodec from '../codecs/_base'
|
|
3
|
-
import { CramCompressionHeader
|
|
3
|
+
import { CramCompressionHeader } from '../sectionParsers'
|
|
4
4
|
import { CramEncoding } from '../encoding'
|
|
5
5
|
import { CramMalformedError } from '../../errors'
|
|
6
6
|
import {
|
|
@@ -95,12 +95,8 @@ export default class CramContainerCompressionScheme {
|
|
|
95
95
|
public tagCodecCache: Record<string, CramCodec> = {}
|
|
96
96
|
public tagEncoding: Record<string, CramEncoding> = {}
|
|
97
97
|
public dataSeriesEncoding: DataSeriesEncodingMap
|
|
98
|
-
private preservation: CramPreservationMap
|
|
99
|
-
private _endPosition: number
|
|
100
|
-
private _size: number
|
|
101
98
|
|
|
102
99
|
constructor(content: CramCompressionHeader) {
|
|
103
|
-
// Object.assign(this, content)
|
|
104
100
|
// interpret some of the preservation map tags for convenient use
|
|
105
101
|
this.readNamesIncluded = content.preservation.RN
|
|
106
102
|
this.APdelta = content.preservation.AP
|
|
@@ -109,9 +105,6 @@ export default class CramContainerCompressionScheme {
|
|
|
109
105
|
this.substitutionMatrix = parseSubstitutionMatrix(content.preservation.SM)
|
|
110
106
|
this.dataSeriesEncoding = content.dataSeriesEncoding
|
|
111
107
|
this.tagEncoding = content.tagEncoding
|
|
112
|
-
this.preservation = content.preservation
|
|
113
|
-
this._size = content._size
|
|
114
|
-
this._endPosition = content._endPosition
|
|
115
108
|
}
|
|
116
109
|
|
|
117
110
|
/**
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { Buffer } from 'buffer'
|
|
1
2
|
import { CramMalformedError } from '../../errors'
|
|
2
|
-
|
|
3
|
+
// locals
|
|
3
4
|
import { itf8Size, parseItem, tinyMemoize } from '../util'
|
|
4
5
|
import CramSlice from '../slice'
|
|
5
6
|
import CramContainerCompressionScheme from './compressionScheme'
|
|
6
7
|
import CramFile from '../file'
|
|
8
|
+
import { getSectionParsers } from '../sectionParsers'
|
|
7
9
|
|
|
8
10
|
export default class CramContainer {
|
|
9
11
|
constructor(
|
|
@@ -11,29 +13,31 @@ export default class CramContainer {
|
|
|
11
13
|
public filePosition: number,
|
|
12
14
|
) {}
|
|
13
15
|
|
|
14
|
-
// memoize
|
|
15
16
|
getHeader() {
|
|
16
17
|
return this._readContainerHeader(this.filePosition)
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
// memoize
|
|
20
20
|
async getCompressionHeaderBlock() {
|
|
21
21
|
const containerHeader = await this.getHeader()
|
|
22
22
|
|
|
23
|
-
// if there are no records in the container, there will be no compression
|
|
24
|
-
|
|
23
|
+
// if there are no records in the container, there will be no compression
|
|
24
|
+
// header
|
|
25
|
+
if (!containerHeader?.numRecords) {
|
|
25
26
|
return null
|
|
26
27
|
}
|
|
27
|
-
const
|
|
28
|
+
const { majorVersion } = await this.file.getDefinition()
|
|
29
|
+
const sectionParsers = getSectionParsers(majorVersion)
|
|
30
|
+
|
|
28
31
|
const block = await this.getFirstBlock()
|
|
29
32
|
if (block === undefined) {
|
|
30
33
|
return undefined
|
|
31
34
|
}
|
|
32
35
|
if (block.contentType !== 'COMPRESSION_HEADER') {
|
|
33
36
|
throw new CramMalformedError(
|
|
34
|
-
`invalid content type ${block.contentType} in
|
|
37
|
+
`invalid content type ${block.contentType} in compression header block`,
|
|
35
38
|
)
|
|
36
39
|
}
|
|
40
|
+
|
|
37
41
|
const content = parseItem(
|
|
38
42
|
block.content,
|
|
39
43
|
sectionParsers.cramCompressionHeader.parser,
|
|
@@ -48,16 +52,20 @@ export default class CramContainer {
|
|
|
48
52
|
|
|
49
53
|
async getFirstBlock() {
|
|
50
54
|
const containerHeader = await this.getHeader()
|
|
55
|
+
if (!containerHeader) {
|
|
56
|
+
return undefined
|
|
57
|
+
}
|
|
51
58
|
return this.file.readBlock(containerHeader._endPosition)
|
|
52
59
|
}
|
|
53
60
|
|
|
54
|
-
// parses the compression header data into a CramContainerCompressionScheme
|
|
55
|
-
//
|
|
61
|
+
// parses the compression header data into a CramContainerCompressionScheme
|
|
62
|
+
// object
|
|
56
63
|
async getCompressionScheme() {
|
|
57
64
|
const header = await this.getCompressionHeaderBlock()
|
|
58
65
|
if (!header) {
|
|
59
66
|
return undefined
|
|
60
67
|
}
|
|
68
|
+
|
|
61
69
|
return new CramContainerCompressionScheme(header.parsedContent)
|
|
62
70
|
}
|
|
63
71
|
|
|
@@ -68,11 +76,13 @@ export default class CramContainer {
|
|
|
68
76
|
}
|
|
69
77
|
|
|
70
78
|
async _readContainerHeader(position: number) {
|
|
71
|
-
const
|
|
79
|
+
const { majorVersion } = await this.file.getDefinition()
|
|
80
|
+
const sectionParsers = getSectionParsers(majorVersion)
|
|
72
81
|
const { cramContainerHeader1, cramContainerHeader2 } = sectionParsers
|
|
73
82
|
const { size: fileSize } = await this.file.stat()
|
|
74
83
|
|
|
75
84
|
if (position >= fileSize) {
|
|
85
|
+
console.warn(`pos:${position}>=fileSize:${fileSize} in cram container`)
|
|
76
86
|
return undefined
|
|
77
87
|
}
|
|
78
88
|
|
|
@@ -80,11 +90,12 @@ export default class CramContainer {
|
|
|
80
90
|
// how much to buffer until you read numLandmarks
|
|
81
91
|
const bytes1 = Buffer.allocUnsafe(cramContainerHeader1.maxLength)
|
|
82
92
|
await this.file.read(bytes1, 0, cramContainerHeader1.maxLength, position)
|
|
83
|
-
const header1 = parseItem(bytes1, cramContainerHeader1.parser)
|
|
93
|
+
const header1 = parseItem(bytes1, cramContainerHeader1.parser)
|
|
84
94
|
const numLandmarksSize = itf8Size(header1.numLandmarks)
|
|
85
95
|
if (position + header1.length >= fileSize) {
|
|
96
|
+
// header indicates container goes beyond fileSize
|
|
86
97
|
console.warn(
|
|
87
|
-
|
|
98
|
+
`container at ${position} is beyond fileSize:${fileSize}, skipping`,
|
|
88
99
|
)
|
|
89
100
|
return undefined
|
|
90
101
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare module 'bzip2'
|
package/src/cramFile/file.ts
CHANGED
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Buffer } from 'buffer'
|
|
2
2
|
import crc32 from 'buffer-crc32'
|
|
3
3
|
import QuickLRU from 'quick-lru'
|
|
4
4
|
import htscodecs from '@jkbonfield/htscodecs'
|
|
5
|
-
import { Parser } from '@gmod/binary-parser'
|
|
6
|
-
// @ts-expect-error
|
|
7
5
|
import bzip2 from 'bzip2'
|
|
8
6
|
import { XzReadableStream } from 'xz-decompress'
|
|
9
7
|
import { CramMalformedError, CramUnimplementedError } from '../errors'
|
|
8
|
+
// locals
|
|
9
|
+
import { unzip } from '../unzip'
|
|
10
10
|
import ransuncompress from '../rans'
|
|
11
11
|
import {
|
|
12
12
|
BlockHeader,
|
|
13
13
|
CompressionMethod,
|
|
14
|
-
cramFileDefinition
|
|
14
|
+
cramFileDefinition,
|
|
15
15
|
getSectionParsers,
|
|
16
16
|
} from './sectionParsers'
|
|
17
|
-
|
|
18
17
|
import CramContainer from './container'
|
|
19
|
-
|
|
18
|
+
import CramRecord from './record'
|
|
20
19
|
import { open } from '../io'
|
|
21
20
|
import { parseItem, tinyMemoize } from './util'
|
|
22
21
|
import { parseHeaderText } from '../sam'
|
|
23
|
-
import CramRecord from './record'
|
|
24
22
|
import { Filehandle } from './filehandle'
|
|
25
23
|
|
|
26
24
|
function bufferToStream(buf: Buffer) {
|
|
@@ -32,25 +30,20 @@ function bufferToStream(buf: Buffer) {
|
|
|
32
30
|
})
|
|
33
31
|
}
|
|
34
32
|
|
|
35
|
-
//source:https://abdulapopoola.com/2019/01/20/check-endianness-with-javascript/
|
|
33
|
+
// source: https://abdulapopoola.com/2019/01/20/check-endianness-with-javascript/
|
|
36
34
|
function getEndianness() {
|
|
37
35
|
const uInt32 = new Uint32Array([0x11223344])
|
|
38
36
|
const uInt8 = new Uint8Array(uInt32.buffer)
|
|
39
37
|
|
|
40
38
|
if (uInt8[0] === 0x44) {
|
|
41
|
-
return 0 //little-endian
|
|
39
|
+
return 0 // little-endian
|
|
42
40
|
} else if (uInt8[0] === 0x11) {
|
|
43
|
-
return 1 //big-endian
|
|
41
|
+
return 1 // big-endian
|
|
44
42
|
} else {
|
|
45
|
-
return 2 //mixed-endian?
|
|
43
|
+
return 2 // mixed-endian?
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
// export type CramFileSource =
|
|
50
|
-
// | { url: string; path?: undefined; filehandle?: undefined }
|
|
51
|
-
// | { path: string; url?: undefined; filehandle?: undefined }
|
|
52
|
-
// | { filehandle: Filehandle; url?: undefined; path?: undefined }
|
|
53
|
-
|
|
54
47
|
export interface CramFileSource {
|
|
55
48
|
filehandle?: Filehandle
|
|
56
49
|
url?: string
|
|
@@ -110,15 +103,7 @@ export default class CramFile {
|
|
|
110
103
|
}
|
|
111
104
|
|
|
112
105
|
// can just read this object like a filehandle
|
|
113
|
-
read(
|
|
114
|
-
buffer: Buffer,
|
|
115
|
-
offset: number,
|
|
116
|
-
length: number,
|
|
117
|
-
position: number,
|
|
118
|
-
): Promise<{
|
|
119
|
-
bytesRead: number
|
|
120
|
-
buffer: Buffer
|
|
121
|
-
}> {
|
|
106
|
+
read(buffer: Buffer, offset: number, length: number, position: number) {
|
|
122
107
|
return this.file.read(buffer, offset, length, position)
|
|
123
108
|
}
|
|
124
109
|
|
|
@@ -129,10 +114,10 @@ export default class CramFile {
|
|
|
129
114
|
|
|
130
115
|
// memoized
|
|
131
116
|
async getDefinition() {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
117
|
+
const { maxLength, parser } = cramFileDefinition()
|
|
118
|
+
const headbytes = Buffer.allocUnsafe(maxLength)
|
|
119
|
+
await this.file.read(headbytes, 0, maxLength, 0)
|
|
120
|
+
const definition = parser(headbytes).value
|
|
136
121
|
if (definition.majorVersion !== 2 && definition.majorVersion !== 3) {
|
|
137
122
|
throw new CramUnimplementedError(
|
|
138
123
|
`CRAM version ${definition.majorVersion} not supported`,
|
|
@@ -169,21 +154,16 @@ export default class CramFile {
|
|
|
169
154
|
return this.header
|
|
170
155
|
}
|
|
171
156
|
|
|
172
|
-
// memoize
|
|
173
|
-
async getSectionParsers() {
|
|
174
|
-
const { majorVersion } = await this.getDefinition()
|
|
175
|
-
return getSectionParsers(majorVersion)
|
|
176
|
-
}
|
|
177
|
-
|
|
178
157
|
async getContainerById(containerNumber: number) {
|
|
179
|
-
const
|
|
158
|
+
const { majorVersion } = await this.getDefinition()
|
|
159
|
+
const sectionParsers = getSectionParsers(majorVersion)
|
|
180
160
|
let position = sectionParsers.cramFileDefinition.maxLength
|
|
181
161
|
const { size: fileSize } = await this.file.stat()
|
|
182
162
|
const { cramContainerHeader1 } = sectionParsers
|
|
183
163
|
|
|
184
164
|
// skip with a series of reads to the proper container
|
|
185
|
-
let currentContainer
|
|
186
|
-
for (let i = 0; i <= containerNumber; i
|
|
165
|
+
let currentContainer: CramContainer | undefined
|
|
166
|
+
for (let i = 0; i <= containerNumber; i++) {
|
|
187
167
|
// if we are about to go off the end of the file
|
|
188
168
|
// and have not found that container, it does not exist
|
|
189
169
|
if (position + cramContainerHeader1.maxLength + 8 >= fileSize) {
|
|
@@ -197,13 +177,12 @@ export default class CramFile {
|
|
|
197
177
|
`container ${containerNumber} not found in file`,
|
|
198
178
|
)
|
|
199
179
|
}
|
|
200
|
-
// if this is the first container, read all the blocks in the
|
|
201
|
-
//
|
|
202
|
-
//
|
|
203
|
-
// in htslib
|
|
180
|
+
// if this is the first container, read all the blocks in the container
|
|
181
|
+
// to determine its length, because we cannot trust the container
|
|
182
|
+
// header's given length due to a bug somewhere in htslib
|
|
204
183
|
if (i === 0) {
|
|
205
184
|
position = currentHeader._endPosition
|
|
206
|
-
for (let j = 0; j < currentHeader.numBlocks; j
|
|
185
|
+
for (let j = 0; j < currentHeader.numBlocks; j++) {
|
|
207
186
|
const block = await this.readBlock(position)
|
|
208
187
|
if (block === undefined) {
|
|
209
188
|
return undefined
|
|
@@ -239,7 +218,8 @@ export default class CramFile {
|
|
|
239
218
|
* @returns {Promise[number]} the number of containers in the file
|
|
240
219
|
*/
|
|
241
220
|
async containerCount(): Promise<number | undefined> {
|
|
242
|
-
const
|
|
221
|
+
const { majorVersion } = await this.getDefinition()
|
|
222
|
+
const sectionParsers = getSectionParsers(majorVersion)
|
|
243
223
|
const { size: fileSize } = await this.file.stat()
|
|
244
224
|
const { cramContainerHeader1 } = sectionParsers
|
|
245
225
|
|
|
@@ -256,7 +236,7 @@ export default class CramFile {
|
|
|
256
236
|
// header's given length due to a bug somewhere in htslib
|
|
257
237
|
if (containerCount === 0) {
|
|
258
238
|
position = currentHeader._endPosition
|
|
259
|
-
for (let j = 0; j < currentHeader.numBlocks; j
|
|
239
|
+
for (let j = 0; j < currentHeader.numBlocks; j++) {
|
|
260
240
|
const block = await this.readBlock(position)
|
|
261
241
|
if (block === undefined) {
|
|
262
242
|
return undefined
|
|
@@ -278,7 +258,8 @@ export default class CramFile {
|
|
|
278
258
|
}
|
|
279
259
|
|
|
280
260
|
async readBlockHeader(position: number) {
|
|
281
|
-
const
|
|
261
|
+
const { majorVersion } = await this.getDefinition()
|
|
262
|
+
const sectionParsers = getSectionParsers(majorVersion)
|
|
282
263
|
const { cramBlockHeader } = sectionParsers
|
|
283
264
|
const { size: fileSize } = await this.file.stat()
|
|
284
265
|
|
|
@@ -292,12 +273,15 @@ export default class CramFile {
|
|
|
292
273
|
}
|
|
293
274
|
|
|
294
275
|
async _parseSection<T>(
|
|
295
|
-
section: {
|
|
276
|
+
section: {
|
|
277
|
+
maxLength: number
|
|
278
|
+
parser: (buffer: Buffer, offset: number) => { offset: number; value: T }
|
|
279
|
+
},
|
|
296
280
|
position: number,
|
|
297
281
|
size = section.maxLength,
|
|
298
282
|
preReadBuffer = undefined,
|
|
299
283
|
) {
|
|
300
|
-
let buffer
|
|
284
|
+
let buffer: Buffer
|
|
301
285
|
if (preReadBuffer) {
|
|
302
286
|
buffer = preReadBuffer
|
|
303
287
|
} else {
|
|
@@ -329,15 +313,15 @@ export default class CramFile {
|
|
|
329
313
|
const bits = bzip2.array(inputBuffer)
|
|
330
314
|
let size = bzip2.header(bits)
|
|
331
315
|
let j = 0
|
|
332
|
-
let chunk
|
|
316
|
+
let chunk: Uint8Array | -1
|
|
333
317
|
do {
|
|
334
318
|
chunk = bzip2.decompress(bits, size)
|
|
335
|
-
if (chunk
|
|
319
|
+
if (chunk !== -1) {
|
|
336
320
|
Buffer.from(chunk).copy(outputBuffer, j)
|
|
337
321
|
j += chunk.length
|
|
338
322
|
size -= chunk.length
|
|
339
323
|
}
|
|
340
|
-
} while (chunk
|
|
324
|
+
} while (chunk !== -1)
|
|
341
325
|
} else if (compressionMethod === 'lzma') {
|
|
342
326
|
const decompressedResponse = new Response(
|
|
343
327
|
new XzReadableStream(bufferToStream(inputBuffer)),
|
|
@@ -363,9 +347,9 @@ export default class CramFile {
|
|
|
363
347
|
}
|
|
364
348
|
}
|
|
365
349
|
|
|
366
|
-
async readBlock(position: number)
|
|
350
|
+
async readBlock(position: number) {
|
|
367
351
|
const { majorVersion } = await this.getDefinition()
|
|
368
|
-
const sectionParsers =
|
|
352
|
+
const sectionParsers = getSectionParsers(majorVersion)
|
|
369
353
|
const blockHeader = await this.readBlockHeader(position)
|
|
370
354
|
if (blockHeader === undefined) {
|
|
371
355
|
return undefined
|
package/src/cramFile/record.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Constants from './constants'
|
|
2
2
|
import CramContainerCompressionScheme from './container/compressionScheme'
|
|
3
|
-
import decodeRecord from './slice/decodeRecord'
|
|
3
|
+
import type decodeRecord from './slice/decodeRecord'
|
|
4
4
|
|
|
5
5
|
export interface RefRegion {
|
|
6
6
|
start: number
|
|
@@ -18,10 +18,7 @@ export interface ReadFeature {
|
|
|
18
18
|
sub?: string
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function decodeReadSequence(
|
|
22
|
-
cramRecord: CramRecord,
|
|
23
|
-
refRegion: RefRegion,
|
|
24
|
-
): string | null {
|
|
21
|
+
function decodeReadSequence(cramRecord: CramRecord, refRegion: RefRegion) {
|
|
25
22
|
// if it has no length, it has no sequence
|
|
26
23
|
if (!cramRecord.lengthOnRef && !cramRecord.readLength) {
|
|
27
24
|
return null
|
|
@@ -215,8 +212,8 @@ function makeFlagsHelper<T>(
|
|
|
215
212
|
): FlagsDecoder<T> & FlagsEncoder<T> {
|
|
216
213
|
const r: any = {}
|
|
217
214
|
for (const [code, name] of x) {
|
|
218
|
-
r[
|
|
219
|
-
r[
|
|
215
|
+
r[`is${name}`] = (flags: number) => !!(flags & code)
|
|
216
|
+
r[`set${name}`] = (flags: number) => flags | code
|
|
220
217
|
}
|
|
221
218
|
|
|
222
219
|
return r
|