@jbrowse/plugin-bed 1.6.7 → 1.7.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/BedTabixAdapter/BedTabixAdapter.js +295 -0
- package/dist/BedTabixAdapter/BedTabixAdapter.test.js +276 -0
- package/dist/BedTabixAdapter/configSchema.js +53 -0
- package/dist/BedTabixAdapter/index.js +15 -0
- package/dist/BigBedAdapter/BigBedAdapter.js +341 -0
- package/dist/BigBedAdapter/BigBedAdapter.test.js +63 -0
- package/dist/BigBedAdapter/configSchema.js +22 -0
- package/dist/BigBedAdapter/index.js +15 -0
- package/dist/declare.d.js +1 -0
- package/dist/index.js +135 -6
- package/dist/index.test.js +24 -0
- package/dist/util.js +124 -0
- package/package.json +3 -6
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
+
|
|
12
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
+
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
+
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
+
|
|
18
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
19
|
+
|
|
20
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
+
|
|
22
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
+
|
|
24
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
+
|
|
26
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
+
|
|
28
|
+
var _bed = _interopRequireDefault(require("@gmod/bed"));
|
|
29
|
+
|
|
30
|
+
var _BaseAdapter = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
31
|
+
|
|
32
|
+
var _io = require("@jbrowse/core/util/io");
|
|
33
|
+
|
|
34
|
+
var _rxjs = require("@jbrowse/core/util/rxjs");
|
|
35
|
+
|
|
36
|
+
var _simpleFeature = _interopRequireDefault(require("@jbrowse/core/util/simpleFeature"));
|
|
37
|
+
|
|
38
|
+
var _tabix = require("@gmod/tabix");
|
|
39
|
+
|
|
40
|
+
var _configuration = require("@jbrowse/core/configuration");
|
|
41
|
+
|
|
42
|
+
var _util = require("../util");
|
|
43
|
+
|
|
44
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
45
|
+
|
|
46
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
47
|
+
|
|
48
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
49
|
+
|
|
50
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
51
|
+
|
|
52
|
+
var BedTabixAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
|
|
53
|
+
(0, _inherits2["default"])(BedTabixAdapter, _BaseFeatureDataAdapt);
|
|
54
|
+
|
|
55
|
+
var _super = _createSuper(BedTabixAdapter);
|
|
56
|
+
|
|
57
|
+
function BedTabixAdapter(config, getSubAdapter, pluginManager) {
|
|
58
|
+
var _this;
|
|
59
|
+
|
|
60
|
+
(0, _classCallCheck2["default"])(this, BedTabixAdapter);
|
|
61
|
+
_this = _super.call(this, config, getSubAdapter, pluginManager);
|
|
62
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "parser", void 0);
|
|
63
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "bed", void 0);
|
|
64
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "columnNames", void 0);
|
|
65
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "scoreColumn", void 0);
|
|
66
|
+
var bedGzLocation = (0, _configuration.readConfObject)(config, 'bedGzLocation');
|
|
67
|
+
var index = (0, _configuration.readConfObject)(config, 'index');
|
|
68
|
+
var autoSql = (0, _configuration.readConfObject)(config, 'autoSql');
|
|
69
|
+
var location = index.location,
|
|
70
|
+
indexType = index.indexType;
|
|
71
|
+
_this.bed = new _tabix.TabixIndexedFile({
|
|
72
|
+
filehandle: (0, _io.openLocation)(bedGzLocation, _this.pluginManager),
|
|
73
|
+
csiFilehandle: indexType === 'CSI' ? (0, _io.openLocation)(location, _this.pluginManager) : undefined,
|
|
74
|
+
tbiFilehandle: indexType !== 'CSI' ? (0, _io.openLocation)(location, _this.pluginManager) : undefined,
|
|
75
|
+
chunkCacheSize: 50 * Math.pow(2, 20)
|
|
76
|
+
});
|
|
77
|
+
_this.columnNames = (0, _configuration.readConfObject)(config, 'columnNames');
|
|
78
|
+
_this.scoreColumn = (0, _configuration.readConfObject)(config, 'scoreColumn');
|
|
79
|
+
_this.parser = new _bed["default"]({
|
|
80
|
+
autoSql: autoSql
|
|
81
|
+
});
|
|
82
|
+
return _this;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
(0, _createClass2["default"])(BedTabixAdapter, [{
|
|
86
|
+
key: "getRefNames",
|
|
87
|
+
value: function () {
|
|
88
|
+
var _getRefNames = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
89
|
+
var opts,
|
|
90
|
+
_args = arguments;
|
|
91
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
92
|
+
while (1) {
|
|
93
|
+
switch (_context.prev = _context.next) {
|
|
94
|
+
case 0:
|
|
95
|
+
opts = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
|
|
96
|
+
return _context.abrupt("return", this.bed.getReferenceSequenceNames(opts));
|
|
97
|
+
|
|
98
|
+
case 2:
|
|
99
|
+
case "end":
|
|
100
|
+
return _context.stop();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}, _callee, this);
|
|
104
|
+
}));
|
|
105
|
+
|
|
106
|
+
function getRefNames() {
|
|
107
|
+
return _getRefNames.apply(this, arguments);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return getRefNames;
|
|
111
|
+
}()
|
|
112
|
+
}, {
|
|
113
|
+
key: "getHeader",
|
|
114
|
+
value: function () {
|
|
115
|
+
var _getHeader = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
116
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
117
|
+
while (1) {
|
|
118
|
+
switch (_context2.prev = _context2.next) {
|
|
119
|
+
case 0:
|
|
120
|
+
return _context2.abrupt("return", this.bed.getHeader());
|
|
121
|
+
|
|
122
|
+
case 1:
|
|
123
|
+
case "end":
|
|
124
|
+
return _context2.stop();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}, _callee2, this);
|
|
128
|
+
}));
|
|
129
|
+
|
|
130
|
+
function getHeader() {
|
|
131
|
+
return _getHeader.apply(this, arguments);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
return getHeader;
|
|
135
|
+
}()
|
|
136
|
+
}, {
|
|
137
|
+
key: "defaultParser",
|
|
138
|
+
value: function defaultParser(fields, line) {
|
|
139
|
+
return Object.fromEntries(line.split('\t').map(function (f, i) {
|
|
140
|
+
return [fields[i], f];
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "getNames",
|
|
145
|
+
value: function () {
|
|
146
|
+
var _getNames = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
147
|
+
var header, defs, defline;
|
|
148
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
149
|
+
while (1) {
|
|
150
|
+
switch (_context3.prev = _context3.next) {
|
|
151
|
+
case 0:
|
|
152
|
+
if (!this.columnNames.length) {
|
|
153
|
+
_context3.next = 2;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return _context3.abrupt("return", this.columnNames);
|
|
158
|
+
|
|
159
|
+
case 2:
|
|
160
|
+
_context3.next = 4;
|
|
161
|
+
return this.bed.getHeader();
|
|
162
|
+
|
|
163
|
+
case 4:
|
|
164
|
+
header = _context3.sent;
|
|
165
|
+
defs = header.split('\n').filter(function (f) {
|
|
166
|
+
return !!f;
|
|
167
|
+
});
|
|
168
|
+
defline = defs[defs.length - 1];
|
|
169
|
+
return _context3.abrupt("return", defline && defline.includes('\t') ? defline.slice(1).split('\t').map(function (field) {
|
|
170
|
+
return field.trim();
|
|
171
|
+
}) : null);
|
|
172
|
+
|
|
173
|
+
case 8:
|
|
174
|
+
case "end":
|
|
175
|
+
return _context3.stop();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}, _callee3, this);
|
|
179
|
+
}));
|
|
180
|
+
|
|
181
|
+
function getNames() {
|
|
182
|
+
return _getNames.apply(this, arguments);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return getNames;
|
|
186
|
+
}()
|
|
187
|
+
}, {
|
|
188
|
+
key: "getFeatures",
|
|
189
|
+
value: function getFeatures(query) {
|
|
190
|
+
var _this2 = this;
|
|
191
|
+
|
|
192
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
193
|
+
return (0, _rxjs.ObservableCreate)( /*#__PURE__*/function () {
|
|
194
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(observer) {
|
|
195
|
+
var meta, columnNumbers, colRef, colStart, colEnd, colSame, names;
|
|
196
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
197
|
+
while (1) {
|
|
198
|
+
switch (_context4.prev = _context4.next) {
|
|
199
|
+
case 0:
|
|
200
|
+
_context4.next = 2;
|
|
201
|
+
return _this2.bed.getMetadata();
|
|
202
|
+
|
|
203
|
+
case 2:
|
|
204
|
+
meta = _context4.sent;
|
|
205
|
+
columnNumbers = meta.columnNumbers;
|
|
206
|
+
colRef = columnNumbers.ref - 1;
|
|
207
|
+
colStart = columnNumbers.start - 1;
|
|
208
|
+
colEnd = columnNumbers.end - 1; // colSame handles special case for tabix where a single column is both
|
|
209
|
+
// the start and end, this is assumed to be covering the base at this
|
|
210
|
+
// position (e.g. tabix -s 1 -b 2 -e 2) begin and end are same
|
|
211
|
+
|
|
212
|
+
colSame = colStart === colEnd ? 1 : 0;
|
|
213
|
+
_context4.next = 10;
|
|
214
|
+
return _this2.getNames();
|
|
215
|
+
|
|
216
|
+
case 10:
|
|
217
|
+
names = _context4.sent;
|
|
218
|
+
_context4.next = 13;
|
|
219
|
+
return _this2.bed.getLines(query.refName, query.start, query.end, {
|
|
220
|
+
lineCallback: function lineCallback(line, fileOffset) {
|
|
221
|
+
var l = line.split('\t');
|
|
222
|
+
var refName = l[colRef];
|
|
223
|
+
var start = +l[colStart];
|
|
224
|
+
var end = +l[colEnd] + colSame;
|
|
225
|
+
var uniqueId = "".concat(_this2.id, "-").concat(fileOffset);
|
|
226
|
+
var data = names ? _this2.defaultParser(names, line) : _this2.parser.parseLine(line, {
|
|
227
|
+
uniqueId: uniqueId
|
|
228
|
+
});
|
|
229
|
+
var blockCount = data.blockCount,
|
|
230
|
+
blockSizes = data.blockSizes,
|
|
231
|
+
blockStarts = data.blockStarts,
|
|
232
|
+
chromStarts = data.chromStarts;
|
|
233
|
+
|
|
234
|
+
if (blockCount) {
|
|
235
|
+
var starts = chromStarts || blockStarts || [];
|
|
236
|
+
var sizes = blockSizes;
|
|
237
|
+
var blocksOffset = start;
|
|
238
|
+
data.subfeatures = [];
|
|
239
|
+
|
|
240
|
+
for (var b = 0; b < blockCount; b += 1) {
|
|
241
|
+
var bmin = (starts[b] || 0) + blocksOffset;
|
|
242
|
+
var bmax = bmin + (sizes[b] || 0);
|
|
243
|
+
data.subfeatures.push({
|
|
244
|
+
uniqueId: "".concat(uniqueId, "-").concat(b),
|
|
245
|
+
start: bmin,
|
|
246
|
+
end: bmax,
|
|
247
|
+
type: 'block'
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (_this2.scoreColumn) {
|
|
253
|
+
data.score = +data[_this2.scoreColumn];
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
delete data.chrom;
|
|
257
|
+
delete data.chromStart;
|
|
258
|
+
delete data.chromEnd;
|
|
259
|
+
var f = new _simpleFeature["default"](_objectSpread(_objectSpread({}, data), {}, {
|
|
260
|
+
start: start,
|
|
261
|
+
end: end,
|
|
262
|
+
refName: refName,
|
|
263
|
+
uniqueId: uniqueId
|
|
264
|
+
}));
|
|
265
|
+
var r = f.get('thickStart') ? (0, _util.ucscProcessedTranscript)(f) : f;
|
|
266
|
+
observer.next(r);
|
|
267
|
+
},
|
|
268
|
+
signal: opts.signal
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
case 13:
|
|
272
|
+
observer.complete();
|
|
273
|
+
|
|
274
|
+
case 14:
|
|
275
|
+
case "end":
|
|
276
|
+
return _context4.stop();
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}, _callee4);
|
|
280
|
+
}));
|
|
281
|
+
|
|
282
|
+
return function (_x) {
|
|
283
|
+
return _ref.apply(this, arguments);
|
|
284
|
+
};
|
|
285
|
+
}(), opts.signal);
|
|
286
|
+
}
|
|
287
|
+
}, {
|
|
288
|
+
key: "freeResources",
|
|
289
|
+
value: function freeResources() {}
|
|
290
|
+
}]);
|
|
291
|
+
return BedTabixAdapter;
|
|
292
|
+
}(_BaseAdapter.BaseFeatureDataAdapter);
|
|
293
|
+
|
|
294
|
+
exports["default"] = BedTabixAdapter;
|
|
295
|
+
(0, _defineProperty2["default"])(BedTabixAdapter, "capabilities", ['getFeatures', 'getRefNames']);
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
6
|
+
|
|
7
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
8
|
+
|
|
9
|
+
var _operators = require("rxjs/operators");
|
|
10
|
+
|
|
11
|
+
var _BedTabixAdapter = _interopRequireDefault(require("./BedTabixAdapter"));
|
|
12
|
+
|
|
13
|
+
var _configSchema = _interopRequireDefault(require("./configSchema"));
|
|
14
|
+
|
|
15
|
+
test('adapter can fetch features from volvox-bed12.bed.gz', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
16
|
+
var adapter, features, featuresArray, featuresJsonArray;
|
|
17
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
18
|
+
while (1) {
|
|
19
|
+
switch (_context.prev = _context.next) {
|
|
20
|
+
case 0:
|
|
21
|
+
adapter = new _BedTabixAdapter["default"](_configSchema["default"].create({
|
|
22
|
+
bedGzLocation: {
|
|
23
|
+
localPath: require.resolve('./test_data/volvox-bed12.bed.gz'),
|
|
24
|
+
locationType: 'LocalPathLocation'
|
|
25
|
+
},
|
|
26
|
+
index: {
|
|
27
|
+
location: {
|
|
28
|
+
localPath: require.resolve('./test_data/volvox-bed12.bed.gz.tbi'),
|
|
29
|
+
locationType: 'LocalPathLocation'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}));
|
|
33
|
+
features = adapter.getFeatures({
|
|
34
|
+
refName: 'ctgA',
|
|
35
|
+
start: 0,
|
|
36
|
+
end: 20000,
|
|
37
|
+
assemblyName: 'volvox'
|
|
38
|
+
});
|
|
39
|
+
_context.t0 = expect;
|
|
40
|
+
_context.next = 5;
|
|
41
|
+
return adapter.hasDataForRefName('ctgA');
|
|
42
|
+
|
|
43
|
+
case 5:
|
|
44
|
+
_context.t1 = _context.sent;
|
|
45
|
+
(0, _context.t0)(_context.t1).toBe(true);
|
|
46
|
+
_context.t2 = expect;
|
|
47
|
+
_context.next = 10;
|
|
48
|
+
return adapter.hasDataForRefName('ctgB');
|
|
49
|
+
|
|
50
|
+
case 10:
|
|
51
|
+
_context.t3 = _context.sent;
|
|
52
|
+
(0, _context.t2)(_context.t3).toBe(false);
|
|
53
|
+
_context.next = 14;
|
|
54
|
+
return features.pipe((0, _operators.toArray)()).toPromise();
|
|
55
|
+
|
|
56
|
+
case 14:
|
|
57
|
+
featuresArray = _context.sent;
|
|
58
|
+
featuresJsonArray = featuresArray.map(function (f) {
|
|
59
|
+
return f.toJSON();
|
|
60
|
+
});
|
|
61
|
+
expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
|
|
62
|
+
|
|
63
|
+
case 17:
|
|
64
|
+
case "end":
|
|
65
|
+
return _context.stop();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, _callee);
|
|
69
|
+
})));
|
|
70
|
+
test('adapter can fetch features from volvox.sort.bed.gz simple bed3', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
|
71
|
+
var adapter, features, featuresArray, featuresJsonArray;
|
|
72
|
+
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
|
73
|
+
while (1) {
|
|
74
|
+
switch (_context2.prev = _context2.next) {
|
|
75
|
+
case 0:
|
|
76
|
+
adapter = new _BedTabixAdapter["default"](_configSchema["default"].create({
|
|
77
|
+
bedGzLocation: {
|
|
78
|
+
localPath: require.resolve('./test_data/volvox.sort.bed.gz'),
|
|
79
|
+
locationType: 'LocalPathLocation'
|
|
80
|
+
},
|
|
81
|
+
index: {
|
|
82
|
+
location: {
|
|
83
|
+
localPath: require.resolve('./test_data/volvox.sort.bed.gz.tbi'),
|
|
84
|
+
locationType: 'LocalPathLocation'
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}));
|
|
88
|
+
features = adapter.getFeatures({
|
|
89
|
+
refName: 'contigA',
|
|
90
|
+
start: 0,
|
|
91
|
+
end: 20000,
|
|
92
|
+
assemblyName: 'volvox'
|
|
93
|
+
});
|
|
94
|
+
_context2.t0 = expect;
|
|
95
|
+
_context2.next = 5;
|
|
96
|
+
return adapter.hasDataForRefName('contigA');
|
|
97
|
+
|
|
98
|
+
case 5:
|
|
99
|
+
_context2.t1 = _context2.sent;
|
|
100
|
+
(0, _context2.t0)(_context2.t1).toBe(true);
|
|
101
|
+
_context2.t2 = expect;
|
|
102
|
+
_context2.next = 10;
|
|
103
|
+
return adapter.hasDataForRefName('ctgB');
|
|
104
|
+
|
|
105
|
+
case 10:
|
|
106
|
+
_context2.t3 = _context2.sent;
|
|
107
|
+
(0, _context2.t2)(_context2.t3).toBe(false);
|
|
108
|
+
_context2.next = 14;
|
|
109
|
+
return features.pipe((0, _operators.toArray)()).toPromise();
|
|
110
|
+
|
|
111
|
+
case 14:
|
|
112
|
+
featuresArray = _context2.sent;
|
|
113
|
+
featuresJsonArray = featuresArray.map(function (f) {
|
|
114
|
+
return f.toJSON();
|
|
115
|
+
});
|
|
116
|
+
expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
|
|
117
|
+
|
|
118
|
+
case 17:
|
|
119
|
+
case "end":
|
|
120
|
+
return _context2.stop();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}, _callee2);
|
|
124
|
+
})));
|
|
125
|
+
test('adapter can fetch features bed with autosql', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
126
|
+
var adapter, features, featuresArray, featuresJsonArray;
|
|
127
|
+
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
128
|
+
while (1) {
|
|
129
|
+
switch (_context3.prev = _context3.next) {
|
|
130
|
+
case 0:
|
|
131
|
+
adapter = new _BedTabixAdapter["default"](_configSchema["default"].create({
|
|
132
|
+
bedGzLocation: {
|
|
133
|
+
localPath: require.resolve('./test_data/volvox-autosql.bed.gz'),
|
|
134
|
+
locationType: 'LocalPathLocation'
|
|
135
|
+
},
|
|
136
|
+
index: {
|
|
137
|
+
location: {
|
|
138
|
+
localPath: require.resolve('./test_data/volvox-autosql.bed.gz.tbi'),
|
|
139
|
+
locationType: 'LocalPathLocation'
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
autoSql: "table gdcCancer\n\"somatic variants converted from MAF files obtained through the NCI GDC\"\n (\n string chrom; \"Chromosome (or contig, scaffold, etc.)\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name of item\"\n uint score; \"Score from 0-1000\"\n char[1] strand; \"+ or -\"\n uint thickStart; \"Start of where display should be thick (start codon)\"\n uint thickEnd; \"End of where display should be thick (stop codon)\"\n uint reserved; \"Used as itemRgb as of 2004-11-22\"\n int blockCount; \"Number of blocks\"\n int[blockCount] blockSizes; \"Comma separated list of block sizes\"\n int[blockCount] chromStarts; \"Start positions relative to chromStart\"\n string sampleCount; \"Number of samples with this variant\"\n string freq; \"Variant frequency\"\n lstring Hugo_Symbol; \"Hugo symbol\"\n lstring Entrez_Gene_Id; \"Entrez Gene Id\"\n lstring Variant_Classification; \"Class of variant\"\n lstring Variant_Type; \"Type of variant\"\n lstring Reference_Allele; \"Reference allele\"\n lstring Tumor_Seq_Allele1; \"Tumor allele 1\"\n lstring Tumor_Seq_Allele2; \"Tumor allele 2\"\n lstring dbSNP_RS; \"dbSNP RS number\"\n lstring dbSNP_Val_Status; \"dbSNP validation status\"\n lstring days_to_death; \"Number of days till death\"\n lstring cigarettes_per_day; \"Number of cigarettes per day\"\n lstring weight; \"Weight\"\n lstring alcohol_history; \"Any alcohol consumption?\"\n lstring alcohol_intensity; \"Frequency of alcohol consumption\"\n lstring bmi; \"Body mass index\"\n lstring years_smoked; \"Number of years smoked\"\n lstring height; \"Height\"\n lstring gender; \"Gender\"\n lstring project_id; \"TCGA Project id\"\n lstring ethnicity; \"Ethnicity\"\n lstring Tumor_Sample_Barcode; \"Tumor sample barcode\"\n lstring Matched_Norm_Sample_Barcode; \"Matcheds normal sample barcode\"\n lstring case_id; \"Case ID number\"\n)"
|
|
143
|
+
}));
|
|
144
|
+
features = adapter.getFeatures({
|
|
145
|
+
refName: 'ctgA',
|
|
146
|
+
start: 0,
|
|
147
|
+
end: 20000,
|
|
148
|
+
assemblyName: 'volvox'
|
|
149
|
+
});
|
|
150
|
+
_context3.t0 = expect;
|
|
151
|
+
_context3.next = 5;
|
|
152
|
+
return adapter.hasDataForRefName('ctgA');
|
|
153
|
+
|
|
154
|
+
case 5:
|
|
155
|
+
_context3.t1 = _context3.sent;
|
|
156
|
+
(0, _context3.t0)(_context3.t1).toBe(true);
|
|
157
|
+
_context3.t2 = expect;
|
|
158
|
+
_context3.next = 10;
|
|
159
|
+
return adapter.hasDataForRefName('ctgB');
|
|
160
|
+
|
|
161
|
+
case 10:
|
|
162
|
+
_context3.t3 = _context3.sent;
|
|
163
|
+
(0, _context3.t2)(_context3.t3).toBe(false);
|
|
164
|
+
_context3.next = 14;
|
|
165
|
+
return features.pipe((0, _operators.toArray)()).toPromise();
|
|
166
|
+
|
|
167
|
+
case 14:
|
|
168
|
+
featuresArray = _context3.sent;
|
|
169
|
+
featuresJsonArray = featuresArray.map(function (f) {
|
|
170
|
+
return f.toJSON();
|
|
171
|
+
});
|
|
172
|
+
expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
|
|
173
|
+
|
|
174
|
+
case 17:
|
|
175
|
+
case "end":
|
|
176
|
+
return _context3.stop();
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}, _callee3);
|
|
180
|
+
})));
|
|
181
|
+
test('adapter can fetch bed with header', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
182
|
+
var adapter, features, featuresArray, featuresJsonArray;
|
|
183
|
+
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
184
|
+
while (1) {
|
|
185
|
+
switch (_context4.prev = _context4.next) {
|
|
186
|
+
case 0:
|
|
187
|
+
adapter = new _BedTabixAdapter["default"](_configSchema["default"].create({
|
|
188
|
+
bedGzLocation: {
|
|
189
|
+
localPath: require.resolve('./test_data/volvox.sort.with.header.bed.gz'),
|
|
190
|
+
locationType: 'LocalPathLocation'
|
|
191
|
+
},
|
|
192
|
+
index: {
|
|
193
|
+
location: {
|
|
194
|
+
localPath: require.resolve('./test_data/volvox.sort.with.header.bed.gz.tbi'),
|
|
195
|
+
locationType: 'LocalPathLocation'
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}));
|
|
199
|
+
features = adapter.getFeatures({
|
|
200
|
+
refName: 'contigA',
|
|
201
|
+
start: 0,
|
|
202
|
+
end: 20000,
|
|
203
|
+
assemblyName: 'volvox'
|
|
204
|
+
});
|
|
205
|
+
_context4.t0 = expect;
|
|
206
|
+
_context4.next = 5;
|
|
207
|
+
return adapter.hasDataForRefName('contigA');
|
|
208
|
+
|
|
209
|
+
case 5:
|
|
210
|
+
_context4.t1 = _context4.sent;
|
|
211
|
+
(0, _context4.t0)(_context4.t1).toBe(true);
|
|
212
|
+
_context4.t2 = expect;
|
|
213
|
+
_context4.next = 10;
|
|
214
|
+
return adapter.hasDataForRefName('ctgB');
|
|
215
|
+
|
|
216
|
+
case 10:
|
|
217
|
+
_context4.t3 = _context4.sent;
|
|
218
|
+
(0, _context4.t2)(_context4.t3).toBe(false);
|
|
219
|
+
_context4.next = 14;
|
|
220
|
+
return features.pipe((0, _operators.toArray)()).toPromise();
|
|
221
|
+
|
|
222
|
+
case 14:
|
|
223
|
+
featuresArray = _context4.sent;
|
|
224
|
+
featuresJsonArray = featuresArray.map(function (f) {
|
|
225
|
+
return f.toJSON();
|
|
226
|
+
});
|
|
227
|
+
expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
|
|
228
|
+
|
|
229
|
+
case 17:
|
|
230
|
+
case "end":
|
|
231
|
+
return _context4.stop();
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}, _callee4);
|
|
235
|
+
})));
|
|
236
|
+
test('adapter can use gwas header', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
|
237
|
+
var adapter, features, featuresArray, featuresJsonArray;
|
|
238
|
+
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
239
|
+
while (1) {
|
|
240
|
+
switch (_context5.prev = _context5.next) {
|
|
241
|
+
case 0:
|
|
242
|
+
adapter = new _BedTabixAdapter["default"](_configSchema["default"].create({
|
|
243
|
+
bedGzLocation: {
|
|
244
|
+
localPath: require.resolve('./test_data/gwas.bed.gz'),
|
|
245
|
+
locationType: 'LocalPathLocation'
|
|
246
|
+
},
|
|
247
|
+
index: {
|
|
248
|
+
location: {
|
|
249
|
+
localPath: require.resolve('./test_data/gwas.bed.gz.tbi'),
|
|
250
|
+
locationType: 'LocalPathLocation'
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}));
|
|
254
|
+
features = adapter.getFeatures({
|
|
255
|
+
refName: '1',
|
|
256
|
+
start: 0,
|
|
257
|
+
end: 100000,
|
|
258
|
+
assemblyName: 'hg19'
|
|
259
|
+
});
|
|
260
|
+
_context5.next = 4;
|
|
261
|
+
return features.pipe((0, _operators.toArray)()).toPromise();
|
|
262
|
+
|
|
263
|
+
case 4:
|
|
264
|
+
featuresArray = _context5.sent;
|
|
265
|
+
featuresJsonArray = featuresArray.map(function (f) {
|
|
266
|
+
return f.toJSON();
|
|
267
|
+
});
|
|
268
|
+
expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
|
|
269
|
+
|
|
270
|
+
case 7:
|
|
271
|
+
case "end":
|
|
272
|
+
return _context5.stop();
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}, _callee5);
|
|
276
|
+
})));
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
|
|
8
|
+
var _configuration = require("@jbrowse/core/configuration");
|
|
9
|
+
|
|
10
|
+
var _mobxStateTree = require("mobx-state-tree");
|
|
11
|
+
|
|
12
|
+
var _default = (0, _configuration.ConfigurationSchema)('BedTabixAdapter', {
|
|
13
|
+
bedGzLocation: {
|
|
14
|
+
type: 'fileLocation',
|
|
15
|
+
defaultValue: {
|
|
16
|
+
uri: '/path/to/my.bed.gz',
|
|
17
|
+
locationType: 'UriLocation'
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
index: (0, _configuration.ConfigurationSchema)('TabixIndex', {
|
|
21
|
+
indexType: {
|
|
22
|
+
model: _mobxStateTree.types.enumeration('IndexType', ['TBI', 'CSI']),
|
|
23
|
+
type: 'stringEnum',
|
|
24
|
+
defaultValue: 'TBI'
|
|
25
|
+
},
|
|
26
|
+
location: {
|
|
27
|
+
type: 'fileLocation',
|
|
28
|
+
defaultValue: {
|
|
29
|
+
uri: '/path/to/my.bed.gz.tbi',
|
|
30
|
+
locationType: 'UriLocation'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}),
|
|
34
|
+
columnNames: {
|
|
35
|
+
type: 'stringArray',
|
|
36
|
+
description: 'List of column names',
|
|
37
|
+
defaultValue: []
|
|
38
|
+
},
|
|
39
|
+
scoreColumn: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: 'The column to use as a "score" attribute',
|
|
42
|
+
defaultValue: ''
|
|
43
|
+
},
|
|
44
|
+
autoSql: {
|
|
45
|
+
type: 'string',
|
|
46
|
+
description: 'The autoSql definition for the data fields in the file',
|
|
47
|
+
defaultValue: ''
|
|
48
|
+
}
|
|
49
|
+
}, {
|
|
50
|
+
explicitlyTyped: true
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "configSchema", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _configSchema["default"];
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
var _configSchema = _interopRequireDefault(require("./configSchema"));
|