@jbrowse/plugin-gff3 1.4.3 → 1.5.2
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.
- package/dist/Gff3Adapter/Gff3Adapter.d.ts +17 -0
- package/dist/Gff3Adapter/configSchema.d.ts +2 -0
- package/dist/Gff3Adapter/index.d.ts +1 -0
- package/dist/Gff3TabixAdapter/Gff3TabixAdapter.d.ts +3 -1
- package/dist/plugin-gff3.cjs.development.js +435 -31
- package/dist/plugin-gff3.cjs.development.js.map +1 -1
- package/dist/plugin-gff3.cjs.production.min.js +1 -1
- package/dist/plugin-gff3.cjs.production.min.js.map +1 -1
- package/dist/plugin-gff3.esm.js +435 -31
- package/dist/plugin-gff3.esm.js.map +1 -1
- package/dist/util.d.ts +14 -0
- package/package.json +6 -4
- package/src/Gff3Adapter/Gff3Adapter.test.ts +33 -0
- package/src/Gff3Adapter/Gff3Adapter.ts +164 -0
- package/src/Gff3Adapter/__snapshots__/Gff3Adapter.test.ts.snap +53 -0
- package/src/Gff3Adapter/configSchema.ts +12 -0
- package/src/Gff3Adapter/index.ts +1 -0
- package/src/Gff3TabixAdapter/Gff3TabixAdapter.test.ts +35 -0
- package/src/Gff3TabixAdapter/Gff3TabixAdapter.ts +18 -22
- package/src/Gff3TabixAdapter/__snapshots__/Gff3TabixAdapter.test.ts.snap +53 -0
- package/src/Gff3TabixAdapter/configSchema.ts +5 -2
- package/src/declare.d.ts +1 -0
- package/src/index.ts +66 -1
- package/src/test_data/volvox.sort.gff3 +246 -0
- package/src/test_data/volvox.sort.gff3.gz +0 -0
- package/src/test_data/volvox.sort.gff3.gz.tbi +0 -0
- package/src/util.ts +12 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
+
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
|
+
import IntervalTree from '@flatten-js/interval-tree';
|
|
4
|
+
import { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
5
|
+
export default class extends BaseFeatureDataAdapter {
|
|
6
|
+
protected gffFeatures?: Promise<{
|
|
7
|
+
header: string;
|
|
8
|
+
intervalTree: Record<string, IntervalTree>;
|
|
9
|
+
}>;
|
|
10
|
+
private loadDataP;
|
|
11
|
+
private loadData;
|
|
12
|
+
getRefNames(opts?: BaseOptions): Promise<string[]>;
|
|
13
|
+
getHeader(): Promise<string>;
|
|
14
|
+
getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
15
|
+
private featureData;
|
|
16
|
+
freeResources(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as configSchema } from './configSchema';
|
|
@@ -4,10 +4,12 @@ import { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
|
4
4
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
5
5
|
import { Instance } from 'mobx-state-tree';
|
|
6
6
|
import MyConfigSchema from './configSchema';
|
|
7
|
+
import PluginManager from '@jbrowse/core/PluginManager';
|
|
8
|
+
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
7
9
|
export default class extends BaseFeatureDataAdapter {
|
|
8
10
|
protected gff: TabixIndexedFile;
|
|
9
11
|
protected dontRedispatch: string[];
|
|
10
|
-
constructor(config: Instance<typeof MyConfigSchema
|
|
12
|
+
constructor(config: Instance<typeof MyConfigSchema>, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
|
|
11
13
|
getRefNames(opts?: BaseOptions): Promise<any>;
|
|
12
14
|
getHeader(): Promise<string>;
|
|
13
15
|
getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
@@ -8,6 +8,7 @@ var AdapterType = _interopDefault(require('@jbrowse/core/pluggableElementTypes/A
|
|
|
8
8
|
var Plugin = _interopDefault(require('@jbrowse/core/Plugin'));
|
|
9
9
|
var mobxStateTree = require('mobx-state-tree');
|
|
10
10
|
var configuration = require('@jbrowse/core/configuration');
|
|
11
|
+
var tracks = require('@jbrowse/core/util/tracks');
|
|
11
12
|
var BaseAdapter = require('@jbrowse/core/data_adapters/BaseAdapter');
|
|
12
13
|
var range = require('@jbrowse/core/util/range');
|
|
13
14
|
var io = require('@jbrowse/core/util/io');
|
|
@@ -15,6 +16,8 @@ var rxjs = require('@jbrowse/core/util/rxjs');
|
|
|
15
16
|
var SimpleFeature = _interopDefault(require('@jbrowse/core/util/simpleFeature'));
|
|
16
17
|
var tabix = require('@gmod/tabix');
|
|
17
18
|
var gff = _interopDefault(require('@gmod/gff'));
|
|
19
|
+
var IntervalTree = _interopDefault(require('@flatten-js/interval-tree'));
|
|
20
|
+
var bgzfFilehandle = require('@gmod/bgzf-filehandle');
|
|
18
21
|
|
|
19
22
|
function ownKeys(object, enumerableOnly) {
|
|
20
23
|
var keys = Object.keys(object);
|
|
@@ -182,6 +185,8 @@ function _assertThisInitialized(self) {
|
|
|
182
185
|
function _possibleConstructorReturn(self, call) {
|
|
183
186
|
if (call && (typeof call === "object" || typeof call === "function")) {
|
|
184
187
|
return call;
|
|
188
|
+
} else if (call !== void 0) {
|
|
189
|
+
throw new TypeError("Derived constructors may only return object or undefined");
|
|
185
190
|
}
|
|
186
191
|
|
|
187
192
|
return _assertThisInitialized(self);
|
|
@@ -269,7 +274,8 @@ var gff3TabixAdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchem
|
|
|
269
274
|
gffGzLocation: {
|
|
270
275
|
type: 'fileLocation',
|
|
271
276
|
defaultValue: {
|
|
272
|
-
uri: '/path/to/my.gff.gz'
|
|
277
|
+
uri: '/path/to/my.gff.gz',
|
|
278
|
+
locationType: 'UriLocation'
|
|
273
279
|
}
|
|
274
280
|
},
|
|
275
281
|
index: /*#__PURE__*/configuration.ConfigurationSchema('Gff3TabixIndex', {
|
|
@@ -281,7 +287,8 @@ var gff3TabixAdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchem
|
|
|
281
287
|
location: {
|
|
282
288
|
type: 'fileLocation',
|
|
283
289
|
defaultValue: {
|
|
284
|
-
uri: '/path/to/my.gff.gz.tbi'
|
|
290
|
+
uri: '/path/to/my.gff.gz.tbi',
|
|
291
|
+
locationType: 'UriLocation'
|
|
285
292
|
}
|
|
286
293
|
}
|
|
287
294
|
}),
|
|
@@ -293,6 +300,18 @@ var gff3TabixAdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchem
|
|
|
293
300
|
explicitlyTyped: true
|
|
294
301
|
});
|
|
295
302
|
|
|
303
|
+
var gff3AdapterConfigSchema = /*#__PURE__*/configuration.ConfigurationSchema('Gff3Adapter', {
|
|
304
|
+
gffLocation: {
|
|
305
|
+
type: 'fileLocation',
|
|
306
|
+
defaultValue: {
|
|
307
|
+
uri: '/path/to/my.gff',
|
|
308
|
+
locationType: 'UriLocation'
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}, {
|
|
312
|
+
explicitlyTyped: true
|
|
313
|
+
});
|
|
314
|
+
|
|
296
315
|
var _default = /*#__PURE__*/function (_Plugin) {
|
|
297
316
|
_inherits(_default, _Plugin);
|
|
298
317
|
|
|
@@ -304,7 +323,7 @@ var _default = /*#__PURE__*/function (_Plugin) {
|
|
|
304
323
|
_classCallCheck(this, _default);
|
|
305
324
|
|
|
306
325
|
_this = _super.apply(this, arguments);
|
|
307
|
-
_this.name = '
|
|
326
|
+
_this.name = 'GFF3Plugin';
|
|
308
327
|
return _this;
|
|
309
328
|
}
|
|
310
329
|
|
|
@@ -322,6 +341,55 @@ var _default = /*#__PURE__*/function (_Plugin) {
|
|
|
322
341
|
}
|
|
323
342
|
});
|
|
324
343
|
});
|
|
344
|
+
pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
|
|
345
|
+
return function (file, index, adapterHint) {
|
|
346
|
+
var regexGuess = /\.gff3?\.b?gz$/i;
|
|
347
|
+
var adapterName = 'Gff3TabixAdapter';
|
|
348
|
+
var fileName = tracks.getFileName(file);
|
|
349
|
+
var indexName = index && tracks.getFileName(index);
|
|
350
|
+
|
|
351
|
+
if (regexGuess.test(fileName) || adapterHint === adapterName) {
|
|
352
|
+
return {
|
|
353
|
+
type: adapterName,
|
|
354
|
+
bamLocation: file,
|
|
355
|
+
gffGzLocation: file,
|
|
356
|
+
index: {
|
|
357
|
+
location: index || tracks.makeIndex(file, '.tbi'),
|
|
358
|
+
indexType: tracks.makeIndexType(indexName, 'CSI', 'TBI')
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
return adapterGuesser(file, index, adapterHint);
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
pluginManager.addAdapterType(function () {
|
|
367
|
+
return new AdapterType({
|
|
368
|
+
name: 'Gff3Adapter',
|
|
369
|
+
configSchema: gff3AdapterConfigSchema,
|
|
370
|
+
getAdapterClass: function getAdapterClass() {
|
|
371
|
+
return Promise.resolve().then(function () { return Gff3Adapter; }).then(function (r) {
|
|
372
|
+
return r["default"];
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
|
|
378
|
+
return function (file, index, adapterHint) {
|
|
379
|
+
var regexGuess = /\.gff3?$/i;
|
|
380
|
+
var adapterName = 'Gff3Adapter';
|
|
381
|
+
var fileName = tracks.getFileName(file);
|
|
382
|
+
|
|
383
|
+
if (regexGuess.test(fileName) || adapterHint === adapterName) {
|
|
384
|
+
return {
|
|
385
|
+
type: adapterName,
|
|
386
|
+
gffLocation: file
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
return adapterGuesser(file, index, adapterHint);
|
|
391
|
+
};
|
|
392
|
+
});
|
|
325
393
|
}
|
|
326
394
|
}]);
|
|
327
395
|
|
|
@@ -425,11 +493,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
425
493
|
|
|
426
494
|
|
|
427
495
|
var IteratorPrototype = {};
|
|
428
|
-
|
|
429
|
-
IteratorPrototype[iteratorSymbol] = function () {
|
|
496
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
|
430
497
|
return this;
|
|
431
|
-
};
|
|
432
|
-
|
|
498
|
+
});
|
|
433
499
|
var getProto = Object.getPrototypeOf;
|
|
434
500
|
var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
|
435
501
|
|
|
@@ -440,8 +506,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
440
506
|
}
|
|
441
507
|
|
|
442
508
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
|
443
|
-
GeneratorFunction.prototype =
|
|
444
|
-
|
|
509
|
+
GeneratorFunction.prototype = GeneratorFunctionPrototype;
|
|
510
|
+
define(Gp, "constructor", GeneratorFunctionPrototype);
|
|
511
|
+
define(GeneratorFunctionPrototype, "constructor", GeneratorFunction);
|
|
445
512
|
GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
|
|
446
513
|
// Iterator interface in terms of a single ._invoke method.
|
|
447
514
|
|
|
@@ -546,11 +613,9 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
546
613
|
}
|
|
547
614
|
|
|
548
615
|
defineIteratorMethods(AsyncIterator.prototype);
|
|
549
|
-
|
|
550
|
-
AsyncIterator.prototype[asyncIteratorSymbol] = function () {
|
|
616
|
+
define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
|
551
617
|
return this;
|
|
552
|
-
};
|
|
553
|
-
|
|
618
|
+
});
|
|
554
619
|
exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
|
|
555
620
|
// AsyncIterator objects; they just return a Promise for the value of
|
|
556
621
|
// the final result produced by the iterator.
|
|
@@ -727,13 +792,12 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
727
792
|
// object to not be returned from this call. This ensures that doesn't happen.
|
|
728
793
|
// See https://github.com/facebook/regenerator/issues/274 for more details.
|
|
729
794
|
|
|
730
|
-
Gp
|
|
795
|
+
define(Gp, iteratorSymbol, function () {
|
|
731
796
|
return this;
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
Gp.toString = function () {
|
|
797
|
+
});
|
|
798
|
+
define(Gp, "toString", function () {
|
|
735
799
|
return "[object Generator]";
|
|
736
|
-
};
|
|
800
|
+
});
|
|
737
801
|
|
|
738
802
|
function pushTryEntry(locs) {
|
|
739
803
|
var entry = {
|
|
@@ -1045,14 +1109,19 @@ var runtime_1 = /*#__PURE__*/createCommonjsModule(function (module) {
|
|
|
1045
1109
|
} catch (accidentalStrictMode) {
|
|
1046
1110
|
// This module should not be running in strict mode, so the above
|
|
1047
1111
|
// assignment should always work unless something is misconfigured. Just
|
|
1048
|
-
// in case runtime.js accidentally runs in strict mode,
|
|
1112
|
+
// in case runtime.js accidentally runs in strict mode, in modern engines
|
|
1113
|
+
// we can explicitly access globalThis. In older engines we can escape
|
|
1049
1114
|
// strict mode using a global Function call. This could conceivably fail
|
|
1050
1115
|
// if a Content Security Policy forbids using Function, but in that case
|
|
1051
1116
|
// the proper solution is to fix the accidental strict mode problem. If
|
|
1052
1117
|
// you've misconfigured your bundler to force strict mode and applied a
|
|
1053
1118
|
// CSP to forbid Function, and you're not willing to fix either of those
|
|
1054
1119
|
// problems, please detail your unique predicament in a GitHub issue.
|
|
1055
|
-
|
|
1120
|
+
if (typeof globalThis === "object") {
|
|
1121
|
+
globalThis.regeneratorRuntime = runtime;
|
|
1122
|
+
} else {
|
|
1123
|
+
Function("r", "regeneratorRuntime = r")(runtime);
|
|
1124
|
+
}
|
|
1056
1125
|
}
|
|
1057
1126
|
});
|
|
1058
1127
|
|
|
@@ -1061,21 +1130,21 @@ var _default$1 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
|
1061
1130
|
|
|
1062
1131
|
var _super = /*#__PURE__*/_createSuper(_default);
|
|
1063
1132
|
|
|
1064
|
-
function _default(config) {
|
|
1133
|
+
function _default(config, getSubAdapter, pluginManager) {
|
|
1065
1134
|
var _this;
|
|
1066
1135
|
|
|
1067
1136
|
_classCallCheck(this, _default);
|
|
1068
1137
|
|
|
1069
|
-
_this = _super.call(this, config);
|
|
1138
|
+
_this = _super.call(this, config, getSubAdapter, pluginManager);
|
|
1070
1139
|
var gffGzLocation = configuration.readConfObject(config, 'gffGzLocation');
|
|
1071
1140
|
var indexType = configuration.readConfObject(config, ['index', 'indexType']);
|
|
1072
1141
|
var location = configuration.readConfObject(config, ['index', 'location']);
|
|
1073
1142
|
var dontRedispatch = configuration.readConfObject(config, 'dontRedispatch');
|
|
1074
1143
|
_this.dontRedispatch = dontRedispatch || ['chromosome', 'contig', 'region'];
|
|
1075
1144
|
_this.gff = new tabix.TabixIndexedFile({
|
|
1076
|
-
filehandle: io.openLocation(gffGzLocation),
|
|
1077
|
-
csiFilehandle: indexType === 'CSI' ? io.openLocation(location) : undefined,
|
|
1078
|
-
tbiFilehandle: indexType !== 'CSI' ? io.openLocation(location) : undefined,
|
|
1145
|
+
filehandle: io.openLocation(gffGzLocation, _this.pluginManager),
|
|
1146
|
+
csiFilehandle: indexType === 'CSI' ? io.openLocation(location, _this.pluginManager) : undefined,
|
|
1147
|
+
tbiFilehandle: indexType !== 'CSI' ? io.openLocation(location, _this.pluginManager) : undefined,
|
|
1079
1148
|
chunkCacheSize: 50 * Math.pow(2, 20),
|
|
1080
1149
|
renameRefSeqs: function renameRefSeqs(n) {
|
|
1081
1150
|
return n;
|
|
@@ -1232,9 +1301,6 @@ var _default$1 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
|
1232
1301
|
break;
|
|
1233
1302
|
}
|
|
1234
1303
|
|
|
1235
|
-
// console.log(
|
|
1236
|
-
// `redispatching ${query.start}-${query.end} => ${minStart}-${maxEnd}`,
|
|
1237
|
-
// )
|
|
1238
1304
|
// make a new feature callback to only return top-level features
|
|
1239
1305
|
// in the original query range
|
|
1240
1306
|
this.getFeaturesHelper(_objectSpread2(_objectSpread2({}, query), {}, {
|
|
@@ -1386,9 +1452,9 @@ var _default$1 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
|
1386
1452
|
}
|
|
1387
1453
|
}, {
|
|
1388
1454
|
key: "freeResources",
|
|
1389
|
-
value: function
|
|
1390
|
-
|
|
1391
|
-
{}
|
|
1455
|
+
value: function
|
|
1456
|
+
/* { region } */
|
|
1457
|
+
freeResources() {}
|
|
1392
1458
|
}]);
|
|
1393
1459
|
|
|
1394
1460
|
return _default;
|
|
@@ -1399,5 +1465,343 @@ var Gff3TabixAdapter = {
|
|
|
1399
1465
|
'default': _default$1
|
|
1400
1466
|
};
|
|
1401
1467
|
|
|
1468
|
+
function isGzip(buf) {
|
|
1469
|
+
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
var _default$2 = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
1473
|
+
_inherits(_default, _BaseFeatureDataAdapt);
|
|
1474
|
+
|
|
1475
|
+
var _super = /*#__PURE__*/_createSuper(_default);
|
|
1476
|
+
|
|
1477
|
+
function _default() {
|
|
1478
|
+
_classCallCheck(this, _default);
|
|
1479
|
+
|
|
1480
|
+
return _super.apply(this, arguments);
|
|
1481
|
+
}
|
|
1482
|
+
|
|
1483
|
+
_createClass(_default, [{
|
|
1484
|
+
key: "loadDataP",
|
|
1485
|
+
value: function () {
|
|
1486
|
+
var _loadDataP = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee() {
|
|
1487
|
+
var _this = this;
|
|
1488
|
+
|
|
1489
|
+
var buffer, buf, data, lines, headerLines, i, header, feats, intervalTree;
|
|
1490
|
+
return runtime_1.wrap(function _callee$(_context) {
|
|
1491
|
+
while (1) {
|
|
1492
|
+
switch (_context.prev = _context.next) {
|
|
1493
|
+
case 0:
|
|
1494
|
+
_context.next = 2;
|
|
1495
|
+
return io.openLocation(configuration.readConfObject(this.config, 'gffLocation'), this.pluginManager).readFile();
|
|
1496
|
+
|
|
1497
|
+
case 2:
|
|
1498
|
+
buffer = _context.sent;
|
|
1499
|
+
|
|
1500
|
+
if (!isGzip(buffer)) {
|
|
1501
|
+
_context.next = 9;
|
|
1502
|
+
break;
|
|
1503
|
+
}
|
|
1504
|
+
|
|
1505
|
+
_context.next = 6;
|
|
1506
|
+
return bgzfFilehandle.unzip(buffer);
|
|
1507
|
+
|
|
1508
|
+
case 6:
|
|
1509
|
+
_context.t0 = _context.sent;
|
|
1510
|
+
_context.next = 10;
|
|
1511
|
+
break;
|
|
1512
|
+
|
|
1513
|
+
case 9:
|
|
1514
|
+
_context.t0 = buffer;
|
|
1515
|
+
|
|
1516
|
+
case 10:
|
|
1517
|
+
buf = _context.t0;
|
|
1518
|
+
|
|
1519
|
+
if (!(buf.length > 536870888)) {
|
|
1520
|
+
_context.next = 13;
|
|
1521
|
+
break;
|
|
1522
|
+
}
|
|
1523
|
+
|
|
1524
|
+
throw new Error('Data exceeds maximum string length (512MB)');
|
|
1525
|
+
|
|
1526
|
+
case 13:
|
|
1527
|
+
data = new TextDecoder('utf8', {
|
|
1528
|
+
fatal: true
|
|
1529
|
+
}).decode(buf);
|
|
1530
|
+
lines = data.split('\n');
|
|
1531
|
+
headerLines = [];
|
|
1532
|
+
|
|
1533
|
+
for (i = 0; i < lines.length && lines[i].startsWith('#'); i++) {
|
|
1534
|
+
headerLines.push(lines[i]);
|
|
1535
|
+
}
|
|
1536
|
+
|
|
1537
|
+
header = headerLines.join('\n');
|
|
1538
|
+
feats = gff.parseStringSync(data, {
|
|
1539
|
+
parseFeatures: true,
|
|
1540
|
+
parseComments: false,
|
|
1541
|
+
parseDirectives: false,
|
|
1542
|
+
parseSequences: false
|
|
1543
|
+
});
|
|
1544
|
+
intervalTree = feats.flat().map(function (f, i) {
|
|
1545
|
+
return new SimpleFeature({
|
|
1546
|
+
data: _this.featureData(f),
|
|
1547
|
+
id: "".concat(_this.id, "-offset-").concat(i)
|
|
1548
|
+
});
|
|
1549
|
+
}).reduce(function (acc, obj) {
|
|
1550
|
+
var key = obj.get('refName');
|
|
1551
|
+
|
|
1552
|
+
if (!acc[key]) {
|
|
1553
|
+
acc[key] = new IntervalTree();
|
|
1554
|
+
}
|
|
1555
|
+
|
|
1556
|
+
acc[key].insert([obj.get('start'), obj.get('end')], obj);
|
|
1557
|
+
return acc;
|
|
1558
|
+
}, {});
|
|
1559
|
+
return _context.abrupt("return", {
|
|
1560
|
+
header: header,
|
|
1561
|
+
intervalTree: intervalTree
|
|
1562
|
+
});
|
|
1563
|
+
|
|
1564
|
+
case 21:
|
|
1565
|
+
case "end":
|
|
1566
|
+
return _context.stop();
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
}, _callee, this);
|
|
1570
|
+
}));
|
|
1571
|
+
|
|
1572
|
+
function loadDataP() {
|
|
1573
|
+
return _loadDataP.apply(this, arguments);
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
return loadDataP;
|
|
1577
|
+
}()
|
|
1578
|
+
}, {
|
|
1579
|
+
key: "loadData",
|
|
1580
|
+
value: function () {
|
|
1581
|
+
var _loadData = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2() {
|
|
1582
|
+
var _this2 = this;
|
|
1583
|
+
|
|
1584
|
+
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1585
|
+
while (1) {
|
|
1586
|
+
switch (_context2.prev = _context2.next) {
|
|
1587
|
+
case 0:
|
|
1588
|
+
if (!this.gffFeatures) {
|
|
1589
|
+
this.gffFeatures = this.loadDataP()["catch"](function (e) {
|
|
1590
|
+
_this2.gffFeatures = undefined;
|
|
1591
|
+
throw e;
|
|
1592
|
+
});
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
return _context2.abrupt("return", this.gffFeatures);
|
|
1596
|
+
|
|
1597
|
+
case 2:
|
|
1598
|
+
case "end":
|
|
1599
|
+
return _context2.stop();
|
|
1600
|
+
}
|
|
1601
|
+
}
|
|
1602
|
+
}, _callee2, this);
|
|
1603
|
+
}));
|
|
1604
|
+
|
|
1605
|
+
function loadData() {
|
|
1606
|
+
return _loadData.apply(this, arguments);
|
|
1607
|
+
}
|
|
1608
|
+
|
|
1609
|
+
return loadData;
|
|
1610
|
+
}()
|
|
1611
|
+
}, {
|
|
1612
|
+
key: "getRefNames",
|
|
1613
|
+
value: function () {
|
|
1614
|
+
var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3() {
|
|
1615
|
+
var _yield$this$loadData,
|
|
1616
|
+
intervalTree;
|
|
1617
|
+
|
|
1618
|
+
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1619
|
+
while (1) {
|
|
1620
|
+
switch (_context3.prev = _context3.next) {
|
|
1621
|
+
case 0:
|
|
1622
|
+
_context3.next = 3;
|
|
1623
|
+
return this.loadData();
|
|
1624
|
+
|
|
1625
|
+
case 3:
|
|
1626
|
+
_yield$this$loadData = _context3.sent;
|
|
1627
|
+
intervalTree = _yield$this$loadData.intervalTree;
|
|
1628
|
+
return _context3.abrupt("return", Object.keys(intervalTree));
|
|
1629
|
+
|
|
1630
|
+
case 6:
|
|
1631
|
+
case "end":
|
|
1632
|
+
return _context3.stop();
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}, _callee3, this);
|
|
1636
|
+
}));
|
|
1637
|
+
|
|
1638
|
+
function getRefNames() {
|
|
1639
|
+
return _getRefNames.apply(this, arguments);
|
|
1640
|
+
}
|
|
1641
|
+
|
|
1642
|
+
return getRefNames;
|
|
1643
|
+
}()
|
|
1644
|
+
}, {
|
|
1645
|
+
key: "getHeader",
|
|
1646
|
+
value: function () {
|
|
1647
|
+
var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4() {
|
|
1648
|
+
var _yield$this$loadData2, header;
|
|
1649
|
+
|
|
1650
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1651
|
+
while (1) {
|
|
1652
|
+
switch (_context4.prev = _context4.next) {
|
|
1653
|
+
case 0:
|
|
1654
|
+
_context4.next = 2;
|
|
1655
|
+
return this.loadData();
|
|
1656
|
+
|
|
1657
|
+
case 2:
|
|
1658
|
+
_yield$this$loadData2 = _context4.sent;
|
|
1659
|
+
header = _yield$this$loadData2.header;
|
|
1660
|
+
return _context4.abrupt("return", header);
|
|
1661
|
+
|
|
1662
|
+
case 5:
|
|
1663
|
+
case "end":
|
|
1664
|
+
return _context4.stop();
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1667
|
+
}, _callee4, this);
|
|
1668
|
+
}));
|
|
1669
|
+
|
|
1670
|
+
function getHeader() {
|
|
1671
|
+
return _getHeader.apply(this, arguments);
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
return getHeader;
|
|
1675
|
+
}()
|
|
1676
|
+
}, {
|
|
1677
|
+
key: "getFeatures",
|
|
1678
|
+
value: function getFeatures(query) {
|
|
1679
|
+
var _this3 = this;
|
|
1680
|
+
|
|
1681
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
1682
|
+
return rxjs.ObservableCreate( /*#__PURE__*/function () {
|
|
1683
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(observer) {
|
|
1684
|
+
var _intervalTree$refName, start, end, refName, _yield$_this3$loadDat, intervalTree;
|
|
1685
|
+
|
|
1686
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1687
|
+
while (1) {
|
|
1688
|
+
switch (_context5.prev = _context5.next) {
|
|
1689
|
+
case 0:
|
|
1690
|
+
_context5.prev = 0;
|
|
1691
|
+
start = query.start, end = query.end, refName = query.refName;
|
|
1692
|
+
_context5.next = 4;
|
|
1693
|
+
return _this3.loadData();
|
|
1694
|
+
|
|
1695
|
+
case 4:
|
|
1696
|
+
_yield$_this3$loadDat = _context5.sent;
|
|
1697
|
+
intervalTree = _yield$_this3$loadDat.intervalTree;
|
|
1698
|
+
(_intervalTree$refName = intervalTree[refName]) === null || _intervalTree$refName === void 0 ? void 0 : _intervalTree$refName.search([start, end]).forEach(function (f) {
|
|
1699
|
+
return observer.next(f);
|
|
1700
|
+
});
|
|
1701
|
+
observer.complete();
|
|
1702
|
+
_context5.next = 13;
|
|
1703
|
+
break;
|
|
1704
|
+
|
|
1705
|
+
case 10:
|
|
1706
|
+
_context5.prev = 10;
|
|
1707
|
+
_context5.t0 = _context5["catch"](0);
|
|
1708
|
+
observer.error(_context5.t0);
|
|
1709
|
+
|
|
1710
|
+
case 13:
|
|
1711
|
+
case "end":
|
|
1712
|
+
return _context5.stop();
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}, _callee5, null, [[0, 10]]);
|
|
1716
|
+
}));
|
|
1717
|
+
|
|
1718
|
+
return function (_x) {
|
|
1719
|
+
return _ref.apply(this, arguments);
|
|
1720
|
+
};
|
|
1721
|
+
}(), opts.signal);
|
|
1722
|
+
}
|
|
1723
|
+
}, {
|
|
1724
|
+
key: "featureData",
|
|
1725
|
+
value: function featureData(data) {
|
|
1726
|
+
var _this4 = this;
|
|
1727
|
+
|
|
1728
|
+
var f = _objectSpread2({}, data);
|
|
1729
|
+
|
|
1730
|
+
f.start -= 1; // convert to interbase
|
|
1731
|
+
|
|
1732
|
+
f.strand = {
|
|
1733
|
+
'+': 1,
|
|
1734
|
+
'-': -1,
|
|
1735
|
+
'.': 0,
|
|
1736
|
+
'?': undefined
|
|
1737
|
+
}[data.strand]; // convert strand
|
|
1738
|
+
|
|
1739
|
+
f.phase = Number(data.phase);
|
|
1740
|
+
f.refName = data.seq_id;
|
|
1741
|
+
|
|
1742
|
+
if (data.score === null) {
|
|
1743
|
+
delete f.score;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
if (data.phase === null) {
|
|
1747
|
+
delete f.score;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
var defaultFields = ['start', 'end', 'seq_id', 'score', 'type', 'source', 'phase', 'strand'];
|
|
1751
|
+
Object.keys(data.attributes).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 (data.attributes[a] !== null) {
|
|
1761
|
+
var attr = data.attributes[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
|
+
}(BaseAdapter.BaseFeatureDataAdapter);
|
|
1800
|
+
|
|
1801
|
+
var Gff3Adapter = {
|
|
1802
|
+
__proto__: null,
|
|
1803
|
+
'default': _default$2
|
|
1804
|
+
};
|
|
1805
|
+
|
|
1402
1806
|
exports.default = _default;
|
|
1403
1807
|
//# sourceMappingURL=plugin-gff3.cjs.development.js.map
|