oncoprintjs 5.0.3 → 6.0.1

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 (100) hide show
  1. package/README.md +34 -0
  2. package/dist/index.d.ts +4 -0
  3. package/dist/index.es.js +14746 -0
  4. package/dist/index.es.js.map +1 -0
  5. package/dist/index.js +14760 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/js/CachedProperty.d.ts +10 -10
  8. package/dist/js/binarysearch.d.ts +1 -1
  9. package/dist/js/bucketsort.d.ts +16 -16
  10. package/dist/js/clustering.d.ts +14 -14
  11. package/dist/js/extractrgba.d.ts +4 -4
  12. package/dist/js/haselementsininterval.d.ts +1 -1
  13. package/dist/js/heatmapcolors.d.ts +5 -4
  14. package/dist/js/makesvgelement.d.ts +1 -1
  15. package/dist/js/modelutils.d.ts +7 -7
  16. package/dist/js/oncoprint.d.ts +168 -170
  17. package/dist/js/oncoprintheaderview.d.ts +23 -22
  18. package/dist/js/oncoprintlabelview.d.ts +79 -78
  19. package/dist/js/oncoprintlegendrenderer.d.ts +32 -31
  20. package/dist/js/oncoprintminimapview.d.ts +69 -68
  21. package/dist/js/oncoprintmodel.d.ts +403 -398
  22. package/dist/js/oncoprintruleset.d.ts +176 -177
  23. package/dist/js/oncoprintshape.d.ts +67 -67
  24. package/dist/js/oncoprintshapetosvg.d.ts +2 -2
  25. package/dist/js/oncoprintshapetovertexes.d.ts +5 -5
  26. package/dist/js/oncoprinttooltip.d.ts +23 -22
  27. package/dist/js/oncoprinttrackinfoview.d.ts +40 -39
  28. package/dist/js/oncoprinttrackoptionsview.d.ts +58 -57
  29. package/dist/js/oncoprintwebglcellview.d.ts +168 -167
  30. package/dist/js/oncoprintzoomslider.d.ts +28 -27
  31. package/dist/js/polyfill.d.ts +4 -4
  32. package/dist/js/precomputedcomparator.d.ts +13 -13
  33. package/dist/js/shaders.d.ts +2 -2
  34. package/dist/js/svgfactory.d.ts +24 -23
  35. package/dist/js/utils.d.ts +16 -16
  36. package/dist/js/workers/clustering-worker.d.ts +19 -20
  37. package/dist/test/gradientCategoricalRuleset.spec.d.ts +1 -1
  38. package/dist/test/monolith.spec.d.ts +1 -1
  39. package/jest.config.ts +2 -0
  40. package/package.json +20 -26
  41. package/rollup.config.ts +14 -0
  42. package/rules/geneticrules.ts +344 -305
  43. package/server.js +11 -0
  44. package/src/img/menudots.svg +9 -9
  45. package/src/img/zoomtofit.svg +12 -12
  46. package/src/index.tsx +13 -0
  47. package/src/js/CachedProperty.ts +6 -7
  48. package/src/js/binarysearch.ts +8 -3
  49. package/src/js/bucketsort.ts +89 -47
  50. package/src/js/clustering.ts +22 -10
  51. package/src/js/extractrgba.ts +16 -12
  52. package/src/js/haselementsininterval.ts +8 -4
  53. package/src/js/heatmapcolors.ts +515 -515
  54. package/src/js/main.js +1 -1
  55. package/src/js/makesvgelement.ts +2 -2
  56. package/src/js/modelutils.ts +11 -8
  57. package/src/js/oncoprint.ts +706 -385
  58. package/src/js/oncoprintheaderview.ts +165 -125
  59. package/src/js/oncoprintlabelview.ts +388 -170
  60. package/src/js/oncoprintlegendrenderer.ts +203 -72
  61. package/src/js/oncoprintminimapview.ts +965 -423
  62. package/src/js/oncoprintmodel.ts +905 -532
  63. package/src/js/oncoprintruleset.ts +694 -379
  64. package/src/js/oncoprintshape.ts +240 -97
  65. package/src/js/oncoprintshapetosvg.ts +77 -26
  66. package/src/js/oncoprintshapetovertexes.ts +153 -48
  67. package/src/js/oncoprinttooltip.ts +58 -27
  68. package/src/js/oncoprinttrackinfoview.ts +115 -59
  69. package/src/js/oncoprinttrackoptionsview.ts +354 -187
  70. package/src/js/oncoprintwebglcellview.ts +951 -415
  71. package/src/js/oncoprintzoomslider.ts +172 -107
  72. package/src/js/polyfill.ts +7 -3
  73. package/src/js/precomputedcomparator.ts +133 -50
  74. package/src/js/shaders.ts +2 -4
  75. package/src/js/svgfactory.ts +128 -73
  76. package/src/js/utils.ts +51 -31
  77. package/src/js/workers/clustering-worker.ts +50 -42
  78. package/src/test/gradientCategoricalRuleset.spec.ts +55 -38
  79. package/src/test/monolith.spec.ts +718 -285
  80. package/test/generate_data.py +108 -0
  81. package/test/glyphmap-data.js +1041 -0
  82. package/test/heatmap-data.js +1027 -0
  83. package/test/index.html +21 -0
  84. package/test/oncoprint-glyphmap.js +79 -0
  85. package/test/oncoprint-heatmap.js +123 -0
  86. package/tsconfig.json +4 -10
  87. package/tsconfig.test.json +11 -0
  88. package/.idea/misc.xml +0 -6
  89. package/.idea/modules.xml +0 -8
  90. package/.idea/oncoprintjs.iml +0 -12
  91. package/.idea/vcs.xml +0 -6
  92. package/.idea/workspace.xml +0 -105
  93. package/dist/.gitkeep +0 -0
  94. package/dist/js/minimaputils.d.ts +0 -0
  95. package/dist/oncoprint.bundle.js +0 -44313
  96. package/jest.config.js +0 -12
  97. package/src/js/minimaputils.ts +0 -0
  98. package/typings/custom.d.ts +0 -7
  99. package/typings/missing.d.ts +0 -7
  100. package/webpack.config.js +0 -43
@@ -1,35 +1,42 @@
1
- import svgfactory from "./svgfactory";
2
- import $ from "jquery";
3
- import OncoprintToolTip from "./oncoprinttooltip";
4
- import OncoprintModel from "./oncoprintmodel";
1
+ import svgfactory from './svgfactory';
2
+ import $ from 'jquery';
3
+ import OncoprintToolTip from './oncoprinttooltip';
4
+ import OncoprintModel from './oncoprintmodel';
5
5
 
6
6
  export default class OncoprintTrackInfoView {
7
-
8
- private $ctr:JQuery;
9
- private $text_ctr:JQuery;
7
+ private $ctr: JQuery;
8
+ private $text_ctr: JQuery;
10
9
  private base_font_size = 12;
11
10
  private font_family = 'Arial';
12
11
  private font_weight = 'bold';
13
12
  private width = 0;
14
- private $label_elts:JQuery[] = [];
13
+ private $label_elts: JQuery[] = [];
15
14
  private rendering_suppressed = false;
16
- private minimum_track_height:number;
15
+ private minimum_track_height: number;
17
16
 
18
- constructor(private $div:JQuery, private tooltip:OncoprintToolTip) {
17
+ constructor(private $div: JQuery, private tooltip: OncoprintToolTip) {
19
18
  this.tooltip.center = false;
20
19
 
21
- this.$ctr = $('<div></div>').css({'position': 'absolute', 'overflow-y':'hidden', 'overflow-x':'hidden'}).appendTo(this.$div);
22
- this.$text_ctr = $('<div></div>').css({'position':'absolute'}).appendTo(this.$ctr);
20
+ this.$ctr = $('<div></div>')
21
+ .css({
22
+ position: 'absolute',
23
+ 'overflow-y': 'hidden',
24
+ 'overflow-x': 'hidden',
25
+ })
26
+ .appendTo(this.$div);
27
+ this.$text_ctr = $('<div></div>')
28
+ .css({ position: 'absolute' })
29
+ .appendTo(this.$ctr);
23
30
  }
24
31
 
25
32
  private destroyLabelElts() {
26
- for (let i=0; i<this.$label_elts.length; i++) {
27
- this.$label_elts[i].off("mousemove mouseleave");
33
+ for (let i = 0; i < this.$label_elts.length; i++) {
34
+ this.$label_elts[i].off('mousemove mouseleave');
28
35
  }
29
36
  this.$label_elts = [];
30
37
  }
31
38
 
32
- private renderAllInfo(model:OncoprintModel) {
39
+ private renderAllInfo(model: OncoprintModel) {
33
40
  if (this.rendering_suppressed) {
34
41
  return;
35
42
  }
@@ -39,7 +46,10 @@ export default class OncoprintTrackInfoView {
39
46
  const tracks = model.getTracks();
40
47
  this.minimum_track_height = Number.POSITIVE_INFINITY;
41
48
  for (let i = 0; i < tracks.length; i++) {
42
- this.minimum_track_height = Math.min(this.minimum_track_height, model.getTrackHeight(tracks[i]));
49
+ this.minimum_track_height = Math.min(
50
+ this.minimum_track_height,
51
+ model.getTrackHeight(tracks[i])
52
+ );
43
53
  }
44
54
 
45
55
  this.width = 0;
@@ -52,10 +62,13 @@ export default class OncoprintTrackInfoView {
52
62
  for (let j = 0; j < tracks.length; j++) {
53
63
  (function() {
54
64
  const i = j;
55
- const $new_label = $('<span>').css({'position': 'absolute',
56
- 'font-family': self.font_family,
57
- 'font-weight': self.font_weight,
58
- 'font-size': font_size})
65
+ const $new_label = $('<span>')
66
+ .css({
67
+ position: 'absolute',
68
+ 'font-family': self.font_family,
69
+ 'font-weight': self.font_weight,
70
+ 'font-size': font_size,
71
+ })
59
72
  .addClass('noselect');
60
73
  const text = model.getTrackInfo(tracks[i]);
61
74
  if (!text) {
@@ -65,95 +78,126 @@ export default class OncoprintTrackInfoView {
65
78
  $new_label.appendTo(self.$text_ctr);
66
79
  self.$label_elts.push($new_label);
67
80
  setTimeout(function() {
68
- $new_label.on("mousemove", function() {
69
- const $tooltip_elt = model.$getTrackInfoTooltip(tracks[i]);
70
- if ($tooltip_elt) {
71
- const offset = $new_label[0].getBoundingClientRect();
72
- self.tooltip.fadeIn(200, offset.left, offset.top, $tooltip_elt);
73
- }
74
- }).on("mouseleave", function() {
75
- self.tooltip.hideIfNotAlreadyGoingTo(150);
76
- });
81
+ $new_label
82
+ .on('mousemove', function() {
83
+ const $tooltip_elt = model.$getTrackInfoTooltip(
84
+ tracks[i]
85
+ );
86
+ if ($tooltip_elt) {
87
+ const offset = $new_label[0].getBoundingClientRect();
88
+ self.tooltip.fadeIn(
89
+ 200,
90
+ offset.left,
91
+ offset.top,
92
+ $tooltip_elt
93
+ );
94
+ }
95
+ })
96
+ .on('mouseleave', function() {
97
+ self.tooltip.hideIfNotAlreadyGoingTo(150);
98
+ });
77
99
  }, 0); // delay to give time for render before adding events
78
- const top = label_tops[tracks[i]] + (model.getCellHeight(tracks[i]) - $new_label.outerHeight()) / 2;
79
- $new_label.css({'top': top + 'px'});
80
- self.width = Math.max(32, self.width, $new_label[0].clientWidth);
100
+ const top =
101
+ label_tops[tracks[i]] +
102
+ (model.getCellHeight(tracks[i]) -
103
+ $new_label.outerHeight()) /
104
+ 2;
105
+ $new_label.css({ top: top + 'px' });
106
+ self.width = Math.max(
107
+ 32,
108
+ self.width,
109
+ $new_label[0].clientWidth
110
+ );
81
111
  })();
82
112
  }
83
113
  if (this.width > 0) {
84
114
  this.width += 10;
85
115
  }
86
- };
87
- private scroll(scroll_y:number) {
116
+ }
117
+ private scroll(scroll_y: number) {
88
118
  if (this.rendering_suppressed) {
89
119
  return;
90
120
  }
91
- this.$text_ctr.css({'top': -scroll_y});
92
- };
121
+ this.$text_ctr.css({ top: -scroll_y });
122
+ }
93
123
 
94
- private resize(model:OncoprintModel, getCellViewHeight:()=>number) {
124
+ private resize(model: OncoprintModel, getCellViewHeight: () => number) {
95
125
  if (this.rendering_suppressed) {
96
126
  return;
97
127
  }
98
- this.$div.css({'width': this.getWidth(), 'height': getCellViewHeight()});
99
- this.$ctr.css({'width': this.getWidth(), 'height': getCellViewHeight()});
100
- };
128
+ this.$div.css({ width: this.getWidth(), height: getCellViewHeight() });
129
+ this.$ctr.css({ width: this.getWidth(), height: getCellViewHeight() });
130
+ }
101
131
 
102
132
  public getFontSize() {
103
- return Math.max(Math.min(this.base_font_size, this.minimum_track_height), 7);
133
+ return Math.max(
134
+ Math.min(this.base_font_size, this.minimum_track_height),
135
+ 7
136
+ );
104
137
  }
105
138
  public getWidth() {
106
139
  return this.width;
107
140
  }
108
- public addTracks(model:OncoprintModel, getCellViewHeight:()=>number) {
141
+ public addTracks(model: OncoprintModel, getCellViewHeight: () => number) {
109
142
  this.renderAllInfo(model);
110
143
  this.resize(model, getCellViewHeight);
111
144
  }
112
- public moveTrack(model:OncoprintModel, getCellViewHeight:()=>number) {
145
+ public moveTrack(model: OncoprintModel, getCellViewHeight: () => number) {
113
146
  this.renderAllInfo(model);
114
147
  this.resize(model, getCellViewHeight);
115
148
  }
116
- public setTrackGroupOrder(model:OncoprintModel, getCellViewHeight:()=>number) {
149
+ public setTrackGroupOrder(
150
+ model: OncoprintModel,
151
+ getCellViewHeight: () => number
152
+ ) {
117
153
  this.renderAllInfo(model);
118
154
  this.resize(model, getCellViewHeight);
119
155
  }
120
- public removeTrack(model:OncoprintModel, getCellViewHeight:()=>number) {
156
+ public removeTrack(model: OncoprintModel, getCellViewHeight: () => number) {
121
157
  this.renderAllInfo(model);
122
158
  this.resize(model, getCellViewHeight);
123
159
  }
124
- public setTrackInfo(model:OncoprintModel, getCellViewHeight:()=>number) {
160
+ public setTrackInfo(
161
+ model: OncoprintModel,
162
+ getCellViewHeight: () => number
163
+ ) {
125
164
  this.renderAllInfo(model);
126
165
  this.resize(model, getCellViewHeight);
127
166
  }
128
- public setTrackGroupHeader(model:OncoprintModel, getCellViewHeight:()=>number) {
167
+ public setTrackGroupHeader(
168
+ model: OncoprintModel,
169
+ getCellViewHeight: () => number
170
+ ) {
129
171
  this.renderAllInfo(model);
130
172
  this.resize(model, getCellViewHeight);
131
173
  }
132
- public setScroll(model:OncoprintModel) {
174
+ public setScroll(model: OncoprintModel) {
133
175
  this.setVertScroll(model);
134
176
  }
135
- public setHorzScroll(model:OncoprintModel) {
136
- }
137
- public setVertScroll(model:OncoprintModel) {
177
+ public setHorzScroll(model: OncoprintModel) {}
178
+ public setVertScroll(model: OncoprintModel) {
138
179
  this.scroll(model.getVertScroll());
139
180
  }
140
- public setZoom(model:OncoprintModel, getCellViewHeight:()=>number) {
181
+ public setZoom(model: OncoprintModel, getCellViewHeight: () => number) {
141
182
  this.setVertZoom(model, getCellViewHeight);
142
183
  }
143
184
 
144
- public setViewport(model:OncoprintModel, getCellViewHeight:()=>number) {
185
+ public setViewport(model: OncoprintModel, getCellViewHeight: () => number) {
145
186
  this.renderAllInfo(model);
146
187
  this.resize(model, getCellViewHeight);
147
188
  this.scroll(model.getVertScroll());
148
189
  }
149
- public setVertZoom(model:OncoprintModel, getCellViewHeight:()=>number) {
190
+ public setVertZoom(model: OncoprintModel, getCellViewHeight: () => number) {
150
191
  this.renderAllInfo(model);
151
192
  this.resize(model, getCellViewHeight);
152
193
  }
153
194
  public suppressRendering() {
154
195
  this.rendering_suppressed = true;
155
196
  }
156
- public releaseRendering(model:OncoprintModel, getCellViewHeight:()=>number) {
197
+ public releaseRendering(
198
+ model: OncoprintModel,
199
+ getCellViewHeight: () => number
200
+ ) {
157
201
  this.rendering_suppressed = false;
158
202
  this.renderAllInfo(model);
159
203
  this.resize(model, getCellViewHeight);
@@ -162,8 +206,12 @@ export default class OncoprintTrackInfoView {
162
206
  public destroy() {
163
207
  this.destroyLabelElts();
164
208
  }
165
- public toSVGGroup(model:OncoprintModel, offset_x:number, offset_y:number) {
166
- const root = svgfactory.group((offset_x || 0), (offset_y || 0));
209
+ public toSVGGroup(
210
+ model: OncoprintModel,
211
+ offset_x: number,
212
+ offset_y: number
213
+ ) {
214
+ const root = svgfactory.group(offset_x || 0, offset_y || 0);
167
215
  const cell_tops = model.getCellTops();
168
216
  const tracks = model.getTracks();
169
217
 
@@ -173,8 +221,16 @@ export default class OncoprintTrackInfoView {
173
221
  const track_id = tracks[i];
174
222
  const y = cell_tops[track_id] + model.getCellHeight(track_id) / 2;
175
223
  const info = model.getTrackInfo(track_id);
176
- const text_elt = svgfactory.text(info, 0, y, font_size, this.font_family, this.font_weight, "bottom");
177
- text_elt.setAttribute("dy", "0.35em");
224
+ const text_elt = svgfactory.text(
225
+ info,
226
+ 0,
227
+ y,
228
+ font_size,
229
+ this.font_family,
230
+ this.font_weight,
231
+ 'bottom'
232
+ );
233
+ text_elt.setAttribute('dy', '0.35em');
178
234
  root.appendChild(text_elt);
179
235
  }
180
236
  return root;