@jbrowse/plugin-alignments 2.4.2 → 2.5.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.
Files changed (147) hide show
  1. package/dist/AlignmentsFeatureDetail/AlignmentsFeatureDetail.d.ts +0 -1
  2. package/dist/AlignmentsFeatureDetail/AlignmentsFeatureFlags.d.ts +0 -1
  3. package/dist/AlignmentsFeatureDetail/AlignmentsFeatureSuppAligns.d.ts +0 -1
  4. package/dist/AlignmentsFeatureDetail/index.d.ts +4 -1
  5. package/dist/AlignmentsTrack/configSchemaF.d.ts +74 -0
  6. package/dist/AlignmentsTrack/configSchemaF.js +19 -0
  7. package/dist/AlignmentsTrack/configSchemaF.js.map +1 -0
  8. package/dist/AlignmentsTrack/index.js +2 -15
  9. package/dist/AlignmentsTrack/index.js.map +1 -1
  10. package/dist/BamAdapter/BamAdapter.d.ts +1 -1
  11. package/dist/BamAdapter/BamAdapter.js +2 -2
  12. package/dist/BamAdapter/BamAdapter.js.map +1 -1
  13. package/dist/BamAdapter/configSchema.d.ts +50 -1
  14. package/dist/CramAdapter/CramAdapter.d.ts +1 -1
  15. package/dist/CramAdapter/CramAdapter.js +1 -1
  16. package/dist/CramAdapter/CramAdapter.js.map +1 -1
  17. package/dist/CramAdapter/CramTestAdapters.js +2 -2
  18. package/dist/CramAdapter/CramTestAdapters.js.map +1 -1
  19. package/dist/CramAdapter/configSchema.d.ts +40 -1
  20. package/dist/HtsgetBamAdapter/configSchema.d.ts +26 -1
  21. package/dist/LinearAlignmentsDisplay/components/AlignmentsDisplay.d.ts +0 -1
  22. package/dist/LinearAlignmentsDisplay/models/configSchema.d.ts +39 -1
  23. package/dist/LinearAlignmentsDisplay/models/model.d.ts +8 -4
  24. package/dist/LinearAlignmentsDisplay/models/model.js +7 -3
  25. package/dist/LinearAlignmentsDisplay/models/model.js.map +1 -1
  26. package/dist/LinearPileupDisplay/components/ColorByModifications.d.ts +0 -1
  27. package/dist/LinearPileupDisplay/components/ColorByTag.d.ts +0 -1
  28. package/dist/LinearPileupDisplay/components/LinearPileupDisplayBlurb.d.ts +0 -1
  29. package/dist/LinearPileupDisplay/components/SetFeatureHeight.d.ts +0 -1
  30. package/dist/LinearPileupDisplay/components/SetMaxHeight.d.ts +0 -1
  31. package/dist/LinearPileupDisplay/components/SetMaxHeight.js +3 -5
  32. package/dist/LinearPileupDisplay/components/SetMaxHeight.js.map +1 -1
  33. package/dist/LinearPileupDisplay/components/SortByTag.d.ts +0 -1
  34. package/dist/LinearPileupDisplay/configSchema.d.ts +57 -1
  35. package/dist/LinearPileupDisplay/model.d.ts +107 -50
  36. package/dist/LinearPileupDisplay/model.js +21 -24
  37. package/dist/LinearPileupDisplay/model.js.map +1 -1
  38. package/dist/LinearReadArcsDisplay/components/ReactComponent.d.ts +0 -1
  39. package/dist/LinearReadArcsDisplay/configSchema.d.ts +62 -1
  40. package/dist/LinearReadArcsDisplay/drawFeats.js +2 -2
  41. package/dist/LinearReadArcsDisplay/drawFeats.js.map +1 -1
  42. package/dist/LinearReadArcsDisplay/model.d.ts +78 -21
  43. package/dist/LinearReadCloudDisplay/components/ReactComponent.d.ts +0 -1
  44. package/dist/LinearReadCloudDisplay/configSchema.d.ts +50 -1
  45. package/dist/LinearReadCloudDisplay/drawFeats.d.ts +2 -0
  46. package/dist/LinearReadCloudDisplay/drawFeats.js +4 -4
  47. package/dist/LinearReadCloudDisplay/drawFeats.js.map +1 -1
  48. package/dist/LinearReadCloudDisplay/model.d.ts +65 -18
  49. package/dist/LinearSNPCoverageDisplay/components/Tooltip.d.ts +0 -1
  50. package/dist/LinearSNPCoverageDisplay/models/configSchema.d.ts +79 -1
  51. package/dist/LinearSNPCoverageDisplay/models/model.d.ts +48 -21
  52. package/dist/LinearSNPCoverageDisplay/models/model.js +1 -1
  53. package/dist/LinearSNPCoverageDisplay/models/model.js.map +1 -1
  54. package/dist/PileupRenderer/PileupLayoutSession.d.ts +1 -1
  55. package/dist/PileupRenderer/PileupRenderer.js +9 -0
  56. package/dist/PileupRenderer/PileupRenderer.js.map +1 -1
  57. package/dist/PileupRenderer/configSchema.d.ts +87 -1
  58. package/dist/SNPCoverageAdapter/SNPCoverageAdapter.d.ts +1 -1
  59. package/dist/SNPCoverageAdapter/SNPCoverageAdapter.js +2 -2
  60. package/dist/SNPCoverageAdapter/SNPCoverageAdapter.js.map +1 -1
  61. package/dist/SNPCoverageAdapter/configSchema.d.ts +10 -1
  62. package/dist/SNPCoverageAdapter/generateCoverageBins.js +50 -46
  63. package/dist/SNPCoverageAdapter/generateCoverageBins.js.map +1 -1
  64. package/dist/SNPCoverageRenderer/configSchema.d.ts +42 -1
  65. package/dist/shared/FilterByTag.d.ts +0 -1
  66. package/esm/AlignmentsFeatureDetail/AlignmentsFeatureDetail.d.ts +0 -1
  67. package/esm/AlignmentsFeatureDetail/AlignmentsFeatureFlags.d.ts +0 -1
  68. package/esm/AlignmentsFeatureDetail/AlignmentsFeatureSuppAligns.d.ts +0 -1
  69. package/esm/AlignmentsFeatureDetail/index.d.ts +4 -1
  70. package/esm/AlignmentsTrack/configSchemaF.d.ts +74 -0
  71. package/esm/AlignmentsTrack/configSchemaF.js +16 -0
  72. package/esm/AlignmentsTrack/configSchemaF.js.map +1 -0
  73. package/esm/AlignmentsTrack/index.js +3 -16
  74. package/esm/AlignmentsTrack/index.js.map +1 -1
  75. package/esm/BamAdapter/BamAdapter.d.ts +1 -1
  76. package/esm/BamAdapter/BamAdapter.js +2 -2
  77. package/esm/BamAdapter/BamAdapter.js.map +1 -1
  78. package/esm/BamAdapter/configSchema.d.ts +50 -1
  79. package/esm/CramAdapter/CramAdapter.d.ts +1 -1
  80. package/esm/CramAdapter/CramAdapter.js +1 -1
  81. package/esm/CramAdapter/CramAdapter.js.map +1 -1
  82. package/esm/CramAdapter/CramTestAdapters.js +1 -1
  83. package/esm/CramAdapter/CramTestAdapters.js.map +1 -1
  84. package/esm/CramAdapter/configSchema.d.ts +40 -1
  85. package/esm/HtsgetBamAdapter/configSchema.d.ts +26 -1
  86. package/esm/LinearAlignmentsDisplay/components/AlignmentsDisplay.d.ts +0 -1
  87. package/esm/LinearAlignmentsDisplay/models/configSchema.d.ts +39 -1
  88. package/esm/LinearAlignmentsDisplay/models/model.d.ts +8 -4
  89. package/esm/LinearAlignmentsDisplay/models/model.js +7 -3
  90. package/esm/LinearAlignmentsDisplay/models/model.js.map +1 -1
  91. package/esm/LinearPileupDisplay/components/ColorByModifications.d.ts +0 -1
  92. package/esm/LinearPileupDisplay/components/ColorByTag.d.ts +0 -1
  93. package/esm/LinearPileupDisplay/components/LinearPileupDisplayBlurb.d.ts +0 -1
  94. package/esm/LinearPileupDisplay/components/SetFeatureHeight.d.ts +0 -1
  95. package/esm/LinearPileupDisplay/components/SetMaxHeight.d.ts +0 -1
  96. package/esm/LinearPileupDisplay/components/SetMaxHeight.js +3 -5
  97. package/esm/LinearPileupDisplay/components/SetMaxHeight.js.map +1 -1
  98. package/esm/LinearPileupDisplay/components/SortByTag.d.ts +0 -1
  99. package/esm/LinearPileupDisplay/configSchema.d.ts +57 -1
  100. package/esm/LinearPileupDisplay/model.d.ts +107 -50
  101. package/esm/LinearPileupDisplay/model.js +21 -24
  102. package/esm/LinearPileupDisplay/model.js.map +1 -1
  103. package/esm/LinearReadArcsDisplay/components/ReactComponent.d.ts +0 -1
  104. package/esm/LinearReadArcsDisplay/configSchema.d.ts +62 -1
  105. package/esm/LinearReadArcsDisplay/drawFeats.js +2 -2
  106. package/esm/LinearReadArcsDisplay/drawFeats.js.map +1 -1
  107. package/esm/LinearReadArcsDisplay/model.d.ts +78 -21
  108. package/esm/LinearReadCloudDisplay/components/ReactComponent.d.ts +0 -1
  109. package/esm/LinearReadCloudDisplay/configSchema.d.ts +50 -1
  110. package/esm/LinearReadCloudDisplay/drawFeats.d.ts +2 -0
  111. package/esm/LinearReadCloudDisplay/drawFeats.js +4 -4
  112. package/esm/LinearReadCloudDisplay/drawFeats.js.map +1 -1
  113. package/esm/LinearReadCloudDisplay/model.d.ts +65 -18
  114. package/esm/LinearSNPCoverageDisplay/components/Tooltip.d.ts +0 -1
  115. package/esm/LinearSNPCoverageDisplay/models/configSchema.d.ts +79 -1
  116. package/esm/LinearSNPCoverageDisplay/models/model.d.ts +48 -21
  117. package/esm/LinearSNPCoverageDisplay/models/model.js +1 -1
  118. package/esm/LinearSNPCoverageDisplay/models/model.js.map +1 -1
  119. package/esm/PileupRenderer/PileupLayoutSession.d.ts +1 -1
  120. package/esm/PileupRenderer/PileupRenderer.js +9 -0
  121. package/esm/PileupRenderer/PileupRenderer.js.map +1 -1
  122. package/esm/PileupRenderer/configSchema.d.ts +87 -1
  123. package/esm/SNPCoverageAdapter/SNPCoverageAdapter.d.ts +1 -1
  124. package/esm/SNPCoverageAdapter/SNPCoverageAdapter.js +2 -2
  125. package/esm/SNPCoverageAdapter/SNPCoverageAdapter.js.map +1 -1
  126. package/esm/SNPCoverageAdapter/configSchema.d.ts +10 -1
  127. package/esm/SNPCoverageAdapter/generateCoverageBins.js +50 -46
  128. package/esm/SNPCoverageAdapter/generateCoverageBins.js.map +1 -1
  129. package/esm/SNPCoverageRenderer/configSchema.d.ts +42 -1
  130. package/esm/shared/FilterByTag.d.ts +0 -1
  131. package/package.json +2 -2
  132. package/src/AlignmentsFeatureDetail/__snapshots__/index.test.tsx.snap +1 -2
  133. package/src/AlignmentsTrack/configSchemaF.ts +22 -0
  134. package/src/AlignmentsTrack/index.ts +3 -24
  135. package/src/BamAdapter/BamAdapter.ts +5 -2
  136. package/src/CramAdapter/CramAdapter.ts +4 -1
  137. package/src/CramAdapter/CramTestAdapters.ts +1 -1
  138. package/src/LinearAlignmentsDisplay/models/model.tsx +11 -3
  139. package/src/LinearPileupDisplay/components/SetMaxHeight.tsx +3 -5
  140. package/src/LinearPileupDisplay/model.ts +38 -36
  141. package/src/LinearReadArcsDisplay/drawFeats.ts +2 -2
  142. package/src/LinearReadCloudDisplay/drawFeats.ts +6 -5
  143. package/src/LinearSNPCoverageDisplay/models/model.ts +1 -1
  144. package/src/PileupRenderer/PileupLayoutSession.ts +1 -1
  145. package/src/PileupRenderer/PileupRenderer.ts +15 -5
  146. package/src/SNPCoverageAdapter/SNPCoverageAdapter.ts +5 -2
  147. package/src/SNPCoverageAdapter/generateCoverageBins.ts +58 -55
@@ -57,6 +57,13 @@ const rendererTypes = new Map([
57
57
 
58
58
  type LGV = LinearGenomeViewModel
59
59
 
60
+ export interface Filter {
61
+ flagInclude: number
62
+ flagExclude: number
63
+ readName?: string
64
+ tagFilter?: { tag: string; value: string }
65
+ }
66
+
60
67
  /**
61
68
  * #stateModel LinearPileupDisplay
62
69
  * extends `BaseLinearDisplay`
@@ -99,6 +106,7 @@ function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
99
106
  * #property
100
107
  */
101
108
  mismatchAlpha: types.maybe(types.boolean),
109
+
102
110
  /**
103
111
  * #property
104
112
  */
@@ -245,7 +253,7 @@ function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
245
253
 
246
254
  if (
247
255
  !view.initialized ||
248
- !self.estimatedStatsReady ||
256
+ !self.featureDensityStatsReady ||
249
257
  self.regionTooLarge
250
258
  ) {
251
259
  return
@@ -331,15 +339,13 @@ function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
331
339
  layoutId: view.id,
332
340
  rendererType: 'PileupRenderer',
333
341
  },
334
- )) as { feature: unknown }
342
+ )) as { feature: SimpleFeatureSerialized }
335
343
 
336
344
  // check featureIdUnderMouse is still the same as the
337
345
  // feature.id that was returned e.g. that the user hasn't
338
346
  // moused over to a new position during the async operation
339
347
  // above
340
- // @ts-expect-error
341
348
  if (self.featureIdUnderMouse === feature.uniqueId) {
342
- // @ts-expect-error
343
349
  self.setFeatureUnderMouse(new SimpleFeature(feature))
344
350
  }
345
351
  }
@@ -403,8 +409,8 @@ function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
403
409
  /**
404
410
  * #action
405
411
  */
406
- setConfig(configuration: AnyConfigurationModel) {
407
- self.configuration = configuration
412
+ setConfig(conf: AnyConfigurationModel) {
413
+ self.configuration = conf
408
414
  },
409
415
 
410
416
  /**
@@ -431,12 +437,7 @@ function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
431
437
  }
432
438
  self.ready = false
433
439
  },
434
- setFilterBy(filter: {
435
- flagInclude: number
436
- flagExclude: number
437
- readName?: string
438
- tagFilter?: { tag: string; value: string }
439
- }) {
440
+ setFilterBy(filter: Filter) {
440
441
  self.filterBy = cast(filter)
441
442
  },
442
443
  }))
@@ -456,49 +457,51 @@ function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
456
457
  })
457
458
 
458
459
  .views(self => ({
459
- /**
460
- * #getter
461
- */
462
- get maxHeight() {
463
- const conf = getConf(self, ['renderers', self.rendererTypeName]) || {}
464
- return self.trackMaxHeight !== undefined
465
- ? self.trackMaxHeight
466
- : conf.maxHeight
467
- },
468
-
469
460
  /**
470
461
  * #getter
471
462
  */
472
463
  get rendererConfig() {
473
- const configBlob =
474
- getConf(self, ['renderers', self.rendererTypeName]) || {}
464
+ const {
465
+ featureHeight,
466
+ noSpacing,
467
+ trackMaxHeight,
468
+ mismatchAlpha,
469
+ rendererTypeName,
470
+ } = self
471
+ const configBlob = getConf(self, ['renderers', rendererTypeName]) || {}
475
472
  return self.rendererType.configSchema.create(
476
473
  {
477
474
  ...configBlob,
478
- height: self.featureHeight,
479
- noSpacing: self.noSpacing,
480
- maxHeight: this.maxHeight,
481
- mismatchAlpha: self.mismatchAlpha,
475
+ ...(featureHeight !== undefined ? { height: featureHeight } : {}),
476
+ ...(noSpacing !== undefined ? { noSpacing } : {}),
477
+ ...(mismatchAlpha !== undefined ? { mismatchAlpha } : {}),
478
+ ...(trackMaxHeight !== undefined
479
+ ? { maxHeight: trackMaxHeight }
480
+ : {}),
482
481
  },
483
482
  getEnv(self),
484
483
  )
485
484
  },
485
+ }))
486
+ .views(self => ({
487
+ /**
488
+ * #getter
489
+ */
490
+ get maxHeight() {
491
+ return readConfObject(self.rendererConfig, 'maxHeight')
492
+ },
486
493
 
487
494
  /**
488
495
  * #getter
489
496
  */
490
497
  get featureHeightSetting() {
491
- return (
492
- self.featureHeight || readConfObject(this.rendererConfig, 'height')
493
- )
498
+ return readConfObject(self.rendererConfig, 'height')
494
499
  },
495
500
  /**
496
501
  * #getter
497
502
  */
498
503
  get mismatchAlphaSetting() {
499
- return self.mismatchAlpha !== undefined
500
- ? self.mismatchAlpha
501
- : readConfObject(this.rendererConfig, 'mismatchAlpha')
504
+ return readConfObject(self.rendererConfig, 'mismatchAlpha')
502
505
  },
503
506
  /**
504
507
  * #getter
@@ -614,10 +617,9 @@ function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
614
617
  layoutId: getContainingView(self).id,
615
618
  rendererType: 'PileupRenderer',
616
619
  },
617
- )) as { feature: unknown }
620
+ )) as { feature: SimpleFeatureSerialized | undefined }
618
621
 
619
622
  if (feature) {
620
- // @ts-expect-error
621
623
  self.selectFeature(new SimpleFeature(feature))
622
624
  }
623
625
  }
@@ -94,8 +94,8 @@ export default async function drawFeats(
94
94
 
95
95
  const p1 = f1 ? k1.start : k1.end
96
96
  const p2 = hasPaired ? (f2 ? k2.start : k2.end) : f2 ? k2.end : k2.start
97
- const ra1 = assembly.getCanonicalRefName(k1.refName)
98
- const ra2 = assembly.getCanonicalRefName(k2.refName)
97
+ const ra1 = assembly.getCanonicalRefName(k1.refName) || k1.refName
98
+ const ra2 = assembly.getCanonicalRefName(k2.refName) || k2.refName
99
99
  const r1 = view.bpToPx({ refName: ra1, coord: p1 })
100
100
  const r2 = view.bpToPx({ refName: ra2, coord: p2 })
101
101
 
@@ -1,4 +1,4 @@
1
- import { getConf } from '@jbrowse/core/configuration'
1
+ import { AnyConfigurationModel, getConf } from '@jbrowse/core/configuration'
2
2
  import { getContainingView, getSession } from '@jbrowse/core/util'
3
3
 
4
4
  import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
@@ -53,6 +53,7 @@ export default async function drawFeats(
53
53
  colorBy?: { type: string }
54
54
  height: number
55
55
  chainData?: ChainData
56
+ configuration: AnyConfigurationModel
56
57
  },
57
58
  ctx: CanvasRenderingContext2D,
58
59
  ) {
@@ -82,8 +83,8 @@ export default async function drawFeats(
82
83
  if (chain[0].flags & 1 && chain.length > 1) {
83
84
  const v0 = chain[0]
84
85
  const v1 = chain[1]
85
- const ra1 = asm.getCanonicalRefName(v0.refName)
86
- const ra2 = asm.getCanonicalRefName(v1.refName)
86
+ const ra1 = asm.getCanonicalRefName(v0.refName) || v0.refName
87
+ const ra2 = asm.getCanonicalRefName(v1.refName) || v1.refName
87
88
  const r1s = view.bpToPx({ refName: ra1, coord: v0.start })
88
89
  const r1e = view.bpToPx({ refName: ra1, coord: v0.end })
89
90
  const r2s = view.bpToPx({ refName: ra2, coord: v1.start })
@@ -118,8 +119,8 @@ export default async function drawFeats(
118
119
  for (let i = 1; i < chain.length; i++) {
119
120
  const v0 = chain[i - 1]
120
121
  const v1 = chain[i]
121
- const ra1 = asm.getCanonicalRefName(v0.refName)
122
- const ra2 = asm.getCanonicalRefName(v1.refName)
122
+ const ra1 = asm.getCanonicalRefName(v0.refName) || v0.refName
123
+ const ra2 = asm.getCanonicalRefName(v1.refName) || v1.refName
123
124
  const r1s = view.bpToPx({ refName: ra1, coord: v0.start })
124
125
  const r1e = view.bpToPx({ refName: ra1, coord: v0.end })
125
126
  const r2s = view.bpToPx({ refName: ra2, coord: v1.start })
@@ -218,7 +218,7 @@ function stateModelFactory(
218
218
 
219
219
  if (
220
220
  !view.initialized ||
221
- !self.estimatedStatsReady ||
221
+ !self.featureDensityStatsReady ||
222
222
  self.regionTooLarge
223
223
  ) {
224
224
  return
@@ -1,6 +1,6 @@
1
1
  import deepEqual from 'fast-deep-equal'
2
2
  import { LayoutSession } from '@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType'
3
- import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema'
3
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration'
4
4
  import SerializableFilterChain from '@jbrowse/core/pluggableElementTypes/renderers/util/serializableFilterChain'
5
5
  import GranularRectLayout from '@jbrowse/core/util/layouts/GranularRectLayout'
6
6
  import MultiLayout from '@jbrowse/core/util/layouts/MultiLayout'
@@ -172,7 +172,7 @@ export default class PileupRenderer extends BoxRendererType {
172
172
  // Expand the start and end of feature when softclipping enabled
173
173
  if (showSoftClip) {
174
174
  const mismatches = feature.get('mismatches') as Mismatch[] | undefined
175
- const seq = feature.get('seq') as string
175
+ const seq = feature.get('seq') as string | undefined
176
176
  if (seq && mismatches) {
177
177
  for (let i = 0; i < mismatches.length; i += 1) {
178
178
  const { type, start, cliplen = 0 } = mismatches[i]
@@ -310,13 +310,16 @@ export default class PileupRenderer extends BoxRendererType {
310
310
  }) {
311
311
  const heightLim = charHeight - 2
312
312
  const { feature, topPx, heightPx } = feat
313
- const seq = feature.get('seq') as string
313
+ const seq = feature.get('seq') as string | undefined
314
314
  const cigarOps = parseCigar(feature.get('CIGAR'))
315
315
  const w = 1 / bpPerPx
316
316
  const start = feature.get('start')
317
317
  let soffset = 0 // sequence offset
318
318
  let roffset = 0 // reference offset
319
319
 
320
+ if (!seq) {
321
+ return
322
+ }
320
323
  for (let i = 0; i < cigarOps.length; i += 2) {
321
324
  const len = +cigarOps[i]
322
325
  const op = cigarOps[i + 1]
@@ -451,9 +454,12 @@ export default class PileupRenderer extends BoxRendererType {
451
454
 
452
455
  const cigar = feature.get('CIGAR')
453
456
  const start = feature.get('start')
454
- const seq = feature.get('seq')
457
+ const seq = feature.get('seq') as string | undefined
455
458
  const strand = feature.get('strand')
456
459
  const cigarOps = parseCigar(cigar)
460
+ if (!seq) {
461
+ return
462
+ }
457
463
 
458
464
  const modifications = getModificationPositions(mm, seq, strand)
459
465
 
@@ -521,10 +527,14 @@ export default class PileupRenderer extends BoxRendererType {
521
527
  const cigar = feature.get('CIGAR')
522
528
  const fstart = feature.get('start')
523
529
  const fend = feature.get('end')
524
- const seq = feature.get('seq')
530
+ const seq = feature.get('seq') as string | undefined
525
531
  const strand = feature.get('strand')
526
532
  const cigarOps = parseCigar(cigar)
527
533
 
534
+ if (!seq) {
535
+ return
536
+ }
537
+
528
538
  const methBins = new Array(region.end - region.start).fill(0)
529
539
  const modifications = getModificationPositions(mm, seq, strand)
530
540
  for (let i = 0; i < modifications.length; i++) {
@@ -1035,7 +1045,7 @@ export default class PileupRenderer extends BoxRendererType {
1035
1045
  const [region] = regions
1036
1046
  const minFeatWidth = readConfObject(config, 'minSubfeatureWidth')
1037
1047
  const mismatches = feature.get('mismatches') as Mismatch[] | undefined
1038
- const seq = feature.get('seq')
1048
+ const seq = feature.get('seq') as string | undefined
1039
1049
  const { charWidth, charHeight } = this.getCharWidthHeight()
1040
1050
  const { bases } = theme.palette
1041
1051
  const colorForBase: { [key: string]: string } = {
@@ -94,9 +94,12 @@ export default class SNPCoverageAdapter extends BaseFeatureDataAdapter {
94
94
  }, opts.signal)
95
95
  }
96
96
 
97
- async estimateRegionsStats(regions: Region[], opts?: BaseOptions) {
97
+ async getMultiRegionFeatureDensityStats(
98
+ regions: Region[],
99
+ opts?: BaseOptions,
100
+ ) {
98
101
  const { subadapter } = await this.configure()
99
- return subadapter.estimateRegionsStats(regions, opts)
102
+ return subadapter.getMultiRegionFeatureDensityStats(regions, opts)
100
103
  }
101
104
 
102
105
  async getRefNames(opts: BaseOptions = {}) {
@@ -109,29 +109,30 @@ export default async function generateCoverageBins(
109
109
  }
110
110
 
111
111
  if (colorBy?.type === 'modifications') {
112
- const seq = feature.get('seq') as string
112
+ const seq = feature.get('seq') as string | undefined
113
113
  const mm = (getTagAlt(feature, 'MM', 'Mm') as string) || ''
114
114
  const ops = parseCigar(feature.get('CIGAR'))
115
115
  const fend = feature.get('end')
116
-
117
- getModificationPositions(mm, seq, fstrand).forEach(
118
- ({ type, positions }) => {
119
- const mod = `mod_${type}`
120
- for (const pos of getNextRefPos(ops, positions)) {
121
- const epos = pos + fstart - region.start
122
- if (epos >= 0 && epos < bins.length && pos + fstart < fend) {
123
- const bin = bins[epos]
124
- if (bin) {
125
- inc(bin, fstrand, 'cov', mod)
126
- } else {
127
- console.warn(
128
- 'Undefined position in modifications snpcoverage encountered',
129
- )
116
+ if (seq) {
117
+ getModificationPositions(mm, seq, fstrand).forEach(
118
+ ({ type, positions }) => {
119
+ const mod = `mod_${type}`
120
+ for (const pos of getNextRefPos(ops, positions)) {
121
+ const epos = pos + fstart - region.start
122
+ if (epos >= 0 && epos < bins.length && pos + fstart < fend) {
123
+ const bin = bins[epos]
124
+ if (bin) {
125
+ inc(bin, fstrand, 'cov', mod)
126
+ } else {
127
+ console.warn(
128
+ 'Undefined position in modifications snpcoverage encountered',
129
+ )
130
+ }
130
131
  }
131
132
  }
132
- }
133
- },
134
- )
133
+ },
134
+ )
135
+ }
135
136
  }
136
137
 
137
138
  // methylation based coloring takes into account both reference
@@ -142,49 +143,51 @@ export default async function generateCoverageBins(
142
143
  'no region sequence detected, need sequenceAdapter configuration',
143
144
  )
144
145
  }
145
- const seq = feature.get('seq')
146
+ const seq = feature.get('seq') as string | undefined
146
147
  const mm = getTagAlt(feature, 'MM', 'Mm') || ''
147
148
  const methBins = new Array(region.end - region.start).fill(0)
148
149
  const ops = parseCigar(feature.get('CIGAR'))
149
150
 
150
- getModificationPositions(mm, seq, fstrand).forEach(
151
- ({ type, positions }) => {
152
- // we are processing methylation
153
- if (type === 'm') {
154
- for (const pos of getNextRefPos(ops, positions)) {
155
- const epos = pos + fstart - region.start
156
- if (epos >= 0 && epos < methBins.length) {
157
- methBins[epos] = 1
151
+ if (seq) {
152
+ getModificationPositions(mm, seq, fstrand).forEach(
153
+ ({ type, positions }) => {
154
+ // we are processing methylation
155
+ if (type === 'm') {
156
+ for (const pos of getNextRefPos(ops, positions)) {
157
+ const epos = pos + fstart - region.start
158
+ if (epos >= 0 && epos < methBins.length) {
159
+ methBins[epos] = 1
160
+ }
158
161
  }
159
162
  }
160
- }
161
- },
162
- )
163
-
164
- for (let j = fstart; j < fend; j++) {
165
- const i = j - region.start
166
- if (i >= 0 && i < bins.length - 1) {
167
- const l1 = regionSeq[i].toLowerCase()
168
- const l2 = regionSeq[i + 1].toLowerCase()
169
- const bin = bins[i]
170
- const bin1 = bins[i + 1]
171
-
172
- // color
173
- if (l1 === 'c' && l2 === 'g') {
174
- if (methBins[i] || methBins[i + 1]) {
175
- inc(bin, fstrand, 'cov', 'meth')
176
- inc(bin1, fstrand, 'cov', 'meth')
177
- bins[i].ref--
178
- bins[i][fstrand]--
179
- bins[i + 1].ref--
180
- bins[i + 1][fstrand]--
181
- } else {
182
- inc(bin, fstrand, 'cov', 'unmeth')
183
- inc(bin1, fstrand, 'cov', 'unmeth')
184
- bins[i].ref--
185
- bins[i][fstrand]--
186
- bins[i + 1].ref--
187
- bins[i + 1][fstrand]--
163
+ },
164
+ )
165
+
166
+ for (let j = fstart; j < fend; j++) {
167
+ const i = j - region.start
168
+ if (i >= 0 && i < bins.length - 1) {
169
+ const l1 = regionSeq[i].toLowerCase()
170
+ const l2 = regionSeq[i + 1].toLowerCase()
171
+ const bin = bins[i]
172
+ const bin1 = bins[i + 1]
173
+
174
+ // color
175
+ if (l1 === 'c' && l2 === 'g') {
176
+ if (methBins[i] || methBins[i + 1]) {
177
+ inc(bin, fstrand, 'cov', 'meth')
178
+ inc(bin1, fstrand, 'cov', 'meth')
179
+ bins[i].ref--
180
+ bins[i][fstrand]--
181
+ bins[i + 1].ref--
182
+ bins[i + 1][fstrand]--
183
+ } else {
184
+ inc(bin, fstrand, 'cov', 'unmeth')
185
+ inc(bin1, fstrand, 'cov', 'unmeth')
186
+ bins[i].ref--
187
+ bins[i][fstrand]--
188
+ bins[i + 1].ref--
189
+ bins[i + 1][fstrand]--
190
+ }
188
191
  }
189
192
  }
190
193
  }