@jbrowse/plugin-gff3 1.7.9 → 2.0.0
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.js +284 -391
- package/dist/Gff3Adapter/Gff3Adapter.js.map +1 -0
- package/dist/Gff3Adapter/configSchema.js +9 -21
- package/dist/Gff3Adapter/configSchema.js.map +1 -0
- package/dist/Gff3Adapter/index.js +8 -14
- package/dist/Gff3Adapter/index.js.map +1 -0
- package/dist/Gff3TabixAdapter/Gff3TabixAdapter.js +305 -386
- package/dist/Gff3TabixAdapter/Gff3TabixAdapter.js.map +1 -0
- package/dist/Gff3TabixAdapter/configSchema.js +27 -40
- package/dist/Gff3TabixAdapter/configSchema.js.map +1 -0
- package/dist/Gff3TabixAdapter/index.js +8 -14
- package/dist/Gff3TabixAdapter/index.js.map +1 -0
- package/dist/index.js +109 -130
- package/dist/index.js.map +1 -0
- package/esm/Gff3Adapter/Gff3Adapter.d.ts +17 -0
- package/esm/Gff3Adapter/Gff3Adapter.js +146 -0
- package/esm/Gff3Adapter/Gff3Adapter.js.map +1 -0
- package/esm/Gff3Adapter/configSchema.d.ts +2 -0
- package/esm/Gff3Adapter/configSchema.js +8 -0
- package/esm/Gff3Adapter/configSchema.js.map +1 -0
- package/esm/Gff3Adapter/index.d.ts +1 -0
- package/esm/Gff3Adapter/index.js +2 -0
- package/esm/Gff3Adapter/index.js.map +1 -0
- package/esm/Gff3TabixAdapter/Gff3TabixAdapter.d.ts +20 -0
- package/esm/Gff3TabixAdapter/Gff3TabixAdapter.js +186 -0
- package/esm/Gff3TabixAdapter/Gff3TabixAdapter.js.map +1 -0
- package/esm/Gff3TabixAdapter/configSchema.d.ts +2 -0
- package/esm/Gff3TabixAdapter/configSchema.js +27 -0
- package/esm/Gff3TabixAdapter/configSchema.js.map +1 -0
- package/esm/Gff3TabixAdapter/index.d.ts +1 -0
- package/esm/Gff3TabixAdapter/index.js +2 -0
- package/esm/Gff3TabixAdapter/index.js.map +1 -0
- package/esm/index.d.ts +6 -0
- package/esm/index.js +62 -0
- package/esm/index.js.map +1 -0
- package/package.json +17 -9
- package/src/Gff3Adapter/Gff3Adapter.ts +5 -8
- package/dist/Gff3Adapter/Gff3Adapter.test.js +0 -71
- package/dist/Gff3TabixAdapter/Gff3TabixAdapter.test.js +0 -74
|
@@ -1,402 +1,295 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
65
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
66
|
+
if (!m) return o;
|
|
67
|
+
var i = m.call(o), r, ar = [], e;
|
|
68
|
+
try {
|
|
69
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
70
|
+
}
|
|
71
|
+
catch (error) { e = { error: error }; }
|
|
72
|
+
finally {
|
|
73
|
+
try {
|
|
74
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
75
|
+
}
|
|
76
|
+
finally { if (e) throw e.error; }
|
|
77
|
+
}
|
|
78
|
+
return ar;
|
|
79
|
+
};
|
|
80
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
81
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
82
|
+
};
|
|
83
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
84
|
+
var BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
85
|
+
var io_1 = require("@jbrowse/core/util/io");
|
|
86
|
+
var rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
87
|
+
var interval_tree_1 = __importDefault(require("@flatten-js/interval-tree"));
|
|
88
|
+
var simpleFeature_1 = __importDefault(require("@jbrowse/core/util/simpleFeature"));
|
|
89
|
+
var bgzf_filehandle_1 = require("@gmod/bgzf-filehandle");
|
|
90
|
+
var gff_1 = __importDefault(require("@gmod/gff"));
|
|
54
91
|
function isGzip(buf) {
|
|
55
|
-
|
|
92
|
+
return buf[0] === 31 && buf[1] === 139 && buf[2] === 8;
|
|
56
93
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
var _super = _createSuper(_default);
|
|
62
|
-
|
|
63
|
-
function _default() {
|
|
64
|
-
var _this;
|
|
65
|
-
|
|
66
|
-
(0, _classCallCheck2.default)(this, _default);
|
|
67
|
-
|
|
68
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
69
|
-
args[_key] = arguments[_key];
|
|
94
|
+
var default_1 = /** @class */ (function (_super) {
|
|
95
|
+
__extends(default_1, _super);
|
|
96
|
+
function default_1() {
|
|
97
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
70
98
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
99
|
+
default_1.prototype.loadDataP = function () {
|
|
100
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
101
|
+
var pm, buf, buffer, _a, data, lines, headerLines, i, header, feats, intervalTree;
|
|
102
|
+
var _this = this;
|
|
103
|
+
return __generator(this, function (_b) {
|
|
104
|
+
switch (_b.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
pm = this.pluginManager;
|
|
107
|
+
return [4 /*yield*/, (0, io_1.openLocation)(this.getConf('gffLocation'), pm).readFile()];
|
|
108
|
+
case 1:
|
|
109
|
+
buf = _b.sent();
|
|
110
|
+
if (!isGzip(buf)) return [3 /*break*/, 3];
|
|
111
|
+
return [4 /*yield*/, (0, bgzf_filehandle_1.unzip)(buf)];
|
|
112
|
+
case 2:
|
|
113
|
+
_a = _b.sent();
|
|
114
|
+
return [3 /*break*/, 4];
|
|
115
|
+
case 3:
|
|
116
|
+
_a = buf;
|
|
117
|
+
_b.label = 4;
|
|
118
|
+
case 4:
|
|
119
|
+
buffer = _a;
|
|
120
|
+
// 512MB max chrome string length is 512MB
|
|
121
|
+
if (buffer.length > 536870888) {
|
|
122
|
+
throw new Error('Data exceeds maximum string length (512MB)');
|
|
123
|
+
}
|
|
124
|
+
data = new TextDecoder('utf8', { fatal: true }).decode(buffer);
|
|
125
|
+
lines = data.split('\n');
|
|
126
|
+
headerLines = [];
|
|
127
|
+
for (i = 0; i < lines.length && lines[i].startsWith('#'); i++) {
|
|
128
|
+
headerLines.push(lines[i]);
|
|
129
|
+
}
|
|
130
|
+
header = headerLines.join('\n');
|
|
131
|
+
feats = gff_1.default.parseStringSync(data, {
|
|
132
|
+
parseFeatures: true,
|
|
133
|
+
parseComments: false,
|
|
134
|
+
parseDirectives: false,
|
|
135
|
+
parseSequences: false,
|
|
136
|
+
});
|
|
137
|
+
intervalTree = feats
|
|
138
|
+
.flat()
|
|
139
|
+
.map(function (f, i) {
|
|
140
|
+
return new simpleFeature_1.default({
|
|
141
|
+
data: _this.featureData(f),
|
|
142
|
+
id: "".concat(_this.id, "-offset-").concat(i),
|
|
143
|
+
});
|
|
144
|
+
})
|
|
145
|
+
.reduce(function (acc, obj) {
|
|
146
|
+
var key = obj.get('refName');
|
|
147
|
+
if (!acc[key]) {
|
|
148
|
+
acc[key] = new interval_tree_1.default();
|
|
149
|
+
}
|
|
150
|
+
acc[key].insert([obj.get('start'), obj.get('end')], obj);
|
|
151
|
+
return acc;
|
|
152
|
+
}, {});
|
|
153
|
+
return [2 /*return*/, { header: header, intervalTree: intervalTree }];
|
|
97
154
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
case 10:
|
|
111
|
-
buf = _context.t0;
|
|
112
|
-
|
|
113
|
-
if (!(buf.length > 536870888)) {
|
|
114
|
-
_context.next = 13;
|
|
115
|
-
break;
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
default_1.prototype.loadData = function () {
|
|
159
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
160
|
+
var _this = this;
|
|
161
|
+
return __generator(this, function (_a) {
|
|
162
|
+
if (!this.gffFeatures) {
|
|
163
|
+
this.gffFeatures = this.loadDataP().catch(function (e) {
|
|
164
|
+
_this.gffFeatures = undefined;
|
|
165
|
+
throw e;
|
|
166
|
+
});
|
|
116
167
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
168
|
+
return [2 /*return*/, this.gffFeatures];
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
default_1.prototype.getRefNames = function (opts) {
|
|
173
|
+
if (opts === void 0) { opts = {}; }
|
|
174
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175
|
+
var intervalTree;
|
|
176
|
+
return __generator(this, function (_a) {
|
|
177
|
+
switch (_a.label) {
|
|
178
|
+
case 0: return [4 /*yield*/, this.loadData()];
|
|
179
|
+
case 1:
|
|
180
|
+
intervalTree = (_a.sent()).intervalTree;
|
|
181
|
+
return [2 /*return*/, Object.keys(intervalTree)];
|
|
129
182
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
});
|
|
143
|
-
}).reduce(function (acc, obj) {
|
|
144
|
-
var key = obj.get('refName');
|
|
145
|
-
|
|
146
|
-
if (!acc[key]) {
|
|
147
|
-
acc[key] = new _intervalTree.default();
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
acc[key].insert([obj.get('start'), obj.get('end')], obj);
|
|
151
|
-
return acc;
|
|
152
|
-
}, {});
|
|
153
|
-
return _context.abrupt("return", {
|
|
154
|
-
header: header,
|
|
155
|
-
intervalTree: intervalTree
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
case 21:
|
|
159
|
-
case "end":
|
|
160
|
-
return _context.stop();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
}, _callee, this);
|
|
164
|
-
}));
|
|
165
|
-
|
|
166
|
-
function loadDataP() {
|
|
167
|
-
return _loadDataP.apply(this, arguments);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return loadDataP;
|
|
171
|
-
}()
|
|
172
|
-
}, {
|
|
173
|
-
key: "loadData",
|
|
174
|
-
value: function () {
|
|
175
|
-
var _loadData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
176
|
-
var _this3 = this;
|
|
177
|
-
|
|
178
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
179
|
-
while (1) {
|
|
180
|
-
switch (_context2.prev = _context2.next) {
|
|
181
|
-
case 0:
|
|
182
|
-
if (!this.gffFeatures) {
|
|
183
|
-
this.gffFeatures = this.loadDataP().catch(function (e) {
|
|
184
|
-
_this3.gffFeatures = undefined;
|
|
185
|
-
throw e;
|
|
186
|
-
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
};
|
|
186
|
+
default_1.prototype.getHeader = function () {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
188
|
+
var header;
|
|
189
|
+
return __generator(this, function (_a) {
|
|
190
|
+
switch (_a.label) {
|
|
191
|
+
case 0: return [4 /*yield*/, this.loadData()];
|
|
192
|
+
case 1:
|
|
193
|
+
header = (_a.sent()).header;
|
|
194
|
+
return [2 /*return*/, header];
|
|
187
195
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
case 5:
|
|
260
|
-
case "end":
|
|
261
|
-
return _context4.stop();
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
};
|
|
199
|
+
default_1.prototype.getFeatures = function (query, opts) {
|
|
200
|
+
var _this = this;
|
|
201
|
+
if (opts === void 0) { opts = {}; }
|
|
202
|
+
return (0, rxjs_1.ObservableCreate)(function (observer) { return __awaiter(_this, void 0, void 0, function () {
|
|
203
|
+
var start, end, refName, intervalTree, e_1;
|
|
204
|
+
var _a;
|
|
205
|
+
return __generator(this, function (_b) {
|
|
206
|
+
switch (_b.label) {
|
|
207
|
+
case 0:
|
|
208
|
+
_b.trys.push([0, 2, , 3]);
|
|
209
|
+
start = query.start, end = query.end, refName = query.refName;
|
|
210
|
+
return [4 /*yield*/, this.loadData()];
|
|
211
|
+
case 1:
|
|
212
|
+
intervalTree = (_b.sent()).intervalTree;
|
|
213
|
+
(_a = intervalTree[refName]) === null || _a === void 0 ? void 0 : _a.search([start, end]).forEach(function (f) { return observer.next(f); });
|
|
214
|
+
observer.complete();
|
|
215
|
+
return [3 /*break*/, 3];
|
|
216
|
+
case 2:
|
|
217
|
+
e_1 = _b.sent();
|
|
218
|
+
observer.error(e_1);
|
|
219
|
+
return [3 /*break*/, 3];
|
|
220
|
+
case 3: return [2 /*return*/];
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}); }, opts.signal);
|
|
224
|
+
};
|
|
225
|
+
default_1.prototype.featureData = function (data) {
|
|
226
|
+
var _this = this;
|
|
227
|
+
var f = __assign({}, data);
|
|
228
|
+
f.start -= 1; // convert to interbase
|
|
229
|
+
if (data.strand === '+') {
|
|
230
|
+
f.strand = 1;
|
|
231
|
+
}
|
|
232
|
+
else if (data.strand === '-') {
|
|
233
|
+
f.strand = -1;
|
|
234
|
+
}
|
|
235
|
+
else if (data.strand === '.') {
|
|
236
|
+
f.strand = 0;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
f.strand = undefined;
|
|
240
|
+
}
|
|
241
|
+
f.phase = Number(data.phase);
|
|
242
|
+
f.refName = data.seq_id;
|
|
243
|
+
if (data.score === null) {
|
|
244
|
+
delete f.score;
|
|
245
|
+
}
|
|
246
|
+
if (data.phase === null) {
|
|
247
|
+
delete f.score;
|
|
248
|
+
}
|
|
249
|
+
var defaultFields = [
|
|
250
|
+
'start',
|
|
251
|
+
'end',
|
|
252
|
+
'seq_id',
|
|
253
|
+
'score',
|
|
254
|
+
'type',
|
|
255
|
+
'source',
|
|
256
|
+
'phase',
|
|
257
|
+
'strand',
|
|
258
|
+
];
|
|
259
|
+
var dataAttributes = data.attributes || {};
|
|
260
|
+
Object.keys(dataAttributes).forEach(function (a) {
|
|
261
|
+
var _a, _b;
|
|
262
|
+
var b = a.toLowerCase();
|
|
263
|
+
if (defaultFields.includes(b)) {
|
|
264
|
+
// add "suffix" to tag name if it already exists
|
|
265
|
+
// reproduces behavior of NCList
|
|
266
|
+
b += '2';
|
|
262
267
|
}
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
return getHeader;
|
|
272
|
-
}()
|
|
273
|
-
}, {
|
|
274
|
-
key: "getFeatures",
|
|
275
|
-
value: function getFeatures(query) {
|
|
276
|
-
var _this4 = this;
|
|
277
|
-
|
|
278
|
-
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
279
|
-
return (0, _rxjs.ObservableCreate)( /*#__PURE__*/function () {
|
|
280
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(observer) {
|
|
281
|
-
var _intervalTree$refName, start, end, refName, _yield$_this4$loadDat, intervalTree;
|
|
282
|
-
|
|
283
|
-
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
284
|
-
while (1) {
|
|
285
|
-
switch (_context5.prev = _context5.next) {
|
|
286
|
-
case 0:
|
|
287
|
-
_context5.prev = 0;
|
|
288
|
-
start = query.start, end = query.end, refName = query.refName;
|
|
289
|
-
_context5.next = 4;
|
|
290
|
-
return _this4.loadData();
|
|
291
|
-
|
|
292
|
-
case 4:
|
|
293
|
-
_yield$_this4$loadDat = _context5.sent;
|
|
294
|
-
intervalTree = _yield$_this4$loadDat.intervalTree;
|
|
295
|
-
(_intervalTree$refName = intervalTree[refName]) === null || _intervalTree$refName === void 0 ? void 0 : _intervalTree$refName.search([start, end]).forEach(function (f) {
|
|
296
|
-
return observer.next(f);
|
|
297
|
-
});
|
|
298
|
-
observer.complete();
|
|
299
|
-
_context5.next = 13;
|
|
300
|
-
break;
|
|
301
|
-
|
|
302
|
-
case 10:
|
|
303
|
-
_context5.prev = 10;
|
|
304
|
-
_context5.t0 = _context5["catch"](0);
|
|
305
|
-
observer.error(_context5.t0);
|
|
306
|
-
|
|
307
|
-
case 13:
|
|
308
|
-
case "end":
|
|
309
|
-
return _context5.stop();
|
|
310
|
-
}
|
|
268
|
+
if (dataAttributes[a] !== null) {
|
|
269
|
+
var attr = dataAttributes[a];
|
|
270
|
+
if (Array.isArray(attr) && attr.length === 1) {
|
|
271
|
+
;
|
|
272
|
+
_a = attr, _b = __read(_a, 1), attr = _b[0];
|
|
273
|
+
}
|
|
274
|
+
f[b] = attr;
|
|
311
275
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
}, {
|
|
321
|
-
key: "featureData",
|
|
322
|
-
value: function featureData(data) {
|
|
323
|
-
var _this5 = this;
|
|
324
|
-
|
|
325
|
-
var f = _objectSpread({}, data);
|
|
326
|
-
|
|
327
|
-
f.start -= 1; // convert to interbase
|
|
328
|
-
|
|
329
|
-
if (data.strand === '+') {
|
|
330
|
-
f.strand = 1;
|
|
331
|
-
} else if (data.strand === '-') {
|
|
332
|
-
f.strand = -1;
|
|
333
|
-
} else if (data.strand === '.') {
|
|
334
|
-
f.strand = 0;
|
|
335
|
-
} else {
|
|
336
|
-
f.strand = undefined;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
f.phase = Number(data.phase);
|
|
340
|
-
f.refName = data.seq_id;
|
|
341
|
-
|
|
342
|
-
if (data.score === null) {
|
|
343
|
-
delete f.score;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
if (data.phase === null) {
|
|
347
|
-
delete f.score;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
var defaultFields = ['start', 'end', 'seq_id', 'score', 'type', 'source', 'phase', 'strand'];
|
|
351
|
-
var dataAttributes = data.attributes || {};
|
|
352
|
-
Object.keys(dataAttributes).forEach(function (a) {
|
|
353
|
-
var b = a.toLowerCase();
|
|
354
|
-
|
|
355
|
-
if (defaultFields.includes(b)) {
|
|
356
|
-
// add "suffix" to tag name if it already exists
|
|
357
|
-
// reproduces behavior of NCList
|
|
358
|
-
b += '2';
|
|
276
|
+
});
|
|
277
|
+
f.refName = f.seq_id;
|
|
278
|
+
// the SimpleFeature constructor takes care of recursively inflating subfeatures
|
|
279
|
+
if (data.child_features && data.child_features.length) {
|
|
280
|
+
f.subfeatures = data.child_features
|
|
281
|
+
.map(function (childLocs) { return childLocs.map(function (childLoc) { return _this.featureData(childLoc); }); })
|
|
282
|
+
.flat();
|
|
359
283
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
f[b] = attr;
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
f.refName = f.seq_id; // the SimpleFeature constructor takes care of recursively inflating subfeatures
|
|
377
|
-
|
|
378
|
-
if (data.child_features && data.child_features.length) {
|
|
379
|
-
f.subfeatures = data.child_features.map(function (childLocs) {
|
|
380
|
-
return childLocs.map(function (childLoc) {
|
|
381
|
-
return _this5.featureData(childLoc);
|
|
382
|
-
});
|
|
383
|
-
}).flat();
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
delete f.child_features;
|
|
387
|
-
delete f.data;
|
|
388
|
-
delete f.derived_features;
|
|
389
|
-
delete f.attributes;
|
|
390
|
-
delete f.seq_id;
|
|
391
|
-
return f;
|
|
392
|
-
}
|
|
393
|
-
}, {
|
|
394
|
-
key: "freeResources",
|
|
395
|
-
value: function
|
|
396
|
-
/* { region } */
|
|
397
|
-
freeResources() {}
|
|
398
|
-
}]);
|
|
399
|
-
return _default;
|
|
400
|
-
}(_BaseAdapter.BaseFeatureDataAdapter);
|
|
401
|
-
|
|
402
|
-
exports.default = _default;
|
|
284
|
+
delete f.child_features;
|
|
285
|
+
delete f.data;
|
|
286
|
+
delete f.derived_features;
|
|
287
|
+
delete f.attributes;
|
|
288
|
+
delete f.seq_id;
|
|
289
|
+
return f;
|
|
290
|
+
};
|
|
291
|
+
default_1.prototype.freeResources = function ( /* { region } */) { };
|
|
292
|
+
return default_1;
|
|
293
|
+
}(BaseAdapter_1.BaseFeatureDataAdapter));
|
|
294
|
+
exports.default = default_1;
|
|
295
|
+
//# sourceMappingURL=Gff3Adapter.js.map
|