@jbrowse/plugin-wiggle 1.7.0 → 1.7.4

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 (63) hide show
  1. package/dist/BigWigAdapter/BigWigAdapter.d.ts +24 -24
  2. package/dist/BigWigAdapter/BigWigAdapter.js +22 -22
  3. package/dist/BigWigAdapter/BigWigAdapter.test.js +9 -9
  4. package/dist/BigWigAdapter/configSchema.d.ts +2 -2
  5. package/dist/BigWigAdapter/configSchema.js +2 -2
  6. package/dist/BigWigAdapter/index.d.ts +1 -1
  7. package/dist/BigWigAdapter/index.js +1 -1
  8. package/dist/DensityRenderer/DensityRenderer.test.js +6 -6
  9. package/dist/DensityRenderer/index.d.ts +6 -6
  10. package/dist/DensityRenderer/index.js +13 -13
  11. package/dist/LinePlotRenderer/LinePlotRenderer.d.ts +4 -9
  12. package/dist/LinePlotRenderer/LinePlotRenderer.js +12 -12
  13. package/dist/LinePlotRenderer/configSchema.d.ts +2 -2
  14. package/dist/LinePlotRenderer/configSchema.js +2 -2
  15. package/dist/LinePlotRenderer/index.d.ts +3 -3
  16. package/dist/LinePlotRenderer/index.js +3 -3
  17. package/dist/LinearWiggleDisplay/components/SetColorDialog.d.ts +10 -10
  18. package/dist/LinearWiggleDisplay/components/SetColorDialog.js +14 -14
  19. package/dist/LinearWiggleDisplay/components/SetMinMaxDialog.d.ts +11 -11
  20. package/dist/LinearWiggleDisplay/components/SetMinMaxDialog.js +13 -13
  21. package/dist/LinearWiggleDisplay/components/Tooltip.d.ts +24 -24
  22. package/dist/LinearWiggleDisplay/components/Tooltip.js +14 -14
  23. package/dist/LinearWiggleDisplay/components/WiggleDisplayComponent.d.ts +8 -8
  24. package/dist/LinearWiggleDisplay/components/WiggleDisplayComponent.js +5 -5
  25. package/dist/LinearWiggleDisplay/components/YScaleBar.d.ts +7 -7
  26. package/dist/LinearWiggleDisplay/components/YScaleBar.js +3 -3
  27. package/dist/LinearWiggleDisplay/index.d.ts +3 -3
  28. package/dist/LinearWiggleDisplay/index.js +4 -4
  29. package/dist/LinearWiggleDisplay/models/configSchema.d.ts +2 -2
  30. package/dist/LinearWiggleDisplay/models/configSchema.js +1 -1
  31. package/dist/LinearWiggleDisplay/models/model.d.ts +288 -288
  32. package/dist/LinearWiggleDisplay/models/model.js +27 -27
  33. package/dist/WiggleBaseRenderer.d.ts +44 -42
  34. package/dist/WiggleBaseRenderer.js +13 -13
  35. package/dist/WiggleRPC/rpcMethods.d.ts +31 -31
  36. package/dist/WiggleRPC/rpcMethods.js +27 -27
  37. package/dist/WiggleRendering.d.ts +16 -16
  38. package/dist/WiggleRendering.js +7 -7
  39. package/dist/WiggleRendering.test.js +3 -3
  40. package/dist/XYPlotRenderer/XYPlotRenderer.d.ts +4 -4
  41. package/dist/XYPlotRenderer/XYPlotRenderer.js +15 -15
  42. package/dist/XYPlotRenderer/XYPlotRenderer.test.js +6 -6
  43. package/dist/XYPlotRenderer/index.d.ts +3 -3
  44. package/dist/XYPlotRenderer/index.js +3 -3
  45. package/dist/configSchema.d.ts +2 -2
  46. package/dist/configSchema.js +2 -2
  47. package/dist/index.d.ts +866 -866
  48. package/dist/index.js +21 -21
  49. package/dist/index.test.js +2 -2
  50. package/dist/util.d.ts +41 -41
  51. package/dist/util.js +4 -4
  52. package/package.json +4 -4
  53. package/dist/DensityRenderer/DensityRenderer.test.d.ts +0 -1
  54. package/dist/WiggleRendering.test.d.ts +0 -1
  55. package/dist/XYPlotRenderer/XYPlotRenderer.test.d.ts +0 -1
  56. package/dist/index.test.d.ts +0 -1
  57. package/dist/plugin-wiggle.cjs.development.js +0 -3556
  58. package/dist/plugin-wiggle.cjs.development.js.map +0 -1
  59. package/dist/plugin-wiggle.cjs.production.min.js +0 -2
  60. package/dist/plugin-wiggle.cjs.production.min.js.map +0 -1
  61. package/dist/plugin-wiggle.esm.js +0 -3541
  62. package/dist/plugin-wiggle.esm.js.map +0 -1
  63. package/dist/util.test.d.ts +0 -1
@@ -1,3556 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var AdapterType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/AdapterType'));
8
- var TrackType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/TrackType'));
9
- var Plugin = _interopDefault(require('@jbrowse/core/Plugin'));
10
- var configuration = require('@jbrowse/core/configuration');
11
- var models = require('@jbrowse/core/pluggableElementTypes/models');
12
- var DisplayType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/DisplayType'));
13
- var FeatureRendererType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/renderers/FeatureRendererType'));
14
- var offscreenCanvasUtils = require('@jbrowse/core/util/offscreenCanvasUtils');
15
- var mobxReact = require('mobx-react');
16
- var React = require('react');
17
- var React__default = _interopDefault(React);
18
- var ui = require('@jbrowse/core/ui');
19
- var util = require('@jbrowse/core/util');
20
- var d3Scale = require('d3-scale');
21
- var mobxStateTree = require('mobx-state-tree');
22
- var pluginLinearGenomeView = require('@jbrowse/plugin-linear-genome-view');
23
- var tracks = require('@jbrowse/core/util/tracks');
24
- var mobx = require('mobx');
25
- var reactD3AxisMod = require('react-d3-axis-mod');
26
- var core = require('@material-ui/core');
27
- var reactPopper = require('react-popper');
28
- var Color = _interopDefault(require('color'));
29
- var dataAdapterCache = require('@jbrowse/core/data_adapters/dataAdapterCache');
30
- var RpcMethodType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/RpcMethodType'));
31
- var BaseAdapter = require('@jbrowse/core/data_adapters/BaseAdapter');
32
- var SerializableFilterChain = _interopDefault(require('@jbrowse/core/pluggableElementTypes/renderers/util/serializableFilterChain'));
33
- var styles = require('@material-ui/core/styles');
34
- var Button = _interopDefault(require('@material-ui/core/Button'));
35
- var TextField = _interopDefault(require('@material-ui/core/TextField'));
36
- var Typography = _interopDefault(require('@material-ui/core/Typography'));
37
- var Dialog = _interopDefault(require('@material-ui/core/Dialog'));
38
- var DialogContent = _interopDefault(require('@material-ui/core/DialogContent'));
39
- var DialogTitle = _interopDefault(require('@material-ui/core/DialogTitle'));
40
- var IconButton = _interopDefault(require('@material-ui/core/IconButton'));
41
- var CloseIcon = _interopDefault(require('@material-ui/icons/Close'));
42
- var reactColor = require('react-color');
43
- var bbi = require('@gmod/bbi');
44
- var io = require('@jbrowse/core/util/io');
45
- var rxjs = require('@jbrowse/core/util/rxjs');
46
- var SimpleFeature = _interopDefault(require('@jbrowse/core/util/simpleFeature'));
47
- var operators = require('rxjs/operators');
48
- var stats = require('@jbrowse/core/util/stats');
49
-
50
- function ownKeys(object, enumerableOnly) {
51
- var keys = Object.keys(object);
52
-
53
- if (Object.getOwnPropertySymbols) {
54
- var symbols = Object.getOwnPropertySymbols(object);
55
- enumerableOnly && (symbols = symbols.filter(function (sym) {
56
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
57
- })), keys.push.apply(keys, symbols);
58
- }
59
-
60
- return keys;
61
- }
62
-
63
- function _objectSpread2(target) {
64
- for (var i = 1; i < arguments.length; i++) {
65
- var source = null != arguments[i] ? arguments[i] : {};
66
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
67
- _defineProperty(target, key, source[key]);
68
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
69
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
70
- });
71
- }
72
-
73
- return target;
74
- }
75
-
76
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
77
- try {
78
- var info = gen[key](arg);
79
- var value = info.value;
80
- } catch (error) {
81
- reject(error);
82
- return;
83
- }
84
-
85
- if (info.done) {
86
- resolve(value);
87
- } else {
88
- Promise.resolve(value).then(_next, _throw);
89
- }
90
- }
91
-
92
- function _asyncToGenerator(fn) {
93
- return function () {
94
- var self = this,
95
- args = arguments;
96
- return new Promise(function (resolve, reject) {
97
- var gen = fn.apply(self, args);
98
-
99
- function _next(value) {
100
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
101
- }
102
-
103
- function _throw(err) {
104
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
105
- }
106
-
107
- _next(undefined);
108
- });
109
- };
110
- }
111
-
112
- function _classCallCheck(instance, Constructor) {
113
- if (!(instance instanceof Constructor)) {
114
- throw new TypeError("Cannot call a class as a function");
115
- }
116
- }
117
-
118
- function _defineProperties(target, props) {
119
- for (var i = 0; i < props.length; i++) {
120
- var descriptor = props[i];
121
- descriptor.enumerable = descriptor.enumerable || false;
122
- descriptor.configurable = true;
123
- if ("value" in descriptor) descriptor.writable = true;
124
- Object.defineProperty(target, descriptor.key, descriptor);
125
- }
126
- }
127
-
128
- function _createClass(Constructor, protoProps, staticProps) {
129
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
130
- if (staticProps) _defineProperties(Constructor, staticProps);
131
- Object.defineProperty(Constructor, "prototype", {
132
- writable: false
133
- });
134
- return Constructor;
135
- }
136
-
137
- function _defineProperty(obj, key, value) {
138
- if (key in obj) {
139
- Object.defineProperty(obj, key, {
140
- value: value,
141
- enumerable: true,
142
- configurable: true,
143
- writable: true
144
- });
145
- } else {
146
- obj[key] = value;
147
- }
148
-
149
- return obj;
150
- }
151
-
152
- function _inherits(subClass, superClass) {
153
- if (typeof superClass !== "function" && superClass !== null) {
154
- throw new TypeError("Super expression must either be null or a function");
155
- }
156
-
157
- subClass.prototype = Object.create(superClass && superClass.prototype, {
158
- constructor: {
159
- value: subClass,
160
- writable: true,
161
- configurable: true
162
- }
163
- });
164
- Object.defineProperty(subClass, "prototype", {
165
- writable: false
166
- });
167
- if (superClass) _setPrototypeOf(subClass, superClass);
168
- }
169
-
170
- function _getPrototypeOf(o) {
171
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
172
- return o.__proto__ || Object.getPrototypeOf(o);
173
- };
174
- return _getPrototypeOf(o);
175
- }
176
-
177
- function _setPrototypeOf(o, p) {
178
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
179
- o.__proto__ = p;
180
- return o;
181
- };
182
-
183
- return _setPrototypeOf(o, p);
184
- }
185
-
186
- function _isNativeReflectConstruct() {
187
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
188
- if (Reflect.construct.sham) return false;
189
- if (typeof Proxy === "function") return true;
190
-
191
- try {
192
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
193
- return true;
194
- } catch (e) {
195
- return false;
196
- }
197
- }
198
-
199
- function _assertThisInitialized(self) {
200
- if (self === void 0) {
201
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
202
- }
203
-
204
- return self;
205
- }
206
-
207
- function _possibleConstructorReturn(self, call) {
208
- if (call && (typeof call === "object" || typeof call === "function")) {
209
- return call;
210
- } else if (call !== void 0) {
211
- throw new TypeError("Derived constructors may only return object or undefined");
212
- }
213
-
214
- return _assertThisInitialized(self);
215
- }
216
-
217
- function _createSuper(Derived) {
218
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
219
-
220
- return function _createSuperInternal() {
221
- var Super = _getPrototypeOf(Derived),
222
- result;
223
-
224
- if (hasNativeReflectConstruct) {
225
- var NewTarget = _getPrototypeOf(this).constructor;
226
-
227
- result = Reflect.construct(Super, arguments, NewTarget);
228
- } else {
229
- result = Super.apply(this, arguments);
230
- }
231
-
232
- return _possibleConstructorReturn(this, result);
233
- };
234
- }
235
-
236
- function _superPropBase(object, property) {
237
- while (!Object.prototype.hasOwnProperty.call(object, property)) {
238
- object = _getPrototypeOf(object);
239
- if (object === null) break;
240
- }
241
-
242
- return object;
243
- }
244
-
245
- function _get() {
246
- if (typeof Reflect !== "undefined" && Reflect.get) {
247
- _get = Reflect.get;
248
- } else {
249
- _get = function _get(target, property, receiver) {
250
- var base = _superPropBase(target, property);
251
-
252
- if (!base) return;
253
- var desc = Object.getOwnPropertyDescriptor(base, property);
254
-
255
- if (desc.get) {
256
- return desc.get.call(arguments.length < 3 ? target : receiver);
257
- }
258
-
259
- return desc.value;
260
- };
261
- }
262
-
263
- return _get.apply(this, arguments);
264
- }
265
-
266
- function _slicedToArray(arr, i) {
267
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
268
- }
269
-
270
- function _toConsumableArray(arr) {
271
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
272
- }
273
-
274
- function _arrayWithoutHoles(arr) {
275
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
276
- }
277
-
278
- function _arrayWithHoles(arr) {
279
- if (Array.isArray(arr)) return arr;
280
- }
281
-
282
- function _iterableToArray(iter) {
283
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
284
- }
285
-
286
- function _iterableToArrayLimit(arr, i) {
287
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
288
-
289
- if (_i == null) return;
290
- var _arr = [];
291
- var _n = true;
292
- var _d = false;
293
-
294
- var _s, _e;
295
-
296
- try {
297
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
298
- _arr.push(_s.value);
299
-
300
- if (i && _arr.length === i) break;
301
- }
302
- } catch (err) {
303
- _d = true;
304
- _e = err;
305
- } finally {
306
- try {
307
- if (!_n && _i["return"] != null) _i["return"]();
308
- } finally {
309
- if (_d) throw _e;
310
- }
311
- }
312
-
313
- return _arr;
314
- }
315
-
316
- function _unsupportedIterableToArray(o, minLen) {
317
- if (!o) return;
318
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
319
- var n = Object.prototype.toString.call(o).slice(8, -1);
320
- if (n === "Object" && o.constructor) n = o.constructor.name;
321
- if (n === "Map" || n === "Set") return Array.from(o);
322
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
323
- }
324
-
325
- function _arrayLikeToArray(arr, len) {
326
- if (len == null || len > arr.length) len = arr.length;
327
-
328
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
329
-
330
- return arr2;
331
- }
332
-
333
- function _nonIterableSpread() {
334
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
335
- }
336
-
337
- function _nonIterableRest() {
338
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
339
- }
340
-
341
- function _createForOfIteratorHelper(o, allowArrayLike) {
342
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
343
-
344
- if (!it) {
345
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
346
- if (it) o = it;
347
- var i = 0;
348
-
349
- var F = function () {};
350
-
351
- return {
352
- s: F,
353
- n: function () {
354
- if (i >= o.length) return {
355
- done: true
356
- };
357
- return {
358
- done: false,
359
- value: o[i++]
360
- };
361
- },
362
- e: function (e) {
363
- throw e;
364
- },
365
- f: F
366
- };
367
- }
368
-
369
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
370
- }
371
-
372
- var normalCompletion = true,
373
- didErr = false,
374
- err;
375
- return {
376
- s: function () {
377
- it = it.call(o);
378
- },
379
- n: function () {
380
- var step = it.next();
381
- normalCompletion = step.done;
382
- return step;
383
- },
384
- e: function (e) {
385
- didErr = true;
386
- err = e;
387
- },
388
- f: function () {
389
- try {
390
- if (!normalCompletion && it.return != null) it.return();
391
- } finally {
392
- if (didErr) throw err;
393
- }
394
- }
395
- };
396
- }
397
-
398
- function createCommonjsModule(fn, module) {
399
- return module = { exports: {} }, fn(module, module.exports), module.exports;
400
- }
401
-
402
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
403
- /**
404
- * Copyright (c) 2014-present, Facebook, Inc.
405
- *
406
- * This source code is licensed under the MIT license found in the
407
- * LICENSE file in the root directory of this source tree.
408
- */
409
- var runtime = function (exports) {
410
-
411
- var Op = Object.prototype;
412
- var hasOwn = Op.hasOwnProperty;
413
- var undefined$1; // More compressible than void 0.
414
-
415
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
416
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
417
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
418
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
419
-
420
- function define(obj, key, value) {
421
- Object.defineProperty(obj, key, {
422
- value: value,
423
- enumerable: true,
424
- configurable: true,
425
- writable: true
426
- });
427
- return obj[key];
428
- }
429
-
430
- try {
431
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
432
- define({}, "");
433
- } catch (err) {
434
- define = function define(obj, key, value) {
435
- return obj[key] = value;
436
- };
437
- }
438
-
439
- function wrap(innerFn, outerFn, self, tryLocsList) {
440
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
441
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
442
- var generator = Object.create(protoGenerator.prototype);
443
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
444
- // .throw, and .return methods.
445
-
446
- generator._invoke = makeInvokeMethod(innerFn, self, context);
447
- return generator;
448
- }
449
-
450
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
451
- // record like context.tryEntries[i].completion. This interface could
452
- // have been (and was previously) designed to take a closure to be
453
- // invoked without arguments, but in all the cases we care about we
454
- // already have an existing method we want to call, so there's no need
455
- // to create a new function object. We can even get away with assuming
456
- // the method takes exactly one argument, since that happens to be true
457
- // in every case, so we don't have to touch the arguments object. The
458
- // only additional allocation required is the completion record, which
459
- // has a stable shape and so hopefully should be cheap to allocate.
460
-
461
- function tryCatch(fn, obj, arg) {
462
- try {
463
- return {
464
- type: "normal",
465
- arg: fn.call(obj, arg)
466
- };
467
- } catch (err) {
468
- return {
469
- type: "throw",
470
- arg: err
471
- };
472
- }
473
- }
474
-
475
- var GenStateSuspendedStart = "suspendedStart";
476
- var GenStateSuspendedYield = "suspendedYield";
477
- var GenStateExecuting = "executing";
478
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
479
- // breaking out of the dispatch switch statement.
480
-
481
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
482
- // .constructor.prototype properties for functions that return Generator
483
- // objects. For full spec compliance, you may wish to configure your
484
- // minifier not to mangle the names of these two functions.
485
-
486
- function Generator() {}
487
-
488
- function GeneratorFunction() {}
489
-
490
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
491
- // don't natively support it.
492
-
493
-
494
- var IteratorPrototype = {};
495
- define(IteratorPrototype, iteratorSymbol, function () {
496
- return this;
497
- });
498
- var getProto = Object.getPrototypeOf;
499
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
500
-
501
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
502
- // This environment has a native %IteratorPrototype%; use it instead
503
- // of the polyfill.
504
- IteratorPrototype = NativeIteratorPrototype;
505
- }
506
-
507
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
508
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
509
- define(Gp, "constructor", GeneratorFunctionPrototype);
510
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
511
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
512
- // Iterator interface in terms of a single ._invoke method.
513
-
514
- function defineIteratorMethods(prototype) {
515
- ["next", "throw", "return"].forEach(function (method) {
516
- define(prototype, method, function (arg) {
517
- return this._invoke(method, arg);
518
- });
519
- });
520
- }
521
-
522
- exports.isGeneratorFunction = function (genFun) {
523
- var ctor = typeof genFun === "function" && genFun.constructor;
524
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
525
- // do is to check its .name property.
526
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
527
- };
528
-
529
- exports.mark = function (genFun) {
530
- if (Object.setPrototypeOf) {
531
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
532
- } else {
533
- genFun.__proto__ = GeneratorFunctionPrototype;
534
- define(genFun, toStringTagSymbol, "GeneratorFunction");
535
- }
536
-
537
- genFun.prototype = Object.create(Gp);
538
- return genFun;
539
- }; // Within the body of any async function, `await x` is transformed to
540
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
541
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
542
- // meant to be awaited.
543
-
544
-
545
- exports.awrap = function (arg) {
546
- return {
547
- __await: arg
548
- };
549
- };
550
-
551
- function AsyncIterator(generator, PromiseImpl) {
552
- function invoke(method, arg, resolve, reject) {
553
- var record = tryCatch(generator[method], generator, arg);
554
-
555
- if (record.type === "throw") {
556
- reject(record.arg);
557
- } else {
558
- var result = record.arg;
559
- var value = result.value;
560
-
561
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
562
- return PromiseImpl.resolve(value.__await).then(function (value) {
563
- invoke("next", value, resolve, reject);
564
- }, function (err) {
565
- invoke("throw", err, resolve, reject);
566
- });
567
- }
568
-
569
- return PromiseImpl.resolve(value).then(function (unwrapped) {
570
- // When a yielded Promise is resolved, its final value becomes
571
- // the .value of the Promise<{value,done}> result for the
572
- // current iteration.
573
- result.value = unwrapped;
574
- resolve(result);
575
- }, function (error) {
576
- // If a rejected Promise was yielded, throw the rejection back
577
- // into the async generator function so it can be handled there.
578
- return invoke("throw", error, resolve, reject);
579
- });
580
- }
581
- }
582
-
583
- var previousPromise;
584
-
585
- function enqueue(method, arg) {
586
- function callInvokeWithMethodAndArg() {
587
- return new PromiseImpl(function (resolve, reject) {
588
- invoke(method, arg, resolve, reject);
589
- });
590
- }
591
-
592
- return previousPromise = // If enqueue has been called before, then we want to wait until
593
- // all previous Promises have been resolved before calling invoke,
594
- // so that results are always delivered in the correct order. If
595
- // enqueue has not been called before, then it is important to
596
- // call invoke immediately, without waiting on a callback to fire,
597
- // so that the async generator function has the opportunity to do
598
- // any necessary setup in a predictable way. This predictability
599
- // is why the Promise constructor synchronously invokes its
600
- // executor callback, and why async functions synchronously
601
- // execute code before the first await. Since we implement simple
602
- // async functions in terms of async generators, it is especially
603
- // important to get this right, even though it requires care.
604
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
605
- // invocations of the iterator.
606
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
607
- } // Define the unified helper method that is used to implement .next,
608
- // .throw, and .return (see defineIteratorMethods).
609
-
610
-
611
- this._invoke = enqueue;
612
- }
613
-
614
- defineIteratorMethods(AsyncIterator.prototype);
615
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
616
- return this;
617
- });
618
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
619
- // AsyncIterator objects; they just return a Promise for the value of
620
- // the final result produced by the iterator.
621
-
622
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
623
- if (PromiseImpl === void 0) PromiseImpl = Promise;
624
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
625
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
626
- : iter.next().then(function (result) {
627
- return result.done ? result.value : iter.next();
628
- });
629
- };
630
-
631
- function makeInvokeMethod(innerFn, self, context) {
632
- var state = GenStateSuspendedStart;
633
- return function invoke(method, arg) {
634
- if (state === GenStateExecuting) {
635
- throw new Error("Generator is already running");
636
- }
637
-
638
- if (state === GenStateCompleted) {
639
- if (method === "throw") {
640
- throw arg;
641
- } // Be forgiving, per 25.3.3.3.3 of the spec:
642
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
643
-
644
-
645
- return doneResult();
646
- }
647
-
648
- context.method = method;
649
- context.arg = arg;
650
-
651
- while (true) {
652
- var delegate = context.delegate;
653
-
654
- if (delegate) {
655
- var delegateResult = maybeInvokeDelegate(delegate, context);
656
-
657
- if (delegateResult) {
658
- if (delegateResult === ContinueSentinel) continue;
659
- return delegateResult;
660
- }
661
- }
662
-
663
- if (context.method === "next") {
664
- // Setting context._sent for legacy support of Babel's
665
- // function.sent implementation.
666
- context.sent = context._sent = context.arg;
667
- } else if (context.method === "throw") {
668
- if (state === GenStateSuspendedStart) {
669
- state = GenStateCompleted;
670
- throw context.arg;
671
- }
672
-
673
- context.dispatchException(context.arg);
674
- } else if (context.method === "return") {
675
- context.abrupt("return", context.arg);
676
- }
677
-
678
- state = GenStateExecuting;
679
- var record = tryCatch(innerFn, self, context);
680
-
681
- if (record.type === "normal") {
682
- // If an exception is thrown from innerFn, we leave state ===
683
- // GenStateExecuting and loop back for another invocation.
684
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
685
-
686
- if (record.arg === ContinueSentinel) {
687
- continue;
688
- }
689
-
690
- return {
691
- value: record.arg,
692
- done: context.done
693
- };
694
- } else if (record.type === "throw") {
695
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
696
- // context.dispatchException(context.arg) call above.
697
-
698
- context.method = "throw";
699
- context.arg = record.arg;
700
- }
701
- }
702
- };
703
- } // Call delegate.iterator[context.method](context.arg) and handle the
704
- // result, either by returning a { value, done } result from the
705
- // delegate iterator, or by modifying context.method and context.arg,
706
- // setting context.delegate to null, and returning the ContinueSentinel.
707
-
708
-
709
- function maybeInvokeDelegate(delegate, context) {
710
- var method = delegate.iterator[context.method];
711
-
712
- if (method === undefined$1) {
713
- // A .throw or .return when the delegate iterator has no .throw
714
- // method always terminates the yield* loop.
715
- context.delegate = null;
716
-
717
- if (context.method === "throw") {
718
- // Note: ["return"] must be used for ES3 parsing compatibility.
719
- if (delegate.iterator["return"]) {
720
- // If the delegate iterator has a return method, give it a
721
- // chance to clean up.
722
- context.method = "return";
723
- context.arg = undefined$1;
724
- maybeInvokeDelegate(delegate, context);
725
-
726
- if (context.method === "throw") {
727
- // If maybeInvokeDelegate(context) changed context.method from
728
- // "return" to "throw", let that override the TypeError below.
729
- return ContinueSentinel;
730
- }
731
- }
732
-
733
- context.method = "throw";
734
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
735
- }
736
-
737
- return ContinueSentinel;
738
- }
739
-
740
- var record = tryCatch(method, delegate.iterator, context.arg);
741
-
742
- if (record.type === "throw") {
743
- context.method = "throw";
744
- context.arg = record.arg;
745
- context.delegate = null;
746
- return ContinueSentinel;
747
- }
748
-
749
- var info = record.arg;
750
-
751
- if (!info) {
752
- context.method = "throw";
753
- context.arg = new TypeError("iterator result is not an object");
754
- context.delegate = null;
755
- return ContinueSentinel;
756
- }
757
-
758
- if (info.done) {
759
- // Assign the result of the finished delegate to the temporary
760
- // variable specified by delegate.resultName (see delegateYield).
761
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
762
-
763
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
764
- // exception, let the outer generator proceed normally. If
765
- // context.method was "next", forget context.arg since it has been
766
- // "consumed" by the delegate iterator. If context.method was
767
- // "return", allow the original .return call to continue in the
768
- // outer generator.
769
-
770
- if (context.method !== "return") {
771
- context.method = "next";
772
- context.arg = undefined$1;
773
- }
774
- } else {
775
- // Re-yield the result returned by the delegate method.
776
- return info;
777
- } // The delegate iterator is finished, so forget it and continue with
778
- // the outer generator.
779
-
780
-
781
- context.delegate = null;
782
- return ContinueSentinel;
783
- } // Define Generator.prototype.{next,throw,return} in terms of the
784
- // unified ._invoke helper method.
785
-
786
-
787
- defineIteratorMethods(Gp);
788
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
789
- // @@iterator function is called on it. Some browsers' implementations of the
790
- // iterator prototype chain incorrectly implement this, causing the Generator
791
- // object to not be returned from this call. This ensures that doesn't happen.
792
- // See https://github.com/facebook/regenerator/issues/274 for more details.
793
-
794
- define(Gp, iteratorSymbol, function () {
795
- return this;
796
- });
797
- define(Gp, "toString", function () {
798
- return "[object Generator]";
799
- });
800
-
801
- function pushTryEntry(locs) {
802
- var entry = {
803
- tryLoc: locs[0]
804
- };
805
-
806
- if (1 in locs) {
807
- entry.catchLoc = locs[1];
808
- }
809
-
810
- if (2 in locs) {
811
- entry.finallyLoc = locs[2];
812
- entry.afterLoc = locs[3];
813
- }
814
-
815
- this.tryEntries.push(entry);
816
- }
817
-
818
- function resetTryEntry(entry) {
819
- var record = entry.completion || {};
820
- record.type = "normal";
821
- delete record.arg;
822
- entry.completion = record;
823
- }
824
-
825
- function Context(tryLocsList) {
826
- // The root entry object (effectively a try statement without a catch
827
- // or a finally block) gives us a place to store values thrown from
828
- // locations where there is no enclosing try statement.
829
- this.tryEntries = [{
830
- tryLoc: "root"
831
- }];
832
- tryLocsList.forEach(pushTryEntry, this);
833
- this.reset(true);
834
- }
835
-
836
- exports.keys = function (object) {
837
- var keys = [];
838
-
839
- for (var key in object) {
840
- keys.push(key);
841
- }
842
-
843
- keys.reverse(); // Rather than returning an object with a next method, we keep
844
- // things simple and return the next function itself.
845
-
846
- return function next() {
847
- while (keys.length) {
848
- var key = keys.pop();
849
-
850
- if (key in object) {
851
- next.value = key;
852
- next.done = false;
853
- return next;
854
- }
855
- } // To avoid creating an additional object, we just hang the .value
856
- // and .done properties off the next function object itself. This
857
- // also ensures that the minifier will not anonymize the function.
858
-
859
-
860
- next.done = true;
861
- return next;
862
- };
863
- };
864
-
865
- function values(iterable) {
866
- if (iterable) {
867
- var iteratorMethod = iterable[iteratorSymbol];
868
-
869
- if (iteratorMethod) {
870
- return iteratorMethod.call(iterable);
871
- }
872
-
873
- if (typeof iterable.next === "function") {
874
- return iterable;
875
- }
876
-
877
- if (!isNaN(iterable.length)) {
878
- var i = -1,
879
- next = function next() {
880
- while (++i < iterable.length) {
881
- if (hasOwn.call(iterable, i)) {
882
- next.value = iterable[i];
883
- next.done = false;
884
- return next;
885
- }
886
- }
887
-
888
- next.value = undefined$1;
889
- next.done = true;
890
- return next;
891
- };
892
-
893
- return next.next = next;
894
- }
895
- } // Return an iterator with no values.
896
-
897
-
898
- return {
899
- next: doneResult
900
- };
901
- }
902
-
903
- exports.values = values;
904
-
905
- function doneResult() {
906
- return {
907
- value: undefined$1,
908
- done: true
909
- };
910
- }
911
-
912
- Context.prototype = {
913
- constructor: Context,
914
- reset: function reset(skipTempReset) {
915
- this.prev = 0;
916
- this.next = 0; // Resetting context._sent for legacy support of Babel's
917
- // function.sent implementation.
918
-
919
- this.sent = this._sent = undefined$1;
920
- this.done = false;
921
- this.delegate = null;
922
- this.method = "next";
923
- this.arg = undefined$1;
924
- this.tryEntries.forEach(resetTryEntry);
925
-
926
- if (!skipTempReset) {
927
- for (var name in this) {
928
- // Not sure about the optimal order of these conditions:
929
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
930
- this[name] = undefined$1;
931
- }
932
- }
933
- }
934
- },
935
- stop: function stop() {
936
- this.done = true;
937
- var rootEntry = this.tryEntries[0];
938
- var rootRecord = rootEntry.completion;
939
-
940
- if (rootRecord.type === "throw") {
941
- throw rootRecord.arg;
942
- }
943
-
944
- return this.rval;
945
- },
946
- dispatchException: function dispatchException(exception) {
947
- if (this.done) {
948
- throw exception;
949
- }
950
-
951
- var context = this;
952
-
953
- function handle(loc, caught) {
954
- record.type = "throw";
955
- record.arg = exception;
956
- context.next = loc;
957
-
958
- if (caught) {
959
- // If the dispatched exception was caught by a catch block,
960
- // then let that catch block handle the exception normally.
961
- context.method = "next";
962
- context.arg = undefined$1;
963
- }
964
-
965
- return !!caught;
966
- }
967
-
968
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
969
- var entry = this.tryEntries[i];
970
- var record = entry.completion;
971
-
972
- if (entry.tryLoc === "root") {
973
- // Exception thrown outside of any try block that could handle
974
- // it, so set the completion value of the entire function to
975
- // throw the exception.
976
- return handle("end");
977
- }
978
-
979
- if (entry.tryLoc <= this.prev) {
980
- var hasCatch = hasOwn.call(entry, "catchLoc");
981
- var hasFinally = hasOwn.call(entry, "finallyLoc");
982
-
983
- if (hasCatch && hasFinally) {
984
- if (this.prev < entry.catchLoc) {
985
- return handle(entry.catchLoc, true);
986
- } else if (this.prev < entry.finallyLoc) {
987
- return handle(entry.finallyLoc);
988
- }
989
- } else if (hasCatch) {
990
- if (this.prev < entry.catchLoc) {
991
- return handle(entry.catchLoc, true);
992
- }
993
- } else if (hasFinally) {
994
- if (this.prev < entry.finallyLoc) {
995
- return handle(entry.finallyLoc);
996
- }
997
- } else {
998
- throw new Error("try statement without catch or finally");
999
- }
1000
- }
1001
- }
1002
- },
1003
- abrupt: function abrupt(type, arg) {
1004
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1005
- var entry = this.tryEntries[i];
1006
-
1007
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1008
- var finallyEntry = entry;
1009
- break;
1010
- }
1011
- }
1012
-
1013
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
1014
- // Ignore the finally entry if control is not jumping to a
1015
- // location outside the try/catch block.
1016
- finallyEntry = null;
1017
- }
1018
-
1019
- var record = finallyEntry ? finallyEntry.completion : {};
1020
- record.type = type;
1021
- record.arg = arg;
1022
-
1023
- if (finallyEntry) {
1024
- this.method = "next";
1025
- this.next = finallyEntry.finallyLoc;
1026
- return ContinueSentinel;
1027
- }
1028
-
1029
- return this.complete(record);
1030
- },
1031
- complete: function complete(record, afterLoc) {
1032
- if (record.type === "throw") {
1033
- throw record.arg;
1034
- }
1035
-
1036
- if (record.type === "break" || record.type === "continue") {
1037
- this.next = record.arg;
1038
- } else if (record.type === "return") {
1039
- this.rval = this.arg = record.arg;
1040
- this.method = "return";
1041
- this.next = "end";
1042
- } else if (record.type === "normal" && afterLoc) {
1043
- this.next = afterLoc;
1044
- }
1045
-
1046
- return ContinueSentinel;
1047
- },
1048
- finish: function finish(finallyLoc) {
1049
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1050
- var entry = this.tryEntries[i];
1051
-
1052
- if (entry.finallyLoc === finallyLoc) {
1053
- this.complete(entry.completion, entry.afterLoc);
1054
- resetTryEntry(entry);
1055
- return ContinueSentinel;
1056
- }
1057
- }
1058
- },
1059
- "catch": function _catch(tryLoc) {
1060
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1061
- var entry = this.tryEntries[i];
1062
-
1063
- if (entry.tryLoc === tryLoc) {
1064
- var record = entry.completion;
1065
-
1066
- if (record.type === "throw") {
1067
- var thrown = record.arg;
1068
- resetTryEntry(entry);
1069
- }
1070
-
1071
- return thrown;
1072
- }
1073
- } // The context.catch method must only be called with a location
1074
- // argument that corresponds to a known catch block.
1075
-
1076
-
1077
- throw new Error("illegal catch attempt");
1078
- },
1079
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1080
- this.delegate = {
1081
- iterator: values(iterable),
1082
- resultName: resultName,
1083
- nextLoc: nextLoc
1084
- };
1085
-
1086
- if (this.method === "next") {
1087
- // Deliberately forget the last sent value so that we don't
1088
- // accidentally pass it on to the delegate.
1089
- this.arg = undefined$1;
1090
- }
1091
-
1092
- return ContinueSentinel;
1093
- }
1094
- }; // Regardless of whether this script is executing as a CommonJS module
1095
- // or not, return the runtime object so that we can declare the variable
1096
- // regeneratorRuntime in the outer scope, which allows this module to be
1097
- // injected easily by `bin/regenerator --include-runtime script.js`.
1098
-
1099
- return exports;
1100
- }( // If this script is executing as a CommonJS module, use module.exports
1101
- // as the regeneratorRuntime namespace. Otherwise create a new empty
1102
- // object. Either way, the resulting object will be used to initialize
1103
- // the regeneratorRuntime variable at the top of this file.
1104
- module.exports );
1105
-
1106
- try {
1107
- regeneratorRuntime = runtime;
1108
- } catch (accidentalStrictMode) {
1109
- // This module should not be running in strict mode, so the above
1110
- // assignment should always work unless something is misconfigured. Just
1111
- // in case runtime.js accidentally runs in strict mode, in modern engines
1112
- // we can explicitly access globalThis. In older engines we can escape
1113
- // strict mode using a global Function call. This could conceivably fail
1114
- // if a Content Security Policy forbids using Function, but in that case
1115
- // the proper solution is to fix the accidental strict mode problem. If
1116
- // you've misconfigured your bundler to force strict mode and applied a
1117
- // CSP to forbid Function, and you're not willing to fix either of those
1118
- // problems, please detail your unique predicament in a GitHub issue.
1119
- if (typeof globalThis === "object") {
1120
- globalThis.regeneratorRuntime = runtime;
1121
- } else {
1122
- Function("r", "regeneratorRuntime = r")(runtime);
1123
- }
1124
- }
1125
- });
1126
-
1127
- var WiggleBaseRenderer = /*#__PURE__*/function (_FeatureRendererType) {
1128
- _inherits(WiggleBaseRenderer, _FeatureRendererType);
1129
-
1130
- var _super = /*#__PURE__*/_createSuper(WiggleBaseRenderer);
1131
-
1132
- function WiggleBaseRenderer() {
1133
- var _this;
1134
-
1135
- _classCallCheck(this, WiggleBaseRenderer);
1136
-
1137
- _this = _super.apply(this, arguments);
1138
- _this.supportsSVG = true;
1139
- return _this;
1140
- }
1141
-
1142
- _createClass(WiggleBaseRenderer, [{
1143
- key: "render",
1144
- value: function () {
1145
- var _render = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(renderProps) {
1146
- var _this2 = this;
1147
-
1148
- var features, height, regions, bpPerPx, _regions, region, width, res, results;
1149
-
1150
- return runtime_1.wrap(function _callee$(_context) {
1151
- while (1) {
1152
- switch (_context.prev = _context.next) {
1153
- case 0:
1154
- _context.next = 2;
1155
- return this.getFeatures(renderProps);
1156
-
1157
- case 2:
1158
- features = _context.sent;
1159
- height = renderProps.height, regions = renderProps.regions, bpPerPx = renderProps.bpPerPx;
1160
- _regions = _slicedToArray(regions, 1), region = _regions[0];
1161
- width = (region.end - region.start) / bpPerPx;
1162
- _context.next = 8;
1163
- return offscreenCanvasUtils.renderToAbstractCanvas(width, height, renderProps, function (ctx) {
1164
- return _this2.draw(ctx, _objectSpread2(_objectSpread2({}, renderProps), {}, {
1165
- features: features
1166
- }));
1167
- });
1168
-
1169
- case 8:
1170
- res = _context.sent;
1171
- _context.next = 11;
1172
- return _get(_getPrototypeOf(WiggleBaseRenderer.prototype), "render", this).call(this, _objectSpread2(_objectSpread2(_objectSpread2({}, renderProps), res), {}, {
1173
- features: features,
1174
- height: height,
1175
- width: width
1176
- }));
1177
-
1178
- case 11:
1179
- results = _context.sent;
1180
- return _context.abrupt("return", _objectSpread2(_objectSpread2(_objectSpread2({}, results), res), {}, {
1181
- features: features,
1182
- height: height,
1183
- width: width
1184
- }));
1185
-
1186
- case 13:
1187
- case "end":
1188
- return _context.stop();
1189
- }
1190
- }
1191
- }, _callee, this);
1192
- }));
1193
-
1194
- function render(_x) {
1195
- return _render.apply(this, arguments);
1196
- }
1197
-
1198
- return render;
1199
- }()
1200
- }]);
1201
-
1202
- return WiggleBaseRenderer;
1203
- }(FeatureRendererType);
1204
-
1205
- function WiggleRendering(props) {
1206
- var regions = props.regions,
1207
- features = props.features,
1208
- bpPerPx = props.bpPerPx,
1209
- width = props.width,
1210
- height = props.height,
1211
- _props$onMouseLeave = props.onMouseLeave,
1212
- _onMouseLeave = _props$onMouseLeave === void 0 ? function () {} : _props$onMouseLeave,
1213
- _props$onMouseMove = props.onMouseMove,
1214
- _onMouseMove = _props$onMouseMove === void 0 ? function () {} : _props$onMouseMove,
1215
- _props$onFeatureClick = props.onFeatureClick,
1216
- onFeatureClick = _props$onFeatureClick === void 0 ? function () {} : _props$onFeatureClick;
1217
-
1218
- var _regions = _slicedToArray(regions, 1),
1219
- region = _regions[0];
1220
-
1221
- var ref = React.useRef(null);
1222
-
1223
- function getFeatureUnderMouse(eventClientX) {
1224
- // calculates feature under mouse
1225
- var offset = 0;
1226
-
1227
- if (ref.current) {
1228
- offset = ref.current.getBoundingClientRect().left;
1229
- }
1230
-
1231
- var offsetX = eventClientX - offset;
1232
- var px = region.reversed ? width - offsetX : offsetX;
1233
- var clientBp = region.start + bpPerPx * px;
1234
- var featureUnderMouse;
1235
-
1236
- var _iterator = _createForOfIteratorHelper(features.values()),
1237
- _step;
1238
-
1239
- try {
1240
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1241
- var feature = _step.value;
1242
-
1243
- if (clientBp <= feature.get('end') && clientBp >= feature.get('start')) {
1244
- featureUnderMouse = feature;
1245
- break;
1246
- }
1247
- }
1248
- } catch (err) {
1249
- _iterator.e(err);
1250
- } finally {
1251
- _iterator.f();
1252
- }
1253
-
1254
- return featureUnderMouse;
1255
- }
1256
-
1257
- return React__default.createElement("div", {
1258
- ref: ref,
1259
- "data-testid": "wiggle-rendering-test",
1260
- onMouseMove: function onMouseMove(event) {
1261
- var featureUnderMouse = getFeatureUnderMouse(event.clientX);
1262
-
1263
- _onMouseMove(event, featureUnderMouse ? featureUnderMouse.id() : undefined);
1264
- },
1265
- onClick: function onClick(event) {
1266
- var featureUnderMouse = getFeatureUnderMouse(event.clientX);
1267
- onFeatureClick(event, featureUnderMouse ? featureUnderMouse.id() : undefined);
1268
- },
1269
- onMouseLeave: function onMouseLeave(event) {
1270
- return _onMouseLeave(event);
1271
- },
1272
- role: "presentation",
1273
- className: "WiggleRendering",
1274
- style: {
1275
- overflow: 'visible',
1276
- position: 'relative',
1277
- height: height
1278
- }
1279
- }, React__default.createElement(ui.PrerenderedCanvas, Object.assign({}, props)));
1280
- }
1281
-
1282
- var XYPlotRendererReactComponent = /*#__PURE__*/mobxReact.observer(WiggleRendering);
1283
-
1284
- var bigWigAdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchema('BigWigAdapter', {
1285
- bigWigLocation: {
1286
- type: 'fileLocation',
1287
- defaultValue: {
1288
- uri: '/path/to/my.bw',
1289
- locationType: 'UriLocation'
1290
- }
1291
- }
1292
- }, {
1293
- explicitlyTyped: true
1294
- });
1295
-
1296
- /**
1297
- * produces a d3-scale from arguments. applies a "nice domain" adjustment
1298
- *
1299
- * @param object - containing attributes
1300
- * - domain [min,max]
1301
- * - range [min,max]
1302
- * - bounds [min,max]
1303
- * - scaleType (linear or log)
1304
- * - pivotValue (number)
1305
- * - inverted (boolean)
1306
- */
1307
-
1308
- function getScale(_ref) {
1309
- var _ref$domain = _ref.domain,
1310
- domain = _ref$domain === void 0 ? [] : _ref$domain,
1311
- _ref$range = _ref.range,
1312
- range = _ref$range === void 0 ? [] : _ref$range,
1313
- scaleType = _ref.scaleType,
1314
- pivotValue = _ref.pivotValue,
1315
- inverted = _ref.inverted;
1316
- var scale;
1317
-
1318
- var _domain = _slicedToArray(domain, 2),
1319
- min = _domain[0],
1320
- max = _domain[1];
1321
-
1322
- if (min === undefined || max === undefined) {
1323
- throw new Error('invalid domain');
1324
- }
1325
-
1326
- if (scaleType === 'linear') {
1327
- scale = d3Scale.scaleLinear();
1328
- } else if (scaleType === 'log') {
1329
- scale = d3Scale.scaleLog();
1330
- scale.base(2);
1331
- } else if (scaleType === 'quantize') {
1332
- scale = d3Scale.scaleQuantize();
1333
- } else {
1334
- throw new Error('undefined scaleType');
1335
- }
1336
-
1337
- scale.domain(pivotValue !== undefined ? [min, pivotValue, max] : [min, max]);
1338
- scale.nice();
1339
-
1340
- var _range = _slicedToArray(range, 2),
1341
- rangeMin = _range[0],
1342
- rangeMax = _range[1];
1343
-
1344
- if (rangeMin === undefined || rangeMax === undefined) {
1345
- throw new Error('invalid range');
1346
- }
1347
-
1348
- scale.range(inverted ? range.slice().reverse() : range);
1349
- return scale;
1350
- }
1351
- /**
1352
- * gets the origin for drawing the graph. for linear this is 0, for log this is arbitrarily set to log(1)==0
1353
- *
1354
- * @param scaleType -
1355
- */
1356
-
1357
- function getOrigin(scaleType
1358
- /* , pivot, stats */
1359
- ) {
1360
- // if (pivot) {
1361
- // if (pivot === 'mean') {
1362
- // return stats.scoreMean || 0
1363
- // }
1364
- // if (pivot === 'zero') {
1365
- // return 0
1366
- // }
1367
- // return parseFloat()
1368
- // }
1369
- // if (scaleType === 'z_score') {
1370
- // return stats.scoreMean || 0
1371
- // }
1372
- if (scaleType === 'log') {
1373
- return 1;
1374
- }
1375
-
1376
- return 0;
1377
- }
1378
- /**
1379
- * produces a "nice" domain that actually rounds down to 0 for the min
1380
- * or 0 to the max depending on if all values are positive or negative
1381
- *
1382
- * @param object - containing attributes
1383
- * - domain [min,max]
1384
- * - bounds [min,max]
1385
- * - mean
1386
- * - stddev
1387
- * - scaleType (linear or log)
1388
- */
1389
-
1390
- function getNiceDomain(_ref2) {
1391
- var scaleType = _ref2.scaleType,
1392
- domain = _ref2.domain,
1393
- bounds = _ref2.bounds;
1394
-
1395
- var _bounds = _slicedToArray(bounds, 2),
1396
- minScore = _bounds[0],
1397
- maxScore = _bounds[1];
1398
-
1399
- var _domain2 = _slicedToArray(domain, 2),
1400
- min = _domain2[0],
1401
- max = _domain2[1];
1402
-
1403
- if (scaleType === 'linear') {
1404
- if (max < 0) {
1405
- max = 0;
1406
- }
1407
-
1408
- if (min > 0) {
1409
- min = 0;
1410
- }
1411
- }
1412
-
1413
- if (scaleType === 'log') {
1414
- // if the min is 0, assume that it's just something
1415
- // with no read coverage and that we should ignore it in calculations
1416
- // if it's greater than 1 pin to 1 for the full range also
1417
- // otherwise, we may see bigwigs with fractional values
1418
- if (min === 0 || min > 1) {
1419
- min = 1;
1420
- }
1421
- }
1422
-
1423
- if (min === undefined || max === undefined) {
1424
- throw new Error('invalid domain supplied to stats function');
1425
- }
1426
-
1427
- if (minScore !== undefined && minScore !== Number.MIN_VALUE) {
1428
- min = minScore;
1429
- }
1430
-
1431
- if (maxScore !== undefined && maxScore !== Number.MAX_VALUE) {
1432
- max = maxScore;
1433
- }
1434
-
1435
- var getScaleType = function getScaleType(type) {
1436
- if (type === 'linear') {
1437
- return d3Scale.scaleLinear();
1438
- }
1439
-
1440
- if (type === 'log') {
1441
- var _scale = d3Scale.scaleLog();
1442
-
1443
- _scale.base(2);
1444
-
1445
- return _scale;
1446
- }
1447
-
1448
- if (type === 'quantize') {
1449
- return d3Scale.scaleQuantize();
1450
- }
1451
-
1452
- throw new Error("undefined scaleType ".concat(type));
1453
- };
1454
-
1455
- var scale = getScaleType(scaleType);
1456
- scale.domain([min, max]);
1457
- scale.nice();
1458
- return scale.domain();
1459
- }
1460
-
1461
- var utils = {
1462
- __proto__: null,
1463
- getScale: getScale,
1464
- getOrigin: getOrigin,
1465
- getNiceDomain: getNiceDomain
1466
- };
1467
-
1468
- var ConfigSchema = /*#__PURE__*/configuration.ConfigurationSchema('WiggleRenderer', {
1469
- color: {
1470
- type: 'color',
1471
- description: 'the color of track, overrides posColor and negColor',
1472
- defaultValue: '#f0f'
1473
- },
1474
- posColor: {
1475
- type: 'color',
1476
- description: 'the color to use when the score is positive',
1477
- defaultValue: 'blue'
1478
- },
1479
- negColor: {
1480
- type: 'color',
1481
- description: 'the color to use when the score is negative',
1482
- defaultValue: 'red'
1483
- },
1484
- highlightColor: {
1485
- type: 'color',
1486
- description: 'the color of highlights over the wiggle track',
1487
- defaultValue: 'rgba(255,255,0,0.5)'
1488
- },
1489
- clipColor: {
1490
- type: 'color',
1491
- description: 'the color of the clipping marker',
1492
- defaultValue: 'red'
1493
- },
1494
- renderType: {
1495
- type: 'stringEnum',
1496
- model: /*#__PURE__*/mobxStateTree.types.enumeration('Rendering type', ['xyplot', 'density', 'line']),
1497
- description: 'The type of rendering for wiggle data to use',
1498
- defaultValue: 'xyplot'
1499
- },
1500
- filled: {
1501
- type: 'boolean',
1502
- description: 'fill in histogram',
1503
- defaultValue: true
1504
- },
1505
- bicolorPivot: {
1506
- type: 'stringEnum',
1507
- model: /*#__PURE__*/mobxStateTree.types.enumeration('Scale type', ['numeric', 'mean', 'z_score', 'none']),
1508
- description: 'type of bicolor pivot',
1509
- defaultValue: 'numeric'
1510
- },
1511
- bicolorPivotValue: {
1512
- type: 'number',
1513
- defaultValue: 0,
1514
- description: 'value to use for bicolor pivot'
1515
- },
1516
- summaryScoreMode: {
1517
- type: 'stringEnum',
1518
- model: /*#__PURE__*/mobxStateTree.types.enumeration('Score type', ['max', 'min', 'avg', 'whiskers']),
1519
- description: 'choose whether to use max/min/average or whiskers which combines all three into the same rendering',
1520
- defaultValue: 'whiskers'
1521
- },
1522
- displayCrossHatches: {
1523
- type: 'boolean',
1524
- description: 'choose to draw cross hatches (sideways lines)',
1525
- defaultValue: false
1526
- }
1527
- }, {
1528
- explicitlyTyped: true
1529
- });
1530
-
1531
- var DensityRenderer = /*#__PURE__*/function (_WiggleBaseRenderer) {
1532
- _inherits(DensityRenderer, _WiggleBaseRenderer);
1533
-
1534
- var _super = /*#__PURE__*/_createSuper(DensityRenderer);
1535
-
1536
- function DensityRenderer() {
1537
- _classCallCheck(this, DensityRenderer);
1538
-
1539
- return _super.apply(this, arguments);
1540
- }
1541
-
1542
- _createClass(DensityRenderer, [{
1543
- key: "draw",
1544
- value: function draw(ctx, props) {
1545
- var features = props.features,
1546
- regions = props.regions,
1547
- bpPerPx = props.bpPerPx,
1548
- scaleOpts = props.scaleOpts,
1549
- height = props.height,
1550
- config = props.config;
1551
-
1552
- var _regions = _slicedToArray(regions, 1),
1553
- region = _regions[0];
1554
-
1555
- var pivot = configuration.readConfObject(config, 'bicolorPivot');
1556
- var pivotValue = configuration.readConfObject(config, 'bicolorPivotValue');
1557
- var negColor = configuration.readConfObject(config, 'negColor');
1558
- var posColor = configuration.readConfObject(config, 'posColor');
1559
- var color = configuration.readConfObject(config, 'color');
1560
- var colorCallback;
1561
-
1562
- if (color === '#f0f') {
1563
- var colorScale = pivot !== 'none' ? getScale(_objectSpread2(_objectSpread2({}, scaleOpts), {}, {
1564
- pivotValue: pivotValue,
1565
- range: [negColor, 'white', posColor]
1566
- })) : getScale(_objectSpread2(_objectSpread2({}, scaleOpts), {}, {
1567
- range: ['white', posColor]
1568
- }));
1569
-
1570
- colorCallback = function colorCallback(feature) {
1571
- return colorScale(feature.get('score'));
1572
- };
1573
- } else {
1574
- colorCallback = function colorCallback(feature) {
1575
- return configuration.readConfObject(config, 'color', {
1576
- feature: feature
1577
- });
1578
- };
1579
- }
1580
-
1581
- var _iterator = _createForOfIteratorHelper(features.values()),
1582
- _step;
1583
-
1584
- try {
1585
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1586
- var feature = _step.value;
1587
-
1588
- var _featureSpanPx = util.featureSpanPx(feature, region, bpPerPx),
1589
- _featureSpanPx2 = _slicedToArray(_featureSpanPx, 2),
1590
- leftPx = _featureSpanPx2[0],
1591
- rightPx = _featureSpanPx2[1];
1592
-
1593
- var w = rightPx - leftPx + 0.3; // fudge factor for subpixel rendering
1594
-
1595
- ctx.fillStyle = colorCallback(feature);
1596
- ctx.fillRect(leftPx, 0, w, height);
1597
- }
1598
- } catch (err) {
1599
- _iterator.e(err);
1600
- } finally {
1601
- _iterator.f();
1602
- }
1603
- }
1604
- }]);
1605
-
1606
- return DensityRenderer;
1607
- }(WiggleBaseRenderer);
1608
- var configSchema = /*#__PURE__*/configuration.ConfigurationSchema('DensityRenderer', {}, {
1609
- baseConfiguration: ConfigSchema,
1610
- explicitlyTyped: true
1611
- });
1612
-
1613
- function WiggleConfigFactory(pluginManager) {
1614
- var XYPlotRendererConfigSchema = pluginManager.getRendererType('XYPlotRenderer').configSchema;
1615
- var DensityRendererConfigSchema = pluginManager.getRendererType('DensityRenderer').configSchema;
1616
- var LinePlotRendererConfigSchema = pluginManager.getRendererType('LinePlotRenderer').configSchema;
1617
- return configuration.ConfigurationSchema('LinearWiggleDisplay', {
1618
- autoscale: {
1619
- type: 'stringEnum',
1620
- defaultValue: 'local',
1621
- model: mobxStateTree.types.enumeration('Autoscale type', ['global', 'local', 'globalsd', 'localsd', 'zscore']),
1622
- description: 'global/local using their min/max values or w/ standard deviations (globalsd/localsd)'
1623
- },
1624
- minimalTicks: {
1625
- type: 'boolean',
1626
- defaultValue: false,
1627
- description: 'use the minimal amount of ticks'
1628
- },
1629
- minScore: {
1630
- type: 'number',
1631
- defaultValue: Number.MIN_VALUE,
1632
- description: 'minimum value for the y-scale'
1633
- },
1634
- maxScore: {
1635
- type: 'number',
1636
- description: 'maximum value for the y-scale',
1637
- defaultValue: Number.MAX_VALUE
1638
- },
1639
- numStdDev: {
1640
- type: 'number',
1641
- description: 'number of standard deviations to use for autoscale types globalsd or localsd',
1642
- defaultValue: 3
1643
- },
1644
- scaleType: {
1645
- type: 'stringEnum',
1646
- model: mobxStateTree.types.enumeration('Scale type', ['linear', 'log']),
1647
- description: 'The type of scale to use',
1648
- defaultValue: 'linear'
1649
- },
1650
- inverted: {
1651
- type: 'boolean',
1652
- description: 'draw upside down',
1653
- defaultValue: false
1654
- },
1655
- defaultRendering: {
1656
- type: 'stringEnum',
1657
- model: mobxStateTree.types.enumeration('Rendering', ['density', 'xyplot', 'line']),
1658
- defaultValue: 'xyplot'
1659
- },
1660
- renderers: configuration.ConfigurationSchema('RenderersConfiguration', {
1661
- DensityRenderer: DensityRendererConfigSchema,
1662
- XYPlotRenderer: XYPlotRendererConfigSchema,
1663
- LinePlotRenderer: LinePlotRendererConfigSchema
1664
- })
1665
- }, {
1666
- baseConfiguration: pluginLinearGenomeView.baseLinearDisplayConfigSchema,
1667
- explicitlyTyped: true
1668
- });
1669
- }
1670
-
1671
- function toP() {
1672
- var s = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1673
- return +(+s).toPrecision(6);
1674
- }
1675
-
1676
- function round(value) {
1677
- return Math.round(value * 1e5) / 1e5;
1678
- }
1679
-
1680
- var en = function en(n) {
1681
- return n.toLocaleString('en-US');
1682
- };
1683
-
1684
- var useStyles = /*#__PURE__*/core.makeStyles(function (theme) {
1685
- return {
1686
- // these styles come from
1687
- // https://github.com/mui-org/material-ui/blob/master/packages/material-ui/src/Tooltip/Tooltip.js
1688
- tooltip: {
1689
- position: 'absolute',
1690
- pointerEvents: 'none',
1691
- backgroundColor: core.alpha(theme.palette.grey[700], 0.9),
1692
- borderRadius: theme.shape.borderRadius,
1693
- color: theme.palette.common.white,
1694
- fontFamily: theme.typography.fontFamily,
1695
- padding: '4px 8px',
1696
- fontSize: theme.typography.pxToRem(12),
1697
- lineHeight: "".concat(round(14 / 10), "em"),
1698
- maxWidth: 300,
1699
- wordWrap: 'break-word'
1700
- },
1701
- hoverVertical: {
1702
- background: '#333',
1703
- border: 'none',
1704
- width: 1,
1705
- height: '100%',
1706
- top: YSCALEBAR_LABEL_OFFSET,
1707
- cursor: 'default',
1708
- position: 'absolute',
1709
- pointerEvents: 'none'
1710
- }
1711
- };
1712
- });
1713
- var TooltipContents = /*#__PURE__*/React__default.forwardRef(function (_ref, ref) {
1714
- var feature = _ref.feature;
1715
- var start = feature.get('start');
1716
- var end = feature.get('end');
1717
- var name = feature.get('refName');
1718
- var loc = [name, start === end ? en(start) : "".concat(en(start), "..").concat(en(end))].filter(function (f) {
1719
- return !!f;
1720
- }).join(':');
1721
- return feature.get('summary') !== undefined ? React__default.createElement("div", {
1722
- ref: ref
1723
- }, loc, React__default.createElement("br", null), "Max: ", toP(feature.get('maxScore')), React__default.createElement("br", null), "Avg: ", toP(feature.get('score')), React__default.createElement("br", null), "Min: ", toP(feature.get('minScore'))) : React__default.createElement("div", {
1724
- ref: ref
1725
- }, loc, React__default.createElement("br", null), "".concat(toP(feature.get('score'))));
1726
- });
1727
- var Tooltip = /*#__PURE__*/mobxReact.observer(function (_ref2) {
1728
- var model = _ref2.model,
1729
- height = _ref2.height,
1730
- clientMouseCoord = _ref2.clientMouseCoord,
1731
- offsetMouseCoord = _ref2.offsetMouseCoord,
1732
- clientRect = _ref2.clientRect,
1733
- TooltipContents = _ref2.TooltipContents;
1734
- var featureUnderMouse = model.featureUnderMouse;
1735
-
1736
- var _useState = React.useState(0),
1737
- _useState2 = _slicedToArray(_useState, 2),
1738
- width = _useState2[0],
1739
- setWidth = _useState2[1];
1740
-
1741
- var _useState3 = React.useState(null),
1742
- _useState4 = _slicedToArray(_useState3, 2),
1743
- anchorEl = _useState4[0],
1744
- setAnchorEl = _useState4[1];
1745
-
1746
- var classes = useStyles(); // must be memoized a la https://github.com/popperjs/react-popper/issues/391
1747
-
1748
- var virtElement = React.useMemo(function () {
1749
- return {
1750
- getBoundingClientRect: function getBoundingClientRect() {
1751
- var x = clientMouseCoord[0] + width / 2 + 20;
1752
- var y = (clientRect === null || clientRect === void 0 ? void 0 : clientRect.top) || 0;
1753
- return {
1754
- top: y,
1755
- left: x,
1756
- bottom: y,
1757
- right: x,
1758
- width: 0,
1759
- height: 0,
1760
- x: x,
1761
- y: y,
1762
- toJSON: function toJSON() {}
1763
- };
1764
- }
1765
- };
1766
- }, [clientRect === null || clientRect === void 0 ? void 0 : clientRect.top, clientMouseCoord, width]);
1767
-
1768
- var _usePopper = reactPopper.usePopper(virtElement, anchorEl),
1769
- styles = _usePopper.styles,
1770
- attributes = _usePopper.attributes;
1771
-
1772
- return featureUnderMouse ? React__default.createElement(React__default.Fragment, null, React__default.createElement(core.Portal, null, React__default.createElement("div", Object.assign({
1773
- ref: setAnchorEl,
1774
- className: classes.tooltip,
1775
- // zIndex needed to go over widget drawer
1776
- style: _objectSpread2(_objectSpread2({}, styles.popper), {}, {
1777
- zIndex: 100000
1778
- })
1779
- }, attributes.popper), React__default.createElement(TooltipContents, {
1780
- ref: function ref(elt) {
1781
- setWidth((elt === null || elt === void 0 ? void 0 : elt.getBoundingClientRect().width) || 0);
1782
- },
1783
- feature: featureUnderMouse
1784
- }))), React__default.createElement("div", {
1785
- className: classes.hoverVertical,
1786
- style: {
1787
- left: offsetMouseCoord[0],
1788
- height: height - YSCALEBAR_LABEL_OFFSET * 2
1789
- }
1790
- })) : null;
1791
- });
1792
- var WiggleTooltip = /*#__PURE__*/mobxReact.observer(function (props) {
1793
- return React__default.createElement(Tooltip, Object.assign({
1794
- TooltipContents: TooltipContents
1795
- }, props));
1796
- });
1797
-
1798
- var YScaleBar = /*#__PURE__*/mobxReact.observer(function (_ref) {
1799
- var model = _ref.model,
1800
- orientation = _ref.orientation;
1801
- var ticks = model.ticks;
1802
- return ticks ? React__default.createElement(reactD3AxisMod.Axis, Object.assign({}, ticks, {
1803
- shadow: 2,
1804
- format: function format(n) {
1805
- return n;
1806
- },
1807
- style: {
1808
- orient: orientation === 'left' ? reactD3AxisMod.LEFT : reactD3AxisMod.RIGHT
1809
- }
1810
- })) : null;
1811
- });
1812
-
1813
- var LinearWiggleDisplay = /*#__PURE__*/mobxReact.observer(function (props) {
1814
- var model = props.model;
1815
- var stats = model.stats,
1816
- height = model.height,
1817
- needsScalebar = model.needsScalebar; // @ts-ignore
1818
-
1819
- var _getContainingView = util.getContainingView(model),
1820
- trackLabels = _getContainingView.trackLabels;
1821
-
1822
- var left = trackLabels === 'overlapping' ? util.measureText(configuration.getConf(util.getContainingTrack(model), 'name'), 12.8) + 100 : 50;
1823
- return React__default.createElement("div", null, React__default.createElement(pluginLinearGenomeView.BaseLinearDisplayComponent, Object.assign({}, props)), stats && needsScalebar ? React__default.createElement("svg", {
1824
- style: {
1825
- position: 'absolute',
1826
- top: 0,
1827
- left: left,
1828
- pointerEvents: 'none',
1829
- height: height,
1830
- width: 50
1831
- }
1832
- }, React__default.createElement(YScaleBar, {
1833
- model: model
1834
- })) : null);
1835
- });
1836
-
1837
- var SetMinMaxDlg = /*#__PURE__*/React.lazy(function () {
1838
- return Promise.resolve().then(function () { return SetMinMaxDialog; });
1839
- });
1840
- var SetColorDlg = /*#__PURE__*/React.lazy(function () {
1841
- return Promise.resolve().then(function () { return SetColorDialog$1; });
1842
- }); // fudge factor for making all labels on the YScalebar visible
1843
-
1844
- var YSCALEBAR_LABEL_OFFSET = 5; // using a map because it preserves order
1845
-
1846
- var rendererTypes = /*#__PURE__*/new Map([['xyplot', 'XYPlotRenderer'], ['density', 'DensityRenderer'], ['line', 'LinePlotRenderer']]);
1847
-
1848
- var stateModelFactory = function stateModelFactory(pluginManager, configSchema) {
1849
- return mobxStateTree.types.compose('LinearWiggleDisplay', pluginLinearGenomeView.BaseLinearDisplay, mobxStateTree.types.model({
1850
- type: mobxStateTree.types.literal('LinearWiggleDisplay'),
1851
- configuration: configuration.ConfigurationReference(configSchema),
1852
- selectedRendering: mobxStateTree.types.optional(mobxStateTree.types.string, ''),
1853
- resolution: mobxStateTree.types.optional(mobxStateTree.types.number, 1),
1854
- fill: mobxStateTree.types.maybe(mobxStateTree.types["boolean"]),
1855
- color: mobxStateTree.types.maybe(mobxStateTree.types.string),
1856
- posColor: mobxStateTree.types.maybe(mobxStateTree.types.string),
1857
- negColor: mobxStateTree.types.maybe(mobxStateTree.types.string),
1858
- summaryScoreMode: mobxStateTree.types.maybe(mobxStateTree.types.string),
1859
- rendererTypeNameState: mobxStateTree.types.maybe(mobxStateTree.types.string),
1860
- scale: mobxStateTree.types.maybe(mobxStateTree.types.string),
1861
- autoscale: mobxStateTree.types.maybe(mobxStateTree.types.string),
1862
- displayCrossHatches: mobxStateTree.types.maybe(mobxStateTree.types["boolean"]),
1863
- constraints: mobxStateTree.types.optional(mobxStateTree.types.model({
1864
- max: mobxStateTree.types.maybe(mobxStateTree.types.number),
1865
- min: mobxStateTree.types.maybe(mobxStateTree.types.number)
1866
- }), {})
1867
- }))["volatile"](function () {
1868
- return {
1869
- statsReady: false,
1870
- message: undefined,
1871
- stats: {
1872
- scoreMin: 0,
1873
- scoreMax: 50
1874
- },
1875
- statsFetchInProgress: undefined
1876
- };
1877
- }).actions(function (self) {
1878
- return {
1879
- updateStats: function updateStats(_ref) {
1880
- var scoreMin = _ref.scoreMin,
1881
- scoreMax = _ref.scoreMax;
1882
-
1883
- if (self.stats.scoreMin !== scoreMin || self.stats.scoreMax !== scoreMax) {
1884
- self.stats = {
1885
- scoreMin: scoreMin,
1886
- scoreMax: scoreMax
1887
- };
1888
- }
1889
-
1890
- self.statsReady = true;
1891
- },
1892
- setColor: function setColor(color) {
1893
- self.color = color;
1894
- },
1895
- setPosColor: function setPosColor(color) {
1896
- self.posColor = color;
1897
- },
1898
- setNegColor: function setNegColor(color) {
1899
- self.negColor = color;
1900
- },
1901
- setLoading: function setLoading(aborter) {
1902
- var statsFetch = self.statsFetchInProgress;
1903
-
1904
- if (statsFetch !== undefined && !statsFetch.signal.aborted) {
1905
- statsFetch.abort();
1906
- }
1907
-
1908
- self.statsFetchInProgress = aborter;
1909
- },
1910
- // this overrides the BaseLinearDisplayModel to avoid popping up a
1911
- // feature detail display, but still sets the feature selection on the
1912
- // model so listeners can detect a click
1913
- selectFeature: function selectFeature(feature) {
1914
- var session = util.getSession(self);
1915
-
1916
- if (util.isSelectionContainer(session)) {
1917
- session.setSelection(feature);
1918
- }
1919
- },
1920
- setResolution: function setResolution(res) {
1921
- self.resolution = res;
1922
- },
1923
- setFill: function setFill(fill) {
1924
- self.fill = fill;
1925
- },
1926
- toggleLogScale: function toggleLogScale() {
1927
- if (self.scale !== 'log') {
1928
- self.scale = 'log';
1929
- } else {
1930
- self.scale = 'linear';
1931
- }
1932
- },
1933
- setScaleType: function setScaleType(scale) {
1934
- self.scale = scale;
1935
- },
1936
- setSummaryScoreMode: function setSummaryScoreMode(val) {
1937
- self.summaryScoreMode = val;
1938
- },
1939
- setAutoscale: function setAutoscale(val) {
1940
- self.autoscale = val;
1941
- },
1942
- setMaxScore: function setMaxScore(val) {
1943
- self.constraints.max = val;
1944
- },
1945
- setRendererType: function setRendererType(val) {
1946
- self.rendererTypeNameState = val;
1947
- },
1948
- setMinScore: function setMinScore(val) {
1949
- self.constraints.min = val;
1950
- },
1951
- toggleCrossHatches: function toggleCrossHatches() {
1952
- self.displayCrossHatches = !self.displayCrossHatches;
1953
- },
1954
- setCrossHatches: function setCrossHatches(cross) {
1955
- self.displayCrossHatches = cross;
1956
- }
1957
- };
1958
- }).views(function (self) {
1959
- return {
1960
- get TooltipComponent() {
1961
- return WiggleTooltip;
1962
- },
1963
-
1964
- get adapterTypeName() {
1965
- return self.adapterConfig.type;
1966
- },
1967
-
1968
- get rendererTypeName() {
1969
- var viewName = self.rendererTypeNameState || configuration.getConf(self, 'defaultRendering');
1970
- var rendererType = rendererTypes.get(viewName);
1971
-
1972
- if (!rendererType) {
1973
- throw new Error("unknown alignments view name ".concat(viewName));
1974
- }
1975
-
1976
- return rendererType;
1977
- },
1978
-
1979
- // subclasses can define these, as snpcoverage track does
1980
- get filters() {
1981
- return undefined;
1982
- },
1983
-
1984
- get scaleType() {
1985
- return self.scale || configuration.getConf(self, 'scaleType');
1986
- },
1987
-
1988
- get maxScore() {
1989
- var max = self.constraints.max;
1990
- return max !== undefined ? max : configuration.getConf(self, 'maxScore');
1991
- },
1992
-
1993
- get minScore() {
1994
- var min = self.constraints.min;
1995
- return min !== undefined ? min : configuration.getConf(self, 'minScore');
1996
- }
1997
-
1998
- };
1999
- }).views(function (self) {
2000
- return {
2001
- get rendererConfig() {
2002
- var configBlob = configuration.getConf(self, ['renderers', self.rendererTypeName]) || {};
2003
- return self.rendererType.configSchema.create(_objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, configBlob), {}, {
2004
- filled: self.fill,
2005
- scaleType: self.scaleType,
2006
- displayCrossHatches: self.displayCrossHatches,
2007
- summaryScoreMode: self.summaryScoreMode
2008
- }, self.color ? {
2009
- color: self.color
2010
- } : {}), self.negColor ? {
2011
- negColor: self.negColor
2012
- } : {}), self.posColor ? {
2013
- posColor: self.posColor
2014
- } : {}), mobxStateTree.getEnv(self));
2015
- }
2016
-
2017
- };
2018
- }).views(function (self) {
2019
- var oldDomain = [0, 0];
2020
- return {
2021
- get filled() {
2022
- return typeof self.fill !== 'undefined' ? self.fill : configuration.readConfObject(self.rendererConfig, 'filled');
2023
- },
2024
-
2025
- get summaryScoreModeSetting() {
2026
- return self.summaryScoreMode || configuration.readConfObject(self.rendererConfig, 'summaryScoreMode');
2027
- },
2028
-
2029
- get domain() {
2030
- var stats = self.stats,
2031
- scaleType = self.scaleType,
2032
- minScore = self.minScore,
2033
- maxScore = self.maxScore;
2034
- var scoreMin = stats.scoreMin,
2035
- scoreMax = stats.scoreMax;
2036
- var ret = getNiceDomain({
2037
- domain: [scoreMin, scoreMax],
2038
- bounds: [minScore, maxScore],
2039
- scaleType: scaleType
2040
- }); // avoid weird scalebar if log value and empty region displayed
2041
-
2042
- if (scaleType === 'log' && ret[1] === Number.MIN_VALUE) {
2043
- return [0, Number.MIN_VALUE];
2044
- } // avoid returning a new object if it matches the old value
2045
-
2046
-
2047
- if (JSON.stringify(oldDomain) !== JSON.stringify(ret)) {
2048
- oldDomain = ret;
2049
- }
2050
-
2051
- return oldDomain;
2052
- },
2053
-
2054
- get needsScalebar() {
2055
- return self.rendererTypeName === 'XYPlotRenderer' || self.rendererTypeName === 'LinePlotRenderer';
2056
- },
2057
-
2058
- get scaleOpts() {
2059
- return {
2060
- domain: this.domain,
2061
- stats: self.stats,
2062
- autoscaleType: this.autoscaleType,
2063
- scaleType: self.scaleType,
2064
- inverted: configuration.getConf(self, 'inverted')
2065
- };
2066
- },
2067
-
2068
- get canHaveFill() {
2069
- return self.rendererTypeName === 'XYPlotRenderer';
2070
- },
2071
-
2072
- get autoscaleType() {
2073
- return self.autoscale || configuration.getConf(self, 'autoscale');
2074
- },
2075
-
2076
- get displayCrossHatchesSetting() {
2077
- return self.displayCrossHatches || configuration.readConfObject(self.rendererConfig, 'displayCrossHatches');
2078
- }
2079
-
2080
- };
2081
- }).views(function (self) {
2082
- return {
2083
- get ticks() {
2084
- var scaleType = self.scaleType,
2085
- domain = self.domain,
2086
- height = self.height;
2087
- var minimalTicks = configuration.getConf(self, 'minimalTicks');
2088
- var range = [height - YSCALEBAR_LABEL_OFFSET, YSCALEBAR_LABEL_OFFSET];
2089
- var scale = getScale({
2090
- scaleType: scaleType,
2091
- domain: domain,
2092
- range: range,
2093
- inverted: configuration.getConf(self, 'inverted')
2094
- });
2095
- var ticks = reactD3AxisMod.axisPropsFromTickScale(scale, 4);
2096
- return height < 100 || minimalTicks ? _objectSpread2(_objectSpread2({}, ticks), {}, {
2097
- values: domain
2098
- }) : ticks;
2099
- }
2100
-
2101
- };
2102
- }).views(function (self) {
2103
- var superRenderProps = self.renderProps;
2104
- return {
2105
- renderProps: function renderProps() {
2106
- var superProps = superRenderProps();
2107
- return _objectSpread2(_objectSpread2({}, superProps), {}, {
2108
- notReady: superProps.notReady || !self.statsReady,
2109
- rpcDriverName: self.rpcDriverName,
2110
- displayModel: self,
2111
- config: self.rendererConfig,
2112
- scaleOpts: self.scaleOpts,
2113
- resolution: self.resolution,
2114
- height: self.height,
2115
- ticks: self.ticks,
2116
- displayCrossHatches: self.displayCrossHatches,
2117
- filters: self.filters
2118
- });
2119
- },
2120
-
2121
- get adapterCapabilities() {
2122
- return pluginManager.getAdapterType(self.adapterTypeName).adapterCapabilities;
2123
- },
2124
-
2125
- get hasResolution() {
2126
- return this.adapterCapabilities.includes('hasResolution');
2127
- },
2128
-
2129
- get hasGlobalStats() {
2130
- return this.adapterCapabilities.includes('hasGlobalStats');
2131
- }
2132
-
2133
- };
2134
- }).views(function (self) {
2135
- var superTrackMenuItems = self.trackMenuItems;
2136
- return {
2137
- trackMenuItems: function trackMenuItems() {
2138
- return [].concat(_toConsumableArray(superTrackMenuItems()), _toConsumableArray(self.hasResolution ? [{
2139
- label: 'Resolution',
2140
- subMenu: [{
2141
- label: 'Finer resolution',
2142
- onClick: function onClick() {
2143
- self.setResolution(self.resolution * 5);
2144
- }
2145
- }, {
2146
- label: 'Coarser resolution',
2147
- onClick: function onClick() {
2148
- self.setResolution(self.resolution / 5);
2149
- }
2150
- }]
2151
- }, {
2152
- label: 'Summary score mode',
2153
- subMenu: ['min', 'max', 'avg', 'whiskers'].map(function (elt) {
2154
- return {
2155
- label: elt,
2156
- onClick: function onClick() {
2157
- return self.setSummaryScoreMode(elt);
2158
- }
2159
- };
2160
- })
2161
- }] : []), _toConsumableArray(self.canHaveFill ? [{
2162
- label: self.filled ? 'Turn off histogram fill' : 'Turn on histogram fill',
2163
- onClick: function onClick() {
2164
- self.setFill(!self.filled);
2165
- }
2166
- }] : []), [{
2167
- label: self.scaleType === 'log' ? 'Set linear scale' : 'Set log scale',
2168
- onClick: function onClick() {
2169
- self.toggleLogScale();
2170
- }
2171
- }, {
2172
- type: 'checkbox',
2173
- label: 'Draw cross hatches',
2174
- checked: self.displayCrossHatchesSetting,
2175
- onClick: function onClick() {
2176
- self.toggleCrossHatches();
2177
- }
2178
- }], _toConsumableArray(Object.keys(configuration.getConf(self, 'renderers') || {}).length > 1 ? [{
2179
- label: 'Renderer type',
2180
- subMenu: _toConsumableArray(rendererTypes.keys()).map(function (key) {
2181
- return {
2182
- label: key,
2183
- onClick: function onClick() {
2184
- return self.setRendererType(key);
2185
- }
2186
- };
2187
- })
2188
- }] : []), [{
2189
- label: 'Autoscale type',
2190
- subMenu: [['local', 'Local']].concat(_toConsumableArray(self.hasGlobalStats ? [['global', 'Global'], ['globalsd', 'Global ± 3σ']] : []), [['localsd', 'Local ± 3σ']]).map(function (_ref2) {
2191
- var _ref3 = _slicedToArray(_ref2, 2),
2192
- val = _ref3[0],
2193
- label = _ref3[1];
2194
-
2195
- return {
2196
- label: label,
2197
- onClick: function onClick() {
2198
- self.setAutoscale(val);
2199
- }
2200
- };
2201
- })
2202
- }, {
2203
- label: 'Set min/max score',
2204
- onClick: function onClick() {
2205
- util.getSession(self).queueDialog(function (doneCallback) {
2206
- return [SetMinMaxDlg, {
2207
- model: self,
2208
- handleClose: doneCallback
2209
- }];
2210
- });
2211
- }
2212
- }, {
2213
- label: 'Set color',
2214
- onClick: function onClick() {
2215
- util.getSession(self).queueDialog(function (doneCallback) {
2216
- return [SetColorDlg, {
2217
- model: self,
2218
- handleClose: doneCallback
2219
- }];
2220
- });
2221
- }
2222
- }]);
2223
- }
2224
- };
2225
- }).actions(function (self) {
2226
- var superReload = self.reload,
2227
- superRenderSvg = self.renderSvg;
2228
-
2229
- function getStats(_x) {
2230
- return _getStats.apply(this, arguments);
2231
- }
2232
-
2233
- function _getStats() {
2234
- _getStats = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(opts) {
2235
- var _getSession, rpcManager, nd, adapterConfig, autoscaleType, sessionId, params, results, scoreMin, scoreMean, scoreStdDev, _getContainingView2, dynamicBlocks, bpPerPx, _results, _scoreMin, _scoreMean, _scoreStdDev;
2236
-
2237
- return runtime_1.wrap(function _callee4$(_context4) {
2238
- while (1) {
2239
- switch (_context4.prev = _context4.next) {
2240
- case 0:
2241
- _getSession = util.getSession(self), rpcManager = _getSession.rpcManager;
2242
- nd = configuration.getConf(self, 'numStdDev') || 3;
2243
- adapterConfig = self.adapterConfig, autoscaleType = self.autoscaleType;
2244
- sessionId = tracks.getRpcSessionId(self);
2245
- params = _objectSpread2({
2246
- sessionId: sessionId,
2247
- adapterConfig: adapterConfig,
2248
- statusCallback: function statusCallback(message) {
2249
- if (mobxStateTree.isAlive(self)) {
2250
- self.setMessage(message);
2251
- }
2252
- }
2253
- }, opts);
2254
-
2255
- if (!(autoscaleType === 'global' || autoscaleType === 'globalsd')) {
2256
- _context4.next = 11;
2257
- break;
2258
- }
2259
-
2260
- _context4.next = 8;
2261
- return rpcManager.call(sessionId, 'WiggleGetGlobalStats', params);
2262
-
2263
- case 8:
2264
- results = _context4.sent;
2265
- scoreMin = results.scoreMin, scoreMean = results.scoreMean, scoreStdDev = results.scoreStdDev; // globalsd uses heuristic to avoid unnecessary scoreMin<0
2266
- // if the scoreMin is never less than 0
2267
- // helps with most coverage bigwigs just being >0
2268
-
2269
- return _context4.abrupt("return", autoscaleType === 'globalsd' ? _objectSpread2(_objectSpread2({}, results), {}, {
2270
- scoreMin: scoreMin >= 0 ? 0 : scoreMean - nd * scoreStdDev,
2271
- scoreMax: scoreMean + nd * scoreStdDev
2272
- }) : results);
2273
-
2274
- case 11:
2275
- if (!(autoscaleType === 'local' || autoscaleType === 'localsd')) {
2276
- _context4.next = 18;
2277
- break;
2278
- }
2279
-
2280
- _getContainingView2 = util.getContainingView(self), dynamicBlocks = _getContainingView2.dynamicBlocks, bpPerPx = _getContainingView2.bpPerPx;
2281
- _context4.next = 15;
2282
- return rpcManager.call(sessionId, 'WiggleGetMultiRegionStats', _objectSpread2(_objectSpread2({}, params), {}, {
2283
- regions: dynamicBlocks.contentBlocks.map(function (region) {
2284
- var start = region.start,
2285
- end = region.end;
2286
- return _objectSpread2(_objectSpread2({}, JSON.parse(JSON.stringify(region))), {}, {
2287
- start: Math.floor(start),
2288
- end: Math.ceil(end)
2289
- });
2290
- }),
2291
- bpPerPx: bpPerPx
2292
- }));
2293
-
2294
- case 15:
2295
- _results = _context4.sent;
2296
- _scoreMin = _results.scoreMin, _scoreMean = _results.scoreMean, _scoreStdDev = _results.scoreStdDev; // localsd uses heuristic to avoid unnecessary scoreMin<0 if the
2297
- // scoreMin is never less than 0 helps with most coverage bigwigs
2298
- // just being >0
2299
-
2300
- return _context4.abrupt("return", autoscaleType === 'localsd' ? _objectSpread2(_objectSpread2({}, _results), {}, {
2301
- scoreMin: _scoreMin >= 0 ? 0 : _scoreMean - nd * _scoreStdDev,
2302
- scoreMax: _scoreMean + nd * _scoreStdDev
2303
- }) : _results);
2304
-
2305
- case 18:
2306
- if (!(autoscaleType === 'zscale')) {
2307
- _context4.next = 20;
2308
- break;
2309
- }
2310
-
2311
- return _context4.abrupt("return", rpcManager.call(sessionId, 'WiggleGetGlobalStats', params));
2312
-
2313
- case 20:
2314
- throw new Error("invalid autoscaleType '".concat(autoscaleType, "'"));
2315
-
2316
- case 21:
2317
- case "end":
2318
- return _context4.stop();
2319
- }
2320
- }
2321
- }, _callee4);
2322
- }));
2323
- return _getStats.apply(this, arguments);
2324
- }
2325
-
2326
- return {
2327
- // re-runs stats and refresh whole display on reload
2328
- reload: function reload() {
2329
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
2330
- var aborter, stats;
2331
- return runtime_1.wrap(function _callee$(_context) {
2332
- while (1) {
2333
- switch (_context.prev = _context.next) {
2334
- case 0:
2335
- self.setError();
2336
- aborter = new AbortController();
2337
- _context.prev = 2;
2338
- _context.next = 5;
2339
- return getStats({
2340
- signal: aborter.signal,
2341
- filters: self.filters
2342
- });
2343
-
2344
- case 5:
2345
- stats = _context.sent;
2346
-
2347
- if (mobxStateTree.isAlive(self)) {
2348
- self.updateStats(stats);
2349
- superReload();
2350
- }
2351
-
2352
- _context.next = 12;
2353
- break;
2354
-
2355
- case 9:
2356
- _context.prev = 9;
2357
- _context.t0 = _context["catch"](2);
2358
- self.setError(_context.t0);
2359
-
2360
- case 12:
2361
- case "end":
2362
- return _context.stop();
2363
- }
2364
- }
2365
- }, _callee, null, [[2, 9]]);
2366
- }))();
2367
- },
2368
- afterAttach: function afterAttach() {
2369
- mobxStateTree.addDisposer(self, mobx.autorun( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2370
- var aborter, view, wiggleStats;
2371
- return runtime_1.wrap(function _callee2$(_context2) {
2372
- while (1) {
2373
- switch (_context2.prev = _context2.next) {
2374
- case 0:
2375
- _context2.prev = 0;
2376
- aborter = new AbortController();
2377
- view = util.getContainingView(self);
2378
- self.setLoading(aborter);
2379
-
2380
- if (view.initialized) {
2381
- _context2.next = 6;
2382
- break;
2383
- }
2384
-
2385
- return _context2.abrupt("return");
2386
-
2387
- case 6:
2388
- if (self.estimatedStatsReady) {
2389
- _context2.next = 8;
2390
- break;
2391
- }
2392
-
2393
- return _context2.abrupt("return");
2394
-
2395
- case 8:
2396
- if (!self.regionTooLarge) {
2397
- _context2.next = 10;
2398
- break;
2399
- }
2400
-
2401
- return _context2.abrupt("return");
2402
-
2403
- case 10:
2404
- _context2.next = 12;
2405
- return getStats({
2406
- signal: aborter.signal,
2407
- filters: self.filters
2408
- });
2409
-
2410
- case 12:
2411
- wiggleStats = _context2.sent;
2412
-
2413
- if (mobxStateTree.isAlive(self)) {
2414
- self.updateStats(wiggleStats);
2415
- }
2416
-
2417
- _context2.next = 19;
2418
- break;
2419
-
2420
- case 16:
2421
- _context2.prev = 16;
2422
- _context2.t0 = _context2["catch"](0);
2423
-
2424
- if (!util.isAbortException(_context2.t0) && mobxStateTree.isAlive(self)) {
2425
- console.error(_context2.t0);
2426
- self.setError(_context2.t0);
2427
- }
2428
-
2429
- case 19:
2430
- case "end":
2431
- return _context2.stop();
2432
- }
2433
- }
2434
- }, _callee2, null, [[0, 16]]);
2435
- })), {
2436
- delay: 1000
2437
- }));
2438
- },
2439
- renderSvg: function renderSvg(opts) {
2440
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
2441
- var needsScalebar, stats, _getContainingView, offsetPx;
2442
-
2443
- return runtime_1.wrap(function _callee3$(_context3) {
2444
- while (1) {
2445
- switch (_context3.prev = _context3.next) {
2446
- case 0:
2447
- _context3.next = 2;
2448
- return mobx.when(function () {
2449
- return self.statsReady && !!self.regionCannotBeRenderedText;
2450
- });
2451
-
2452
- case 2:
2453
- needsScalebar = self.needsScalebar, stats = self.stats;
2454
- _getContainingView = util.getContainingView(self), offsetPx = _getContainingView.offsetPx;
2455
- _context3.t0 = React__default;
2456
- _context3.t1 = React__default.Fragment;
2457
- _context3.t2 = React__default;
2458
- _context3.t3 = {
2459
- id: "snpcov"
2460
- };
2461
- _context3.next = 10;
2462
- return superRenderSvg(opts);
2463
-
2464
- case 10:
2465
- _context3.t4 = _context3.sent;
2466
- _context3.t5 = _context3.t2.createElement.call(_context3.t2, "g", _context3.t3, _context3.t4);
2467
- _context3.t6 = needsScalebar && stats ? React__default.createElement("g", {
2468
- transform: "translate(".concat(Math.max(-offsetPx, 0), ")")
2469
- }, React__default.createElement(YScaleBar, {
2470
- model: self,
2471
- orientation: "left"
2472
- })) : null;
2473
- return _context3.abrupt("return", _context3.t0.createElement.call(_context3.t0, _context3.t1, null, _context3.t5, _context3.t6));
2474
-
2475
- case 14:
2476
- case "end":
2477
- return _context3.stop();
2478
- }
2479
- }
2480
- }, _callee3);
2481
- }))();
2482
- }
2483
- };
2484
- });
2485
- };
2486
-
2487
- var XYPlotRenderer = /*#__PURE__*/function (_WiggleBaseRenderer) {
2488
- _inherits(XYPlotRenderer, _WiggleBaseRenderer);
2489
-
2490
- var _super = /*#__PURE__*/_createSuper(XYPlotRenderer);
2491
-
2492
- function XYPlotRenderer() {
2493
- _classCallCheck(this, XYPlotRenderer);
2494
-
2495
- return _super.apply(this, arguments);
2496
- }
2497
-
2498
- _createClass(XYPlotRenderer, [{
2499
- key: "draw",
2500
- value: function draw(ctx, props) {
2501
- var features = props.features,
2502
- bpPerPx = props.bpPerPx,
2503
- regions = props.regions,
2504
- scaleOpts = props.scaleOpts,
2505
- unadjustedHeight = props.height,
2506
- config = props.config,
2507
- ticks = props.ticks,
2508
- displayCrossHatches = props.displayCrossHatches;
2509
-
2510
- var _regions = _slicedToArray(regions, 1),
2511
- region = _regions[0];
2512
-
2513
- var width = (region.end - region.start) / bpPerPx; // the adjusted height takes into account YSCALEBAR_LABEL_OFFSET from the
2514
- // wiggle display, and makes the height of the actual drawn area add
2515
- // "padding" to the top and bottom of the display
2516
-
2517
- var offset = YSCALEBAR_LABEL_OFFSET;
2518
- var height = unadjustedHeight - offset * 2;
2519
- var pivotValue = configuration.readConfObject(config, 'bicolorPivotValue');
2520
- var negColor = configuration.readConfObject(config, 'negColor');
2521
- var posColor = configuration.readConfObject(config, 'posColor');
2522
- var filled = configuration.readConfObject(config, 'filled');
2523
- var clipColor = configuration.readConfObject(config, 'clipColor');
2524
- var highlightColor = configuration.readConfObject(config, 'highlightColor');
2525
- var summaryScoreMode = configuration.readConfObject(config, 'summaryScoreMode');
2526
- var scale = getScale(_objectSpread2(_objectSpread2({}, scaleOpts), {}, {
2527
- range: [0, height]
2528
- }));
2529
- var originY = getOrigin(scaleOpts.scaleType);
2530
-
2531
- var _scale$domain = scale.domain(),
2532
- _scale$domain2 = _slicedToArray(_scale$domain, 2),
2533
- niceMin = _scale$domain2[0],
2534
- niceMax = _scale$domain2[1];
2535
-
2536
- var toY = function toY(n) {
2537
- return height - (scale(n) || 0) + offset;
2538
- };
2539
-
2540
- var toHeight = function toHeight(n) {
2541
- return toY(originY) - toY(n);
2542
- };
2543
-
2544
- var colorCallback = configuration.readConfObject(config, 'color') === '#f0f' ? function (_, score) {
2545
- return score < pivotValue ? negColor : posColor;
2546
- } : function (feature, _score) {
2547
- return configuration.readConfObject(config, 'color', {
2548
- feature: feature
2549
- });
2550
- };
2551
- var crossingOrigin = niceMin < pivotValue && niceMax > pivotValue;
2552
-
2553
- var _iterator = _createForOfIteratorHelper(features.values()),
2554
- _step;
2555
-
2556
- try {
2557
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
2558
- var feature = _step.value;
2559
-
2560
- var _featureSpanPx = util.featureSpanPx(feature, region, bpPerPx),
2561
- _featureSpanPx2 = _slicedToArray(_featureSpanPx, 2),
2562
- leftPx = _featureSpanPx2[0],
2563
- rightPx = _featureSpanPx2[1];
2564
-
2565
- var score = feature.get('score');
2566
- var maxr = feature.get('maxScore');
2567
- var minr = feature.get('minScore');
2568
- var lowClipping = score < niceMin;
2569
- var highClipping = score > niceMax;
2570
- var w = rightPx - leftPx + 0.4; // fudge factor for subpixel rendering
2571
-
2572
- var summary = feature.get('summary');
2573
-
2574
- if (summaryScoreMode === 'max') {
2575
- score = summary ? maxr : score;
2576
- ctx.fillStyle = colorCallback(feature, score);
2577
- ctx.fillRect(leftPx, toY(score), w, filled ? toHeight(score) : 1);
2578
- } else if (summaryScoreMode === 'min') {
2579
- score = summary ? minr : score;
2580
- ctx.fillStyle = colorCallback(feature, score);
2581
- ctx.fillRect(leftPx, toY(score), w, filled ? toHeight(score) : 1);
2582
- } else if (summaryScoreMode === 'whiskers') {
2583
- var c = colorCallback(feature, score);
2584
-
2585
- if (summary) {
2586
- ctx.fillStyle = crossingOrigin ? colorCallback(feature, maxr) : Color(c).lighten(0.6).toString();
2587
- ctx.fillRect(leftPx, toY(maxr), w, filled ? toHeight(maxr) - toHeight(score) : 1);
2588
- } // normal
2589
-
2590
-
2591
- ctx.fillStyle = crossingOrigin && summary ? Color(colorCallback(feature, maxr)).mix(Color(colorCallback(feature, minr))) : c;
2592
- ctx.fillRect(leftPx, toY(score), w, filled ? toHeight(score) - (summary ? toHeight(minr) : 0) : 1); // min
2593
-
2594
- if (summary) {
2595
- ctx.fillStyle = crossingOrigin ? colorCallback(feature, minr) : Color(c).darken(0.6).toString();
2596
- ctx.fillRect(leftPx, toY(minr), w, filled ? toHeight(minr) : 1);
2597
- }
2598
- } else {
2599
- ctx.fillStyle = colorCallback(feature, score);
2600
- ctx.fillRect(leftPx, toY(score), w, filled ? toHeight(score) : 1);
2601
- }
2602
-
2603
- if (highClipping) {
2604
- ctx.fillStyle = clipColor;
2605
- ctx.fillRect(leftPx, 0, w, 4);
2606
- } else if (lowClipping && scaleOpts.scaleType !== 'log') {
2607
- ctx.fillStyle = clipColor;
2608
- ctx.fillRect(leftPx, unadjustedHeight - 4, w, 4);
2609
- }
2610
-
2611
- if (feature.get('highlighted')) {
2612
- ctx.fillStyle = highlightColor;
2613
- ctx.fillRect(leftPx, 0, w, height);
2614
- }
2615
- }
2616
- } catch (err) {
2617
- _iterator.e(err);
2618
- } finally {
2619
- _iterator.f();
2620
- }
2621
-
2622
- if (displayCrossHatches) {
2623
- ctx.lineWidth = 1;
2624
- ctx.strokeStyle = 'rgba(200,200,200,0.8)';
2625
- ticks.values.forEach(function (tick) {
2626
- ctx.beginPath();
2627
- ctx.moveTo(0, Math.round(toY(tick)));
2628
- ctx.lineTo(width, Math.round(toY(tick)));
2629
- ctx.stroke();
2630
- });
2631
- }
2632
- }
2633
- }]);
2634
-
2635
- return XYPlotRenderer;
2636
- }(WiggleBaseRenderer);
2637
-
2638
- var configSchema$1 = /*#__PURE__*/configuration.ConfigurationSchema('XYPlotRenderer', {}, {
2639
- baseConfiguration: ConfigSchema,
2640
- explicitlyTyped: true
2641
- });
2642
-
2643
- var LinePlotRenderer = /*#__PURE__*/function (_WiggleBaseRenderer) {
2644
- _inherits(LinePlotRenderer, _WiggleBaseRenderer);
2645
-
2646
- var _super = /*#__PURE__*/_createSuper(LinePlotRenderer);
2647
-
2648
- function LinePlotRenderer() {
2649
- _classCallCheck(this, LinePlotRenderer);
2650
-
2651
- return _super.apply(this, arguments);
2652
- }
2653
-
2654
- _createClass(LinePlotRenderer, [{
2655
- key: "draw",
2656
- value: function draw(ctx, props) {
2657
- var features = props.features,
2658
- regions = props.regions,
2659
- bpPerPx = props.bpPerPx,
2660
- scaleOpts = props.scaleOpts,
2661
- unadjustedHeight = props.height,
2662
- values = props.ticks.values,
2663
- displayCrossHatches = props.displayCrossHatches,
2664
- config = props.config;
2665
-
2666
- var _regions = _slicedToArray(regions, 1),
2667
- region = _regions[0];
2668
-
2669
- var width = (region.end - region.start) / bpPerPx;
2670
- var offset = YSCALEBAR_LABEL_OFFSET; // the adjusted height takes into account YSCALEBAR_LABEL_OFFSET from the
2671
- // wiggle display, and makes the height of the actual drawn area add
2672
- // "padding" to the top and bottom of the display
2673
-
2674
- var height = unadjustedHeight - offset * 2;
2675
- var clipColor = configuration.readConfObject(config, 'clipColor');
2676
- var highlightColor = configuration.readConfObject(config, 'highlightColor');
2677
- var scale = getScale(_objectSpread2(_objectSpread2({}, scaleOpts), {}, {
2678
- range: [0, height]
2679
- }));
2680
-
2681
- var _scale$domain = scale.domain(),
2682
- _scale$domain2 = _slicedToArray(_scale$domain, 2),
2683
- niceMin = _scale$domain2[0],
2684
- niceMax = _scale$domain2[1];
2685
-
2686
- var toY = function toY(rawscore) {
2687
- return height - scale(rawscore) + offset;
2688
- };
2689
-
2690
- var colorCallback = configuration.readConfObject(config, 'color') === '#f0f' ? function () {
2691
- return 'grey';
2692
- } : function (feature) {
2693
- return configuration.readConfObject(config, 'color', {
2694
- feature: feature
2695
- });
2696
- };
2697
- var lastVal;
2698
-
2699
- var _iterator = _createForOfIteratorHelper(features.values()),
2700
- _step;
2701
-
2702
- try {
2703
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
2704
- var feature = _step.value;
2705
-
2706
- var _featureSpanPx = util.featureSpanPx(feature, region, bpPerPx),
2707
- _featureSpanPx2 = _slicedToArray(_featureSpanPx, 2),
2708
- leftPx = _featureSpanPx2[0],
2709
- rightPx = _featureSpanPx2[1];
2710
-
2711
- var score = feature.get('score');
2712
- var lowClipping = score < niceMin;
2713
- var highClipping = score > niceMax;
2714
- var w = rightPx - leftPx + 0.3; // fudge factor for subpixel rendering
2715
-
2716
- var c = colorCallback(feature);
2717
- ctx.strokeStyle = c;
2718
- ctx.beginPath();
2719
-
2720
- if (!region.reversed) {
2721
- ctx.moveTo(leftPx, toY(typeof lastVal !== 'undefined' ? lastVal : score));
2722
- ctx.lineTo(leftPx, toY(score));
2723
- ctx.lineTo(rightPx, toY(score));
2724
- } else {
2725
- ctx.moveTo(rightPx, toY(typeof lastVal !== 'undefined' ? lastVal : score));
2726
- ctx.lineTo(rightPx, toY(score));
2727
- ctx.lineTo(leftPx, toY(score));
2728
- }
2729
-
2730
- ctx.stroke();
2731
- lastVal = score;
2732
-
2733
- if (highClipping) {
2734
- ctx.fillStyle = clipColor;
2735
- ctx.fillRect(leftPx, 0, w, 4);
2736
- } else if (lowClipping && scaleOpts.scaleType !== 'log') {
2737
- ctx.fillStyle = clipColor;
2738
- ctx.fillRect(leftPx, height - 4, w, height);
2739
- }
2740
-
2741
- if (feature.get('highlighted')) {
2742
- ctx.fillStyle = highlightColor;
2743
- ctx.fillRect(leftPx, 0, w, height);
2744
- }
2745
- }
2746
- } catch (err) {
2747
- _iterator.e(err);
2748
- } finally {
2749
- _iterator.f();
2750
- }
2751
-
2752
- if (displayCrossHatches) {
2753
- ctx.lineWidth = 1;
2754
- ctx.strokeStyle = 'rgba(200,200,200,0.8)';
2755
- values.forEach(function (tick) {
2756
- ctx.beginPath();
2757
- ctx.moveTo(0, Math.round(toY(tick)));
2758
- ctx.lineTo(width, Math.round(toY(tick)));
2759
- ctx.stroke();
2760
- });
2761
- }
2762
- }
2763
- }]);
2764
-
2765
- return LinePlotRenderer;
2766
- }(WiggleBaseRenderer);
2767
-
2768
- var configSchema$2 = /*#__PURE__*/configuration.ConfigurationSchema('LinePlotRenderer', {}, {
2769
- baseConfiguration: ConfigSchema,
2770
- explicitlyTyped: true
2771
- });
2772
-
2773
- var WiggleGetGlobalStats = /*#__PURE__*/function (_RpcMethodType) {
2774
- _inherits(WiggleGetGlobalStats, _RpcMethodType);
2775
-
2776
- var _super = /*#__PURE__*/_createSuper(WiggleGetGlobalStats);
2777
-
2778
- function WiggleGetGlobalStats() {
2779
- var _this;
2780
-
2781
- _classCallCheck(this, WiggleGetGlobalStats);
2782
-
2783
- _this = _super.apply(this, arguments);
2784
- _this.name = 'WiggleGetGlobalStats';
2785
- return _this;
2786
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
2787
-
2788
-
2789
- _createClass(WiggleGetGlobalStats, [{
2790
- key: "deserializeArguments",
2791
- value: function () {
2792
- var _deserializeArguments = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(args, rpcDriverClassName) {
2793
- var l;
2794
- return runtime_1.wrap(function _callee$(_context) {
2795
- while (1) {
2796
- switch (_context.prev = _context.next) {
2797
- case 0:
2798
- _context.next = 2;
2799
- return _get(_getPrototypeOf(WiggleGetGlobalStats.prototype), "deserializeArguments", this).call(this, args, rpcDriverClassName);
2800
-
2801
- case 2:
2802
- l = _context.sent;
2803
- return _context.abrupt("return", _objectSpread2(_objectSpread2({}, l), {}, {
2804
- filters: args.filters ? new SerializableFilterChain({
2805
- filters: args.filters
2806
- }) : undefined
2807
- }));
2808
-
2809
- case 4:
2810
- case "end":
2811
- return _context.stop();
2812
- }
2813
- }
2814
- }, _callee, this);
2815
- }));
2816
-
2817
- function deserializeArguments(_x, _x2) {
2818
- return _deserializeArguments.apply(this, arguments);
2819
- }
2820
-
2821
- return deserializeArguments;
2822
- }()
2823
- }, {
2824
- key: "execute",
2825
- value: function () {
2826
- var _execute = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(args, rpcDriverClassName) {
2827
- var deserializedArgs, adapterConfig, sessionId, _yield$getAdapter, dataAdapter;
2828
-
2829
- return runtime_1.wrap(function _callee2$(_context2) {
2830
- while (1) {
2831
- switch (_context2.prev = _context2.next) {
2832
- case 0:
2833
- _context2.next = 2;
2834
- return this.deserializeArguments(args, rpcDriverClassName);
2835
-
2836
- case 2:
2837
- deserializedArgs = _context2.sent;
2838
- adapterConfig = deserializedArgs.adapterConfig, sessionId = deserializedArgs.sessionId;
2839
- _context2.next = 6;
2840
- return dataAdapterCache.getAdapter(this.pluginManager, sessionId, adapterConfig);
2841
-
2842
- case 6:
2843
- _yield$getAdapter = _context2.sent;
2844
- dataAdapter = _yield$getAdapter.dataAdapter;
2845
- return _context2.abrupt("return", dataAdapter.getGlobalStats(deserializedArgs));
2846
-
2847
- case 9:
2848
- case "end":
2849
- return _context2.stop();
2850
- }
2851
- }
2852
- }, _callee2, this);
2853
- }));
2854
-
2855
- function execute(_x3, _x4) {
2856
- return _execute.apply(this, arguments);
2857
- }
2858
-
2859
- return execute;
2860
- }()
2861
- }]);
2862
-
2863
- return WiggleGetGlobalStats;
2864
- }(RpcMethodType);
2865
- var WiggleGetMultiRegionStats = /*#__PURE__*/function (_RpcMethodType2) {
2866
- _inherits(WiggleGetMultiRegionStats, _RpcMethodType2);
2867
-
2868
- var _super2 = /*#__PURE__*/_createSuper(WiggleGetMultiRegionStats);
2869
-
2870
- function WiggleGetMultiRegionStats() {
2871
- var _this2;
2872
-
2873
- _classCallCheck(this, WiggleGetMultiRegionStats);
2874
-
2875
- _this2 = _super2.apply(this, arguments);
2876
- _this2.name = 'WiggleGetMultiRegionStats';
2877
- return _this2;
2878
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
2879
-
2880
-
2881
- _createClass(WiggleGetMultiRegionStats, [{
2882
- key: "deserializeArguments",
2883
- value: function () {
2884
- var _deserializeArguments2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(args, rpcDriverClassName) {
2885
- var l;
2886
- return runtime_1.wrap(function _callee3$(_context3) {
2887
- while (1) {
2888
- switch (_context3.prev = _context3.next) {
2889
- case 0:
2890
- _context3.next = 2;
2891
- return _get(_getPrototypeOf(WiggleGetMultiRegionStats.prototype), "deserializeArguments", this).call(this, args, rpcDriverClassName);
2892
-
2893
- case 2:
2894
- l = _context3.sent;
2895
- return _context3.abrupt("return", _objectSpread2(_objectSpread2({}, l), {}, {
2896
- filters: args.filters ? new SerializableFilterChain({
2897
- filters: args.filters
2898
- }) : undefined
2899
- }));
2900
-
2901
- case 4:
2902
- case "end":
2903
- return _context3.stop();
2904
- }
2905
- }
2906
- }, _callee3, this);
2907
- }));
2908
-
2909
- function deserializeArguments(_x5, _x6) {
2910
- return _deserializeArguments2.apply(this, arguments);
2911
- }
2912
-
2913
- return deserializeArguments;
2914
- }()
2915
- }, {
2916
- key: "serializeArguments",
2917
- value: function () {
2918
- var _serializeArguments = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(args, rpcDriverClassName) {
2919
- var _this$pluginManager$r, _this$pluginManager$r2;
2920
-
2921
- var assemblyManager, renamedArgs;
2922
- return runtime_1.wrap(function _callee4$(_context4) {
2923
- while (1) {
2924
- switch (_context4.prev = _context4.next) {
2925
- case 0:
2926
- assemblyManager = (_this$pluginManager$r = this.pluginManager.rootModel) === null || _this$pluginManager$r === void 0 ? void 0 : (_this$pluginManager$r2 = _this$pluginManager$r.session) === null || _this$pluginManager$r2 === void 0 ? void 0 : _this$pluginManager$r2.assemblyManager;
2927
-
2928
- if (assemblyManager) {
2929
- _context4.next = 3;
2930
- break;
2931
- }
2932
-
2933
- return _context4.abrupt("return", args);
2934
-
2935
- case 3:
2936
- _context4.next = 5;
2937
- return util.renameRegionsIfNeeded(assemblyManager, _objectSpread2(_objectSpread2({}, args), {}, {
2938
- filters: args.filters && args.filters.toJSON().filters
2939
- }));
2940
-
2941
- case 5:
2942
- renamedArgs = _context4.sent;
2943
- return _context4.abrupt("return", _get(_getPrototypeOf(WiggleGetMultiRegionStats.prototype), "serializeArguments", this).call(this, renamedArgs, rpcDriverClassName));
2944
-
2945
- case 7:
2946
- case "end":
2947
- return _context4.stop();
2948
- }
2949
- }
2950
- }, _callee4, this);
2951
- }));
2952
-
2953
- function serializeArguments(_x7, _x8) {
2954
- return _serializeArguments.apply(this, arguments);
2955
- }
2956
-
2957
- return serializeArguments;
2958
- }()
2959
- }, {
2960
- key: "execute",
2961
- value: function () {
2962
- var _execute2 = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(args, rpcDriverClassName) {
2963
- var deserializedArgs, regions, adapterConfig, sessionId, _yield$getAdapter2, dataAdapter;
2964
-
2965
- return runtime_1.wrap(function _callee5$(_context5) {
2966
- while (1) {
2967
- switch (_context5.prev = _context5.next) {
2968
- case 0:
2969
- _context5.next = 2;
2970
- return this.deserializeArguments(args, rpcDriverClassName);
2971
-
2972
- case 2:
2973
- deserializedArgs = _context5.sent;
2974
- regions = deserializedArgs.regions, adapterConfig = deserializedArgs.adapterConfig, sessionId = deserializedArgs.sessionId;
2975
- _context5.next = 6;
2976
- return dataAdapterCache.getAdapter(this.pluginManager, sessionId, adapterConfig);
2977
-
2978
- case 6:
2979
- _yield$getAdapter2 = _context5.sent;
2980
- dataAdapter = _yield$getAdapter2.dataAdapter;
2981
-
2982
- if (!(dataAdapter instanceof BaseAdapter.BaseFeatureDataAdapter)) {
2983
- _context5.next = 10;
2984
- break;
2985
- }
2986
-
2987
- return _context5.abrupt("return", dataAdapter.getMultiRegionStats(regions, deserializedArgs));
2988
-
2989
- case 10:
2990
- throw new Error('Data adapter not found');
2991
-
2992
- case 11:
2993
- case "end":
2994
- return _context5.stop();
2995
- }
2996
- }
2997
- }, _callee5, this);
2998
- }));
2999
-
3000
- function execute(_x9, _x10) {
3001
- return _execute2.apply(this, arguments);
3002
- }
3003
-
3004
- return execute;
3005
- }()
3006
- }]);
3007
-
3008
- return WiggleGetMultiRegionStats;
3009
- }(RpcMethodType);
3010
-
3011
- var WigglePlugin = /*#__PURE__*/function (_Plugin) {
3012
- _inherits(WigglePlugin, _Plugin);
3013
-
3014
- var _super = /*#__PURE__*/_createSuper(WigglePlugin);
3015
-
3016
- function WigglePlugin() {
3017
- var _this;
3018
-
3019
- _classCallCheck(this, WigglePlugin);
3020
-
3021
- _this = _super.apply(this, arguments);
3022
- _this.name = 'WigglePlugin';
3023
- _this.exports = {
3024
- LinearWiggleDisplayReactComponent: LinearWiggleDisplay,
3025
- XYPlotRendererReactComponent: XYPlotRendererReactComponent,
3026
- XYPlotRenderer: XYPlotRenderer,
3027
- xyPlotRendererConfigSchema: configSchema$1,
3028
- utils: utils,
3029
- WiggleBaseRenderer: WiggleBaseRenderer,
3030
- linearWiggleDisplayModelFactory: stateModelFactory
3031
- };
3032
- return _this;
3033
- }
3034
-
3035
- _createClass(WigglePlugin, [{
3036
- key: "install",
3037
- value: function install(pluginManager) {
3038
- pluginManager.addTrackType(function () {
3039
- var configSchema = configuration.ConfigurationSchema('QuantitativeTrack', {}, {
3040
- baseConfiguration: models.createBaseTrackConfig(pluginManager)
3041
- });
3042
- return new TrackType({
3043
- name: 'QuantitativeTrack',
3044
- configSchema: configSchema,
3045
- stateModel: models.createBaseTrackModel(pluginManager, 'QuantitativeTrack', configSchema)
3046
- });
3047
- });
3048
- pluginManager.addDisplayType(function () {
3049
- var configSchema = WiggleConfigFactory(pluginManager);
3050
- return new DisplayType({
3051
- name: 'LinearWiggleDisplay',
3052
- configSchema: configSchema,
3053
- stateModel: stateModelFactory(pluginManager, configSchema),
3054
- trackType: 'QuantitativeTrack',
3055
- viewType: 'LinearGenomeView',
3056
- ReactComponent: LinearWiggleDisplay
3057
- });
3058
- });
3059
- pluginManager.addAdapterType(function () {
3060
- return new AdapterType({
3061
- name: 'BigWigAdapter',
3062
- configSchema: bigWigAdapterConfigSchema,
3063
- adapterCapabilities: ['hasResolution', 'hasLocalStats', 'hasGlobalStats'],
3064
- getAdapterClass: function getAdapterClass() {
3065
- return Promise.resolve().then(function () { return BigWigAdapter$1; }).then(function (r) {
3066
- return r["default"];
3067
- });
3068
- }
3069
- });
3070
- });
3071
- pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
3072
- return function (file, index, adapterHint) {
3073
- var regexGuess = /\.(bw|bigwig)$/i;
3074
- var adapterName = 'BigWigAdapter';
3075
- var fileName = tracks.getFileName(file);
3076
- var obj = {
3077
- type: adapterName,
3078
- bigWigLocation: file
3079
- };
3080
-
3081
- if (regexGuess.test(fileName) && !adapterHint) {
3082
- return obj;
3083
- } else if (adapterHint === adapterName) {
3084
- return obj;
3085
- }
3086
-
3087
- return adapterGuesser(file, index, adapterHint);
3088
- };
3089
- });
3090
- pluginManager.addToExtensionPoint('Core-guessTrackTypeForLocation', function (trackTypeGuesser) {
3091
- return function (adapterName) {
3092
- if (adapterName === 'BigWigAdapter') {
3093
- return 'QuantitativeTrack';
3094
- }
3095
-
3096
- return trackTypeGuesser(adapterName);
3097
- };
3098
- });
3099
- pluginManager.addRendererType(function () {
3100
- return new DensityRenderer({
3101
- name: 'DensityRenderer',
3102
- ReactComponent: XYPlotRendererReactComponent,
3103
- configSchema: configSchema,
3104
- pluginManager: pluginManager
3105
- });
3106
- });
3107
- pluginManager.addRendererType(function () {
3108
- return new LinePlotRenderer({
3109
- name: 'LinePlotRenderer',
3110
- ReactComponent: XYPlotRendererReactComponent,
3111
- configSchema: configSchema$2,
3112
- pluginManager: pluginManager
3113
- });
3114
- });
3115
- pluginManager.addRendererType(function () {
3116
- return new XYPlotRenderer({
3117
- name: 'XYPlotRenderer',
3118
- ReactComponent: XYPlotRendererReactComponent,
3119
- configSchema: configSchema$1,
3120
- pluginManager: pluginManager
3121
- });
3122
- });
3123
- pluginManager.addRpcMethod(function () {
3124
- return new WiggleGetGlobalStats(pluginManager);
3125
- });
3126
- pluginManager.addRpcMethod(function () {
3127
- return new WiggleGetMultiRegionStats(pluginManager);
3128
- });
3129
- }
3130
- }]);
3131
-
3132
- return WigglePlugin;
3133
- }(Plugin);
3134
-
3135
- var useStyles$1 = /*#__PURE__*/styles.makeStyles(function (theme) {
3136
- return {
3137
- root: {},
3138
- closeButton: {
3139
- position: 'absolute',
3140
- right: theme.spacing(1),
3141
- top: theme.spacing(1),
3142
- color: theme.palette.grey[500]
3143
- }
3144
- };
3145
- });
3146
- function SetMinMaxDlg$1(props) {
3147
- var classes = useStyles$1();
3148
- var model = props.model,
3149
- handleClose = props.handleClose;
3150
- var minScore = model.minScore,
3151
- maxScore = model.maxScore,
3152
- scaleType = model.scaleType;
3153
-
3154
- var _useState = React.useState("".concat(minScore !== Number.MIN_VALUE ? minScore : '')),
3155
- _useState2 = _slicedToArray(_useState, 2),
3156
- min = _useState2[0],
3157
- setMin = _useState2[1];
3158
-
3159
- var _useState3 = React.useState("".concat(maxScore !== Number.MAX_VALUE ? maxScore : '')),
3160
- _useState4 = _slicedToArray(_useState3, 2),
3161
- max = _useState4[0],
3162
- setMax = _useState4[1];
3163
-
3164
- var ok = min !== '' && max !== '' && !Number.isNaN(+min) && !Number.isNaN(+max) ? +max > +min : true;
3165
- var logOk = scaleType === 'log' && min !== '' && !Number.isNaN(+min) ? +min > 0 : true;
3166
- return React__default.createElement(Dialog, {
3167
- open: true,
3168
- onClose: handleClose
3169
- }, React__default.createElement(DialogTitle, null, "Set min/max score for track", React__default.createElement(IconButton, {
3170
- className: classes.closeButton,
3171
- onClick: handleClose
3172
- }, React__default.createElement(CloseIcon, null))), React__default.createElement(DialogContent, {
3173
- style: {
3174
- overflowX: 'hidden'
3175
- }
3176
- }, React__default.createElement("div", {
3177
- className: classes.root
3178
- }, React__default.createElement(Typography, null, "Enter min/max score: "), !ok ? React__default.createElement(Typography, {
3179
- color: "error"
3180
- }, "Max is greater than or equal to min") : null, !logOk ? React__default.createElement(Typography, {
3181
- color: "error"
3182
- }, "Min score should be greater than 0 for log scale") : null, React__default.createElement(TextField, {
3183
- value: min,
3184
- onChange: function onChange(event) {
3185
- setMin(event.target.value);
3186
- },
3187
- placeholder: "Enter min score"
3188
- }), React__default.createElement(TextField, {
3189
- value: max,
3190
- onChange: function onChange(event) {
3191
- setMax(event.target.value);
3192
- },
3193
- placeholder: "Enter max score"
3194
- }), React__default.createElement(Button, {
3195
- variant: "contained",
3196
- color: "primary",
3197
- type: "submit",
3198
- style: {
3199
- marginLeft: 20
3200
- },
3201
- disabled: !ok,
3202
- onClick: function onClick() {
3203
- model.setMinScore(min !== '' && !Number.isNaN(+min) ? +min : undefined);
3204
- model.setMaxScore(max !== '' && !Number.isNaN(+max) ? +max : undefined);
3205
- handleClose();
3206
- }
3207
- }, "Submit"))));
3208
- }
3209
-
3210
- var SetMinMaxDialog = {
3211
- __proto__: null,
3212
- 'default': SetMinMaxDlg$1
3213
- };
3214
-
3215
- var useStyles$2 = /*#__PURE__*/core.makeStyles(function (theme) {
3216
- return {
3217
- closeButton: {
3218
- position: 'absolute',
3219
- right: theme.spacing(1),
3220
- top: theme.spacing(1),
3221
- color: theme.palette.grey[500]
3222
- }
3223
- };
3224
- }); // this is needed because passing a entire color object into the react-color
3225
- // for alpha, can't pass in an rgba string for example
3226
-
3227
- function serialize(color) {
3228
- if (color instanceof Object) {
3229
- var r = color.r,
3230
- g = color.g,
3231
- b = color.b;
3232
- return "rgb(".concat(r, ",").concat(g, ",").concat(b, ")");
3233
- }
3234
-
3235
- return color;
3236
- }
3237
-
3238
- function SetColorDialog(_ref) {
3239
- var model = _ref.model,
3240
- handleClose = _ref.handleClose;
3241
- var classes = useStyles$2();
3242
-
3243
- var _useState = React.useState(false),
3244
- _useState2 = _slicedToArray(_useState, 2),
3245
- posneg = _useState2[0],
3246
- setPosNeg = _useState2[1];
3247
-
3248
- return React__default.createElement(core.Dialog, {
3249
- open: true,
3250
- onClose: handleClose
3251
- }, React__default.createElement(core.DialogTitle, null, "Select either an overall color, or the positive/negative colors. Note that density renderers only work properly with positive/negative colors", React__default.createElement(core.IconButton, {
3252
- "aria-label": "close",
3253
- className: classes.closeButton,
3254
- onClick: handleClose
3255
- }, React__default.createElement(CloseIcon, null))), React__default.createElement(core.DialogContent, null, React__default.createElement(core.FormControlLabel, {
3256
- checked: !posneg,
3257
- onClick: function onClick() {
3258
- return setPosNeg(false);
3259
- },
3260
- control: React__default.createElement(core.Radio, null),
3261
- label: 'Overall color'
3262
- }), React__default.createElement(core.FormControlLabel, {
3263
- checked: posneg,
3264
- onClick: function onClick() {
3265
- return setPosNeg(true);
3266
- },
3267
- control: React__default.createElement(core.Radio, null),
3268
- label: 'Positive/negative color'
3269
- }), posneg ? React__default.createElement(React__default.Fragment, null, React__default.createElement(core.Typography, null, "Positive color"), React__default.createElement(reactColor.CompactPicker, {
3270
- onChange: function onChange(event) {
3271
- model.setPosColor(serialize(event.rgb));
3272
- model.setColor(undefined);
3273
- }
3274
- }), React__default.createElement(core.Typography, null, "Negative color"), React__default.createElement(reactColor.CompactPicker, {
3275
- onChange: function onChange(event) {
3276
- model.setNegColor(serialize(event.rgb));
3277
- model.setColor(undefined);
3278
- }
3279
- })) : React__default.createElement(React__default.Fragment, null, React__default.createElement(core.Typography, null, "Overall color"), React__default.createElement(reactColor.CompactPicker, {
3280
- onChange: function onChange(event) {
3281
- model.setColor(serialize(event.rgb));
3282
- }
3283
- }))), React__default.createElement(core.DialogActions, null, React__default.createElement(core.Button, {
3284
- onClick: function onClick() {
3285
- model.setPosColor(undefined);
3286
- model.setNegColor(undefined);
3287
- model.setColor(undefined);
3288
- },
3289
- color: "secondary",
3290
- variant: "contained"
3291
- }, "Restore default"), React__default.createElement(core.Button, {
3292
- variant: "contained",
3293
- color: "primary",
3294
- type: "submit",
3295
- onClick: function onClick() {
3296
- handleClose();
3297
- }
3298
- }, "Submit")));
3299
- }
3300
-
3301
- var SetColorDialog$1 = {
3302
- __proto__: null,
3303
- 'default': SetColorDialog
3304
- };
3305
-
3306
- var BigWigAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
3307
- _inherits(BigWigAdapter, _BaseFeatureDataAdapt);
3308
-
3309
- var _super = /*#__PURE__*/_createSuper(BigWigAdapter);
3310
-
3311
- function BigWigAdapter(config, getSubAdapter, pluginManager) {
3312
- var _this;
3313
-
3314
- _classCallCheck(this, BigWigAdapter);
3315
-
3316
- _this = _super.call(this, config, getSubAdapter, pluginManager);
3317
- _this.bigwig = new bbi.BigWig({
3318
- filehandle: io.openLocation(configuration.readConfObject(config, 'bigWigLocation'), _this.pluginManager)
3319
- });
3320
- return _this;
3321
- }
3322
-
3323
- _createClass(BigWigAdapter, [{
3324
- key: "setup",
3325
- value: function () {
3326
- var _setup = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(opts) {
3327
- var _this2 = this;
3328
-
3329
- var _ref, _ref$statusCallback, statusCallback;
3330
-
3331
- return runtime_1.wrap(function _callee$(_context) {
3332
- while (1) {
3333
- switch (_context.prev = _context.next) {
3334
- case 0:
3335
- _ref = opts || {}, _ref$statusCallback = _ref.statusCallback, statusCallback = _ref$statusCallback === void 0 ? function () {} : _ref$statusCallback;
3336
- return _context.abrupt("return", util.updateStatus('Downloading bigwig header', statusCallback, function () {
3337
- return _this2.bigwig.getHeader(opts);
3338
- }));
3339
-
3340
- case 2:
3341
- case "end":
3342
- return _context.stop();
3343
- }
3344
- }
3345
- }, _callee);
3346
- }));
3347
-
3348
- function setup(_x) {
3349
- return _setup.apply(this, arguments);
3350
- }
3351
-
3352
- return setup;
3353
- }()
3354
- }, {
3355
- key: "getRefNames",
3356
- value: function () {
3357
- var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(opts) {
3358
- var _yield$this$setup, refsByName;
3359
-
3360
- return runtime_1.wrap(function _callee2$(_context2) {
3361
- while (1) {
3362
- switch (_context2.prev = _context2.next) {
3363
- case 0:
3364
- _context2.next = 2;
3365
- return this.setup(opts);
3366
-
3367
- case 2:
3368
- _yield$this$setup = _context2.sent;
3369
- refsByName = _yield$this$setup.refsByName;
3370
- return _context2.abrupt("return", Object.keys(refsByName));
3371
-
3372
- case 5:
3373
- case "end":
3374
- return _context2.stop();
3375
- }
3376
- }
3377
- }, _callee2, this);
3378
- }));
3379
-
3380
- function getRefNames(_x2) {
3381
- return _getRefNames.apply(this, arguments);
3382
- }
3383
-
3384
- return getRefNames;
3385
- }()
3386
- }, {
3387
- key: "refIdToName",
3388
- value: function () {
3389
- var _refIdToName = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(refId) {
3390
- var _refsByNumber$refId;
3391
-
3392
- var _yield$this$setup2, refsByNumber;
3393
-
3394
- return runtime_1.wrap(function _callee3$(_context3) {
3395
- while (1) {
3396
- switch (_context3.prev = _context3.next) {
3397
- case 0:
3398
- _context3.next = 2;
3399
- return this.setup();
3400
-
3401
- case 2:
3402
- _yield$this$setup2 = _context3.sent;
3403
- refsByNumber = _yield$this$setup2.refsByNumber;
3404
- return _context3.abrupt("return", (_refsByNumber$refId = refsByNumber[refId]) === null || _refsByNumber$refId === void 0 ? void 0 : _refsByNumber$refId.name);
3405
-
3406
- case 5:
3407
- case "end":
3408
- return _context3.stop();
3409
- }
3410
- }
3411
- }, _callee3, this);
3412
- }));
3413
-
3414
- function refIdToName(_x3) {
3415
- return _refIdToName.apply(this, arguments);
3416
- }
3417
-
3418
- return refIdToName;
3419
- }()
3420
- }, {
3421
- key: "getGlobalStats",
3422
- value: function () {
3423
- var _getGlobalStats = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(opts) {
3424
- var _yield$this$setup3, totalSummary;
3425
-
3426
- return runtime_1.wrap(function _callee4$(_context4) {
3427
- while (1) {
3428
- switch (_context4.prev = _context4.next) {
3429
- case 0:
3430
- _context4.next = 2;
3431
- return this.setup(opts);
3432
-
3433
- case 2:
3434
- _yield$this$setup3 = _context4.sent;
3435
- totalSummary = _yield$this$setup3.totalSummary;
3436
- return _context4.abrupt("return", stats.rectifyStats(totalSummary));
3437
-
3438
- case 5:
3439
- case "end":
3440
- return _context4.stop();
3441
- }
3442
- }
3443
- }, _callee4, this);
3444
- }));
3445
-
3446
- function getGlobalStats(_x4) {
3447
- return _getGlobalStats.apply(this, arguments);
3448
- }
3449
-
3450
- return getGlobalStats;
3451
- }()
3452
- }, {
3453
- key: "getFeatures",
3454
- value: function getFeatures(region) {
3455
- var _this3 = this;
3456
-
3457
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
3458
- var refName = region.refName,
3459
- start = region.start,
3460
- end = region.end;
3461
- var _opts$bpPerPx = opts.bpPerPx,
3462
- bpPerPx = _opts$bpPerPx === void 0 ? 0 : _opts$bpPerPx,
3463
- signal = opts.signal,
3464
- _opts$resolution = opts.resolution,
3465
- resolution = _opts$resolution === void 0 ? 1 : _opts$resolution,
3466
- _opts$statusCallback = opts.statusCallback,
3467
- statusCallback = _opts$statusCallback === void 0 ? function () {} : _opts$statusCallback;
3468
- return rxjs.ObservableCreate( /*#__PURE__*/function () {
3469
- var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(observer) {
3470
- var ob;
3471
- return runtime_1.wrap(function _callee5$(_context5) {
3472
- while (1) {
3473
- switch (_context5.prev = _context5.next) {
3474
- case 0:
3475
- statusCallback('Downloading bigwig data');
3476
- _context5.next = 3;
3477
- return _this3.bigwig.getFeatureStream(refName, start, end, _objectSpread2(_objectSpread2({}, opts), {}, {
3478
- basesPerSpan: bpPerPx / resolution
3479
- }));
3480
-
3481
- case 3:
3482
- ob = _context5.sent;
3483
- ob.pipe(operators.mergeAll(), operators.map(function (record) {
3484
- return new SimpleFeature({
3485
- id: "".concat(refName, ":").concat(record.start, "-").concat(record.end),
3486
- data: _objectSpread2(_objectSpread2({}, record), {}, {
3487
- refName: refName
3488
- })
3489
- });
3490
- })).subscribe(observer);
3491
-
3492
- case 5:
3493
- case "end":
3494
- return _context5.stop();
3495
- }
3496
- }
3497
- }, _callee5);
3498
- }));
3499
-
3500
- return function (_x5) {
3501
- return _ref2.apply(this, arguments);
3502
- };
3503
- }(), signal);
3504
- } // always render bigwig instead of calculating a feature density for it
3505
-
3506
- }, {
3507
- key: "estimateRegionsStats",
3508
- value: function () {
3509
- var _estimateRegionsStats = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(_regions) {
3510
- return runtime_1.wrap(function _callee6$(_context6) {
3511
- while (1) {
3512
- switch (_context6.prev = _context6.next) {
3513
- case 0:
3514
- return _context6.abrupt("return", {
3515
- featureDensity: 0
3516
- });
3517
-
3518
- case 1:
3519
- case "end":
3520
- return _context6.stop();
3521
- }
3522
- }
3523
- }, _callee6);
3524
- }));
3525
-
3526
- function estimateRegionsStats(_x6) {
3527
- return _estimateRegionsStats.apply(this, arguments);
3528
- }
3529
-
3530
- return estimateRegionsStats;
3531
- }()
3532
- }, {
3533
- key: "freeResources",
3534
- value: function freeResources() {}
3535
- }]);
3536
-
3537
- return BigWigAdapter;
3538
- }(BaseAdapter.BaseFeatureDataAdapter);
3539
- BigWigAdapter.capabilities = ['hasResolution', 'hasLocalStats', 'hasGlobalStats'];
3540
-
3541
- var BigWigAdapter$1 = {
3542
- __proto__: null,
3543
- 'default': BigWigAdapter
3544
- };
3545
-
3546
- exports.LinearWiggleDisplayReactComponent = LinearWiggleDisplay;
3547
- exports.Tooltip = Tooltip;
3548
- exports.WiggleBaseRenderer = WiggleBaseRenderer;
3549
- exports.WiggleRendering = XYPlotRendererReactComponent;
3550
- exports.YSCALEBAR_LABEL_OFFSET = YSCALEBAR_LABEL_OFFSET;
3551
- exports.default = WigglePlugin;
3552
- exports.getNiceDomain = getNiceDomain;
3553
- exports.getOrigin = getOrigin;
3554
- exports.getScale = getScale;
3555
- exports.linearWiggleDisplayModelFactory = stateModelFactory;
3556
- //# sourceMappingURL=plugin-wiggle.cjs.development.js.map