@gmod/cram 2.0.2 → 2.0.4
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/README.md +0 -4
- package/dist/craiIndex.js +1 -1
- package/dist/craiIndex.js.map +1 -1
- package/dist/cram-bundle.js +1 -1
- package/dist/cram-bundle.js.LICENSE.txt +0 -2
- package/dist/cramFile/codecs/byteArrayStop.d.ts +0 -1
- package/dist/cramFile/codecs/getBits.d.ts +0 -1
- package/dist/cramFile/codecs/getBits.js +2 -2
- package/dist/cramFile/codecs/getBits.js.map +1 -1
- package/dist/cramFile/codecs/index.js +1 -2
- package/dist/cramFile/codecs/index.js.map +1 -1
- package/dist/cramFile/container/index.d.ts +1 -2
- package/dist/cramFile/file.d.ts +1 -3
- package/dist/cramFile/file.js +2 -2
- package/dist/cramFile/file.js.map +1 -1
- package/dist/cramFile/sectionParsers.d.ts +0 -1
- package/dist/cramFile/sectionParsers.js +3 -3
- package/dist/cramFile/sectionParsers.js.map +1 -1
- package/dist/cramFile/slice/decodeRecord.js +1 -1
- package/dist/cramFile/slice/decodeRecord.js.map +1 -1
- package/dist/cramFile/util.d.ts +0 -2
- package/dist/cramFile/util.js +5 -6
- package/dist/cramFile/util.js.map +1 -1
- package/dist/indexedCramFile.d.ts +0 -3
- package/dist/indexedCramFile.js +4 -16
- package/dist/indexedCramFile.js.map +1 -1
- package/dist/io/index.d.ts +1 -3
- package/dist/io/index.js +3 -16
- package/dist/io/index.js.map +1 -1
- package/dist/rans/d04.js +1 -1
- package/dist/rans/d04.js.map +1 -1
- package/dist/rans/d14.js +1 -1
- package/dist/rans/d14.js.map +1 -1
- package/dist/rans/frequencies.js +2 -3
- package/dist/rans/frequencies.js.map +1 -1
- package/dist/rans/index.js +1 -1
- package/dist/rans/index.js.map +1 -1
- package/dist/sam.d.ts +1 -1
- package/dist/sam.js +3 -4
- package/dist/sam.js.map +1 -1
- package/dist/typescript.d.ts +0 -1
- package/dist/typescript.js +0 -8
- package/dist/typescript.js.map +1 -1
- package/dist/unzip-pako.d.ts +0 -1
- package/dist/unzip-pako.js +1 -2
- package/dist/unzip-pako.js.map +1 -1
- package/dist/unzip.d.ts +0 -1
- package/esm/craiIndex.js +1 -1
- package/esm/craiIndex.js.map +1 -1
- package/esm/cramFile/codecs/byteArrayStop.d.ts +0 -1
- package/esm/cramFile/codecs/getBits.d.ts +0 -1
- package/esm/cramFile/container/index.d.ts +1 -2
- package/esm/cramFile/file.d.ts +1 -3
- package/esm/cramFile/sectionParsers.d.ts +0 -1
- package/esm/cramFile/util.d.ts +0 -2
- package/esm/indexedCramFile.d.ts +0 -3
- package/esm/indexedCramFile.js +3 -15
- package/esm/indexedCramFile.js.map +1 -1
- package/esm/io/index.d.ts +1 -3
- package/esm/io/index.js +2 -11
- package/esm/io/index.js.map +1 -1
- package/esm/sam.d.ts +1 -1
- package/esm/sam.js +2 -2
- package/esm/sam.js.map +1 -1
- package/esm/typescript.d.ts +0 -1
- package/esm/typescript.js +1 -6
- package/esm/typescript.js.map +1 -1
- package/esm/unzip-pako.d.ts +0 -1
- package/esm/unzip.d.ts +0 -1
- package/package.json +5 -10
- package/src/craiIndex.ts +1 -1
- package/src/indexedCramFile.ts +3 -25
- package/src/io/index.ts +2 -12
- package/src/sam.ts +3 -3
- package/src/typescript.ts +0 -7
package/src/indexedCramFile.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { CramUnimplementedError } from './errors'
|
|
3
2
|
import CramFile from './cramFile'
|
|
4
3
|
import CramRecord from './cramFile/record'
|
|
5
4
|
import { SeqFetch } from './cramFile/file'
|
|
@@ -24,7 +23,6 @@ export interface CramIndexLike {
|
|
|
24
23
|
export default class IndexedCramFile {
|
|
25
24
|
public cram: CramFile
|
|
26
25
|
public index: CramIndexLike
|
|
27
|
-
private fetchSizeLimit: number
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
*
|
|
@@ -32,14 +30,12 @@ export default class IndexedCramFile {
|
|
|
32
30
|
* @param {CramFile} args.cram
|
|
33
31
|
* @param {Index-like} args.index object that supports getEntriesForRange(seqId,start,end) -> Promise[Array[index entries]]
|
|
34
32
|
* @param {number} [args.cacheSize] optional maximum number of CRAM records to cache. default 20,000
|
|
35
|
-
* @param {number} [args.fetchSizeLimit] optional maximum number of bytes to fetch in a single getRecordsForRange call. Default 3 MiB.
|
|
36
33
|
* @param {boolean} [args.checkSequenceMD5] - default true. if false, disables verifying the MD5
|
|
37
34
|
* checksum of the reference sequence underlying a slice. In some applications, this check can cause an inconvenient amount (many megabases) of sequences to be fetched.
|
|
38
35
|
*/
|
|
39
36
|
constructor(
|
|
40
37
|
args: {
|
|
41
38
|
index: CramIndexLike
|
|
42
|
-
fetchSizeLimit?: number
|
|
43
39
|
} & (
|
|
44
40
|
| { cram: CramFile }
|
|
45
41
|
| ({
|
|
@@ -70,8 +66,6 @@ export default class IndexedCramFile {
|
|
|
70
66
|
if (!this.index.getEntriesForRange) {
|
|
71
67
|
throw new Error('invalid arguments: not an index')
|
|
72
68
|
}
|
|
73
|
-
|
|
74
|
-
this.fetchSizeLimit = args.fetchSizeLimit || 3000000
|
|
75
69
|
}
|
|
76
70
|
|
|
77
71
|
/**
|
|
@@ -103,12 +97,6 @@ export default class IndexedCramFile {
|
|
|
103
97
|
}
|
|
104
98
|
const seqId = seq
|
|
105
99
|
const slices = await this.index.getEntriesForRange(seqId, start, end)
|
|
106
|
-
const totalSize = slices.map(s => s.sliceBytes).reduce((a, b) => a + b, 0)
|
|
107
|
-
if (totalSize > this.fetchSizeLimit) {
|
|
108
|
-
throw new CramSizeLimitError(
|
|
109
|
-
`data size of ${totalSize.toLocaleString()} bytes exceeded fetch size limit of ${this.fetchSizeLimit.toLocaleString()} bytes`,
|
|
110
|
-
)
|
|
111
|
-
}
|
|
112
100
|
|
|
113
101
|
// TODO: do we need to merge or de-duplicate the blocks?
|
|
114
102
|
|
|
@@ -180,17 +168,7 @@ export default class IndexedCramFile {
|
|
|
180
168
|
|
|
181
169
|
const mateRecordPromises = []
|
|
182
170
|
const mateFeatPromises: Promise<CramRecord[]>[] = []
|
|
183
|
-
|
|
184
|
-
const mateTotalSize = mateChunks
|
|
185
|
-
.map(s => s.sliceBytes)
|
|
186
|
-
.reduce((a, b) => a + b, 0)
|
|
187
|
-
if (mateTotalSize > this.fetchSizeLimit) {
|
|
188
|
-
throw new Error(
|
|
189
|
-
`mate data size of ${mateTotalSize.toLocaleString()} bytes exceeded fetch size limit of ${this.fetchSizeLimit.toLocaleString()} bytes`,
|
|
190
|
-
)
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
mateChunks.forEach(c => {
|
|
171
|
+
for (const c of mateChunks) {
|
|
194
172
|
let recordPromise = this.cram.featureCache.get(c.toString())
|
|
195
173
|
if (!recordPromise) {
|
|
196
174
|
recordPromise = this.getRecordsInSlice(c, () => true)
|
|
@@ -210,7 +188,7 @@ export default class IndexedCramFile {
|
|
|
210
188
|
return mateRecs
|
|
211
189
|
})
|
|
212
190
|
mateFeatPromises.push(featPromise)
|
|
213
|
-
}
|
|
191
|
+
}
|
|
214
192
|
const newMateFeats = await Promise.all(mateFeatPromises)
|
|
215
193
|
if (newMateFeats.length) {
|
|
216
194
|
const newMates = newMateFeats.reduce((result, current) =>
|
package/src/io/index.ts
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import url from 'url'
|
|
2
|
-
import { ensureNotNullish } from '../typescript'
|
|
3
1
|
import { Filehandle } from '../cramFile/filehandle'
|
|
4
2
|
import { LocalFile, RemoteFile } from 'generic-filehandle'
|
|
5
3
|
|
|
6
|
-
function fromUrl(source: string) {
|
|
7
|
-
const { protocol, pathname } = url.parse(source)
|
|
8
|
-
if (protocol === 'file:') {
|
|
9
|
-
return new LocalFile(unescape(ensureNotNullish(pathname)))
|
|
10
|
-
}
|
|
11
|
-
return new RemoteFile(source)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
4
|
function open(
|
|
15
5
|
maybeUrl?: string,
|
|
16
6
|
maybePath?: string,
|
|
@@ -20,7 +10,7 @@ function open(
|
|
|
20
10
|
return maybeFilehandle
|
|
21
11
|
}
|
|
22
12
|
if (maybeUrl) {
|
|
23
|
-
return
|
|
13
|
+
return new RemoteFile(maybeUrl)
|
|
24
14
|
}
|
|
25
15
|
if (maybePath) {
|
|
26
16
|
return new LocalFile(maybePath)
|
|
@@ -28,6 +18,6 @@ function open(
|
|
|
28
18
|
throw new Error('no url, path, or filehandle provided, cannot open')
|
|
29
19
|
}
|
|
30
20
|
|
|
31
|
-
export {
|
|
21
|
+
export { open }
|
|
32
22
|
|
|
33
23
|
export { LocalFile, RemoteFile } from 'generic-filehandle'
|
package/src/sam.ts
CHANGED
|
@@ -4,7 +4,7 @@ export function parseHeaderText(text: string) {
|
|
|
4
4
|
tag: string
|
|
5
5
|
data: {
|
|
6
6
|
tag: string
|
|
7
|
-
value: string
|
|
7
|
+
value: string
|
|
8
8
|
}[]
|
|
9
9
|
}[] = []
|
|
10
10
|
for (const line of lines) {
|
|
@@ -21,10 +21,10 @@ export function parseHeaderText(text: string) {
|
|
|
21
21
|
}
|
|
22
22
|
: // @CO lines are not comma separated.
|
|
23
23
|
// See "samtools view -H c2\#pad.3.0.cram"
|
|
24
|
-
// so, just store value tag itself
|
|
24
|
+
// so, just store value tag and value itself
|
|
25
25
|
{
|
|
26
26
|
tag: f,
|
|
27
|
-
value:
|
|
27
|
+
value: '',
|
|
28
28
|
}
|
|
29
29
|
}),
|
|
30
30
|
})
|
package/src/typescript.ts
CHANGED