@jbrowse/plugin-bed 1.7.8 → 1.7.11

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.
@@ -0,0 +1,255 @@
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 _BedAdapter = _interopRequireDefault(require("./BedAdapter"));
12
+
13
+ var _configSchema = _interopRequireDefault(require("./configSchema"));
14
+
15
+ var _webEncoding = require("web-encoding");
16
+
17
+ if (!window.TextDecoder) {
18
+ window.TextDecoder = _webEncoding.TextDecoder;
19
+ }
20
+
21
+ test('adapter can fetch features from volvox-bed12.bed', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
22
+ var adapter, features, featuresArray, featuresJsonArray;
23
+ return _regenerator.default.wrap(function _callee$(_context) {
24
+ while (1) {
25
+ switch (_context.prev = _context.next) {
26
+ case 0:
27
+ adapter = new _BedAdapter.default(_configSchema.default.create({
28
+ bedLocation: {
29
+ localPath: require.resolve('./test_data/volvox-bed12.bed'),
30
+ locationType: 'LocalPathLocation'
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 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 _BedAdapter.default(_configSchema.default.create({
77
+ bedLocation: {
78
+ localPath: require.resolve('./test_data/volvox.sort.bed'),
79
+ locationType: 'LocalPathLocation'
80
+ }
81
+ }));
82
+ features = adapter.getFeatures({
83
+ refName: 'contigA',
84
+ start: 0,
85
+ end: 20000,
86
+ assemblyName: 'volvox'
87
+ });
88
+ _context2.t0 = expect;
89
+ _context2.next = 5;
90
+ return adapter.hasDataForRefName('contigA');
91
+
92
+ case 5:
93
+ _context2.t1 = _context2.sent;
94
+ (0, _context2.t0)(_context2.t1).toBe(true);
95
+ _context2.t2 = expect;
96
+ _context2.next = 10;
97
+ return adapter.hasDataForRefName('ctgB');
98
+
99
+ case 10:
100
+ _context2.t3 = _context2.sent;
101
+ (0, _context2.t2)(_context2.t3).toBe(false);
102
+ _context2.next = 14;
103
+ return features.pipe((0, _operators.toArray)()).toPromise();
104
+
105
+ case 14:
106
+ featuresArray = _context2.sent;
107
+ featuresJsonArray = featuresArray.map(function (f) {
108
+ return f.toJSON();
109
+ });
110
+ expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
111
+
112
+ case 17:
113
+ case "end":
114
+ return _context2.stop();
115
+ }
116
+ }
117
+ }, _callee2);
118
+ })));
119
+ test('adapter can fetch features bed with autosql', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
120
+ var adapter, features, featuresArray, featuresJsonArray;
121
+ return _regenerator.default.wrap(function _callee3$(_context3) {
122
+ while (1) {
123
+ switch (_context3.prev = _context3.next) {
124
+ case 0:
125
+ adapter = new _BedAdapter.default(_configSchema.default.create({
126
+ bedLocation: {
127
+ localPath: require.resolve('./test_data/volvox-autosql.bed'),
128
+ locationType: 'LocalPathLocation'
129
+ },
130
+ 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)"
131
+ }));
132
+ features = adapter.getFeatures({
133
+ refName: 'ctgA',
134
+ start: 0,
135
+ end: 20000,
136
+ assemblyName: 'volvox'
137
+ });
138
+ _context3.t0 = expect;
139
+ _context3.next = 5;
140
+ return adapter.hasDataForRefName('ctgA');
141
+
142
+ case 5:
143
+ _context3.t1 = _context3.sent;
144
+ (0, _context3.t0)(_context3.t1).toBe(true);
145
+ _context3.t2 = expect;
146
+ _context3.next = 10;
147
+ return adapter.hasDataForRefName('ctgB');
148
+
149
+ case 10:
150
+ _context3.t3 = _context3.sent;
151
+ (0, _context3.t2)(_context3.t3).toBe(false);
152
+ _context3.next = 14;
153
+ return features.pipe((0, _operators.toArray)()).toPromise();
154
+
155
+ case 14:
156
+ featuresArray = _context3.sent;
157
+ featuresJsonArray = featuresArray.map(function (f) {
158
+ return f.toJSON();
159
+ });
160
+ expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
161
+
162
+ case 17:
163
+ case "end":
164
+ return _context3.stop();
165
+ }
166
+ }
167
+ }, _callee3);
168
+ })));
169
+ test('adapter can fetch bed with header', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
170
+ var adapter, features, featuresArray, featuresJsonArray;
171
+ return _regenerator.default.wrap(function _callee4$(_context4) {
172
+ while (1) {
173
+ switch (_context4.prev = _context4.next) {
174
+ case 0:
175
+ adapter = new _BedAdapter.default(_configSchema.default.create({
176
+ bedLocation: {
177
+ localPath: require.resolve('./test_data/volvox.sort.with.header.bed'),
178
+ locationType: 'LocalPathLocation'
179
+ }
180
+ }));
181
+ features = adapter.getFeatures({
182
+ refName: 'contigA',
183
+ start: 0,
184
+ end: 20000,
185
+ assemblyName: 'volvox'
186
+ });
187
+ _context4.t0 = expect;
188
+ _context4.next = 5;
189
+ return adapter.hasDataForRefName('contigA');
190
+
191
+ case 5:
192
+ _context4.t1 = _context4.sent;
193
+ (0, _context4.t0)(_context4.t1).toBe(true);
194
+ _context4.t2 = expect;
195
+ _context4.next = 10;
196
+ return adapter.hasDataForRefName('ctgB');
197
+
198
+ case 10:
199
+ _context4.t3 = _context4.sent;
200
+ (0, _context4.t2)(_context4.t3).toBe(false);
201
+ _context4.next = 14;
202
+ return features.pipe((0, _operators.toArray)()).toPromise();
203
+
204
+ case 14:
205
+ featuresArray = _context4.sent;
206
+ featuresJsonArray = featuresArray.map(function (f) {
207
+ return f.toJSON();
208
+ });
209
+ expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
210
+
211
+ case 17:
212
+ case "end":
213
+ return _context4.stop();
214
+ }
215
+ }
216
+ }, _callee4);
217
+ })));
218
+ test('adapter can use gwas header', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
219
+ var adapter, features, featuresArray, featuresJsonArray;
220
+ return _regenerator.default.wrap(function _callee5$(_context5) {
221
+ while (1) {
222
+ switch (_context5.prev = _context5.next) {
223
+ case 0:
224
+ adapter = new _BedAdapter.default(_configSchema.default.create({
225
+ bedLocation: {
226
+ localPath: require.resolve('./test_data/gwas.bed'),
227
+ locationType: 'LocalPathLocation'
228
+ },
229
+ colRef: 0,
230
+ colStart: 1,
231
+ colEnd: 1
232
+ }));
233
+ features = adapter.getFeatures({
234
+ refName: '1',
235
+ start: 0,
236
+ end: 100000,
237
+ assemblyName: 'hg19'
238
+ });
239
+ _context5.next = 4;
240
+ return features.pipe((0, _operators.toArray)()).toPromise();
241
+
242
+ case 4:
243
+ featuresArray = _context5.sent;
244
+ featuresJsonArray = featuresArray.map(function (f) {
245
+ return f.toJSON();
246
+ });
247
+ expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
248
+
249
+ case 7:
250
+ case "end":
251
+ return _context5.stop();
252
+ }
253
+ }
254
+ }, _callee5);
255
+ })));
@@ -0,0 +1,2 @@
1
+ declare const _default: import("@jbrowse/core/configuration").AnyConfigurationSchemaType;
2
+ export default _default;
@@ -0,0 +1,52 @@
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 _default = (0, _configuration.ConfigurationSchema)('BedAdapter', {
11
+ bedLocation: {
12
+ type: 'fileLocation',
13
+ defaultValue: {
14
+ uri: '/path/to/my.bed.gz',
15
+ locationType: 'UriLocation'
16
+ }
17
+ },
18
+ columnNames: {
19
+ type: 'stringArray',
20
+ description: 'List of column names',
21
+ defaultValue: []
22
+ },
23
+ scoreColumn: {
24
+ type: 'string',
25
+ description: 'The column to use as a "score" attribute',
26
+ defaultValue: ''
27
+ },
28
+ autoSql: {
29
+ type: 'string',
30
+ description: 'The autoSql definition for the data fields in the file',
31
+ defaultValue: ''
32
+ },
33
+ colRef: {
34
+ type: 'number',
35
+ description: 'The column to use as a "refName" attribute',
36
+ defaultValue: 0
37
+ },
38
+ colStart: {
39
+ type: 'number',
40
+ description: 'The column to use as a "start" attribute',
41
+ defaultValue: 1
42
+ },
43
+ colEnd: {
44
+ type: 'number',
45
+ description: 'The column to use as a "end" attribute',
46
+ defaultValue: 2
47
+ }
48
+ }, {
49
+ explicitlyTyped: true
50
+ });
51
+
52
+ exports.default = _default;
@@ -0,0 +1 @@
1
+ export { default as configSchema } from './configSchema';
@@ -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"));
@@ -1,9 +1,8 @@
1
1
  import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
2
- import { Region } from '@jbrowse/core/util/types';
3
- import { Feature } from '@jbrowse/core/util/simpleFeature';
2
+ import { Region, Feature } from '@jbrowse/core/util';
4
3
  import { TabixIndexedFile } from '@gmod/tabix';
5
4
  import PluginManager from '@jbrowse/core/PluginManager';
6
- import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema';
5
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration';
7
6
  import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
8
7
  export default class BedTabixAdapter extends BaseFeatureDataAdapter {
9
8
  private parser;
@@ -14,10 +13,7 @@ export default class BedTabixAdapter extends BaseFeatureDataAdapter {
14
13
  constructor(config: AnyConfigurationModel, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
15
14
  getRefNames(opts?: BaseOptions): Promise<any>;
16
15
  getHeader(): Promise<string>;
17
- defaultParser(fields: string[], line: string): {
18
- [k: string]: string;
19
- };
20
- getNames(): Promise<string[] | null>;
16
+ getNames(): Promise<string[] | undefined>;
21
17
  getFeatures(query: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
22
18
  freeResources(): void;
23
19
  }
@@ -33,18 +33,10 @@ var _io = require("@jbrowse/core/util/io");
33
33
 
34
34
  var _rxjs = require("@jbrowse/core/util/rxjs");
35
35
 
36
- var _simpleFeature = _interopRequireDefault(require("@jbrowse/core/util/simpleFeature"));
37
-
38
36
  var _tabix = require("@gmod/tabix");
39
37
 
40
- var _configuration = require("@jbrowse/core/configuration");
41
-
42
38
  var _util = require("../util");
43
39
 
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
40
  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
41
 
50
42
  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; } }
@@ -63,19 +55,24 @@ var BedTabixAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
63
55
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "bed", void 0);
64
56
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "columnNames", void 0);
65
57
  (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;
58
+
59
+ var bedGzLoc = _this.getConf('bedGzLocation');
60
+
61
+ var type = _this.getConf(['index', 'indexType']);
62
+
63
+ var loc = _this.getConf(['index', 'location']);
64
+
65
+ var autoSql = _this.getConf('autoSql');
66
+
67
+ var pm = _this.pluginManager;
71
68
  _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,
69
+ filehandle: (0, _io.openLocation)(bedGzLoc, pm),
70
+ csiFilehandle: type === 'CSI' ? (0, _io.openLocation)(loc, pm) : undefined,
71
+ tbiFilehandle: type !== 'CSI' ? (0, _io.openLocation)(loc, pm) : undefined,
75
72
  chunkCacheSize: 50 * Math.pow(2, 20)
76
73
  });
77
- _this.columnNames = (0, _configuration.readConfObject)(config, 'columnNames');
78
- _this.scoreColumn = (0, _configuration.readConfObject)(config, 'scoreColumn');
74
+ _this.columnNames = _this.getConf('columnNames');
75
+ _this.scoreColumn = _this.getConf('scoreColumn');
79
76
  _this.parser = new _bed.default({
80
77
  autoSql: autoSql
81
78
  });
@@ -133,13 +130,6 @@ var BedTabixAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
133
130
 
134
131
  return getHeader;
135
132
  }()
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
133
  }, {
144
134
  key: "getNames",
145
135
  value: function () {
@@ -166,9 +156,9 @@ var BedTabixAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
166
156
  return !!f;
167
157
  });
168
158
  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);
159
+ return _context3.abrupt("return", defline !== null && defline !== void 0 && defline.includes('\t') ? defline.slice(1).split('\t').map(function (f) {
160
+ return f.trim();
161
+ }) : undefined);
172
162
 
173
163
  case 8:
174
164
  case "end":
@@ -192,7 +182,7 @@ var BedTabixAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
192
182
  var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
193
183
  return (0, _rxjs.ObservableCreate)( /*#__PURE__*/function () {
194
184
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(observer) {
195
- var meta, columnNumbers, colRef, colStart, colEnd, colSame, names;
185
+ var meta, columnNumbers, colRef, colStart, colEnd, names;
196
186
  return _regenerator.default.wrap(function _callee4$(_context4) {
197
187
  while (1) {
198
188
  switch (_context4.prev = _context4.next) {
@@ -209,69 +199,23 @@ var BedTabixAdapter = /*#__PURE__*/function (_BaseFeatureDataAdapt) {
209
199
  // the start and end, this is assumed to be covering the base at this
210
200
  // position (e.g. tabix -s 1 -b 2 -e 2) begin and end are same
211
201
 
212
- colSame = colStart === colEnd ? 1 : 0;
213
- _context4.next = 10;
202
+ _context4.next = 9;
214
203
  return _this2.getNames();
215
204
 
216
- case 10:
205
+ case 9:
217
206
  names = _context4.sent;
218
- _context4.next = 13;
207
+ _context4.next = 12;
219
208
  return _this2.bed.getLines(query.refName, query.start, query.end, {
220
209
  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);
210
+ observer.next((0, _util.featureData)(line, colRef, colStart, colEnd, _this2.scoreColumn, _this2.parser, "".concat(_this2.id, "-").concat(fileOffset), names));
267
211
  },
268
212
  signal: opts.signal
269
213
  });
270
214
 
271
- case 13:
215
+ case 12:
272
216
  observer.complete();
273
217
 
274
- case 14:
218
+ case 13:
275
219
  case "end":
276
220
  return _context4.stop();
277
221
  }
package/dist/index.js CHANGED
@@ -31,6 +31,8 @@ var _BigBedAdapter = require("./BigBedAdapter");
31
31
 
32
32
  var _BedTabixAdapter = require("./BedTabixAdapter");
33
33
 
34
+ var _BedAdapter = require("./BedAdapter");
35
+
34
36
  var _tracks = require("@jbrowse/core/util/tracks");
35
37
 
36
38
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -108,6 +110,19 @@ var BedPlugin = /*#__PURE__*/function (_Plugin) {
108
110
  }
109
111
  });
110
112
  });
113
+ pluginManager.addAdapterType(function () {
114
+ return new _AdapterType.default({
115
+ name: 'BedAdapter',
116
+ configSchema: _BedAdapter.configSchema,
117
+ getAdapterClass: function getAdapterClass() {
118
+ return Promise.resolve().then(function () {
119
+ return _interopRequireWildcard(require('./BedAdapter/BedAdapter'));
120
+ }).then(function (r) {
121
+ return r.default;
122
+ });
123
+ }
124
+ });
125
+ });
111
126
  pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
112
127
  return function (file, index, adapterHint) {
113
128
  var regexGuess = /\.bed\.b?gz$/i;
@@ -126,6 +141,22 @@ var BedPlugin = /*#__PURE__*/function (_Plugin) {
126
141
  };
127
142
  }
128
143
 
144
+ return adapterGuesser(file, index, adapterHint);
145
+ };
146
+ });
147
+ pluginManager.addToExtensionPoint('Core-guessAdapterForLocation', function (adapterGuesser) {
148
+ return function (file, index, adapterHint) {
149
+ var regexGuess = /\.bed$/i;
150
+ var adapterName = 'BedAdapter';
151
+ var fileName = (0, _tracks.getFileName)(file);
152
+
153
+ if (regexGuess.test(fileName) || adapterHint === adapterName) {
154
+ return {
155
+ type: adapterName,
156
+ bedLocation: file
157
+ };
158
+ }
159
+
129
160
  return adapterGuesser(file, index, adapterHint);
130
161
  };
131
162
  });
package/dist/util.d.ts CHANGED
@@ -1,2 +1,4 @@
1
- import SimpleFeature, { Feature } from '@jbrowse/core/util/simpleFeature';
1
+ import { SimpleFeature, Feature } from '@jbrowse/core/util';
2
+ import BED from '@gmod/bed';
2
3
  export declare function ucscProcessedTranscript(feature: Feature): Feature | SimpleFeature;
4
+ export declare function featureData(line: string, colRef: number, colStart: number, colEnd: number, scoreColumn: string, parser: typeof BED, uniqueId: string, names?: string[]): Feature | SimpleFeature;