@gmod/cram 4.0.0 → 4.0.3

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.
@@ -29,10 +29,17 @@ export default class IndexedCramFile {
29
29
  *
30
30
  * @param {object} args
31
31
  * @param {CramFile} args.cram
32
- * @param {Index-like} args.index object that supports getEntriesForRange(seqId,start,end) -> Promise[Array[index entries]]
33
- * @param {number} [args.cacheSize] optional maximum number of CRAM records to cache. default 20,000
34
- * @param {boolean} [args.checkSequenceMD5] - default true. if false, disables verifying the MD5
35
- * 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.
32
+ *
33
+ * @param {Index-like} args.index object that supports
34
+ * getEntriesForRange(seqId,start,end) -> Promise[Array[index entries]]
35
+ *
36
+ * @param {number} [args.cacheSize] optional maximum number of CRAM records
37
+ * to cache. default 20,000
38
+ *
39
+ * @param {boolean} [args.checkSequenceMD5] - default true. if false,
40
+ * disables verifying the MD5 checksum of the reference sequence underlying a
41
+ * slice. In some applications, this check can cause an inconvenient amount
42
+ * (many megabases) of sequences to be fetched.
36
43
  */
37
44
  constructor(
38
45
  args: {
@@ -47,7 +54,6 @@ export default class IndexedCramFile {
47
54
  } & CramFileSource)
48
55
  ),
49
56
  ) {
50
- // { cram, index, seqFetch /* fasta, fastaIndex */ }) {
51
57
  this.cram =
52
58
  args.cram ??
53
59
  new CramFile({
@@ -68,10 +74,9 @@ export default class IndexedCramFile {
68
74
 
69
75
  /**
70
76
  *
71
- * @param {number} seq numeric ID of the reference sequence
72
- * @param {number} start start of the range of interest. 1-based closed coordinates.
73
- * @param {number} end end of the range of interest. 1-based closed coordinates.
74
- * @returns {Promise[Array[CramRecord]]}
77
+ * @param seq numeric ID of the reference sequence
78
+ * @param start start of the range of interest. 1-based closed coordinates.
79
+ * @param end end of the range of interest. 1-based closed coordinates.
75
80
  */
76
81
  async getRecordsForRange(
77
82
  seq: number,
@@ -96,16 +101,18 @@ export default class IndexedCramFile {
96
101
  const seqId = seq
97
102
  const slices = await this.index.getEntriesForRange(seqId, start, end)
98
103
 
99
- // TODO: do we need to merge or de-duplicate the blocks?
100
-
101
104
  // fetch all the slices and parse the feature data
102
- const filter = (feature: CramRecord) =>
103
- feature.sequenceId === seq &&
104
- feature.alignmentStart <= end &&
105
- feature.lengthOnRef !== undefined &&
106
- feature.alignmentStart + feature.lengthOnRef - 1 >= start
107
105
  const sliceResults = await Promise.all(
108
- slices.map(slice => this.getRecordsInSlice(slice, filter)),
106
+ slices.map(slice =>
107
+ this.getRecordsInSlice(
108
+ slice,
109
+ feature =>
110
+ feature.sequenceId === seq &&
111
+ feature.alignmentStart <= end &&
112
+ feature.lengthOnRef !== undefined &&
113
+ feature.alignmentStart + feature.lengthOnRef - 1 >= start,
114
+ ),
115
+ ),
109
116
  )
110
117
 
111
118
  let ret: CramRecord[] = Array.prototype.concat(...sliceResults)
package/src/io/index.ts CHANGED
@@ -21,4 +21,4 @@ function open(
21
21
 
22
22
  export { open }
23
23
 
24
- export { LocalFile, RemoteFile } from 'generic-filehandle'
24
+ export { LocalFile, RemoteFile } from 'generic-filehandle2'