@jbrowse/plugin-gff3 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,1807 +0,0 @@
1
- import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
2
- import Plugin from '@jbrowse/core/Plugin';
3
- import { types } from 'mobx-state-tree';
4
- import { ConfigurationSchema, readConfObject } from '@jbrowse/core/configuration';
5
- import { getFileName, makeIndex, makeIndexType } from '@jbrowse/core/util/tracks';
6
- import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
7
- import { doesIntersect2 } from '@jbrowse/core/util/range';
8
- import { openLocation } from '@jbrowse/core/util/io';
9
- import { ObservableCreate } from '@jbrowse/core/util/rxjs';
10
- import SimpleFeature from '@jbrowse/core/util/simpleFeature';
11
- import { TabixIndexedFile } from '@gmod/tabix';
12
- import gff from '@gmod/gff';
13
- import IntervalTree from '@flatten-js/interval-tree';
14
- import { unzip } from '@gmod/bgzf-filehandle';
15
-
16
- function ownKeys(object, enumerableOnly) {
17
- var keys = Object.keys(object);
18
-
19
- if (Object.getOwnPropertySymbols) {
20
- var symbols = Object.getOwnPropertySymbols(object);
21
- enumerableOnly && (symbols = symbols.filter(function (sym) {
22
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
23
- })), keys.push.apply(keys, symbols);
24
- }
25
-
26
- return keys;
27
- }
28
-
29
- function _objectSpread2(target) {
30
- for (var i = 1; i < arguments.length; i++) {
31
- var source = null != arguments[i] ? arguments[i] : {};
32
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
33
- _defineProperty(target, key, source[key]);
34
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
35
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
36
- });
37
- }
38
-
39
- return target;
40
- }
41
-
42
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
43
- try {
44
- var info = gen[key](arg);
45
- var value = info.value;
46
- } catch (error) {
47
- reject(error);
48
- return;
49
- }
50
-
51
- if (info.done) {
52
- resolve(value);
53
- } else {
54
- Promise.resolve(value).then(_next, _throw);
55
- }
56
- }
57
-
58
- function _asyncToGenerator(fn) {
59
- return function () {
60
- var self = this,
61
- args = arguments;
62
- return new Promise(function (resolve, reject) {
63
- var gen = fn.apply(self, args);
64
-
65
- function _next(value) {
66
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
67
- }
68
-
69
- function _throw(err) {
70
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
71
- }
72
-
73
- _next(undefined);
74
- });
75
- };
76
- }
77
-
78
- function _classCallCheck(instance, Constructor) {
79
- if (!(instance instanceof Constructor)) {
80
- throw new TypeError("Cannot call a class as a function");
81
- }
82
- }
83
-
84
- function _defineProperties(target, props) {
85
- for (var i = 0; i < props.length; i++) {
86
- var descriptor = props[i];
87
- descriptor.enumerable = descriptor.enumerable || false;
88
- descriptor.configurable = true;
89
- if ("value" in descriptor) descriptor.writable = true;
90
- Object.defineProperty(target, descriptor.key, descriptor);
91
- }
92
- }
93
-
94
- function _createClass(Constructor, protoProps, staticProps) {
95
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
96
- if (staticProps) _defineProperties(Constructor, staticProps);
97
- Object.defineProperty(Constructor, "prototype", {
98
- writable: false
99
- });
100
- return Constructor;
101
- }
102
-
103
- function _defineProperty(obj, key, value) {
104
- if (key in obj) {
105
- Object.defineProperty(obj, key, {
106
- value: value,
107
- enumerable: true,
108
- configurable: true,
109
- writable: true
110
- });
111
- } else {
112
- obj[key] = value;
113
- }
114
-
115
- return obj;
116
- }
117
-
118
- function _inherits(subClass, superClass) {
119
- if (typeof superClass !== "function" && superClass !== null) {
120
- throw new TypeError("Super expression must either be null or a function");
121
- }
122
-
123
- subClass.prototype = Object.create(superClass && superClass.prototype, {
124
- constructor: {
125
- value: subClass,
126
- writable: true,
127
- configurable: true
128
- }
129
- });
130
- Object.defineProperty(subClass, "prototype", {
131
- writable: false
132
- });
133
- if (superClass) _setPrototypeOf(subClass, superClass);
134
- }
135
-
136
- function _getPrototypeOf(o) {
137
- _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
138
- return o.__proto__ || Object.getPrototypeOf(o);
139
- };
140
- return _getPrototypeOf(o);
141
- }
142
-
143
- function _setPrototypeOf(o, p) {
144
- _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
145
- o.__proto__ = p;
146
- return o;
147
- };
148
-
149
- return _setPrototypeOf(o, p);
150
- }
151
-
152
- function _isNativeReflectConstruct() {
153
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
154
- if (Reflect.construct.sham) return false;
155
- if (typeof Proxy === "function") return true;
156
-
157
- try {
158
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
159
- return true;
160
- } catch (e) {
161
- return false;
162
- }
163
- }
164
-
165
- function _assertThisInitialized(self) {
166
- if (self === void 0) {
167
- throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
168
- }
169
-
170
- return self;
171
- }
172
-
173
- function _possibleConstructorReturn(self, call) {
174
- if (call && (typeof call === "object" || typeof call === "function")) {
175
- return call;
176
- } else if (call !== void 0) {
177
- throw new TypeError("Derived constructors may only return object or undefined");
178
- }
179
-
180
- return _assertThisInitialized(self);
181
- }
182
-
183
- function _createSuper(Derived) {
184
- var hasNativeReflectConstruct = _isNativeReflectConstruct();
185
-
186
- return function _createSuperInternal() {
187
- var Super = _getPrototypeOf(Derived),
188
- result;
189
-
190
- if (hasNativeReflectConstruct) {
191
- var NewTarget = _getPrototypeOf(this).constructor;
192
-
193
- result = Reflect.construct(Super, arguments, NewTarget);
194
- } else {
195
- result = Super.apply(this, arguments);
196
- }
197
-
198
- return _possibleConstructorReturn(this, result);
199
- };
200
- }
201
-
202
- function _slicedToArray(arr, i) {
203
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
204
- }
205
-
206
- function _arrayWithHoles(arr) {
207
- if (Array.isArray(arr)) return arr;
208
- }
209
-
210
- function _iterableToArrayLimit(arr, i) {
211
- var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
212
-
213
- if (_i == null) return;
214
- var _arr = [];
215
- var _n = true;
216
- var _d = false;
217
-
218
- var _s, _e;
219
-
220
- try {
221
- for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
222
- _arr.push(_s.value);
223
-
224
- if (i && _arr.length === i) break;
225
- }
226
- } catch (err) {
227
- _d = true;
228
- _e = err;
229
- } finally {
230
- try {
231
- if (!_n && _i["return"] != null) _i["return"]();
232
- } finally {
233
- if (_d) throw _e;
234
- }
235
- }
236
-
237
- return _arr;
238
- }
239
-
240
- function _unsupportedIterableToArray(o, minLen) {
241
- if (!o) return;
242
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
243
- var n = Object.prototype.toString.call(o).slice(8, -1);
244
- if (n === "Object" && o.constructor) n = o.constructor.name;
245
- if (n === "Map" || n === "Set") return Array.from(o);
246
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
247
- }
248
-
249
- function _arrayLikeToArray(arr, len) {
250
- if (len == null || len > arr.length) len = arr.length;
251
-
252
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
253
-
254
- return arr2;
255
- }
256
-
257
- function _nonIterableRest() {
258
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
259
- }
260
-
261
- var gff3TabixAdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('Gff3TabixAdapter', {
262
- gffGzLocation: {
263
- type: 'fileLocation',
264
- defaultValue: {
265
- uri: '/path/to/my.gff.gz',
266
- locationType: 'UriLocation'
267
- }
268
- },
269
- index: /*#__PURE__*/ConfigurationSchema('Gff3TabixIndex', {
270
- indexType: {
271
- model: /*#__PURE__*/types.enumeration('IndexType', ['TBI', 'CSI']),
272
- type: 'stringEnum',
273
- defaultValue: 'TBI'
274
- },
275
- location: {
276
- type: 'fileLocation',
277
- defaultValue: {
278
- uri: '/path/to/my.gff.gz.tbi',
279
- locationType: 'UriLocation'
280
- }
281
- }
282
- }),
283
- dontRedispatch: {
284
- type: 'stringArray',
285
- defaultValue: ['chromosome', 'region']
286
- }
287
- }, {
288
- explicitlyTyped: true
289
- });
290
-
291
- var gff3AdapterConfigSchema = /*#__PURE__*/ConfigurationSchema('Gff3Adapter', {
292
- gffLocation: {
293
- type: 'fileLocation',
294
- defaultValue: {
295
- uri: '/path/to/my.gff',
296
- locationType: 'UriLocation'
297
- }
298
- }
299
- }, {
300
- explicitlyTyped: true
301
- });
302
-
303
- var _default = /*#__PURE__*/function (_Plugin) {
304
- _inherits(_default, _Plugin);
305
-
306
- var _super = /*#__PURE__*/_createSuper(_default);
307
-
308
- function _default() {
309
- var _this;
310
-
311
- _classCallCheck(this, _default);
312
-
313
- _this = _super.apply(this, arguments);
314
- _this.name = 'GFF3Plugin';
315
- return _this;
316
- }
317
-
318
- _createClass(_default, [{
319
- key: "install",
320
- value: function install(pluginManager) {
321
- pluginManager.addAdapterType(function () {
322
- return new AdapterType({
323
- name: 'Gff3TabixAdapter',
324
- configSchema: gff3TabixAdapterConfigSchema,
325
- getAdapterClass: function getAdapterClass() {
326
- return Promise.resolve().then(function () { return Gff3TabixAdapter; }).then(function (r) {
327
- return r["default"];
328
- });
329
- }
330
- });
331
- });
332
- pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
333
- return function (file, index, adapterHint) {
334
- var regexGuess = /\.gff3?\.b?gz$/i;
335
- var adapterName = 'Gff3TabixAdapter';
336
- var fileName = getFileName(file);
337
- var indexName = index && getFileName(index);
338
-
339
- if (regexGuess.test(fileName) || adapterHint === adapterName) {
340
- return {
341
- type: adapterName,
342
- bamLocation: file,
343
- gffGzLocation: file,
344
- index: {
345
- location: index || makeIndex(file, '.tbi'),
346
- indexType: makeIndexType(indexName, 'CSI', 'TBI')
347
- }
348
- };
349
- }
350
-
351
- return adapterGuesser(file, index, adapterHint);
352
- };
353
- });
354
- pluginManager.addAdapterType(function () {
355
- return new AdapterType({
356
- name: 'Gff3Adapter',
357
- configSchema: gff3AdapterConfigSchema,
358
- getAdapterClass: function getAdapterClass() {
359
- return Promise.resolve().then(function () { return Gff3Adapter; }).then(function (r) {
360
- return r["default"];
361
- });
362
- }
363
- });
364
- });
365
- pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
366
- return function (file, index, adapterHint) {
367
- var regexGuess = /\.gff3?$/i;
368
- var adapterName = 'Gff3Adapter';
369
- var fileName = getFileName(file);
370
- var obj = {
371
- type: adapterName,
372
- gffLocation: file
373
- };
374
-
375
- if (regexGuess.test(fileName) && !adapterHint) {
376
- return obj;
377
- } else if (adapterHint === adapterName) {
378
- return obj;
379
- }
380
-
381
- return adapterGuesser(file, index, adapterHint);
382
- };
383
- });
384
- }
385
- }]);
386
-
387
- return _default;
388
- }(Plugin);
389
-
390
- function createCommonjsModule(fn, module) {
391
- return module = { exports: {} }, fn(module, module.exports), module.exports;
392
- }
393
-
394
- var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
395
- /**
396
- * Copyright (c) 2014-present, Facebook, Inc.
397
- *
398
- * This source code is licensed under the MIT license found in the
399
- * LICENSE file in the root directory of this source tree.
400
- */
401
- var runtime = function (exports) {
402
-
403
- var Op = Object.prototype;
404
- var hasOwn = Op.hasOwnProperty;
405
- var undefined$1; // More compressible than void 0.
406
-
407
- var $Symbol = typeof Symbol === "function" ? Symbol : {};
408
- var iteratorSymbol = $Symbol.iterator || "@@iterator";
409
- var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
410
- var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
411
-
412
- function define(obj, key, value) {
413
- Object.defineProperty(obj, key, {
414
- value: value,
415
- enumerable: true,
416
- configurable: true,
417
- writable: true
418
- });
419
- return obj[key];
420
- }
421
-
422
- try {
423
- // IE 8 has a broken Object.defineProperty that only works on DOM objects.
424
- define({}, "");
425
- } catch (err) {
426
- define = function define(obj, key, value) {
427
- return obj[key] = value;
428
- };
429
- }
430
-
431
- function wrap(innerFn, outerFn, self, tryLocsList) {
432
- // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
433
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
434
- var generator = Object.create(protoGenerator.prototype);
435
- var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
436
- // .throw, and .return methods.
437
-
438
- generator._invoke = makeInvokeMethod(innerFn, self, context);
439
- return generator;
440
- }
441
-
442
- exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
443
- // record like context.tryEntries[i].completion. This interface could
444
- // have been (and was previously) designed to take a closure to be
445
- // invoked without arguments, but in all the cases we care about we
446
- // already have an existing method we want to call, so there's no need
447
- // to create a new function object. We can even get away with assuming
448
- // the method takes exactly one argument, since that happens to be true
449
- // in every case, so we don't have to touch the arguments object. The
450
- // only additional allocation required is the completion record, which
451
- // has a stable shape and so hopefully should be cheap to allocate.
452
-
453
- function tryCatch(fn, obj, arg) {
454
- try {
455
- return {
456
- type: "normal",
457
- arg: fn.call(obj, arg)
458
- };
459
- } catch (err) {
460
- return {
461
- type: "throw",
462
- arg: err
463
- };
464
- }
465
- }
466
-
467
- var GenStateSuspendedStart = "suspendedStart";
468
- var GenStateSuspendedYield = "suspendedYield";
469
- var GenStateExecuting = "executing";
470
- var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
471
- // breaking out of the dispatch switch statement.
472
-
473
- var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
474
- // .constructor.prototype properties for functions that return Generator
475
- // objects. For full spec compliance, you may wish to configure your
476
- // minifier not to mangle the names of these two functions.
477
-
478
- function Generator() {}
479
-
480
- function GeneratorFunction() {}
481
-
482
- function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
483
- // don't natively support it.
484
-
485
-
486
- var IteratorPrototype = {};
487
- define(IteratorPrototype, iteratorSymbol, function () {
488
- return this;
489
- });
490
- var getProto = Object.getPrototypeOf;
491
- var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
492
-
493
- if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
494
- // This environment has a native %IteratorPrototype%; use it instead
495
- // of the polyfill.
496
- IteratorPrototype = NativeIteratorPrototype;
497
- }
498
-
499
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
500
- GeneratorFunction.prototype = GeneratorFunctionPrototype;
501
- define(Gp, "constructor", GeneratorFunctionPrototype);
502
- define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
503
- GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
504
- // Iterator interface in terms of a single ._invoke method.
505
-
506
- function defineIteratorMethods(prototype) {
507
- ["next", "throw", "return"].forEach(function (method) {
508
- define(prototype, method, function (arg) {
509
- return this._invoke(method, arg);
510
- });
511
- });
512
- }
513
-
514
- exports.isGeneratorFunction = function (genFun) {
515
- var ctor = typeof genFun === "function" && genFun.constructor;
516
- return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
517
- // do is to check its .name property.
518
- (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
519
- };
520
-
521
- exports.mark = function (genFun) {
522
- if (Object.setPrototypeOf) {
523
- Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
524
- } else {
525
- genFun.__proto__ = GeneratorFunctionPrototype;
526
- define(genFun, toStringTagSymbol, "GeneratorFunction");
527
- }
528
-
529
- genFun.prototype = Object.create(Gp);
530
- return genFun;
531
- }; // Within the body of any async function, `await x` is transformed to
532
- // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
533
- // `hasOwn.call(value, "__await")` to determine if the yielded value is
534
- // meant to be awaited.
535
-
536
-
537
- exports.awrap = function (arg) {
538
- return {
539
- __await: arg
540
- };
541
- };
542
-
543
- function AsyncIterator(generator, PromiseImpl) {
544
- function invoke(method, arg, resolve, reject) {
545
- var record = tryCatch(generator[method], generator, arg);
546
-
547
- if (record.type === "throw") {
548
- reject(record.arg);
549
- } else {
550
- var result = record.arg;
551
- var value = result.value;
552
-
553
- if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
554
- return PromiseImpl.resolve(value.__await).then(function (value) {
555
- invoke("next", value, resolve, reject);
556
- }, function (err) {
557
- invoke("throw", err, resolve, reject);
558
- });
559
- }
560
-
561
- return PromiseImpl.resolve(value).then(function (unwrapped) {
562
- // When a yielded Promise is resolved, its final value becomes
563
- // the .value of the Promise<{value,done}> result for the
564
- // current iteration.
565
- result.value = unwrapped;
566
- resolve(result);
567
- }, function (error) {
568
- // If a rejected Promise was yielded, throw the rejection back
569
- // into the async generator function so it can be handled there.
570
- return invoke("throw", error, resolve, reject);
571
- });
572
- }
573
- }
574
-
575
- var previousPromise;
576
-
577
- function enqueue(method, arg) {
578
- function callInvokeWithMethodAndArg() {
579
- return new PromiseImpl(function (resolve, reject) {
580
- invoke(method, arg, resolve, reject);
581
- });
582
- }
583
-
584
- return previousPromise = // If enqueue has been called before, then we want to wait until
585
- // all previous Promises have been resolved before calling invoke,
586
- // so that results are always delivered in the correct order. If
587
- // enqueue has not been called before, then it is important to
588
- // call invoke immediately, without waiting on a callback to fire,
589
- // so that the async generator function has the opportunity to do
590
- // any necessary setup in a predictable way. This predictability
591
- // is why the Promise constructor synchronously invokes its
592
- // executor callback, and why async functions synchronously
593
- // execute code before the first await. Since we implement simple
594
- // async functions in terms of async generators, it is especially
595
- // important to get this right, even though it requires care.
596
- previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
597
- // invocations of the iterator.
598
- callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
599
- } // Define the unified helper method that is used to implement .next,
600
- // .throw, and .return (see defineIteratorMethods).
601
-
602
-
603
- this._invoke = enqueue;
604
- }
605
-
606
- defineIteratorMethods(AsyncIterator.prototype);
607
- define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
608
- return this;
609
- });
610
- exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
611
- // AsyncIterator objects; they just return a Promise for the value of
612
- // the final result produced by the iterator.
613
-
614
- exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
615
- if (PromiseImpl === void 0) PromiseImpl = Promise;
616
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
617
- return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
618
- : iter.next().then(function (result) {
619
- return result.done ? result.value : iter.next();
620
- });
621
- };
622
-
623
- function makeInvokeMethod(innerFn, self, context) {
624
- var state = GenStateSuspendedStart;
625
- return function invoke(method, arg) {
626
- if (state === GenStateExecuting) {
627
- throw new Error("Generator is already running");
628
- }
629
-
630
- if (state === GenStateCompleted) {
631
- if (method === "throw") {
632
- throw arg;
633
- } // Be forgiving, per 25.3.3.3.3 of the spec:
634
- // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
635
-
636
-
637
- return doneResult();
638
- }
639
-
640
- context.method = method;
641
- context.arg = arg;
642
-
643
- while (true) {
644
- var delegate = context.delegate;
645
-
646
- if (delegate) {
647
- var delegateResult = maybeInvokeDelegate(delegate, context);
648
-
649
- if (delegateResult) {
650
- if (delegateResult === ContinueSentinel) continue;
651
- return delegateResult;
652
- }
653
- }
654
-
655
- if (context.method === "next") {
656
- // Setting context._sent for legacy support of Babel's
657
- // function.sent implementation.
658
- context.sent = context._sent = context.arg;
659
- } else if (context.method === "throw") {
660
- if (state === GenStateSuspendedStart) {
661
- state = GenStateCompleted;
662
- throw context.arg;
663
- }
664
-
665
- context.dispatchException(context.arg);
666
- } else if (context.method === "return") {
667
- context.abrupt("return", context.arg);
668
- }
669
-
670
- state = GenStateExecuting;
671
- var record = tryCatch(innerFn, self, context);
672
-
673
- if (record.type === "normal") {
674
- // If an exception is thrown from innerFn, we leave state ===
675
- // GenStateExecuting and loop back for another invocation.
676
- state = context.done ? GenStateCompleted : GenStateSuspendedYield;
677
-
678
- if (record.arg === ContinueSentinel) {
679
- continue;
680
- }
681
-
682
- return {
683
- value: record.arg,
684
- done: context.done
685
- };
686
- } else if (record.type === "throw") {
687
- state = GenStateCompleted; // Dispatch the exception by looping back around to the
688
- // context.dispatchException(context.arg) call above.
689
-
690
- context.method = "throw";
691
- context.arg = record.arg;
692
- }
693
- }
694
- };
695
- } // Call delegate.iterator[context.method](context.arg) and handle the
696
- // result, either by returning a { value, done } result from the
697
- // delegate iterator, or by modifying context.method and context.arg,
698
- // setting context.delegate to null, and returning the ContinueSentinel.
699
-
700
-
701
- function maybeInvokeDelegate(delegate, context) {
702
- var method = delegate.iterator[context.method];
703
-
704
- if (method === undefined$1) {
705
- // A .throw or .return when the delegate iterator has no .throw
706
- // method always terminates the yield* loop.
707
- context.delegate = null;
708
-
709
- if (context.method === "throw") {
710
- // Note: ["return"] must be used for ES3 parsing compatibility.
711
- if (delegate.iterator["return"]) {
712
- // If the delegate iterator has a return method, give it a
713
- // chance to clean up.
714
- context.method = "return";
715
- context.arg = undefined$1;
716
- maybeInvokeDelegate(delegate, context);
717
-
718
- if (context.method === "throw") {
719
- // If maybeInvokeDelegate(context) changed context.method from
720
- // "return" to "throw", let that override the TypeError below.
721
- return ContinueSentinel;
722
- }
723
- }
724
-
725
- context.method = "throw";
726
- context.arg = new TypeError("The iterator does not provide a 'throw' method");
727
- }
728
-
729
- return ContinueSentinel;
730
- }
731
-
732
- var record = tryCatch(method, delegate.iterator, context.arg);
733
-
734
- if (record.type === "throw") {
735
- context.method = "throw";
736
- context.arg = record.arg;
737
- context.delegate = null;
738
- return ContinueSentinel;
739
- }
740
-
741
- var info = record.arg;
742
-
743
- if (!info) {
744
- context.method = "throw";
745
- context.arg = new TypeError("iterator result is not an object");
746
- context.delegate = null;
747
- return ContinueSentinel;
748
- }
749
-
750
- if (info.done) {
751
- // Assign the result of the finished delegate to the temporary
752
- // variable specified by delegate.resultName (see delegateYield).
753
- context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
754
-
755
- context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
756
- // exception, let the outer generator proceed normally. If
757
- // context.method was "next", forget context.arg since it has been
758
- // "consumed" by the delegate iterator. If context.method was
759
- // "return", allow the original .return call to continue in the
760
- // outer generator.
761
-
762
- if (context.method !== "return") {
763
- context.method = "next";
764
- context.arg = undefined$1;
765
- }
766
- } else {
767
- // Re-yield the result returned by the delegate method.
768
- return info;
769
- } // The delegate iterator is finished, so forget it and continue with
770
- // the outer generator.
771
-
772
-
773
- context.delegate = null;
774
- return ContinueSentinel;
775
- } // Define Generator.prototype.{next,throw,return} in terms of the
776
- // unified ._invoke helper method.
777
-
778
-
779
- defineIteratorMethods(Gp);
780
- define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
781
- // @@iterator function is called on it. Some browsers' implementations of the
782
- // iterator prototype chain incorrectly implement this, causing the Generator
783
- // object to not be returned from this call. This ensures that doesn't happen.
784
- // See https://github.com/facebook/regenerator/issues/274 for more details.
785
-
786
- define(Gp, iteratorSymbol, function () {
787
- return this;
788
- });
789
- define(Gp, "toString", function () {
790
- return "[object Generator]";
791
- });
792
-
793
- function pushTryEntry(locs) {
794
- var entry = {
795
- tryLoc: locs[0]
796
- };
797
-
798
- if (1 in locs) {
799
- entry.catchLoc = locs[1];
800
- }
801
-
802
- if (2 in locs) {
803
- entry.finallyLoc = locs[2];
804
- entry.afterLoc = locs[3];
805
- }
806
-
807
- this.tryEntries.push(entry);
808
- }
809
-
810
- function resetTryEntry(entry) {
811
- var record = entry.completion || {};
812
- record.type = "normal";
813
- delete record.arg;
814
- entry.completion = record;
815
- }
816
-
817
- function Context(tryLocsList) {
818
- // The root entry object (effectively a try statement without a catch
819
- // or a finally block) gives us a place to store values thrown from
820
- // locations where there is no enclosing try statement.
821
- this.tryEntries = [{
822
- tryLoc: "root"
823
- }];
824
- tryLocsList.forEach(pushTryEntry, this);
825
- this.reset(true);
826
- }
827
-
828
- exports.keys = function (object) {
829
- var keys = [];
830
-
831
- for (var key in object) {
832
- keys.push(key);
833
- }
834
-
835
- keys.reverse(); // Rather than returning an object with a next method, we keep
836
- // things simple and return the next function itself.
837
-
838
- return function next() {
839
- while (keys.length) {
840
- var key = keys.pop();
841
-
842
- if (key in object) {
843
- next.value = key;
844
- next.done = false;
845
- return next;
846
- }
847
- } // To avoid creating an additional object, we just hang the .value
848
- // and .done properties off the next function object itself. This
849
- // also ensures that the minifier will not anonymize the function.
850
-
851
-
852
- next.done = true;
853
- return next;
854
- };
855
- };
856
-
857
- function values(iterable) {
858
- if (iterable) {
859
- var iteratorMethod = iterable[iteratorSymbol];
860
-
861
- if (iteratorMethod) {
862
- return iteratorMethod.call(iterable);
863
- }
864
-
865
- if (typeof iterable.next === "function") {
866
- return iterable;
867
- }
868
-
869
- if (!isNaN(iterable.length)) {
870
- var i = -1,
871
- next = function next() {
872
- while (++i < iterable.length) {
873
- if (hasOwn.call(iterable, i)) {
874
- next.value = iterable[i];
875
- next.done = false;
876
- return next;
877
- }
878
- }
879
-
880
- next.value = undefined$1;
881
- next.done = true;
882
- return next;
883
- };
884
-
885
- return next.next = next;
886
- }
887
- } // Return an iterator with no values.
888
-
889
-
890
- return {
891
- next: doneResult
892
- };
893
- }
894
-
895
- exports.values = values;
896
-
897
- function doneResult() {
898
- return {
899
- value: undefined$1,
900
- done: true
901
- };
902
- }
903
-
904
- Context.prototype = {
905
- constructor: Context,
906
- reset: function reset(skipTempReset) {
907
- this.prev = 0;
908
- this.next = 0; // Resetting context._sent for legacy support of Babel's
909
- // function.sent implementation.
910
-
911
- this.sent = this._sent = undefined$1;
912
- this.done = false;
913
- this.delegate = null;
914
- this.method = "next";
915
- this.arg = undefined$1;
916
- this.tryEntries.forEach(resetTryEntry);
917
-
918
- if (!skipTempReset) {
919
- for (var name in this) {
920
- // Not sure about the optimal order of these conditions:
921
- if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
922
- this[name] = undefined$1;
923
- }
924
- }
925
- }
926
- },
927
- stop: function stop() {
928
- this.done = true;
929
- var rootEntry = this.tryEntries[0];
930
- var rootRecord = rootEntry.completion;
931
-
932
- if (rootRecord.type === "throw") {
933
- throw rootRecord.arg;
934
- }
935
-
936
- return this.rval;
937
- },
938
- dispatchException: function dispatchException(exception) {
939
- if (this.done) {
940
- throw exception;
941
- }
942
-
943
- var context = this;
944
-
945
- function handle(loc, caught) {
946
- record.type = "throw";
947
- record.arg = exception;
948
- context.next = loc;
949
-
950
- if (caught) {
951
- // If the dispatched exception was caught by a catch block,
952
- // then let that catch block handle the exception normally.
953
- context.method = "next";
954
- context.arg = undefined$1;
955
- }
956
-
957
- return !!caught;
958
- }
959
-
960
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
961
- var entry = this.tryEntries[i];
962
- var record = entry.completion;
963
-
964
- if (entry.tryLoc === "root") {
965
- // Exception thrown outside of any try block that could handle
966
- // it, so set the completion value of the entire function to
967
- // throw the exception.
968
- return handle("end");
969
- }
970
-
971
- if (entry.tryLoc <= this.prev) {
972
- var hasCatch = hasOwn.call(entry, "catchLoc");
973
- var hasFinally = hasOwn.call(entry, "finallyLoc");
974
-
975
- if (hasCatch && hasFinally) {
976
- if (this.prev < entry.catchLoc) {
977
- return handle(entry.catchLoc, true);
978
- } else if (this.prev < entry.finallyLoc) {
979
- return handle(entry.finallyLoc);
980
- }
981
- } else if (hasCatch) {
982
- if (this.prev < entry.catchLoc) {
983
- return handle(entry.catchLoc, true);
984
- }
985
- } else if (hasFinally) {
986
- if (this.prev < entry.finallyLoc) {
987
- return handle(entry.finallyLoc);
988
- }
989
- } else {
990
- throw new Error("try statement without catch or finally");
991
- }
992
- }
993
- }
994
- },
995
- abrupt: function abrupt(type, arg) {
996
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
997
- var entry = this.tryEntries[i];
998
-
999
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
1000
- var finallyEntry = entry;
1001
- break;
1002
- }
1003
- }
1004
-
1005
- if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
1006
- // Ignore the finally entry if control is not jumping to a
1007
- // location outside the try/catch block.
1008
- finallyEntry = null;
1009
- }
1010
-
1011
- var record = finallyEntry ? finallyEntry.completion : {};
1012
- record.type = type;
1013
- record.arg = arg;
1014
-
1015
- if (finallyEntry) {
1016
- this.method = "next";
1017
- this.next = finallyEntry.finallyLoc;
1018
- return ContinueSentinel;
1019
- }
1020
-
1021
- return this.complete(record);
1022
- },
1023
- complete: function complete(record, afterLoc) {
1024
- if (record.type === "throw") {
1025
- throw record.arg;
1026
- }
1027
-
1028
- if (record.type === "break" || record.type === "continue") {
1029
- this.next = record.arg;
1030
- } else if (record.type === "return") {
1031
- this.rval = this.arg = record.arg;
1032
- this.method = "return";
1033
- this.next = "end";
1034
- } else if (record.type === "normal" && afterLoc) {
1035
- this.next = afterLoc;
1036
- }
1037
-
1038
- return ContinueSentinel;
1039
- },
1040
- finish: function finish(finallyLoc) {
1041
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1042
- var entry = this.tryEntries[i];
1043
-
1044
- if (entry.finallyLoc === finallyLoc) {
1045
- this.complete(entry.completion, entry.afterLoc);
1046
- resetTryEntry(entry);
1047
- return ContinueSentinel;
1048
- }
1049
- }
1050
- },
1051
- "catch": function _catch(tryLoc) {
1052
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1053
- var entry = this.tryEntries[i];
1054
-
1055
- if (entry.tryLoc === tryLoc) {
1056
- var record = entry.completion;
1057
-
1058
- if (record.type === "throw") {
1059
- var thrown = record.arg;
1060
- resetTryEntry(entry);
1061
- }
1062
-
1063
- return thrown;
1064
- }
1065
- } // The context.catch method must only be called with a location
1066
- // argument that corresponds to a known catch block.
1067
-
1068
-
1069
- throw new Error("illegal catch attempt");
1070
- },
1071
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
1072
- this.delegate = {
1073
- iterator: values(iterable),
1074
- resultName: resultName,
1075
- nextLoc: nextLoc
1076
- };
1077
-
1078
- if (this.method === "next") {
1079
- // Deliberately forget the last sent value so that we don't
1080
- // accidentally pass it on to the delegate.
1081
- this.arg = undefined$1;
1082
- }
1083
-
1084
- return ContinueSentinel;
1085
- }
1086
- }; // Regardless of whether this script is executing as a CommonJS module
1087
- // or not, return the runtime object so that we can declare the variable
1088
- // regeneratorRuntime in the outer scope, which allows this module to be
1089
- // injected easily by `bin/regenerator --include-runtime script.js`.
1090
-
1091
- return exports;
1092
- }( // If this script is executing as a CommonJS module, use module.exports
1093
- // as the regeneratorRuntime namespace. Otherwise create a new empty
1094
- // object. Either way, the resulting object will be used to initialize
1095
- // the regeneratorRuntime variable at the top of this file.
1096
- module.exports );
1097
-
1098
- try {
1099
- regeneratorRuntime = runtime;
1100
- } catch (accidentalStrictMode) {
1101
- // This module should not be running in strict mode, so the above
1102
- // assignment should always work unless something is misconfigured. Just
1103
- // in case runtime.js accidentally runs in strict mode, in modern engines
1104
- // we can explicitly access globalThis. In older engines we can escape
1105
- // strict mode using a global Function call. This could conceivably fail
1106
- // if a Content Security Policy forbids using Function, but in that case
1107
- // the proper solution is to fix the accidental strict mode problem. If
1108
- // you've misconfigured your bundler to force strict mode and applied a
1109
- // CSP to forbid Function, and you're not willing to fix either of those
1110
- // problems, please detail your unique predicament in a GitHub issue.
1111
- if (typeof globalThis === "object") {
1112
- globalThis.regeneratorRuntime = runtime;
1113
- } else {
1114
- Function("r", "regeneratorRuntime = r")(runtime);
1115
- }
1116
- }
1117
- });
1118
-
1119
- var _default$1 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1120
- _inherits(_default, _BaseFeatureDataAdapt);
1121
-
1122
- var _super = /*#__PURE__*/_createSuper(_default);
1123
-
1124
- function _default(config, getSubAdapter, pluginManager) {
1125
- var _this;
1126
-
1127
- _classCallCheck(this, _default);
1128
-
1129
- _this = _super.call(this, config, getSubAdapter, pluginManager);
1130
- var gffGzLocation = readConfObject(config, 'gffGzLocation');
1131
- var indexType = readConfObject(config, ['index', 'indexType']);
1132
- var location = readConfObject(config, ['index', 'location']);
1133
- var dontRedispatch = readConfObject(config, 'dontRedispatch');
1134
- _this.dontRedispatch = dontRedispatch || ['chromosome', 'contig', 'region'];
1135
- _this.gff = new TabixIndexedFile({
1136
- filehandle: openLocation(gffGzLocation, _this.pluginManager),
1137
- csiFilehandle: indexType === 'CSI' ? openLocation(location, _this.pluginManager) : undefined,
1138
- tbiFilehandle: indexType !== 'CSI' ? openLocation(location, _this.pluginManager) : undefined,
1139
- chunkCacheSize: 50 * Math.pow(2, 20),
1140
- renameRefSeqs: function renameRefSeqs(n) {
1141
- return n;
1142
- }
1143
- });
1144
- return _this;
1145
- }
1146
-
1147
- _createClass(_default, [{
1148
- key: "getRefNames",
1149
- value: function () {
1150
- var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1151
- var opts,
1152
- _args = arguments;
1153
- return runtime_1.wrap(function _callee$(_context) {
1154
- while (1) {
1155
- switch (_context.prev = _context.next) {
1156
- case 0:
1157
- opts = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
1158
- return _context.abrupt("return", this.gff.getReferenceSequenceNames(opts));
1159
-
1160
- case 2:
1161
- case "end":
1162
- return _context.stop();
1163
- }
1164
- }
1165
- }, _callee, this);
1166
- }));
1167
-
1168
- function getRefNames() {
1169
- return _getRefNames.apply(this, arguments);
1170
- }
1171
-
1172
- return getRefNames;
1173
- }()
1174
- }, {
1175
- key: "getHeader",
1176
- value: function () {
1177
- var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1178
- return runtime_1.wrap(function _callee2$(_context2) {
1179
- while (1) {
1180
- switch (_context2.prev = _context2.next) {
1181
- case 0:
1182
- return _context2.abrupt("return", this.gff.getHeader());
1183
-
1184
- case 1:
1185
- case "end":
1186
- return _context2.stop();
1187
- }
1188
- }
1189
- }, _callee2, this);
1190
- }));
1191
-
1192
- function getHeader() {
1193
- return _getHeader.apply(this, arguments);
1194
- }
1195
-
1196
- return getHeader;
1197
- }()
1198
- }, {
1199
- key: "getFeatures",
1200
- value: function getFeatures(query) {
1201
- var _this2 = this;
1202
-
1203
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1204
- return ObservableCreate( /*#__PURE__*/function () {
1205
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(observer) {
1206
- var metadata;
1207
- return runtime_1.wrap(function _callee3$(_context3) {
1208
- while (1) {
1209
- switch (_context3.prev = _context3.next) {
1210
- case 0:
1211
- _context3.next = 2;
1212
- return _this2.gff.getMetadata();
1213
-
1214
- case 2:
1215
- metadata = _context3.sent;
1216
-
1217
- _this2.getFeaturesHelper(query, opts, metadata, observer, true);
1218
-
1219
- case 4:
1220
- case "end":
1221
- return _context3.stop();
1222
- }
1223
- }
1224
- }, _callee3);
1225
- }));
1226
-
1227
- return function (_x) {
1228
- return _ref.apply(this, arguments);
1229
- };
1230
- }(), opts.signal);
1231
- }
1232
- }, {
1233
- key: "getFeaturesHelper",
1234
- value: function () {
1235
- var _getFeaturesHelper = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(query) {
1236
- var _this3 = this;
1237
-
1238
- var opts,
1239
- metadata,
1240
- observer,
1241
- allowRedispatch,
1242
- originalQuery,
1243
- lines,
1244
- minStart,
1245
- maxEnd,
1246
- gff3,
1247
- features,
1248
- _args4 = arguments;
1249
- return runtime_1.wrap(function _callee4$(_context4) {
1250
- while (1) {
1251
- switch (_context4.prev = _context4.next) {
1252
- case 0:
1253
- opts = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
1254
- metadata = _args4.length > 2 ? _args4[2] : undefined;
1255
- observer = _args4.length > 3 ? _args4[3] : undefined;
1256
- allowRedispatch = _args4.length > 4 ? _args4[4] : undefined;
1257
- originalQuery = _args4.length > 5 && _args4[5] !== undefined ? _args4[5] : query;
1258
- _context4.prev = 5;
1259
- lines = [];
1260
- _context4.next = 9;
1261
- return this.gff.getLines(query.refName, query.start, query.end, function (line, fileOffset) {
1262
- lines.push(_this3.parseLine(metadata.columnNumbers, line, fileOffset));
1263
- });
1264
-
1265
- case 9:
1266
- if (!(allowRedispatch && lines.length)) {
1267
- _context4.next = 16;
1268
- break;
1269
- }
1270
-
1271
- minStart = Infinity;
1272
- maxEnd = -Infinity;
1273
- lines.forEach(function (line) {
1274
- var featureType = line.fields[2]; // only expand redispatch range if feature is not a "dontRedispatch" type
1275
- // skips large regions like chromosome,region
1276
-
1277
- if (!_this3.dontRedispatch.includes(featureType)) {
1278
- var start = line.start - 1; // gff is 1-based
1279
-
1280
- if (start < minStart) {
1281
- minStart = start;
1282
- }
1283
-
1284
- if (line.end > maxEnd) {
1285
- maxEnd = line.end;
1286
- }
1287
- }
1288
- });
1289
-
1290
- if (!(maxEnd > query.end || minStart < query.start)) {
1291
- _context4.next = 16;
1292
- break;
1293
- }
1294
-
1295
- // make a new feature callback to only return top-level features
1296
- // in the original query range
1297
- this.getFeaturesHelper(_objectSpread2(_objectSpread2({}, query), {}, {
1298
- start: minStart,
1299
- end: maxEnd
1300
- }), opts, metadata, observer, false, query);
1301
- return _context4.abrupt("return");
1302
-
1303
- case 16:
1304
- gff3 = lines.map(function (lineRecord) {
1305
- if (lineRecord.fields[8] && lineRecord.fields[8] !== '.') {
1306
- if (!lineRecord.fields[8].includes('_lineHash')) {
1307
- lineRecord.fields[8] += ";_lineHash=".concat(lineRecord.lineHash);
1308
- }
1309
- } else {
1310
- lineRecord.fields[8] = "_lineHash=".concat(lineRecord.lineHash);
1311
- }
1312
-
1313
- return lineRecord.fields.join('\t');
1314
- }).join('\n');
1315
- features = gff.parseStringSync(gff3, {
1316
- parseFeatures: true,
1317
- parseComments: false,
1318
- parseDirectives: false,
1319
- parseSequences: false
1320
- });
1321
- features.forEach(function (featureLocs) {
1322
- return _this3.formatFeatures(featureLocs).forEach(function (f) {
1323
- if (doesIntersect2(f.get('start'), f.get('end'), originalQuery.start, originalQuery.end)) {
1324
- observer.next(f);
1325
- }
1326
- });
1327
- });
1328
- observer.complete();
1329
- _context4.next = 25;
1330
- break;
1331
-
1332
- case 22:
1333
- _context4.prev = 22;
1334
- _context4.t0 = _context4["catch"](5);
1335
- observer.error(_context4.t0);
1336
-
1337
- case 25:
1338
- case "end":
1339
- return _context4.stop();
1340
- }
1341
- }
1342
- }, _callee4, this, [[5, 22]]);
1343
- }));
1344
-
1345
- function getFeaturesHelper(_x2) {
1346
- return _getFeaturesHelper.apply(this, arguments);
1347
- }
1348
-
1349
- return getFeaturesHelper;
1350
- }()
1351
- }, {
1352
- key: "parseLine",
1353
- value: function parseLine(columnNumbers, line, fileOffset) {
1354
- var fields = line.split('\t'); // note: index column numbers are 1-based
1355
-
1356
- return {
1357
- start: +fields[columnNumbers.start - 1],
1358
- end: +fields[columnNumbers.end - 1],
1359
- lineHash: fileOffset,
1360
- fields: fields
1361
- };
1362
- }
1363
- }, {
1364
- key: "formatFeatures",
1365
- value: function formatFeatures(featureLocs) {
1366
- var _this4 = this;
1367
-
1368
- return featureLocs.map(function (featureLoc) {
1369
- return new SimpleFeature({
1370
- data: _this4.featureData(featureLoc),
1371
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1372
- id: "".concat(_this4.id, "-offset-").concat(featureLoc.attributes._lineHash[0])
1373
- });
1374
- });
1375
- }
1376
- }, {
1377
- key: "featureData",
1378
- value: function featureData(data) {
1379
- var _this5 = this;
1380
-
1381
- var f = _objectSpread2({}, data);
1382
-
1383
- f.start -= 1; // convert to interbase
1384
-
1385
- if (data.strand === '+') {
1386
- f.strand = 1;
1387
- } else if (data.strand === '-') {
1388
- f.strand = -1;
1389
- } else if (data.strand === '.') {
1390
- f.strand = 0;
1391
- } else {
1392
- f.strand = undefined;
1393
- }
1394
-
1395
- f.phase = Number(data.phase);
1396
- f.refName = data.seq_id;
1397
-
1398
- if (data.score === null) {
1399
- delete f.score;
1400
- }
1401
-
1402
- if (data.phase === null) {
1403
- delete f.score;
1404
- }
1405
-
1406
- var defaultFields = ['start', 'end', 'seq_id', 'score', 'type', 'source', 'phase', 'strand'];
1407
- var dataAttributes = data.attributes || {};
1408
- Object.keys(dataAttributes).forEach(function (a) {
1409
- var b = a.toLowerCase();
1410
-
1411
- if (defaultFields.includes(b)) {
1412
- // add "suffix" to tag name if it already exists
1413
- // reproduces behavior of NCList
1414
- b += '2';
1415
- }
1416
-
1417
- if (dataAttributes[a] !== null) {
1418
- var attr = dataAttributes[a];
1419
-
1420
- if (Array.isArray(attr) && attr.length === 1) {
1421
- var _attr = attr;
1422
-
1423
- var _attr2 = _slicedToArray(_attr, 1);
1424
-
1425
- attr = _attr2[0];
1426
- }
1427
-
1428
- f[b] = attr;
1429
- }
1430
- });
1431
- f.refName = f.seq_id; // the SimpleFeature constructor takes care of recursively inflating subfeatures
1432
-
1433
- if (data.child_features && data.child_features.length) {
1434
- f.subfeatures = data.child_features.map(function (childLocs) {
1435
- return childLocs.map(function (childLoc) {
1436
- return _this5.featureData(childLoc);
1437
- });
1438
- }).flat();
1439
- }
1440
-
1441
- delete f.child_features;
1442
- delete f.data;
1443
- delete f.derived_features;
1444
- delete f._linehash;
1445
- delete f.attributes;
1446
- delete f.seq_id;
1447
- return f;
1448
- }
1449
- }, {
1450
- key: "freeResources",
1451
- value: function
1452
- /* { region } */
1453
- freeResources() {}
1454
- }]);
1455
-
1456
- return _default;
1457
- }(BaseFeatureDataAdapter);
1458
-
1459
- var Gff3TabixAdapter = {
1460
- __proto__: null,
1461
- 'default': _default$1
1462
- };
1463
-
1464
- function isGzip(buf) {
1465
- return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
1466
- }
1467
-
1468
- var _default$2 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
1469
- _inherits(_default, _BaseFeatureDataAdapt);
1470
-
1471
- var _super = /*#__PURE__*/_createSuper(_default);
1472
-
1473
- function _default() {
1474
- _classCallCheck(this, _default);
1475
-
1476
- return _super.apply(this, arguments);
1477
- }
1478
-
1479
- _createClass(_default, [{
1480
- key: "loadDataP",
1481
- value: function () {
1482
- var _loadDataP = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
1483
- var _this = this;
1484
-
1485
- var buffer, buf, data, lines, headerLines, i, header, feats, intervalTree;
1486
- return runtime_1.wrap(function _callee$(_context) {
1487
- while (1) {
1488
- switch (_context.prev = _context.next) {
1489
- case 0:
1490
- _context.next = 2;
1491
- return openLocation(readConfObject(this.config, 'gffLocation'), this.pluginManager).readFile();
1492
-
1493
- case 2:
1494
- buffer = _context.sent;
1495
-
1496
- if (!isGzip(buffer)) {
1497
- _context.next = 9;
1498
- break;
1499
- }
1500
-
1501
- _context.next = 6;
1502
- return unzip(buffer);
1503
-
1504
- case 6:
1505
- _context.t0 = _context.sent;
1506
- _context.next = 10;
1507
- break;
1508
-
1509
- case 9:
1510
- _context.t0 = buffer;
1511
-
1512
- case 10:
1513
- buf = _context.t0;
1514
-
1515
- if (!(buf.length > 536870888)) {
1516
- _context.next = 13;
1517
- break;
1518
- }
1519
-
1520
- throw new Error('Data exceeds maximum string length (512MB)');
1521
-
1522
- case 13:
1523
- data = new TextDecoder('utf8', {
1524
- fatal: true
1525
- }).decode(buf);
1526
- lines = data.split('\n');
1527
- headerLines = [];
1528
-
1529
- for (i = 0; i < lines.length && lines[i].startsWith('#'); i++) {
1530
- headerLines.push(lines[i]);
1531
- }
1532
-
1533
- header = headerLines.join('\n');
1534
- feats = gff.parseStringSync(data, {
1535
- parseFeatures: true,
1536
- parseComments: false,
1537
- parseDirectives: false,
1538
- parseSequences: false
1539
- });
1540
- intervalTree = feats.flat().map(function (f, i) {
1541
- return new SimpleFeature({
1542
- data: _this.featureData(f),
1543
- id: "".concat(_this.id, "-offset-").concat(i)
1544
- });
1545
- }).reduce(function (acc, obj) {
1546
- var key = obj.get('refName');
1547
-
1548
- if (!acc[key]) {
1549
- acc[key] = new IntervalTree();
1550
- }
1551
-
1552
- acc[key].insert([obj.get('start'), obj.get('end')], obj);
1553
- return acc;
1554
- }, {});
1555
- return _context.abrupt("return", {
1556
- header: header,
1557
- intervalTree: intervalTree
1558
- });
1559
-
1560
- case 21:
1561
- case "end":
1562
- return _context.stop();
1563
- }
1564
- }
1565
- }, _callee, this);
1566
- }));
1567
-
1568
- function loadDataP() {
1569
- return _loadDataP.apply(this, arguments);
1570
- }
1571
-
1572
- return loadDataP;
1573
- }()
1574
- }, {
1575
- key: "loadData",
1576
- value: function () {
1577
- var _loadData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
1578
- var _this2 = this;
1579
-
1580
- return runtime_1.wrap(function _callee2$(_context2) {
1581
- while (1) {
1582
- switch (_context2.prev = _context2.next) {
1583
- case 0:
1584
- if (!this.gffFeatures) {
1585
- this.gffFeatures = this.loadDataP()["catch"](function (e) {
1586
- _this2.gffFeatures = undefined;
1587
- throw e;
1588
- });
1589
- }
1590
-
1591
- return _context2.abrupt("return", this.gffFeatures);
1592
-
1593
- case 2:
1594
- case "end":
1595
- return _context2.stop();
1596
- }
1597
- }
1598
- }, _callee2, this);
1599
- }));
1600
-
1601
- function loadData() {
1602
- return _loadData.apply(this, arguments);
1603
- }
1604
-
1605
- return loadData;
1606
- }()
1607
- }, {
1608
- key: "getRefNames",
1609
- value: function () {
1610
- var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
1611
- var _yield$this$loadData,
1612
- intervalTree;
1613
-
1614
- return runtime_1.wrap(function _callee3$(_context3) {
1615
- while (1) {
1616
- switch (_context3.prev = _context3.next) {
1617
- case 0:
1618
- _context3.next = 3;
1619
- return this.loadData();
1620
-
1621
- case 3:
1622
- _yield$this$loadData = _context3.sent;
1623
- intervalTree = _yield$this$loadData.intervalTree;
1624
- return _context3.abrupt("return", Object.keys(intervalTree));
1625
-
1626
- case 6:
1627
- case "end":
1628
- return _context3.stop();
1629
- }
1630
- }
1631
- }, _callee3, this);
1632
- }));
1633
-
1634
- function getRefNames() {
1635
- return _getRefNames.apply(this, arguments);
1636
- }
1637
-
1638
- return getRefNames;
1639
- }()
1640
- }, {
1641
- key: "getHeader",
1642
- value: function () {
1643
- var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
1644
- var _yield$this$loadData2, header;
1645
-
1646
- return runtime_1.wrap(function _callee4$(_context4) {
1647
- while (1) {
1648
- switch (_context4.prev = _context4.next) {
1649
- case 0:
1650
- _context4.next = 2;
1651
- return this.loadData();
1652
-
1653
- case 2:
1654
- _yield$this$loadData2 = _context4.sent;
1655
- header = _yield$this$loadData2.header;
1656
- return _context4.abrupt("return", header);
1657
-
1658
- case 5:
1659
- case "end":
1660
- return _context4.stop();
1661
- }
1662
- }
1663
- }, _callee4, this);
1664
- }));
1665
-
1666
- function getHeader() {
1667
- return _getHeader.apply(this, arguments);
1668
- }
1669
-
1670
- return getHeader;
1671
- }()
1672
- }, {
1673
- key: "getFeatures",
1674
- value: function getFeatures(query) {
1675
- var _this3 = this;
1676
-
1677
- var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1678
- return ObservableCreate( /*#__PURE__*/function () {
1679
- var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(observer) {
1680
- var _intervalTree$refName, start, end, refName, _yield$_this3$loadDat, intervalTree;
1681
-
1682
- return runtime_1.wrap(function _callee5$(_context5) {
1683
- while (1) {
1684
- switch (_context5.prev = _context5.next) {
1685
- case 0:
1686
- _context5.prev = 0;
1687
- start = query.start, end = query.end, refName = query.refName;
1688
- _context5.next = 4;
1689
- return _this3.loadData();
1690
-
1691
- case 4:
1692
- _yield$_this3$loadDat = _context5.sent;
1693
- intervalTree = _yield$_this3$loadDat.intervalTree;
1694
- (_intervalTree$refName = intervalTree[refName]) === null || _intervalTree$refName === void 0 ? void 0 : _intervalTree$refName.search([start, end]).forEach(function (f) {
1695
- return observer.next(f);
1696
- });
1697
- observer.complete();
1698
- _context5.next = 13;
1699
- break;
1700
-
1701
- case 10:
1702
- _context5.prev = 10;
1703
- _context5.t0 = _context5["catch"](0);
1704
- observer.error(_context5.t0);
1705
-
1706
- case 13:
1707
- case "end":
1708
- return _context5.stop();
1709
- }
1710
- }
1711
- }, _callee5, null, [[0, 10]]);
1712
- }));
1713
-
1714
- return function (_x) {
1715
- return _ref.apply(this, arguments);
1716
- };
1717
- }(), opts.signal);
1718
- }
1719
- }, {
1720
- key: "featureData",
1721
- value: function featureData(data) {
1722
- var _this4 = this;
1723
-
1724
- var f = _objectSpread2({}, data);
1725
-
1726
- f.start -= 1; // convert to interbase
1727
-
1728
- if (data.strand === '+') {
1729
- f.strand = 1;
1730
- } else if (data.strand === '-') {
1731
- f.strand = -1;
1732
- } else if (data.strand === '.') {
1733
- f.strand = 0;
1734
- } else {
1735
- f.strand = undefined;
1736
- }
1737
-
1738
- f.phase = Number(data.phase);
1739
- f.refName = data.seq_id;
1740
-
1741
- if (data.score === null) {
1742
- delete f.score;
1743
- }
1744
-
1745
- if (data.phase === null) {
1746
- delete f.score;
1747
- }
1748
-
1749
- var defaultFields = ['start', 'end', 'seq_id', 'score', 'type', 'source', 'phase', 'strand'];
1750
- var dataAttributes = data.attributes || {};
1751
- Object.keys(dataAttributes).forEach(function (a) {
1752
- var b = a.toLowerCase();
1753
-
1754
- if (defaultFields.includes(b)) {
1755
- // add "suffix" to tag name if it already exists
1756
- // reproduces behavior of NCList
1757
- b += '2';
1758
- }
1759
-
1760
- if (dataAttributes[a] !== null) {
1761
- var attr = dataAttributes[a];
1762
-
1763
- if (Array.isArray(attr) && attr.length === 1) {
1764
- var _attr = attr;
1765
-
1766
- var _attr2 = _slicedToArray(_attr, 1);
1767
-
1768
- attr = _attr2[0];
1769
- }
1770
-
1771
- f[b] = attr;
1772
- }
1773
- });
1774
- f.refName = f.seq_id; // the SimpleFeature constructor takes care of recursively inflating subfeatures
1775
-
1776
- if (data.child_features && data.child_features.length) {
1777
- f.subfeatures = data.child_features.map(function (childLocs) {
1778
- return childLocs.map(function (childLoc) {
1779
- return _this4.featureData(childLoc);
1780
- });
1781
- }).flat();
1782
- }
1783
-
1784
- delete f.child_features;
1785
- delete f.data;
1786
- delete f.derived_features;
1787
- delete f.attributes;
1788
- delete f.seq_id;
1789
- return f;
1790
- }
1791
- }, {
1792
- key: "freeResources",
1793
- value: function
1794
- /* { region } */
1795
- freeResources() {}
1796
- }]);
1797
-
1798
- return _default;
1799
- }(BaseFeatureDataAdapter);
1800
-
1801
- var Gff3Adapter = {
1802
- __proto__: null,
1803
- 'default': _default$2
1804
- };
1805
-
1806
- export default _default;
1807
- //# sourceMappingURL=plugin-gff3.esm.js.map