@jbrowse/plugin-gtf 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,1297 +0,0 @@
1
- import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
2
- import Plugin from '@jbrowse/core/Plugin';
3
- import { ConfigurationSchema, readConfObject } from '@jbrowse/core/configuration';
4
- import { getFileName } from '@jbrowse/core/util/tracks';
5
- import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
6
- import { openLocation } from '@jbrowse/core/util/io';
7
- import { ObservableCreate } from '@jbrowse/core/util/rxjs';
8
- import IntervalTree from '@flatten-js/interval-tree';
9
- import SimpleFeature from '@jbrowse/core/util/simpleFeature';
10
- import { unzip } from '@gmod/bgzf-filehandle';
11
- import gtf from '@gmod/gtf';
12
-
13
- function ownKeys(object, enumerableOnly) {
14
- var keys = Object.keys(object);
15
-
16
- if (Object.getOwnPropertySymbols) {
17
- var symbols = Object.getOwnPropertySymbols(object);
18
- enumerableOnly && (symbols = symbols.filter(function (sym) {
19
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
20
- })), keys.push.apply(keys, symbols);
21
- }
22
-
23
- return keys;
24
- }
25
-
26
- function _objectSpread2(target) {
27
- for (var i = 1; i < arguments.length; i++) {
28
- var source = null != arguments[i] ? arguments[i] : {};
29
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
30
- _defineProperty(target, key, source[key]);
31
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
32
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
33
- });
34
- }
35
-
36
- return target;
37
- }
38
-
39
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
40
- try {
41
- var info = gen[key](arg);
42
- var value = info.value;
43
- } catch (error) {
44
- reject(error);
45
- return;
46
- }
47
-
48
- if (info.done) {
49
- resolve(value);
50
- } else {
51
- Promise.resolve(value).then(_next, _throw);
52
- }
53
- }
54
-
55
- function _asyncToGenerator(fn) {
56
- return function () {
57
- var self = this,
58
- args = arguments;
59
- return new Promise(function (resolve, reject) {
60
- var gen = fn.apply(self, args);
61
-
62
- function _next(value) {
63
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
64
- }
65
-
66
- function _throw(err) {
67
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
68
- }
69
-
70
- _next(undefined);
71
- });
72
- };
73
- }
74
-
75
- function _classCallCheck(instance, Constructor) {
76
- if (!(instance instanceof Constructor)) {
77
- throw new TypeError("Cannot call a class as a function");
78
- }
79
- }
80
-
81
- function _defineProperties(target, props) {
82
- for (var i = 0; i < props.length; i++) {
83
- var descriptor = props[i];
84
- descriptor.enumerable = descriptor.enumerable || false;
85
- descriptor.configurable = true;
86
- if ("value" in descriptor) descriptor.writable = true;
87
- Object.defineProperty(target, descriptor.key, descriptor);
88
- }
89
- }
90
-
91
- function _createClass(Constructor, protoProps, staticProps) {
92
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
93
- if (staticProps) _defineProperties(Constructor, staticProps);
94
- Object.defineProperty(Constructor, "prototype", {
95
- writable: false
96
- });
97
- return Constructor;
98
- }
99
-
100
- function _defineProperty(obj, key, value) {
101
- if (key in obj) {
102
- Object.defineProperty(obj, key, {
103
- value: value,
104
- enumerable: true,
105
- configurable: true,
106
- writable: true
107
- });
108
- } else {
109
- obj[key] = value;
110
- }
111
-
112
- return obj;
113
- }
114
-
115
- function _inherits(subClass, superClass) {
116
- if (typeof superClass !== "function" && superClass !== null) {
117
- throw new TypeError("Super expression must either be null or a function");
118
- }
119
-
120
- subClass.prototype = Object.create(superClass && superClass.prototype, {
121
- constructor: {
122
- value: subClass,
123
- writable: true,
124
- configurable: true
125
- }
126
- });
127
- Object.defineProperty(subClass, "prototype", {
128
- writable: false
129
- });
130
- if (superClass) _setPrototypeOf(subClass, superClass);
131
- }
132
-
133
- function _getPrototypeOf(o) {
134
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
135
- return o.__proto__ || Object.getPrototypeOf(o);
136
- };
137
- return _getPrototypeOf(o);
138
- }
139
-
140
- function _setPrototypeOf(o, p) {
141
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
142
- o.__proto__ = p;
143
- return o;
144
- };
145
-
146
- return _setPrototypeOf(o, p);
147
- }
148
-
149
- function _isNativeReflectConstruct() {
150
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
151
- if (Reflect.construct.sham) return false;
152
- if (typeof Proxy === "function") return true;
153
-
154
- try {
155
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
156
- return true;
157
- } catch (e) {
158
- return false;
159
- }
160
- }
161
-
162
- function _assertThisInitialized(self) {
163
- if (self === void 0) {
164
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
165
- }
166
-
167
- return self;
168
- }
169
-
170
- function _possibleConstructorReturn(self, call) {
171
- if (call && (typeof call === "object" || typeof call === "function")) {
172
- return call;
173
- } else if (call !== void 0) {
174
- throw new TypeError("Derived constructors may only return object or undefined");
175
- }
176
-
177
- return _assertThisInitialized(self);
178
- }
179
-
180
- function _createSuper(Derived) {
181
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
182
-
183
- return function _createSuperInternal() {
184
- var Super = _getPrototypeOf(Derived),
185
- result;
186
-
187
- if (hasNativeReflectConstruct) {
188
- var NewTarget = _getPrototypeOf(this).constructor;
189
-
190
- result = Reflect.construct(Super, arguments, NewTarget);
191
- } else {
192
- result = Super.apply(this, arguments);
193
- }
194
-
195
- return _possibleConstructorReturn(this, result);
196
- };
197
- }
198
-
199
- var gtfAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('GtfAdapter', {
200
- gtfLocation: {
201
- type: 'fileLocation',
202
- defaultValue: {
203
- uri: '/path/to/my.gtf',
204
- locationType: 'UriLocation'
205
- }
206
- }
207
- }, {
208
- explicitlyTyped: true
209
- });
210
-
211
- var GtfPlugin = /*#__PURE__*/function (_Plugin) {
212
- _inherits(GtfPlugin, _Plugin);
213
-
214
- var _super = /*#__PURE__*/_createSuper(GtfPlugin);
215
-
216
- function GtfPlugin() {
217
- var _this;
218
-
219
- _classCallCheck(this, GtfPlugin);
220
-
221
- _this = _super.apply(this, arguments);
222
- _this.name = 'GTFPlugin';
223
- return _this;
224
- }
225
-
226
- _createClass(GtfPlugin, [{
227
- key: "install",
228
- value: function install(pluginManager) {
229
- pluginManager.addAdapterType(function () {
230
- return new AdapterType({
231
- name: 'GtfAdapter',
232
- configSchema: gtfAdapterConfigSchema,
233
- getAdapterClass: function getAdapterClass() {
234
- return Promise.resolve().then(function () { return GtfAdapter; }).then(function (r) {
235
- return r["default"];
236
- });
237
- }
238
- });
239
- });
240
- pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
241
- return function (file, index, adapterHint) {
242
- var regexGuess = /\.gtf(\.gz)?$/i;
243
- var adapterName = 'GtfAdapter';
244
- var fileName = getFileName(file);
245
- var obj = {
246
- type: adapterName,
247
- gtfLocation: file
248
- };
249
-
250
- if (regexGuess.test(fileName) && !adapterHint) {
251
- return obj;
252
- } else if (adapterHint === adapterName) {
253
- return obj;
254
- }
255
-
256
- return adapterGuesser(file, index, adapterHint);
257
- };
258
- });
259
- }
260
- }]);
261
-
262
- return GtfPlugin;
263
- }(Plugin);
264
-
265
- function createCommonjsModule(fn, module) {
266
- return module = { exports: {} }, fn(module, module.exports), module.exports;
267
- }
268
-
269
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
270
- /**
271
- * Copyright (c) 2014-present, Facebook, Inc.
272
- *
273
- * This source code is licensed under the MIT license found in the
274
- * LICENSE file in the root directory of this source tree.
275
- */
276
- var runtime = function (exports) {
277
-
278
- var Op = Object.prototype;
279
- var hasOwn = Op.hasOwnProperty;
280
- var undefined$1; // More compressible than void 0.
281
-
282
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
283
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
284
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
285
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
286
-
287
- function define(obj, key, value) {
288
- Object.defineProperty(obj, key, {
289
- value: value,
290
- enumerable: true,
291
- configurable: true,
292
- writable: true
293
- });
294
- return obj[key];
295
- }
296
-
297
- try {
298
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
299
- define({}, "");
300
- } catch (err) {
301
- define = function define(obj, key, value) {
302
- return obj[key] = value;
303
- };
304
- }
305
-
306
- function wrap(innerFn, outerFn, self, tryLocsList) {
307
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
308
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
309
- var generator = Object.create(protoGenerator.prototype);
310
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
311
- // .throw, and .return methods.
312
-
313
- generator._invoke = makeInvokeMethod(innerFn, self, context);
314
- return generator;
315
- }
316
-
317
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
318
- // record like context.tryEntries[i].completion. This interface could
319
- // have been (and was previously) designed to take a closure to be
320
- // invoked without arguments, but in all the cases we care about we
321
- // already have an existing method we want to call, so there's no need
322
- // to create a new function object. We can even get away with assuming
323
- // the method takes exactly one argument, since that happens to be true
324
- // in every case, so we don't have to touch the arguments object. The
325
- // only additional allocation required is the completion record, which
326
- // has a stable shape and so hopefully should be cheap to allocate.
327
-
328
- function tryCatch(fn, obj, arg) {
329
- try {
330
- return {
331
- type: "normal",
332
- arg: fn.call(obj, arg)
333
- };
334
- } catch (err) {
335
- return {
336
- type: "throw",
337
- arg: err
338
- };
339
- }
340
- }
341
-
342
- var GenStateSuspendedStart = "suspendedStart";
343
- var GenStateSuspendedYield = "suspendedYield";
344
- var GenStateExecuting = "executing";
345
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
346
- // breaking out of the dispatch switch statement.
347
-
348
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
349
- // .constructor.prototype properties for functions that return Generator
350
- // objects. For full spec compliance, you may wish to configure your
351
- // minifier not to mangle the names of these two functions.
352
-
353
- function Generator() {}
354
-
355
- function GeneratorFunction() {}
356
-
357
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
358
- // don't natively support it.
359
-
360
-
361
- var IteratorPrototype = {};
362
- define(IteratorPrototype, iteratorSymbol, function () {
363
- return this;
364
- });
365
- var getProto = Object.getPrototypeOf;
366
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
367
-
368
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
369
- // This environment has a native %IteratorPrototype%; use it instead
370
- // of the polyfill.
371
- IteratorPrototype = NativeIteratorPrototype;
372
- }
373
-
374
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
375
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
376
- define(Gp, "constructor", GeneratorFunctionPrototype);
377
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
378
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
379
- // Iterator interface in terms of a single ._invoke method.
380
-
381
- function defineIteratorMethods(prototype) {
382
- ["next", "throw", "return"].forEach(function (method) {
383
- define(prototype, method, function (arg) {
384
- return this._invoke(method, arg);
385
- });
386
- });
387
- }
388
-
389
- exports.isGeneratorFunction = function (genFun) {
390
- var ctor = typeof genFun === "function" && genFun.constructor;
391
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
392
- // do is to check its .name property.
393
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
394
- };
395
-
396
- exports.mark = function (genFun) {
397
- if (Object.setPrototypeOf) {
398
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
399
- } else {
400
- genFun.__proto__ = GeneratorFunctionPrototype;
401
- define(genFun, toStringTagSymbol, "GeneratorFunction");
402
- }
403
-
404
- genFun.prototype = Object.create(Gp);
405
- return genFun;
406
- }; // Within the body of any async function, `await x` is transformed to
407
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
408
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
409
- // meant to be awaited.
410
-
411
-
412
- exports.awrap = function (arg) {
413
- return {
414
- __await: arg
415
- };
416
- };
417
-
418
- function AsyncIterator(generator, PromiseImpl) {
419
- function invoke(method, arg, resolve, reject) {
420
- var record = tryCatch(generator[method], generator, arg);
421
-
422
- if (record.type === "throw") {
423
- reject(record.arg);
424
- } else {
425
- var result = record.arg;
426
- var value = result.value;
427
-
428
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
429
- return PromiseImpl.resolve(value.__await).then(function (value) {
430
- invoke("next", value, resolve, reject);
431
- }, function (err) {
432
- invoke("throw", err, resolve, reject);
433
- });
434
- }
435
-
436
- return PromiseImpl.resolve(value).then(function (unwrapped) {
437
- // When a yielded Promise is resolved, its final value becomes
438
- // the .value of the Promise<{value,done}> result for the
439
- // current iteration.
440
- result.value = unwrapped;
441
- resolve(result);
442
- }, function (error) {
443
- // If a rejected Promise was yielded, throw the rejection back
444
- // into the async generator function so it can be handled there.
445
- return invoke("throw", error, resolve, reject);
446
- });
447
- }
448
- }
449
-
450
- var previousPromise;
451
-
452
- function enqueue(method, arg) {
453
- function callInvokeWithMethodAndArg() {
454
- return new PromiseImpl(function (resolve, reject) {
455
- invoke(method, arg, resolve, reject);
456
- });
457
- }
458
-
459
- return previousPromise = // If enqueue has been called before, then we want to wait until
460
- // all previous Promises have been resolved before calling invoke,
461
- // so that results are always delivered in the correct order. If
462
- // enqueue has not been called before, then it is important to
463
- // call invoke immediately, without waiting on a callback to fire,
464
- // so that the async generator function has the opportunity to do
465
- // any necessary setup in a predictable way. This predictability
466
- // is why the Promise constructor synchronously invokes its
467
- // executor callback, and why async functions synchronously
468
- // execute code before the first await. Since we implement simple
469
- // async functions in terms of async generators, it is especially
470
- // important to get this right, even though it requires care.
471
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
472
- // invocations of the iterator.
473
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
474
- } // Define the unified helper method that is used to implement .next,
475
- // .throw, and .return (see defineIteratorMethods).
476
-
477
-
478
- this._invoke = enqueue;
479
- }
480
-
481
- defineIteratorMethods(AsyncIterator.prototype);
482
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
483
- return this;
484
- });
485
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
486
- // AsyncIterator objects; they just return a Promise for the value of
487
- // the final result produced by the iterator.
488
-
489
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
490
- if (PromiseImpl === void 0) PromiseImpl = Promise;
491
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
492
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
493
- : iter.next().then(function (result) {
494
- return result.done ? result.value : iter.next();
495
- });
496
- };
497
-
498
- function makeInvokeMethod(innerFn, self, context) {
499
- var state = GenStateSuspendedStart;
500
- return function invoke(method, arg) {
501
- if (state === GenStateExecuting) {
502
- throw new Error("Generator is already running");
503
- }
504
-
505
- if (state === GenStateCompleted) {
506
- if (method === "throw") {
507
- throw arg;
508
- } // Be forgiving, per 25.3.3.3.3 of the spec:
509
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
510
-
511
-
512
- return doneResult();
513
- }
514
-
515
- context.method = method;
516
- context.arg = arg;
517
-
518
- while (true) {
519
- var delegate = context.delegate;
520
-
521
- if (delegate) {
522
- var delegateResult = maybeInvokeDelegate(delegate, context);
523
-
524
- if (delegateResult) {
525
- if (delegateResult === ContinueSentinel) continue;
526
- return delegateResult;
527
- }
528
- }
529
-
530
- if (context.method === "next") {
531
- // Setting context._sent for legacy support of Babel's
532
- // function.sent implementation.
533
- context.sent = context._sent = context.arg;
534
- } else if (context.method === "throw") {
535
- if (state === GenStateSuspendedStart) {
536
- state = GenStateCompleted;
537
- throw context.arg;
538
- }
539
-
540
- context.dispatchException(context.arg);
541
- } else if (context.method === "return") {
542
- context.abrupt("return", context.arg);
543
- }
544
-
545
- state = GenStateExecuting;
546
- var record = tryCatch(innerFn, self, context);
547
-
548
- if (record.type === "normal") {
549
- // If an exception is thrown from innerFn, we leave state ===
550
- // GenStateExecuting and loop back for another invocation.
551
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
552
-
553
- if (record.arg === ContinueSentinel) {
554
- continue;
555
- }
556
-
557
- return {
558
- value: record.arg,
559
- done: context.done
560
- };
561
- } else if (record.type === "throw") {
562
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
563
- // context.dispatchException(context.arg) call above.
564
-
565
- context.method = "throw";
566
- context.arg = record.arg;
567
- }
568
- }
569
- };
570
- } // Call delegate.iterator[context.method](context.arg) and handle the
571
- // result, either by returning a { value, done } result from the
572
- // delegate iterator, or by modifying context.method and context.arg,
573
- // setting context.delegate to null, and returning the ContinueSentinel.
574
-
575
-
576
- function maybeInvokeDelegate(delegate, context) {
577
- var method = delegate.iterator[context.method];
578
-
579
- if (method === undefined$1) {
580
- // A .throw or .return when the delegate iterator has no .throw
581
- // method always terminates the yield* loop.
582
- context.delegate = null;
583
-
584
- if (context.method === "throw") {
585
- // Note: ["return"] must be used for ES3 parsing compatibility.
586
- if (delegate.iterator["return"]) {
587
- // If the delegate iterator has a return method, give it a
588
- // chance to clean up.
589
- context.method = "return";
590
- context.arg = undefined$1;
591
- maybeInvokeDelegate(delegate, context);
592
-
593
- if (context.method === "throw") {
594
- // If maybeInvokeDelegate(context) changed context.method from
595
- // "return" to "throw", let that override the TypeError below.
596
- return ContinueSentinel;
597
- }
598
- }
599
-
600
- context.method = "throw";
601
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
602
- }
603
-
604
- return ContinueSentinel;
605
- }
606
-
607
- var record = tryCatch(method, delegate.iterator, context.arg);
608
-
609
- if (record.type === "throw") {
610
- context.method = "throw";
611
- context.arg = record.arg;
612
- context.delegate = null;
613
- return ContinueSentinel;
614
- }
615
-
616
- var info = record.arg;
617
-
618
- if (!info) {
619
- context.method = "throw";
620
- context.arg = new TypeError("iterator result is not an object");
621
- context.delegate = null;
622
- return ContinueSentinel;
623
- }
624
-
625
- if (info.done) {
626
- // Assign the result of the finished delegate to the temporary
627
- // variable specified by delegate.resultName (see delegateYield).
628
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
629
-
630
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
631
- // exception, let the outer generator proceed normally. If
632
- // context.method was "next", forget context.arg since it has been
633
- // "consumed" by the delegate iterator. If context.method was
634
- // "return", allow the original .return call to continue in the
635
- // outer generator.
636
-
637
- if (context.method !== "return") {
638
- context.method = "next";
639
- context.arg = undefined$1;
640
- }
641
- } else {
642
- // Re-yield the result returned by the delegate method.
643
- return info;
644
- } // The delegate iterator is finished, so forget it and continue with
645
- // the outer generator.
646
-
647
-
648
- context.delegate = null;
649
- return ContinueSentinel;
650
- } // Define Generator.prototype.{next,throw,return} in terms of the
651
- // unified ._invoke helper method.
652
-
653
-
654
- defineIteratorMethods(Gp);
655
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
656
- // @@iterator function is called on it. Some browsers' implementations of the
657
- // iterator prototype chain incorrectly implement this, causing the Generator
658
- // object to not be returned from this call. This ensures that doesn't happen.
659
- // See https://github.com/facebook/regenerator/issues/274 for more details.
660
-
661
- define(Gp, iteratorSymbol, function () {
662
- return this;
663
- });
664
- define(Gp, "toString", function () {
665
- return "[object Generator]";
666
- });
667
-
668
- function pushTryEntry(locs) {
669
- var entry = {
670
- tryLoc: locs[0]
671
- };
672
-
673
- if (1 in locs) {
674
- entry.catchLoc = locs[1];
675
- }
676
-
677
- if (2 in locs) {
678
- entry.finallyLoc = locs[2];
679
- entry.afterLoc = locs[3];
680
- }
681
-
682
- this.tryEntries.push(entry);
683
- }
684
-
685
- function resetTryEntry(entry) {
686
- var record = entry.completion || {};
687
- record.type = "normal";
688
- delete record.arg;
689
- entry.completion = record;
690
- }
691
-
692
- function Context(tryLocsList) {
693
- // The root entry object (effectively a try statement without a catch
694
- // or a finally block) gives us a place to store values thrown from
695
- // locations where there is no enclosing try statement.
696
- this.tryEntries = [{
697
- tryLoc: "root"
698
- }];
699
- tryLocsList.forEach(pushTryEntry, this);
700
- this.reset(true);
701
- }
702
-
703
- exports.keys = function (object) {
704
- var keys = [];
705
-
706
- for (var key in object) {
707
- keys.push(key);
708
- }
709
-
710
- keys.reverse(); // Rather than returning an object with a next method, we keep
711
- // things simple and return the next function itself.
712
-
713
- return function next() {
714
- while (keys.length) {
715
- var key = keys.pop();
716
-
717
- if (key in object) {
718
- next.value = key;
719
- next.done = false;
720
- return next;
721
- }
722
- } // To avoid creating an additional object, we just hang the .value
723
- // and .done properties off the next function object itself. This
724
- // also ensures that the minifier will not anonymize the function.
725
-
726
-
727
- next.done = true;
728
- return next;
729
- };
730
- };
731
-
732
- function values(iterable) {
733
- if (iterable) {
734
- var iteratorMethod = iterable[iteratorSymbol];
735
-
736
- if (iteratorMethod) {
737
- return iteratorMethod.call(iterable);
738
- }
739
-
740
- if (typeof iterable.next === "function") {
741
- return iterable;
742
- }
743
-
744
- if (!isNaN(iterable.length)) {
745
- var i = -1,
746
- next = function next() {
747
- while (++i < iterable.length) {
748
- if (hasOwn.call(iterable, i)) {
749
- next.value = iterable[i];
750
- next.done = false;
751
- return next;
752
- }
753
- }
754
-
755
- next.value = undefined$1;
756
- next.done = true;
757
- return next;
758
- };
759
-
760
- return next.next = next;
761
- }
762
- } // Return an iterator with no values.
763
-
764
-
765
- return {
766
- next: doneResult
767
- };
768
- }
769
-
770
- exports.values = values;
771
-
772
- function doneResult() {
773
- return {
774
- value: undefined$1,
775
- done: true
776
- };
777
- }
778
-
779
- Context.prototype = {
780
- constructor: Context,
781
- reset: function reset(skipTempReset) {
782
- this.prev = 0;
783
- this.next = 0; // Resetting context._sent for legacy support of Babel's
784
- // function.sent implementation.
785
-
786
- this.sent = this._sent = undefined$1;
787
- this.done = false;
788
- this.delegate = null;
789
- this.method = "next";
790
- this.arg = undefined$1;
791
- this.tryEntries.forEach(resetTryEntry);
792
-
793
- if (!skipTempReset) {
794
- for (var name in this) {
795
- // Not sure about the optimal order of these conditions:
796
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
797
- this[name] = undefined$1;
798
- }
799
- }
800
- }
801
- },
802
- stop: function stop() {
803
- this.done = true;
804
- var rootEntry = this.tryEntries[0];
805
- var rootRecord = rootEntry.completion;
806
-
807
- if (rootRecord.type === "throw") {
808
- throw rootRecord.arg;
809
- }
810
-
811
- return this.rval;
812
- },
813
- dispatchException: function dispatchException(exception) {
814
- if (this.done) {
815
- throw exception;
816
- }
817
-
818
- var context = this;
819
-
820
- function handle(loc, caught) {
821
- record.type = "throw";
822
- record.arg = exception;
823
- context.next = loc;
824
-
825
- if (caught) {
826
- // If the dispatched exception was caught by a catch block,
827
- // then let that catch block handle the exception normally.
828
- context.method = "next";
829
- context.arg = undefined$1;
830
- }
831
-
832
- return !!caught;
833
- }
834
-
835
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
836
- var entry = this.tryEntries[i];
837
- var record = entry.completion;
838
-
839
- if (entry.tryLoc === "root") {
840
- // Exception thrown outside of any try block that could handle
841
- // it, so set the completion value of the entire function to
842
- // throw the exception.
843
- return handle("end");
844
- }
845
-
846
- if (entry.tryLoc <= this.prev) {
847
- var hasCatch = hasOwn.call(entry, "catchLoc");
848
- var hasFinally = hasOwn.call(entry, "finallyLoc");
849
-
850
- if (hasCatch && hasFinally) {
851
- if (this.prev < entry.catchLoc) {
852
- return handle(entry.catchLoc, true);
853
- } else if (this.prev < entry.finallyLoc) {
854
- return handle(entry.finallyLoc);
855
- }
856
- } else if (hasCatch) {
857
- if (this.prev < entry.catchLoc) {
858
- return handle(entry.catchLoc, true);
859
- }
860
- } else if (hasFinally) {
861
- if (this.prev < entry.finallyLoc) {
862
- return handle(entry.finallyLoc);
863
- }
864
- } else {
865
- throw new Error("try statement without catch or finally");
866
- }
867
- }
868
- }
869
- },
870
- abrupt: function abrupt(type, arg) {
871
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
872
- var entry = this.tryEntries[i];
873
-
874
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
875
- var finallyEntry = entry;
876
- break;
877
- }
878
- }
879
-
880
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
881
- // Ignore the finally entry if control is not jumping to a
882
- // location outside the try/catch block.
883
- finallyEntry = null;
884
- }
885
-
886
- var record = finallyEntry ? finallyEntry.completion : {};
887
- record.type = type;
888
- record.arg = arg;
889
-
890
- if (finallyEntry) {
891
- this.method = "next";
892
- this.next = finallyEntry.finallyLoc;
893
- return ContinueSentinel;
894
- }
895
-
896
- return this.complete(record);
897
- },
898
- complete: function complete(record, afterLoc) {
899
- if (record.type === "throw") {
900
- throw record.arg;
901
- }
902
-
903
- if (record.type === "break" || record.type === "continue") {
904
- this.next = record.arg;
905
- } else if (record.type === "return") {
906
- this.rval = this.arg = record.arg;
907
- this.method = "return";
908
- this.next = "end";
909
- } else if (record.type === "normal" && afterLoc) {
910
- this.next = afterLoc;
911
- }
912
-
913
- return ContinueSentinel;
914
- },
915
- finish: function finish(finallyLoc) {
916
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
917
- var entry = this.tryEntries[i];
918
-
919
- if (entry.finallyLoc === finallyLoc) {
920
- this.complete(entry.completion, entry.afterLoc);
921
- resetTryEntry(entry);
922
- return ContinueSentinel;
923
- }
924
- }
925
- },
926
- "catch": function _catch(tryLoc) {
927
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
928
- var entry = this.tryEntries[i];
929
-
930
- if (entry.tryLoc === tryLoc) {
931
- var record = entry.completion;
932
-
933
- if (record.type === "throw") {
934
- var thrown = record.arg;
935
- resetTryEntry(entry);
936
- }
937
-
938
- return thrown;
939
- }
940
- } // The context.catch method must only be called with a location
941
- // argument that corresponds to a known catch block.
942
-
943
-
944
- throw new Error("illegal catch attempt");
945
- },
946
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
947
- this.delegate = {
948
- iterator: values(iterable),
949
- resultName: resultName,
950
- nextLoc: nextLoc
951
- };
952
-
953
- if (this.method === "next") {
954
- // Deliberately forget the last sent value so that we don't
955
- // accidentally pass it on to the delegate.
956
- this.arg = undefined$1;
957
- }
958
-
959
- return ContinueSentinel;
960
- }
961
- }; // Regardless of whether this script is executing as a CommonJS module
962
- // or not, return the runtime object so that we can declare the variable
963
- // regeneratorRuntime in the outer scope, which allows this module to be
964
- // injected easily by `bin/regenerator --include-runtime script.js`.
965
-
966
- return exports;
967
- }( // If this script is executing as a CommonJS module, use module.exports
968
- // as the regeneratorRuntime namespace. Otherwise create a new empty
969
- // object. Either way, the resulting object will be used to initialize
970
- // the regeneratorRuntime variable at the top of this file.
971
- module.exports );
972
-
973
- try {
974
- regeneratorRuntime = runtime;
975
- } catch (accidentalStrictMode) {
976
- // This module should not be running in strict mode, so the above
977
- // assignment should always work unless something is misconfigured. Just
978
- // in case runtime.js accidentally runs in strict mode, in modern engines
979
- // we can explicitly access globalThis. In older engines we can escape
980
- // strict mode using a global Function call. This could conceivably fail
981
- // if a Content Security Policy forbids using Function, but in that case
982
- // the proper solution is to fix the accidental strict mode problem. If
983
- // you've misconfigured your bundler to force strict mode and applied a
984
- // CSP to forbid Function, and you're not willing to fix either of those
985
- // problems, please detail your unique predicament in a GitHub issue.
986
- if (typeof globalThis === "object") {
987
- globalThis.regeneratorRuntime = runtime;
988
- } else {
989
- Function("r", "regeneratorRuntime = r")(runtime);
990
- }
991
- }
992
- });
993
-
994
- function featureData(data) {
995
- var f = _objectSpread2({}, data);
996
-
997
- f.start -= 1; // convert to interbase
998
-
999
- f.strand = {
1000
- '+': 1,
1001
- '-': -1,
1002
- '.': 0,
1003
- '?': undefined
1004
- }[data.strand]; // convert strand
1005
-
1006
- f.phase = Number(data.frame);
1007
- f.refName = data.seq_name;
1008
-
1009
- if (data.score === null) {
1010
- delete f.score;
1011
- }
1012
-
1013
- if (data.frame === null) {
1014
- delete f.score;
1015
- }
1016
-
1017
- var defaultFields = ['start', 'end', 'seq_name', 'score', 'featureType', 'source', 'frame', 'strand'];
1018
- Object.keys(data.attributes).forEach(function (a) {
1019
- var b = a.toLowerCase();
1020
-
1021
- if (defaultFields.includes(b)) {
1022
- // add "suffix" to tag name if it already exists
1023
- // reproduces behavior of NCList
1024
- b += '2';
1025
- }
1026
-
1027
- if (data.attributes[a] !== null) {
1028
- var attr = data.attributes[a];
1029
-
1030
- if (Array.isArray(attr) && attr.length === 1) {
1031
- // gtf uses double quotes for text values in the attributes column, remove them
1032
- var formattedAttr = attr[0].replace(/^"|"$/g, '');
1033
- attr = formattedAttr;
1034
- }
1035
-
1036
- f[b] = attr;
1037
- }
1038
- });
1039
- f.refName = f.seq_name;
1040
- f.type = f.featureType; // the SimpleFeature constructor takes care of recursively inflating subfeatures
1041
-
1042
- if (data.child_features && data.child_features.length) {
1043
- f.subfeatures = data.child_features.map(function (childLocs) {
1044
- return childLocs.map(function (childLoc) {
1045
- return featureData(childLoc);
1046
- });
1047
- }).flat();
1048
- }
1049
-
1050
- delete f.child_features;
1051
- delete f.data;
1052
- delete f.derived_features; // eslint-disable-next-line no-underscore-dangle
1053
-
1054
- delete f._linehash;
1055
- delete f.attributes;
1056
- delete f.seq_name;
1057
- delete f.featureType;
1058
- delete f.frame;
1059
-
1060
- if (f.transcript_id) {
1061
- f.name = f.transcript_id;
1062
- }
1063
-
1064
- return f;
1065
- }
1066
-
1067
- function isGzip(buf) {
1068
- return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
1069
- }
1070
-
1071
- var _default = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1072
- _inherits(_default, _BaseFeatureDataAdapt);
1073
-
1074
- var _super = /*#__PURE__*/_createSuper(_default);
1075
-
1076
- function _default() {
1077
- _classCallCheck(this, _default);
1078
-
1079
- return _super.apply(this, arguments);
1080
- }
1081
-
1082
- _createClass(_default, [{
1083
- key: "loadDataP",
1084
- value: function () {
1085
- var _loadDataP = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1086
- var _this = this;
1087
-
1088
- var buffer, buf, data, feats, intervalTree;
1089
- return runtime_1.wrap(function _callee$(_context) {
1090
- while (1) {
1091
- switch (_context.prev = _context.next) {
1092
- case 0:
1093
- _context.next = 2;
1094
- return openLocation(readConfObject(this.config, 'gtfLocation'), this.pluginManager).readFile();
1095
-
1096
- case 2:
1097
- buffer = _context.sent;
1098
-
1099
- if (!isGzip(buffer)) {
1100
- _context.next = 9;
1101
- break;
1102
- }
1103
-
1104
- _context.next = 6;
1105
- return unzip(buffer);
1106
-
1107
- case 6:
1108
- _context.t0 = _context.sent;
1109
- _context.next = 10;
1110
- break;
1111
-
1112
- case 9:
1113
- _context.t0 = buffer;
1114
-
1115
- case 10:
1116
- buf = _context.t0;
1117
-
1118
- if (!(buf.length > 536870888)) {
1119
- _context.next = 13;
1120
- break;
1121
- }
1122
-
1123
- throw new Error('Data exceeds maximum string length (512MB)');
1124
-
1125
- case 13:
1126
- data = new TextDecoder('utf8', {
1127
- fatal: true
1128
- }).decode(buf);
1129
- feats = gtf.parseStringSync(data, {
1130
- parseFeatures: true,
1131
- parseComments: false,
1132
- parseDirectives: false,
1133
- parseSequences: false
1134
- });
1135
- intervalTree = feats.flat().map(function (f, i) {
1136
- return new SimpleFeature({
1137
- data: featureData(f),
1138
- id: "".concat(_this.id, "-offset-").concat(i)
1139
- });
1140
- }).reduce(function (acc, obj) {
1141
- var key = obj.get('refName');
1142
-
1143
- if (!acc[key]) {
1144
- acc[key] = new IntervalTree();
1145
- }
1146
-
1147
- acc[key].insert([obj.get('start'), obj.get('end')], obj);
1148
- return acc;
1149
- }, {});
1150
- return _context.abrupt("return", {
1151
- intervalTree: intervalTree
1152
- });
1153
-
1154
- case 17:
1155
- case "end":
1156
- return _context.stop();
1157
- }
1158
- }
1159
- }, _callee, this);
1160
- }));
1161
-
1162
- function loadDataP() {
1163
- return _loadDataP.apply(this, arguments);
1164
- }
1165
-
1166
- return loadDataP;
1167
- }()
1168
- }, {
1169
- key: "loadData",
1170
- value: function () {
1171
- var _loadData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1172
- var _this2 = this;
1173
-
1174
- return runtime_1.wrap(function _callee2$(_context2) {
1175
- while (1) {
1176
- switch (_context2.prev = _context2.next) {
1177
- case 0:
1178
- if (!this.gtfFeatures) {
1179
- this.gtfFeatures = this.loadDataP()["catch"](function (e) {
1180
- _this2.gtfFeatures = undefined;
1181
- throw e;
1182
- });
1183
- }
1184
-
1185
- return _context2.abrupt("return", this.gtfFeatures);
1186
-
1187
- case 2:
1188
- case "end":
1189
- return _context2.stop();
1190
- }
1191
- }
1192
- }, _callee2, this);
1193
- }));
1194
-
1195
- function loadData() {
1196
- return _loadData.apply(this, arguments);
1197
- }
1198
-
1199
- return loadData;
1200
- }()
1201
- }, {
1202
- key: "getRefNames",
1203
- value: function () {
1204
- var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
1205
- var _yield$this$loadData,
1206
- intervalTree;
1207
-
1208
- return runtime_1.wrap(function _callee3$(_context3) {
1209
- while (1) {
1210
- switch (_context3.prev = _context3.next) {
1211
- case 0:
1212
- _context3.next = 3;
1213
- return this.loadData();
1214
-
1215
- case 3:
1216
- _yield$this$loadData = _context3.sent;
1217
- intervalTree = _yield$this$loadData.intervalTree;
1218
- return _context3.abrupt("return", Object.keys(intervalTree));
1219
-
1220
- case 6:
1221
- case "end":
1222
- return _context3.stop();
1223
- }
1224
- }
1225
- }, _callee3, this);
1226
- }));
1227
-
1228
- function getRefNames() {
1229
- return _getRefNames.apply(this, arguments);
1230
- }
1231
-
1232
- return getRefNames;
1233
- }()
1234
- }, {
1235
- key: "getFeatures",
1236
- value: function getFeatures(query) {
1237
- var _this3 = this;
1238
-
1239
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1240
- return ObservableCreate( /*#__PURE__*/function () {
1241
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(observer) {
1242
- var _intervalTree$refName, start, end, refName, _yield$_this3$loadDat, intervalTree;
1243
-
1244
- return runtime_1.wrap(function _callee4$(_context4) {
1245
- while (1) {
1246
- switch (_context4.prev = _context4.next) {
1247
- case 0:
1248
- _context4.prev = 0;
1249
- start = query.start, end = query.end, refName = query.refName;
1250
- _context4.next = 4;
1251
- return _this3.loadData();
1252
-
1253
- case 4:
1254
- _yield$_this3$loadDat = _context4.sent;
1255
- intervalTree = _yield$_this3$loadDat.intervalTree;
1256
- (_intervalTree$refName = intervalTree[refName]) === null || _intervalTree$refName === void 0 ? void 0 : _intervalTree$refName.search([start, end]).forEach(function (f) {
1257
- return observer.next(f);
1258
- });
1259
- observer.complete();
1260
- _context4.next = 13;
1261
- break;
1262
-
1263
- case 10:
1264
- _context4.prev = 10;
1265
- _context4.t0 = _context4["catch"](0);
1266
- observer.error(_context4.t0);
1267
-
1268
- case 13:
1269
- case "end":
1270
- return _context4.stop();
1271
- }
1272
- }
1273
- }, _callee4, null, [[0, 10]]);
1274
- }));
1275
-
1276
- return function (_x) {
1277
- return _ref.apply(this, arguments);
1278
- };
1279
- }(), opts.signal);
1280
- }
1281
- }, {
1282
- key: "freeResources",
1283
- value: function
1284
- /* { region } */
1285
- freeResources() {}
1286
- }]);
1287
-
1288
- return _default;
1289
- }(BaseFeatureDataAdapter);
1290
-
1291
- var GtfAdapter = {
1292
- __proto__: null,
1293
- 'default': _default
1294
- };
1295
-
1296
- export default GtfPlugin;
1297
- //# sourceMappingURL=plugin-gtf.esm.js.map