@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.
Files changed (76) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +0 -4
  3. package/dist/craiIndex.js +1 -1
  4. package/dist/craiIndex.js.map +1 -1
  5. package/dist/cram-bundle.js +1 -1
  6. package/dist/cram-bundle.js.LICENSE.txt +0 -2
  7. package/dist/cramFile/codecs/byteArrayStop.d.ts +0 -1
  8. package/dist/cramFile/codecs/getBits.d.ts +0 -1
  9. package/dist/cramFile/codecs/getBits.js +2 -2
  10. package/dist/cramFile/codecs/getBits.js.map +1 -1
  11. package/dist/cramFile/codecs/index.js +1 -2
  12. package/dist/cramFile/codecs/index.js.map +1 -1
  13. package/dist/cramFile/container/index.d.ts +1 -2
  14. package/dist/cramFile/file.d.ts +1 -3
  15. package/dist/cramFile/file.js +2 -2
  16. package/dist/cramFile/file.js.map +1 -1
  17. package/dist/cramFile/sectionParsers.d.ts +0 -1
  18. package/dist/cramFile/sectionParsers.js +3 -3
  19. package/dist/cramFile/sectionParsers.js.map +1 -1
  20. package/dist/cramFile/slice/decodeRecord.js +1 -1
  21. package/dist/cramFile/slice/decodeRecord.js.map +1 -1
  22. package/dist/cramFile/util.d.ts +0 -2
  23. package/dist/cramFile/util.js +5 -6
  24. package/dist/cramFile/util.js.map +1 -1
  25. package/dist/indexedCramFile.d.ts +0 -3
  26. package/dist/indexedCramFile.js +4 -16
  27. package/dist/indexedCramFile.js.map +1 -1
  28. package/dist/io/index.d.ts +1 -3
  29. package/dist/io/index.js +3 -16
  30. package/dist/io/index.js.map +1 -1
  31. package/dist/rans/d04.js +1 -1
  32. package/dist/rans/d04.js.map +1 -1
  33. package/dist/rans/d14.js +1 -1
  34. package/dist/rans/d14.js.map +1 -1
  35. package/dist/rans/frequencies.js +2 -3
  36. package/dist/rans/frequencies.js.map +1 -1
  37. package/dist/rans/index.js +1 -1
  38. package/dist/rans/index.js.map +1 -1
  39. package/dist/sam.d.ts +1 -1
  40. package/dist/sam.js +3 -4
  41. package/dist/sam.js.map +1 -1
  42. package/dist/typescript.d.ts +0 -1
  43. package/dist/typescript.js +0 -8
  44. package/dist/typescript.js.map +1 -1
  45. package/dist/unzip-pako.d.ts +0 -1
  46. package/dist/unzip-pako.js +1 -2
  47. package/dist/unzip-pako.js.map +1 -1
  48. package/dist/unzip.d.ts +0 -1
  49. package/esm/craiIndex.js +1 -1
  50. package/esm/craiIndex.js.map +1 -1
  51. package/esm/cramFile/codecs/byteArrayStop.d.ts +0 -1
  52. package/esm/cramFile/codecs/getBits.d.ts +0 -1
  53. package/esm/cramFile/container/index.d.ts +1 -2
  54. package/esm/cramFile/file.d.ts +1 -3
  55. package/esm/cramFile/sectionParsers.d.ts +0 -1
  56. package/esm/cramFile/util.d.ts +0 -2
  57. package/esm/indexedCramFile.d.ts +0 -3
  58. package/esm/indexedCramFile.js +3 -15
  59. package/esm/indexedCramFile.js.map +1 -1
  60. package/esm/io/index.d.ts +1 -3
  61. package/esm/io/index.js +2 -11
  62. package/esm/io/index.js.map +1 -1
  63. package/esm/sam.d.ts +1 -1
  64. package/esm/sam.js +2 -2
  65. package/esm/sam.js.map +1 -1
  66. package/esm/typescript.d.ts +0 -1
  67. package/esm/typescript.js +1 -6
  68. package/esm/typescript.js.map +1 -1
  69. package/esm/unzip-pako.d.ts +0 -1
  70. package/esm/unzip.d.ts +0 -1
  71. package/package.json +5 -10
  72. package/src/craiIndex.ts +1 -1
  73. package/src/indexedCramFile.ts +3 -25
  74. package/src/io/index.ts +2 -12
  75. package/src/sam.ts +3 -3
  76. package/src/typescript.ts +0 -7
@@ -1,5 +1,4 @@
1
- import { CramSizeLimitError, CramUnimplementedError } from './errors'
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 fromUrl(maybeUrl)
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 { fromUrl, open }
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 | undefined
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: undefined,
27
+ value: '',
28
28
  }
29
29
  }),
30
30
  })
package/src/typescript.ts CHANGED
@@ -1,10 +1,3 @@
1
- export function ensureNotNullish<T>(x: T | null | undefined): T {
2
- if (x === null || x === undefined) {
3
- throw new Error('Value must not be nullish.')
4
- }
5
- return x
6
- }
7
-
8
1
  export type TupleOf<T, N extends number> = N extends N
9
2
  ? number extends N
10
3
  ? T[]