@jbrowse/plugin-variants 1.7.0 → 1.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/ChordVariantDisplay/index.d.ts +3 -3
  2. package/dist/ChordVariantDisplay/index.js +3 -3
  3. package/dist/ChordVariantDisplay/models/ChordVariantDisplay.d.ts +5 -5
  4. package/dist/ChordVariantDisplay/models/ChordVariantDisplay.js +3 -3
  5. package/dist/LinearVariantDisplay/configSchema.d.ts +5 -5
  6. package/dist/LinearVariantDisplay/configSchema.test.js +12 -12
  7. package/dist/LinearVariantDisplay/index.d.ts +2 -2
  8. package/dist/LinearVariantDisplay/index.js +1 -1
  9. package/dist/LinearVariantDisplay/model.d.ts +207 -207
  10. package/dist/LinearVariantDisplay/model.js +3 -3
  11. package/dist/StructuralVariantChordRenderer/ReactComponent.d.ts +24 -24
  12. package/dist/StructuralVariantChordRenderer/ReactComponent.js +17 -17
  13. package/dist/StructuralVariantChordRenderer/index.d.ts +3 -3
  14. package/dist/StructuralVariantChordRenderer/index.js +4 -4
  15. package/dist/VariantFeatureWidget/BreakendOptionDialog.d.ts +10 -10
  16. package/dist/VariantFeatureWidget/BreakendOptionDialog.js +13 -13
  17. package/dist/VariantFeatureWidget/VariantFeatureWidget.d.ts +4 -4
  18. package/dist/VariantFeatureWidget/VariantFeatureWidget.js +32 -32
  19. package/dist/VariantFeatureWidget/VariantFeatureWidget.test.js +2 -2
  20. package/dist/VariantFeatureWidget/index.d.ts +11 -11
  21. package/dist/VcfAdapter/VcfAdapter.d.ts +24 -24
  22. package/dist/VcfAdapter/VcfAdapter.js +26 -26
  23. package/dist/VcfAdapter/VcfAdapter.test.js +3 -3
  24. package/dist/VcfAdapter/configSchema.d.ts +2 -2
  25. package/dist/VcfAdapter/configSchema.js +2 -2
  26. package/dist/VcfAdapter/index.d.ts +1 -1
  27. package/dist/VcfAdapter/index.js +1 -1
  28. package/dist/VcfTabixAdapter/VcfFeature.d.ts +59 -59
  29. package/dist/VcfTabixAdapter/VcfFeature.js +19 -19
  30. package/dist/VcfTabixAdapter/VcfFeature.test.js +14 -14
  31. package/dist/VcfTabixAdapter/VcfTabixAdapter.d.ts +35 -35
  32. package/dist/VcfTabixAdapter/VcfTabixAdapter.js +26 -26
  33. package/dist/VcfTabixAdapter/VcfTabixAdapter.test.js +4 -4
  34. package/dist/VcfTabixAdapter/configSchema.d.ts +2 -2
  35. package/dist/VcfTabixAdapter/configSchema.js +2 -2
  36. package/dist/VcfTabixAdapter/index.d.ts +1 -1
  37. package/dist/VcfTabixAdapter/index.js +1 -1
  38. package/dist/index.d.ts +7 -7
  39. package/dist/index.js +19 -19
  40. package/dist/index.test.js +2 -2
  41. package/package.json +5 -3
  42. package/dist/LinearVariantDisplay/configSchema.test.d.ts +0 -1
  43. package/dist/VariantFeatureWidget/VariantFeatureWidget.test.d.ts +0 -1
  44. package/dist/index.test.d.ts +0 -1
  45. package/dist/plugin-variants.cjs.development.js +0 -2897
  46. package/dist/plugin-variants.cjs.development.js.map +0 -1
  47. package/dist/plugin-variants.cjs.production.min.js +0 -2
  48. package/dist/plugin-variants.cjs.production.min.js.map +0 -1
  49. package/dist/plugin-variants.esm.js +0 -2889
  50. package/dist/plugin-variants.esm.js.map +0 -1
@@ -1,2897 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
- var React = require('react');
8
- var React__default = _interopDefault(React);
9
- var configuration = require('@jbrowse/core/configuration');
10
- var AdapterType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/AdapterType'));
11
- var DisplayType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/DisplayType'));
12
- var models = require('@jbrowse/core/pluggableElementTypes/models');
13
- var TrackType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/TrackType'));
14
- var WidgetType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/WidgetType'));
15
- var Plugin = _interopDefault(require('@jbrowse/core/Plugin'));
16
- var pluginLinearGenomeView = require('@jbrowse/plugin-linear-genome-view');
17
- var pluginCircularView = require('@jbrowse/plugin-circular-view');
18
- var tracks = require('@jbrowse/core/util/tracks');
19
- var util = require('@jbrowse/core/util');
20
- var mobxStateTree = require('mobx-state-tree');
21
- var ChordRendererType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/renderers/CircularChordRendererType'));
22
- var mobxReact = require('mobx-react');
23
- var mst = require('@jbrowse/core/util/types/mst');
24
- var VCF = require('@gmod/vcf');
25
- var VCF__default = _interopDefault(VCF);
26
- var PropTypes = _interopDefault(require('prop-types'));
27
- var BaseAdapter = require('@jbrowse/core/data_adapters/BaseAdapter');
28
- var io = require('@jbrowse/core/util/io');
29
- var rxjs = require('@jbrowse/core/util/rxjs');
30
- var tabix = require('@gmod/tabix');
31
- var IntervalTree = _interopDefault(require('@flatten-js/interval-tree'));
32
- var bgzfFilehandle = require('@gmod/bgzf-filehandle');
33
- var core = require('@material-ui/core');
34
- var SimpleFeature = _interopDefault(require('@jbrowse/core/util/simpleFeature'));
35
- var xDataGrid = require('@mui/x-data-grid');
36
- var BaseFeatureDetail = require('@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail');
37
- var CloseIcon = _interopDefault(require('@material-ui/icons/Close'));
38
-
39
- function ownKeys(object, enumerableOnly) {
40
- var keys = Object.keys(object);
41
-
42
- if (Object.getOwnPropertySymbols) {
43
- var symbols = Object.getOwnPropertySymbols(object);
44
- enumerableOnly && (symbols = symbols.filter(function (sym) {
45
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
46
- })), keys.push.apply(keys, symbols);
47
- }
48
-
49
- return keys;
50
- }
51
-
52
- function _objectSpread2(target) {
53
- for (var i = 1; i < arguments.length; i++) {
54
- var source = null != arguments[i] ? arguments[i] : {};
55
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
56
- _defineProperty(target, key, source[key]);
57
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
58
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
59
- });
60
- }
61
-
62
- return target;
63
- }
64
-
65
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
66
- try {
67
- var info = gen[key](arg);
68
- var value = info.value;
69
- } catch (error) {
70
- reject(error);
71
- return;
72
- }
73
-
74
- if (info.done) {
75
- resolve(value);
76
- } else {
77
- Promise.resolve(value).then(_next, _throw);
78
- }
79
- }
80
-
81
- function _asyncToGenerator(fn) {
82
- return function () {
83
- var self = this,
84
- args = arguments;
85
- return new Promise(function (resolve, reject) {
86
- var gen = fn.apply(self, args);
87
-
88
- function _next(value) {
89
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
90
- }
91
-
92
- function _throw(err) {
93
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
94
- }
95
-
96
- _next(undefined);
97
- });
98
- };
99
- }
100
-
101
- function _classCallCheck(instance, Constructor) {
102
- if (!(instance instanceof Constructor)) {
103
- throw new TypeError("Cannot call a class as a function");
104
- }
105
- }
106
-
107
- function _defineProperties(target, props) {
108
- for (var i = 0; i < props.length; i++) {
109
- var descriptor = props[i];
110
- descriptor.enumerable = descriptor.enumerable || false;
111
- descriptor.configurable = true;
112
- if ("value" in descriptor) descriptor.writable = true;
113
- Object.defineProperty(target, descriptor.key, descriptor);
114
- }
115
- }
116
-
117
- function _createClass(Constructor, protoProps, staticProps) {
118
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
119
- if (staticProps) _defineProperties(Constructor, staticProps);
120
- Object.defineProperty(Constructor, "prototype", {
121
- writable: false
122
- });
123
- return Constructor;
124
- }
125
-
126
- function _defineProperty(obj, key, value) {
127
- if (key in obj) {
128
- Object.defineProperty(obj, key, {
129
- value: value,
130
- enumerable: true,
131
- configurable: true,
132
- writable: true
133
- });
134
- } else {
135
- obj[key] = value;
136
- }
137
-
138
- return obj;
139
- }
140
-
141
- function _inherits(subClass, superClass) {
142
- if (typeof superClass !== "function" && superClass !== null) {
143
- throw new TypeError("Super expression must either be null or a function");
144
- }
145
-
146
- subClass.prototype = Object.create(superClass && superClass.prototype, {
147
- constructor: {
148
- value: subClass,
149
- writable: true,
150
- configurable: true
151
- }
152
- });
153
- Object.defineProperty(subClass, "prototype", {
154
- writable: false
155
- });
156
- if (superClass) _setPrototypeOf(subClass, superClass);
157
- }
158
-
159
- function _getPrototypeOf(o) {
160
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
161
- return o.__proto__ || Object.getPrototypeOf(o);
162
- };
163
- return _getPrototypeOf(o);
164
- }
165
-
166
- function _setPrototypeOf(o, p) {
167
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
168
- o.__proto__ = p;
169
- return o;
170
- };
171
-
172
- return _setPrototypeOf(o, p);
173
- }
174
-
175
- function _isNativeReflectConstruct() {
176
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
177
- if (Reflect.construct.sham) return false;
178
- if (typeof Proxy === "function") return true;
179
-
180
- try {
181
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
182
- return true;
183
- } catch (e) {
184
- return false;
185
- }
186
- }
187
-
188
- function _objectWithoutPropertiesLoose(source, excluded) {
189
- if (source == null) return {};
190
- var target = {};
191
- var sourceKeys = Object.keys(source);
192
- var key, i;
193
-
194
- for (i = 0; i < sourceKeys.length; i++) {
195
- key = sourceKeys[i];
196
- if (excluded.indexOf(key) >= 0) continue;
197
- target[key] = source[key];
198
- }
199
-
200
- return target;
201
- }
202
-
203
- function _objectWithoutProperties(source, excluded) {
204
- if (source == null) return {};
205
-
206
- var target = _objectWithoutPropertiesLoose(source, excluded);
207
-
208
- var key, i;
209
-
210
- if (Object.getOwnPropertySymbols) {
211
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
212
-
213
- for (i = 0; i < sourceSymbolKeys.length; i++) {
214
- key = sourceSymbolKeys[i];
215
- if (excluded.indexOf(key) >= 0) continue;
216
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
217
- target[key] = source[key];
218
- }
219
- }
220
-
221
- return target;
222
- }
223
-
224
- function _assertThisInitialized(self) {
225
- if (self === void 0) {
226
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
227
- }
228
-
229
- return self;
230
- }
231
-
232
- function _possibleConstructorReturn(self, call) {
233
- if (call && (typeof call === "object" || typeof call === "function")) {
234
- return call;
235
- } else if (call !== void 0) {
236
- throw new TypeError("Derived constructors may only return object or undefined");
237
- }
238
-
239
- return _assertThisInitialized(self);
240
- }
241
-
242
- function _createSuper(Derived) {
243
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
244
-
245
- return function _createSuperInternal() {
246
- var Super = _getPrototypeOf(Derived),
247
- result;
248
-
249
- if (hasNativeReflectConstruct) {
250
- var NewTarget = _getPrototypeOf(this).constructor;
251
-
252
- result = Reflect.construct(Super, arguments, NewTarget);
253
- } else {
254
- result = Super.apply(this, arguments);
255
- }
256
-
257
- return _possibleConstructorReturn(this, result);
258
- };
259
- }
260
-
261
- function _superPropBase(object, property) {
262
- while (!Object.prototype.hasOwnProperty.call(object, property)) {
263
- object = _getPrototypeOf(object);
264
- if (object === null) break;
265
- }
266
-
267
- return object;
268
- }
269
-
270
- function _get() {
271
- if (typeof Reflect !== "undefined" && Reflect.get) {
272
- _get = Reflect.get;
273
- } else {
274
- _get = function _get(target, property, receiver) {
275
- var base = _superPropBase(target, property);
276
-
277
- if (!base) return;
278
- var desc = Object.getOwnPropertyDescriptor(base, property);
279
-
280
- if (desc.get) {
281
- return desc.get.call(arguments.length < 3 ? target : receiver);
282
- }
283
-
284
- return desc.value;
285
- };
286
- }
287
-
288
- return _get.apply(this, arguments);
289
- }
290
-
291
- function _slicedToArray(arr, i) {
292
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
293
- }
294
-
295
- function _toConsumableArray(arr) {
296
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
297
- }
298
-
299
- function _arrayWithoutHoles(arr) {
300
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
301
- }
302
-
303
- function _arrayWithHoles(arr) {
304
- if (Array.isArray(arr)) return arr;
305
- }
306
-
307
- function _iterableToArray(iter) {
308
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
309
- }
310
-
311
- function _iterableToArrayLimit(arr, i) {
312
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
313
-
314
- if (_i == null) return;
315
- var _arr = [];
316
- var _n = true;
317
- var _d = false;
318
-
319
- var _s, _e;
320
-
321
- try {
322
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
323
- _arr.push(_s.value);
324
-
325
- if (i && _arr.length === i) break;
326
- }
327
- } catch (err) {
328
- _d = true;
329
- _e = err;
330
- } finally {
331
- try {
332
- if (!_n && _i["return"] != null) _i["return"]();
333
- } finally {
334
- if (_d) throw _e;
335
- }
336
- }
337
-
338
- return _arr;
339
- }
340
-
341
- function _unsupportedIterableToArray(o, minLen) {
342
- if (!o) return;
343
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
344
- var n = Object.prototype.toString.call(o).slice(8, -1);
345
- if (n === "Object" && o.constructor) n = o.constructor.name;
346
- if (n === "Map" || n === "Set") return Array.from(o);
347
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
348
- }
349
-
350
- function _arrayLikeToArray(arr, len) {
351
- if (len == null || len > arr.length) len = arr.length;
352
-
353
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
354
-
355
- return arr2;
356
- }
357
-
358
- function _nonIterableSpread() {
359
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
360
- }
361
-
362
- function _nonIterableRest() {
363
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
364
- }
365
-
366
- function _createForOfIteratorHelper(o, allowArrayLike) {
367
- var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"];
368
-
369
- if (!it) {
370
- if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
371
- if (it) o = it;
372
- var i = 0;
373
-
374
- var F = function () {};
375
-
376
- return {
377
- s: F,
378
- n: function () {
379
- if (i >= o.length) return {
380
- done: true
381
- };
382
- return {
383
- done: false,
384
- value: o[i++]
385
- };
386
- },
387
- e: function (e) {
388
- throw e;
389
- },
390
- f: F
391
- };
392
- }
393
-
394
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
395
- }
396
-
397
- var normalCompletion = true,
398
- didErr = false,
399
- err;
400
- return {
401
- s: function () {
402
- it = it.call(o);
403
- },
404
- n: function () {
405
- var step = it.next();
406
- normalCompletion = step.done;
407
- return step;
408
- },
409
- e: function (e) {
410
- didErr = true;
411
- err = e;
412
- },
413
- f: function () {
414
- try {
415
- if (!normalCompletion && it.return != null) it.return();
416
- } finally {
417
- if (didErr) throw err;
418
- }
419
- }
420
- };
421
- }
422
-
423
- var ChordVariantDisplayF = function ChordVariantDisplayF(pluginManager) {
424
- var jbrequire = pluginManager.jbrequire;
425
-
426
- var _jbrequire = jbrequire('mobx-state-tree'),
427
- types = _jbrequire.types;
428
-
429
- var _jbrequire2 = jbrequire('@jbrowse/core/configuration'),
430
- ConfigurationSchema = _jbrequire2.ConfigurationSchema,
431
- ConfigurationReference = _jbrequire2.ConfigurationReference;
432
-
433
- var _jbrequire3 = jbrequire('@jbrowse/core/util'),
434
- getContainingView = _jbrequire3.getContainingView;
435
-
436
- var _jbrequire4 = jbrequire('@jbrowse/core/util/tracks'),
437
- getParentRenderProps = _jbrequire4.getParentRenderProps;
438
-
439
- var configSchema = ConfigurationSchema('ChordVariantDisplay', {
440
- renderer: types.optional(pluginManager.pluggableConfigSchemaType('renderer'), {
441
- type: 'StructuralVariantChordRenderer'
442
- })
443
- }, {
444
- baseConfiguration: pluginCircularView.baseChordDisplayConfig,
445
- explicitlyTyped: true
446
- });
447
- var stateModel = types.compose('ChordVariantDisplay', pluginCircularView.BaseChordDisplayModel, types.model({
448
- type: types.literal('ChordVariantDisplay'),
449
- configuration: ConfigurationReference(configSchema)
450
- })).views(function (self) {
451
- return {
452
- get rendererTypeName() {
453
- return self.configuration.renderer.type;
454
- },
455
-
456
- renderProps: function renderProps() {
457
- var view = getContainingView(self);
458
- return _objectSpread2(_objectSpread2({}, getParentRenderProps(self)), {}, {
459
- rpcDriverName: self.rpcDriverName,
460
- displayModel: self,
461
- bezierRadius: view.radiusPx * self.bezierRadiusRatio,
462
- radius: view.radiusPx,
463
- blockDefinitions: this.blockDefinitions,
464
- config: self.configuration.renderer,
465
- onChordClick: self.onChordClick
466
- });
467
- }
468
- };
469
- });
470
- return {
471
- stateModel: stateModel,
472
- configSchema: configSchema
473
- };
474
- }; // http://localhost:3000/test_data/hs37d5.HG002-SequelII-CCS.sv.vcf.gz.tbi
475
-
476
- var ChordVariantDisplay = (function (pluginManager) {
477
- var lib = pluginManager.lib,
478
- load = pluginManager.load;
479
- var DisplayType = lib['@jbrowse/core/pluggableElementTypes/DisplayType'];
480
-
481
- var _load = load(ChordVariantDisplayF),
482
- stateModel = _load.stateModel,
483
- configSchema = _load.configSchema;
484
-
485
- return new DisplayType({
486
- name: 'ChordVariantDisplay',
487
- configSchema: configSchema,
488
- stateModel: stateModel,
489
- trackType: 'VariantTrack',
490
- viewType: 'CircularView',
491
- ReactComponent: pluginCircularView.BaseChordDisplayComponentFactory(pluginManager)
492
- });
493
- });
494
-
495
- function LinearVariantDisplayConfigFactory(pluginManager) {
496
- var configSchema = pluginLinearGenomeView.linearBasicDisplayConfigSchemaFactory(pluginManager);
497
- return configuration.ConfigurationSchema('LinearVariantDisplay', {}, {
498
- baseConfiguration: configSchema,
499
- explicitlyTyped: true
500
- });
501
- }
502
-
503
- function createCommonjsModule(fn, module) {
504
- return module = { exports: {} }, fn(module, module.exports), module.exports;
505
- }
506
-
507
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
508
- /**
509
- * Copyright (c) 2014-present, Facebook, Inc.
510
- *
511
- * This source code is licensed under the MIT license found in the
512
- * LICENSE file in the root directory of this source tree.
513
- */
514
- var runtime = function (exports) {
515
-
516
- var Op = Object.prototype;
517
- var hasOwn = Op.hasOwnProperty;
518
- var undefined$1; // More compressible than void 0.
519
-
520
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
521
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
522
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
523
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
524
-
525
- function define(obj, key, value) {
526
- Object.defineProperty(obj, key, {
527
- value: value,
528
- enumerable: true,
529
- configurable: true,
530
- writable: true
531
- });
532
- return obj[key];
533
- }
534
-
535
- try {
536
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
537
- define({}, "");
538
- } catch (err) {
539
- define = function define(obj, key, value) {
540
- return obj[key] = value;
541
- };
542
- }
543
-
544
- function wrap(innerFn, outerFn, self, tryLocsList) {
545
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
546
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
547
- var generator = Object.create(protoGenerator.prototype);
548
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
549
- // .throw, and .return methods.
550
-
551
- generator._invoke = makeInvokeMethod(innerFn, self, context);
552
- return generator;
553
- }
554
-
555
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
556
- // record like context.tryEntries[i].completion. This interface could
557
- // have been (and was previously) designed to take a closure to be
558
- // invoked without arguments, but in all the cases we care about we
559
- // already have an existing method we want to call, so there's no need
560
- // to create a new function object. We can even get away with assuming
561
- // the method takes exactly one argument, since that happens to be true
562
- // in every case, so we don't have to touch the arguments object. The
563
- // only additional allocation required is the completion record, which
564
- // has a stable shape and so hopefully should be cheap to allocate.
565
-
566
- function tryCatch(fn, obj, arg) {
567
- try {
568
- return {
569
- type: "normal",
570
- arg: fn.call(obj, arg)
571
- };
572
- } catch (err) {
573
- return {
574
- type: "throw",
575
- arg: err
576
- };
577
- }
578
- }
579
-
580
- var GenStateSuspendedStart = "suspendedStart";
581
- var GenStateSuspendedYield = "suspendedYield";
582
- var GenStateExecuting = "executing";
583
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
584
- // breaking out of the dispatch switch statement.
585
-
586
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
587
- // .constructor.prototype properties for functions that return Generator
588
- // objects. For full spec compliance, you may wish to configure your
589
- // minifier not to mangle the names of these two functions.
590
-
591
- function Generator() {}
592
-
593
- function GeneratorFunction() {}
594
-
595
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
596
- // don't natively support it.
597
-
598
-
599
- var IteratorPrototype = {};
600
- define(IteratorPrototype, iteratorSymbol, function () {
601
- return this;
602
- });
603
- var getProto = Object.getPrototypeOf;
604
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
605
-
606
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
607
- // This environment has a native %IteratorPrototype%; use it instead
608
- // of the polyfill.
609
- IteratorPrototype = NativeIteratorPrototype;
610
- }
611
-
612
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
613
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
614
- define(Gp, "constructor", GeneratorFunctionPrototype);
615
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
616
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
617
- // Iterator interface in terms of a single ._invoke method.
618
-
619
- function defineIteratorMethods(prototype) {
620
- ["next", "throw", "return"].forEach(function (method) {
621
- define(prototype, method, function (arg) {
622
- return this._invoke(method, arg);
623
- });
624
- });
625
- }
626
-
627
- exports.isGeneratorFunction = function (genFun) {
628
- var ctor = typeof genFun === "function" && genFun.constructor;
629
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
630
- // do is to check its .name property.
631
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
632
- };
633
-
634
- exports.mark = function (genFun) {
635
- if (Object.setPrototypeOf) {
636
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
637
- } else {
638
- genFun.__proto__ = GeneratorFunctionPrototype;
639
- define(genFun, toStringTagSymbol, "GeneratorFunction");
640
- }
641
-
642
- genFun.prototype = Object.create(Gp);
643
- return genFun;
644
- }; // Within the body of any async function, `await x` is transformed to
645
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
646
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
647
- // meant to be awaited.
648
-
649
-
650
- exports.awrap = function (arg) {
651
- return {
652
- __await: arg
653
- };
654
- };
655
-
656
- function AsyncIterator(generator, PromiseImpl) {
657
- function invoke(method, arg, resolve, reject) {
658
- var record = tryCatch(generator[method], generator, arg);
659
-
660
- if (record.type === "throw") {
661
- reject(record.arg);
662
- } else {
663
- var result = record.arg;
664
- var value = result.value;
665
-
666
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
667
- return PromiseImpl.resolve(value.__await).then(function (value) {
668
- invoke("next", value, resolve, reject);
669
- }, function (err) {
670
- invoke("throw", err, resolve, reject);
671
- });
672
- }
673
-
674
- return PromiseImpl.resolve(value).then(function (unwrapped) {
675
- // When a yielded Promise is resolved, its final value becomes
676
- // the .value of the Promise<{value,done}> result for the
677
- // current iteration.
678
- result.value = unwrapped;
679
- resolve(result);
680
- }, function (error) {
681
- // If a rejected Promise was yielded, throw the rejection back
682
- // into the async generator function so it can be handled there.
683
- return invoke("throw", error, resolve, reject);
684
- });
685
- }
686
- }
687
-
688
- var previousPromise;
689
-
690
- function enqueue(method, arg) {
691
- function callInvokeWithMethodAndArg() {
692
- return new PromiseImpl(function (resolve, reject) {
693
- invoke(method, arg, resolve, reject);
694
- });
695
- }
696
-
697
- return previousPromise = // If enqueue has been called before, then we want to wait until
698
- // all previous Promises have been resolved before calling invoke,
699
- // so that results are always delivered in the correct order. If
700
- // enqueue has not been called before, then it is important to
701
- // call invoke immediately, without waiting on a callback to fire,
702
- // so that the async generator function has the opportunity to do
703
- // any necessary setup in a predictable way. This predictability
704
- // is why the Promise constructor synchronously invokes its
705
- // executor callback, and why async functions synchronously
706
- // execute code before the first await. Since we implement simple
707
- // async functions in terms of async generators, it is especially
708
- // important to get this right, even though it requires care.
709
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
710
- // invocations of the iterator.
711
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
712
- } // Define the unified helper method that is used to implement .next,
713
- // .throw, and .return (see defineIteratorMethods).
714
-
715
-
716
- this._invoke = enqueue;
717
- }
718
-
719
- defineIteratorMethods(AsyncIterator.prototype);
720
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
721
- return this;
722
- });
723
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
724
- // AsyncIterator objects; they just return a Promise for the value of
725
- // the final result produced by the iterator.
726
-
727
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
728
- if (PromiseImpl === void 0) PromiseImpl = Promise;
729
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
730
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
731
- : iter.next().then(function (result) {
732
- return result.done ? result.value : iter.next();
733
- });
734
- };
735
-
736
- function makeInvokeMethod(innerFn, self, context) {
737
- var state = GenStateSuspendedStart;
738
- return function invoke(method, arg) {
739
- if (state === GenStateExecuting) {
740
- throw new Error("Generator is already running");
741
- }
742
-
743
- if (state === GenStateCompleted) {
744
- if (method === "throw") {
745
- throw arg;
746
- } // Be forgiving, per 25.3.3.3.3 of the spec:
747
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
748
-
749
-
750
- return doneResult();
751
- }
752
-
753
- context.method = method;
754
- context.arg = arg;
755
-
756
- while (true) {
757
- var delegate = context.delegate;
758
-
759
- if (delegate) {
760
- var delegateResult = maybeInvokeDelegate(delegate, context);
761
-
762
- if (delegateResult) {
763
- if (delegateResult === ContinueSentinel) continue;
764
- return delegateResult;
765
- }
766
- }
767
-
768
- if (context.method === "next") {
769
- // Setting context._sent for legacy support of Babel's
770
- // function.sent implementation.
771
- context.sent = context._sent = context.arg;
772
- } else if (context.method === "throw") {
773
- if (state === GenStateSuspendedStart) {
774
- state = GenStateCompleted;
775
- throw context.arg;
776
- }
777
-
778
- context.dispatchException(context.arg);
779
- } else if (context.method === "return") {
780
- context.abrupt("return", context.arg);
781
- }
782
-
783
- state = GenStateExecuting;
784
- var record = tryCatch(innerFn, self, context);
785
-
786
- if (record.type === "normal") {
787
- // If an exception is thrown from innerFn, we leave state ===
788
- // GenStateExecuting and loop back for another invocation.
789
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
790
-
791
- if (record.arg === ContinueSentinel) {
792
- continue;
793
- }
794
-
795
- return {
796
- value: record.arg,
797
- done: context.done
798
- };
799
- } else if (record.type === "throw") {
800
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
801
- // context.dispatchException(context.arg) call above.
802
-
803
- context.method = "throw";
804
- context.arg = record.arg;
805
- }
806
- }
807
- };
808
- } // Call delegate.iterator[context.method](context.arg) and handle the
809
- // result, either by returning a { value, done } result from the
810
- // delegate iterator, or by modifying context.method and context.arg,
811
- // setting context.delegate to null, and returning the ContinueSentinel.
812
-
813
-
814
- function maybeInvokeDelegate(delegate, context) {
815
- var method = delegate.iterator[context.method];
816
-
817
- if (method === undefined$1) {
818
- // A .throw or .return when the delegate iterator has no .throw
819
- // method always terminates the yield* loop.
820
- context.delegate = null;
821
-
822
- if (context.method === "throw") {
823
- // Note: ["return"] must be used for ES3 parsing compatibility.
824
- if (delegate.iterator["return"]) {
825
- // If the delegate iterator has a return method, give it a
826
- // chance to clean up.
827
- context.method = "return";
828
- context.arg = undefined$1;
829
- maybeInvokeDelegate(delegate, context);
830
-
831
- if (context.method === "throw") {
832
- // If maybeInvokeDelegate(context) changed context.method from
833
- // "return" to "throw", let that override the TypeError below.
834
- return ContinueSentinel;
835
- }
836
- }
837
-
838
- context.method = "throw";
839
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
840
- }
841
-
842
- return ContinueSentinel;
843
- }
844
-
845
- var record = tryCatch(method, delegate.iterator, context.arg);
846
-
847
- if (record.type === "throw") {
848
- context.method = "throw";
849
- context.arg = record.arg;
850
- context.delegate = null;
851
- return ContinueSentinel;
852
- }
853
-
854
- var info = record.arg;
855
-
856
- if (!info) {
857
- context.method = "throw";
858
- context.arg = new TypeError("iterator result is not an object");
859
- context.delegate = null;
860
- return ContinueSentinel;
861
- }
862
-
863
- if (info.done) {
864
- // Assign the result of the finished delegate to the temporary
865
- // variable specified by delegate.resultName (see delegateYield).
866
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
867
-
868
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
869
- // exception, let the outer generator proceed normally. If
870
- // context.method was "next", forget context.arg since it has been
871
- // "consumed" by the delegate iterator. If context.method was
872
- // "return", allow the original .return call to continue in the
873
- // outer generator.
874
-
875
- if (context.method !== "return") {
876
- context.method = "next";
877
- context.arg = undefined$1;
878
- }
879
- } else {
880
- // Re-yield the result returned by the delegate method.
881
- return info;
882
- } // The delegate iterator is finished, so forget it and continue with
883
- // the outer generator.
884
-
885
-
886
- context.delegate = null;
887
- return ContinueSentinel;
888
- } // Define Generator.prototype.{next,throw,return} in terms of the
889
- // unified ._invoke helper method.
890
-
891
-
892
- defineIteratorMethods(Gp);
893
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
894
- // @@iterator function is called on it. Some browsers' implementations of the
895
- // iterator prototype chain incorrectly implement this, causing the Generator
896
- // object to not be returned from this call. This ensures that doesn't happen.
897
- // See https://github.com/facebook/regenerator/issues/274 for more details.
898
-
899
- define(Gp, iteratorSymbol, function () {
900
- return this;
901
- });
902
- define(Gp, "toString", function () {
903
- return "[object Generator]";
904
- });
905
-
906
- function pushTryEntry(locs) {
907
- var entry = {
908
- tryLoc: locs[0]
909
- };
910
-
911
- if (1 in locs) {
912
- entry.catchLoc = locs[1];
913
- }
914
-
915
- if (2 in locs) {
916
- entry.finallyLoc = locs[2];
917
- entry.afterLoc = locs[3];
918
- }
919
-
920
- this.tryEntries.push(entry);
921
- }
922
-
923
- function resetTryEntry(entry) {
924
- var record = entry.completion || {};
925
- record.type = "normal";
926
- delete record.arg;
927
- entry.completion = record;
928
- }
929
-
930
- function Context(tryLocsList) {
931
- // The root entry object (effectively a try statement without a catch
932
- // or a finally block) gives us a place to store values thrown from
933
- // locations where there is no enclosing try statement.
934
- this.tryEntries = [{
935
- tryLoc: "root"
936
- }];
937
- tryLocsList.forEach(pushTryEntry, this);
938
- this.reset(true);
939
- }
940
-
941
- exports.keys = function (object) {
942
- var keys = [];
943
-
944
- for (var key in object) {
945
- keys.push(key);
946
- }
947
-
948
- keys.reverse(); // Rather than returning an object with a next method, we keep
949
- // things simple and return the next function itself.
950
-
951
- return function next() {
952
- while (keys.length) {
953
- var key = keys.pop();
954
-
955
- if (key in object) {
956
- next.value = key;
957
- next.done = false;
958
- return next;
959
- }
960
- } // To avoid creating an additional object, we just hang the .value
961
- // and .done properties off the next function object itself. This
962
- // also ensures that the minifier will not anonymize the function.
963
-
964
-
965
- next.done = true;
966
- return next;
967
- };
968
- };
969
-
970
- function values(iterable) {
971
- if (iterable) {
972
- var iteratorMethod = iterable[iteratorSymbol];
973
-
974
- if (iteratorMethod) {
975
- return iteratorMethod.call(iterable);
976
- }
977
-
978
- if (typeof iterable.next === "function") {
979
- return iterable;
980
- }
981
-
982
- if (!isNaN(iterable.length)) {
983
- var i = -1,
984
- next = function next() {
985
- while (++i < iterable.length) {
986
- if (hasOwn.call(iterable, i)) {
987
- next.value = iterable[i];
988
- next.done = false;
989
- return next;
990
- }
991
- }
992
-
993
- next.value = undefined$1;
994
- next.done = true;
995
- return next;
996
- };
997
-
998
- return next.next = next;
999
- }
1000
- } // Return an iterator with no values.
1001
-
1002
-
1003
- return {
1004
- next: doneResult
1005
- };
1006
- }
1007
-
1008
- exports.values = values;
1009
-
1010
- function doneResult() {
1011
- return {
1012
- value: undefined$1,
1013
- done: true
1014
- };
1015
- }
1016
-
1017
- Context.prototype = {
1018
- constructor: Context,
1019
- reset: function reset(skipTempReset) {
1020
- this.prev = 0;
1021
- this.next = 0; // Resetting context._sent for legacy support of Babel's
1022
- // function.sent implementation.
1023
-
1024
- this.sent = this._sent = undefined$1;
1025
- this.done = false;
1026
- this.delegate = null;
1027
- this.method = "next";
1028
- this.arg = undefined$1;
1029
- this.tryEntries.forEach(resetTryEntry);
1030
-
1031
- if (!skipTempReset) {
1032
- for (var name in this) {
1033
- // Not sure about the optimal order of these conditions:
1034
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
1035
- this[name] = undefined$1;
1036
- }
1037
- }
1038
- }
1039
- },
1040
- stop: function stop() {
1041
- this.done = true;
1042
- var rootEntry = this.tryEntries[0];
1043
- var rootRecord = rootEntry.completion;
1044
-
1045
- if (rootRecord.type === "throw") {
1046
- throw rootRecord.arg;
1047
- }
1048
-
1049
- return this.rval;
1050
- },
1051
- dispatchException: function dispatchException(exception) {
1052
- if (this.done) {
1053
- throw exception;
1054
- }
1055
-
1056
- var context = this;
1057
-
1058
- function handle(loc, caught) {
1059
- record.type = "throw";
1060
- record.arg = exception;
1061
- context.next = loc;
1062
-
1063
- if (caught) {
1064
- // If the dispatched exception was caught by a catch block,
1065
- // then let that catch block handle the exception normally.
1066
- context.method = "next";
1067
- context.arg = undefined$1;
1068
- }
1069
-
1070
- return !!caught;
1071
- }
1072
-
1073
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1074
- var entry = this.tryEntries[i];
1075
- var record = entry.completion;
1076
-
1077
- if (entry.tryLoc === "root") {
1078
- // Exception thrown outside of any try block that could handle
1079
- // it, so set the completion value of the entire function to
1080
- // throw the exception.
1081
- return handle("end");
1082
- }
1083
-
1084
- if (entry.tryLoc <= this.prev) {
1085
- var hasCatch = hasOwn.call(entry, "catchLoc");
1086
- var hasFinally = hasOwn.call(entry, "finallyLoc");
1087
-
1088
- if (hasCatch && hasFinally) {
1089
- if (this.prev < entry.catchLoc) {
1090
- return handle(entry.catchLoc, true);
1091
- } else if (this.prev < entry.finallyLoc) {
1092
- return handle(entry.finallyLoc);
1093
- }
1094
- } else if (hasCatch) {
1095
- if (this.prev < entry.catchLoc) {
1096
- return handle(entry.catchLoc, true);
1097
- }
1098
- } else if (hasFinally) {
1099
- if (this.prev < entry.finallyLoc) {
1100
- return handle(entry.finallyLoc);
1101
- }
1102
- } else {
1103
- throw new Error("try statement without catch or finally");
1104
- }
1105
- }
1106
- }
1107
- },
1108
- abrupt: function abrupt(type, arg) {
1109
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1110
- var entry = this.tryEntries[i];
1111
-
1112
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1113
- var finallyEntry = entry;
1114
- break;
1115
- }
1116
- }
1117
-
1118
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
1119
- // Ignore the finally entry if control is not jumping to a
1120
- // location outside the try/catch block.
1121
- finallyEntry = null;
1122
- }
1123
-
1124
- var record = finallyEntry ? finallyEntry.completion : {};
1125
- record.type = type;
1126
- record.arg = arg;
1127
-
1128
- if (finallyEntry) {
1129
- this.method = "next";
1130
- this.next = finallyEntry.finallyLoc;
1131
- return ContinueSentinel;
1132
- }
1133
-
1134
- return this.complete(record);
1135
- },
1136
- complete: function complete(record, afterLoc) {
1137
- if (record.type === "throw") {
1138
- throw record.arg;
1139
- }
1140
-
1141
- if (record.type === "break" || record.type === "continue") {
1142
- this.next = record.arg;
1143
- } else if (record.type === "return") {
1144
- this.rval = this.arg = record.arg;
1145
- this.method = "return";
1146
- this.next = "end";
1147
- } else if (record.type === "normal" && afterLoc) {
1148
- this.next = afterLoc;
1149
- }
1150
-
1151
- return ContinueSentinel;
1152
- },
1153
- finish: function finish(finallyLoc) {
1154
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1155
- var entry = this.tryEntries[i];
1156
-
1157
- if (entry.finallyLoc === finallyLoc) {
1158
- this.complete(entry.completion, entry.afterLoc);
1159
- resetTryEntry(entry);
1160
- return ContinueSentinel;
1161
- }
1162
- }
1163
- },
1164
- "catch": function _catch(tryLoc) {
1165
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1166
- var entry = this.tryEntries[i];
1167
-
1168
- if (entry.tryLoc === tryLoc) {
1169
- var record = entry.completion;
1170
-
1171
- if (record.type === "throw") {
1172
- var thrown = record.arg;
1173
- resetTryEntry(entry);
1174
- }
1175
-
1176
- return thrown;
1177
- }
1178
- } // The context.catch method must only be called with a location
1179
- // argument that corresponds to a known catch block.
1180
-
1181
-
1182
- throw new Error("illegal catch attempt");
1183
- },
1184
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1185
- this.delegate = {
1186
- iterator: values(iterable),
1187
- resultName: resultName,
1188
- nextLoc: nextLoc
1189
- };
1190
-
1191
- if (this.method === "next") {
1192
- // Deliberately forget the last sent value so that we don't
1193
- // accidentally pass it on to the delegate.
1194
- this.arg = undefined$1;
1195
- }
1196
-
1197
- return ContinueSentinel;
1198
- }
1199
- }; // Regardless of whether this script is executing as a CommonJS module
1200
- // or not, return the runtime object so that we can declare the variable
1201
- // regeneratorRuntime in the outer scope, which allows this module to be
1202
- // injected easily by `bin/regenerator --include-runtime script.js`.
1203
-
1204
- return exports;
1205
- }( // If this script is executing as a CommonJS module, use module.exports
1206
- // as the regeneratorRuntime namespace. Otherwise create a new empty
1207
- // object. Either way, the resulting object will be used to initialize
1208
- // the regeneratorRuntime variable at the top of this file.
1209
- module.exports );
1210
-
1211
- try {
1212
- regeneratorRuntime = runtime;
1213
- } catch (accidentalStrictMode) {
1214
- // This module should not be running in strict mode, so the above
1215
- // assignment should always work unless something is misconfigured. Just
1216
- // in case runtime.js accidentally runs in strict mode, in modern engines
1217
- // we can explicitly access globalThis. In older engines we can escape
1218
- // strict mode using a global Function call. This could conceivably fail
1219
- // if a Content Security Policy forbids using Function, but in that case
1220
- // the proper solution is to fix the accidental strict mode problem. If
1221
- // you've misconfigured your bundler to force strict mode and applied a
1222
- // CSP to forbid Function, and you're not willing to fix either of those
1223
- // problems, please detail your unique predicament in a GitHub issue.
1224
- if (typeof globalThis === "object") {
1225
- globalThis.regeneratorRuntime = runtime;
1226
- } else {
1227
- Function("r", "regeneratorRuntime = r")(runtime);
1228
- }
1229
- }
1230
- });
1231
-
1232
- function linearVariantDisplayModelFactory (configSchema) {
1233
- return mobxStateTree.types.compose('LinearVariantDisplay', pluginLinearGenomeView.linearBasicDisplayModelFactory(configSchema), mobxStateTree.types.model({
1234
- type: mobxStateTree.types.literal('LinearVariantDisplay'),
1235
- configuration: configuration.ConfigurationReference(configSchema)
1236
- })).actions(function (self) {
1237
- return {
1238
- selectFeature: function selectFeature(feature) {
1239
- return _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1240
- var session, rpcManager, sessionId, track, adapterConfig, header, featureWidget;
1241
- return runtime_1.wrap(function _callee$(_context) {
1242
- while (1) {
1243
- switch (_context.prev = _context.next) {
1244
- case 0:
1245
- session = util.getSession(self);
1246
-
1247
- if (!util.isSessionModelWithWidgets(session)) {
1248
- _context.next = 11;
1249
- break;
1250
- }
1251
-
1252
- rpcManager = session.rpcManager;
1253
- sessionId = tracks.getRpcSessionId(self);
1254
- track = util.getContainingTrack(self);
1255
- adapterConfig = configuration.getConf(track, 'adapter');
1256
- _context.next = 8;
1257
- return rpcManager.call(sessionId, 'CoreGetMetadata', {
1258
- adapterConfig: adapterConfig
1259
- });
1260
-
1261
- case 8:
1262
- header = _context.sent;
1263
- featureWidget = session.addWidget('VariantFeatureWidget', 'variantFeature', {
1264
- featureData: feature.toJSON(),
1265
- view: util.getContainingView(self),
1266
- descriptions: header
1267
- });
1268
- session.showWidget(featureWidget);
1269
-
1270
- case 11:
1271
- session.setSelection(feature);
1272
-
1273
- case 12:
1274
- case "end":
1275
- return _context.stop();
1276
- }
1277
- }
1278
- }, _callee);
1279
- }))();
1280
- }
1281
- };
1282
- });
1283
- }
1284
-
1285
- function bpToRadians(block, pos) {
1286
- var blockStart = block.region.elided ? 0 : block.region.start;
1287
- var blockEnd = block.region.elided ? 0 : block.region.end;
1288
- var bpOffset = block.flipped ? blockEnd - pos : pos - blockStart;
1289
- var radians = bpOffset / block.bpPerRadian + block.startRadians;
1290
- return radians;
1291
- }
1292
-
1293
- var Chord = /*#__PURE__*/mobxReact.observer(function Chord(_ref) {
1294
- var _feature$get;
1295
-
1296
- var feature = _ref.feature,
1297
- blocksForRefs = _ref.blocksForRefs,
1298
- radius = _ref.radius,
1299
- config = _ref.config,
1300
- bezierRadius = _ref.bezierRadius,
1301
- selected = _ref.selected,
1302
- _onClick = _ref.onClick;
1303
- // find the blocks that our start and end points belong to
1304
- var startBlock = blocksForRefs[feature.get('refName')];
1305
-
1306
- if (!startBlock) {
1307
- return null;
1308
- }
1309
-
1310
- var svType;
1311
-
1312
- if (feature.get('INFO')) {
1313
-
1314
- var _ref2 = feature.get('INFO').SVTYPE || [];
1315
-
1316
- var _ref3 = _slicedToArray(_ref2, 1);
1317
-
1318
- svType = _ref3[0];
1319
- } else if (feature.get('mate')) {
1320
- svType = 'mate';
1321
- }
1322
-
1323
- var endPosition;
1324
- var endBlock;
1325
- var alt = (_feature$get = feature.get('ALT')) === null || _feature$get === void 0 ? void 0 : _feature$get[0];
1326
- var bnd = alt && VCF.parseBreakend(alt);
1327
-
1328
- if (bnd) {
1329
- // VCF BND
1330
- var matePosition = bnd.MatePosition.split(':');
1331
- endPosition = +matePosition[1];
1332
- endBlock = blocksForRefs[matePosition[0]];
1333
- } else if (alt === '<TRA>') {
1334
- var _feature$get2, _feature$get2$CHR, _feature$get3, _feature$get3$END;
1335
-
1336
- // VCF TRA
1337
- var chr2 = (_feature$get2 = feature.get('INFO')) === null || _feature$get2 === void 0 ? void 0 : (_feature$get2$CHR = _feature$get2.CHR2) === null || _feature$get2$CHR === void 0 ? void 0 : _feature$get2$CHR[0];
1338
- var end = (_feature$get3 = feature.get('INFO')) === null || _feature$get3 === void 0 ? void 0 : (_feature$get3$END = _feature$get3.END) === null || _feature$get3$END === void 0 ? void 0 : _feature$get3$END[0];
1339
- endPosition = parseInt(end, 10);
1340
- endBlock = blocksForRefs[chr2];
1341
- } else if (svType === 'mate') {
1342
- // generic simplefeatures arcs
1343
- var mate = feature.get('mate');
1344
- var _chr = mate.refName;
1345
- endPosition = mate.start;
1346
- endBlock = blocksForRefs[_chr];
1347
- }
1348
-
1349
- if (endBlock) {
1350
- var startPos = feature.get('start');
1351
- var startRadians = bpToRadians(startBlock, startPos);
1352
- var endRadians = bpToRadians(endBlock, endPosition);
1353
- var startXY = util.polarToCartesian(radius, startRadians);
1354
- var endXY = util.polarToCartesian(radius, endRadians);
1355
- var controlXY = util.polarToCartesian(bezierRadius, (endRadians + startRadians) / 2);
1356
- var strokeColor = selected ? configuration.readConfObject(config, 'strokeColorSelected', {
1357
- feature: feature
1358
- }) : configuration.readConfObject(config, 'strokeColor', {
1359
- feature: feature
1360
- });
1361
- var hoverStrokeColor = configuration.readConfObject(config, 'strokeColorHover', {
1362
- feature: feature
1363
- });
1364
- return /*#__PURE__*/React__default.createElement("path", {
1365
- "data-testid": "chord-".concat(feature.id()),
1366
- d: ['M'].concat(_toConsumableArray(startXY), ['Q'], _toConsumableArray(controlXY), _toConsumableArray(endXY)).join(' '),
1367
- style: {
1368
- stroke: strokeColor
1369
- },
1370
- onClick: function onClick(evt) {
1371
- return _onClick(feature, startBlock.region, endBlock.region, evt);
1372
- },
1373
- onMouseOver: function onMouseOver(evt) {
1374
- if (!selected) {
1375
- evt.target.style.stroke = hoverStrokeColor;
1376
- evt.target.style.strokeWidth = 3;
1377
- }
1378
- },
1379
- onMouseOut: function onMouseOut(evt) {
1380
- if (!selected) {
1381
- evt.target.style.stroke = strokeColor;
1382
- evt.target.style.strokeWidth = 1;
1383
- }
1384
- }
1385
- });
1386
- }
1387
-
1388
- return null;
1389
- });
1390
-
1391
- function StructuralVariantChords(props) {
1392
- var features = props.features,
1393
- config = props.config,
1394
- displayModel = props.displayModel,
1395
- blockDefinitions = props.blockDefinitions,
1396
- radius = props.radius,
1397
- bezierRadius = props.bezierRadius,
1398
- selectedFeatureId = props.displayModel.selectedFeatureId,
1399
- onChordClick = props.onChordClick; // make a map of refName -> blockDefinition
1400
-
1401
- var blocksForRefsMemo = React.useMemo(function () {
1402
- var blocksForRefs = {};
1403
- blockDefinitions.forEach(function (block) {
1404
- var regions = block.region.elided ? block.region.regions : [block.region];
1405
- regions.forEach(function (region) {
1406
- blocksForRefs[region.refName] = block;
1407
- });
1408
- });
1409
- return blocksForRefs;
1410
- }, [blockDefinitions]); // console.log(blocksForRefs)
1411
-
1412
- var chords = [];
1413
-
1414
- var _iterator = _createForOfIteratorHelper(features),
1415
- _step;
1416
-
1417
- try {
1418
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
1419
- var _step$value = _slicedToArray(_step.value, 2),
1420
- id = _step$value[0],
1421
- feature = _step$value[1];
1422
-
1423
- var selected = String(selectedFeatureId) === String(feature.id());
1424
- chords.push( /*#__PURE__*/React__default.createElement(Chord, {
1425
- key: id,
1426
- feature: feature,
1427
- config: config,
1428
- displayModel: displayModel,
1429
- radius: radius,
1430
- bezierRadius: bezierRadius,
1431
- blocksForRefs: blocksForRefsMemo,
1432
- selected: selected,
1433
- onClick: onChordClick
1434
- }));
1435
- }
1436
- } catch (err) {
1437
- _iterator.e(err);
1438
- } finally {
1439
- _iterator.f();
1440
- }
1441
-
1442
- var trackStyleId = "chords-".concat(displayModel.id);
1443
- return /*#__PURE__*/React__default.createElement("g", {
1444
- id: trackStyleId,
1445
- "data-testid": "structuralVariantChordRenderer"
1446
- }, /*#__PURE__*/React__default.createElement("style", {
1447
- // eslint-disable-next-line react/no-danger
1448
- dangerouslySetInnerHTML: {
1449
- __html: "\n #".concat(trackStyleId, " > path {\n cursor: crosshair;\n fill: none;\n }\n")
1450
- }
1451
- }), chords);
1452
- }
1453
-
1454
- StructuralVariantChords.propTypes = {
1455
- features: /*#__PURE__*/PropTypes.instanceOf(Map).isRequired,
1456
- config: mst.PropTypes.ConfigSchema.isRequired,
1457
- displayModel: mobxReact.PropTypes.objectOrObservableObject,
1458
- blockDefinitions: /*#__PURE__*/PropTypes.arrayOf(mobxReact.PropTypes.objectOrObservableObject).isRequired,
1459
- radius: PropTypes.number.isRequired,
1460
- bezierRadius: PropTypes.number.isRequired,
1461
- selectedFeatureId: PropTypes.string,
1462
- onChordClick: /*#__PURE__*/PropTypes.oneOfType([PropTypes.func, PropTypes.string])
1463
- };
1464
- StructuralVariantChords.defaultProps = {
1465
- displayModel: undefined,
1466
- selectedFeatureId: '',
1467
- onChordClick: undefined
1468
- };
1469
- var ReactComponent = /*#__PURE__*/mobxReact.observer(StructuralVariantChords);
1470
-
1471
- var ChordRendererConfigF = function ChordRendererConfigF(pluginManager) {
1472
- var configSchema = configuration.ConfigurationSchema('StructuralVariantChordRenderer', {
1473
- strokeColor: {
1474
- type: 'color',
1475
- description: 'the line color of each arc',
1476
- defaultValue: 'rgba(255,133,0,0.32)',
1477
- contextVariable: ['feature']
1478
- },
1479
- strokeColorSelected: {
1480
- type: 'color',
1481
- description: 'the line color of an arc that has been selected',
1482
- defaultValue: 'black',
1483
- contextVariable: ['feature']
1484
- },
1485
- strokeColorHover: {
1486
- type: 'color',
1487
- description: 'the line color of an arc that is being hovered over with the mouse',
1488
- defaultValue: '#555',
1489
- contextVariable: ['feature']
1490
- }
1491
- }, {
1492
- explicitlyTyped: true
1493
- });
1494
- return new ChordRendererType({
1495
- name: 'StructuralVariantChordRenderer',
1496
- ReactComponent: ReactComponent,
1497
- configSchema: configSchema,
1498
- pluginManager: pluginManager
1499
- });
1500
- };
1501
-
1502
- var configSchema = /*#__PURE__*/configuration.ConfigurationSchema('VariantFeatureWidget', {});
1503
- function stateModelFactory(pluginManager) {
1504
- return mobxStateTree.types.model('VariantFeatureWidget', {
1505
- id: mst.ElementId,
1506
- type: mobxStateTree.types.literal('VariantFeatureWidget'),
1507
- view: mobxStateTree.types.safeReference(pluginManager.pluggableMstType('view', 'stateModel')),
1508
- featureData: mobxStateTree.types.frozen(),
1509
- descriptions: mobxStateTree.types.frozen()
1510
- }).actions(function (self) {
1511
- return {
1512
- setFeatureData: function setFeatureData(data) {
1513
- self.featureData = data;
1514
- },
1515
- clearFeatureData: function clearFeatureData() {
1516
- self.featureData = undefined;
1517
- }
1518
- };
1519
- });
1520
- }
1521
-
1522
- var vcfTabixAdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchema('VcfTabixAdapter', {
1523
- vcfGzLocation: {
1524
- type: 'fileLocation',
1525
- defaultValue: {
1526
- uri: '/path/to/my.vcf.gz',
1527
- locationType: 'UriLocation'
1528
- }
1529
- },
1530
- index: /*#__PURE__*/configuration.ConfigurationSchema('VcfIndex', {
1531
- indexType: {
1532
- model: /*#__PURE__*/mobxStateTree.types.enumeration('IndexType', ['TBI', 'CSI']),
1533
- type: 'stringEnum',
1534
- defaultValue: 'TBI'
1535
- },
1536
- location: {
1537
- type: 'fileLocation',
1538
- defaultValue: {
1539
- uri: '/path/to/my.vcf.gz.tbi',
1540
- locationType: 'UriLocation'
1541
- }
1542
- }
1543
- })
1544
- }, {
1545
- explicitlyTyped: true
1546
- });
1547
-
1548
- var vcfAdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchema('VcfAdapter', {
1549
- vcfLocation: {
1550
- type: 'fileLocation',
1551
- defaultValue: {
1552
- uri: '/path/to/my.vcf',
1553
- locationType: 'UriLocation'
1554
- }
1555
- }
1556
- }, {
1557
- explicitlyTyped: true
1558
- });
1559
-
1560
- var VCFFeature = /*#__PURE__*/function () {
1561
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1562
- function VCFFeature(args) {
1563
- _classCallCheck(this, VCFFeature);
1564
-
1565
- this.variant = args.variant;
1566
- this.parser = args.parser;
1567
- this.data = this.dataFromVariant(this.variant);
1568
- this._id = args.id;
1569
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
1570
-
1571
-
1572
- _createClass(VCFFeature, [{
1573
- key: "get",
1574
- value: function get(field) {
1575
- return field === 'samples' ? this.variant.SAMPLES : this.data[field] || this.variant[field];
1576
- }
1577
- }, {
1578
- key: "set",
1579
- value: function set() {}
1580
- }, {
1581
- key: "parent",
1582
- value: function parent() {
1583
- return undefined;
1584
- }
1585
- }, {
1586
- key: "children",
1587
- value: function children() {
1588
- return undefined;
1589
- }
1590
- }, {
1591
- key: "tags",
1592
- value: function tags() {
1593
- var t = [].concat(_toConsumableArray(Object.keys(this.data)), _toConsumableArray(Object.keys(this.variant)), ['samples']);
1594
- return t;
1595
- }
1596
- }, {
1597
- key: "id",
1598
- value: function id() {
1599
- return this._id;
1600
- }
1601
- }, {
1602
- key: "dataFromVariant",
1603
- value: function dataFromVariant(variant) {
1604
- var REF = variant.REF,
1605
- ALT = variant.ALT,
1606
- POS = variant.POS,
1607
- CHROM = variant.CHROM,
1608
- INFO = variant.INFO,
1609
- ID = variant.ID;
1610
- var start = POS - 1;
1611
-
1612
- var _this$_getSOTermAndDe = this._getSOTermAndDescription(REF, ALT),
1613
- _this$_getSOTermAndDe2 = _slicedToArray(_this$_getSOTermAndDe, 2),
1614
- SO_term = _this$_getSOTermAndDe2[0],
1615
- description = _this$_getSOTermAndDe2[1];
1616
-
1617
- var isTRA = ALT === null || ALT === void 0 ? void 0 : ALT.some(function (f) {
1618
- return f === '<TRA>';
1619
- });
1620
- var isSymbolic = ALT === null || ALT === void 0 ? void 0 : ALT.some(function (f) {
1621
- return f.indexOf('<') !== -1;
1622
- });
1623
- return {
1624
- refName: CHROM,
1625
- start: start,
1626
- end: isSymbolic && INFO.END && !isTRA ? +INFO.END[0] : start + REF.length,
1627
- description: description,
1628
- type: SO_term,
1629
- name: ID === null || ID === void 0 ? void 0 : ID.join(','),
1630
- aliases: ID && ID.length > 1 ? variant.ID.slice(1) : undefined
1631
- };
1632
- }
1633
- /**
1634
- * Get a sequence ontology (SO) term that describes the variant type
1635
- */
1636
-
1637
- }, {
1638
- key: "_getSOTermAndDescription",
1639
- value: function _getSOTermAndDescription(ref, alt) {
1640
- var _this = this;
1641
-
1642
- // it's just a remark if there are no alternate alleles
1643
- if (!alt || alt === []) {
1644
- return ['remark', 'no alternative alleles'];
1645
- }
1646
-
1647
- var soTerms = new Set();
1648
- var descriptions = new Set();
1649
- alt.forEach(function (a) {
1650
- var _this$_getSOAndDescFr = _this._getSOAndDescFromAltDefs(ref, a),
1651
- _this$_getSOAndDescFr2 = _slicedToArray(_this$_getSOAndDescFr, 2),
1652
- soTerm = _this$_getSOAndDescFr2[0],
1653
- description = _this$_getSOAndDescFr2[1];
1654
-
1655
- if (!soTerm) {
1656
-
1657
- var _this$_getSOAndDescBy = _this._getSOAndDescByExamination(ref, a);
1658
-
1659
- var _this$_getSOAndDescBy2 = _slicedToArray(_this$_getSOAndDescBy, 2);
1660
-
1661
- soTerm = _this$_getSOAndDescBy2[0];
1662
- description = _this$_getSOAndDescBy2[1];
1663
- }
1664
-
1665
- if (soTerm && description) {
1666
- soTerms.add(soTerm);
1667
- descriptions.add(description);
1668
- }
1669
- }); // Combine descriptions like ["SNV G -> A", "SNV G -> T"] to ["SNV G -> A,T"]
1670
-
1671
- if (descriptions.size > 1) {
1672
- var prefixes = new Set(_toConsumableArray(descriptions).map(function (desc) {
1673
- var prefix = desc.split('->');
1674
- return prefix[1] ? prefix[0] : desc;
1675
- }));
1676
-
1677
- var new_descs = _toConsumableArray(prefixes).map(function (prefix) {
1678
- var suffixes = _toConsumableArray(descriptions).map(function (desc) {
1679
- var pref = desc.split('-> ');
1680
- return pref[1] && pref[0] === prefix ? pref[1] : '';
1681
- }).filter(function (f) {
1682
- return !!f;
1683
- });
1684
-
1685
- return suffixes.length ? prefix + '-> ' + suffixes.join(',') : _toConsumableArray(descriptions).join(',');
1686
- });
1687
-
1688
- descriptions = new Set(new_descs);
1689
- }
1690
-
1691
- if (soTerms.size) {
1692
- return [_toConsumableArray(soTerms).join(','), _toConsumableArray(descriptions).join(',')];
1693
- }
1694
-
1695
- return [undefined, undefined];
1696
- }
1697
- }, {
1698
- key: "_getSOAndDescFromAltDefs",
1699
- value: function _getSOAndDescFromAltDefs(ref, alt) {
1700
- if (typeof alt === 'string' && !alt.startsWith('<')) {
1701
- return [undefined, undefined];
1702
- } // look for a definition with an SO type for this
1703
-
1704
-
1705
- var soTerm = VCFFeature._altTypeToSO[alt]; // if no SO term but ALT is in metadata, assume sequence_variant
1706
-
1707
- if (!soTerm && this.parser.getMetadata('ALT', alt)) {
1708
- soTerm = 'sequence_variant';
1709
- }
1710
-
1711
- if (soTerm) {
1712
- return [soTerm, alt];
1713
- } // try to look for a definition for a parent term if we can
1714
-
1715
-
1716
- var modAlt = alt.split(':');
1717
-
1718
- if (modAlt.length > 1) {
1719
- return this._getSOAndDescFromAltDefs(ref, "<".concat(modAlt.slice(0, modAlt.length - 1).join(':'), ">"));
1720
- } // no parent
1721
-
1722
-
1723
- return [undefined, undefined];
1724
- } // note: term SNV is used instead of SNP because SO definition of SNP says
1725
- // abundance must be at least 1% in population, and can't be sure we meet
1726
- // that
1727
-
1728
- }, {
1729
- key: "_getSOAndDescByExamination",
1730
- value: function _getSOAndDescByExamination(ref, alt) {
1731
- var bnd = VCF.parseBreakend(alt);
1732
-
1733
- if (bnd) {
1734
- return ['breakend', alt];
1735
- } else if (ref.length === 1 && alt.length === 1) {
1736
- return ['SNV', this._makeDescriptionString('SNV', ref, alt)];
1737
- } else if (alt === '<INS>') {
1738
- return ['insertion', alt];
1739
- } else if (alt === '<DEL>') {
1740
- return ['deletion', alt];
1741
- } else if (alt === '<INV>') {
1742
- return ['deletion', alt];
1743
- } else if (alt === '<TRA>') {
1744
- return ['translocation', alt];
1745
- } else if (alt.includes('<')) {
1746
- return ['sv', alt];
1747
- } else if (ref.length === alt.length) {
1748
- if (ref.split('').reverse().join('') === alt) {
1749
- return ['inversion', this._makeDescriptionString('inversion', ref, alt)];
1750
- }
1751
-
1752
- return ['substitution', this._makeDescriptionString('substitution', ref, alt)];
1753
- } else if (ref.length <= alt.length) {
1754
- return ['insertion', this._makeDescriptionString('insertion', ref, alt)];
1755
- } else if (ref.length > alt.length) {
1756
- return ['deletion', this._makeDescriptionString('deletion', ref, alt)];
1757
- }
1758
-
1759
- return ['indel', this._makeDescriptionString('indel', ref, alt)];
1760
- }
1761
- }, {
1762
- key: "_makeDescriptionString",
1763
- value: function _makeDescriptionString(soTerm, ref, alt) {
1764
- return "".concat(soTerm, " ").concat(ref, " -> ").concat(alt);
1765
- } // eslint-disable-next-line @typescript-eslint/no-explicit-any
1766
-
1767
- }, {
1768
- key: "toJSON",
1769
- value: function toJSON() {
1770
- return _objectSpread2(_objectSpread2(_objectSpread2({
1771
- uniqueId: this._id
1772
- }, this.variant), this.data), {}, {
1773
- samples: this.variant.SAMPLES
1774
- });
1775
- }
1776
- }]);
1777
-
1778
- return VCFFeature;
1779
- }();
1780
- VCFFeature._altTypeToSO = {
1781
- DEL: 'deletion',
1782
- INS: 'insertion',
1783
- DUP: 'duplication',
1784
- INV: 'inversion',
1785
- INVDUP: 'inverted duplication',
1786
- CNV: 'copy_number_variation',
1787
- TRA: 'translocation',
1788
- 'DUP:TANDEM': 'tandem_duplication',
1789
- NON_REF: 'sequence_variant',
1790
- '*': 'sequence_variant'
1791
- };
1792
-
1793
- var VariantsPlugin = /*#__PURE__*/function (_Plugin) {
1794
- _inherits(VariantsPlugin, _Plugin);
1795
-
1796
- var _super = /*#__PURE__*/_createSuper(VariantsPlugin);
1797
-
1798
- function VariantsPlugin() {
1799
- var _this;
1800
-
1801
- _classCallCheck(this, VariantsPlugin);
1802
-
1803
- _this = _super.apply(this, arguments);
1804
- _this.name = 'VariantsPlugin';
1805
- return _this;
1806
- }
1807
-
1808
- _createClass(VariantsPlugin, [{
1809
- key: "install",
1810
- value: function install(pluginManager) {
1811
- pluginManager.addAdapterType(function () {
1812
- return new AdapterType({
1813
- name: 'VcfTabixAdapter',
1814
- configSchema: vcfTabixAdapterConfigSchema,
1815
- getAdapterClass: function getAdapterClass() {
1816
- return Promise.resolve().then(function () { return VcfTabixAdapter; }).then(function (r) {
1817
- return r["default"];
1818
- });
1819
- }
1820
- });
1821
- });
1822
- pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
1823
- return function (file, index, adapterHint) {
1824
- var regexGuess = /\.vcf\.b?gz$/i;
1825
- var adapterName = 'VcfTabixAdapter';
1826
- var fileName = tracks.getFileName(file);
1827
- var indexName = index && tracks.getFileName(index);
1828
- var obj = {
1829
- type: adapterName,
1830
- vcfGzLocation: file,
1831
- index: {
1832
- location: index || tracks.makeIndex(file, '.tbi'),
1833
- indexType: tracks.makeIndexType(indexName, 'CSI', 'TBI')
1834
- }
1835
- };
1836
-
1837
- if (regexGuess.test(fileName) && !adapterHint) {
1838
- return obj;
1839
- } else if (adapterHint === adapterName) {
1840
- return obj;
1841
- }
1842
-
1843
- return adapterGuesser(file, index, adapterHint);
1844
- };
1845
- });
1846
- pluginManager.addToExtensionPoint('Core-guessTrackTypeForLocation', function (trackTypeGuesser) {
1847
- return function (adapterName) {
1848
- if (adapterName === 'VcfTabixAdapter' || adapterName === 'VcfAdapter') {
1849
- return 'VariantTrack';
1850
- }
1851
-
1852
- return trackTypeGuesser(adapterName);
1853
- };
1854
- });
1855
- pluginManager.addAdapterType(function () {
1856
- return new AdapterType({
1857
- name: 'VcfAdapter',
1858
- configSchema: vcfAdapterConfigSchema,
1859
- getAdapterClass: function getAdapterClass() {
1860
- return Promise.resolve().then(function () { return VcfAdapter$1; }).then(function (r) {
1861
- return r["default"];
1862
- });
1863
- }
1864
- });
1865
- });
1866
- pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
1867
- return function (file, index, adapterHint) {
1868
- var regexGuess = /\.vcf$/i;
1869
- var adapterName = 'VcfAdapter';
1870
- var fileName = tracks.getFileName(file);
1871
-
1872
- if (regexGuess.test(fileName) || adapterHint === adapterName) {
1873
- return {
1874
- type: adapterName,
1875
- vcfLocation: file
1876
- };
1877
- }
1878
-
1879
- return adapterGuesser(file, index, adapterHint);
1880
- };
1881
- });
1882
- pluginManager.addRendererType(function () {
1883
- return pluginManager.jbrequire(ChordRendererConfigF);
1884
- });
1885
- pluginManager.addTrackType(function () {
1886
- var configSchema = configuration.ConfigurationSchema('VariantTrack', {}, {
1887
- baseConfiguration: models.createBaseTrackConfig(pluginManager)
1888
- });
1889
- return new TrackType({
1890
- name: 'VariantTrack',
1891
- configSchema: configSchema,
1892
- stateModel: models.createBaseTrackModel(pluginManager, 'VariantTrack', configSchema)
1893
- });
1894
- });
1895
- pluginManager.addDisplayType(function () {
1896
- return pluginManager.jbrequire(ChordVariantDisplay);
1897
- });
1898
- pluginManager.addDisplayType(function () {
1899
- var configSchema = LinearVariantDisplayConfigFactory(pluginManager);
1900
- return new DisplayType({
1901
- name: 'LinearVariantDisplay',
1902
- configSchema: configSchema,
1903
- stateModel: linearVariantDisplayModelFactory(configSchema),
1904
- trackType: 'VariantTrack',
1905
- viewType: 'LinearGenomeView',
1906
- ReactComponent: pluginLinearGenomeView.BaseLinearDisplayComponent
1907
- });
1908
- });
1909
- pluginManager.addWidgetType(function () {
1910
- return new WidgetType({
1911
- name: 'VariantFeatureWidget',
1912
- heading: 'Feature details',
1913
- configSchema: configSchema,
1914
- stateModel: stateModelFactory(pluginManager),
1915
- ReactComponent: /*#__PURE__*/React.lazy(function () {
1916
- return Promise.resolve().then(function () { return VariantFeatureWidget$1; });
1917
- })
1918
- });
1919
- });
1920
- }
1921
- }]);
1922
-
1923
- return VariantsPlugin;
1924
- }(Plugin);
1925
-
1926
- var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1927
- _inherits(_default, _BaseFeatureDataAdapt);
1928
-
1929
- var _super = /*#__PURE__*/_createSuper(_default);
1930
-
1931
- function _default() {
1932
- _classCallCheck(this, _default);
1933
-
1934
- return _super.apply(this, arguments);
1935
- }
1936
-
1937
- _createClass(_default, [{
1938
- key: "configurePre",
1939
- value: function () {
1940
- var _configurePre = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1941
- var vcfGzLocation, location, indexType, filehandle, isCSI, vcf, header;
1942
- return runtime_1.wrap(function _callee$(_context) {
1943
- while (1) {
1944
- switch (_context.prev = _context.next) {
1945
- case 0:
1946
- vcfGzLocation = configuration.readConfObject(this.config, 'vcfGzLocation');
1947
- location = configuration.readConfObject(this.config, ['index', 'location']);
1948
- indexType = configuration.readConfObject(this.config, ['index', 'indexType']);
1949
- filehandle = io.openLocation(vcfGzLocation, this.pluginManager);
1950
- isCSI = indexType === 'CSI';
1951
- vcf = new tabix.TabixIndexedFile({
1952
- filehandle: filehandle,
1953
- csiFilehandle: isCSI ? io.openLocation(location, this.pluginManager) : undefined,
1954
- tbiFilehandle: !isCSI ? io.openLocation(location, this.pluginManager) : undefined,
1955
- chunkCacheSize: 50 * Math.pow(2, 20),
1956
- chunkSizeLimit: 1000000000
1957
- });
1958
- _context.next = 8;
1959
- return vcf.getHeader();
1960
-
1961
- case 8:
1962
- header = _context.sent;
1963
- return _context.abrupt("return", {
1964
- filehandle: filehandle,
1965
- vcf: vcf,
1966
- parser: new VCF__default({
1967
- header: header
1968
- })
1969
- });
1970
-
1971
- case 10:
1972
- case "end":
1973
- return _context.stop();
1974
- }
1975
- }
1976
- }, _callee, this);
1977
- }));
1978
-
1979
- function configurePre() {
1980
- return _configurePre.apply(this, arguments);
1981
- }
1982
-
1983
- return configurePre;
1984
- }()
1985
- }, {
1986
- key: "configure",
1987
- value: function () {
1988
- var _configure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1989
- var _this = this;
1990
-
1991
- return runtime_1.wrap(function _callee2$(_context2) {
1992
- while (1) {
1993
- switch (_context2.prev = _context2.next) {
1994
- case 0:
1995
- if (!this.configured) {
1996
- this.configured = this.configurePre()["catch"](function (e) {
1997
- _this.configured = undefined;
1998
- throw e;
1999
- });
2000
- }
2001
-
2002
- return _context2.abrupt("return", this.configured);
2003
-
2004
- case 2:
2005
- case "end":
2006
- return _context2.stop();
2007
- }
2008
- }
2009
- }, _callee2, this);
2010
- }));
2011
-
2012
- function configure() {
2013
- return _configure.apply(this, arguments);
2014
- }
2015
-
2016
- return configure;
2017
- }()
2018
- }, {
2019
- key: "getRefNames",
2020
- value: function () {
2021
- var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
2022
- var opts,
2023
- _yield$this$configure,
2024
- vcf,
2025
- _args3 = arguments;
2026
-
2027
- return runtime_1.wrap(function _callee3$(_context3) {
2028
- while (1) {
2029
- switch (_context3.prev = _context3.next) {
2030
- case 0:
2031
- opts = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
2032
- _context3.next = 3;
2033
- return this.configure();
2034
-
2035
- case 3:
2036
- _yield$this$configure = _context3.sent;
2037
- vcf = _yield$this$configure.vcf;
2038
- return _context3.abrupt("return", vcf.getReferenceSequenceNames(opts));
2039
-
2040
- case 6:
2041
- case "end":
2042
- return _context3.stop();
2043
- }
2044
- }
2045
- }, _callee3, this);
2046
- }));
2047
-
2048
- function getRefNames() {
2049
- return _getRefNames.apply(this, arguments);
2050
- }
2051
-
2052
- return getRefNames;
2053
- }()
2054
- }, {
2055
- key: "getHeader",
2056
- value: function () {
2057
- var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
2058
- var _yield$this$configure2, vcf;
2059
-
2060
- return runtime_1.wrap(function _callee4$(_context4) {
2061
- while (1) {
2062
- switch (_context4.prev = _context4.next) {
2063
- case 0:
2064
- _context4.next = 2;
2065
- return this.configure();
2066
-
2067
- case 2:
2068
- _yield$this$configure2 = _context4.sent;
2069
- vcf = _yield$this$configure2.vcf;
2070
- return _context4.abrupt("return", vcf.getHeader());
2071
-
2072
- case 5:
2073
- case "end":
2074
- return _context4.stop();
2075
- }
2076
- }
2077
- }, _callee4, this);
2078
- }));
2079
-
2080
- function getHeader() {
2081
- return _getHeader.apply(this, arguments);
2082
- }
2083
-
2084
- return getHeader;
2085
- }()
2086
- }, {
2087
- key: "getMetadata",
2088
- value: function () {
2089
- var _getMetadata = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
2090
- var _yield$this$configure3, parser;
2091
-
2092
- return runtime_1.wrap(function _callee5$(_context5) {
2093
- while (1) {
2094
- switch (_context5.prev = _context5.next) {
2095
- case 0:
2096
- _context5.next = 2;
2097
- return this.configure();
2098
-
2099
- case 2:
2100
- _yield$this$configure3 = _context5.sent;
2101
- parser = _yield$this$configure3.parser;
2102
- return _context5.abrupt("return", parser.getMetadata());
2103
-
2104
- case 5:
2105
- case "end":
2106
- return _context5.stop();
2107
- }
2108
- }
2109
- }, _callee5, this);
2110
- }));
2111
-
2112
- function getMetadata() {
2113
- return _getMetadata.apply(this, arguments);
2114
- }
2115
-
2116
- return getMetadata;
2117
- }()
2118
- }, {
2119
- key: "getFeatures",
2120
- value: function getFeatures(query) {
2121
- var _this2 = this;
2122
-
2123
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2124
- return rxjs.ObservableCreate( /*#__PURE__*/function () {
2125
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(observer) {
2126
- var refName, start, end, _yield$_this2$configu, vcf, parser;
2127
-
2128
- return runtime_1.wrap(function _callee6$(_context6) {
2129
- while (1) {
2130
- switch (_context6.prev = _context6.next) {
2131
- case 0:
2132
- refName = query.refName, start = query.start, end = query.end;
2133
- _context6.next = 3;
2134
- return _this2.configure();
2135
-
2136
- case 3:
2137
- _yield$_this2$configu = _context6.sent;
2138
- vcf = _yield$_this2$configu.vcf;
2139
- parser = _yield$_this2$configu.parser;
2140
- _context6.next = 8;
2141
- return vcf.getLines(refName, start, end, _objectSpread2({
2142
- lineCallback: function lineCallback(line, fileOffset) {
2143
- observer.next(new VCFFeature({
2144
- variant: parser.parseLine(line),
2145
- parser: parser,
2146
- id: "".concat(_this2.id, "-vcf-").concat(fileOffset)
2147
- }));
2148
- }
2149
- }, opts));
2150
-
2151
- case 8:
2152
- observer.complete();
2153
-
2154
- case 9:
2155
- case "end":
2156
- return _context6.stop();
2157
- }
2158
- }
2159
- }, _callee6);
2160
- }));
2161
-
2162
- return function (_x) {
2163
- return _ref.apply(this, arguments);
2164
- };
2165
- }(), opts.signal);
2166
- }
2167
- /**
2168
- * Checks if the data source has data for the given reference sequence,
2169
- * and then gets the features in the region if it does
2170
- *
2171
- * Currently this just calls getFeatureInRegion for each region. Adapters that
2172
- * are frequently called on multiple regions simultaneously may want to
2173
- * implement a more efficient custom version of this method.
2174
- *
2175
- * Also includes a bit of extra logging to warn when fetching a large portion
2176
- * of a VCF
2177
- * @param regions - Regions
2178
- * @param opts - Feature adapter options
2179
- * @returns Observable of Feature objects in the regions
2180
- */
2181
-
2182
- }, {
2183
- key: "getFeaturesInMultipleRegions",
2184
- value: function getFeaturesInMultipleRegions(regions) {
2185
- var _this3 = this;
2186
-
2187
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2188
-
2189
- // TODO: restore commented version below once TSDX supports Rollup v2
2190
- // xref: https://github.com/rollup/rollup/blob/master/CHANGELOG.md#bug-fixes-45
2191
- var superGetFeaturesInMultipleRegions = _get(_getPrototypeOf(_default.prototype), "getFeaturesInMultipleRegions", this);
2192
-
2193
- return rxjs.ObservableCreate( /*#__PURE__*/function () {
2194
- var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee7(observer) {
2195
- var _yield$_this3$configu, vcf, bytes, _yield$_this3$configu2, filehandle, stat, pct;
2196
-
2197
- return runtime_1.wrap(function _callee7$(_context7) {
2198
- while (1) {
2199
- switch (_context7.prev = _context7.next) {
2200
- case 0:
2201
- _context7.next = 2;
2202
- return _this3.configure();
2203
-
2204
- case 2:
2205
- _yield$_this3$configu = _context7.sent;
2206
- vcf = _yield$_this3$configu.vcf;
2207
- _context7.next = 6;
2208
- return util.bytesForRegions(regions, vcf.index);
2209
-
2210
- case 6:
2211
- bytes = _context7.sent;
2212
- _context7.next = 9;
2213
- return _this3.configure();
2214
-
2215
- case 9:
2216
- _yield$_this3$configu2 = _context7.sent;
2217
- filehandle = _yield$_this3$configu2.filehandle;
2218
- _context7.next = 13;
2219
- return filehandle.stat();
2220
-
2221
- case 13:
2222
- stat = _context7.sent;
2223
- pct = Math.round(bytes / stat.size * 100);
2224
-
2225
- if (pct > 100) {
2226
- // this is just a bad estimate, make 100% if it goes over
2227
- pct = 100;
2228
- }
2229
-
2230
- if (pct > 60) {
2231
- console.warn("getFeaturesInMultipleRegions fetching ".concat(pct, "% of VCF file, but whole-file streaming not yet implemented"));
2232
- }
2233
-
2234
- superGetFeaturesInMultipleRegions.call(_this3, regions, opts).subscribe(observer); // super.getFeaturesInMultipleRegions(regions, opts).subscribe(observer)
2235
-
2236
- case 18:
2237
- case "end":
2238
- return _context7.stop();
2239
- }
2240
- }
2241
- }, _callee7);
2242
- }));
2243
-
2244
- return function (_x2) {
2245
- return _ref2.apply(this, arguments);
2246
- };
2247
- }());
2248
- }
2249
- }, {
2250
- key: "freeResources",
2251
- value: function
2252
- /* { region } */
2253
- freeResources() {}
2254
- }]);
2255
-
2256
- return _default;
2257
- }(BaseAdapter.BaseFeatureDataAdapter);
2258
-
2259
- var VcfTabixAdapter = {
2260
- __proto__: null,
2261
- 'default': _default
2262
- };
2263
-
2264
- var readVcf = function readVcf(f) {
2265
- var lines = f.split('\n');
2266
- var header = [];
2267
- var rest = [];
2268
- lines.forEach(function (line) {
2269
- if (line.startsWith('#')) {
2270
- header.push(line);
2271
- } else if (line) {
2272
- rest.push(line);
2273
- }
2274
- });
2275
- return {
2276
- header: header.join('\n'),
2277
- lines: rest
2278
- };
2279
- };
2280
-
2281
- function isGzip(buf) {
2282
- return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
2283
- }
2284
-
2285
- var VcfAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
2286
- _inherits(VcfAdapter, _BaseFeatureDataAdapt);
2287
-
2288
- var _super = /*#__PURE__*/_createSuper(VcfAdapter);
2289
-
2290
- function VcfAdapter() {
2291
- _classCallCheck(this, VcfAdapter);
2292
-
2293
- return _super.apply(this, arguments);
2294
- }
2295
-
2296
- _createClass(VcfAdapter, [{
2297
- key: "getHeader",
2298
- value: function () {
2299
- var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
2300
- var _yield$this$setup, header;
2301
-
2302
- return runtime_1.wrap(function _callee$(_context) {
2303
- while (1) {
2304
- switch (_context.prev = _context.next) {
2305
- case 0:
2306
- _context.next = 2;
2307
- return this.setup();
2308
-
2309
- case 2:
2310
- _yield$this$setup = _context.sent;
2311
- header = _yield$this$setup.header;
2312
- return _context.abrupt("return", header);
2313
-
2314
- case 5:
2315
- case "end":
2316
- return _context.stop();
2317
- }
2318
- }
2319
- }, _callee, this);
2320
- }));
2321
-
2322
- function getHeader() {
2323
- return _getHeader.apply(this, arguments);
2324
- }
2325
-
2326
- return getHeader;
2327
- }()
2328
- }, {
2329
- key: "getMetadata",
2330
- value: function () {
2331
- var _getMetadata = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
2332
- var _yield$this$setup2, header, parser;
2333
-
2334
- return runtime_1.wrap(function _callee2$(_context2) {
2335
- while (1) {
2336
- switch (_context2.prev = _context2.next) {
2337
- case 0:
2338
- _context2.next = 2;
2339
- return this.setup();
2340
-
2341
- case 2:
2342
- _yield$this$setup2 = _context2.sent;
2343
- header = _yield$this$setup2.header;
2344
- parser = new VCF__default({
2345
- header: header
2346
- });
2347
- return _context2.abrupt("return", parser.getMetadata());
2348
-
2349
- case 6:
2350
- case "end":
2351
- return _context2.stop();
2352
- }
2353
- }
2354
- }, _callee2, this);
2355
- }));
2356
-
2357
- function getMetadata() {
2358
- return _getMetadata.apply(this, arguments);
2359
- }
2360
-
2361
- return getMetadata;
2362
- }() // converts lines into an interval tree
2363
-
2364
- }, {
2365
- key: "setupP",
2366
- value: function () {
2367
- var _setupP = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
2368
- var buffer, buf, str, _readVcf, header, lines, intervalTree;
2369
-
2370
- return runtime_1.wrap(function _callee3$(_context3) {
2371
- while (1) {
2372
- switch (_context3.prev = _context3.next) {
2373
- case 0:
2374
- _context3.next = 2;
2375
- return io.openLocation(configuration.readConfObject(this.config, 'vcfLocation'), this.pluginManager).readFile();
2376
-
2377
- case 2:
2378
- buffer = _context3.sent;
2379
-
2380
- if (!isGzip(buffer)) {
2381
- _context3.next = 9;
2382
- break;
2383
- }
2384
-
2385
- _context3.next = 6;
2386
- return bgzfFilehandle.unzip(buffer);
2387
-
2388
- case 6:
2389
- _context3.t0 = _context3.sent;
2390
- _context3.next = 10;
2391
- break;
2392
-
2393
- case 9:
2394
- _context3.t0 = buffer;
2395
-
2396
- case 10:
2397
- buf = _context3.t0;
2398
-
2399
- if (!(buf.length > 536870888)) {
2400
- _context3.next = 13;
2401
- break;
2402
- }
2403
-
2404
- throw new Error('Data exceeds maximum string length (512MB)');
2405
-
2406
- case 13:
2407
- str = new TextDecoder().decode(buf);
2408
- _readVcf = readVcf(str), header = _readVcf.header, lines = _readVcf.lines;
2409
- intervalTree = lines.map(function (line, id) {
2410
- var _info$match;
2411
-
2412
- var _line$split = line.split('\t'),
2413
- _line$split2 = _slicedToArray(_line$split, 8),
2414
- refName = _line$split2[0],
2415
- startP = _line$split2[1],
2416
- ref = _line$split2[3],
2417
- info = _line$split2[7];
2418
-
2419
- var start = +startP - 1;
2420
- var end = +(((_info$match = info.match(/END=(\d+)/)) === null || _info$match === void 0 ? void 0 : _info$match[1].trim()) || start + ref.length);
2421
- return {
2422
- line: line,
2423
- refName: refName,
2424
- start: start,
2425
- end: end,
2426
- id: id
2427
- };
2428
- }).reduce(function (acc, obj) {
2429
- var key = obj.refName;
2430
-
2431
- if (!acc[key]) {
2432
- acc[key] = new IntervalTree();
2433
- }
2434
-
2435
- acc[key].insert([obj.start, obj.end], obj);
2436
- return acc;
2437
- }, {});
2438
- return _context3.abrupt("return", {
2439
- header: header,
2440
- intervalTree: intervalTree
2441
- });
2442
-
2443
- case 17:
2444
- case "end":
2445
- return _context3.stop();
2446
- }
2447
- }
2448
- }, _callee3, this);
2449
- }));
2450
-
2451
- function setupP() {
2452
- return _setupP.apply(this, arguments);
2453
- }
2454
-
2455
- return setupP;
2456
- }()
2457
- }, {
2458
- key: "setup",
2459
- value: function () {
2460
- var _setup = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
2461
- var _this = this;
2462
-
2463
- return runtime_1.wrap(function _callee4$(_context4) {
2464
- while (1) {
2465
- switch (_context4.prev = _context4.next) {
2466
- case 0:
2467
- if (!this.vcfFeatures) {
2468
- this.vcfFeatures = this.setupP()["catch"](function (e) {
2469
- _this.vcfFeatures = undefined;
2470
- throw e;
2471
- });
2472
- }
2473
-
2474
- return _context4.abrupt("return", this.vcfFeatures);
2475
-
2476
- case 2:
2477
- case "end":
2478
- return _context4.stop();
2479
- }
2480
- }
2481
- }, _callee4, this);
2482
- }));
2483
-
2484
- function setup() {
2485
- return _setup.apply(this, arguments);
2486
- }
2487
-
2488
- return setup;
2489
- }()
2490
- }, {
2491
- key: "getRefNames",
2492
- value: function () {
2493
- var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5() {
2494
- var _yield$this$setup3,
2495
- intervalTree;
2496
-
2497
- return runtime_1.wrap(function _callee5$(_context5) {
2498
- while (1) {
2499
- switch (_context5.prev = _context5.next) {
2500
- case 0:
2501
- _context5.next = 3;
2502
- return this.setup();
2503
-
2504
- case 3:
2505
- _yield$this$setup3 = _context5.sent;
2506
- intervalTree = _yield$this$setup3.intervalTree;
2507
- return _context5.abrupt("return", Object.keys(intervalTree));
2508
-
2509
- case 6:
2510
- case "end":
2511
- return _context5.stop();
2512
- }
2513
- }
2514
- }, _callee5, this);
2515
- }));
2516
-
2517
- function getRefNames() {
2518
- return _getRefNames.apply(this, arguments);
2519
- }
2520
-
2521
- return getRefNames;
2522
- }()
2523
- }, {
2524
- key: "getFeatures",
2525
- value: function getFeatures(region) {
2526
- var _this2 = this;
2527
-
2528
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2529
- return rxjs.ObservableCreate( /*#__PURE__*/function () {
2530
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee6(observer) {
2531
- var _intervalTree$refName, start, end, refName, _yield$_this2$setup, header, intervalTree, parser;
2532
-
2533
- return runtime_1.wrap(function _callee6$(_context6) {
2534
- while (1) {
2535
- switch (_context6.prev = _context6.next) {
2536
- case 0:
2537
- _context6.prev = 0;
2538
- start = region.start, end = region.end, refName = region.refName;
2539
- _context6.next = 4;
2540
- return _this2.setup();
2541
-
2542
- case 4:
2543
- _yield$_this2$setup = _context6.sent;
2544
- header = _yield$_this2$setup.header;
2545
- intervalTree = _yield$_this2$setup.intervalTree;
2546
- parser = new VCF__default({
2547
- header: header
2548
- });
2549
- (_intervalTree$refName = intervalTree[refName]) === null || _intervalTree$refName === void 0 ? void 0 : _intervalTree$refName.search([start, end]).forEach(function (f) {
2550
- return observer.next(new VCFFeature({
2551
- variant: parser.parseLine(f.line),
2552
- parser: parser,
2553
- id: "".concat(_this2.id, "-").concat(f.id)
2554
- }));
2555
- });
2556
- observer.complete();
2557
- _context6.next = 15;
2558
- break;
2559
-
2560
- case 12:
2561
- _context6.prev = 12;
2562
- _context6.t0 = _context6["catch"](0);
2563
- observer.error(_context6.t0);
2564
-
2565
- case 15:
2566
- case "end":
2567
- return _context6.stop();
2568
- }
2569
- }
2570
- }, _callee6, null, [[0, 12]]);
2571
- }));
2572
-
2573
- return function (_x) {
2574
- return _ref.apply(this, arguments);
2575
- };
2576
- }(), opts.signal);
2577
- }
2578
- }, {
2579
- key: "freeResources",
2580
- value: function freeResources() {}
2581
- }]);
2582
-
2583
- return VcfAdapter;
2584
- }(BaseAdapter.BaseFeatureDataAdapter);
2585
- VcfAdapter.capabilities = ['getFeatures', 'getRefNames'];
2586
-
2587
- var VcfAdapter$1 = {
2588
- __proto__: null,
2589
- 'default': VcfAdapter
2590
- };
2591
-
2592
- var useStyles = /*#__PURE__*/core.makeStyles(function (theme) {
2593
- return {
2594
- closeButton: {
2595
- position: 'absolute',
2596
- right: theme.spacing(1),
2597
- top: theme.spacing(1),
2598
- color: theme.palette.grey[500]
2599
- },
2600
- block: {
2601
- display: 'block'
2602
- }
2603
- };
2604
- });
2605
-
2606
- function BreakendOptionDialog(_ref) {
2607
- var model = _ref.model,
2608
- handleClose = _ref.handleClose,
2609
- feature = _ref.feature,
2610
- viewType = _ref.viewType;
2611
- var classes = useStyles();
2612
-
2613
- var _useState = React.useState(true),
2614
- _useState2 = _slicedToArray(_useState, 2),
2615
- copyTracks = _useState2[0],
2616
- setCopyTracks = _useState2[1];
2617
-
2618
- var _useState3 = React.useState(true),
2619
- _useState4 = _slicedToArray(_useState3, 2),
2620
- mirrorTracks = _useState4[0],
2621
- setMirrorTracks = _useState4[1];
2622
-
2623
- return /*#__PURE__*/React__default.createElement(core.Dialog, {
2624
- open: true,
2625
- onClose: handleClose
2626
- }, /*#__PURE__*/React__default.createElement(core.DialogTitle, null, "Breakpoint split view options", handleClose ? /*#__PURE__*/React__default.createElement(core.IconButton, {
2627
- className: classes.closeButton,
2628
- onClick: function onClick() {
2629
- return handleClose();
2630
- }
2631
- }, /*#__PURE__*/React__default.createElement(CloseIcon, null)) : null), /*#__PURE__*/React__default.createElement(core.Divider, null), /*#__PURE__*/React__default.createElement(core.DialogContent, null, /*#__PURE__*/React__default.createElement(core.FormControlLabel, {
2632
- className: classes.block,
2633
- control: /*#__PURE__*/React__default.createElement(core.Checkbox, {
2634
- checked: copyTracks,
2635
- onChange: function onChange() {
2636
- return setCopyTracks(function (val) {
2637
- return !val;
2638
- });
2639
- }
2640
- }),
2641
- label: "Copy tracks into the new view"
2642
- }), /*#__PURE__*/React__default.createElement(core.FormControlLabel, {
2643
- className: classes.block,
2644
- control: /*#__PURE__*/React__default.createElement(core.Checkbox, {
2645
- checked: mirrorTracks,
2646
- onChange: function onChange() {
2647
- return setMirrorTracks(function (val) {
2648
- return !val;
2649
- });
2650
- }
2651
- }),
2652
- label: "Mirror tracks vertically in vertically stacked view"
2653
- })), /*#__PURE__*/React__default.createElement(core.DialogActions, null, /*#__PURE__*/React__default.createElement(core.Button, {
2654
- onClick: function onClick() {
2655
- var view = model.view;
2656
- var session = util.getSession(model);
2657
-
2658
- try {
2659
- var viewSnapshot = viewType.snapshotFromBreakendFeature(feature, view);
2660
- viewSnapshot.views[0].offsetPx -= view.width / 2 + 100;
2661
- viewSnapshot.views[1].offsetPx -= view.width / 2 + 100;
2662
- viewSnapshot.featureData = feature;
2663
- var viewTracks = mobxStateTree.getSnapshot(view.tracks);
2664
- viewSnapshot.views[0].tracks = viewTracks;
2665
- viewSnapshot.views[1].tracks = mirrorTracks ? viewTracks.slice().reverse() : viewTracks;
2666
- session.addView('BreakpointSplitView', viewSnapshot);
2667
- } catch (e) {
2668
- console.error(e);
2669
- session.notify("".concat(e));
2670
- }
2671
-
2672
- handleClose();
2673
- },
2674
- variant: "contained",
2675
- color: "primary",
2676
- autoFocus: true
2677
- }, "OK"), /*#__PURE__*/React__default.createElement(core.Button, {
2678
- onClick: function onClick() {
2679
- return handleClose();
2680
- },
2681
- color: "secondary",
2682
- variant: "contained"
2683
- }, "Cancel")));
2684
- }
2685
-
2686
- var BreakendOptionDialog$1 = /*#__PURE__*/mobxReact.observer(BreakendOptionDialog);
2687
-
2688
- var _excluded = ["samples"];
2689
-
2690
- function VariantSamples(props) {
2691
- var _useState = React.useState({}),
2692
- _useState2 = _slicedToArray(_useState, 2),
2693
- filter = _useState2[0],
2694
- setFilter = _useState2[1];
2695
-
2696
- var _useState3 = React.useState(false),
2697
- _useState4 = _slicedToArray(_useState3, 2),
2698
- showFilters = _useState4[0],
2699
- setShowFilters = _useState4[1];
2700
-
2701
- var feature = props.feature;
2702
- var _feature$samples = feature.samples,
2703
- samples = _feature$samples === void 0 ? {} : _feature$samples;
2704
- var preFilteredRows = Object.entries(samples);
2705
-
2706
- if (!preFilteredRows.length) {
2707
- return null;
2708
- }
2709
-
2710
- var infoFields = ['sample'].concat(_toConsumableArray(Object.keys(preFilteredRows[0][1]))).map(function (field) {
2711
- return {
2712
- field: field
2713
- };
2714
- });
2715
- var error;
2716
- var rows = [];
2717
- var filters = Object.keys(filter); // catch some error thrown from regex
2718
- // note: maps all values into a string, if this is not done rows are not
2719
- // sortable by the data-grid
2720
-
2721
- try {
2722
- rows = preFilteredRows.map(function (row) {
2723
- return _objectSpread2(_objectSpread2({}, Object.fromEntries(Object.entries(row[1]).map(function (entry) {
2724
- return [entry[0], String(entry[1])];
2725
- }))), {}, {
2726
- sample: row[0],
2727
- id: row[0]
2728
- });
2729
- }).filter(function (row) {
2730
- return filters.length ? filters.every(function (key) {
2731
- var val = row[key];
2732
- var currFilter = filter[key];
2733
- return currFilter ? val.match(new RegExp(currFilter, 'i')) : true;
2734
- }) : true;
2735
- });
2736
- } catch (e) {
2737
- error = e;
2738
- } // disableSelectionOnClick helps avoid
2739
- // https://github.com/mui-org/material-ui-x/issues/1197
2740
-
2741
-
2742
- return /*#__PURE__*/React__default.createElement(BaseFeatureDetail.BaseCard, Object.assign({}, props, {
2743
- title: "Samples"
2744
- }), error ? /*#__PURE__*/React__default.createElement(core.Typography, {
2745
- color: "error"
2746
- }, "".concat(error)) : null, /*#__PURE__*/React__default.createElement(core.FormControlLabel, {
2747
- control: /*#__PURE__*/React__default.createElement(core.Checkbox, {
2748
- checked: showFilters,
2749
- onChange: function onChange() {
2750
- return setShowFilters(function (f) {
2751
- return !f;
2752
- });
2753
- }
2754
- }),
2755
- label: "Show sample filters"
2756
- }), showFilters ? /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(core.Typography, null, "These filters can use a plain text search or regex style query, e.g. in the genotype field, entering 1 will query for all genotypes that include the first alternate allele e.g. 0|1 or 1|1, entering [1-9]\\d* will find any non-zero allele e.g. 0|2 or 2/33"), infoFields.map(function (_ref) {
2757
- var field = _ref.field;
2758
- return /*#__PURE__*/React__default.createElement(core.TextField, {
2759
- key: "filter-".concat(field),
2760
- placeholder: "Filter ".concat(field),
2761
- value: filter[field] || '',
2762
- onChange: function onChange(event) {
2763
- return setFilter(_objectSpread2(_objectSpread2({}, filter), {}, _defineProperty({}, field, event.target.value)));
2764
- }
2765
- });
2766
- })) : null, /*#__PURE__*/React__default.createElement("div", {
2767
- style: {
2768
- height: 600,
2769
- width: '100%',
2770
- overflow: 'auto'
2771
- }
2772
- }, /*#__PURE__*/React__default.createElement(xDataGrid.DataGrid, {
2773
- rows: rows,
2774
- columns: infoFields,
2775
- rowHeight: 20,
2776
- headerHeight: 25,
2777
- disableSelectionOnClick: true,
2778
- disableColumnMenu: true
2779
- })));
2780
- }
2781
-
2782
- function BreakendPanel(props) {
2783
- var model = props.model,
2784
- locStrings = props.locStrings,
2785
- feature = props.feature;
2786
- var session = util.getSession(model);
2787
-
2788
- var _getEnv = mobxStateTree.getEnv(session),
2789
- pluginManager = _getEnv.pluginManager;
2790
-
2791
- var _useState5 = React.useState(false),
2792
- _useState6 = _slicedToArray(_useState5, 2),
2793
- breakpointDialog = _useState6[0],
2794
- setBreakpointDialog = _useState6[1];
2795
-
2796
- var viewType;
2797
-
2798
- try {
2799
- viewType = pluginManager.getViewType('BreakpointSplitView');
2800
- } catch (e) {// ignore
2801
- }
2802
-
2803
- var simpleFeature = new SimpleFeature(feature);
2804
- return /*#__PURE__*/React__default.createElement(BaseFeatureDetail.BaseCard, Object.assign({}, props, {
2805
- title: "Breakends"
2806
- }), /*#__PURE__*/React__default.createElement(core.Typography, null, "Link to linear view of breakend endpoints"), /*#__PURE__*/React__default.createElement("ul", null, locStrings.map(function (locString) {
2807
- return /*#__PURE__*/React__default.createElement("li", {
2808
- key: "".concat(JSON.stringify(locString))
2809
- }, /*#__PURE__*/React__default.createElement(core.Link, {
2810
- href: "#",
2811
- onClick: function onClick(event) {
2812
- event.preventDefault();
2813
- var view = model.view;
2814
-
2815
- try {
2816
- if (view) {
2817
- var _view$navToLocString;
2818
-
2819
- (_view$navToLocString = view.navToLocString) === null || _view$navToLocString === void 0 ? void 0 : _view$navToLocString.call(view, locString);
2820
- } else {
2821
- throw new Error('No view associated with this feature detail panel anymore');
2822
- }
2823
- } catch (e) {
2824
- console.error(e);
2825
- session.notify("".concat(e));
2826
- }
2827
- }
2828
- }, "LGV - ".concat(locString)));
2829
- })), viewType ? /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(core.Typography, null, "Launch split views with breakend source and target"), /*#__PURE__*/React__default.createElement("ul", null, locStrings.map(function (locString) {
2830
- return /*#__PURE__*/React__default.createElement("li", {
2831
- key: "".concat(JSON.stringify(locString))
2832
- }, /*#__PURE__*/React__default.createElement(core.Link, {
2833
- href: "#",
2834
- onClick: function onClick(event) {
2835
- event.preventDefault();
2836
- setBreakpointDialog(true);
2837
- }
2838
- }, "".concat(feature.refName, ":").concat(feature.start, " // ").concat(locString, " (split view)")));
2839
- })), breakpointDialog ? /*#__PURE__*/React__default.createElement(BreakendOptionDialog$1, {
2840
- model: model,
2841
- feature: simpleFeature,
2842
- viewType: viewType,
2843
- handleClose: function handleClose() {
2844
- setBreakpointDialog(false);
2845
- }
2846
- }) : null) : null);
2847
- }
2848
-
2849
- function VariantFeatureDetails(props) {
2850
- var model = props.model;
2851
- var featureData = model.featureData,
2852
- descriptions = model.descriptions;
2853
- var feat = JSON.parse(JSON.stringify(featureData));
2854
-
2855
- var rest = _objectWithoutProperties(feat, _excluded);
2856
-
2857
- var basicDescriptions = {
2858
- CHROM: 'chromosome: An identifier from the reference genome',
2859
- POS: 'position: The reference position, with the 1st base having position 1',
2860
- ID: 'identifier: Semi-colon separated list of unique identifiers where available',
2861
- REF: 'reference base(s): Each base must be one of A,C,G,T,N (case insensitive).',
2862
- ALT: 'alternate base(s): Comma-separated list of alternate non-reference alleles',
2863
- QUAL: 'quality: Phred-scaled quality score for the assertion made in ALT',
2864
- FILTER: 'filter status: PASS if this position has passed all filters, otherwise a semicolon-separated list of codes for filters that fail'
2865
- };
2866
- return /*#__PURE__*/React__default.createElement(core.Paper, {
2867
- "data-testid": "variant-side-drawer"
2868
- }, /*#__PURE__*/React__default.createElement(BaseFeatureDetail.FeatureDetails, Object.assign({
2869
- feature: rest,
2870
- descriptions: _objectSpread2(_objectSpread2({}, basicDescriptions), descriptions)
2871
- }, props)), /*#__PURE__*/React__default.createElement(core.Divider, null), feat.type === 'breakend' ? /*#__PURE__*/React__default.createElement(BreakendPanel, {
2872
- feature: feat,
2873
- locStrings: feat.ALT.map(function (alt) {
2874
- var _parseBreakend;
2875
-
2876
- return ((_parseBreakend = VCF.parseBreakend(alt)) === null || _parseBreakend === void 0 ? void 0 : _parseBreakend.MatePosition) || '';
2877
- }),
2878
- model: model
2879
- }) : null, feat.type === 'translocation' ? /*#__PURE__*/React__default.createElement(BreakendPanel, {
2880
- feature: feat,
2881
- model: model,
2882
- locStrings: ["".concat(feat.INFO.CHR2[0], ":").concat(feat.INFO.END)]
2883
- }) : null, /*#__PURE__*/React__default.createElement(VariantSamples, Object.assign({
2884
- feature: feat
2885
- }, props)));
2886
- }
2887
-
2888
- var VariantFeatureWidget = /*#__PURE__*/mobxReact.observer(VariantFeatureDetails);
2889
-
2890
- var VariantFeatureWidget$1 = {
2891
- __proto__: null,
2892
- 'default': VariantFeatureWidget
2893
- };
2894
-
2895
- exports.VcfFeature = VCFFeature;
2896
- exports.default = VariantsPlugin;
2897
- //# sourceMappingURL=plugin-variants.cjs.development.js.map