@jbrowse/plugin-alignments 1.7.9 → 1.7.10

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.
@@ -65,24 +65,56 @@ export default class PileupRenderer extends BoxRendererType {
65
65
  getOrientation(feature: Feature, config: AnyConfigurationModel): string;
66
66
  colorByInsertSize(feature: Feature, _config: AnyConfigurationModel): string;
67
67
  colorByStranded(feature: Feature, _config: AnyConfigurationModel): "color_rev_strand" | "color_fwd_strand" | "color_rev_missing_mate" | "color_fwd_missing_mate" | "color_rev_strand_not_proper" | "color_fwd_strand_not_proper" | "color_fwd_diff_chr" | "color_rev_diff_chr";
68
- colorByPerBaseLettering(ctx: CanvasRenderingContext2D, feat: LayoutFeature, _config: AnyConfigurationModel, region: Region, bpPerPx: number, props: {
68
+ colorByPerBaseLettering({ ctx, feat, region, bpPerPx, colorForBase, contrastForBase, charWidth, charHeight, canvasWidth, }: {
69
+ ctx: CanvasRenderingContext2D;
70
+ feat: LayoutFeature;
71
+ region: Region;
72
+ bpPerPx: number;
69
73
  colorForBase: Record<string, string>;
70
74
  contrastForBase: Record<string, string>;
71
75
  charWidth: number;
72
76
  charHeight: number;
77
+ canvasWidth: number;
78
+ }): void;
79
+ colorByPerBaseQuality({ ctx, feat, region, bpPerPx, canvasWidth, }: {
80
+ ctx: CanvasRenderingContext2D;
81
+ feat: LayoutFeature;
82
+ region: Region;
83
+ bpPerPx: number;
84
+ canvasWidth: number;
85
+ }): void;
86
+ colorByModifications({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, }: {
87
+ ctx: CanvasRenderingContext2D;
88
+ feat: LayoutFeature;
89
+ region: Region;
90
+ bpPerPx: number;
91
+ renderArgs: RenderArgsDeserializedWithFeaturesAndLayout;
92
+ canvasWidth: number;
93
+ }): void;
94
+ colorByMethylation({ ctx, feat, region, bpPerPx, renderArgs, canvasWidth, }: {
95
+ ctx: CanvasRenderingContext2D;
96
+ feat: LayoutFeature;
97
+ region: Region;
98
+ bpPerPx: number;
99
+ renderArgs: RenderArgsDeserializedWithFeaturesAndLayout;
100
+ canvasWidth: number;
73
101
  }): void;
74
- colorByPerBaseQuality(ctx: CanvasRenderingContext2D, feat: LayoutFeature, _config: AnyConfigurationModel, region: Region, bpPerPx: number): void;
75
- colorByModifications(ctx: CanvasRenderingContext2D, layoutFeature: LayoutFeature, _config: AnyConfigurationModel, region: Region, bpPerPx: number, props: RenderArgsDeserializedWithFeaturesAndLayout): void;
76
- colorByMethylation(ctx: CanvasRenderingContext2D, layoutFeature: LayoutFeature, _config: AnyConfigurationModel, region: Region, bpPerPx: number, props: RenderArgsDeserializedWithFeaturesAndLayout): void;
77
102
  drawRect(ctx: CanvasRenderingContext2D, feat: LayoutFeature, props: RenderArgsDeserialized): void;
78
- drawAlignmentRect(ctx: CanvasRenderingContext2D, feat: LayoutFeature, props: RenderArgsDeserializedWithFeaturesAndLayout & {
103
+ drawAlignmentRect({ ctx, feat, renderArgs, colorForBase, contrastForBase, charWidth, charHeight, defaultColor, canvasWidth, }: {
104
+ ctx: CanvasRenderingContext2D;
105
+ feat: LayoutFeature;
106
+ renderArgs: RenderArgsDeserializedWithFeaturesAndLayout;
79
107
  colorForBase: Record<string, string>;
80
108
  contrastForBase: Record<string, string>;
81
109
  charWidth: number;
82
110
  charHeight: number;
83
111
  defaultColor: boolean;
112
+ canvasWidth: number;
84
113
  }): void;
85
- drawMismatches(ctx: CanvasRenderingContext2D, feat: LayoutFeature, props: RenderArgsDeserializedWithFeaturesAndLayout, opts: {
114
+ drawMismatches({ ctx, feat, renderArgs, minSubfeatureWidth, largeInsertionIndicatorScale, mismatchAlpha, charWidth, charHeight, colorForBase, contrastForBase, canvasWidth, drawSNPs, drawIndels, }: {
115
+ ctx: CanvasRenderingContext2D;
116
+ feat: LayoutFeature;
117
+ renderArgs: RenderArgsDeserializedWithFeaturesAndLayout;
86
118
  colorForBase: {
87
119
  [key: string]: string;
88
120
  };
@@ -96,9 +128,22 @@ export default class PileupRenderer extends BoxRendererType {
96
128
  largeInsertionIndicatorScale: number;
97
129
  charWidth: number;
98
130
  charHeight: number;
131
+ canvasWidth: number;
132
+ }): void;
133
+ drawSoftClipping({ ctx, feat, renderArgs, config, theme, canvasWidth, }: {
134
+ ctx: CanvasRenderingContext2D;
135
+ feat: LayoutFeature;
136
+ renderArgs: RenderArgsDeserializedWithFeaturesAndLayout;
137
+ config: AnyConfigurationModel;
138
+ theme: Theme;
139
+ canvasWidth: number;
140
+ }): void;
141
+ makeImageData({ ctx, layoutRecords, canvasWidth, renderArgs, }: {
142
+ ctx: CanvasRenderingContext2D;
143
+ canvasWidth: number;
144
+ layoutRecords: (LayoutFeature | null)[];
145
+ renderArgs: RenderArgsDeserializedWithFeaturesAndLayout;
99
146
  }): void;
100
- drawSoftClipping(ctx: CanvasRenderingContext2D, feat: LayoutFeature, props: RenderArgsDeserializedWithFeaturesAndLayout, config: AnyConfigurationModel, theme: Theme): void;
101
- makeImageData(ctx: CanvasRenderingContext2D, layoutRecords: (LayoutFeature | null)[], props: RenderArgsDeserializedWithFeaturesAndLayout): void;
102
147
  layoutFeats(props: RenderArgsDeserializedWithFeaturesAndLayout): (LayoutRecord | null)[];
103
148
  fetchSequence(renderProps: RenderArgsDeserialized): Promise<any>;
104
149
  render(renderProps: RenderArgsDeserialized): Promise<{
@@ -65,6 +65,18 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
65
65
 
66
66
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
67
67
 
68
+ function fillRect(ctx, l, t, w, h, cw, color) {
69
+ if (l + w < 0 || l > cw) {
70
+ return;
71
+ } else {
72
+ if (color) {
73
+ ctx.fillStyle = color;
74
+ }
75
+
76
+ ctx.fillRect(l, t, w, h);
77
+ }
78
+ }
79
+
68
80
  function getColorBaseMap(theme) {
69
81
  return {
70
82
  A: theme.palette.bases.A.main,
@@ -275,18 +287,23 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
275
287
  }
276
288
  }, {
277
289
  key: "colorByPerBaseLettering",
278
- value: function colorByPerBaseLettering(ctx, feat, _config, region, bpPerPx, props) {
279
- var colorForBase = props.colorForBase,
280
- contrastForBase = props.contrastForBase,
281
- charWidth = props.charWidth,
282
- charHeight = props.charHeight;
290
+ value: function colorByPerBaseLettering(_ref4) {
291
+ var ctx = _ref4.ctx,
292
+ feat = _ref4.feat,
293
+ region = _ref4.region,
294
+ bpPerPx = _ref4.bpPerPx,
295
+ colorForBase = _ref4.colorForBase,
296
+ contrastForBase = _ref4.contrastForBase,
297
+ charWidth = _ref4.charWidth,
298
+ charHeight = _ref4.charHeight,
299
+ canvasWidth = _ref4.canvasWidth;
283
300
  var heightLim = charHeight - 2;
284
301
  var feature = feat.feature,
285
302
  topPx = feat.topPx,
286
303
  heightPx = feat.heightPx;
287
304
  var seq = feature.get('seq');
288
305
  var cigarOps = (0, _MismatchParser.parseCigar)(feature.get('CIGAR'));
289
- var widthPx = 1 / bpPerPx;
306
+ var w = 1 / bpPerPx;
290
307
  var start = feature.get('start');
291
308
  var soffset = 0; // sequence offset
292
309
 
@@ -303,18 +320,18 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
303
320
  } else if (op === 'M' || op === 'X' || op === '=') {
304
321
  for (var m = 0; m < len; m++) {
305
322
  var letter = seq[soffset + m];
306
- ctx.fillStyle = colorForBase[letter];
323
+ var r = start + roffset + m;
307
324
 
308
- var _bpSpanPx3 = (0, _util.bpSpanPx)(start + roffset + m, start + roffset + m + 1, region, bpPerPx),
325
+ var _bpSpanPx3 = (0, _util.bpSpanPx)(r, r + 1, region, bpPerPx),
309
326
  _bpSpanPx4 = (0, _slicedToArray2.default)(_bpSpanPx3, 1),
310
327
  leftPx = _bpSpanPx4[0];
311
328
 
312
- ctx.fillRect(leftPx, topPx, widthPx + 0.5, heightPx);
329
+ fillRect(ctx, leftPx, topPx, w + 0.5, heightPx, canvasWidth, colorForBase[letter]);
313
330
 
314
- if (widthPx >= charWidth && heightPx >= heightLim) {
331
+ if (w >= charWidth && heightPx >= heightLim) {
315
332
  // normal SNP coloring
316
333
  ctx.fillStyle = contrastForBase[letter];
317
- ctx.fillText(letter, leftPx + (widthPx - charWidth) / 2 + 1, topPx + heightPx);
334
+ ctx.fillText(letter, leftPx + (w - charWidth) / 2 + 1, topPx + heightPx);
318
335
  }
319
336
  }
320
337
 
@@ -325,7 +342,12 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
325
342
  }
326
343
  }, {
327
344
  key: "colorByPerBaseQuality",
328
- value: function colorByPerBaseQuality(ctx, feat, _config, region, bpPerPx) {
345
+ value: function colorByPerBaseQuality(_ref5) {
346
+ var ctx = _ref5.ctx,
347
+ feat = _ref5.feat,
348
+ region = _ref5.region,
349
+ bpPerPx = _ref5.bpPerPx,
350
+ canvasWidth = _ref5.canvasWidth;
329
351
  var feature = feat.feature,
330
352
  topPx = feat.topPx,
331
353
  heightPx = feat.heightPx;
@@ -351,13 +373,12 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
351
373
  } else if (op === 'M' || op === 'X' || op === '=') {
352
374
  for (var m = 0; m < len; m++) {
353
375
  var score = scores[soffset + m];
354
- ctx.fillStyle = "hsl(".concat(score === 255 ? 150 : score * 1.5, ",55%,50%)");
355
376
 
356
377
  var _bpSpanPx5 = (0, _util.bpSpanPx)(start + roffset + m, start + roffset + m + 1, region, bpPerPx),
357
378
  _bpSpanPx6 = (0, _slicedToArray2.default)(_bpSpanPx5, 1),
358
379
  leftPx = _bpSpanPx6[0];
359
380
 
360
- ctx.fillRect(leftPx, topPx, width + 0.5, heightPx);
381
+ fillRect(ctx, leftPx, topPx, width + 0.5, heightPx, canvasWidth, "hsl(".concat(score === 255 ? 150 : score * 1.5, ",55%,50%)"));
361
382
  }
362
383
 
363
384
  soffset += len;
@@ -376,12 +397,18 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
376
397
 
377
398
  }, {
378
399
  key: "colorByModifications",
379
- value: function colorByModifications(ctx, layoutFeature, _config, region, bpPerPx, props) {
380
- var feature = layoutFeature.feature,
381
- topPx = layoutFeature.topPx,
382
- heightPx = layoutFeature.heightPx;
383
- var _props$modificationTa = props.modificationTagMap,
384
- modificationTagMap = _props$modificationTa === void 0 ? {} : _props$modificationTa;
400
+ value: function colorByModifications(_ref6) {
401
+ var ctx = _ref6.ctx,
402
+ feat = _ref6.feat,
403
+ region = _ref6.region,
404
+ bpPerPx = _ref6.bpPerPx,
405
+ renderArgs = _ref6.renderArgs,
406
+ canvasWidth = _ref6.canvasWidth;
407
+ var feature = feat.feature,
408
+ topPx = feat.topPx,
409
+ heightPx = feat.heightPx;
410
+ var _renderArgs$modificat = renderArgs.modificationTagMap,
411
+ modificationTagMap = _renderArgs$modificat === void 0 ? {} : _renderArgs$modificat;
385
412
  var mm = (0, _util2.getTagAlt)(feature, 'MM', 'Mm') || '';
386
413
  var ml = (0, _util2.getTagAlt)(feature, 'ML', 'Ml') || [];
387
414
  var probabilities = ml ? (typeof ml === 'string' ? ml.split(',').map(function (e) {
@@ -425,8 +452,7 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
425
452
 
426
453
 
427
454
  var prob = probabilities[probIndex];
428
- ctx.fillStyle = prob && prob !== 1 ? base.alpha(prob + 0.1).hsl().string() : col;
429
- ctx.fillRect(leftPx, topPx, rightPx - leftPx + 0.5, heightPx);
455
+ fillRect(ctx, leftPx, topPx, rightPx - leftPx + 0.5, heightPx, canvasWidth, prob && prob !== 1 ? base.alpha(prob + 0.1).hsl().string() : col);
430
456
  probIndex++;
431
457
  }
432
458
  } catch (err) {
@@ -441,11 +467,17 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
441
467
 
442
468
  }, {
443
469
  key: "colorByMethylation",
444
- value: function colorByMethylation(ctx, layoutFeature, _config, region, bpPerPx, props) {
445
- var regionSequence = props.regionSequence;
446
- var feature = layoutFeature.feature,
447
- topPx = layoutFeature.topPx,
448
- heightPx = layoutFeature.heightPx;
470
+ value: function colorByMethylation(_ref7) {
471
+ var ctx = _ref7.ctx,
472
+ feat = _ref7.feat,
473
+ region = _ref7.region,
474
+ bpPerPx = _ref7.bpPerPx,
475
+ renderArgs = _ref7.renderArgs,
476
+ canvasWidth = _ref7.canvasWidth;
477
+ var regionSequence = renderArgs.regionSequence;
478
+ var feature = feat.feature,
479
+ topPx = feat.topPx,
480
+ heightPx = feat.heightPx;
449
481
  var mm = (0, _util2.getTagAlt)(feature, 'MM', 'Mm') || '';
450
482
 
451
483
  if (!regionSequence) {
@@ -505,8 +537,7 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
505
537
  leftPx = _bpSpanPx10[0],
506
538
  rightPx = _bpSpanPx10[1];
507
539
 
508
- ctx.fillStyle = methBins[_i] || methBins[_i + 1] ? 'red' : 'blue';
509
- ctx.fillRect(leftPx, topPx, rightPx - leftPx + 0.5, heightPx);
540
+ fillRect(ctx, leftPx, topPx, rightPx - leftPx + 0.5, heightPx, canvasWidth, methBins[_i] || methBins[_i + 1] ? 'red' : 'blue');
510
541
  }
511
542
  } // if we are zoomed in, color the c inside the cpg
512
543
  else {
@@ -519,16 +550,14 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
519
550
  _leftPx = _bpSpanPx12[0],
520
551
  _rightPx = _bpSpanPx12[1];
521
552
 
522
- ctx.fillStyle = methBins[_i] ? 'red' : 'blue';
523
- ctx.fillRect(_leftPx, topPx, _rightPx - _leftPx + 0.5, heightPx);
553
+ fillRect(ctx, _leftPx, topPx, _rightPx - _leftPx + 0.5, heightPx, canvasWidth, methBins[_i] ? 'red' : 'blue');
524
554
 
525
555
  var _bpSpanPx13 = (0, _util.bpSpanPx)(_s + 1, _s + 2, region, bpPerPx),
526
556
  _bpSpanPx14 = (0, _slicedToArray2.default)(_bpSpanPx13, 2),
527
557
  leftPx2 = _bpSpanPx14[0],
528
558
  rightPx2 = _bpSpanPx14[1];
529
559
 
530
- ctx.fillStyle = methBins[_i + 1] ? 'red' : 'blue';
531
- ctx.fillRect(leftPx2, topPx, rightPx2 - leftPx2 + 0.5, heightPx);
560
+ fillRect(ctx, leftPx2, topPx, rightPx2 - leftPx2 + 0.5, heightPx, canvasWidth, methBins[_i + 1] ? 'red' : 'blue');
532
561
  }
533
562
  }
534
563
  }
@@ -580,24 +609,28 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
580
609
  }
581
610
  }, {
582
611
  key: "drawAlignmentRect",
583
- value: function drawAlignmentRect(ctx, feat, props) {
584
- var defaultColor = props.defaultColor,
585
- config = props.config,
586
- bpPerPx = props.bpPerPx,
587
- regions = props.regions,
588
- colorBy = props.colorBy,
589
- _props$colorTagMap = props.colorTagMap,
590
- colorTagMap = _props$colorTagMap === void 0 ? {} : _props$colorTagMap,
591
- colorForBase = props.colorForBase,
592
- contrastForBase = props.contrastForBase,
593
- charWidth = props.charWidth,
594
- charHeight = props.charHeight;
595
-
596
- var _ref4 = colorBy || {},
597
- _ref4$tag = _ref4.tag,
598
- tag = _ref4$tag === void 0 ? '' : _ref4$tag,
599
- _ref4$type = _ref4.type,
600
- colorType = _ref4$type === void 0 ? '' : _ref4$type;
612
+ value: function drawAlignmentRect(_ref8) {
613
+ var ctx = _ref8.ctx,
614
+ feat = _ref8.feat,
615
+ renderArgs = _ref8.renderArgs,
616
+ colorForBase = _ref8.colorForBase,
617
+ contrastForBase = _ref8.contrastForBase,
618
+ charWidth = _ref8.charWidth,
619
+ charHeight = _ref8.charHeight,
620
+ defaultColor = _ref8.defaultColor,
621
+ canvasWidth = _ref8.canvasWidth;
622
+ var config = renderArgs.config,
623
+ bpPerPx = renderArgs.bpPerPx,
624
+ regions = renderArgs.regions,
625
+ colorBy = renderArgs.colorBy,
626
+ _renderArgs$colorTagM = renderArgs.colorTagMap,
627
+ colorTagMap = _renderArgs$colorTagM === void 0 ? {} : _renderArgs$colorTagM;
628
+
629
+ var _ref9 = colorBy || {},
630
+ _ref9$tag = _ref9.tag,
631
+ tag = _ref9$tag === void 0 ? '' : _ref9$tag,
632
+ _ref9$type = _ref9.type,
633
+ colorType = _ref9$type === void 0 ? '' : _ref9$type;
601
634
 
602
635
  var feature = feat.feature;
603
636
  var region = regions[0]; // first pass for simple color changes that change the color of the
@@ -685,48 +718,77 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
685
718
  break;
686
719
  }
687
720
 
688
- this.drawRect(ctx, feat, props); // second pass for color types that render per-base things that go over the
721
+ this.drawRect(ctx, feat, renderArgs); // second pass for color types that render per-base things that go over the
689
722
  // existing drawing
690
723
 
691
724
  switch (colorType) {
692
725
  case 'perBaseQuality':
693
- this.colorByPerBaseQuality(ctx, feat, config, region, bpPerPx);
726
+ this.colorByPerBaseQuality({
727
+ ctx: ctx,
728
+ feat: feat,
729
+ region: region,
730
+ bpPerPx: bpPerPx,
731
+ canvasWidth: canvasWidth
732
+ });
694
733
  break;
695
734
 
696
735
  case 'perBaseLettering':
697
- this.colorByPerBaseLettering(ctx, feat, config, region, bpPerPx, {
736
+ this.colorByPerBaseLettering({
737
+ ctx: ctx,
738
+ feat: feat,
739
+ region: region,
740
+ bpPerPx: bpPerPx,
698
741
  colorForBase: colorForBase,
699
742
  contrastForBase: contrastForBase,
700
743
  charWidth: charWidth,
701
- charHeight: charHeight
744
+ charHeight: charHeight,
745
+ canvasWidth: canvasWidth
702
746
  });
703
747
  break;
704
748
 
705
749
  case 'modifications':
706
- this.colorByModifications(ctx, feat, config, region, bpPerPx, props);
750
+ this.colorByModifications({
751
+ ctx: ctx,
752
+ feat: feat,
753
+ region: region,
754
+ bpPerPx: bpPerPx,
755
+ renderArgs: renderArgs,
756
+ canvasWidth: canvasWidth
757
+ });
707
758
  break;
708
759
 
709
760
  case 'methylation':
710
- this.colorByMethylation(ctx, feat, config, region, bpPerPx, props);
761
+ this.colorByMethylation({
762
+ ctx: ctx,
763
+ feat: feat,
764
+ region: region,
765
+ bpPerPx: bpPerPx,
766
+ renderArgs: renderArgs,
767
+ canvasWidth: canvasWidth
768
+ });
711
769
  break;
712
770
  }
713
771
  }
714
772
  }, {
715
773
  key: "drawMismatches",
716
- value: function drawMismatches(ctx, feat, props, opts) {
717
- var minSubfeatureWidth = opts.minSubfeatureWidth,
718
- largeInsertionIndicatorScale = opts.largeInsertionIndicatorScale,
719
- mismatchAlpha = opts.mismatchAlpha,
720
- _opts$drawSNPs = opts.drawSNPs,
721
- drawSNPs = _opts$drawSNPs === void 0 ? true : _opts$drawSNPs,
722
- _opts$drawIndels = opts.drawIndels,
723
- drawIndels = _opts$drawIndels === void 0 ? true : _opts$drawIndels,
724
- charWidth = opts.charWidth,
725
- charHeight = opts.charHeight,
726
- colorForBase = opts.colorForBase,
727
- contrastForBase = opts.contrastForBase;
728
- var bpPerPx = props.bpPerPx,
729
- regions = props.regions;
774
+ value: function drawMismatches(_ref10) {
775
+ var ctx = _ref10.ctx,
776
+ feat = _ref10.feat,
777
+ renderArgs = _ref10.renderArgs,
778
+ minSubfeatureWidth = _ref10.minSubfeatureWidth,
779
+ largeInsertionIndicatorScale = _ref10.largeInsertionIndicatorScale,
780
+ mismatchAlpha = _ref10.mismatchAlpha,
781
+ charWidth = _ref10.charWidth,
782
+ charHeight = _ref10.charHeight,
783
+ colorForBase = _ref10.colorForBase,
784
+ contrastForBase = _ref10.contrastForBase,
785
+ canvasWidth = _ref10.canvasWidth,
786
+ _ref10$drawSNPs = _ref10.drawSNPs,
787
+ drawSNPs = _ref10$drawSNPs === void 0 ? true : _ref10$drawSNPs,
788
+ _ref10$drawIndels = _ref10.drawIndels,
789
+ drawIndels = _ref10$drawIndels === void 0 ? true : _ref10$drawIndels;
790
+ var bpPerPx = renderArgs.bpPerPx,
791
+ regions = renderArgs.regions;
730
792
  var heightPx = feat.heightPx,
731
793
  topPx = feat.topPx,
732
794
  feature = feat.feature;
@@ -759,8 +821,7 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
759
821
 
760
822
  if (mismatch.type === 'mismatch' && drawSNPs) {
761
823
  var baseColor = colorForBase[mismatch.base] || '#888';
762
- ctx.fillStyle = !mismatchAlpha ? baseColor : mismatch.qual !== undefined ? (0, _color.default)(baseColor).alpha(Math.min(1, mismatch.qual / 50)).hsl().string() : baseColor;
763
- ctx.fillRect(leftPx, topPx, widthPx, heightPx);
824
+ fillRect(ctx, leftPx, topPx, widthPx, heightPx, canvasWidth, !mismatchAlpha ? baseColor : mismatch.qual !== undefined ? (0, _color.default)(baseColor).alpha(Math.min(1, mismatch.qual / 50)).hsl().string() : baseColor);
764
825
 
765
826
  if (widthPx >= charWidth && heightPx >= heightLim) {
766
827
  // normal SNP coloring
@@ -769,9 +830,7 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
769
830
  ctx.fillText(mbase, leftPx + (widthPx - charWidth) / 2 + 1, topPx + heightPx);
770
831
  }
771
832
  } else if (mismatch.type === 'deletion' && drawIndels) {
772
- var _baseColor = colorForBase.deletion;
773
- ctx.fillStyle = _baseColor;
774
- ctx.fillRect(leftPx, topPx, widthPx, heightPx);
833
+ fillRect(ctx, leftPx, topPx, widthPx, heightPx, canvasWidth, colorForBase.deletion);
775
834
  var txt = "".concat(mismatch.length);
776
835
  var rwidth = (0, _util.measureText)(txt, 10);
777
836
 
@@ -786,24 +845,22 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
786
845
  var insW = Math.max(minSubfeatureWidth / 2, Math.min(1.2, 1 / bpPerPx));
787
846
 
788
847
  if (len < 10) {
789
- ctx.fillRect(pos, topPx, insW, heightPx);
848
+ fillRect(ctx, pos, topPx, insW, heightPx, canvasWidth, 'purple');
790
849
 
791
850
  if (1 / bpPerPx >= charWidth && heightPx >= heightLim) {
792
- ctx.fillRect(pos - insW, topPx, insW * 3, 1);
793
- ctx.fillRect(pos - insW, topPx + heightPx - 1, insW * 3, 1);
851
+ fillRect(ctx, pos - insW, topPx, insW * 3, 1, canvasWidth);
852
+ fillRect(ctx, pos - insW, topPx + heightPx - 1, insW * 3, 1, canvasWidth);
794
853
  ctx.fillText("(".concat(mismatch.base, ")"), pos + 3, topPx + heightPx);
795
854
  }
796
855
  }
797
856
  } else if (mismatch.type === 'hardclip' || mismatch.type === 'softclip') {
798
- ctx.fillStyle = mismatch.type === 'hardclip' ? 'red' : 'blue';
799
-
800
857
  var _pos = leftPx + extraHorizontallyFlippedOffset;
801
858
 
802
- ctx.fillRect(_pos, topPx, w, heightPx);
859
+ fillRect(ctx, _pos, topPx, w, heightPx, canvasWidth, mismatch.type === 'hardclip' ? 'red' : 'blue');
803
860
 
804
861
  if (1 / bpPerPx >= charWidth && heightPx >= heightLim) {
805
- ctx.fillRect(_pos - w, topPx, w * 3, 1);
806
- ctx.fillRect(_pos - w, topPx + heightPx - 1, w * 3, 1);
862
+ fillRect(ctx, _pos - w, topPx, w * 3, 1, canvasWidth);
863
+ fillRect(ctx, _pos - w, topPx + heightPx - 1, w * 3, 1, canvasWidth);
807
864
  ctx.fillText("(".concat(mismatch.base, ")"), _pos + 3, topPx + heightPx);
808
865
  }
809
866
  } else if (mismatch.type === 'skip') {
@@ -814,8 +871,7 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
814
871
  // make small exons more visible when zoomed far out
815
872
  var adjustPx = widthPx - (bpPerPx > 10 ? 1.5 : 0);
816
873
  ctx.clearRect(leftPx, topPx, adjustPx, heightPx);
817
- ctx.fillStyle = '#333';
818
- ctx.fillRect(Math.max(0, leftPx), topPx + heightPx / 2 - 1, adjustPx + (leftPx < 0 ? leftPx : 0), 2);
874
+ fillRect(ctx, Math.max(0, leftPx), topPx + heightPx / 2 - 1, adjustPx + (leftPx < 0 ? leftPx : 0), 2, canvasWidth, '#333');
819
875
  }
820
876
  }
821
877
  } // second pass, draw wide insertion markers on top
@@ -839,20 +895,17 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
839
895
 
840
896
  if (_mismatch.type === 'insertion' && _len2 >= 10) {
841
897
  if (bpPerPx > largeInsertionIndicatorScale) {
842
- ctx.fillStyle = 'purple';
843
- ctx.fillRect(_leftPx2 - 1, topPx, 2, heightPx);
898
+ fillRect(ctx, _leftPx2 - 1, topPx, 2, heightPx, canvasWidth, 'purple');
844
899
  } else if (heightPx > charHeight) {
845
900
  var _rwidth = (0, _util.measureText)(_txt);
846
901
 
847
902
  var padding = 5;
848
- ctx.fillStyle = 'purple';
849
- ctx.fillRect(_leftPx2 - _rwidth / 2 - padding, topPx, _rwidth + 2 * padding, heightPx);
903
+ fillRect(ctx, _leftPx2 - _rwidth / 2 - padding, topPx, _rwidth + 2 * padding, heightPx, canvasWidth, 'purple');
850
904
  ctx.fillStyle = 'white';
851
905
  ctx.fillText(_txt, _leftPx2 - _rwidth / 2, topPx + heightPx);
852
906
  } else {
853
907
  var _padding = 2;
854
- ctx.fillStyle = 'purple';
855
- ctx.fillRect(_leftPx2 - _padding, topPx, 2 * _padding, heightPx);
908
+ fillRect(ctx, _leftPx2 - _padding, topPx, 2 * _padding, heightPx, canvasWidth, 'purple');
856
909
  }
857
910
  }
858
911
  }
@@ -860,12 +913,18 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
860
913
  }
861
914
  }, {
862
915
  key: "drawSoftClipping",
863
- value: function drawSoftClipping(ctx, feat, props, config, theme) {
916
+ value: function drawSoftClipping(_ref11) {
917
+ var ctx = _ref11.ctx,
918
+ feat = _ref11.feat,
919
+ renderArgs = _ref11.renderArgs,
920
+ config = _ref11.config,
921
+ theme = _ref11.theme,
922
+ canvasWidth = _ref11.canvasWidth;
864
923
  var feature = feat.feature,
865
924
  topPx = feat.topPx,
866
925
  heightPx = feat.heightPx;
867
- var regions = props.regions,
868
- bpPerPx = props.bpPerPx;
926
+ var regions = renderArgs.regions,
927
+ bpPerPx = renderArgs.bpPerPx;
869
928
 
870
929
  var _regions3 = (0, _slicedToArray2.default)(regions, 1),
871
930
  region = _regions3[0];
@@ -913,7 +972,7 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
913
972
 
914
973
  var baseColor = colorForBase[base] || '#000000';
915
974
  ctx.fillStyle = baseColor;
916
- ctx.fillRect(softClipLeftPx, topPx, softClipWidthPx, heightPx);
975
+ fillRect(ctx, softClipLeftPx, topPx, softClipWidthPx, heightPx, canvasWidth);
917
976
 
918
977
  if (softClipWidthPx >= charWidth && heightPx >= charHeight - 5) {
919
978
  ctx.fillStyle = theme.palette.getContrastText(baseColor);
@@ -925,12 +984,16 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
925
984
  }
926
985
  }, {
927
986
  key: "makeImageData",
928
- value: function makeImageData(ctx, layoutRecords, props) {
929
- var layout = props.layout,
930
- config = props.config,
931
- showSoftClip = props.showSoftClip,
932
- colorBy = props.colorBy,
933
- configTheme = props.theme;
987
+ value: function makeImageData(_ref12) {
988
+ var ctx = _ref12.ctx,
989
+ layoutRecords = _ref12.layoutRecords,
990
+ canvasWidth = _ref12.canvasWidth,
991
+ renderArgs = _ref12.renderArgs;
992
+ var layout = renderArgs.layout,
993
+ config = renderArgs.config,
994
+ showSoftClip = renderArgs.showSoftClip,
995
+ colorBy = renderArgs.colorBy,
996
+ configTheme = renderArgs.theme;
934
997
  var mismatchAlpha = (0, _configuration.readConfObject)(config, 'mismatchAlpha');
935
998
  var minSubfeatureWidth = (0, _configuration.readConfObject)(config, 'minSubfeatureWidth');
936
999
  var largeInsertionIndicatorScale = (0, _configuration.readConfObject)(config, 'largeInsertionIndicatorScale');
@@ -963,14 +1026,21 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
963
1026
  continue;
964
1027
  }
965
1028
 
966
- this.drawAlignmentRect(ctx, feat, _objectSpread(_objectSpread({}, props), {}, {
1029
+ this.drawAlignmentRect({
1030
+ ctx: ctx,
1031
+ feat: feat,
1032
+ renderArgs: renderArgs,
967
1033
  defaultColor: defaultColor,
968
1034
  colorForBase: colorForBase,
969
1035
  contrastForBase: contrastForBase,
970
1036
  charWidth: charWidth,
971
- charHeight: charHeight
972
- }));
973
- this.drawMismatches(ctx, feat, props, {
1037
+ charHeight: charHeight,
1038
+ canvasWidth: canvasWidth
1039
+ });
1040
+ this.drawMismatches({
1041
+ ctx: ctx,
1042
+ feat: feat,
1043
+ renderArgs: renderArgs,
974
1044
  mismatchAlpha: mismatchAlpha,
975
1045
  drawSNPs: drawSNPs,
976
1046
  drawIndels: drawIndels,
@@ -979,19 +1049,19 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
979
1049
  charWidth: charWidth,
980
1050
  charHeight: charHeight,
981
1051
  colorForBase: colorForBase,
982
- contrastForBase: contrastForBase
1052
+ contrastForBase: contrastForBase,
1053
+ canvasWidth: canvasWidth
983
1054
  });
984
- }
985
-
986
- if (showSoftClip) {
987
- for (var _i3 = 0; _i3 < layoutRecords.length; _i3++) {
988
- var _feat = layoutRecords[_i3];
989
-
990
- if (_feat === null) {
991
- continue;
992
- }
993
1055
 
994
- this.drawSoftClipping(ctx, _feat, props, config, theme);
1056
+ if (showSoftClip) {
1057
+ this.drawSoftClipping({
1058
+ ctx: ctx,
1059
+ feat: feat,
1060
+ renderArgs: renderArgs,
1061
+ config: config,
1062
+ theme: theme,
1063
+ canvasWidth: canvasWidth
1064
+ });
995
1065
  }
996
1066
  }
997
1067
  } // we perform a full layout before render as a separate method because the
@@ -1130,11 +1200,16 @@ var PileupRenderer = /*#__PURE__*/function (_BoxRendererType) {
1130
1200
  height = Math.max(layout.getTotalHeight(), 1);
1131
1201
  _context2.next = 20;
1132
1202
  return (0, _offscreenCanvasUtils.renderToAbstractCanvas)(width, height, renderProps, function (ctx) {
1133
- return _this3.makeImageData(ctx, layoutRecords, _objectSpread(_objectSpread({}, renderProps), {}, {
1134
- layout: layout,
1135
- features: features,
1136
- regionSequence: regionSequence
1137
- }));
1203
+ return _this3.makeImageData({
1204
+ ctx: ctx,
1205
+ layoutRecords: layoutRecords,
1206
+ canvasWidth: width,
1207
+ renderArgs: _objectSpread(_objectSpread({}, renderProps), {}, {
1208
+ layout: layout,
1209
+ features: features,
1210
+ regionSequence: regionSequence
1211
+ })
1212
+ });
1138
1213
  });
1139
1214
 
1140
1215
  case 20:
@@ -19,7 +19,9 @@ export default class SNPCoverageAdapter extends BaseFeatureDataAdapter {
19
19
  };
20
20
  }): Promise<{
21
21
  bins: {
22
+ refbase?: string | undefined;
22
23
  total: number;
24
+ all: number;
23
25
  ref: number;
24
26
  '-1': 0;
25
27
  '0': 0;