oncoprintjs 6.0.3 → 6.0.5

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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export { default as OncoprintJS, InitParams, HorzZoomCallback, MinimapCloseCallback, CellMouseOverCallback, CellClickCallback, ClipboardChangeCallback, } from './js/oncoprint';
2
2
  export * from './js/oncoprintruleset';
3
+ export { default as OncoprintModel } from './js/oncoprintmodel';
3
4
  export * from './js/oncoprintmodel';
4
5
  export { default as shapeToSvg } from './js/oncoprintshapetosvg';
package/dist/index.es.js CHANGED
@@ -1,6 +1,6 @@
1
- import { __awaiter, __generator, __extends } from 'tslib';
1
+ import { __awaiter, __generator, __spreadArrays, __extends } from 'tslib';
2
2
  import $$1 from 'jquery';
3
- import _ from 'lodash';
3
+ import _, { isNumber } from 'lodash';
4
4
  import gl_matrix from 'gl-matrix';
5
5
 
6
6
  /*
@@ -1385,6 +1385,12 @@ var OncoprintModel = /** @class */ (function () {
1385
1385
  writable: true,
1386
1386
  value: void 0
1387
1387
  });
1388
+ Object.defineProperty(this, "data_groups", {
1389
+ enumerable: true,
1390
+ configurable: true,
1391
+ writable: true,
1392
+ value: void 0
1393
+ });
1388
1394
  Object.defineProperty(this, "column_indexes_after_a_gap", {
1389
1395
  enumerable: true,
1390
1396
  configurable: true,
@@ -1606,6 +1612,38 @@ var OncoprintModel = /** @class */ (function () {
1606
1612
  }
1607
1613
  return gapIds;
1608
1614
  });
1615
+ this.data_groups = new CachedProperty({}, function (model) {
1616
+ // multiple tracks can have gaps
1617
+ // the groups will be segemented heirarchically
1618
+ var trackIdsWithGaps = model
1619
+ .getTracks()
1620
+ .filter(function (trackId) { return model.getTrackShowGaps(trackId); });
1621
+ var data_groups = _.reduce(model.track_label, function (agg, label, trackId) {
1622
+ // key the data by the datum UID
1623
+ var keyedData = _.keyBy(model.track_data[trackId], function (m) { return m.uid; });
1624
+ var groups = trackIdsWithGaps.map(function (id) {
1625
+ // we need the datum in sorted order
1626
+ var data = model.id_order.map(function (d) { return keyedData[d]; });
1627
+ var indexesAfterGap = model.column_indexes_after_a_gap.get();
1628
+ // the indexes come AFTER a gap, so we need to include zero up front
1629
+ // in order to get initial slice of data
1630
+ var groupStartIndexes = __spreadArrays([0], indexesAfterGap);
1631
+ // using the group start indexes, slice the id data into corresponding groups
1632
+ return groupStartIndexes.map(function (n, i) {
1633
+ if (i === groupStartIndexes.length - 1) {
1634
+ // we're at last one, so last group
1635
+ return data.slice(n);
1636
+ }
1637
+ else {
1638
+ return data.slice(n, groupStartIndexes[i + 1]);
1639
+ }
1640
+ });
1641
+ });
1642
+ agg[label.trim()] = groups;
1643
+ return agg;
1644
+ }, {});
1645
+ return data_groups;
1646
+ });
1609
1647
  this.visible_id_order.addBoundProperty(this.ids_after_a_gap);
1610
1648
  this.precomputed_comparator.addBoundProperty(this.ids_after_a_gap);
1611
1649
  this.column_indexes_after_a_gap = new CachedProperty([], function (model) {
@@ -2185,7 +2223,12 @@ var OncoprintModel = /** @class */ (function () {
2185
2223
  configurable: true,
2186
2224
  writable: true,
2187
2225
  value: function () {
2188
- return this.getCellWidth(true);
2226
+ if (this.showGaps()) {
2227
+ return 50; // this creates enough space for 3 digit percentage
2228
+ }
2229
+ else {
2230
+ return this.getCellWidth(true);
2231
+ }
2189
2232
  }
2190
2233
  });
2191
2234
  Object.defineProperty(OncoprintModel.prototype, "getCellWidth", {
@@ -3011,7 +3054,18 @@ var OncoprintModel = /** @class */ (function () {
3011
3054
  var lastIdLeft = base
3012
3055
  ? this.getColumnLeft(lastId)
3013
3056
  : this.getZoomedColumnLeft(lastId);
3014
- return lastIdLeft + this.getCellWidth(base) + 1; // this fixes some edge case issues with scrolling
3057
+ // when gaps are showing, we need to add space at the end of the
3058
+ // oncoprint to accomodate the label
3059
+ var lastGap = this.showGaps() ? this.getGapSize() : 0;
3060
+ return lastIdLeft + this.getCellWidth(base) + lastGap + 1; // this fixes some edge case issues with scrolling
3061
+ }
3062
+ });
3063
+ Object.defineProperty(OncoprintModel.prototype, "showGaps", {
3064
+ enumerable: false,
3065
+ configurable: true,
3066
+ writable: true,
3067
+ value: function () {
3068
+ return _.some(this.track_show_gaps);
3015
3069
  }
3016
3070
  });
3017
3071
  Object.defineProperty(OncoprintModel.prototype, "getOncoprintWidthNoColumnPaddingNoGaps", {
@@ -3330,6 +3384,29 @@ var OncoprintModel = /** @class */ (function () {
3330
3384
  this.track_custom_options[track_id] = options;
3331
3385
  }
3332
3386
  });
3387
+ // get the pixel offset (from the grid origin) for the gaps based
3388
+ Object.defineProperty(OncoprintModel.prototype, "getGapOffsets", {
3389
+ enumerable: false,
3390
+ configurable: true,
3391
+ writable: true,
3392
+ value: function () {
3393
+ var _this = this;
3394
+ var offsets = _(this.ids_after_a_gap.get())
3395
+ .keys()
3396
+ .map(function (num) { return _this.getZoomedColumnLeft(num); })
3397
+ .sort(function (a, b) { return a - b; })
3398
+ .value();
3399
+ // we only want to include this if gaps are on
3400
+ if (this.showGaps) {
3401
+ var last = this.getZoomedColumnLeft(this.id_order[this.id_order.length - 1]) +
3402
+ this.getGapSize() +
3403
+ this.cell_width +
3404
+ this.cell_padding;
3405
+ offsets.push(last);
3406
+ }
3407
+ return offsets;
3408
+ }
3409
+ });
3333
3410
  Object.defineProperty(OncoprintModel.prototype, "setTrackInfoTooltip", {
3334
3411
  enumerable: false,
3335
3412
  configurable: true,
@@ -4428,7 +4505,7 @@ var COLUMN_LABEL_ANGLE = 65;
4428
4505
  var COLUMN_LABEL_MARGIN = 30;
4429
4506
  var CELL_HIGHLIGHT_STROKE = 'rgba(0,0,0,0.5)';
4430
4507
  var OncoprintWebGLCellView = /** @class */ (function () {
4431
- function OncoprintWebGLCellView($container, $canvas, $overlay_canvas, $column_label_canvas, $dummy_scroll_div_contents, model, tooltip, highlight_area_callback, cell_over_callback, cell_click_callback) {
4508
+ function OncoprintWebGLCellView($container, $canvas, $overlay_canvas, $gap_canvas, $column_label_canvas, $dummy_scroll_div_contents, model, tooltip, highlight_area_callback, cell_over_callback, cell_click_callback) {
4432
4509
  Object.defineProperty(this, "$container", {
4433
4510
  enumerable: true,
4434
4511
  configurable: true,
@@ -4447,6 +4524,12 @@ var OncoprintWebGLCellView = /** @class */ (function () {
4447
4524
  writable: true,
4448
4525
  value: $overlay_canvas
4449
4526
  });
4527
+ Object.defineProperty(this, "$gap_canvas", {
4528
+ enumerable: true,
4529
+ configurable: true,
4530
+ writable: true,
4531
+ value: $gap_canvas
4532
+ });
4450
4533
  Object.defineProperty(this, "$column_label_canvas", {
4451
4534
  enumerable: true,
4452
4535
  configurable: true,
@@ -4519,6 +4602,12 @@ var OncoprintWebGLCellView = /** @class */ (function () {
4519
4602
  writable: true,
4520
4603
  value: void 0
4521
4604
  });
4605
+ Object.defineProperty(this, "gap_ctx", {
4606
+ enumerable: true,
4607
+ configurable: true,
4608
+ writable: true,
4609
+ value: void 0
4610
+ });
4522
4611
  Object.defineProperty(this, "ext", {
4523
4612
  enumerable: true,
4524
4613
  configurable: true,
@@ -4651,6 +4740,18 @@ var OncoprintWebGLCellView = /** @class */ (function () {
4651
4740
  writable: true,
4652
4741
  value: {}
4653
4742
  }); // index of first vertex corresponding to given id for given track, e.g. 0, 3, 6, ...
4743
+ Object.defineProperty(this, "gapTooltipTargets", {
4744
+ enumerable: true,
4745
+ configurable: true,
4746
+ writable: true,
4747
+ value: []
4748
+ });
4749
+ Object.defineProperty(this, "hoveredGap", {
4750
+ enumerable: true,
4751
+ configurable: true,
4752
+ writable: true,
4753
+ value: void 0
4754
+ });
4654
4755
  this.getWebGLContextAndSetUpMatrices();
4655
4756
  this.setUpShaders(model);
4656
4757
  this.getOverlayContextAndClear();
@@ -4757,9 +4858,28 @@ var OncoprintWebGLCellView = /** @class */ (function () {
4757
4858
  self.scroll_y, model.getTrackTooltipFn(overlapping_cells.track)(overlapping_data));
4758
4859
  }
4759
4860
  else {
4760
- tooltip.hideIfNotAlreadyGoingTo(150);
4761
4861
  overlapping_cells = null;
4762
4862
  }
4863
+ // find a gap which is in range of mouse position
4864
+ var overlappingGap = self.gapTooltipTargets.find(function (t) {
4865
+ return (_.inRange(mouseX - t.origin_x, 0, 20) &&
4866
+ _.inRange(t.origin_y - mouseY, -10, 15));
4867
+ });
4868
+ // if there is no gap, turn
4869
+ if (overlappingGap === undefined) {
4870
+ self.hoveredGap = undefined;
4871
+ }
4872
+ else if (self.hoveredGap === overlappingGap) ;
4873
+ else {
4874
+ // we have a new hovered gap, so show a tooltip
4875
+ var clientRect = self.$overlay_canvas[0].getBoundingClientRect();
4876
+ self.hoveredGap = overlappingGap;
4877
+ tooltip.center = false;
4878
+ tooltip.show(250, clientRect.left + overlappingGap.origin_x, clientRect.top + overlappingGap.origin_y - 20, $$1("<span>" + overlappingGap.data.tooltipFormatter() + "</span>"), false);
4879
+ }
4880
+ if (!overlapping_data && !overlappingGap) {
4881
+ tooltip.hideIfNotAlreadyGoingTo(150);
4882
+ }
4763
4883
  }
4764
4884
  else {
4765
4885
  overlapping_cells = null;
@@ -4803,6 +4923,22 @@ var OncoprintWebGLCellView = /** @class */ (function () {
4803
4923
  self.highlightHighlightedTracks(model);
4804
4924
  });
4805
4925
  }
4926
+ Object.defineProperty(OncoprintWebGLCellView.prototype, "drawGapLabel", {
4927
+ enumerable: false,
4928
+ configurable: true,
4929
+ writable: true,
4930
+ value: function (txt, x, y) {
4931
+ this.gap_ctx.font = '15pt Arial';
4932
+ this.gap_ctx.textAlign = 'right';
4933
+ var origin_x = x * this.supersampling_ratio + 52;
4934
+ var origin_y = y * this.supersampling_ratio + 4;
4935
+ this.gap_ctx.fillText(txt, origin_x, origin_y);
4936
+ return {
4937
+ origin_x: x,
4938
+ origin_y: y,
4939
+ };
4940
+ }
4941
+ });
4806
4942
  Object.defineProperty(OncoprintWebGLCellView.prototype, "getNewCanvas", {
4807
4943
  enumerable: false,
4808
4944
  configurable: true,
@@ -4818,6 +4954,19 @@ var OncoprintWebGLCellView = /** @class */ (function () {
4818
4954
  this.ext = null;
4819
4955
  }
4820
4956
  });
4957
+ Object.defineProperty(OncoprintWebGLCellView.prototype, "getGapContext", {
4958
+ enumerable: false,
4959
+ configurable: true,
4960
+ writable: true,
4961
+ value: function () {
4962
+ try {
4963
+ return this.$gap_canvas[0].getContext('2d');
4964
+ }
4965
+ catch (e) {
4966
+ return null;
4967
+ }
4968
+ }
4969
+ });
4821
4970
  Object.defineProperty(OncoprintWebGLCellView.prototype, "getWebGLCanvasContext", {
4822
4971
  enumerable: false,
4823
4972
  configurable: true,
@@ -4981,6 +5130,7 @@ var OncoprintWebGLCellView = /** @class */ (function () {
4981
5130
  configurable: true,
4982
5131
  writable: true,
4983
5132
  value: function () {
5133
+ this.gap_ctx = this.getGapContext();
4984
5134
  this.ctx = this.getWebGLCanvasContext();
4985
5135
  if (this.ctx) {
4986
5136
  this.ext = this.ctx.getExtension('ANGLE_instanced_arrays');
@@ -5059,6 +5209,11 @@ var OncoprintWebGLCellView = /** @class */ (function () {
5059
5209
  this.dummy_scroll_div_client_size.update();
5060
5210
  this.$canvas[0].height = this.supersampling_ratio * height;
5061
5211
  this.$canvas[0].style.height = height + 'px';
5212
+ this.$gap_canvas[0].height = this.supersampling_ratio * height;
5213
+ this.$gap_canvas[0].style.height = height + 'px';
5214
+ this.$gap_canvas[0].width =
5215
+ this.supersampling_ratio * visible_area_width;
5216
+ this.$gap_canvas[0].style.width = visible_area_width + 'px';
5062
5217
  this.$overlay_canvas[0].height = this.supersampling_ratio * height;
5063
5218
  this.$overlay_canvas[0].style.height = height + 'px';
5064
5219
  this.$column_label_canvas[0].height = this.supersampling_ratio * height;
@@ -5084,6 +5239,7 @@ var OncoprintWebGLCellView = /** @class */ (function () {
5084
5239
  configurable: true,
5085
5240
  writable: true,
5086
5241
  value: function (model, dont_resize) {
5242
+ var _this = this;
5087
5243
  if (this.rendering_suppressed) {
5088
5244
  return;
5089
5245
  }
@@ -5113,75 +5269,98 @@ var OncoprintWebGLCellView = /** @class */ (function () {
5113
5269
  }
5114
5270
  this.ctx.clearColor(1.0, 1.0, 1.0, 1.0);
5115
5271
  this.ctx.clear(this.ctx.COLOR_BUFFER_BIT | this.ctx.DEPTH_BUFFER_BIT);
5272
+ this.gap_ctx.clearRect(0, 0, this.$gap_canvas[0].width, this.$gap_canvas[0].height);
5273
+ var gapOffsets = model.getGapOffsets();
5116
5274
  var tracks = model.getTracks();
5117
- for (var i = 0; i < tracks.length; i++) {
5275
+ this.gapTooltipTargets = [];
5276
+ var _loop_1 = function (i) {
5118
5277
  var track_id = tracks[i];
5119
5278
  var cell_top = model.getCellTops(track_id);
5120
5279
  var cell_height = model.getCellHeight(track_id);
5280
+ if (model.showGaps()) {
5281
+ var gaps = this_1.getGaps(model, track_id);
5282
+ if (gaps) {
5283
+ gaps.forEach(function (gap, i) {
5284
+ var x = gapOffsets[i] - scroll_x - model.getGapSize();
5285
+ var y = model.getZoomedTrackTops()[track_id] +
5286
+ cell_height -
5287
+ scroll_y;
5288
+ _this.drawGapLabel(gap.labelFormatter(), x, y);
5289
+ _this.gapTooltipTargets.push({
5290
+ origin_x: x,
5291
+ origin_y: y,
5292
+ data: gap,
5293
+ });
5294
+ });
5295
+ }
5296
+ }
5121
5297
  if (cell_top / zoom_y >= window_bottom ||
5122
5298
  (cell_top + cell_height) / zoom_y < window_top) {
5123
- // vertical clipping
5124
- continue;
5299
+ return "continue";
5125
5300
  }
5126
- var buffers = this.getTrackBuffers(track_id);
5301
+ var buffers = this_1.getTrackBuffers(track_id);
5127
5302
  if (buffers.position.numItems === 0) {
5128
- continue;
5303
+ return "continue";
5129
5304
  }
5130
5305
  for (var _i = 0, _a = [false, true]; _i < _a.length; _i++) {
5131
5306
  var forSpecificShapes = _a[_i];
5132
- var shader_program = this.shader_program;
5133
- this.ctx.useProgram(shader_program);
5307
+ var shader_program = this_1.shader_program;
5308
+ this_1.ctx.useProgram(shader_program);
5134
5309
  if (forSpecificShapes) {
5135
- this.ctx.bindBuffer(this.ctx.ARRAY_BUFFER, buffers.position);
5136
- this.ctx.vertexAttribPointer(shader_program.vertexPositionAttribute, buffers.position.itemSize, this.ctx.FLOAT, false, 0, 0);
5137
- this.ctx.bindBuffer(this.ctx.ARRAY_BUFFER, buffers.color);
5138
- this.ctx.vertexAttribPointer(shader_program.vertexColorAttribute, buffers.color.itemSize, this.ctx.FLOAT, false, 0, 0);
5139
- this.ctx.bindBuffer(this.ctx.ARRAY_BUFFER, buffers.column);
5140
- this.ctx.vertexAttribPointer(shader_program.vertexOncoprintColumnAttribute, buffers.column.itemSize, this.ctx.FLOAT, false, 0, 0);
5310
+ this_1.ctx.bindBuffer(this_1.ctx.ARRAY_BUFFER, buffers.position);
5311
+ this_1.ctx.vertexAttribPointer(shader_program.vertexPositionAttribute, buffers.position.itemSize, this_1.ctx.FLOAT, false, 0, 0);
5312
+ this_1.ctx.bindBuffer(this_1.ctx.ARRAY_BUFFER, buffers.color);
5313
+ this_1.ctx.vertexAttribPointer(shader_program.vertexColorAttribute, buffers.color.itemSize, this_1.ctx.FLOAT, false, 0, 0);
5314
+ this_1.ctx.bindBuffer(this_1.ctx.ARRAY_BUFFER, buffers.column);
5315
+ this_1.ctx.vertexAttribPointer(shader_program.vertexOncoprintColumnAttribute, buffers.column.itemSize, this_1.ctx.FLOAT, false, 0, 0);
5141
5316
  // make sure to set divisor 0, otherwise the track will only use the first item in the column buffer
5142
- this.ext.vertexAttribDivisorANGLE(shader_program.vertexOncoprintColumnAttribute, 0);
5317
+ this_1.ext.vertexAttribDivisorANGLE(shader_program.vertexOncoprintColumnAttribute, 0);
5143
5318
  }
5144
5319
  else {
5145
5320
  // set up for drawArraysInstanced
5146
5321
  var universalShapesStart = buffers.position.specificShapesNumItems *
5147
5322
  buffers.position.itemSize;
5148
- this.ctx.bindBuffer(this.ctx.ARRAY_BUFFER, buffers.position);
5149
- this.ctx.vertexAttribPointer(shader_program.vertexPositionAttribute, buffers.position.itemSize, this.ctx.FLOAT, false, 0, 4 * universalShapesStart);
5150
- this.ctx.bindBuffer(this.ctx.ARRAY_BUFFER, buffers.color);
5151
- this.ctx.vertexAttribPointer(shader_program.vertexColorAttribute, buffers.color.itemSize, this.ctx.FLOAT, false, 0, 4 * universalShapesStart);
5152
- this.ctx.bindBuffer(this.ctx.ARRAY_BUFFER, this.simple_count_buffer);
5153
- this.ctx.vertexAttribPointer(shader_program.vertexOncoprintColumnAttribute, 1, this.ctx.FLOAT, false, 0, 4 * horz_first_id_in_window_index);
5154
- this.ext.vertexAttribDivisorANGLE(shader_program.vertexOncoprintColumnAttribute, 1);
5323
+ this_1.ctx.bindBuffer(this_1.ctx.ARRAY_BUFFER, buffers.position);
5324
+ this_1.ctx.vertexAttribPointer(shader_program.vertexPositionAttribute, buffers.position.itemSize, this_1.ctx.FLOAT, false, 0, 4 * universalShapesStart);
5325
+ this_1.ctx.bindBuffer(this_1.ctx.ARRAY_BUFFER, buffers.color);
5326
+ this_1.ctx.vertexAttribPointer(shader_program.vertexColorAttribute, buffers.color.itemSize, this_1.ctx.FLOAT, false, 0, 4 * universalShapesStart);
5327
+ this_1.ctx.bindBuffer(this_1.ctx.ARRAY_BUFFER, this_1.simple_count_buffer);
5328
+ this_1.ctx.vertexAttribPointer(shader_program.vertexOncoprintColumnAttribute, 1, this_1.ctx.FLOAT, false, 0, 4 * horz_first_id_in_window_index);
5329
+ this_1.ext.vertexAttribDivisorANGLE(shader_program.vertexOncoprintColumnAttribute, 1);
5155
5330
  }
5156
- this.ctx.activeTexture(this.ctx.TEXTURE0);
5157
- this.ctx.bindTexture(this.ctx.TEXTURE_2D, buffers.color_tex.texture);
5158
- this.ctx.uniform1i(shader_program.samplerUniform, 0);
5159
- this.ctx.uniform1f(shader_program.texSizeUniform, buffers.color_tex.size);
5160
- this.ctx.uniform1fv(shader_program.columnsRightAfterGapsUniform, this.getColumnIndexesAfterAGap(model)); // need min size of 1
5161
- this.ctx.uniform1f(shader_program.gapSizeUniform, model.getGapSize());
5162
- this.ctx.uniformMatrix4fv(shader_program.pMatrixUniform, false, this.pMatrix);
5163
- this.ctx.uniformMatrix4fv(shader_program.mvMatrixUniform, false, this.mvMatrix);
5164
- this.ctx.uniform1f(shader_program.columnWidthUniform, model.getCellWidth(true) + model.getCellPadding(true));
5165
- this.ctx.uniform1f(shader_program.scrollXUniform, scroll_x);
5166
- this.ctx.uniform1f(shader_program.scrollYUniform, scroll_y);
5167
- this.ctx.uniform1f(shader_program.zoomXUniform, zoom_x);
5168
- this.ctx.uniform1f(shader_program.zoomYUniform, zoom_y);
5169
- this.ctx.uniform1f(shader_program.offsetYUniform, cell_top);
5170
- this.ctx.uniform1f(shader_program.supersamplingRatioUniform, this.supersampling_ratio);
5171
- this.ctx.uniform1f(shader_program.positionBitPackBaseUniform, this.position_bit_pack_base);
5331
+ this_1.ctx.activeTexture(this_1.ctx.TEXTURE0);
5332
+ this_1.ctx.bindTexture(this_1.ctx.TEXTURE_2D, buffers.color_tex.texture);
5333
+ this_1.ctx.uniform1i(shader_program.samplerUniform, 0);
5334
+ this_1.ctx.uniform1f(shader_program.texSizeUniform, buffers.color_tex.size);
5335
+ this_1.ctx.uniform1fv(shader_program.columnsRightAfterGapsUniform, this_1.getColumnIndexesAfterAGap(model)); // need min size of 1
5336
+ this_1.ctx.uniform1f(shader_program.gapSizeUniform, model.getGapSize());
5337
+ this_1.ctx.uniformMatrix4fv(shader_program.pMatrixUniform, false, this_1.pMatrix);
5338
+ this_1.ctx.uniformMatrix4fv(shader_program.mvMatrixUniform, false, this_1.mvMatrix);
5339
+ this_1.ctx.uniform1f(shader_program.columnWidthUniform, model.getCellWidth(true) + model.getCellPadding(true));
5340
+ this_1.ctx.uniform1f(shader_program.scrollXUniform, scroll_x);
5341
+ this_1.ctx.uniform1f(shader_program.scrollYUniform, scroll_y);
5342
+ this_1.ctx.uniform1f(shader_program.zoomXUniform, zoom_x);
5343
+ this_1.ctx.uniform1f(shader_program.zoomYUniform, zoom_y);
5344
+ this_1.ctx.uniform1f(shader_program.offsetYUniform, cell_top);
5345
+ this_1.ctx.uniform1f(shader_program.supersamplingRatioUniform, this_1.supersampling_ratio);
5346
+ this_1.ctx.uniform1f(shader_program.positionBitPackBaseUniform, this_1.position_bit_pack_base);
5172
5347
  if (forSpecificShapes) {
5173
- var first_index = this.id_to_first_vertex_index[track_id][horz_first_id_in_window];
5348
+ var first_index = this_1.id_to_first_vertex_index[track_id][horz_first_id_in_window];
5174
5349
  var first_index_out = horz_first_id_after_window === null
5175
5350
  ? buffers.position.specificShapesNumItems
5176
- : this.id_to_first_vertex_index[track_id][horz_first_id_after_window];
5177
- this.ctx.drawArrays(this.ctx.TRIANGLES, first_index, first_index_out - first_index);
5351
+ : this_1.id_to_first_vertex_index[track_id][horz_first_id_after_window];
5352
+ this_1.ctx.drawArrays(this_1.ctx.TRIANGLES, first_index, first_index_out - first_index);
5178
5353
  }
5179
5354
  else {
5180
- this.ext.drawArraysInstancedANGLE(this.ctx.TRIANGLES, 0, buffers.position.itemSize *
5355
+ this_1.ext.drawArraysInstancedANGLE(this_1.ctx.TRIANGLES, 0, buffers.position.itemSize *
5181
5356
  buffers.position.universalShapesNumItems, horz_first_id_after_window_index -
5182
5357
  horz_first_id_in_window_index);
5183
5358
  }
5184
5359
  }
5360
+ };
5361
+ var this_1 = this;
5362
+ for (var i = 0; i < tracks.length; i++) {
5363
+ _loop_1(i);
5185
5364
  }
5186
5365
  this.ctx.flush();
5187
5366
  this.renderColumnLabels(model, id_order.slice(horz_first_id_in_window_index, horz_first_id_after_window_index === -1
@@ -6190,21 +6369,57 @@ var OncoprintWebGLCellView = /** @class */ (function () {
6190
6369
  return this.dummy_scroll_div_client_size.get();
6191
6370
  }
6192
6371
  });
6372
+ Object.defineProperty(OncoprintWebGLCellView.prototype, "getGaps", {
6373
+ enumerable: false,
6374
+ configurable: true,
6375
+ writable: true,
6376
+ value: function (model, track_id) {
6377
+ var _a;
6378
+ var custom = model.getTrackCustomOptions(track_id);
6379
+ return _.isEmpty(model.ids_after_a_gap.get())
6380
+ ? undefined
6381
+ : (_a = custom.find(function (t) { return !!t.gapLabelsFn; })) === null || _a === void 0 ? void 0 : _a.gapLabelsFn(model);
6382
+ }
6383
+ });
6193
6384
  Object.defineProperty(OncoprintWebGLCellView.prototype, "toSVGGroup", {
6194
6385
  enumerable: false,
6195
6386
  configurable: true,
6196
6387
  writable: true,
6197
6388
  value: function (model, offset_x, offset_y) {
6389
+ var _a;
6198
6390
  var root = svgfactory.group(offset_x || 0, offset_y || 0);
6199
6391
  var cell_tops = model.getCellTops();
6200
6392
  var tracks = model.getTracks();
6201
6393
  var zoomedColumnLeft = model.getZoomedColumnLeft();
6202
6394
  // add cell shapes
6203
- for (var i = 0; i < tracks.length; i++) {
6395
+ var gapOffsets = model.getGapOffsets();
6396
+ var _loop_2 = function (i) {
6204
6397
  var track_id = tracks[i];
6205
6398
  var offset_y_1 = cell_tops[track_id];
6399
+ var cell_height = model.getCellHeight(track_id);
6206
6400
  var universal_shapes = model.getTrackUniversalShapes(track_id, false);
6207
6401
  var identified_shape_list_list = model.getSpecificShapesForData(track_id, false);
6402
+ var custom = model.getTrackCustomOptions(track_id);
6403
+ if (gapOffsets[0]) {
6404
+ var gaps = _.isEmpty(model.ids_after_a_gap.get())
6405
+ ? undefined
6406
+ : (_a = custom.find(function (t) { return !!t.gapLabelsFn; })) === null || _a === void 0 ? void 0 : _a.gapLabelsFn(model);
6407
+ if (gaps) {
6408
+ gaps.forEach(function (gap, i) {
6409
+ var textElt = makesvgelement('text', {
6410
+ x: gapOffsets[i] - model.getGapSize() + 25,
6411
+ y: offset_y_1 + cell_height - 3,
6412
+ 'font-size': '10',
6413
+ 'font-family': 'Arial',
6414
+ 'font-weight': 'normal',
6415
+ 'text-anchor': 'end',
6416
+ 'alignment-baseline': 'top',
6417
+ });
6418
+ textElt.textContent = gap.labelFormatter();
6419
+ root.appendChild(textElt);
6420
+ });
6421
+ }
6422
+ }
6208
6423
  for (var j = 0; j < identified_shape_list_list.length; j++) {
6209
6424
  var id_sl = identified_shape_list_list[j];
6210
6425
  var id = id_sl.id;
@@ -6223,6 +6438,9 @@ var OncoprintWebGLCellView = /** @class */ (function () {
6223
6438
  root.appendChild(svgfactory.fromShape(sl[h], offset_x_1, offset_y_1));
6224
6439
  }
6225
6440
  }
6441
+ };
6442
+ for (var i = 0; i < tracks.length; i++) {
6443
+ _loop_2(i);
6226
6444
  }
6227
6445
  // add column labels
6228
6446
  var labels = model.getColumnLabels();
@@ -9710,20 +9928,24 @@ var OncoprintTrackOptionsView = /** @class */ (function () {
9710
9928
  .addClass(SEPARATOR_CLASS);
9711
9929
  }
9712
9930
  });
9931
+ // 11/2/2023 we are removing sort arrow
9932
+ // leaving commented out if it needs to be restored based on complaint
9713
9933
  Object.defineProperty(OncoprintTrackOptionsView, "renderSortArrow", {
9714
9934
  enumerable: false,
9715
9935
  configurable: true,
9716
9936
  writable: true,
9717
9937
  value: function ($sortarrow, model, track_id) {
9718
- var sortarrow_char = '';
9719
- if (model.isTrackSortDirectionChangeable(track_id)) {
9720
- sortarrow_char = {
9721
- '1': '<i class="fa fa-signal" aria-hidden="true" title="Sorted ascending"></i>',
9722
- '-1': '<i class="fa fa-signal" style="transform: scaleX(-1);" aria-hidden="true" title="Sorted descending"></i>',
9723
- '0': '',
9724
- }[model.getTrackSortDirection(track_id)];
9725
- }
9726
- $sortarrow.html(sortarrow_char);
9938
+ // let sortarrow_char = '';
9939
+ // if (model.isTrackSortDirectionChangeable(track_id)) {
9940
+ // sortarrow_char = {
9941
+ // '1':
9942
+ // '<i class="fa fa-signal" aria-hidden="true" title="Sorted ascending"></i>',
9943
+ // '-1':
9944
+ // '<i class="fa fa-signal" style="transform: scaleX(-1);" aria-hidden="true" title="Sorted descending"></i>',
9945
+ // '0': '',
9946
+ // }[model.getTrackSortDirection(track_id)];
9947
+ // }
9948
+ // $sortarrow.html(sortarrow_char);
9727
9949
  }
9728
9950
  });
9729
9951
  Object.defineProperty(OncoprintTrackOptionsView.prototype, "renderTrackOptions", {
@@ -10817,7 +11039,7 @@ var OncoprintTrackInfoView = /** @class */ (function () {
10817
11039
  })
10818
11040
  .appendTo(this.$div);
10819
11041
  this.$text_ctr = $$1('<div></div>')
10820
- .css({ position: 'absolute' })
11042
+ .css({ position: 'absolute', overflow: 'visible', width: '100%' })
10821
11043
  .appendTo(this.$ctr);
10822
11044
  }
10823
11045
  Object.defineProperty(OncoprintTrackInfoView.prototype, "destroyLabelElts", {
@@ -10853,6 +11075,7 @@ var OncoprintTrackInfoView = /** @class */ (function () {
10853
11075
  var self = this;
10854
11076
  var _loop_1 = function (j) {
10855
11077
  (function () {
11078
+ var _a, _b;
10856
11079
  var i = j;
10857
11080
  var $new_label = $$1('<span>')
10858
11081
  .css({
@@ -10860,13 +11083,29 @@ var OncoprintTrackInfoView = /** @class */ (function () {
10860
11083
  'font-family': self.font_family,
10861
11084
  'font-weight': self.font_weight,
10862
11085
  'font-size': font_size,
11086
+ right: '11px',
10863
11087
  })
10864
11088
  .addClass('noselect');
10865
11089
  var text = model.getTrackInfo(tracks[i]);
10866
11090
  if (!text) {
10867
11091
  return;
10868
11092
  }
10869
- $new_label.text(text);
11093
+ var num = (_a = text.match(/^[\d\.]*/)) === null || _a === void 0 ? void 0 : _a[0];
11094
+ var suffix = (_b = text.match(/[^\d]*$/)) === null || _b === void 0 ? void 0 : _b[0];
11095
+ var float = parseFloat(num);
11096
+ var formattedPercent = '';
11097
+ if (isNaN(float)) {
11098
+ formattedPercent = 'N/P';
11099
+ suffix = ''; // we don't want any suffix in this case
11100
+ }
11101
+ else if (isNumber(float)) {
11102
+ formattedPercent =
11103
+ float < 1 && float > 0
11104
+ ? '<1'
11105
+ : Math.round(float).toString();
11106
+ }
11107
+ else ;
11108
+ $new_label.text(formattedPercent + suffix);
10870
11109
  $new_label.appendTo(self.$text_ctr);
10871
11110
  self.$label_elts.push($new_label);
10872
11111
  setTimeout(function () {
@@ -13106,6 +13345,10 @@ var Oncoprint = /** @class */ (function () {
13106
13345
  .attr({ width: '0px', height: '0px' })
13107
13346
  .css({ position: 'absolute', top: '0px', left: '0px' })
13108
13347
  .addClass('noselect');
13348
+ var $gap_canvas = $$1('<canvas></canvas>')
13349
+ .attr({ width: '0px', height: '0px' })
13350
+ .css({ position: 'absolute', top: '0px', left: '0px' })
13351
+ .addClass('noselect gap_canvas');
13109
13352
  var $dummy_scroll_div = $$1('<div>')
13110
13353
  .css({
13111
13354
  position: 'absolute',
@@ -13168,6 +13411,7 @@ var Oncoprint = /** @class */ (function () {
13168
13411
  $legend_div.appendTo($legend_ctr);
13169
13412
  $minimap_div.appendTo($ctr);
13170
13413
  $cell_canvas.appendTo($cell_div);
13414
+ $gap_canvas.appendTo($cell_div);
13171
13415
  $cell_overlay_canvas.appendTo($cell_div);
13172
13416
  $column_label_canvas.appendTo($cell_div); // column labels should show above the overlay canvas because the text should show over the highlights
13173
13417
  $dummy_scroll_div.appendTo($cell_div);
@@ -13189,7 +13433,7 @@ var Oncoprint = /** @class */ (function () {
13189
13433
  this.$cell_overlay_canvas = $cell_overlay_canvas;
13190
13434
  this.model = new OncoprintModel(params);
13191
13435
  this.header_view = new OncoprintHeaderView(this.$header_div);
13192
- this.cell_view = new OncoprintWebGLCellView($cell_div, $cell_canvas, $cell_overlay_canvas, $column_label_canvas, $dummy_scroll_div_contents, this.model, new OncoprintToolTip($tooltip_ctr), function (left, right) {
13436
+ this.cell_view = new OncoprintWebGLCellView($cell_div, $cell_canvas, $cell_overlay_canvas, $gap_canvas, $column_label_canvas, $dummy_scroll_div_contents, this.model, new OncoprintToolTip($tooltip_ctr), function (left, right) {
13193
13437
  var enclosed_ids = self.model.getIdsInZoomedLeftInterval(left, right);
13194
13438
  self.setHorzZoom(self.model.getHorzZoomToFit(self.cell_view.getVisibleAreaWidth(), enclosed_ids));
13195
13439
  self.$dummy_scroll_div.scrollLeft(self.model.getZoomedColumnLeft(enclosed_ids[0]));
@@ -14743,5 +14987,5 @@ var Oncoprint = /** @class */ (function () {
14743
14987
  return Oncoprint;
14744
14988
  }());
14745
14989
 
14746
- export { GeneticAlterationRuleSet, LinearInterpRangeType, Oncoprint as OncoprintJS, Rule, RuleSet, RuleSetType, shapeToSVG as shapeToSvg };
14990
+ export { GeneticAlterationRuleSet, LinearInterpRangeType, Oncoprint as OncoprintJS, OncoprintModel, Rule, RuleSet, RuleSetType, shapeToSVG as shapeToSvg };
14747
14991
  //# sourceMappingURL=index.es.js.map