@jbrowse/plugin-bed 1.5.9 → 1.6.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BedTabixAdapter/BedTabixAdapter.d.ts +2 -3
- package/dist/BigBedAdapter/BigBedAdapter.d.ts +33 -11
- package/dist/plugin-bed.cjs.development.js +136 -110
- package/dist/plugin-bed.cjs.development.js.map +1 -1
- package/dist/plugin-bed.cjs.production.min.js +1 -1
- package/dist/plugin-bed.cjs.production.min.js.map +1 -1
- package/dist/plugin-bed.esm.js +136 -110
- package/dist/plugin-bed.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/BedTabixAdapter/BedTabixAdapter.ts +2 -3
- package/src/BigBedAdapter/BigBedAdapter.test.ts +0 -2
- package/src/BigBedAdapter/BigBedAdapter.ts +82 -92
- package/src/index.ts +9 -5
|
@@ -2,9 +2,8 @@ import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters
|
|
|
2
2
|
import { Region } from '@jbrowse/core/util/types';
|
|
3
3
|
import { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
4
4
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
5
|
-
import { Instance } from 'mobx-state-tree';
|
|
6
|
-
import MyConfigSchema from './configSchema';
|
|
7
5
|
import PluginManager from '@jbrowse/core/PluginManager';
|
|
6
|
+
import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema';
|
|
8
7
|
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
9
8
|
export default class BedTabixAdapter extends BaseFeatureDataAdapter {
|
|
10
9
|
private parser;
|
|
@@ -12,7 +11,7 @@ export default class BedTabixAdapter extends BaseFeatureDataAdapter {
|
|
|
12
11
|
protected columnNames: string[];
|
|
13
12
|
protected scoreColumn: string;
|
|
14
13
|
static capabilities: string[];
|
|
15
|
-
constructor(config:
|
|
14
|
+
constructor(config: AnyConfigurationModel, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
|
|
16
15
|
getRefNames(opts?: BaseOptions): Promise<any>;
|
|
17
16
|
getHeader(): Promise<string>;
|
|
18
17
|
defaultParser(fields: string[], line: string): {
|
|
@@ -1,24 +1,46 @@
|
|
|
1
|
+
import { BigBed } from '@gmod/bbi';
|
|
1
2
|
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
3
|
import { Region } from '@jbrowse/core/util/types';
|
|
3
4
|
import { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
interface BEDFeature {
|
|
6
|
+
chrom: string;
|
|
7
|
+
chromStart: number;
|
|
8
|
+
chromEnd: number;
|
|
9
|
+
[key: string]: any;
|
|
10
|
+
}
|
|
11
|
+
interface Parser {
|
|
12
|
+
parseLine: (line: string, opts: {
|
|
13
|
+
uniqueId: string | number;
|
|
14
|
+
}) => BEDFeature;
|
|
15
|
+
autoSql: {
|
|
16
|
+
fields: {
|
|
17
|
+
name: string;
|
|
18
|
+
comment: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
}
|
|
8
22
|
export default class BigBedAdapter extends BaseFeatureDataAdapter {
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
23
|
+
private cached?;
|
|
24
|
+
configurePre(opts?: BaseOptions): Promise<{
|
|
25
|
+
bigbed: BigBed;
|
|
26
|
+
header: any;
|
|
27
|
+
parser: Parser;
|
|
28
|
+
}>;
|
|
29
|
+
configure(opts?: BaseOptions): Promise<{
|
|
30
|
+
bigbed: BigBed;
|
|
31
|
+
header: any;
|
|
32
|
+
parser: Parser;
|
|
33
|
+
}>;
|
|
34
|
+
getRefNames(opts?: BaseOptions): Promise<string[]>;
|
|
13
35
|
getHeader(opts?: BaseOptions): Promise<{
|
|
14
36
|
version: any;
|
|
15
37
|
fileType: any;
|
|
16
|
-
autoSql:
|
|
38
|
+
autoSql: {};
|
|
17
39
|
fields: {
|
|
18
|
-
[k: string]:
|
|
40
|
+
[k: string]: string;
|
|
19
41
|
};
|
|
20
42
|
}>;
|
|
21
|
-
refIdToName(refId: number): Promise<any>;
|
|
22
43
|
getFeatures(region: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
23
44
|
freeResources(): void;
|
|
24
45
|
}
|
|
46
|
+
export {};
|
|
@@ -125,14 +125,14 @@ function _inherits(subClass, superClass) {
|
|
|
125
125
|
throw new TypeError("Super expression must either be null or a function");
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
129
|
+
constructor: {
|
|
130
|
+
value: subClass,
|
|
131
|
+
writable: true,
|
|
132
|
+
configurable: true
|
|
133
|
+
}
|
|
134
|
+
});
|
|
128
135
|
Object.defineProperty(subClass, "prototype", {
|
|
129
|
-
value: Object.create(superClass && superClass.prototype, {
|
|
130
|
-
constructor: {
|
|
131
|
-
value: subClass,
|
|
132
|
-
writable: true,
|
|
133
|
-
configurable: true
|
|
134
|
-
}
|
|
135
|
-
}),
|
|
136
136
|
writable: false
|
|
137
137
|
});
|
|
138
138
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
|
@@ -327,12 +327,15 @@ var BedPlugin = /*#__PURE__*/function (_Plugin) {
|
|
|
327
327
|
var regexGuess = /\.(bb|bigbed)$/i;
|
|
328
328
|
var adapterName = 'BigBedAdapter';
|
|
329
329
|
var fileName = tracks.getFileName(file);
|
|
330
|
+
var obj = {
|
|
331
|
+
type: adapterName,
|
|
332
|
+
bigBedLocation: file
|
|
333
|
+
};
|
|
330
334
|
|
|
331
|
-
if (regexGuess.test(fileName)
|
|
332
|
-
return
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
};
|
|
335
|
+
if (regexGuess.test(fileName) && !adapterHint) {
|
|
336
|
+
return obj;
|
|
337
|
+
} else if (adapterHint === adapterName) {
|
|
338
|
+
return obj;
|
|
336
339
|
}
|
|
337
340
|
|
|
338
341
|
return adapterGuesser(file, index, adapterHint);
|
|
@@ -1222,47 +1225,48 @@ function ucscProcessedTranscript(feature) {
|
|
|
1222
1225
|
var _excluded = ["fields"],
|
|
1223
1226
|
_excluded2 = ["chromStart", "chromEnd", "chrom"];
|
|
1224
1227
|
|
|
1228
|
+
function isUCSC(f) {
|
|
1229
|
+
return f.get('thickStart') && f.get('blockCount') && f.get('strand') !== 0;
|
|
1230
|
+
}
|
|
1231
|
+
|
|
1225
1232
|
var BigBedAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
1226
1233
|
_inherits(BigBedAdapter, _BaseFeatureDataAdapt);
|
|
1227
1234
|
|
|
1228
1235
|
var _super = /*#__PURE__*/_createSuper(BigBedAdapter);
|
|
1229
1236
|
|
|
1230
|
-
function BigBedAdapter(
|
|
1231
|
-
var _this;
|
|
1232
|
-
|
|
1237
|
+
function BigBedAdapter() {
|
|
1233
1238
|
_classCallCheck(this, BigBedAdapter);
|
|
1234
1239
|
|
|
1235
|
-
|
|
1236
|
-
var bigBedLocation = configuration.readConfObject(config, 'bigBedLocation');
|
|
1237
|
-
_this.bigbed = new bbi.BigBed({
|
|
1238
|
-
filehandle: io.openLocation(bigBedLocation, _this.pluginManager)
|
|
1239
|
-
});
|
|
1240
|
-
_this.parser = _this.bigbed.getHeader().then(function (_ref) {
|
|
1241
|
-
var autoSql = _ref.autoSql;
|
|
1242
|
-
return new BED({
|
|
1243
|
-
autoSql: autoSql
|
|
1244
|
-
});
|
|
1245
|
-
});
|
|
1246
|
-
return _this;
|
|
1240
|
+
return _super.apply(this, arguments);
|
|
1247
1241
|
}
|
|
1248
1242
|
|
|
1249
1243
|
_createClass(BigBedAdapter, [{
|
|
1250
|
-
key: "
|
|
1244
|
+
key: "configurePre",
|
|
1251
1245
|
value: function () {
|
|
1252
|
-
var
|
|
1246
|
+
var _configurePre = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(opts) {
|
|
1247
|
+
var bigbed, header, parser;
|
|
1253
1248
|
return runtime_1.wrap(function _callee$(_context) {
|
|
1254
1249
|
while (1) {
|
|
1255
1250
|
switch (_context.prev = _context.next) {
|
|
1256
1251
|
case 0:
|
|
1257
|
-
|
|
1252
|
+
bigbed = new bbi.BigBed({
|
|
1253
|
+
filehandle: io.openLocation(configuration.readConfObject(this.config, 'bigBedLocation'), this.pluginManager)
|
|
1254
|
+
});
|
|
1258
1255
|
_context.next = 3;
|
|
1259
|
-
return
|
|
1256
|
+
return bigbed.getHeader(opts);
|
|
1260
1257
|
|
|
1261
1258
|
case 3:
|
|
1262
|
-
|
|
1263
|
-
|
|
1259
|
+
header = _context.sent;
|
|
1260
|
+
parser = new BED({
|
|
1261
|
+
autoSql: header.autoSql
|
|
1262
|
+
});
|
|
1263
|
+
return _context.abrupt("return", {
|
|
1264
|
+
bigbed: bigbed,
|
|
1265
|
+
header: header,
|
|
1266
|
+
parser: parser
|
|
1267
|
+
});
|
|
1264
1268
|
|
|
1265
|
-
case
|
|
1269
|
+
case 6:
|
|
1266
1270
|
case "end":
|
|
1267
1271
|
return _context.stop();
|
|
1268
1272
|
}
|
|
@@ -1270,50 +1274,32 @@ var BigBedAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
|
1270
1274
|
}, _callee, this);
|
|
1271
1275
|
}));
|
|
1272
1276
|
|
|
1273
|
-
function
|
|
1274
|
-
return
|
|
1277
|
+
function configurePre(_x) {
|
|
1278
|
+
return _configurePre.apply(this, arguments);
|
|
1275
1279
|
}
|
|
1276
1280
|
|
|
1277
|
-
return
|
|
1281
|
+
return configurePre;
|
|
1278
1282
|
}()
|
|
1279
1283
|
}, {
|
|
1280
|
-
key: "
|
|
1284
|
+
key: "configure",
|
|
1281
1285
|
value: function () {
|
|
1282
|
-
var
|
|
1283
|
-
var
|
|
1286
|
+
var _configure = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(opts) {
|
|
1287
|
+
var _this = this;
|
|
1284
1288
|
|
|
1285
1289
|
return runtime_1.wrap(function _callee2$(_context2) {
|
|
1286
1290
|
while (1) {
|
|
1287
1291
|
switch (_context2.prev = _context2.next) {
|
|
1288
1292
|
case 0:
|
|
1289
|
-
|
|
1290
|
-
|
|
1293
|
+
if (!this.cached) {
|
|
1294
|
+
this.cached = this.configurePre(opts)["catch"](function (e) {
|
|
1295
|
+
_this.cached = undefined;
|
|
1296
|
+
throw e;
|
|
1297
|
+
});
|
|
1298
|
+
}
|
|
1291
1299
|
|
|
1292
|
-
|
|
1293
|
-
_yield$this$bigbed$ge = _context2.sent;
|
|
1294
|
-
version = _yield$this$bigbed$ge.version;
|
|
1295
|
-
fileType = _yield$this$bigbed$ge.fileType;
|
|
1296
|
-
_context2.next = 7;
|
|
1297
|
-
return this.parser;
|
|
1298
|
-
|
|
1299
|
-
case 7:
|
|
1300
|
-
_yield$this$parser = _context2.sent;
|
|
1301
|
-
autoSql = _yield$this$parser.autoSql;
|
|
1302
|
-
fields = autoSql.fields, rest = _objectWithoutProperties(autoSql, _excluded);
|
|
1303
|
-
f = Object.fromEntries( // @ts-ignore
|
|
1304
|
-
fields.map(function (_ref2) {
|
|
1305
|
-
var name = _ref2.name,
|
|
1306
|
-
comment = _ref2.comment;
|
|
1307
|
-
return [name, comment];
|
|
1308
|
-
}));
|
|
1309
|
-
return _context2.abrupt("return", {
|
|
1310
|
-
version: version,
|
|
1311
|
-
fileType: fileType,
|
|
1312
|
-
autoSql: _objectSpread2({}, rest),
|
|
1313
|
-
fields: f
|
|
1314
|
-
});
|
|
1300
|
+
return _context2.abrupt("return", this.cached);
|
|
1315
1301
|
|
|
1316
|
-
case
|
|
1302
|
+
case 2:
|
|
1317
1303
|
case "end":
|
|
1318
1304
|
return _context2.stop();
|
|
1319
1305
|
}
|
|
@@ -1321,50 +1307,87 @@ var BigBedAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
|
1321
1307
|
}, _callee2, this);
|
|
1322
1308
|
}));
|
|
1323
1309
|
|
|
1324
|
-
function
|
|
1325
|
-
return
|
|
1310
|
+
function configure(_x2) {
|
|
1311
|
+
return _configure.apply(this, arguments);
|
|
1326
1312
|
}
|
|
1327
1313
|
|
|
1328
|
-
return
|
|
1314
|
+
return configure;
|
|
1329
1315
|
}()
|
|
1330
1316
|
}, {
|
|
1331
|
-
key: "
|
|
1317
|
+
key: "getRefNames",
|
|
1332
1318
|
value: function () {
|
|
1333
|
-
var
|
|
1319
|
+
var _getRefNames = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee3(opts) {
|
|
1320
|
+
var _yield$this$configure, header;
|
|
1321
|
+
|
|
1334
1322
|
return runtime_1.wrap(function _callee3$(_context3) {
|
|
1335
1323
|
while (1) {
|
|
1336
1324
|
switch (_context3.prev = _context3.next) {
|
|
1337
1325
|
case 0:
|
|
1338
1326
|
_context3.next = 2;
|
|
1339
|
-
return this.
|
|
1327
|
+
return this.configure(opts);
|
|
1340
1328
|
|
|
1341
1329
|
case 2:
|
|
1342
|
-
|
|
1343
|
-
|
|
1330
|
+
_yield$this$configure = _context3.sent;
|
|
1331
|
+
header = _yield$this$configure.header;
|
|
1332
|
+
return _context3.abrupt("return", Object.keys(header.refsByName));
|
|
1344
1333
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1334
|
+
case 5:
|
|
1335
|
+
case "end":
|
|
1336
|
+
return _context3.stop();
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
}, _callee3, this);
|
|
1340
|
+
}));
|
|
1349
1341
|
|
|
1350
|
-
|
|
1342
|
+
function getRefNames(_x3) {
|
|
1343
|
+
return _getRefNames.apply(this, arguments);
|
|
1344
|
+
}
|
|
1351
1345
|
|
|
1352
|
-
|
|
1353
|
-
|
|
1346
|
+
return getRefNames;
|
|
1347
|
+
}()
|
|
1348
|
+
}, {
|
|
1349
|
+
key: "getHeader",
|
|
1350
|
+
value: function () {
|
|
1351
|
+
var _getHeader = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee4(opts) {
|
|
1352
|
+
var _yield$this$configure2, parser, header, version, fileType, _parser$autoSql, fields, rest;
|
|
1354
1353
|
|
|
1355
|
-
|
|
1354
|
+
return runtime_1.wrap(function _callee4$(_context4) {
|
|
1355
|
+
while (1) {
|
|
1356
|
+
switch (_context4.prev = _context4.next) {
|
|
1357
|
+
case 0:
|
|
1358
|
+
_context4.next = 2;
|
|
1359
|
+
return this.configure(opts);
|
|
1360
|
+
|
|
1361
|
+
case 2:
|
|
1362
|
+
_yield$this$configure2 = _context4.sent;
|
|
1363
|
+
parser = _yield$this$configure2.parser;
|
|
1364
|
+
header = _yield$this$configure2.header;
|
|
1365
|
+
version = header.version, fileType = header.fileType;
|
|
1366
|
+
_parser$autoSql = parser.autoSql, fields = _parser$autoSql.fields, rest = _objectWithoutProperties(_parser$autoSql, _excluded);
|
|
1367
|
+
return _context4.abrupt("return", {
|
|
1368
|
+
version: version,
|
|
1369
|
+
fileType: fileType,
|
|
1370
|
+
autoSql: _objectSpread2({}, rest),
|
|
1371
|
+
fields: Object.fromEntries(fields.map(function (_ref) {
|
|
1372
|
+
var name = _ref.name,
|
|
1373
|
+
comment = _ref.comment;
|
|
1374
|
+
return [name, comment];
|
|
1375
|
+
}))
|
|
1376
|
+
});
|
|
1377
|
+
|
|
1378
|
+
case 8:
|
|
1356
1379
|
case "end":
|
|
1357
|
-
return
|
|
1380
|
+
return _context4.stop();
|
|
1358
1381
|
}
|
|
1359
1382
|
}
|
|
1360
|
-
},
|
|
1383
|
+
}, _callee4, this);
|
|
1361
1384
|
}));
|
|
1362
1385
|
|
|
1363
|
-
function
|
|
1364
|
-
return
|
|
1386
|
+
function getHeader(_x4) {
|
|
1387
|
+
return _getHeader.apply(this, arguments);
|
|
1365
1388
|
}
|
|
1366
1389
|
|
|
1367
|
-
return
|
|
1390
|
+
return getHeader;
|
|
1368
1391
|
}()
|
|
1369
1392
|
}, {
|
|
1370
1393
|
key: "getFeatures",
|
|
@@ -1377,26 +1400,29 @@ var BigBedAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
|
1377
1400
|
end = region.end;
|
|
1378
1401
|
var signal = opts.signal;
|
|
1379
1402
|
return rxjs.ObservableCreate( /*#__PURE__*/function () {
|
|
1380
|
-
var
|
|
1381
|
-
var parser, ob;
|
|
1382
|
-
|
|
1403
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee5(observer) {
|
|
1404
|
+
var _yield$_this2$configu, parser, bigbed, ob;
|
|
1405
|
+
|
|
1406
|
+
return runtime_1.wrap(function _callee5$(_context5) {
|
|
1383
1407
|
while (1) {
|
|
1384
|
-
switch (
|
|
1408
|
+
switch (_context5.prev = _context5.next) {
|
|
1385
1409
|
case 0:
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
return _this2.
|
|
1410
|
+
_context5.prev = 0;
|
|
1411
|
+
_context5.next = 3;
|
|
1412
|
+
return _this2.configure(opts);
|
|
1389
1413
|
|
|
1390
1414
|
case 3:
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1415
|
+
_yield$_this2$configu = _context5.sent;
|
|
1416
|
+
parser = _yield$_this2$configu.parser;
|
|
1417
|
+
bigbed = _yield$_this2$configu.bigbed;
|
|
1418
|
+
_context5.next = 8;
|
|
1419
|
+
return bigbed.getFeatureStream(refName, start, end, {
|
|
1394
1420
|
signal: signal,
|
|
1395
1421
|
basesPerSpan: end - start
|
|
1396
1422
|
});
|
|
1397
1423
|
|
|
1398
|
-
case
|
|
1399
|
-
ob =
|
|
1424
|
+
case 8:
|
|
1425
|
+
ob = _context5.sent;
|
|
1400
1426
|
ob.pipe(operators.mergeAll(), operators.map(function (r) {
|
|
1401
1427
|
var data = parser.parseLine("".concat(refName, "\t").concat(r.start, "\t").concat(r.end, "\t").concat(r.rest), {
|
|
1402
1428
|
uniqueId: r.uniqueId
|
|
@@ -1441,26 +1467,26 @@ var BigBedAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
|
1441
1467
|
// should be converted to a gene, CNV bigbed has many gene like
|
|
1442
1468
|
// features including thickStart and blockCount but no strand
|
|
1443
1469
|
|
|
1444
|
-
return
|
|
1470
|
+
return isUCSC(f) ? ucscProcessedTranscript(f) : f;
|
|
1445
1471
|
})).subscribe(observer);
|
|
1446
|
-
|
|
1472
|
+
_context5.next = 15;
|
|
1447
1473
|
break;
|
|
1448
1474
|
|
|
1449
|
-
case
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
observer.error(
|
|
1475
|
+
case 12:
|
|
1476
|
+
_context5.prev = 12;
|
|
1477
|
+
_context5.t0 = _context5["catch"](0);
|
|
1478
|
+
observer.error(_context5.t0);
|
|
1453
1479
|
|
|
1454
|
-
case
|
|
1480
|
+
case 15:
|
|
1455
1481
|
case "end":
|
|
1456
|
-
return
|
|
1482
|
+
return _context5.stop();
|
|
1457
1483
|
}
|
|
1458
1484
|
}
|
|
1459
|
-
},
|
|
1485
|
+
}, _callee5, null, [[0, 12]]);
|
|
1460
1486
|
}));
|
|
1461
1487
|
|
|
1462
|
-
return function (
|
|
1463
|
-
return
|
|
1488
|
+
return function (_x5) {
|
|
1489
|
+
return _ref2.apply(this, arguments);
|
|
1464
1490
|
};
|
|
1465
1491
|
}(), opts.signal);
|
|
1466
1492
|
}
|