@jbrowse/plugin-wiggle 1.6.8 → 1.7.1

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