@jbrowse/plugin-gtf 1.6.9 → 1.7.3

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