@jbrowse/plugin-sequence 1.7.6 → 1.7.9
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/BgzipFastaAdapter/configSchema.js +8 -0
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.d.ts +4 -2
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.js +69 -18
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.test.js +13 -3
- package/dist/IndexedFastaAdapter/configSchema.js +8 -0
- package/package.json +2 -2
- package/src/BgzipFastaAdapter/configSchema.ts +8 -0
- package/src/IndexedFastaAdapter/IndexedFastaAdapter.test.ts +7 -0
- package/src/IndexedFastaAdapter/IndexedFastaAdapter.ts +26 -5
- package/src/IndexedFastaAdapter/configSchema.ts +8 -0
|
@@ -22,6 +22,14 @@ var _default = (0, _configuration.ConfigurationSchema)('BgzipFastaAdapter', {
|
|
|
22
22
|
locationType: 'UriLocation'
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
+
metadataLocation: {
|
|
26
|
+
description: 'Optional metadata file',
|
|
27
|
+
type: 'fileLocation',
|
|
28
|
+
defaultValue: {
|
|
29
|
+
uri: '/path/to/fa.metadata.yaml',
|
|
30
|
+
locationType: 'UriLocation'
|
|
31
|
+
}
|
|
32
|
+
},
|
|
25
33
|
gziLocation: {
|
|
26
34
|
type: 'fileLocation',
|
|
27
35
|
defaultValue: {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { IndexedFasta } from '@gmod/indexedfasta';
|
|
2
2
|
import { BaseSequenceAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
3
|
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
4
|
-
import { Feature } from '@jbrowse/core/util
|
|
5
|
-
import { AnyConfigurationModel } from '@jbrowse/core/configuration
|
|
4
|
+
import { Feature } from '@jbrowse/core/util';
|
|
5
|
+
import { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
6
6
|
import PluginManager from '@jbrowse/core/PluginManager';
|
|
7
7
|
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
8
8
|
export default class extends BaseSequenceAdapter {
|
|
9
9
|
protected fasta: IndexedFasta;
|
|
10
|
+
protected header?: Promise<string>;
|
|
10
11
|
private seqCache;
|
|
11
12
|
constructor(config: AnyConfigurationModel, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
|
|
12
13
|
getRefNames(opts?: BaseOptions): Promise<string[]>;
|
|
@@ -15,6 +16,7 @@ export default class extends BaseSequenceAdapter {
|
|
|
15
16
|
start: number;
|
|
16
17
|
end: number;
|
|
17
18
|
}[]>;
|
|
19
|
+
getHeader(): Promise<string | null>;
|
|
18
20
|
getFeatures(region: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
19
21
|
/**
|
|
20
22
|
* called to provide a hint that data tied to a certain region
|
|
@@ -33,9 +33,7 @@ var _io = require("@jbrowse/core/util/io");
|
|
|
33
33
|
|
|
34
34
|
var _rxjs = require("@jbrowse/core/util/rxjs");
|
|
35
35
|
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
var _configuration = require("@jbrowse/core/configuration");
|
|
36
|
+
var _util = require("@jbrowse/core/util");
|
|
39
37
|
|
|
40
38
|
var _abortablePromiseCache = _interopRequireDefault(require("abortable-promise-cache"));
|
|
41
39
|
|
|
@@ -60,6 +58,7 @@ var _default = /*#__PURE__*/function (_BaseSequenceAdapter) {
|
|
|
60
58
|
(0, _classCallCheck2.default)(this, _default);
|
|
61
59
|
_this = _super.call(this, config, getSubAdapter, pluginManager);
|
|
62
60
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fasta", void 0);
|
|
61
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "header", void 0);
|
|
63
62
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "seqCache", new _abortablePromiseCache.default({
|
|
64
63
|
cache: new _QuickLRU.default({
|
|
65
64
|
maxSize: 200
|
|
@@ -91,8 +90,11 @@ var _default = /*#__PURE__*/function (_BaseSequenceAdapter) {
|
|
|
91
90
|
return fill;
|
|
92
91
|
}()
|
|
93
92
|
}));
|
|
94
|
-
|
|
95
|
-
var
|
|
93
|
+
|
|
94
|
+
var fastaLocation = _this.getConf('fastaLocation');
|
|
95
|
+
|
|
96
|
+
var faiLocation = _this.getConf('faiLocation');
|
|
97
|
+
|
|
96
98
|
var fastaOpts = {
|
|
97
99
|
fasta: (0, _io.openLocation)(fastaLocation, _this.pluginManager),
|
|
98
100
|
fai: (0, _io.openLocation)(faiLocation, _this.pluginManager)
|
|
@@ -142,26 +144,75 @@ var _default = /*#__PURE__*/function (_BaseSequenceAdapter) {
|
|
|
142
144
|
|
|
143
145
|
return getRegions;
|
|
144
146
|
}()
|
|
147
|
+
}, {
|
|
148
|
+
key: "getHeader",
|
|
149
|
+
value: function () {
|
|
150
|
+
var _getHeader = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
151
|
+
var _this2 = this;
|
|
152
|
+
|
|
153
|
+
var loc;
|
|
154
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
155
|
+
while (1) {
|
|
156
|
+
switch (_context3.prev = _context3.next) {
|
|
157
|
+
case 0:
|
|
158
|
+
if (!this.header) {
|
|
159
|
+
_context3.next = 2;
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return _context3.abrupt("return", this.header);
|
|
164
|
+
|
|
165
|
+
case 2:
|
|
166
|
+
loc = this.getConf('metadataLocation');
|
|
167
|
+
|
|
168
|
+
if (!(loc.uri === '' || loc.uri === '/path/to/fa.metadata.yaml')) {
|
|
169
|
+
_context3.next = 5;
|
|
170
|
+
break;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return _context3.abrupt("return", null);
|
|
174
|
+
|
|
175
|
+
case 5:
|
|
176
|
+
this.header = (0, _io.openLocation)(loc).readFile('utf8').catch(function (e) {
|
|
177
|
+
_this2.header = undefined;
|
|
178
|
+
throw e;
|
|
179
|
+
});
|
|
180
|
+
return _context3.abrupt("return", this.header);
|
|
181
|
+
|
|
182
|
+
case 7:
|
|
183
|
+
case "end":
|
|
184
|
+
return _context3.stop();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}, _callee3, this);
|
|
188
|
+
}));
|
|
189
|
+
|
|
190
|
+
function getHeader() {
|
|
191
|
+
return _getHeader.apply(this, arguments);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return getHeader;
|
|
195
|
+
}()
|
|
145
196
|
}, {
|
|
146
197
|
key: "getFeatures",
|
|
147
198
|
value: function getFeatures(region, opts) {
|
|
148
|
-
var
|
|
199
|
+
var _this3 = this;
|
|
149
200
|
|
|
150
201
|
var refName = region.refName,
|
|
151
202
|
start = region.start,
|
|
152
203
|
end = region.end;
|
|
153
204
|
return (0, _rxjs.ObservableCreate)( /*#__PURE__*/function () {
|
|
154
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function
|
|
205
|
+
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4(observer) {
|
|
155
206
|
var size, regionEnd, chunks, chunkSize, s, e, chunkStart, r, seq;
|
|
156
|
-
return _regenerator.default.wrap(function
|
|
207
|
+
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
157
208
|
while (1) {
|
|
158
|
-
switch (
|
|
209
|
+
switch (_context4.prev = _context4.next) {
|
|
159
210
|
case 0:
|
|
160
|
-
|
|
161
|
-
return
|
|
211
|
+
_context4.next = 2;
|
|
212
|
+
return _this3.fasta.getSequenceSize(refName, opts);
|
|
162
213
|
|
|
163
214
|
case 2:
|
|
164
|
-
size =
|
|
215
|
+
size = _context4.sent;
|
|
165
216
|
regionEnd = size !== undefined ? Math.min(size, end) : end;
|
|
166
217
|
chunks = [];
|
|
167
218
|
chunkSize = 128000;
|
|
@@ -174,17 +225,17 @@ var _default = /*#__PURE__*/function (_BaseSequenceAdapter) {
|
|
|
174
225
|
start: chunkStart,
|
|
175
226
|
end: chunkStart + chunkSize
|
|
176
227
|
};
|
|
177
|
-
chunks.push(
|
|
228
|
+
chunks.push(_this3.seqCache.get(JSON.stringify(r), r, opts === null || opts === void 0 ? void 0 : opts.signal));
|
|
178
229
|
}
|
|
179
230
|
|
|
180
|
-
|
|
231
|
+
_context4.next = 11;
|
|
181
232
|
return Promise.all(chunks);
|
|
182
233
|
|
|
183
234
|
case 11:
|
|
184
|
-
seq =
|
|
235
|
+
seq = _context4.sent.join('').slice(start - s).slice(0, end - start);
|
|
185
236
|
|
|
186
237
|
if (seq) {
|
|
187
|
-
observer.next(new
|
|
238
|
+
observer.next(new _util.SimpleFeature({
|
|
188
239
|
id: "".concat(refName, " ").concat(start, "-").concat(regionEnd),
|
|
189
240
|
data: {
|
|
190
241
|
refName: refName,
|
|
@@ -199,10 +250,10 @@ var _default = /*#__PURE__*/function (_BaseSequenceAdapter) {
|
|
|
199
250
|
|
|
200
251
|
case 14:
|
|
201
252
|
case "end":
|
|
202
|
-
return
|
|
253
|
+
return _context4.stop();
|
|
203
254
|
}
|
|
204
255
|
}
|
|
205
|
-
},
|
|
256
|
+
}, _callee4);
|
|
206
257
|
}));
|
|
207
258
|
|
|
208
259
|
return function (_x4) {
|
|
@@ -13,7 +13,7 @@ var _IndexedFastaAdapter = _interopRequireDefault(require("./IndexedFastaAdapter
|
|
|
13
13
|
var _configSchema = _interopRequireDefault(require("./configSchema"));
|
|
14
14
|
|
|
15
15
|
test('adapter can fetch sequence from volvox.fa', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
16
|
-
var adapter, features, featuresArray, features2, featuresArray2, features3, featuresArray3;
|
|
16
|
+
var adapter, features, featuresArray, features2, featuresArray2, features3, data, featuresArray3;
|
|
17
17
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
18
18
|
while (1) {
|
|
19
19
|
switch (_context.prev = _context.next) {
|
|
@@ -26,6 +26,10 @@ test('adapter can fetch sequence from volvox.fa', /*#__PURE__*/(0, _asyncToGener
|
|
|
26
26
|
faiLocation: {
|
|
27
27
|
localPath: require.resolve('../../test_data/volvox.fa.fai'),
|
|
28
28
|
locationType: 'LocalPathLocation'
|
|
29
|
+
},
|
|
30
|
+
metadataLocation: {
|
|
31
|
+
localPath: require.resolve('../../test_data/hello.txt'),
|
|
32
|
+
locationType: 'LocalPathLocation'
|
|
29
33
|
}
|
|
30
34
|
}));
|
|
31
35
|
features = adapter.getFeatures({
|
|
@@ -56,13 +60,19 @@ test('adapter can fetch sequence from volvox.fa', /*#__PURE__*/(0, _asyncToGener
|
|
|
56
60
|
end: 20000
|
|
57
61
|
});
|
|
58
62
|
_context.next = 14;
|
|
59
|
-
return
|
|
63
|
+
return adapter.getHeader();
|
|
60
64
|
|
|
61
65
|
case 14:
|
|
66
|
+
data = _context.sent;
|
|
67
|
+
expect(data === null || data === void 0 ? void 0 : data.trim()).toBe('hello world');
|
|
68
|
+
_context.next = 18;
|
|
69
|
+
return features3.pipe((0, _operators.toArray)()).toPromise();
|
|
70
|
+
|
|
71
|
+
case 18:
|
|
62
72
|
featuresArray3 = _context.sent;
|
|
63
73
|
expect(featuresArray3).toMatchSnapshot();
|
|
64
74
|
|
|
65
|
-
case
|
|
75
|
+
case 20:
|
|
66
76
|
case "end":
|
|
67
77
|
return _context.stop();
|
|
68
78
|
}
|
|
@@ -21,6 +21,14 @@ var _default = (0, _configuration.ConfigurationSchema)('IndexedFastaAdapter', {
|
|
|
21
21
|
uri: '/path/to/seq.fa.fai',
|
|
22
22
|
locationType: 'UriLocation'
|
|
23
23
|
}
|
|
24
|
+
},
|
|
25
|
+
metadataLocation: {
|
|
26
|
+
description: 'Optional metadata file',
|
|
27
|
+
type: 'fileLocation',
|
|
28
|
+
defaultValue: {
|
|
29
|
+
uri: '/path/to/fa.metadata.yaml',
|
|
30
|
+
locationType: 'UriLocation'
|
|
31
|
+
}
|
|
24
32
|
}
|
|
25
33
|
}, {
|
|
26
34
|
explicitlyTyped: true
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-sequence",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.9",
|
|
4
4
|
"description": "JBrowse 2 sequence adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "a6504c385d703ce6e755d05652ef659ffe28c864"
|
|
57
57
|
}
|
|
@@ -14,6 +14,14 @@ export default ConfigurationSchema(
|
|
|
14
14
|
locationType: 'UriLocation',
|
|
15
15
|
},
|
|
16
16
|
},
|
|
17
|
+
metadataLocation: {
|
|
18
|
+
description: 'Optional metadata file',
|
|
19
|
+
type: 'fileLocation',
|
|
20
|
+
defaultValue: {
|
|
21
|
+
uri: '/path/to/fa.metadata.yaml',
|
|
22
|
+
locationType: 'UriLocation',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
17
25
|
gziLocation: {
|
|
18
26
|
type: 'fileLocation',
|
|
19
27
|
defaultValue: {
|
|
@@ -13,6 +13,10 @@ test('adapter can fetch sequence from volvox.fa', async () => {
|
|
|
13
13
|
localPath: require.resolve('../../test_data/volvox.fa.fai'),
|
|
14
14
|
locationType: 'LocalPathLocation',
|
|
15
15
|
},
|
|
16
|
+
metadataLocation: {
|
|
17
|
+
localPath: require.resolve('../../test_data/hello.txt'),
|
|
18
|
+
locationType: 'LocalPathLocation',
|
|
19
|
+
},
|
|
16
20
|
}),
|
|
17
21
|
)
|
|
18
22
|
|
|
@@ -40,6 +44,9 @@ test('adapter can fetch sequence from volvox.fa', async () => {
|
|
|
40
44
|
end: 20000,
|
|
41
45
|
})
|
|
42
46
|
|
|
47
|
+
const data = await adapter.getHeader()
|
|
48
|
+
expect(data?.trim()).toBe('hello world')
|
|
49
|
+
|
|
43
50
|
const featuresArray3 = await features3.pipe(toArray()).toPromise()
|
|
44
51
|
expect(featuresArray3).toMatchSnapshot()
|
|
45
52
|
})
|
|
@@ -6,9 +6,8 @@ import {
|
|
|
6
6
|
import { FileLocation, NoAssemblyRegion } from '@jbrowse/core/util/types'
|
|
7
7
|
import { openLocation } from '@jbrowse/core/util/io'
|
|
8
8
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
9
|
-
import SimpleFeature,
|
|
10
|
-
import {
|
|
11
|
-
import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema'
|
|
9
|
+
import { SimpleFeature, Feature } from '@jbrowse/core/util'
|
|
10
|
+
import { AnyConfigurationModel } from '@jbrowse/core/configuration'
|
|
12
11
|
import AbortablePromiseCache from 'abortable-promise-cache'
|
|
13
12
|
import LRU from '@jbrowse/core/util/QuickLRU'
|
|
14
13
|
import PluginManager from '@jbrowse/core/PluginManager'
|
|
@@ -17,6 +16,8 @@ import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
|
|
|
17
16
|
export default class extends BaseSequenceAdapter {
|
|
18
17
|
protected fasta: IndexedFasta
|
|
19
18
|
|
|
19
|
+
protected header?: Promise<string>
|
|
20
|
+
|
|
20
21
|
private seqCache = new AbortablePromiseCache({
|
|
21
22
|
cache: new LRU({ maxSize: 200 }),
|
|
22
23
|
fill: async (
|
|
@@ -34,8 +35,8 @@ export default class extends BaseSequenceAdapter {
|
|
|
34
35
|
pluginManager?: PluginManager,
|
|
35
36
|
) {
|
|
36
37
|
super(config, getSubAdapter, pluginManager)
|
|
37
|
-
const fastaLocation =
|
|
38
|
-
const faiLocation =
|
|
38
|
+
const fastaLocation = this.getConf('fastaLocation')
|
|
39
|
+
const faiLocation = this.getConf('faiLocation')
|
|
39
40
|
const fastaOpts = {
|
|
40
41
|
fasta: openLocation(fastaLocation as FileLocation, this.pluginManager),
|
|
41
42
|
fai: openLocation(faiLocation as FileLocation, this.pluginManager),
|
|
@@ -57,6 +58,26 @@ export default class extends BaseSequenceAdapter {
|
|
|
57
58
|
}))
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
public async getHeader() {
|
|
62
|
+
if (this.header) {
|
|
63
|
+
return this.header
|
|
64
|
+
}
|
|
65
|
+
const loc = this.getConf('metadataLocation')
|
|
66
|
+
|
|
67
|
+
if (loc.uri === '' || loc.uri === '/path/to/fa.metadata.yaml') {
|
|
68
|
+
return null
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
this.header = openLocation(loc)
|
|
72
|
+
.readFile('utf8')
|
|
73
|
+
.catch(e => {
|
|
74
|
+
this.header = undefined
|
|
75
|
+
throw e
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
return this.header
|
|
79
|
+
}
|
|
80
|
+
|
|
60
81
|
public getFeatures(region: NoAssemblyRegion, opts?: BaseOptions) {
|
|
61
82
|
const { refName, start, end } = region
|
|
62
83
|
return ObservableCreate<Feature>(async observer => {
|
|
@@ -11,6 +11,14 @@ export default ConfigurationSchema(
|
|
|
11
11
|
type: 'fileLocation',
|
|
12
12
|
defaultValue: { uri: '/path/to/seq.fa.fai', locationType: 'UriLocation' },
|
|
13
13
|
},
|
|
14
|
+
metadataLocation: {
|
|
15
|
+
description: 'Optional metadata file',
|
|
16
|
+
type: 'fileLocation',
|
|
17
|
+
defaultValue: {
|
|
18
|
+
uri: '/path/to/fa.metadata.yaml',
|
|
19
|
+
locationType: 'UriLocation',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
14
22
|
},
|
|
15
23
|
{ explicitlyTyped: true },
|
|
16
24
|
)
|