oncoprintjs 6.0.4 → 6.0.6

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,5 +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
+ export { default as OncoprintModel, GAP_MODE_ENUM } from './js/oncoprintmodel';
4
4
  export * from './js/oncoprintmodel';
5
5
  export { default as shapeToSvg } from './js/oncoprintshapetosvg';
package/dist/index.es.js CHANGED
@@ -793,6 +793,12 @@ function calculateTrackAndHeaderTops(model, zoomed) {
793
793
  }
794
794
 
795
795
  /* jshint browserify: true, asi: true */
796
+ var GAP_MODE_ENUM;
797
+ (function (GAP_MODE_ENUM) {
798
+ GAP_MODE_ENUM["SHOW_GAPS"] = "SHOW_GAPS";
799
+ GAP_MODE_ENUM["SHOW_GAPS_PERCENT"] = "SHOW_GAPS_PERCENT";
800
+ GAP_MODE_ENUM["HIDE_GAPS"] = "HIDE_GAPS";
801
+ })(GAP_MODE_ENUM || (GAP_MODE_ENUM = {}));
796
802
  var UnionOfSets = /** @class */ (function () {
797
803
  function UnionOfSets() {
798
804
  // a set, to be passed in as argument, is an object where the values are truthy
@@ -1598,7 +1604,10 @@ var OncoprintModel = /** @class */ (function () {
1598
1604
  var precomputedComparator = model.precomputed_comparator.get();
1599
1605
  var trackIdsWithGaps = model
1600
1606
  .getTracks()
1601
- .filter(function (trackId) { return model.getTrackShowGaps(trackId); });
1607
+ .filter(function (trackId) {
1608
+ return model.getTrackShowGaps(trackId) !==
1609
+ GAP_MODE_ENUM.HIDE_GAPS;
1610
+ });
1602
1611
  var ids = model.visible_id_order.get();
1603
1612
  for (var i = 1; i < ids.length; i++) {
1604
1613
  for (var _i = 0, trackIdsWithGaps_1 = trackIdsWithGaps; _i < trackIdsWithGaps_1.length; _i++) {
@@ -2224,7 +2233,14 @@ var OncoprintModel = /** @class */ (function () {
2224
2233
  writable: true,
2225
2234
  value: function () {
2226
2235
  if (this.showGaps()) {
2227
- return 50; // this creates enough space for 3 digit percentage
2236
+ switch (this.gapMode()) {
2237
+ case GAP_MODE_ENUM.SHOW_GAPS:
2238
+ return this.getCellWidth(true);
2239
+ case GAP_MODE_ENUM.SHOW_GAPS_PERCENT:
2240
+ return 50;
2241
+ default:
2242
+ return 50;
2243
+ }
2228
2244
  }
2229
2245
  else {
2230
2246
  return this.getCellWidth(true);
@@ -2590,7 +2606,9 @@ var OncoprintModel = /** @class */ (function () {
2590
2606
  this.track_sort_direction[track_id] = ifndef(params.init_sort_direction, 1);
2591
2607
  this.track_can_show_gaps[track_id] = ifndef(params.track_can_show_gaps, false);
2592
2608
  var trackShowGaps = ifndef(params.show_gaps_on_init, false);
2593
- this.track_show_gaps[track_id] = trackShowGaps;
2609
+ this.track_show_gaps[track_id] = trackShowGaps
2610
+ ? GAP_MODE_ENUM.SHOW_GAPS_PERCENT
2611
+ : GAP_MODE_ENUM.HIDE_GAPS;
2594
2612
  var trackNotSorted = this.track_sort_direction[track_id] === 0;
2595
2613
  if (trackShowGaps && trackNotSorted) {
2596
2614
  this.track_sort_direction[track_id] = 1;
@@ -3065,7 +3083,20 @@ var OncoprintModel = /** @class */ (function () {
3065
3083
  configurable: true,
3066
3084
  writable: true,
3067
3085
  value: function () {
3068
- return _.some(this.track_show_gaps);
3086
+ return _(this.track_show_gaps)
3087
+ .values()
3088
+ .some(function (t) { return t !== GAP_MODE_ENUM.HIDE_GAPS; });
3089
+ }
3090
+ });
3091
+ Object.defineProperty(OncoprintModel.prototype, "gapMode", {
3092
+ enumerable: false,
3093
+ configurable: true,
3094
+ writable: true,
3095
+ value: function () {
3096
+ var mode = _(this.track_show_gaps)
3097
+ .values()
3098
+ .find(function (g) { return g !== GAP_MODE_ENUM.HIDE_GAPS; });
3099
+ return mode || GAP_MODE_ENUM.HIDE_GAPS;
3069
3100
  }
3070
3101
  });
3071
3102
  Object.defineProperty(OncoprintModel.prototype, "getOncoprintWidthNoColumnPaddingNoGaps", {
@@ -5277,14 +5308,16 @@ var OncoprintWebGLCellView = /** @class */ (function () {
5277
5308
  var track_id = tracks[i];
5278
5309
  var cell_top = model.getCellTops(track_id);
5279
5310
  var cell_height = model.getCellHeight(track_id);
5280
- if (model.showGaps()) {
5311
+ if (model.showGaps() &&
5312
+ model.gapMode() === GAP_MODE_ENUM.SHOW_GAPS_PERCENT) {
5281
5313
  var gaps = this_1.getGaps(model, track_id);
5282
5314
  if (gaps) {
5283
5315
  gaps.forEach(function (gap, i) {
5284
5316
  var x = gapOffsets[i] - scroll_x - model.getGapSize();
5285
5317
  var y = model.getZoomedTrackTops()[track_id] +
5286
5318
  cell_height -
5287
- scroll_y;
5319
+ scroll_y -
5320
+ 4;
5288
5321
  _this.drawGapLabel(gap.labelFormatter(), x, y);
5289
5322
  _this.gapTooltipTargets.push({
5290
5323
  origin_x: x,
@@ -10097,20 +10130,38 @@ var OncoprintTrackOptionsView = /** @class */ (function () {
10097
10130
  }
10098
10131
  if (model.getTrackCanShowGaps(track_id)) {
10099
10132
  $dropdown.append(OncoprintTrackOptionsView.$makeDropdownSeparator());
10100
- var $show_gaps_opt_1 = OncoprintTrackOptionsView.$makeDropdownOption('Show gaps', model.getTrackShowGaps(track_id) ? 'bold' : 'normal', false, function (evt) {
10133
+ var $show_gaps_percent_opt = OncoprintTrackOptionsView.$makeDropdownOption(model.getTrackShowGaps(track_id) ===
10134
+ GAP_MODE_ENUM.SHOW_GAPS_PERCENT
10135
+ ? 'Hide gaps (w/%)'
10136
+ : 'Show Gaps (w/%)', model.getTrackShowGaps(track_id) ===
10137
+ GAP_MODE_ENUM.SHOW_GAPS_PERCENT
10138
+ ? 'bold'
10139
+ : 'normal', false, function (evt) {
10101
10140
  evt.stopPropagation();
10102
10141
  $show_gaps_opt_1.css('font-weight', 'bold');
10103
- $dont_show_gaps_opt_1.css('font-weight', 'normal');
10104
- self.showGapsCallback(track_id, true);
10142
+ var mode = [
10143
+ GAP_MODE_ENUM.SHOW_GAPS_PERCENT,
10144
+ ].includes(model.getTrackShowGaps(track_id))
10145
+ ? GAP_MODE_ENUM.HIDE_GAPS
10146
+ : GAP_MODE_ENUM.SHOW_GAPS_PERCENT;
10147
+ self.showGapsCallback(track_id, mode);
10105
10148
  });
10106
- var $dont_show_gaps_opt_1 = OncoprintTrackOptionsView.$makeDropdownOption("Don't show gaps", model.getTrackShowGaps(track_id) ? 'normal' : 'bold', false, function (evt) {
10149
+ var $show_gaps_opt_1 = OncoprintTrackOptionsView.$makeDropdownOption(model.getTrackShowGaps(track_id) === GAP_MODE_ENUM.SHOW_GAPS
10150
+ ? 'Hide gaps'
10151
+ : 'Show Gaps', model.getTrackShowGaps(track_id) === GAP_MODE_ENUM.SHOW_GAPS
10152
+ ? 'bold'
10153
+ : 'normal', false, function (evt) {
10107
10154
  evt.stopPropagation();
10108
- $show_gaps_opt_1.css('font-weight', 'normal');
10109
- $dont_show_gaps_opt_1.css('font-weight', 'bold');
10110
- self.showGapsCallback(track_id, false);
10155
+ $show_gaps_opt_1.css('font-weight', 'bold');
10156
+ var mode = [
10157
+ GAP_MODE_ENUM.SHOW_GAPS,
10158
+ ].includes(model.getTrackShowGaps(track_id))
10159
+ ? GAP_MODE_ENUM.HIDE_GAPS
10160
+ : GAP_MODE_ENUM.SHOW_GAPS;
10161
+ self.showGapsCallback(track_id, mode);
10111
10162
  });
10112
10163
  $dropdown.append($show_gaps_opt_1);
10113
- $dropdown.append($dont_show_gaps_opt_1);
10164
+ $dropdown.append($show_gaps_percent_opt);
10114
10165
  }
10115
10166
  // Add custom options
10116
10167
  var custom_options = model.getTrackCustomOptions(track_id);
@@ -11075,6 +11126,7 @@ var OncoprintTrackInfoView = /** @class */ (function () {
11075
11126
  var self = this;
11076
11127
  var _loop_1 = function (j) {
11077
11128
  (function () {
11129
+ var _a, _b;
11078
11130
  var i = j;
11079
11131
  var $new_label = $$1('<span>')
11080
11132
  .css({
@@ -11089,19 +11141,22 @@ var OncoprintTrackInfoView = /** @class */ (function () {
11089
11141
  if (!text) {
11090
11142
  return;
11091
11143
  }
11092
- var float = parseFloat(text);
11144
+ var num = (_a = text.match(/^[\d\.]*/)) === null || _a === void 0 ? void 0 : _a[0];
11145
+ var suffix = (_b = text.match(/[^\d]*$/)) === null || _b === void 0 ? void 0 : _b[0];
11146
+ var float = parseFloat(num);
11093
11147
  var formattedPercent = '';
11094
11148
  if (isNaN(float)) {
11095
11149
  formattedPercent = 'N/P';
11150
+ suffix = ''; // we don't want any suffix in this case
11096
11151
  }
11097
11152
  else if (isNumber(float)) {
11098
11153
  formattedPercent =
11099
11154
  float < 1 && float > 0
11100
- ? '<1%'
11101
- : Math.round(float) + '%';
11155
+ ? '<1'
11156
+ : Math.round(float).toString();
11102
11157
  }
11103
11158
  else ;
11104
- $new_label.text(formattedPercent);
11159
+ $new_label.text(formattedPercent + suffix);
11105
11160
  $new_label.appendTo(self.$text_ctr);
11106
11161
  self.$label_elts.push($new_label);
11107
11162
  setTimeout(function () {
@@ -14372,7 +14427,7 @@ var Oncoprint = /** @class */ (function () {
14372
14427
  }
14373
14428
  if (this.model.getTrackSortDirection(track_id) === 0) {
14374
14429
  if (this.model.getTrackShowGaps(track_id)) {
14375
- this.setTrackShowGaps(track_id, false);
14430
+ this.setTrackShowGaps(track_id, GAP_MODE_ENUM.HIDE_GAPS);
14376
14431
  }
14377
14432
  }
14378
14433
  }
@@ -14442,9 +14497,10 @@ var Oncoprint = /** @class */ (function () {
14442
14497
  enumerable: false,
14443
14498
  configurable: true,
14444
14499
  writable: true,
14445
- value: function (track_id, showGaps) {
14446
- this.model.setTrackShowGaps(track_id, showGaps);
14447
- if (this.model.getTrackSortDirection(track_id) === 0 && showGaps) {
14500
+ value: function (track_id, gap_mode) {
14501
+ this.model.setTrackShowGaps(track_id, gap_mode);
14502
+ if (this.model.getTrackSortDirection(track_id) === 0 &&
14503
+ gap_mode !== GAP_MODE_ENUM.HIDE_GAPS) {
14448
14504
  this.setTrackSortDirection(track_id, 1);
14449
14505
  }
14450
14506
  this.track_options_view.setTrackShowGaps(this.model, this.getCellViewHeight);
@@ -14983,5 +15039,5 @@ var Oncoprint = /** @class */ (function () {
14983
15039
  return Oncoprint;
14984
15040
  }());
14985
15041
 
14986
- export { GeneticAlterationRuleSet, LinearInterpRangeType, Oncoprint as OncoprintJS, OncoprintModel, Rule, RuleSet, RuleSetType, shapeToSVG as shapeToSvg };
15042
+ export { GAP_MODE_ENUM, GeneticAlterationRuleSet, LinearInterpRangeType, Oncoprint as OncoprintJS, OncoprintModel, Rule, RuleSet, RuleSetType, shapeToSVG as shapeToSvg };
14987
15043
  //# sourceMappingURL=index.es.js.map