@jbrowse/plugin-sequence 2.1.2 → 2.1.4
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/BgzipFastaAdapter.d.ts +4 -4
- package/dist/BgzipFastaAdapter/BgzipFastaAdapter.js +5 -16
- package/dist/BgzipFastaAdapter/BgzipFastaAdapter.js.map +1 -1
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.d.ts +9 -2
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.js +31 -26
- package/dist/IndexedFastaAdapter/IndexedFastaAdapter.js.map +1 -1
- package/esm/BgzipFastaAdapter/BgzipFastaAdapter.d.ts +4 -4
- package/esm/BgzipFastaAdapter/BgzipFastaAdapter.js +5 -16
- package/esm/BgzipFastaAdapter/BgzipFastaAdapter.js.map +1 -1
- package/esm/IndexedFastaAdapter/IndexedFastaAdapter.d.ts +9 -2
- package/esm/IndexedFastaAdapter/IndexedFastaAdapter.js +33 -28
- package/esm/IndexedFastaAdapter/IndexedFastaAdapter.js.map +1 -1
- package/package.json +2 -2
- package/src/BgzipFastaAdapter/BgzipFastaAdapter.ts +5 -23
- package/src/IndexedFastaAdapter/IndexedFastaAdapter.ts +41 -38
- package/src/declare.d.ts +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BgzipIndexedFasta } from '@gmod/indexedfasta';
|
|
2
2
|
import IndexedFasta from '../IndexedFastaAdapter/IndexedFastaAdapter';
|
|
3
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
4
|
-
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
5
3
|
export default class extends IndexedFasta {
|
|
6
|
-
|
|
4
|
+
setupPre(): Promise<{
|
|
5
|
+
fasta: BgzipIndexedFasta;
|
|
6
|
+
}>;
|
|
7
7
|
}
|
|
@@ -5,29 +5,18 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const indexedfasta_1 = require("@gmod/indexedfasta");
|
|
7
7
|
const io_1 = require("@jbrowse/core/util/io");
|
|
8
|
-
const configuration_1 = require("@jbrowse/core/configuration");
|
|
9
8
|
const IndexedFastaAdapter_1 = __importDefault(require("../IndexedFastaAdapter/IndexedFastaAdapter"));
|
|
10
9
|
class default_1 extends IndexedFastaAdapter_1.default {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const gziLocation = (0, configuration_1.readConfObject)(config, 'gziLocation');
|
|
16
|
-
if (!fastaLocation) {
|
|
17
|
-
throw new Error('must provide fastaLocation');
|
|
18
|
-
}
|
|
19
|
-
if (!faiLocation) {
|
|
20
|
-
throw new Error('must provide faiLocation');
|
|
21
|
-
}
|
|
22
|
-
if (!gziLocation) {
|
|
23
|
-
throw new Error('must provide gziLocation');
|
|
24
|
-
}
|
|
10
|
+
async setupPre() {
|
|
11
|
+
const fastaLocation = this.getConf('fastaLocation');
|
|
12
|
+
const faiLocation = this.getConf('faiLocation');
|
|
13
|
+
const gziLocation = this.getConf('gziLocation');
|
|
25
14
|
const fastaOpts = {
|
|
26
15
|
fasta: (0, io_1.openLocation)(fastaLocation, this.pluginManager),
|
|
27
16
|
fai: (0, io_1.openLocation)(faiLocation, this.pluginManager),
|
|
28
17
|
gzi: (0, io_1.openLocation)(gziLocation, this.pluginManager),
|
|
29
18
|
};
|
|
30
|
-
|
|
19
|
+
return { fasta: new indexedfasta_1.BgzipIndexedFasta(fastaOpts) };
|
|
31
20
|
}
|
|
32
21
|
}
|
|
33
22
|
exports.default = default_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BgzipFastaAdapter.js","sourceRoot":"","sources":["../../src/BgzipFastaAdapter/BgzipFastaAdapter.ts"],"names":[],"mappings":";;;;;AAAA,qDAAsD;AAEtD,8CAAoD;AACpD
|
|
1
|
+
{"version":3,"file":"BgzipFastaAdapter.js","sourceRoot":"","sources":["../../src/BgzipFastaAdapter/BgzipFastaAdapter.ts"],"names":[],"mappings":";;;;;AAAA,qDAAsD;AAEtD,8CAAoD;AACpD,qGAAqE;AAErE,eAAqB,SAAQ,6BAAY;IAChC,KAAK,CAAC,QAAQ;QACnB,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QAC/C,MAAM,SAAS,GAAG;YAChB,KAAK,EAAE,IAAA,iBAAY,EAAC,aAA6B,EAAE,IAAI,CAAC,aAAa,CAAC;YACtE,GAAG,EAAE,IAAA,iBAAY,EAAC,WAA2B,EAAE,IAAI,CAAC,aAAa,CAAC;YAClE,GAAG,EAAE,IAAA,iBAAY,EAAC,WAA2B,EAAE,IAAI,CAAC,aAAa,CAAC;SACnE,CAAA;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,gCAAiB,CAAC,SAAS,CAAC,EAAE,CAAA;IACpD,CAAC;CACF;AAbD,4BAaC"}
|
|
@@ -6,8 +6,9 @@ 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
|
-
protected
|
|
10
|
-
|
|
9
|
+
protected setupP?: Promise<{
|
|
10
|
+
fasta: IndexedFasta;
|
|
11
|
+
}>;
|
|
11
12
|
private seqCache;
|
|
12
13
|
constructor(config: AnyConfigurationModel, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
|
|
13
14
|
getRefNames(opts?: BaseOptions): Promise<string[]>;
|
|
@@ -16,7 +17,13 @@ export default class extends BaseSequenceAdapter {
|
|
|
16
17
|
start: number;
|
|
17
18
|
end: number;
|
|
18
19
|
}[]>;
|
|
20
|
+
setupPre(): Promise<{
|
|
21
|
+
fasta: IndexedFasta;
|
|
22
|
+
}>;
|
|
19
23
|
getHeader(): Promise<string | null>;
|
|
24
|
+
setup(): Promise<{
|
|
25
|
+
fasta: IndexedFasta;
|
|
26
|
+
}>;
|
|
20
27
|
getFeatures(region: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
21
28
|
/**
|
|
22
29
|
* called to provide a hint that data tied to a certain region
|
|
@@ -16,49 +16,54 @@ class default_1 extends BaseAdapter_1.BaseSequenceAdapter {
|
|
|
16
16
|
this.seqCache = new abortable_promise_cache_1.default({
|
|
17
17
|
cache: new QuickLRU_1.default({ maxSize: 200 }),
|
|
18
18
|
fill: async (args, signal) => {
|
|
19
|
-
const { refName, start, end } = args;
|
|
20
|
-
return
|
|
19
|
+
const { refName, start, end, fasta } = args;
|
|
20
|
+
return fasta.getSequence(refName, start, end, { ...args, signal });
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
|
-
const fastaLocation = this.getConf('fastaLocation');
|
|
24
|
-
const faiLocation = this.getConf('faiLocation');
|
|
25
|
-
const fastaOpts = {
|
|
26
|
-
fasta: (0, io_1.openLocation)(fastaLocation, this.pluginManager),
|
|
27
|
-
fai: (0, io_1.openLocation)(faiLocation, this.pluginManager),
|
|
28
|
-
};
|
|
29
|
-
this.fasta = new indexedfasta_1.IndexedFasta(fastaOpts);
|
|
30
23
|
}
|
|
31
|
-
getRefNames(opts) {
|
|
32
|
-
|
|
24
|
+
async getRefNames(opts) {
|
|
25
|
+
const { fasta } = await this.setup();
|
|
26
|
+
return fasta.getSequenceNames(opts);
|
|
33
27
|
}
|
|
34
28
|
async getRegions(opts) {
|
|
35
|
-
const
|
|
29
|
+
const { fasta } = await this.setup();
|
|
30
|
+
const seqSizes = await fasta.getSequenceSizes(opts);
|
|
36
31
|
return Object.keys(seqSizes).map(refName => ({
|
|
37
32
|
refName,
|
|
38
33
|
start: 0,
|
|
39
34
|
end: seqSizes[refName],
|
|
40
35
|
}));
|
|
41
36
|
}
|
|
37
|
+
async setupPre() {
|
|
38
|
+
const fastaLocation = this.getConf('fastaLocation');
|
|
39
|
+
const faiLocation = this.getConf('faiLocation');
|
|
40
|
+
return {
|
|
41
|
+
fasta: new indexedfasta_1.IndexedFasta({
|
|
42
|
+
fasta: (0, io_1.openLocation)(fastaLocation, this.pluginManager),
|
|
43
|
+
fai: (0, io_1.openLocation)(faiLocation, this.pluginManager),
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
42
47
|
async getHeader() {
|
|
43
|
-
if (this.header) {
|
|
44
|
-
return this.header;
|
|
45
|
-
}
|
|
46
48
|
const loc = this.getConf('metadataLocation');
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
return loc.uri === '' || loc.uri === '/path/to/fa.metadata.yaml'
|
|
50
|
+
? null
|
|
51
|
+
: (0, io_1.openLocation)(loc).readFile('utf8');
|
|
52
|
+
}
|
|
53
|
+
async setup() {
|
|
54
|
+
if (!this.setupP) {
|
|
55
|
+
this.setupP = this.setupPre().catch(e => {
|
|
56
|
+
this.setupP = undefined;
|
|
57
|
+
throw e;
|
|
58
|
+
});
|
|
49
59
|
}
|
|
50
|
-
this.
|
|
51
|
-
.readFile('utf8')
|
|
52
|
-
.catch(e => {
|
|
53
|
-
this.header = undefined;
|
|
54
|
-
throw e;
|
|
55
|
-
});
|
|
56
|
-
return this.header;
|
|
60
|
+
return this.setupP;
|
|
57
61
|
}
|
|
58
62
|
getFeatures(region, opts) {
|
|
59
63
|
const { refName, start, end } = region;
|
|
60
64
|
return (0, rxjs_1.ObservableCreate)(async (observer) => {
|
|
61
|
-
const
|
|
65
|
+
const { fasta } = await this.setup();
|
|
66
|
+
const size = await fasta.getSequenceSize(refName, opts);
|
|
62
67
|
const regionEnd = size !== undefined ? Math.min(size, end) : end;
|
|
63
68
|
const chunks = [];
|
|
64
69
|
const chunkSize = 128000;
|
|
@@ -70,7 +75,7 @@ class default_1 extends BaseAdapter_1.BaseSequenceAdapter {
|
|
|
70
75
|
start: chunkStart,
|
|
71
76
|
end: chunkStart + chunkSize,
|
|
72
77
|
};
|
|
73
|
-
chunks.push(this.seqCache.get(JSON.stringify(r), r, opts === null || opts === void 0 ? void 0 : opts.signal));
|
|
78
|
+
chunks.push(this.seqCache.get(JSON.stringify(r), { ...r, fasta }, opts === null || opts === void 0 ? void 0 : opts.signal));
|
|
74
79
|
}
|
|
75
80
|
const seq = (await Promise.all(chunks))
|
|
76
81
|
.join('')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedFastaAdapter.js","sourceRoot":"","sources":["../../src/IndexedFastaAdapter/IndexedFastaAdapter.ts"],"names":[],"mappings":";;;;;AAAA,qDAAiD;AACjD,yEAGgD;AAEhD,8CAAoD;AACpD,kDAA0D;AAC1D,6CAA2D;AAE3D,sFAA2D;AAC3D,
|
|
1
|
+
{"version":3,"file":"IndexedFastaAdapter.js","sourceRoot":"","sources":["../../src/IndexedFastaAdapter/IndexedFastaAdapter.ts"],"names":[],"mappings":";;;;;AAAA,qDAAiD;AACjD,yEAGgD;AAEhD,8CAAoD;AACpD,kDAA0D;AAC1D,6CAA2D;AAE3D,sFAA2D;AAC3D,2EAAkD;AAMlD,eAAqB,SAAQ,iCAAmB;IAW9C,YACE,MAA6B,EAC7B,aAAiC,EACjC,aAA6B;QAE7B,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,aAAa,CAAC,CAAA;QAbrC,aAAQ,GAAG,IAAI,iCAAqB,CAAwB;YAClE,KAAK,EAAE,IAAI,kBAAQ,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC;YACrC,IAAI,EAAE,KAAK,EAAE,IAAO,EAAE,MAAoB,EAAE,EAAE;gBAC5C,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,C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AAU,GAAG,CAAC,EAAE,UAAU,GAAG,CAAC,EAAE,UAAU,IAAI,SAAS,EAAE;gBAChE,MAAM,CAAC,GAAG;oBACR,OAAO;oBACP,KAAK,EAAE,UAAU;oBACjB,GAAG,EAAE,UAAU,GAAG,SAAS;iBAC5B,CAAA;gBACD,MAAM,CAAC,IAAI,CACT,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,KAAK,EAAE,EAAE,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,CAAC,CACpE,CAAA;aACF;YACD,MAAM,GAAG,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACpC,IAAI,CAAC,EAAE,CAAC;iBACR,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;iBAChB,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAA;YACxB,IAAI,GAAG,EAAE;gBACP,QAAQ,CAAC,IAAI,CACX,IAAI,oBAAa,CAAC;oBAChB,EAAE,EAAE,GAAG,OAAO,IAAI,KAAK,IAAI,SAAS,EAAE;oBACtC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE;iBAC9C,CAAC,CACH,CAAA;aACF;YACD,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;OAIG;IACI,aAAa,EAAC,gBAAgB,IAAS,CAAC;CAChD;AA1GD,4BA0GC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BgzipIndexedFasta } from '@gmod/indexedfasta';
|
|
2
2
|
import IndexedFasta from '../IndexedFastaAdapter/IndexedFastaAdapter';
|
|
3
|
-
import PluginManager from '@jbrowse/core/PluginManager';
|
|
4
|
-
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
5
3
|
export default class extends IndexedFasta {
|
|
6
|
-
|
|
4
|
+
setupPre(): Promise<{
|
|
5
|
+
fasta: BgzipIndexedFasta;
|
|
6
|
+
}>;
|
|
7
7
|
}
|
|
@@ -1,28 +1,17 @@
|
|
|
1
1
|
import { BgzipIndexedFasta } from '@gmod/indexedfasta';
|
|
2
2
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
3
|
-
import { readConfObject } from '@jbrowse/core/configuration';
|
|
4
3
|
import IndexedFasta from '../IndexedFastaAdapter/IndexedFastaAdapter';
|
|
5
4
|
export default class extends IndexedFasta {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const gziLocation = readConfObject(config, 'gziLocation');
|
|
11
|
-
if (!fastaLocation) {
|
|
12
|
-
throw new Error('must provide fastaLocation');
|
|
13
|
-
}
|
|
14
|
-
if (!faiLocation) {
|
|
15
|
-
throw new Error('must provide faiLocation');
|
|
16
|
-
}
|
|
17
|
-
if (!gziLocation) {
|
|
18
|
-
throw new Error('must provide gziLocation');
|
|
19
|
-
}
|
|
5
|
+
async setupPre() {
|
|
6
|
+
const fastaLocation = this.getConf('fastaLocation');
|
|
7
|
+
const faiLocation = this.getConf('faiLocation');
|
|
8
|
+
const gziLocation = this.getConf('gziLocation');
|
|
20
9
|
const fastaOpts = {
|
|
21
10
|
fasta: openLocation(fastaLocation, this.pluginManager),
|
|
22
11
|
fai: openLocation(faiLocation, this.pluginManager),
|
|
23
12
|
gzi: openLocation(gziLocation, this.pluginManager),
|
|
24
13
|
};
|
|
25
|
-
|
|
14
|
+
return { fasta: new BgzipIndexedFasta(fastaOpts) };
|
|
26
15
|
}
|
|
27
16
|
}
|
|
28
17
|
//# sourceMappingURL=BgzipFastaAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BgzipFastaAdapter.js","sourceRoot":"","sources":["../../src/BgzipFastaAdapter/BgzipFastaAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"BgzipFastaAdapter.js","sourceRoot":"","sources":["../../src/BgzipFastaAdapter/BgzipFastaAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,YAAY,MAAM,4CAA4C,CAAA;AAErE,MAAM,CAAC,OAAO,MAAO,SAAQ,YAAY;IAChC,KAAK,CAAC,QAAQ;QACnB,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QACnD,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QAC/C,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAA;QAC/C,MAAM,SAAS,GAAG;YAChB,KAAK,EAAE,YAAY,CAAC,aAA6B,EAAE,IAAI,CAAC,aAAa,CAAC;YACtE,GAAG,EAAE,YAAY,CAAC,WAA2B,EAAE,IAAI,CAAC,aAAa,CAAC;YAClE,GAAG,EAAE,YAAY,CAAC,WAA2B,EAAE,IAAI,CAAC,aAAa,CAAC;SACnE,CAAA;QAED,OAAO,EAAE,KAAK,EAAE,IAAI,iBAAiB,CAAC,SAAS,CAAC,EAAE,CAAA;IACpD,CAAC;CACF"}
|
|
@@ -6,8 +6,9 @@ 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
|
-
protected
|
|
10
|
-
|
|
9
|
+
protected setupP?: Promise<{
|
|
10
|
+
fasta: IndexedFasta;
|
|
11
|
+
}>;
|
|
11
12
|
private seqCache;
|
|
12
13
|
constructor(config: AnyConfigurationModel, getSubAdapter?: getSubAdapterType, pluginManager?: PluginManager);
|
|
13
14
|
getRefNames(opts?: BaseOptions): Promise<string[]>;
|
|
@@ -16,7 +17,13 @@ export default class extends BaseSequenceAdapter {
|
|
|
16
17
|
start: number;
|
|
17
18
|
end: number;
|
|
18
19
|
}[]>;
|
|
20
|
+
setupPre(): Promise<{
|
|
21
|
+
fasta: IndexedFasta;
|
|
22
|
+
}>;
|
|
19
23
|
getHeader(): Promise<string | null>;
|
|
24
|
+
setup(): Promise<{
|
|
25
|
+
fasta: IndexedFasta;
|
|
26
|
+
}>;
|
|
20
27
|
getFeatures(region: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
21
28
|
/**
|
|
22
29
|
* called to provide a hint that data tied to a certain region
|
|
@@ -4,56 +4,61 @@ import { openLocation } from '@jbrowse/core/util/io';
|
|
|
4
4
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
5
5
|
import { SimpleFeature } from '@jbrowse/core/util';
|
|
6
6
|
import AbortablePromiseCache from 'abortable-promise-cache';
|
|
7
|
-
import
|
|
7
|
+
import QuickLRU from '@jbrowse/core/util/QuickLRU';
|
|
8
8
|
export default class extends BaseSequenceAdapter {
|
|
9
9
|
constructor(config, getSubAdapter, pluginManager) {
|
|
10
10
|
super(config, getSubAdapter, pluginManager);
|
|
11
11
|
this.seqCache = new AbortablePromiseCache({
|
|
12
|
-
cache: new
|
|
12
|
+
cache: new QuickLRU({ maxSize: 200 }),
|
|
13
13
|
fill: async (args, signal) => {
|
|
14
|
-
const { refName, start, end } = args;
|
|
15
|
-
return
|
|
14
|
+
const { refName, start, end, fasta } = args;
|
|
15
|
+
return fasta.getSequence(refName, start, end, { ...args, signal });
|
|
16
16
|
},
|
|
17
17
|
});
|
|
18
|
-
const fastaLocation = this.getConf('fastaLocation');
|
|
19
|
-
const faiLocation = this.getConf('faiLocation');
|
|
20
|
-
const fastaOpts = {
|
|
21
|
-
fasta: openLocation(fastaLocation, this.pluginManager),
|
|
22
|
-
fai: openLocation(faiLocation, this.pluginManager),
|
|
23
|
-
};
|
|
24
|
-
this.fasta = new IndexedFasta(fastaOpts);
|
|
25
18
|
}
|
|
26
|
-
getRefNames(opts) {
|
|
27
|
-
|
|
19
|
+
async getRefNames(opts) {
|
|
20
|
+
const { fasta } = await this.setup();
|
|
21
|
+
return fasta.getSequenceNames(opts);
|
|
28
22
|
}
|
|
29
23
|
async getRegions(opts) {
|
|
30
|
-
const
|
|
24
|
+
const { fasta } = await this.setup();
|
|
25
|
+
const seqSizes = await fasta.getSequenceSizes(opts);
|
|
31
26
|
return Object.keys(seqSizes).map(refName => ({
|
|
32
27
|
refName,
|
|
33
28
|
start: 0,
|
|
34
29
|
end: seqSizes[refName],
|
|
35
30
|
}));
|
|
36
31
|
}
|
|
32
|
+
async setupPre() {
|
|
33
|
+
const fastaLocation = this.getConf('fastaLocation');
|
|
34
|
+
const faiLocation = this.getConf('faiLocation');
|
|
35
|
+
return {
|
|
36
|
+
fasta: new IndexedFasta({
|
|
37
|
+
fasta: openLocation(fastaLocation, this.pluginManager),
|
|
38
|
+
fai: openLocation(faiLocation, this.pluginManager),
|
|
39
|
+
}),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
37
42
|
async getHeader() {
|
|
38
|
-
if (this.header) {
|
|
39
|
-
return this.header;
|
|
40
|
-
}
|
|
41
43
|
const loc = this.getConf('metadataLocation');
|
|
42
|
-
|
|
43
|
-
|
|
44
|
+
return loc.uri === '' || loc.uri === '/path/to/fa.metadata.yaml'
|
|
45
|
+
? null
|
|
46
|
+
: openLocation(loc).readFile('utf8');
|
|
47
|
+
}
|
|
48
|
+
async setup() {
|
|
49
|
+
if (!this.setupP) {
|
|
50
|
+
this.setupP = this.setupPre().catch(e => {
|
|
51
|
+
this.setupP = undefined;
|
|
52
|
+
throw e;
|
|
53
|
+
});
|
|
44
54
|
}
|
|
45
|
-
this.
|
|
46
|
-
.readFile('utf8')
|
|
47
|
-
.catch(e => {
|
|
48
|
-
this.header = undefined;
|
|
49
|
-
throw e;
|
|
50
|
-
});
|
|
51
|
-
return this.header;
|
|
55
|
+
return this.setupP;
|
|
52
56
|
}
|
|
53
57
|
getFeatures(region, opts) {
|
|
54
58
|
const { refName, start, end } = region;
|
|
55
59
|
return ObservableCreate(async (observer) => {
|
|
56
|
-
const
|
|
60
|
+
const { fasta } = await this.setup();
|
|
61
|
+
const size = await fasta.getSequenceSize(refName, opts);
|
|
57
62
|
const regionEnd = size !== undefined ? Math.min(size, end) : end;
|
|
58
63
|
const chunks = [];
|
|
59
64
|
const chunkSize = 128000;
|
|
@@ -65,7 +70,7 @@ export default class extends BaseSequenceAdapter {
|
|
|
65
70
|
start: chunkStart,
|
|
66
71
|
end: chunkStart + chunkSize,
|
|
67
72
|
};
|
|
68
|
-
chunks.push(this.seqCache.get(JSON.stringify(r), r, opts === null || opts === void 0 ? void 0 : opts.signal));
|
|
73
|
+
chunks.push(this.seqCache.get(JSON.stringify(r), { ...r, fasta }, opts === null || opts === void 0 ? void 0 : opts.signal));
|
|
69
74
|
}
|
|
70
75
|
const seq = (await Promise.all(chunks))
|
|
71
76
|
.join('')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndexedFastaAdapter.js","sourceRoot":"","sources":["../../src/IndexedFastaAdapter/IndexedFastaAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EACL,mBAAmB,GAEpB,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,aAAa,EAAW,MAAM,oBAAoB,CAAA;AAE3D,OAAO,qBAAqB,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,IAAI,CAAE,MAAM,CAAC,CACpE,CAAA;aACF;YACD,MAAM,GAAG,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;iBACpC,IAAI,CAAC,EAAE,CAAC;iBACR,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;iBAChB,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,CAAA;YACxB,IAAI,GAAG,EAAE;gBACP,QAAQ,CAAC,IAAI,CACX,IAAI,aAAa,CAAC;oBAChB,EAAE,EAAE,GAAG,OAAO,IAAI,KAAK,IAAI,SAAS,EAAE;oBACtC,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE;iBAC9C,CAAC,CACH,CAAA;aACF;YACD,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC,CAAC,CAAA;IACJ,CAAC;IAED;;;;OAIG;IACI,aAAa,EAAC,gBAAgB,IAAS,CAAC;CAChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-sequence",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "JBrowse 2 sequence adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"distModule": "esm/index.js",
|
|
60
60
|
"srcModule": "src/index.ts",
|
|
61
61
|
"module": "esm/index.js",
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "8f53e016dd83b01a1beea0fc61c33964f5b6c809"
|
|
63
63
|
}
|
|
@@ -1,37 +1,19 @@
|
|
|
1
1
|
import { BgzipIndexedFasta } from '@gmod/indexedfasta'
|
|
2
2
|
import { FileLocation } from '@jbrowse/core/util/types'
|
|
3
3
|
import { openLocation } from '@jbrowse/core/util/io'
|
|
4
|
-
import { readConfObject } from '@jbrowse/core/configuration'
|
|
5
|
-
import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema'
|
|
6
4
|
import IndexedFasta from '../IndexedFastaAdapter/IndexedFastaAdapter'
|
|
7
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
8
|
-
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
|
|
9
5
|
|
|
10
6
|
export default class extends IndexedFasta {
|
|
11
|
-
public
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
) {
|
|
16
|
-
super(config, getSubAdapter, pluginManager)
|
|
17
|
-
const fastaLocation = readConfObject(config, 'fastaLocation')
|
|
18
|
-
const faiLocation = readConfObject(config, 'faiLocation')
|
|
19
|
-
const gziLocation = readConfObject(config, 'gziLocation')
|
|
20
|
-
if (!fastaLocation) {
|
|
21
|
-
throw new Error('must provide fastaLocation')
|
|
22
|
-
}
|
|
23
|
-
if (!faiLocation) {
|
|
24
|
-
throw new Error('must provide faiLocation')
|
|
25
|
-
}
|
|
26
|
-
if (!gziLocation) {
|
|
27
|
-
throw new Error('must provide gziLocation')
|
|
28
|
-
}
|
|
7
|
+
public async setupPre() {
|
|
8
|
+
const fastaLocation = this.getConf('fastaLocation')
|
|
9
|
+
const faiLocation = this.getConf('faiLocation')
|
|
10
|
+
const gziLocation = this.getConf('gziLocation')
|
|
29
11
|
const fastaOpts = {
|
|
30
12
|
fasta: openLocation(fastaLocation as FileLocation, this.pluginManager),
|
|
31
13
|
fai: openLocation(faiLocation as FileLocation, this.pluginManager),
|
|
32
14
|
gzi: openLocation(gziLocation as FileLocation, this.pluginManager),
|
|
33
15
|
}
|
|
34
16
|
|
|
35
|
-
|
|
17
|
+
return { fasta: new BgzipIndexedFasta(fastaOpts) }
|
|
36
18
|
}
|
|
37
19
|
}
|
|
@@ -9,23 +9,20 @@ import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
|
9
9
|
import { SimpleFeature, Feature } from '@jbrowse/core/util'
|
|
10
10
|
import { AnyConfigurationModel } from '@jbrowse/core/configuration'
|
|
11
11
|
import AbortablePromiseCache from 'abortable-promise-cache'
|
|
12
|
-
import
|
|
12
|
+
import QuickLRU from '@jbrowse/core/util/QuickLRU'
|
|
13
13
|
import PluginManager from '@jbrowse/core/PluginManager'
|
|
14
14
|
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
protected fasta: IndexedFasta
|
|
16
|
+
type T = { refName: string; start: number; end: number; fasta: IndexedFasta }
|
|
18
17
|
|
|
19
|
-
|
|
18
|
+
export default class extends BaseSequenceAdapter {
|
|
19
|
+
protected setupP?: Promise<{ fasta: IndexedFasta }>
|
|
20
20
|
|
|
21
|
-
private seqCache = new AbortablePromiseCache({
|
|
22
|
-
cache: new
|
|
23
|
-
fill: async (
|
|
24
|
-
|
|
25
|
-
signal
|
|
26
|
-
) => {
|
|
27
|
-
const { refName, start, end } = args
|
|
28
|
-
return this.fasta.getSequence(refName, start, end, { ...args, signal })
|
|
21
|
+
private seqCache = new AbortablePromiseCache<T, string | undefined>({
|
|
22
|
+
cache: new QuickLRU({ maxSize: 200 }),
|
|
23
|
+
fill: async (args: T, signal?: AbortSignal) => {
|
|
24
|
+
const { refName, start, end, fasta } = args
|
|
25
|
+
return fasta.getSequence(refName, start, end, { ...args, signal })
|
|
29
26
|
},
|
|
30
27
|
})
|
|
31
28
|
|
|
@@ -35,22 +32,16 @@ export default class extends BaseSequenceAdapter {
|
|
|
35
32
|
pluginManager?: PluginManager,
|
|
36
33
|
) {
|
|
37
34
|
super(config, getSubAdapter, pluginManager)
|
|
38
|
-
const fastaLocation = this.getConf('fastaLocation')
|
|
39
|
-
const faiLocation = this.getConf('faiLocation')
|
|
40
|
-
const fastaOpts = {
|
|
41
|
-
fasta: openLocation(fastaLocation as FileLocation, this.pluginManager),
|
|
42
|
-
fai: openLocation(faiLocation as FileLocation, this.pluginManager),
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this.fasta = new IndexedFasta(fastaOpts)
|
|
46
35
|
}
|
|
47
36
|
|
|
48
|
-
public getRefNames(opts?: BaseOptions) {
|
|
49
|
-
|
|
37
|
+
public async getRefNames(opts?: BaseOptions) {
|
|
38
|
+
const { fasta } = await this.setup()
|
|
39
|
+
return fasta.getSequenceNames(opts)
|
|
50
40
|
}
|
|
51
41
|
|
|
52
42
|
public async getRegions(opts?: BaseOptions) {
|
|
53
|
-
const
|
|
43
|
+
const { fasta } = await this.setup()
|
|
44
|
+
const seqSizes = await fasta.getSequenceSizes(opts)
|
|
54
45
|
return Object.keys(seqSizes).map(refName => ({
|
|
55
46
|
refName,
|
|
56
47
|
start: 0,
|
|
@@ -58,30 +49,40 @@ export default class extends BaseSequenceAdapter {
|
|
|
58
49
|
}))
|
|
59
50
|
}
|
|
60
51
|
|
|
61
|
-
public async
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
const loc = this.getConf('metadataLocation')
|
|
52
|
+
public async setupPre() {
|
|
53
|
+
const fastaLocation = this.getConf('fastaLocation') as FileLocation
|
|
54
|
+
const faiLocation = this.getConf('faiLocation') as FileLocation
|
|
66
55
|
|
|
67
|
-
|
|
68
|
-
|
|
56
|
+
return {
|
|
57
|
+
fasta: new IndexedFasta({
|
|
58
|
+
fasta: openLocation(fastaLocation, this.pluginManager),
|
|
59
|
+
fai: openLocation(faiLocation, this.pluginManager),
|
|
60
|
+
}),
|
|
69
61
|
}
|
|
62
|
+
}
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
public async getHeader() {
|
|
65
|
+
const loc = this.getConf('metadataLocation')
|
|
66
|
+
return loc.uri === '' || loc.uri === '/path/to/fa.metadata.yaml'
|
|
67
|
+
? null
|
|
68
|
+
: openLocation(loc).readFile('utf8')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public async setup() {
|
|
72
|
+
if (!this.setupP) {
|
|
73
|
+
this.setupP = this.setupPre().catch(e => {
|
|
74
|
+
this.setupP = undefined
|
|
75
75
|
throw e
|
|
76
76
|
})
|
|
77
|
-
|
|
78
|
-
return this.
|
|
77
|
+
}
|
|
78
|
+
return this.setupP
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
public getFeatures(region: NoAssemblyRegion, opts?: BaseOptions) {
|
|
82
82
|
const { refName, start, end } = region
|
|
83
83
|
return ObservableCreate<Feature>(async observer => {
|
|
84
|
-
const
|
|
84
|
+
const { fasta } = await this.setup()
|
|
85
|
+
const size = await fasta.getSequenceSize(refName, opts)
|
|
85
86
|
const regionEnd = size !== undefined ? Math.min(size, end) : end
|
|
86
87
|
const chunks = []
|
|
87
88
|
const chunkSize = 128000
|
|
@@ -94,7 +95,9 @@ export default class extends BaseSequenceAdapter {
|
|
|
94
95
|
start: chunkStart,
|
|
95
96
|
end: chunkStart + chunkSize,
|
|
96
97
|
}
|
|
97
|
-
chunks.push(
|
|
98
|
+
chunks.push(
|
|
99
|
+
this.seqCache.get(JSON.stringify(r), { ...r, fasta }, opts?.signal),
|
|
100
|
+
)
|
|
98
101
|
}
|
|
99
102
|
const seq = (await Promise.all(chunks))
|
|
100
103
|
.join('')
|
package/src/declare.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
declare module '@jbrowse/core/util/QuickLRU'
|