@gmod/cram 1.6.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/craiIndex.d.ts +19 -12
- package/dist/craiIndex.js +63 -123
- package/dist/craiIndex.js.map +1 -1
- package/dist/cram-bundle.js +2 -17
- package/dist/cram-bundle.js.LICENSE.txt +17 -0
- package/dist/cramFile/codecs/_base.d.ts +26 -5
- package/dist/cramFile/codecs/_base.js +3 -39
- package/dist/cramFile/codecs/_base.js.map +1 -1
- package/dist/cramFile/codecs/beta.d.ts +7 -3
- package/dist/cramFile/codecs/beta.js +13 -31
- package/dist/cramFile/codecs/beta.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayLength.d.ts +13 -7
- package/dist/cramFile/codecs/byteArrayLength.js +22 -41
- package/dist/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/dist/cramFile/codecs/byteArrayStop.d.ts +9 -5
- package/dist/cramFile/codecs/byteArrayStop.js +25 -46
- package/dist/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/dist/cramFile/codecs/dataSeriesTypes.d.ts +4 -0
- package/dist/cramFile/codecs/dataSeriesTypes.js +3 -0
- package/dist/cramFile/codecs/dataSeriesTypes.js.map +1 -0
- package/dist/cramFile/codecs/external.d.ts +10 -6
- package/dist/cramFile/codecs/external.js +26 -44
- package/dist/cramFile/codecs/external.js.map +1 -1
- package/dist/cramFile/codecs/gamma.d.ts +7 -3
- package/dist/cramFile/codecs/gamma.js +16 -34
- package/dist/cramFile/codecs/gamma.js.map +1 -1
- package/dist/cramFile/codecs/getBits.d.ts +7 -0
- package/dist/cramFile/codecs/getBits.js +26 -0
- package/dist/cramFile/codecs/getBits.js.map +1 -0
- package/dist/cramFile/codecs/huffman.d.ts +17 -13
- package/dist/cramFile/codecs/huffman.js +76 -85
- package/dist/cramFile/codecs/huffman.js.map +1 -1
- package/dist/cramFile/codecs/index.d.ts +4 -2
- package/dist/cramFile/codecs/index.js +12 -13
- package/dist/cramFile/codecs/index.js.map +1 -1
- package/dist/cramFile/codecs/subexp.d.ts +7 -3
- package/dist/cramFile/codecs/subexp.js +19 -36
- package/dist/cramFile/codecs/subexp.js.map +1 -1
- package/dist/cramFile/constants.d.ts +35 -35
- package/dist/cramFile/constants.js +1 -1
- package/dist/cramFile/constants.js.map +1 -1
- package/dist/cramFile/container/compressionScheme.d.ts +57 -11
- package/dist/cramFile/container/compressionScheme.js +37 -32
- package/dist/cramFile/container/compressionScheme.js.map +1 -1
- package/dist/cramFile/container/index.d.ts +23 -9
- package/dist/cramFile/container/index.js +74 -144
- package/dist/cramFile/container/index.js.map +1 -1
- package/dist/cramFile/encoding.d.ts +78 -0
- package/dist/cramFile/encoding.js +3 -0
- package/dist/cramFile/encoding.js.map +1 -0
- package/dist/cramFile/file.d.ts +91 -41
- package/dist/cramFile/file.js +234 -368
- package/dist/cramFile/file.js.map +1 -1
- package/dist/cramFile/filehandle.d.ts +2 -0
- package/dist/cramFile/filehandle.js +3 -0
- package/dist/cramFile/filehandle.js.map +1 -0
- package/dist/cramFile/index.d.ts +1 -1
- package/dist/cramFile/index.js +1 -1
- package/dist/cramFile/index.js.map +1 -1
- package/dist/cramFile/record.d.ts +61 -17
- package/dist/cramFile/record.js +153 -77
- package/dist/cramFile/record.js.map +1 -1
- package/dist/cramFile/sectionParsers.d.ts +99 -8
- package/dist/cramFile/sectionParsers.js +70 -80
- package/dist/cramFile/sectionParsers.js.map +1 -1
- package/dist/cramFile/slice/decodeRecord.d.ts +30 -2
- package/dist/cramFile/slice/decodeRecord.js +148 -118
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/cramFile/slice/index.d.ts +21 -14
- package/dist/cramFile/slice/index.js +286 -381
- package/dist/cramFile/slice/index.js.map +1 -1
- package/dist/cramFile/util.d.ts +11 -5
- package/dist/cramFile/util.js +19 -97
- package/dist/cramFile/util.js.map +1 -1
- package/dist/errors.d.ts +5 -10
- package/dist/errors.js +11 -62
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/indexedCramFile.d.ts +37 -12
- package/dist/indexedCramFile.js +114 -154
- package/dist/indexedCramFile.js.map +1 -1
- package/dist/io/index.d.ts +5 -5
- package/dist/io/index.js +9 -9
- package/dist/io/index.js.map +1 -1
- package/dist/rans/constants.js +3 -3
- package/dist/rans/constants.js.map +1 -1
- package/dist/rans/d04.js +15 -15
- package/dist/rans/d04.js.map +1 -1
- package/dist/rans/d14.js +21 -21
- package/dist/rans/d14.js.map +1 -1
- package/dist/rans/decoding.js +27 -30
- package/dist/rans/decoding.js.map +1 -1
- package/dist/rans/frequencies.js +11 -11
- package/dist/rans/frequencies.js.map +1 -1
- package/dist/rans/index.js +46 -49
- package/dist/rans/index.js.map +1 -1
- package/dist/sam.d.ts +8 -1
- package/dist/sam.js +7 -7
- package/dist/sam.js.map +1 -1
- package/dist/typescript.d.ts +3 -0
- package/dist/typescript.js +11 -0
- package/dist/typescript.js.map +1 -0
- package/dist/unzip-pako.js +1 -1
- package/dist/unzip-pako.js.map +1 -1
- package/dist/unzip.js +1 -1
- package/dist/unzip.js.map +1 -1
- package/errors.js +11 -62
- package/esm/craiIndex.d.ts +19 -12
- package/esm/craiIndex.js +8 -24
- package/esm/craiIndex.js.map +1 -1
- package/esm/cramFile/codecs/_base.d.ts +26 -5
- package/esm/cramFile/codecs/_base.js +1 -35
- package/esm/cramFile/codecs/_base.js.map +1 -1
- package/esm/cramFile/codecs/beta.d.ts +7 -3
- package/esm/cramFile/codecs/beta.js +4 -3
- package/esm/cramFile/codecs/beta.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayLength.d.ts +13 -7
- package/esm/cramFile/codecs/byteArrayLength.js +1 -1
- package/esm/cramFile/codecs/byteArrayLength.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayStop.d.ts +9 -5
- package/esm/cramFile/codecs/byteArrayStop.js +7 -9
- package/esm/cramFile/codecs/byteArrayStop.js.map +1 -1
- package/esm/cramFile/codecs/dataSeriesTypes.d.ts +4 -0
- package/esm/cramFile/codecs/dataSeriesTypes.js +2 -0
- package/esm/cramFile/codecs/dataSeriesTypes.js.map +1 -0
- package/esm/cramFile/codecs/external.d.ts +10 -6
- package/esm/cramFile/codecs/external.js +4 -3
- package/esm/cramFile/codecs/external.js.map +1 -1
- package/esm/cramFile/codecs/gamma.d.ts +7 -3
- package/esm/cramFile/codecs/gamma.js +5 -4
- package/esm/cramFile/codecs/gamma.js.map +1 -1
- package/esm/cramFile/codecs/getBits.d.ts +7 -0
- package/esm/cramFile/codecs/getBits.js +21 -0
- package/esm/cramFile/codecs/getBits.js.map +1 -0
- package/esm/cramFile/codecs/huffman.d.ts +17 -13
- package/esm/cramFile/codecs/huffman.js +22 -9
- package/esm/cramFile/codecs/huffman.js.map +1 -1
- package/esm/cramFile/codecs/index.d.ts +4 -2
- package/esm/cramFile/codecs/index.js +1 -1
- package/esm/cramFile/codecs/index.js.map +1 -1
- package/esm/cramFile/codecs/subexp.d.ts +7 -3
- package/esm/cramFile/codecs/subexp.js +7 -5
- package/esm/cramFile/codecs/subexp.js.map +1 -1
- package/esm/cramFile/constants.d.ts +35 -35
- package/esm/cramFile/constants.js.map +1 -1
- package/esm/cramFile/container/compressionScheme.d.ts +57 -11
- package/esm/cramFile/container/compressionScheme.js +15 -8
- package/esm/cramFile/container/compressionScheme.js.map +1 -1
- package/esm/cramFile/container/index.d.ts +23 -9
- package/esm/cramFile/container/index.js +11 -9
- package/esm/cramFile/container/index.js.map +1 -1
- package/esm/cramFile/encoding.d.ts +78 -0
- package/esm/cramFile/encoding.js +2 -0
- package/esm/cramFile/encoding.js.map +1 -0
- package/esm/cramFile/file.d.ts +91 -41
- package/esm/cramFile/file.js +59 -47
- package/esm/cramFile/file.js.map +1 -1
- package/esm/cramFile/filehandle.d.ts +2 -0
- package/esm/cramFile/filehandle.js +2 -0
- package/esm/cramFile/filehandle.js.map +1 -0
- package/esm/cramFile/index.d.ts +1 -1
- package/esm/cramFile/index.js.map +1 -1
- package/esm/cramFile/record.d.ts +61 -17
- package/esm/cramFile/record.js +83 -5
- package/esm/cramFile/record.js.map +1 -1
- package/esm/cramFile/sectionParsers.d.ts +99 -8
- package/esm/cramFile/sectionParsers.js +7 -17
- package/esm/cramFile/sectionParsers.js.map +1 -1
- package/esm/cramFile/slice/decodeRecord.d.ts +30 -2
- package/esm/cramFile/slice/decodeRecord.js +102 -70
- package/esm/cramFile/slice/decodeRecord.js.map +1 -1
- package/esm/cramFile/slice/index.d.ts +21 -14
- package/esm/cramFile/slice/index.js +77 -38
- package/esm/cramFile/slice/index.js.map +1 -1
- package/esm/cramFile/util.d.ts +11 -5
- package/esm/cramFile/util.js +11 -82
- package/esm/cramFile/util.js.map +1 -1
- package/esm/errors.d.ts +5 -10
- package/esm/errors.js +0 -5
- package/esm/errors.js.map +1 -1
- package/esm/index.d.ts +3 -3
- package/esm/index.js.map +1 -1
- package/esm/indexedCramFile.d.ts +37 -12
- package/esm/indexedCramFile.js +19 -8
- package/esm/indexedCramFile.js.map +1 -1
- package/esm/io/index.d.ts +5 -5
- package/esm/io/index.js +3 -3
- package/esm/io/index.js.map +1 -1
- package/esm/sam.d.ts +8 -1
- package/esm/sam.js.map +1 -1
- package/esm/typescript.d.ts +3 -0
- package/esm/typescript.js +7 -0
- package/esm/typescript.js.map +1 -0
- package/package.json +18 -11
- package/src/{craiIndex.js → craiIndex.ts} +37 -31
- package/src/cramFile/codecs/_base.ts +45 -0
- package/src/cramFile/codecs/beta.ts +34 -0
- package/src/cramFile/codecs/{byteArrayLength.js → byteArrayLength.ts} +27 -5
- package/src/cramFile/codecs/{byteArrayStop.js → byteArrayStop.ts} +25 -12
- package/src/cramFile/codecs/dataSeriesTypes.ts +39 -0
- package/src/cramFile/codecs/{external.js → external.ts} +28 -12
- package/src/cramFile/codecs/gamma.ts +42 -0
- package/src/cramFile/codecs/getBits.ts +28 -0
- package/src/cramFile/codecs/{huffman.js → huffman.ts} +48 -15
- package/src/cramFile/codecs/{index.js → index.ts} +9 -3
- package/src/cramFile/codecs/subexp.ts +45 -0
- package/src/cramFile/{constants.js → constants.ts} +0 -0
- package/src/cramFile/container/{compressionScheme.js → compressionScheme.ts} +50 -18
- package/src/cramFile/container/{index.js → index.ts} +13 -13
- package/src/cramFile/encoding.ts +98 -0
- package/src/cramFile/{file.js → file.ts} +136 -62
- package/src/cramFile/filehandle.ts +3 -0
- package/src/cramFile/{index.js → index.ts} +0 -0
- package/src/cramFile/{record.js → record.ts} +185 -14
- package/src/cramFile/{sectionParsers.js → sectionParsers.ts} +148 -20
- package/src/cramFile/slice/{decodeRecord.js → decodeRecord.ts} +158 -105
- package/src/cramFile/slice/{index.js → index.ts} +138 -63
- package/src/cramFile/{util.js → util.ts} +28 -17
- package/src/{errors.js → errors.ts} +0 -5
- package/src/{index.js → index.ts} +0 -0
- package/src/{indexedCramFile.js → indexedCramFile.ts} +79 -19
- package/src/io/{index.js → index.ts} +10 -5
- package/src/{sam.js → sam.ts} +7 -2
- package/src/typescript.ts +17 -0
- package/src/typings/binary-parser.d.ts +44 -0
- package/src/typings/bzip2.d.ts +7 -0
- package/src/typings/htscodecs.d.ts +6 -0
- package/dist/io/bufferCache.d.ts +0 -12
- package/dist/io/bufferCache.js +0 -112
- package/dist/io/bufferCache.js.map +0 -1
- package/dist/io/localFile.d.ts +0 -10
- package/dist/io/localFile.js +0 -108
- package/dist/io/localFile.js.map +0 -1
- package/dist/io/remoteFile.d.ts +0 -16
- package/dist/io/remoteFile.js +0 -143
- package/dist/io/remoteFile.js.map +0 -1
- package/esm/io/bufferCache.d.ts +0 -12
- package/esm/io/bufferCache.js +0 -54
- package/esm/io/bufferCache.js.map +0 -1
- package/esm/io/localFile.d.ts +0 -10
- package/esm/io/localFile.js +0 -31
- package/esm/io/localFile.js.map +0 -1
- package/esm/io/remoteFile.d.ts +0 -16
- package/esm/io/remoteFile.js +0 -64
- package/esm/io/remoteFile.js.map +0 -1
- package/src/cramFile/codecs/_base.js +0 -49
- package/src/cramFile/codecs/beta.js +0 -23
- package/src/cramFile/codecs/gamma.js +0 -30
- package/src/cramFile/codecs/subexp.js +0 -32
- package/src/io/bufferCache.js +0 -66
- package/src/io/localFile.js +0 -35
- package/src/io/remoteFile.js +0 -71
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/cramFile/constants.
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/cramFile/constants.ts"],"names":[],"mappings":";;AAAA,MAAM,SAAS,GAAG;IAChB,8BAA8B,EAAE,CAAC,IAAI,CAAC;IACtC,kBAAkB,EAAE,CAAC,IAAI,CAAC;IAC1B,yBAAyB,EAAE,CAAC,IAAI,CAAC;IACjC,gBAAgB,EAAE,CAAC,IAAI,CAAC;IACxB,cAAc,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC;IAE5B,wBAAwB;IACxB,cAAc,EAAE,CAAC;IACjB,yBAAyB;IACzB,YAAY,EAAE,CAAC;IAEf,8EAA8E;IAC9E,WAAW,EAAE,CAAC;IACd,uCAAuC;IACvC,gBAAgB,EAAE,CAAC;IACnB,kEAAkE;IAClE,UAAU,EAAE,CAAC;IACb,wBAAwB;IACxB,WAAW,EAAE,CAAC;IACd,4CAA4C;IAC5C,YAAY,EAAE,EAAE;IAChB,4CAA4C;IAC5C,aAAa,EAAE,EAAE;IACjB,iBAAiB;IACjB,UAAU,EAAE,EAAE;IACd,iBAAiB;IACjB,UAAU,EAAE,GAAG;IACf,yBAAyB;IACzB,cAAc,EAAE,GAAG;IACnB,cAAc;IACd,WAAW,EAAE,GAAG;IAChB,4BAA4B;IAC5B,QAAQ,EAAE,IAAI;IACd,2BAA2B;IAC3B,kBAAkB,EAAE,IAAI;IAExB,UAAU,EAAE,CAAC;IACb,QAAQ,EAAE,CAAC;IACX,QAAQ,EAAE,CAAC;IACX,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,CAAC;IACjB,cAAc,EAAE,CAAC;IACjB,QAAQ,EAAE,CAAC;IACX,UAAU,EAAE,CAAC;IACb,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,CAAC;IAEZ,aAAa,EAAE,YAAY;IAC3B,eAAe,EAAE,CAAC;IAClB,cAAc,EAAE,GAAG;IACnB,cAAc,EAAE,OAAO;CACxB,CAAA;AAED,kBAAe,SAAS,CAAA"}
|
|
@@ -1,23 +1,69 @@
|
|
|
1
|
+
import CramCodec from '../codecs/_base';
|
|
2
|
+
import { CramCompressionHeader } from '../sectionParsers';
|
|
3
|
+
import { CramEncoding } from '../encoding';
|
|
4
|
+
import { DataSeriesEncodingKey, DataSeriesEncodingMap } from '../codecs/dataSeriesTypes';
|
|
5
|
+
declare const dataSeriesTypes: {
|
|
6
|
+
readonly BF: "int";
|
|
7
|
+
readonly CF: "int";
|
|
8
|
+
readonly RI: "int";
|
|
9
|
+
readonly RL: "int";
|
|
10
|
+
readonly AP: "int";
|
|
11
|
+
readonly RG: "int";
|
|
12
|
+
readonly MF: "int";
|
|
13
|
+
readonly NS: "int";
|
|
14
|
+
readonly NP: "int";
|
|
15
|
+
readonly TS: "int";
|
|
16
|
+
readonly NF: "int";
|
|
17
|
+
readonly TC: "byte";
|
|
18
|
+
readonly TN: "int";
|
|
19
|
+
readonly FN: "int";
|
|
20
|
+
readonly FC: "byte";
|
|
21
|
+
readonly FP: "int";
|
|
22
|
+
readonly BS: "byte";
|
|
23
|
+
readonly IN: "byteArray";
|
|
24
|
+
readonly SC: "byteArray";
|
|
25
|
+
readonly DL: "int";
|
|
26
|
+
readonly BA: "byte";
|
|
27
|
+
readonly BB: "byteArray";
|
|
28
|
+
readonly RS: "int";
|
|
29
|
+
readonly PD: "int";
|
|
30
|
+
readonly HC: "int";
|
|
31
|
+
readonly MQ: "int";
|
|
32
|
+
readonly RN: "byteArray";
|
|
33
|
+
readonly QS: "byte";
|
|
34
|
+
readonly QQ: "byteArray";
|
|
35
|
+
readonly TL: "int";
|
|
36
|
+
};
|
|
37
|
+
export declare type DataSeriesTypes = typeof dataSeriesTypes;
|
|
38
|
+
declare type DataSeriesCache = {
|
|
39
|
+
[K in DataSeriesEncodingKey]?: CramCodec<DataSeriesTypes[K]>;
|
|
40
|
+
};
|
|
1
41
|
export default class CramContainerCompressionScheme {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
APdelta: any;
|
|
42
|
+
readNamesIncluded: boolean;
|
|
43
|
+
APdelta: boolean;
|
|
5
44
|
referenceRequired: boolean;
|
|
6
|
-
tagIdsDictionary:
|
|
7
|
-
substitutionMatrix:
|
|
8
|
-
dataSeriesCodecCache:
|
|
9
|
-
tagCodecCache:
|
|
45
|
+
tagIdsDictionary: Record<number, string[]>;
|
|
46
|
+
substitutionMatrix: string[][];
|
|
47
|
+
dataSeriesCodecCache: DataSeriesCache;
|
|
48
|
+
tagCodecCache: Record<string, CramCodec>;
|
|
49
|
+
tagEncoding: Record<string, CramEncoding>;
|
|
50
|
+
dataSeriesEncoding: DataSeriesEncodingMap;
|
|
51
|
+
private preservation;
|
|
52
|
+
private _endPosition;
|
|
53
|
+
private _size;
|
|
54
|
+
constructor(content: CramCompressionHeader);
|
|
10
55
|
/**
|
|
11
56
|
* @param {string} tagName three-character tag name
|
|
12
57
|
* @private
|
|
13
58
|
*/
|
|
14
|
-
|
|
59
|
+
getCodecForTag(tagName: string): CramCodec;
|
|
15
60
|
/**
|
|
16
61
|
*
|
|
17
62
|
* @param {number} tagListId ID of the tag list to fetch from the tag dictionary
|
|
18
63
|
* @private
|
|
19
64
|
*/
|
|
20
|
-
|
|
21
|
-
getCodecForDataSeries(dataSeriesName:
|
|
22
|
-
toJSON():
|
|
65
|
+
getTagNames(tagListId: number): string[];
|
|
66
|
+
getCodecForDataSeries<TDataSeries extends DataSeriesEncodingKey>(dataSeriesName: TDataSeries): CramCodec<DataSeriesTypes[TDataSeries]> | undefined;
|
|
67
|
+
toJSON(): any;
|
|
23
68
|
}
|
|
69
|
+
export {};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
const codecs_1 = require("../codecs");
|
|
4
|
+
const errors_1 = require("../../errors");
|
|
5
5
|
// the hardcoded data type to be decoded for each core
|
|
6
6
|
// data field
|
|
7
|
-
|
|
7
|
+
const dataSeriesTypes = {
|
|
8
8
|
BF: 'int',
|
|
9
9
|
CF: 'int',
|
|
10
10
|
RI: 'int',
|
|
@@ -35,12 +35,12 @@ var dataSeriesTypes = {
|
|
|
35
35
|
QS: 'byte',
|
|
36
36
|
QQ: 'byteArray',
|
|
37
37
|
TL: 'int',
|
|
38
|
-
TM: 'ignore',
|
|
39
|
-
TV: 'ignore',
|
|
38
|
+
// TM: 'ignore',
|
|
39
|
+
// TV: 'ignore',
|
|
40
40
|
};
|
|
41
41
|
function parseSubstitutionMatrix(byteArray) {
|
|
42
|
-
|
|
43
|
-
for (
|
|
42
|
+
const matrix = new Array(5);
|
|
43
|
+
for (let i = 0; i < 5; i += 1) {
|
|
44
44
|
matrix[i] = new Array(4);
|
|
45
45
|
}
|
|
46
46
|
matrix[0][(byteArray[0] >> 6) & 3] = 'C';
|
|
@@ -65,66 +65,71 @@ function parseSubstitutionMatrix(byteArray) {
|
|
|
65
65
|
matrix[4][(byteArray[4] >> 0) & 3] = 'T';
|
|
66
66
|
return matrix;
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
class CramContainerCompressionScheme {
|
|
69
|
+
constructor(content) {
|
|
70
|
+
this.dataSeriesCodecCache = {};
|
|
71
|
+
this.tagCodecCache = {};
|
|
72
|
+
this.tagEncoding = {};
|
|
73
|
+
// Object.assign(this, content)
|
|
71
74
|
// interpret some of the preservation map tags for convenient use
|
|
72
75
|
this.readNamesIncluded = content.preservation.RN;
|
|
73
76
|
this.APdelta = content.preservation.AP;
|
|
74
77
|
this.referenceRequired = !!content.preservation.RR;
|
|
75
78
|
this.tagIdsDictionary = content.preservation.TD;
|
|
76
79
|
this.substitutionMatrix = parseSubstitutionMatrix(content.preservation.SM);
|
|
77
|
-
this.
|
|
78
|
-
this.
|
|
80
|
+
this.dataSeriesEncoding = content.dataSeriesEncoding;
|
|
81
|
+
this.tagEncoding = content.tagEncoding;
|
|
82
|
+
this.preservation = content.preservation;
|
|
83
|
+
this._size = content._size;
|
|
84
|
+
this._endPosition = content._endPosition;
|
|
79
85
|
}
|
|
80
86
|
/**
|
|
81
87
|
* @param {string} tagName three-character tag name
|
|
82
88
|
* @private
|
|
83
89
|
*/
|
|
84
|
-
|
|
90
|
+
getCodecForTag(tagName) {
|
|
85
91
|
if (!this.tagCodecCache[tagName]) {
|
|
86
|
-
|
|
92
|
+
const encodingData = this.tagEncoding[tagName];
|
|
87
93
|
if (encodingData) {
|
|
88
94
|
this.tagCodecCache[tagName] = (0, codecs_1.instantiateCodec)(encodingData, 'byteArray');
|
|
89
95
|
}
|
|
90
96
|
}
|
|
91
97
|
return this.tagCodecCache[tagName];
|
|
92
|
-
}
|
|
98
|
+
}
|
|
93
99
|
/**
|
|
94
100
|
*
|
|
95
101
|
* @param {number} tagListId ID of the tag list to fetch from the tag dictionary
|
|
96
102
|
* @private
|
|
97
103
|
*/
|
|
98
|
-
|
|
104
|
+
getTagNames(tagListId) {
|
|
99
105
|
return this.tagIdsDictionary[tagListId];
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
106
|
+
}
|
|
107
|
+
getCodecForDataSeries(dataSeriesName) {
|
|
108
|
+
let r = this.dataSeriesCodecCache[dataSeriesName];
|
|
103
109
|
if (r === undefined) {
|
|
104
|
-
|
|
110
|
+
const encodingData = this.dataSeriesEncoding[dataSeriesName];
|
|
105
111
|
if (encodingData) {
|
|
106
|
-
|
|
112
|
+
const dataType = dataSeriesTypes[dataSeriesName];
|
|
107
113
|
if (!dataType) {
|
|
108
|
-
throw new errors_1.CramMalformedError(
|
|
114
|
+
throw new errors_1.CramMalformedError(`data series name ${dataSeriesName} not defined in file compression header`);
|
|
109
115
|
}
|
|
110
116
|
r = (0, codecs_1.instantiateCodec)(encodingData, dataType);
|
|
111
|
-
this
|
|
117
|
+
// didn't find a way to make TS understand this
|
|
118
|
+
this.dataSeriesCodecCache[dataSeriesName] = r;
|
|
112
119
|
}
|
|
113
120
|
}
|
|
114
121
|
return r;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
Object.keys(this).forEach(function (k) {
|
|
122
|
+
}
|
|
123
|
+
toJSON() {
|
|
124
|
+
const data = {};
|
|
125
|
+
Object.keys(this).forEach(k => {
|
|
120
126
|
if (/Cache$/.test(k)) {
|
|
121
127
|
return;
|
|
122
128
|
}
|
|
123
|
-
data[k] =
|
|
129
|
+
data[k] = this[k];
|
|
124
130
|
});
|
|
125
131
|
return data;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
}());
|
|
132
|
+
}
|
|
133
|
+
}
|
|
129
134
|
exports.default = CramContainerCompressionScheme;
|
|
130
135
|
//# sourceMappingURL=compressionScheme.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressionScheme.js","sourceRoot":"","sources":["../../../src/cramFile/container/compressionScheme.
|
|
1
|
+
{"version":3,"file":"compressionScheme.js","sourceRoot":"","sources":["../../../src/cramFile/container/compressionScheme.ts"],"names":[],"mappings":";;AAAA,sCAA4C;AAI5C,yCAAiD;AAMjD,sDAAsD;AACtD,aAAa;AACb,MAAM,eAAe,GAAG;IACtB,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,EAAE,EAAE,KAAK;IACT,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AAC,GAAG,IAAA,yBAAgB,EAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;gBAC5C,+CAA+C;gBAC/C,IAAI,CAAC,oBAAoB,CAAC,cAAc,CAAC,GAAG,CAAmB,CAAA;aAChE;SACF;QACD,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM;QACJ,MAAM,IAAI,GAAQ,EAAE,CAAA;QACpB,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YAC5B,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;gBACpB,OAAM;aACP;YACD,IAAI,CAAC,CAAC,CAAC,GAAI,IAAY,CAAC,CAAC,CAAC,CAAA;QAC5B,CAAC,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC;CACF;AAvFD,iDAuFC"}
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import CramSlice from '../slice';
|
|
3
|
+
import CramContainerCompressionScheme from './compressionScheme';
|
|
4
|
+
import CramFile from '../file';
|
|
1
5
|
export default class CramContainer {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
filePosition:
|
|
6
|
+
file: CramFile;
|
|
7
|
+
filePosition: number;
|
|
8
|
+
constructor(file: CramFile, filePosition: number);
|
|
5
9
|
getHeader(): Promise<any>;
|
|
6
|
-
getCompressionHeaderBlock(): Promise<
|
|
7
|
-
|
|
10
|
+
getCompressionHeaderBlock(): Promise<{
|
|
11
|
+
parsedContent: import("../util").ParsedItem<import("../sectionParsers").CramCompressionHeader>;
|
|
12
|
+
compressionMethod: import("../sectionParsers").CompressionMethod;
|
|
13
|
+
contentType: "FILE_HEADER" | "COMPRESSION_HEADER" | "MAPPED_SLICE_HEADER" | "UNMAPPED_SLICE_HEADER" | "EXTERNAL_DATA" | "CORE_DATA";
|
|
14
|
+
contentId: number;
|
|
15
|
+
compressedSize: number;
|
|
16
|
+
uncompressedSize: number;
|
|
17
|
+
_endPosition: number;
|
|
18
|
+
contentPosition: number;
|
|
19
|
+
_size: number;
|
|
20
|
+
content: Buffer;
|
|
21
|
+
crc32?: number | undefined;
|
|
22
|
+
} | null | undefined>;
|
|
23
|
+
getFirstBlock(): Promise<import("../file").CramFileBlock | undefined>;
|
|
8
24
|
getCompressionScheme(): Promise<CramContainerCompressionScheme | undefined>;
|
|
9
|
-
getSlice(slicePosition:
|
|
10
|
-
_readContainerHeader(position:
|
|
25
|
+
getSlice(slicePosition: number, sliceSize: number): CramSlice;
|
|
26
|
+
_readContainerHeader(position: number): Promise<any>;
|
|
11
27
|
}
|
|
12
|
-
import CramContainerCompressionScheme from "./compressionScheme";
|
|
13
|
-
import CramSlice from "../slice";
|
|
@@ -8,169 +8,99 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
13
|
};
|
|
41
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.
|
|
50
|
-
// position of this container in the file
|
|
51
|
-
this.filePosition = position;
|
|
52
|
-
// console.log(`container: ${this.filePosition}`)
|
|
15
|
+
const errors_1 = require("../../errors");
|
|
16
|
+
const util_1 = require("../util");
|
|
17
|
+
const slice_1 = __importDefault(require("../slice"));
|
|
18
|
+
const compressionScheme_1 = __importDefault(require("./compressionScheme"));
|
|
19
|
+
class CramContainer {
|
|
20
|
+
constructor(file, filePosition) {
|
|
21
|
+
this.file = file;
|
|
22
|
+
this.filePosition = filePosition;
|
|
53
23
|
}
|
|
54
24
|
// memoize
|
|
55
|
-
|
|
25
|
+
getHeader() {
|
|
56
26
|
return this._readContainerHeader(this.filePosition);
|
|
57
|
-
}
|
|
27
|
+
}
|
|
58
28
|
// memoize
|
|
59
|
-
|
|
60
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return [4 /*yield*/, this.getFirstBlock()];
|
|
77
|
-
case 3:
|
|
78
|
-
block = _a.sent();
|
|
79
|
-
if (block.contentType !== 'COMPRESSION_HEADER') {
|
|
80
|
-
throw new errors_1.CramMalformedError("invalid content type ".concat(block.contentType, " in what is supposed to be the compression header block"));
|
|
81
|
-
}
|
|
82
|
-
content = (0, util_1.parseItem)(block.content, sectionParsers.cramCompressionHeader.parser, 0, block.contentPosition);
|
|
83
|
-
block.content = content;
|
|
84
|
-
return [2 /*return*/, block];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
29
|
+
getCompressionHeaderBlock() {
|
|
30
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
const containerHeader = yield this.getHeader();
|
|
32
|
+
// if there are no records in the container, there will be no compression header
|
|
33
|
+
if (!containerHeader.numRecords) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
const sectionParsers = yield this.file.getSectionParsers();
|
|
37
|
+
const block = yield this.getFirstBlock();
|
|
38
|
+
if (block === undefined) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
if (block.contentType !== 'COMPRESSION_HEADER') {
|
|
42
|
+
throw new errors_1.CramMalformedError(`invalid content type ${block.contentType} in what is supposed to be the compression header block`);
|
|
43
|
+
}
|
|
44
|
+
const content = (0, util_1.parseItem)(block.content, sectionParsers.cramCompressionHeader.parser, 0, block.contentPosition);
|
|
45
|
+
return Object.assign(Object.assign({}, block), { parsedContent: content });
|
|
87
46
|
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
-
|
|
92
|
-
return
|
|
93
|
-
switch (_a.label) {
|
|
94
|
-
case 0: return [4 /*yield*/, this.getHeader()];
|
|
95
|
-
case 1:
|
|
96
|
-
containerHeader = _a.sent();
|
|
97
|
-
return [2 /*return*/, this.file.readBlock(containerHeader._endPosition)];
|
|
98
|
-
}
|
|
99
|
-
});
|
|
47
|
+
}
|
|
48
|
+
getFirstBlock() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const containerHeader = yield this.getHeader();
|
|
51
|
+
return this.file.readBlock(containerHeader._endPosition);
|
|
100
52
|
});
|
|
101
|
-
}
|
|
53
|
+
}
|
|
102
54
|
// parses the compression header data into a CramContainerCompressionScheme object
|
|
103
55
|
// memoize
|
|
104
|
-
|
|
105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
header = _a.sent();
|
|
112
|
-
if (!header) {
|
|
113
|
-
return [2 /*return*/, undefined];
|
|
114
|
-
}
|
|
115
|
-
return [2 /*return*/, new compressionScheme_1.default(header.content)];
|
|
116
|
-
}
|
|
117
|
-
});
|
|
56
|
+
getCompressionScheme() {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const header = yield this.getCompressionHeaderBlock();
|
|
59
|
+
if (!header) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
return new compressionScheme_1.default(header.parsedContent);
|
|
118
63
|
});
|
|
119
|
-
}
|
|
120
|
-
|
|
64
|
+
}
|
|
65
|
+
getSlice(slicePosition, sliceSize) {
|
|
121
66
|
// note: slicePosition is relative to the end of the container header
|
|
122
67
|
// TODO: perhaps we should cache slices?
|
|
123
68
|
return new slice_1.default(this, slicePosition, sliceSize);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
case 4:
|
|
153
|
-
_a.sent();
|
|
154
|
-
header2 = (0, util_1.parseItem)(bytes2, cramContainerHeader2.parser);
|
|
155
|
-
if (!(this.file.validateChecksums && header2.crc32 !== undefined)) return [3 /*break*/, 6];
|
|
156
|
-
return [4 /*yield*/, this.file.checkCrc32(position, header1._size + header2._size - numLandmarksSize - 4, header2.crc32, "container header beginning at position ".concat(position))];
|
|
157
|
-
case 5:
|
|
158
|
-
_a.sent();
|
|
159
|
-
_a.label = 6;
|
|
160
|
-
case 6:
|
|
161
|
-
completeHeader = Object.assign(header1, header2, {
|
|
162
|
-
_size: header1._size + header2._size - numLandmarksSize,
|
|
163
|
-
_endPosition: header1._size + header2._size - numLandmarksSize + position,
|
|
164
|
-
});
|
|
165
|
-
return [2 /*return*/, completeHeader];
|
|
166
|
-
}
|
|
69
|
+
}
|
|
70
|
+
_readContainerHeader(position) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const sectionParsers = yield this.file.getSectionParsers();
|
|
73
|
+
const { cramContainerHeader1, cramContainerHeader2 } = sectionParsers;
|
|
74
|
+
const { size: fileSize } = yield this.file.stat();
|
|
75
|
+
if (position >= fileSize) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
// parse the container header. do it in 2 pieces because you cannot tell
|
|
79
|
+
// how much to buffer until you read numLandmarks
|
|
80
|
+
const bytes1 = Buffer.allocUnsafe(cramContainerHeader1.maxLength);
|
|
81
|
+
yield this.file.read(bytes1, 0, cramContainerHeader1.maxLength, position);
|
|
82
|
+
const header1 = (0, util_1.parseItem)(bytes1, cramContainerHeader1.parser);
|
|
83
|
+
const numLandmarksSize = (0, util_1.itf8Size)(header1.numLandmarks);
|
|
84
|
+
if (position + header1.length >= fileSize) {
|
|
85
|
+
console.warn(`${this.file}: container header at ${position} indicates that the container has length ${header1.length}, which extends beyond the length of the file. Skipping this container.`);
|
|
86
|
+
return undefined;
|
|
87
|
+
}
|
|
88
|
+
const bytes2 = Buffer.allocUnsafe(cramContainerHeader2.maxLength(header1.numLandmarks));
|
|
89
|
+
yield this.file.read(bytes2, 0, cramContainerHeader2.maxLength(header1.numLandmarks), position + header1._size - numLandmarksSize);
|
|
90
|
+
const header2 = (0, util_1.parseItem)(bytes2, cramContainerHeader2.parser);
|
|
91
|
+
if (this.file.validateChecksums && header2.crc32 !== undefined) {
|
|
92
|
+
yield this.file.checkCrc32(position, header1._size + header2._size - numLandmarksSize - 4, header2.crc32, `container header beginning at position ${position}`);
|
|
93
|
+
}
|
|
94
|
+
const completeHeader = Object.assign(header1, header2, {
|
|
95
|
+
_size: header1._size + header2._size - numLandmarksSize,
|
|
96
|
+
_endPosition: header1._size + header2._size - numLandmarksSize + position,
|
|
167
97
|
});
|
|
98
|
+
return completeHeader;
|
|
168
99
|
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
}());
|
|
100
|
+
}
|
|
101
|
+
}
|
|
172
102
|
exports.default = CramContainer;
|
|
173
103
|
'getHeader getCompressionHeaderBlock getCompressionScheme'
|
|
174
104
|
.split(' ')
|
|
175
|
-
.forEach(
|
|
105
|
+
.forEach(method => (0, util_1.tinyMemoize)(CramContainer, method));
|
|
176
106
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cramFile/container/index.
|
|
1
|
+
{"version":3,"file":"index.js","source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AAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
export declare type NullEncoding = {
|
|
2
|
+
codecId: 0;
|
|
3
|
+
parametersBytes: number;
|
|
4
|
+
parameters: Record<string, never>;
|
|
5
|
+
};
|
|
6
|
+
export declare type ExternalCramEncoding = {
|
|
7
|
+
codecId: 1;
|
|
8
|
+
parametersBytes: number;
|
|
9
|
+
parameters: {
|
|
10
|
+
blockContentId: number;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export declare type GolombEncoding = {
|
|
14
|
+
codecId: 2;
|
|
15
|
+
parametersBytes: number;
|
|
16
|
+
parameters: {
|
|
17
|
+
offset: number;
|
|
18
|
+
M: number;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare type HuffmanEncoding = {
|
|
22
|
+
codecId: 3;
|
|
23
|
+
parametersBytes: number;
|
|
24
|
+
parameters: {
|
|
25
|
+
numCodes: number;
|
|
26
|
+
symbols: number[];
|
|
27
|
+
numLengths: number;
|
|
28
|
+
bitLengths: number[];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare type ByteArrayLengthEncoding = {
|
|
32
|
+
codecId: 4;
|
|
33
|
+
parametersBytes: number;
|
|
34
|
+
parameters: {
|
|
35
|
+
lengthsEncoding: CramEncoding;
|
|
36
|
+
valuesEncoding: CramEncoding;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare type ByteArrayStopCramEncoding = {
|
|
40
|
+
codecId: 5;
|
|
41
|
+
parametersBytes: number;
|
|
42
|
+
parameters: {
|
|
43
|
+
stopByte: number;
|
|
44
|
+
blockContentId: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare type BetaEncoding = {
|
|
48
|
+
codecId: 6;
|
|
49
|
+
parametersBytes: number;
|
|
50
|
+
parameters: {
|
|
51
|
+
offset: number;
|
|
52
|
+
length: number;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export declare type SubexpEncoding = {
|
|
56
|
+
codecId: 7;
|
|
57
|
+
parametersBytes: number;
|
|
58
|
+
parameters: {
|
|
59
|
+
offset: number;
|
|
60
|
+
K: number;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
export declare type GolombRiceEncoding = {
|
|
64
|
+
codecId: 8;
|
|
65
|
+
parametersBytes: number;
|
|
66
|
+
parameters: {
|
|
67
|
+
offset: number;
|
|
68
|
+
log2m: number;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export declare type GammaEncoding = {
|
|
72
|
+
codecId: 9;
|
|
73
|
+
parametersBytes: number;
|
|
74
|
+
parameters: {
|
|
75
|
+
offset: number;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export declare type CramEncoding = NullEncoding | ExternalCramEncoding | GolombEncoding | HuffmanEncoding | ByteArrayLengthEncoding | ByteArrayStopCramEncoding | BetaEncoding | SubexpEncoding | GolombRiceEncoding | GammaEncoding;
|