@gmod/cram 2.0.1 → 2.0.2
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 +4 -0
- package/dist/craiIndex.d.ts +2 -2
- package/dist/craiIndex.js +5 -9
- package/dist/craiIndex.js.map +1 -1
- package/dist/cram-bundle.js +1 -1
- package/dist/cramFile/codecs/_base.d.ts +6 -6
- package/dist/cramFile/codecs/external.js +1 -0
- package/dist/cramFile/codecs/external.js.map +1 -1
- package/dist/cramFile/codecs/huffman.d.ts +0 -1
- package/dist/cramFile/codecs/huffman.js +1 -3
- package/dist/cramFile/codecs/huffman.js.map +1 -1
- package/dist/cramFile/container/compressionScheme.js +1 -1
- package/dist/cramFile/container/compressionScheme.js.map +1 -1
- package/dist/cramFile/encoding.d.ts +20 -20
- package/dist/cramFile/file.d.ts +6 -6
- package/dist/cramFile/filehandle.d.ts +1 -2
- package/dist/cramFile/index.d.ts +1 -2
- package/dist/cramFile/index.js +3 -3
- package/dist/cramFile/index.js.map +1 -1
- package/dist/cramFile/record.d.ts +6 -6
- package/dist/cramFile/record.js +7 -4
- package/dist/cramFile/record.js.map +1 -1
- package/dist/cramFile/sectionParsers.d.ts +8 -8
- package/dist/cramFile/sectionParsers.js +3 -4
- package/dist/cramFile/sectionParsers.js.map +1 -1
- package/dist/cramFile/slice/decodeRecord.js +6 -10
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/cramFile/slice/index.js +24 -22
- package/dist/cramFile/slice/index.js.map +1 -1
- package/dist/cramFile/util.js +1 -1
- package/dist/cramFile/util.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +7 -30
- package/dist/index.js.map +1 -1
- package/dist/indexedCramFile.d.ts +6 -6
- package/dist/indexedCramFile.js +13 -18
- package/dist/indexedCramFile.js.map +1 -1
- package/dist/io/index.d.ts +2 -1
- package/dist/io/index.js +4 -3
- package/dist/io/index.js.map +1 -1
- package/dist/sam.js +10 -13
- package/dist/sam.js.map +1 -1
- package/dist/unzip.d.ts +1 -2
- package/dist/unzip.js +1 -1
- package/dist/unzip.js.map +1 -1
- package/esm/craiIndex.d.ts +2 -2
- package/esm/craiIndex.js +5 -9
- package/esm/craiIndex.js.map +1 -1
- package/esm/cramFile/codecs/_base.d.ts +6 -6
- package/esm/cramFile/codecs/external.js +1 -0
- package/esm/cramFile/codecs/external.js.map +1 -1
- package/esm/cramFile/codecs/huffman.d.ts +0 -1
- package/esm/cramFile/codecs/huffman.js +1 -3
- package/esm/cramFile/codecs/huffman.js.map +1 -1
- package/esm/cramFile/container/compressionScheme.js +1 -1
- package/esm/cramFile/container/compressionScheme.js.map +1 -1
- package/esm/cramFile/encoding.d.ts +20 -20
- package/esm/cramFile/file.d.ts +6 -6
- package/esm/cramFile/filehandle.d.ts +1 -2
- package/esm/cramFile/index.d.ts +1 -2
- package/esm/cramFile/index.js +1 -2
- package/esm/cramFile/index.js.map +1 -1
- package/esm/cramFile/record.d.ts +6 -6
- package/esm/cramFile/record.js +7 -4
- package/esm/cramFile/record.js.map +1 -1
- package/esm/cramFile/sectionParsers.d.ts +8 -8
- package/esm/cramFile/sectionParsers.js +3 -4
- package/esm/cramFile/sectionParsers.js.map +1 -1
- package/esm/cramFile/slice/decodeRecord.js +6 -10
- package/esm/cramFile/slice/decodeRecord.js.map +1 -1
- package/esm/cramFile/slice/index.js +24 -22
- package/esm/cramFile/slice/index.js.map +1 -1
- package/esm/cramFile/util.js +1 -1
- package/esm/cramFile/util.js.map +1 -1
- package/esm/index.d.ts +3 -4
- package/esm/index.js +3 -4
- package/esm/index.js.map +1 -1
- package/esm/indexedCramFile.d.ts +6 -6
- package/esm/indexedCramFile.js +13 -18
- package/esm/indexedCramFile.js.map +1 -1
- package/esm/io/index.d.ts +2 -1
- package/esm/io/index.js +2 -1
- package/esm/io/index.js.map +1 -1
- package/esm/sam.js +10 -13
- package/esm/sam.js.map +1 -1
- package/esm/unzip.d.ts +1 -2
- package/esm/unzip.js +1 -2
- package/esm/unzip.js.map +1 -1
- package/package.json +11 -11
- package/src/craiIndex.ts +8 -13
- package/src/cramFile/codecs/_base.ts +3 -3
- package/src/cramFile/codecs/external.ts +1 -0
- package/src/cramFile/codecs/huffman.ts +7 -8
- package/src/cramFile/container/compressionScheme.ts +1 -1
- package/src/cramFile/encoding.ts +10 -10
- package/src/cramFile/file.ts +5 -5
- package/src/cramFile/filehandle.ts +1 -3
- package/src/cramFile/index.ts +1 -2
- package/src/cramFile/record.ts +13 -10
- package/src/cramFile/sectionParsers.ts +8 -9
- package/src/cramFile/slice/decodeRecord.ts +15 -17
- package/src/cramFile/slice/index.ts +26 -23
- package/src/cramFile/util.ts +1 -1
- package/src/index.ts +3 -5
- package/src/indexedCramFile.ts +19 -23
- package/src/io/index.ts +3 -1
- package/src/sam.ts +12 -14
- package/src/typings/binary-parser.d.ts +1 -1
- package/src/unzip.ts +1 -2
package/src/indexedCramFile.ts
CHANGED
|
@@ -6,13 +6,13 @@ import { SeqFetch } from './cramFile/file'
|
|
|
6
6
|
import { Filehandle } from './cramFile/filehandle'
|
|
7
7
|
import { Slice } from './craiIndex'
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export interface CramFileSource {
|
|
10
10
|
cramFilehandle?: Filehandle
|
|
11
11
|
cramUrl?: string
|
|
12
12
|
cramPath?: string
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export
|
|
15
|
+
export interface CramIndexLike {
|
|
16
16
|
getEntriesForRange: (
|
|
17
17
|
seqId: number,
|
|
18
18
|
start: number,
|
|
@@ -44,17 +44,16 @@ export default class IndexedCramFile {
|
|
|
44
44
|
| { cram: CramFile }
|
|
45
45
|
| ({
|
|
46
46
|
cram?: undefined
|
|
47
|
-
seqFetch
|
|
48
|
-
checkSequenceMD5
|
|
47
|
+
seqFetch?: SeqFetch
|
|
48
|
+
checkSequenceMD5?: boolean
|
|
49
49
|
cacheSize?: number
|
|
50
50
|
} & CramFileSource)
|
|
51
51
|
),
|
|
52
52
|
) {
|
|
53
53
|
// { cram, index, seqFetch /* fasta, fastaIndex */ }) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.cram = new CramFile({
|
|
54
|
+
this.cram =
|
|
55
|
+
args.cram ??
|
|
56
|
+
new CramFile({
|
|
58
57
|
url: args.cramUrl,
|
|
59
58
|
path: args.cramPath,
|
|
60
59
|
filehandle: args.cramFilehandle,
|
|
@@ -62,7 +61,6 @@ export default class IndexedCramFile {
|
|
|
62
61
|
checkSequenceMD5: args.checkSequenceMD5,
|
|
63
62
|
cacheSize: args.cacheSize,
|
|
64
63
|
})
|
|
65
|
-
}
|
|
66
64
|
|
|
67
65
|
if (!(this.cram instanceof CramFile)) {
|
|
68
66
|
throw new Error('invalid arguments: no cramfile')
|
|
@@ -128,12 +126,12 @@ export default class IndexedCramFile {
|
|
|
128
126
|
if (opts.viewAsPairs) {
|
|
129
127
|
const readNames: Record<string, number> = {}
|
|
130
128
|
const readIds: Record<string, number> = {}
|
|
131
|
-
for (
|
|
132
|
-
const name =
|
|
129
|
+
for (const read of ret) {
|
|
130
|
+
const name = read.readName
|
|
133
131
|
if (name === undefined) {
|
|
134
|
-
throw new Error()
|
|
132
|
+
throw new Error('readName undefined')
|
|
135
133
|
}
|
|
136
|
-
const id =
|
|
134
|
+
const id = read.uniqueId
|
|
137
135
|
if (!readNames[name]) {
|
|
138
136
|
readNames[name] = 0
|
|
139
137
|
}
|
|
@@ -147,11 +145,10 @@ export default class IndexedCramFile {
|
|
|
147
145
|
}
|
|
148
146
|
})
|
|
149
147
|
const matePromises = []
|
|
150
|
-
for (
|
|
151
|
-
const cramRecord = ret[i]
|
|
148
|
+
for (const cramRecord of ret) {
|
|
152
149
|
const name = cramRecord.readName
|
|
153
150
|
if (name === undefined) {
|
|
154
|
-
throw new Error()
|
|
151
|
+
throw new Error('readName undefined')
|
|
155
152
|
}
|
|
156
153
|
if (
|
|
157
154
|
unmatedPairs[name] &&
|
|
@@ -169,9 +166,9 @@ export default class IndexedCramFile {
|
|
|
169
166
|
}
|
|
170
167
|
}
|
|
171
168
|
const mateBlocks = await Promise.all(matePromises)
|
|
172
|
-
let mateChunks = []
|
|
173
|
-
for (
|
|
174
|
-
mateChunks.push(...
|
|
169
|
+
let mateChunks = [] as Slice[]
|
|
170
|
+
for (const block of mateBlocks) {
|
|
171
|
+
mateChunks.push(...block)
|
|
175
172
|
}
|
|
176
173
|
// filter out duplicates
|
|
177
174
|
mateChunks = mateChunks
|
|
@@ -182,7 +179,7 @@ export default class IndexedCramFile {
|
|
|
182
179
|
)
|
|
183
180
|
|
|
184
181
|
const mateRecordPromises = []
|
|
185
|
-
const mateFeatPromises:
|
|
182
|
+
const mateFeatPromises: Promise<CramRecord[]>[] = []
|
|
186
183
|
|
|
187
184
|
const mateTotalSize = mateChunks
|
|
188
185
|
.map(s => s.sliceBytes)
|
|
@@ -202,10 +199,9 @@ export default class IndexedCramFile {
|
|
|
202
199
|
mateRecordPromises.push(recordPromise)
|
|
203
200
|
const featPromise = recordPromise.then(feats => {
|
|
204
201
|
const mateRecs = []
|
|
205
|
-
for (
|
|
206
|
-
const feature = feats[i]
|
|
202
|
+
for (const feature of feats) {
|
|
207
203
|
if (feature.readName === undefined) {
|
|
208
|
-
throw new Error()
|
|
204
|
+
throw new Error('readName undefined')
|
|
209
205
|
}
|
|
210
206
|
if (unmatedPairs[feature.readName] && !readIds[feature.uniqueId]) {
|
|
211
207
|
mateRecs.push(feature)
|
package/src/io/index.ts
CHANGED
package/src/sam.ts
CHANGED
|
@@ -14,20 +14,18 @@ export function parseHeaderText(text: string) {
|
|
|
14
14
|
tag: tag.slice(1),
|
|
15
15
|
data: fields.map(f => {
|
|
16
16
|
const r = f.indexOf(':')
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
}
|
|
17
|
+
return r !== -1
|
|
18
|
+
? {
|
|
19
|
+
tag: f.slice(0, r),
|
|
20
|
+
value: f.slice(r + 1),
|
|
21
|
+
}
|
|
22
|
+
: // @CO lines are not comma separated.
|
|
23
|
+
// See "samtools view -H c2\#pad.3.0.cram"
|
|
24
|
+
// so, just store value tag itself
|
|
25
|
+
{
|
|
26
|
+
tag: f,
|
|
27
|
+
value: undefined,
|
|
28
|
+
}
|
|
31
29
|
}),
|
|
32
30
|
})
|
|
33
31
|
}
|
package/src/unzip.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { gunzipSync as unzip }
|
|
1
|
+
export { gunzipSync as unzip } from 'zlib'
|