jbrowse-plugin-mafviewer 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +8 -0
  3. package/dist/jbrowse-plugin-mafviewer.umd.development.js +1310 -0
  4. package/dist/jbrowse-plugin-mafviewer.umd.development.js.map +1 -0
  5. package/dist/jbrowse-plugin-mafviewer.umd.production.min.js +2 -0
  6. package/dist/jbrowse-plugin-mafviewer.umd.production.min.js.map +1 -0
  7. package/package.json +90 -0
  8. package/src/BigMafAdapter/BigMafAdapter.ts +120 -0
  9. package/src/BigMafAdapter/configSchema.ts +33 -0
  10. package/src/BigMafAdapter/index.ts +15 -0
  11. package/src/LinearMafDisplay/components/ColorLegend.tsx +59 -0
  12. package/src/LinearMafDisplay/components/ReactComponent.tsx +23 -0
  13. package/src/LinearMafDisplay/components/RectBg.tsx +14 -0
  14. package/src/LinearMafDisplay/components/YScaleBars.tsx +63 -0
  15. package/src/LinearMafDisplay/configSchema.ts +23 -0
  16. package/src/LinearMafDisplay/index.ts +21 -0
  17. package/src/LinearMafDisplay/renderSvg.tsx +26 -0
  18. package/src/LinearMafDisplay/stateModel.ts +111 -0
  19. package/src/LinearMafRenderer/LinearMafRenderer.ts +172 -0
  20. package/src/LinearMafRenderer/components/ReactComponent.tsx +9 -0
  21. package/src/LinearMafRenderer/configSchema.ts +19 -0
  22. package/src/LinearMafRenderer/index.ts +16 -0
  23. package/src/MafAddTrackWorkflow/AddTrackWorkflow.tsx +166 -0
  24. package/src/MafAddTrackWorkflow/index.ts +17 -0
  25. package/src/MafTabixAdapter/MafTabixAdapter.ts +104 -0
  26. package/src/MafTabixAdapter/configSchema.ts +45 -0
  27. package/src/MafTabixAdapter/index.ts +15 -0
  28. package/src/MafTrack/configSchema.ts +20 -0
  29. package/src/MafTrack/index.ts +18 -0
  30. package/src/declare.d.ts +1 -0
  31. package/src/index.ts +26 -0
@@ -0,0 +1,1310 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@jbrowse/core/Plugin'), require('@jbrowse/core/pluggableElementTypes'), require('@jbrowse/core/configuration'), require('@jbrowse/core/data_adapters/BaseAdapter'), require('mobx-state-tree'), require('@jbrowse/core/util'), require('@jbrowse/core/util/rxjs'), require('react'), require('mobx-react'), require('@jbrowse/core/ui'), require('@mui/material'), require('tss-react/mui')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@jbrowse/core/Plugin', '@jbrowse/core/pluggableElementTypes', '@jbrowse/core/configuration', '@jbrowse/core/data_adapters/BaseAdapter', 'mobx-state-tree', '@jbrowse/core/util', '@jbrowse/core/util/rxjs', 'react', 'mobx-react', '@jbrowse/core/ui', '@mui/material', 'tss-react/mui'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.JBrowsePluginMafViewer = {}, global.JBrowseExports["@jbrowse/core/Plugin"], global.JBrowseExports["@jbrowse/core/pluggableElementTypes"], global.JBrowseExports["@jbrowse/core/configuration"], global.JBrowseExports["@jbrowse/core/data_adapters/BaseAdapter"], global.JBrowseExports["mobx-state-tree"], global.JBrowseExports["@jbrowse/core/util"], global.JBrowseExports["@jbrowse/core/util/rxjs"], global.JBrowseExports.react, global.JBrowseExports["mobx-react"], global.JBrowseExports["@jbrowse/core/ui"], global.JBrowseExports["@mui/material"], global.JBrowseExports["tss-react/mui"]));
5
+ })(this, (function (exports, Plugin, pluggableElementTypes, configuration, BaseAdapter, mobxStateTree, util, rxjs, React, mobxReact, ui, material, mui) { 'use strict';
6
+
7
+ var version = "1.0.1";
8
+
9
+ const configSchema$2 = configuration.ConfigurationSchema('BigMafAdapter', {
10
+ /**
11
+ * #slot
12
+ */
13
+ samples: {
14
+ type: 'stringArray',
15
+ defaultValue: [],
16
+ },
17
+ /**
18
+ * #slot
19
+ */
20
+ bigBedLocation: {
21
+ type: 'fileLocation',
22
+ defaultValue: {
23
+ uri: '/path/to/my.bb',
24
+ locationType: 'UriLocation',
25
+ },
26
+ },
27
+ }, { explicitlyTyped: true });
28
+
29
+ /******************************************************************************
30
+ Copyright (c) Microsoft Corporation.
31
+
32
+ Permission to use, copy, modify, and/or distribute this software for any
33
+ purpose with or without fee is hereby granted.
34
+
35
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
36
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
37
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
38
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
39
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
40
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
41
+ PERFORMANCE OF THIS SOFTWARE.
42
+ ***************************************************************************** */
43
+ /* global Reflect, Promise, SuppressedError, Symbol */
44
+
45
+ var extendStatics = function(d, b) {
46
+ extendStatics = Object.setPrototypeOf ||
47
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
48
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
49
+ return extendStatics(d, b);
50
+ };
51
+
52
+ function __extends(d, b) {
53
+ if (typeof b !== "function" && b !== null)
54
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
55
+ extendStatics(d, b);
56
+ function __() { this.constructor = d; }
57
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
58
+ }
59
+
60
+ function __values(o) {
61
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
62
+ if (m) return m.call(o);
63
+ if (o && typeof o.length === "number") return {
64
+ next: function () {
65
+ if (o && i >= o.length) o = void 0;
66
+ return { value: o && o[i++], done: !o };
67
+ }
68
+ };
69
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
70
+ }
71
+
72
+ function __read(o, n) {
73
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
74
+ if (!m) return o;
75
+ var i = m.call(o), r, ar = [], e;
76
+ try {
77
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
78
+ }
79
+ catch (error) { e = { error: error }; }
80
+ finally {
81
+ try {
82
+ if (r && !r.done && (m = i["return"])) m.call(i);
83
+ }
84
+ finally { if (e) throw e.error; }
85
+ }
86
+ return ar;
87
+ }
88
+
89
+ function __spreadArray(to, from, pack) {
90
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
91
+ if (ar || !(i in from)) {
92
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
93
+ ar[i] = from[i];
94
+ }
95
+ }
96
+ return to.concat(ar || Array.prototype.slice.call(from));
97
+ }
98
+
99
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
100
+ var e = new Error(message);
101
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
102
+ };
103
+
104
+ function isFunction(value) {
105
+ return typeof value === 'function';
106
+ }
107
+
108
+ function createErrorClass(createImpl) {
109
+ var _super = function (instance) {
110
+ Error.call(instance);
111
+ instance.stack = new Error().stack;
112
+ };
113
+ var ctorFunc = createImpl(_super);
114
+ ctorFunc.prototype = Object.create(Error.prototype);
115
+ ctorFunc.prototype.constructor = ctorFunc;
116
+ return ctorFunc;
117
+ }
118
+
119
+ var UnsubscriptionError = createErrorClass(function (_super) {
120
+ return function UnsubscriptionErrorImpl(errors) {
121
+ _super(this);
122
+ this.message = errors
123
+ ? errors.length + " errors occurred during unsubscription:\n" + errors.map(function (err, i) { return i + 1 + ") " + err.toString(); }).join('\n ')
124
+ : '';
125
+ this.name = 'UnsubscriptionError';
126
+ this.errors = errors;
127
+ };
128
+ });
129
+
130
+ function arrRemove(arr, item) {
131
+ if (arr) {
132
+ var index = arr.indexOf(item);
133
+ 0 <= index && arr.splice(index, 1);
134
+ }
135
+ }
136
+
137
+ var Subscription = (function () {
138
+ function Subscription(initialTeardown) {
139
+ this.initialTeardown = initialTeardown;
140
+ this.closed = false;
141
+ this._parentage = null;
142
+ this._finalizers = null;
143
+ }
144
+ Subscription.prototype.unsubscribe = function () {
145
+ var e_1, _a, e_2, _b;
146
+ var errors;
147
+ if (!this.closed) {
148
+ this.closed = true;
149
+ var _parentage = this._parentage;
150
+ if (_parentage) {
151
+ this._parentage = null;
152
+ if (Array.isArray(_parentage)) {
153
+ try {
154
+ for (var _parentage_1 = __values(_parentage), _parentage_1_1 = _parentage_1.next(); !_parentage_1_1.done; _parentage_1_1 = _parentage_1.next()) {
155
+ var parent_1 = _parentage_1_1.value;
156
+ parent_1.remove(this);
157
+ }
158
+ }
159
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
160
+ finally {
161
+ try {
162
+ if (_parentage_1_1 && !_parentage_1_1.done && (_a = _parentage_1.return)) _a.call(_parentage_1);
163
+ }
164
+ finally { if (e_1) throw e_1.error; }
165
+ }
166
+ }
167
+ else {
168
+ _parentage.remove(this);
169
+ }
170
+ }
171
+ var initialFinalizer = this.initialTeardown;
172
+ if (isFunction(initialFinalizer)) {
173
+ try {
174
+ initialFinalizer();
175
+ }
176
+ catch (e) {
177
+ errors = e instanceof UnsubscriptionError ? e.errors : [e];
178
+ }
179
+ }
180
+ var _finalizers = this._finalizers;
181
+ if (_finalizers) {
182
+ this._finalizers = null;
183
+ try {
184
+ for (var _finalizers_1 = __values(_finalizers), _finalizers_1_1 = _finalizers_1.next(); !_finalizers_1_1.done; _finalizers_1_1 = _finalizers_1.next()) {
185
+ var finalizer = _finalizers_1_1.value;
186
+ try {
187
+ execFinalizer(finalizer);
188
+ }
189
+ catch (err) {
190
+ errors = errors !== null && errors !== void 0 ? errors : [];
191
+ if (err instanceof UnsubscriptionError) {
192
+ errors = __spreadArray(__spreadArray([], __read(errors)), __read(err.errors));
193
+ }
194
+ else {
195
+ errors.push(err);
196
+ }
197
+ }
198
+ }
199
+ }
200
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
201
+ finally {
202
+ try {
203
+ if (_finalizers_1_1 && !_finalizers_1_1.done && (_b = _finalizers_1.return)) _b.call(_finalizers_1);
204
+ }
205
+ finally { if (e_2) throw e_2.error; }
206
+ }
207
+ }
208
+ if (errors) {
209
+ throw new UnsubscriptionError(errors);
210
+ }
211
+ }
212
+ };
213
+ Subscription.prototype.add = function (teardown) {
214
+ var _a;
215
+ if (teardown && teardown !== this) {
216
+ if (this.closed) {
217
+ execFinalizer(teardown);
218
+ }
219
+ else {
220
+ if (teardown instanceof Subscription) {
221
+ if (teardown.closed || teardown._hasParent(this)) {
222
+ return;
223
+ }
224
+ teardown._addParent(this);
225
+ }
226
+ (this._finalizers = (_a = this._finalizers) !== null && _a !== void 0 ? _a : []).push(teardown);
227
+ }
228
+ }
229
+ };
230
+ Subscription.prototype._hasParent = function (parent) {
231
+ var _parentage = this._parentage;
232
+ return _parentage === parent || (Array.isArray(_parentage) && _parentage.includes(parent));
233
+ };
234
+ Subscription.prototype._addParent = function (parent) {
235
+ var _parentage = this._parentage;
236
+ this._parentage = Array.isArray(_parentage) ? (_parentage.push(parent), _parentage) : _parentage ? [_parentage, parent] : parent;
237
+ };
238
+ Subscription.prototype._removeParent = function (parent) {
239
+ var _parentage = this._parentage;
240
+ if (_parentage === parent) {
241
+ this._parentage = null;
242
+ }
243
+ else if (Array.isArray(_parentage)) {
244
+ arrRemove(_parentage, parent);
245
+ }
246
+ };
247
+ Subscription.prototype.remove = function (teardown) {
248
+ var _finalizers = this._finalizers;
249
+ _finalizers && arrRemove(_finalizers, teardown);
250
+ if (teardown instanceof Subscription) {
251
+ teardown._removeParent(this);
252
+ }
253
+ };
254
+ Subscription.EMPTY = (function () {
255
+ var empty = new Subscription();
256
+ empty.closed = true;
257
+ return empty;
258
+ })();
259
+ return Subscription;
260
+ }());
261
+ function isSubscription(value) {
262
+ return (value instanceof Subscription ||
263
+ (value && 'closed' in value && isFunction(value.remove) && isFunction(value.add) && isFunction(value.unsubscribe)));
264
+ }
265
+ function execFinalizer(finalizer) {
266
+ if (isFunction(finalizer)) {
267
+ finalizer();
268
+ }
269
+ else {
270
+ finalizer.unsubscribe();
271
+ }
272
+ }
273
+
274
+ var config = {
275
+ onUnhandledError: null,
276
+ onStoppedNotification: null,
277
+ Promise: undefined,
278
+ useDeprecatedSynchronousErrorHandling: false,
279
+ useDeprecatedNextContext: false,
280
+ };
281
+
282
+ var timeoutProvider = {
283
+ setTimeout: function (handler, timeout) {
284
+ var args = [];
285
+ for (var _i = 2; _i < arguments.length; _i++) {
286
+ args[_i - 2] = arguments[_i];
287
+ }
288
+ var delegate = timeoutProvider.delegate;
289
+ if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
290
+ return delegate.setTimeout.apply(delegate, __spreadArray([handler, timeout], __read(args)));
291
+ }
292
+ return setTimeout.apply(void 0, __spreadArray([handler, timeout], __read(args)));
293
+ },
294
+ clearTimeout: function (handle) {
295
+ var delegate = timeoutProvider.delegate;
296
+ return ((delegate === null || delegate === void 0 ? void 0 : delegate.clearTimeout) || clearTimeout)(handle);
297
+ },
298
+ delegate: undefined,
299
+ };
300
+
301
+ function reportUnhandledError(err) {
302
+ timeoutProvider.setTimeout(function () {
303
+ {
304
+ throw err;
305
+ }
306
+ });
307
+ }
308
+
309
+ function noop() { }
310
+
311
+ var Subscriber = (function (_super) {
312
+ __extends(Subscriber, _super);
313
+ function Subscriber(destination) {
314
+ var _this = _super.call(this) || this;
315
+ _this.isStopped = false;
316
+ if (destination) {
317
+ _this.destination = destination;
318
+ if (isSubscription(destination)) {
319
+ destination.add(_this);
320
+ }
321
+ }
322
+ else {
323
+ _this.destination = EMPTY_OBSERVER;
324
+ }
325
+ return _this;
326
+ }
327
+ Subscriber.create = function (next, error, complete) {
328
+ return new SafeSubscriber(next, error, complete);
329
+ };
330
+ Subscriber.prototype.next = function (value) {
331
+ if (this.isStopped) ;
332
+ else {
333
+ this._next(value);
334
+ }
335
+ };
336
+ Subscriber.prototype.error = function (err) {
337
+ if (this.isStopped) ;
338
+ else {
339
+ this.isStopped = true;
340
+ this._error(err);
341
+ }
342
+ };
343
+ Subscriber.prototype.complete = function () {
344
+ if (this.isStopped) ;
345
+ else {
346
+ this.isStopped = true;
347
+ this._complete();
348
+ }
349
+ };
350
+ Subscriber.prototype.unsubscribe = function () {
351
+ if (!this.closed) {
352
+ this.isStopped = true;
353
+ _super.prototype.unsubscribe.call(this);
354
+ this.destination = null;
355
+ }
356
+ };
357
+ Subscriber.prototype._next = function (value) {
358
+ this.destination.next(value);
359
+ };
360
+ Subscriber.prototype._error = function (err) {
361
+ try {
362
+ this.destination.error(err);
363
+ }
364
+ finally {
365
+ this.unsubscribe();
366
+ }
367
+ };
368
+ Subscriber.prototype._complete = function () {
369
+ try {
370
+ this.destination.complete();
371
+ }
372
+ finally {
373
+ this.unsubscribe();
374
+ }
375
+ };
376
+ return Subscriber;
377
+ }(Subscription));
378
+ var _bind = Function.prototype.bind;
379
+ function bind(fn, thisArg) {
380
+ return _bind.call(fn, thisArg);
381
+ }
382
+ var ConsumerObserver = (function () {
383
+ function ConsumerObserver(partialObserver) {
384
+ this.partialObserver = partialObserver;
385
+ }
386
+ ConsumerObserver.prototype.next = function (value) {
387
+ var partialObserver = this.partialObserver;
388
+ if (partialObserver.next) {
389
+ try {
390
+ partialObserver.next(value);
391
+ }
392
+ catch (error) {
393
+ handleUnhandledError(error);
394
+ }
395
+ }
396
+ };
397
+ ConsumerObserver.prototype.error = function (err) {
398
+ var partialObserver = this.partialObserver;
399
+ if (partialObserver.error) {
400
+ try {
401
+ partialObserver.error(err);
402
+ }
403
+ catch (error) {
404
+ handleUnhandledError(error);
405
+ }
406
+ }
407
+ else {
408
+ handleUnhandledError(err);
409
+ }
410
+ };
411
+ ConsumerObserver.prototype.complete = function () {
412
+ var partialObserver = this.partialObserver;
413
+ if (partialObserver.complete) {
414
+ try {
415
+ partialObserver.complete();
416
+ }
417
+ catch (error) {
418
+ handleUnhandledError(error);
419
+ }
420
+ }
421
+ };
422
+ return ConsumerObserver;
423
+ }());
424
+ var SafeSubscriber = (function (_super) {
425
+ __extends(SafeSubscriber, _super);
426
+ function SafeSubscriber(observerOrNext, error, complete) {
427
+ var _this = _super.call(this) || this;
428
+ var partialObserver;
429
+ if (isFunction(observerOrNext) || !observerOrNext) {
430
+ partialObserver = {
431
+ next: (observerOrNext !== null && observerOrNext !== void 0 ? observerOrNext : undefined),
432
+ error: error !== null && error !== void 0 ? error : undefined,
433
+ complete: complete !== null && complete !== void 0 ? complete : undefined,
434
+ };
435
+ }
436
+ else {
437
+ var context_1;
438
+ if (_this && config.useDeprecatedNextContext) {
439
+ context_1 = Object.create(observerOrNext);
440
+ context_1.unsubscribe = function () { return _this.unsubscribe(); };
441
+ partialObserver = {
442
+ next: observerOrNext.next && bind(observerOrNext.next, context_1),
443
+ error: observerOrNext.error && bind(observerOrNext.error, context_1),
444
+ complete: observerOrNext.complete && bind(observerOrNext.complete, context_1),
445
+ };
446
+ }
447
+ else {
448
+ partialObserver = observerOrNext;
449
+ }
450
+ }
451
+ _this.destination = new ConsumerObserver(partialObserver);
452
+ return _this;
453
+ }
454
+ return SafeSubscriber;
455
+ }(Subscriber));
456
+ function handleUnhandledError(error) {
457
+ {
458
+ reportUnhandledError(error);
459
+ }
460
+ }
461
+ function defaultErrorHandler(err) {
462
+ throw err;
463
+ }
464
+ var EMPTY_OBSERVER = {
465
+ closed: true,
466
+ next: noop,
467
+ error: defaultErrorHandler,
468
+ complete: noop,
469
+ };
470
+
471
+ function hasLift(source) {
472
+ return isFunction(source === null || source === void 0 ? void 0 : source.lift);
473
+ }
474
+ function operate(init) {
475
+ return function (source) {
476
+ if (hasLift(source)) {
477
+ return source.lift(function (liftedSource) {
478
+ try {
479
+ return init(liftedSource, this);
480
+ }
481
+ catch (err) {
482
+ this.error(err);
483
+ }
484
+ });
485
+ }
486
+ throw new TypeError('Unable to lift unknown Observable type');
487
+ };
488
+ }
489
+
490
+ function createOperatorSubscriber(destination, onNext, onComplete, onError, onFinalize) {
491
+ return new OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize);
492
+ }
493
+ var OperatorSubscriber = (function (_super) {
494
+ __extends(OperatorSubscriber, _super);
495
+ function OperatorSubscriber(destination, onNext, onComplete, onError, onFinalize, shouldUnsubscribe) {
496
+ var _this = _super.call(this, destination) || this;
497
+ _this.onFinalize = onFinalize;
498
+ _this.shouldUnsubscribe = shouldUnsubscribe;
499
+ _this._next = onNext
500
+ ? function (value) {
501
+ try {
502
+ onNext(value);
503
+ }
504
+ catch (err) {
505
+ destination.error(err);
506
+ }
507
+ }
508
+ : _super.prototype._next;
509
+ _this._error = onError
510
+ ? function (err) {
511
+ try {
512
+ onError(err);
513
+ }
514
+ catch (err) {
515
+ destination.error(err);
516
+ }
517
+ finally {
518
+ this.unsubscribe();
519
+ }
520
+ }
521
+ : _super.prototype._error;
522
+ _this._complete = onComplete
523
+ ? function () {
524
+ try {
525
+ onComplete();
526
+ }
527
+ catch (err) {
528
+ destination.error(err);
529
+ }
530
+ finally {
531
+ this.unsubscribe();
532
+ }
533
+ }
534
+ : _super.prototype._complete;
535
+ return _this;
536
+ }
537
+ OperatorSubscriber.prototype.unsubscribe = function () {
538
+ var _a;
539
+ if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
540
+ var closed_1 = this.closed;
541
+ _super.prototype.unsubscribe.call(this);
542
+ !closed_1 && ((_a = this.onFinalize) === null || _a === void 0 ? void 0 : _a.call(this));
543
+ }
544
+ };
545
+ return OperatorSubscriber;
546
+ }(Subscriber));
547
+
548
+ var EmptyError = createErrorClass(function (_super) { return function EmptyErrorImpl() {
549
+ _super(this);
550
+ this.name = 'EmptyError';
551
+ this.message = 'no elements in sequence';
552
+ }; });
553
+
554
+ function firstValueFrom(source, config) {
555
+ var hasConfig = typeof config === 'object';
556
+ return new Promise(function (resolve, reject) {
557
+ var subscriber = new SafeSubscriber({
558
+ next: function (value) {
559
+ resolve(value);
560
+ subscriber.unsubscribe();
561
+ },
562
+ error: reject,
563
+ complete: function () {
564
+ if (hasConfig) {
565
+ resolve(config.defaultValue);
566
+ }
567
+ else {
568
+ reject(new EmptyError());
569
+ }
570
+ },
571
+ });
572
+ source.subscribe(subscriber);
573
+ });
574
+ }
575
+
576
+ function scanInternals(accumulator, seed, hasSeed, emitOnNext, emitBeforeComplete) {
577
+ return function (source, subscriber) {
578
+ var hasState = hasSeed;
579
+ var state = seed;
580
+ var index = 0;
581
+ source.subscribe(createOperatorSubscriber(subscriber, function (value) {
582
+ var i = index++;
583
+ state = hasState
584
+ ?
585
+ accumulator(state, value, i)
586
+ :
587
+ ((hasState = true), value);
588
+ emitOnNext && subscriber.next(state);
589
+ }, emitBeforeComplete &&
590
+ (function () {
591
+ hasState && subscriber.next(state);
592
+ subscriber.complete();
593
+ })));
594
+ };
595
+ }
596
+
597
+ function reduce(accumulator, seed) {
598
+ return operate(scanInternals(accumulator, seed, arguments.length >= 2, false, true));
599
+ }
600
+
601
+ var arrReducer = function (arr, value) { return (arr.push(value), arr); };
602
+ function toArray() {
603
+ return operate(function (source, subscriber) {
604
+ reduce(arrReducer, [])(source).subscribe(subscriber);
605
+ });
606
+ }
607
+
608
+ let BigMafAdapter$1 = class BigMafAdapter extends BaseAdapter.BaseFeatureDataAdapter {
609
+ setupP;
610
+ async setup() {
611
+ if (!this.getSubAdapter) {
612
+ throw new Error('no getSubAdapter available');
613
+ }
614
+ const adapter = await this.getSubAdapter({
615
+ ...mobxStateTree.getSnapshot(this.config),
616
+ type: 'BigBedAdapter',
617
+ });
618
+ return {
619
+ adapter: adapter.dataAdapter,
620
+ };
621
+ }
622
+ async setupPre() {
623
+ if (!this.setupP) {
624
+ this.setupP = this.setup().catch(e => {
625
+ this.setupP = undefined;
626
+ throw e;
627
+ });
628
+ }
629
+ return this.setupP;
630
+ }
631
+ async getRefNames() {
632
+ const { adapter } = await this.setup();
633
+ return adapter.getRefNames();
634
+ }
635
+ async getHeader() {
636
+ const { adapter } = await this.setup();
637
+ return adapter.getHeader();
638
+ }
639
+ getFeatures(query) {
640
+ return rxjs.ObservableCreate(async (observer) => {
641
+ const { adapter } = await this.setup();
642
+ const features = await firstValueFrom(adapter.getFeatures(query).pipe(toArray()));
643
+ for (const feature of features) {
644
+ const maf = feature.get('mafBlock');
645
+ const blocks = maf.split(';');
646
+ let aln;
647
+ const alns = [];
648
+ const alignments = {};
649
+ const blocks2 = [];
650
+ for (const block of blocks) {
651
+ if (block[0] === 's') {
652
+ if (!aln) {
653
+ aln = block.split(/ +/)[6];
654
+ alns.push(aln);
655
+ blocks2.push(block);
656
+ }
657
+ else {
658
+ alns.push(block.split(/ +/)[6]);
659
+ blocks2.push(block);
660
+ }
661
+ }
662
+ }
663
+ const alns2 = alns.map(() => '');
664
+ if (aln) {
665
+ for (let i = 0; i < aln?.length; i++) {
666
+ if (aln[i] !== '-') {
667
+ for (let j = 0; j < alns.length; j++) {
668
+ alns2[j] += alns[j][i];
669
+ }
670
+ }
671
+ }
672
+ }
673
+ for (let i = 0; i < blocks2.length; i++) {
674
+ const elt = blocks2[i];
675
+ const ad = elt.split(/ +/);
676
+ const y = ad[1].split('.');
677
+ const org = y[0];
678
+ const chr = y[1];
679
+ alignments[org] = {
680
+ chr: chr,
681
+ start: +ad[1],
682
+ srcSize: +ad[2],
683
+ strand: ad[3] === '+' ? 1 : -1,
684
+ unknown: +ad[4],
685
+ data: alns2[i],
686
+ };
687
+ }
688
+ observer.next(new util.SimpleFeature({
689
+ id: feature.id(),
690
+ data: {
691
+ start: feature.get('start'),
692
+ end: feature.get('end'),
693
+ refName: feature.get('refName'),
694
+ seq: alns2[0],
695
+ alignments: alignments,
696
+ },
697
+ }));
698
+ }
699
+ observer.complete();
700
+ });
701
+ }
702
+ freeResources() { }
703
+ };
704
+
705
+ function BigMafAdapterF(pluginManager) {
706
+ return pluginManager.addAdapterType(() => new pluggableElementTypes.AdapterType({
707
+ name: 'BigMafAdapter',
708
+ AdapterClass: BigMafAdapter$1,
709
+ configSchema: configSchema$2,
710
+ }));
711
+ }
712
+
713
+ function configSchemaF$1(pluginManager) {
714
+ return configuration.ConfigurationSchema('MafTrack', {}, {
715
+ /**
716
+ * #baseConfiguration
717
+ */
718
+ baseConfiguration: pluggableElementTypes.createBaseTrackConfig(pluginManager),
719
+ /**
720
+ * #identifier
721
+ */
722
+ explicitIdentifier: 'trackId',
723
+ });
724
+ }
725
+
726
+ function MafTrackF(pluginManager) {
727
+ return pluginManager.addTrackType(() => {
728
+ const configSchema = configSchemaF$1(pluginManager);
729
+ return new pluggableElementTypes.TrackType({
730
+ name: 'MafTrack',
731
+ configSchema,
732
+ displayName: 'MAF track',
733
+ stateModel: pluggableElementTypes.createBaseTrackModel(pluginManager, 'MafTrack', configSchema),
734
+ });
735
+ });
736
+ }
737
+
738
+ function configSchemaF(pluginManager) {
739
+ const LinearGenomePlugin = pluginManager.getPlugin('LinearGenomeViewPlugin');
740
+ // @ts-expect-error
741
+ const { linearBasicDisplayConfigSchemaFactory } = LinearGenomePlugin.exports;
742
+ return configuration.ConfigurationSchema('LinearMafDisplay', {
743
+ /**
744
+ * #slot
745
+ */
746
+ renderer: pluginManager.pluggableConfigSchemaType('renderer'),
747
+ }, {
748
+ baseConfiguration: linearBasicDisplayConfigSchemaFactory(pluginManager),
749
+ explicitlyTyped: true,
750
+ });
751
+ }
752
+
753
+ /**
754
+ * #stateModel LinearMafDisplay
755
+ * extends LinearBasicDisplay
756
+ */
757
+ function stateModelFactory(configSchema, pluginManager) {
758
+ const LinearGenomePlugin = pluginManager.getPlugin('LinearGenomeViewPlugin');
759
+ // @ts-expect-error
760
+ const { linearBasicDisplayModelFactory } = LinearGenomePlugin.exports;
761
+ return mobxStateTree.types
762
+ .compose('LinearMafDisplay', linearBasicDisplayModelFactory(configSchema), mobxStateTree.types.model({
763
+ /**
764
+ * #property
765
+ */
766
+ type: mobxStateTree.types.literal('LinearMafDisplay'),
767
+ /**
768
+ * #property
769
+ */
770
+ configuration: configuration.ConfigurationReference(configSchema),
771
+ }))
772
+ .volatile(() => ({
773
+ prefersOffset: true,
774
+ }))
775
+ .views(self => ({
776
+ /**
777
+ * #getter
778
+ */
779
+ get samples() {
780
+ const r = self.adapterConfig.samples;
781
+ return r.map(elt => ({ name: elt, color: undefined }));
782
+ },
783
+ /**
784
+ * #getter
785
+ */
786
+ get rowHeight() {
787
+ return 20;
788
+ },
789
+ /**
790
+ * #getter
791
+ */
792
+ get rendererTypeName() {
793
+ return 'LinearMafRenderer';
794
+ },
795
+ /**
796
+ * #getter
797
+ */
798
+ get rendererConfig() {
799
+ const configBlob = configuration.getConf(self, ['renderer']) || {};
800
+ const config = configBlob;
801
+ return self.rendererType.configSchema.create({
802
+ ...config,
803
+ type: 'LinearMafRenderer',
804
+ }, util.getEnv(self));
805
+ },
806
+ }))
807
+ .views(self => {
808
+ const { renderProps: superRenderProps } = self;
809
+ return {
810
+ /**
811
+ * #method
812
+ */
813
+ renderProps() {
814
+ return {
815
+ ...superRenderProps(),
816
+ samples: self.samples,
817
+ rowHeight: self.rowHeight,
818
+ };
819
+ },
820
+ };
821
+ })
822
+ .actions(self => {
823
+ const { renderSvg: superRenderSvg } = self;
824
+ return {
825
+ /**
826
+ * #action
827
+ */
828
+ async renderSvg(opts) {
829
+ const { renderSvg } = await Promise.resolve().then(function () { return renderSvg$1; });
830
+ // @ts-expect-error
831
+ return renderSvg(self, opts, superRenderSvg);
832
+ },
833
+ };
834
+ });
835
+ }
836
+
837
+ const RectBg = (props) => {
838
+ const { color = 'rgb(255,255,255,0.8)' } = props;
839
+ return React.createElement("rect", { ...props, fill: color });
840
+ };
841
+
842
+ const ColorLegend = mobxReact.observer(function ({ model, labelWidth, }) {
843
+ const { samples, rowHeight } = model;
844
+ const svgFontSize = Math.min(rowHeight, 12);
845
+ const canDisplayLabel = rowHeight > 11;
846
+ const colorBoxWidth = 15;
847
+ const legendWidth = labelWidth + colorBoxWidth + 5;
848
+ const extraOffset = 0;
849
+ return samples ? (React.createElement(React.Fragment, null, samples.map((source, idx) => {
850
+ const boxHeight = Math.min(20, rowHeight);
851
+ return (React.createElement(React.Fragment, { key: `${source.name}-${idx}` },
852
+ source.color ? (React.createElement(RectBg, { y: idx * rowHeight + 1, x: extraOffset, width: colorBoxWidth, height: boxHeight, color: source.color })) : null,
853
+ React.createElement(RectBg, { y: idx * rowHeight + 1, x: extraOffset, width: legendWidth, height: boxHeight }),
854
+ canDisplayLabel ? (React.createElement("text", { y: idx * rowHeight + 13, x: extraOffset + colorBoxWidth + 2, fontSize: svgFontSize }, source.name)) : null));
855
+ }))) : null;
856
+ });
857
+
858
+ const Wrapper = mobxReact.observer(function ({ children, model, exportSVG, }) {
859
+ if (exportSVG) {
860
+ return React.createElement(React.Fragment, null, children);
861
+ }
862
+ else {
863
+ const { rowHeight, samples } = model;
864
+ return (React.createElement("svg", { style: {
865
+ position: 'absolute',
866
+ top: 0,
867
+ left: 0,
868
+ pointerEvents: 'none',
869
+ height: samples.length * rowHeight,
870
+ width: util.getContainingView(model).width,
871
+ } }, children));
872
+ }
873
+ });
874
+ const YScaleBars = mobxReact.observer(function (props) {
875
+ const { model } = props;
876
+ const { rowHeight, samples } = model;
877
+ const svgFontSize = Math.min(rowHeight, 12);
878
+ const canDisplayLabel = rowHeight > 11;
879
+ const minWidth = 20;
880
+ const labelWidth = Math.max(...(samples
881
+ .map(s => util.measureText(s, svgFontSize))
882
+ .map(width => (canDisplayLabel ? width : minWidth)) || [0]));
883
+ return (React.createElement(Wrapper, { ...props },
884
+ React.createElement(ColorLegend, { model: model, labelWidth: labelWidth })));
885
+ });
886
+
887
+ const LinearMafDisplay = mobxReact.observer(function (props) {
888
+ const { model } = props;
889
+ const { pluginManager } = util.getEnv(model);
890
+ const LinearGenomePlugin = pluginManager.getPlugin('LinearGenomeViewPlugin');
891
+ const { BaseLinearDisplayComponent } = LinearGenomePlugin.exports;
892
+ return (React.createElement("div", null,
893
+ React.createElement(BaseLinearDisplayComponent, { ...props }),
894
+ React.createElement(YScaleBars, { model: model })));
895
+ });
896
+
897
+ function LinearMafDisplayF(pluginManager) {
898
+ pluginManager.addDisplayType(() => {
899
+ const configSchema = configSchemaF(pluginManager);
900
+ const stateModel = stateModelFactory(configSchema, pluginManager);
901
+ return new pluggableElementTypes.DisplayType({
902
+ name: 'LinearMafDisplay',
903
+ configSchema,
904
+ stateModel,
905
+ ReactComponent: LinearMafDisplay,
906
+ viewType: 'LinearGenomeView',
907
+ trackType: 'MafTrack',
908
+ displayName: 'MAF display',
909
+ });
910
+ });
911
+ }
912
+
913
+ const configSchema$1 = configuration.ConfigurationSchema('LinearMafRenderer', {}, {
914
+ /**
915
+ * #baseConfiguration
916
+ */
917
+ explicitlyTyped: true,
918
+ });
919
+
920
+ function getCorrectionFactor(scale) {
921
+ if (scale >= 1) {
922
+ return 0.6;
923
+ }
924
+ else if (scale >= 0.2) {
925
+ return 0.05;
926
+ }
927
+ else if (scale >= 0.02) {
928
+ return 0.03;
929
+ }
930
+ else {
931
+ return 0.02;
932
+ }
933
+ }
934
+ function getContrastBaseMap(theme) {
935
+ return Object.fromEntries(Object.entries(getColorBaseMap(theme)).map(([key, value]) => [
936
+ key,
937
+ theme.palette.getContrastText(value),
938
+ ]));
939
+ }
940
+ function getColorBaseMap(theme) {
941
+ const { bases } = theme.palette;
942
+ return {
943
+ a: bases.A.main,
944
+ c: bases.C.main,
945
+ g: bases.G.main,
946
+ t: bases.T.main,
947
+ };
948
+ }
949
+ function makeImageData({ ctx, renderArgs, }) {
950
+ const { regions, bpPerPx, rowHeight, theme: configTheme, samples, } = renderArgs;
951
+ const [region] = regions;
952
+ const features = renderArgs.features;
953
+ const h = rowHeight;
954
+ const theme = ui.createJBrowseTheme(configTheme);
955
+ const colorForBase = getColorBaseMap(theme);
956
+ const contrastForBase = getContrastBaseMap(theme);
957
+ const sampleToRowMap = new Map(samples.map((s, i) => [s.name, i]));
958
+ const scale = 1 / bpPerPx;
959
+ const correctionFactor = getCorrectionFactor(bpPerPx);
960
+ // sample as alignments
961
+ ctx.font = 'bold 10px Courier New,monospace';
962
+ for (const feature of features.values()) {
963
+ const [leftPx] = util.featureSpanPx(feature, region, bpPerPx);
964
+ const vals = feature.get('alignments');
965
+ const seq = feature.get('seq').toLowerCase();
966
+ for (const [sample, val] of Object.entries(vals)) {
967
+ const origAlignment = val.data;
968
+ const alignment = origAlignment.toLowerCase();
969
+ // gaps
970
+ ctx.beginPath();
971
+ ctx.fillStyle = 'black';
972
+ const offset0 = (5 / 12) * h;
973
+ const h6 = h / 6;
974
+ const row = sampleToRowMap.get(sample);
975
+ if (row === undefined) {
976
+ throw new Error(`unknown sample encountered: ${sample}`);
977
+ }
978
+ const t = h * row;
979
+ for (let i = 0; i < alignment.length; i++) {
980
+ const l = leftPx + scale * i;
981
+ if (alignment[i] === '-') {
982
+ ctx.rect(l, offset0 + t, scale + correctionFactor, h6);
983
+ }
984
+ }
985
+ ctx.fill();
986
+ const offset = (1 / 4) * h;
987
+ const h2 = h / 2;
988
+ // matches
989
+ ctx.beginPath();
990
+ ctx.fillStyle = 'lightgrey';
991
+ for (let i = 0; i < alignment.length; i++) {
992
+ const c = alignment[i];
993
+ const l = leftPx + scale * i;
994
+ if (seq[i] === c && c !== '-') {
995
+ ctx.rect(l, offset + t, scale + correctionFactor, h2);
996
+ }
997
+ }
998
+ ctx.fill();
999
+ // mismatches
1000
+ for (let i = 0; i < alignment.length; i++) {
1001
+ const c = alignment[i];
1002
+ if (seq[i] !== c && c !== '-') {
1003
+ const l = leftPx + scale * i;
1004
+ ctx.fillStyle =
1005
+ colorForBase[c] ?? 'purple';
1006
+ ctx.fillRect(l, offset + t, scale + correctionFactor, h2);
1007
+ }
1008
+ }
1009
+ // font
1010
+ const charSize = { w: 10 };
1011
+ if (scale >= charSize.w) {
1012
+ for (let i = 0; i < alignment.length; i++) {
1013
+ const l = leftPx + scale * i;
1014
+ const offset = (scale - charSize.w) / 2 + 1;
1015
+ const c = alignment[i];
1016
+ if (seq[i] !== c && c !== '-') {
1017
+ ctx.fillStyle = contrastForBase[c] ?? 'black';
1018
+ ctx.fillText(origAlignment[i], l + offset, h2 + t + 3);
1019
+ }
1020
+ }
1021
+ }
1022
+ }
1023
+ }
1024
+ }
1025
+ class LinearMafRenderer extends pluggableElementTypes.FeatureRendererType {
1026
+ async render(renderProps) {
1027
+ const { regions, bpPerPx, samples, rowHeight } = renderProps;
1028
+ const [region] = regions;
1029
+ const height = samples.length * rowHeight;
1030
+ const width = (region.end - region.start) / bpPerPx;
1031
+ const features = await this.getFeatures(renderProps);
1032
+ const res = await util.renderToAbstractCanvas(width, height, renderProps, ctx => makeImageData({
1033
+ ctx,
1034
+ renderArgs: {
1035
+ ...renderProps,
1036
+ features,
1037
+ },
1038
+ }));
1039
+ const results = await super.render({
1040
+ ...renderProps,
1041
+ ...res,
1042
+ width,
1043
+ height,
1044
+ });
1045
+ return {
1046
+ ...results,
1047
+ ...res,
1048
+ width,
1049
+ height,
1050
+ };
1051
+ }
1052
+ }
1053
+
1054
+ const LinearMafRendering = mobxReact.observer(function (props) {
1055
+ return React.createElement(ui.PrerenderedCanvas, { ...props });
1056
+ });
1057
+
1058
+ function LinearMafRendererF(pluginManager) {
1059
+ pluginManager.addRendererType(() => new LinearMafRenderer({
1060
+ name: 'LinearMafRenderer',
1061
+ ReactComponent: LinearMafRendering,
1062
+ configSchema: configSchema$1,
1063
+ pluginManager,
1064
+ }));
1065
+ }
1066
+
1067
+ const configSchema = configuration.ConfigurationSchema('MafTabixAdapter', {
1068
+ /**
1069
+ * #slot
1070
+ */
1071
+ samples: {
1072
+ type: 'stringArray',
1073
+ defaultValue: [],
1074
+ },
1075
+ /**
1076
+ * #slot
1077
+ */
1078
+ bedGzLocation: {
1079
+ type: 'fileLocation',
1080
+ defaultValue: {
1081
+ uri: '/path/to/my.bed.gz.tbi',
1082
+ locationType: 'UriLocation',
1083
+ },
1084
+ },
1085
+ index: configuration.ConfigurationSchema('Index', {
1086
+ location: {
1087
+ type: 'fileLocation',
1088
+ defaultValue: {
1089
+ uri: '/path/to/my.bed.gz.tbi',
1090
+ },
1091
+ },
1092
+ indexType: {
1093
+ type: 'string',
1094
+ defaultValue: 'TBI',
1095
+ },
1096
+ }),
1097
+ }, { explicitlyTyped: true });
1098
+
1099
+ class BigMafAdapter extends BaseAdapter.BaseFeatureDataAdapter {
1100
+ setupP;
1101
+ async setup() {
1102
+ const config = this.config;
1103
+ if (!this.getSubAdapter) {
1104
+ throw new Error('no getSubAdapter available');
1105
+ }
1106
+ const adapter = await this.getSubAdapter({
1107
+ ...mobxStateTree.getSnapshot(config),
1108
+ type: 'BedTabixAdapter',
1109
+ });
1110
+ return {
1111
+ adapter: adapter.dataAdapter,
1112
+ };
1113
+ }
1114
+ async setupPre() {
1115
+ if (!this.setupP) {
1116
+ this.setupP = this.setup().catch(e => {
1117
+ this.setupP = undefined;
1118
+ throw e;
1119
+ });
1120
+ }
1121
+ return this.setupP;
1122
+ }
1123
+ async getRefNames() {
1124
+ const { adapter } = await this.setup();
1125
+ return adapter.getRefNames();
1126
+ }
1127
+ getFeatures(query) {
1128
+ return rxjs.ObservableCreate(async (observer) => {
1129
+ const { adapter } = await this.setup();
1130
+ const features = await firstValueFrom(adapter.getFeatures(query).pipe(toArray()));
1131
+ for (const feature of features) {
1132
+ const data = feature.get('field5').split(',');
1133
+ const alignments = {};
1134
+ const main = data[0];
1135
+ const aln = main.split(':')[5];
1136
+ const alns = data.map(elt => elt.split(':')[5]);
1137
+ const alns2 = data.map(() => '');
1138
+ // remove extraneous data in other alignments
1139
+ // reason being: cannot represent missing data in main species that are in others)
1140
+ for (let i = 0, o = 0; i < aln.length; i++, o++) {
1141
+ if (aln[i] !== '-') {
1142
+ for (let j = 0; j < data.length; j++) {
1143
+ alns2[j] += alns[j][i];
1144
+ }
1145
+ }
1146
+ }
1147
+ for (let j = 0; j < data.length; j++) {
1148
+ const elt = data[j];
1149
+ const ad = elt.split(':');
1150
+ const org = ad[0].split('.')[0];
1151
+ const chr = ad[0].split('.')[1];
1152
+ alignments[org] = {
1153
+ chr: chr,
1154
+ start: +ad[1],
1155
+ srcSize: +ad[2],
1156
+ strand: ad[3] === '-' ? -1 : 1,
1157
+ unknown: +ad[4],
1158
+ data: alns2[j],
1159
+ };
1160
+ }
1161
+ observer.next(new util.SimpleFeature({
1162
+ id: feature.id(),
1163
+ data: {
1164
+ start: feature.get('start'),
1165
+ end: feature.get('end'),
1166
+ refName: feature.get('refName'),
1167
+ name: feature.get('name'),
1168
+ score: feature.get('score'),
1169
+ alignments: alignments,
1170
+ seq: alns2[0],
1171
+ },
1172
+ }));
1173
+ }
1174
+ observer.complete();
1175
+ });
1176
+ }
1177
+ freeResources() { }
1178
+ }
1179
+
1180
+ function MafTabixAdapterF(pluginManager) {
1181
+ return pluginManager.addAdapterType(() => new pluggableElementTypes.AdapterType({
1182
+ name: 'MafTabixAdapter',
1183
+ AdapterClass: BigMafAdapter,
1184
+ configSchema,
1185
+ }));
1186
+ }
1187
+
1188
+ const useStyles = mui.makeStyles()(theme => ({
1189
+ textbox: {
1190
+ width: '100%',
1191
+ },
1192
+ paper: {
1193
+ margin: theme.spacing(),
1194
+ padding: theme.spacing(),
1195
+ },
1196
+ submit: {
1197
+ marginTop: 25,
1198
+ marginBottom: 100,
1199
+ display: 'block',
1200
+ },
1201
+ }));
1202
+ function MultiMAFWidget({ model }) {
1203
+ const { classes } = useStyles();
1204
+ const [samples, setSamples] = React.useState('');
1205
+ const [loc, setLoc] = React.useState();
1206
+ const [indexLoc, setIndexLoc] = React.useState();
1207
+ const [error, setError] = React.useState();
1208
+ const [trackName, setTrackName] = React.useState('MAF track');
1209
+ const [choice, setChoice] = React.useState('BigMafAdapter');
1210
+ const rootModel = mobxStateTree.getRoot(model);
1211
+ return (React.createElement(material.Paper, { className: classes.paper },
1212
+ React.createElement(material.Paper, null,
1213
+ error ? React.createElement(ui.ErrorMessage, { error: error }) : null,
1214
+ React.createElement(material.FormControl, null,
1215
+ React.createElement(material.FormLabel, null, "File type"),
1216
+ React.createElement(material.RadioGroup, { value: choice, onChange: event => setChoice(event.target.value) },
1217
+ React.createElement(material.FormControlLabel, { value: "BigMafAdapter", control: React.createElement(material.Radio, null), checked: choice === 'BigMafAdapter', label: "bigMaf" }),
1218
+ React.createElement(material.FormControlLabel, { value: "MafTabixAdapter", control: React.createElement(material.Radio, null), checked: choice === 'MafTabixAdapter', label: "mafTabix" }))),
1219
+ choice === 'BigMafAdapter' ? (React.createElement(ui.FileSelector, { location: loc, name: "Path to bigMaf", setLocation: arg => setLoc(arg), rootModel: rootModel })) : (React.createElement(React.Fragment, null,
1220
+ React.createElement(ui.FileSelector, { location: loc, name: "Path to MAF tabix", setLocation: arg => setLoc(arg), rootModel: rootModel }),
1221
+ React.createElement(ui.FileSelector, { location: indexLoc, name: "Path to MAF tabix index", setLocation: arg => setIndexLoc(arg), rootModel: rootModel })))),
1222
+ React.createElement(material.TextField, { multiline: true, rows: 10, value: samples, onChange: event => setSamples(event.target.value), placeholder: 'Enter sample names from the MAF file, one per line, or JSON formatted array of samples', variant: "outlined", fullWidth: true }),
1223
+ React.createElement(material.TextField, { value: trackName, onChange: event => setTrackName(event.target.value), helperText: "Track name" }),
1224
+ React.createElement(material.Button, { variant: "contained", className: classes.submit, onClick: () => {
1225
+ try {
1226
+ const session = util.getSession(model);
1227
+ let sampleNames = [];
1228
+ try {
1229
+ sampleNames = JSON.parse(samples);
1230
+ }
1231
+ catch (e) {
1232
+ sampleNames = samples.split(/\n|\r\n|\r/);
1233
+ }
1234
+ const trackId = [
1235
+ `${trackName.toLowerCase().replaceAll(' ', '_')}-${Date.now()}`,
1236
+ `${session.adminMode ? '' : '-sessionTrack'}`,
1237
+ ].join('');
1238
+ if (util.isSessionWithAddTracks(session)) {
1239
+ session.addTrackConf({
1240
+ trackId,
1241
+ type: 'MafTrack',
1242
+ name: trackName,
1243
+ assemblyNames: [model.assembly],
1244
+ adapter: choice === 'BigMafAdapter'
1245
+ ? {
1246
+ type: choice,
1247
+ bigBedLocation: loc,
1248
+ samples: sampleNames,
1249
+ }
1250
+ : {
1251
+ type: choice,
1252
+ bedGzLocation: loc,
1253
+ index: { location: indexLoc },
1254
+ samples: sampleNames,
1255
+ },
1256
+ });
1257
+ model.view?.showTrack(trackId);
1258
+ }
1259
+ model.clearData();
1260
+ if (util.isSessionModelWithWidgets(session)) {
1261
+ session.hideWidget(model);
1262
+ }
1263
+ }
1264
+ catch (e) {
1265
+ setError(e);
1266
+ }
1267
+ } }, "Submit")));
1268
+ }
1269
+
1270
+ function MafAddTrackWorkflowF(pluginManager) {
1271
+ pluginManager.addAddTrackWorkflowType(() => new pluggableElementTypes.AddTrackWorkflowType({
1272
+ name: 'MAF track',
1273
+ ReactComponent: MultiMAFWidget,
1274
+ stateModel: mobxStateTree.types.model({}),
1275
+ }));
1276
+ }
1277
+
1278
+ class MafViewerPlugin extends Plugin {
1279
+ name = 'MafViewerPlugin';
1280
+ version = version;
1281
+ install(pluginManager) {
1282
+ BigMafAdapterF(pluginManager);
1283
+ MafTrackF(pluginManager);
1284
+ LinearMafDisplayF(pluginManager);
1285
+ LinearMafRendererF(pluginManager);
1286
+ MafTabixAdapterF(pluginManager);
1287
+ MafAddTrackWorkflowF(pluginManager);
1288
+ }
1289
+ configure(pluginManager) { }
1290
+ }
1291
+
1292
+ async function renderSvg(self, opts, superRenderSvg) {
1293
+ const { offsetPx } = util.getContainingView(self);
1294
+ return (React.createElement(React.Fragment, null,
1295
+ React.createElement("g", { id: "snpcov" }, await superRenderSvg(opts)),
1296
+ React.createElement("g", { transform: `translate(${Math.max(-offsetPx, 0)})` },
1297
+ React.createElement(YScaleBars, { model: self, orientation: "left", exportSVG: true }))));
1298
+ }
1299
+
1300
+ var renderSvg$1 = {
1301
+ __proto__: null,
1302
+ renderSvg: renderSvg
1303
+ };
1304
+
1305
+ exports.default = MafViewerPlugin;
1306
+
1307
+ Object.defineProperty(exports, '__esModule', { value: true });
1308
+
1309
+ }));
1310
+ //# sourceMappingURL=jbrowse-plugin-mafviewer.umd.development.js.map