@jbrowse/plugin-gff3 3.0.1 → 3.0.2
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.
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
2
2
|
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
-
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
4
|
-
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
5
3
|
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
6
|
-
import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
7
4
|
import type { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
8
5
|
import type { Region } from '@jbrowse/core/util/types';
|
|
9
6
|
export default class Gff3TabixAdapter extends BaseFeatureDataAdapter {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
private configured?;
|
|
8
|
+
private configurePre;
|
|
9
|
+
protected configurePre2(): Promise<{
|
|
10
|
+
gff: TabixIndexedFile;
|
|
11
|
+
dontRedispatch: string[];
|
|
12
|
+
}>;
|
|
13
|
+
configure(opts?: BaseOptions): Promise<{
|
|
14
|
+
gff: TabixIndexedFile;
|
|
15
|
+
dontRedispatch: string[];
|
|
16
|
+
}>;
|
|
13
17
|
getRefNames(opts?: BaseOptions): Promise<string[]>;
|
|
14
|
-
getHeader(): Promise<string>;
|
|
18
|
+
getHeader(opts?: BaseOptions): Promise<string>;
|
|
15
19
|
getFeatures(query: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
16
20
|
private getFeaturesHelper;
|
|
17
21
|
private parseLine;
|
|
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const tabix_1 = require("@gmod/tabix");
|
|
7
|
-
const configuration_1 = require("@jbrowse/core/configuration");
|
|
8
7
|
const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
8
|
+
const util_1 = require("@jbrowse/core/util");
|
|
9
9
|
const io_1 = require("@jbrowse/core/util/io");
|
|
10
10
|
const range_1 = require("@jbrowse/core/util/range");
|
|
11
11
|
const rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
@@ -13,50 +13,71 @@ const simpleFeature_1 = __importDefault(require("@jbrowse/core/util/simpleFeatur
|
|
|
13
13
|
const gff_nostream_1 = require("gff-nostream");
|
|
14
14
|
const featureData_1 = require("../featureData");
|
|
15
15
|
class Gff3TabixAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
16
|
+
async configurePre(_opts) {
|
|
17
|
+
const gffGzLocation = this.getConf('gffGzLocation');
|
|
18
|
+
const indexType = this.getConf(['index', 'indexType']);
|
|
19
|
+
const loc = this.getConf(['index', 'location']);
|
|
20
|
+
const dontRedispatch = this.getConf('dontRedispatch') || [
|
|
21
|
+
'chromosome',
|
|
22
|
+
'contig',
|
|
23
|
+
'region',
|
|
24
|
+
];
|
|
25
|
+
const gff = new tabix_1.TabixIndexedFile({
|
|
24
26
|
filehandle: (0, io_1.openLocation)(gffGzLocation, this.pluginManager),
|
|
25
|
-
csiFilehandle: indexType === 'CSI'
|
|
26
|
-
|
|
27
|
-
: undefined,
|
|
28
|
-
tbiFilehandle: indexType !== 'CSI'
|
|
29
|
-
? (0, io_1.openLocation)(location, this.pluginManager)
|
|
30
|
-
: undefined,
|
|
27
|
+
csiFilehandle: indexType === 'CSI' ? (0, io_1.openLocation)(loc, this.pluginManager) : undefined,
|
|
28
|
+
tbiFilehandle: indexType !== 'CSI' ? (0, io_1.openLocation)(loc, this.pluginManager) : undefined,
|
|
31
29
|
chunkCacheSize: 50 * 2 ** 20,
|
|
32
30
|
renameRefSeqs: (n) => n,
|
|
33
31
|
});
|
|
32
|
+
return {
|
|
33
|
+
gff,
|
|
34
|
+
dontRedispatch,
|
|
35
|
+
header: await gff.getHeader(),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
async configurePre2() {
|
|
39
|
+
if (!this.configured) {
|
|
40
|
+
this.configured = this.configurePre().catch((e) => {
|
|
41
|
+
this.configured = undefined;
|
|
42
|
+
throw e;
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return this.configured;
|
|
46
|
+
}
|
|
47
|
+
async configure(opts) {
|
|
48
|
+
const { statusCallback = () => { } } = opts || {};
|
|
49
|
+
return (0, util_1.updateStatus)('Downloading index', statusCallback, () => this.configurePre2());
|
|
34
50
|
}
|
|
35
51
|
async getRefNames(opts = {}) {
|
|
36
|
-
|
|
52
|
+
const { gff } = await this.configure(opts);
|
|
53
|
+
return gff.getReferenceSequenceNames(opts);
|
|
37
54
|
}
|
|
38
|
-
async getHeader() {
|
|
39
|
-
|
|
55
|
+
async getHeader(opts = {}) {
|
|
56
|
+
const { gff } = await this.configure(opts);
|
|
57
|
+
return gff.getHeader();
|
|
40
58
|
}
|
|
41
59
|
getFeatures(query, opts = {}) {
|
|
42
60
|
return (0, rxjs_1.ObservableCreate)(async (observer) => {
|
|
43
|
-
const
|
|
61
|
+
const { gff } = await this.configure(opts);
|
|
62
|
+
const metadata = await gff.getMetadata();
|
|
44
63
|
await this.getFeaturesHelper(query, opts, metadata, observer, true);
|
|
45
64
|
}, opts.stopToken);
|
|
46
65
|
}
|
|
47
66
|
async getFeaturesHelper(query, opts, metadata, observer, allowRedispatch, originalQuery = query) {
|
|
48
67
|
var _a, _b;
|
|
68
|
+
const { statusCallback = () => { } } = opts;
|
|
49
69
|
try {
|
|
50
70
|
const lines = [];
|
|
51
|
-
|
|
71
|
+
const { dontRedispatch, gff } = await this.configure(opts);
|
|
72
|
+
await (0, util_1.updateStatus)('Downloading features', statusCallback, () => gff.getLines(query.refName, query.start, query.end, (line, fileOffset) => {
|
|
52
73
|
lines.push(this.parseLine(metadata.columnNumbers, line, fileOffset));
|
|
53
|
-
});
|
|
74
|
+
}));
|
|
54
75
|
if (allowRedispatch && lines.length) {
|
|
55
76
|
let minStart = Number.POSITIVE_INFINITY;
|
|
56
77
|
let maxEnd = Number.NEGATIVE_INFINITY;
|
|
57
78
|
for (const line of lines) {
|
|
58
79
|
const featureType = line.fields[2];
|
|
59
|
-
if (!
|
|
80
|
+
if (!dontRedispatch.includes(featureType)) {
|
|
60
81
|
const start = line.start - 1;
|
|
61
82
|
if (start < minStart) {
|
|
62
83
|
minStart = start;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
2
2
|
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
-
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
4
|
-
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
5
3
|
import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
6
|
-
import type { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache';
|
|
7
4
|
import type { Feature } from '@jbrowse/core/util/simpleFeature';
|
|
8
5
|
import type { Region } from '@jbrowse/core/util/types';
|
|
9
6
|
export default class Gff3TabixAdapter extends BaseFeatureDataAdapter {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
private configured?;
|
|
8
|
+
private configurePre;
|
|
9
|
+
protected configurePre2(): Promise<{
|
|
10
|
+
gff: TabixIndexedFile;
|
|
11
|
+
dontRedispatch: string[];
|
|
12
|
+
}>;
|
|
13
|
+
configure(opts?: BaseOptions): Promise<{
|
|
14
|
+
gff: TabixIndexedFile;
|
|
15
|
+
dontRedispatch: string[];
|
|
16
|
+
}>;
|
|
13
17
|
getRefNames(opts?: BaseOptions): Promise<string[]>;
|
|
14
|
-
getHeader(): Promise<string>;
|
|
18
|
+
getHeader(opts?: BaseOptions): Promise<string>;
|
|
15
19
|
getFeatures(query: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
16
20
|
private getFeaturesHelper;
|
|
17
21
|
private parseLine;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
2
|
-
import { readConfObject } from '@jbrowse/core/configuration';
|
|
3
2
|
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
+
import { updateStatus } from '@jbrowse/core/util';
|
|
4
4
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
5
5
|
import { doesIntersect2 } from '@jbrowse/core/util/range';
|
|
6
6
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
@@ -8,50 +8,71 @@ import SimpleFeature from '@jbrowse/core/util/simpleFeature';
|
|
|
8
8
|
import { parseStringSync } from 'gff-nostream';
|
|
9
9
|
import { featureData } from '../featureData';
|
|
10
10
|
export default class Gff3TabixAdapter extends BaseFeatureDataAdapter {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
async configurePre(_opts) {
|
|
12
|
+
const gffGzLocation = this.getConf('gffGzLocation');
|
|
13
|
+
const indexType = this.getConf(['index', 'indexType']);
|
|
14
|
+
const loc = this.getConf(['index', 'location']);
|
|
15
|
+
const dontRedispatch = this.getConf('dontRedispatch') || [
|
|
16
|
+
'chromosome',
|
|
17
|
+
'contig',
|
|
18
|
+
'region',
|
|
19
|
+
];
|
|
20
|
+
const gff = new TabixIndexedFile({
|
|
19
21
|
filehandle: openLocation(gffGzLocation, this.pluginManager),
|
|
20
|
-
csiFilehandle: indexType === 'CSI'
|
|
21
|
-
|
|
22
|
-
: undefined,
|
|
23
|
-
tbiFilehandle: indexType !== 'CSI'
|
|
24
|
-
? openLocation(location, this.pluginManager)
|
|
25
|
-
: undefined,
|
|
22
|
+
csiFilehandle: indexType === 'CSI' ? openLocation(loc, this.pluginManager) : undefined,
|
|
23
|
+
tbiFilehandle: indexType !== 'CSI' ? openLocation(loc, this.pluginManager) : undefined,
|
|
26
24
|
chunkCacheSize: 50 * 2 ** 20,
|
|
27
25
|
renameRefSeqs: (n) => n,
|
|
28
26
|
});
|
|
27
|
+
return {
|
|
28
|
+
gff,
|
|
29
|
+
dontRedispatch,
|
|
30
|
+
header: await gff.getHeader(),
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async configurePre2() {
|
|
34
|
+
if (!this.configured) {
|
|
35
|
+
this.configured = this.configurePre().catch((e) => {
|
|
36
|
+
this.configured = undefined;
|
|
37
|
+
throw e;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return this.configured;
|
|
41
|
+
}
|
|
42
|
+
async configure(opts) {
|
|
43
|
+
const { statusCallback = () => { } } = opts || {};
|
|
44
|
+
return updateStatus('Downloading index', statusCallback, () => this.configurePre2());
|
|
29
45
|
}
|
|
30
46
|
async getRefNames(opts = {}) {
|
|
31
|
-
|
|
47
|
+
const { gff } = await this.configure(opts);
|
|
48
|
+
return gff.getReferenceSequenceNames(opts);
|
|
32
49
|
}
|
|
33
|
-
async getHeader() {
|
|
34
|
-
|
|
50
|
+
async getHeader(opts = {}) {
|
|
51
|
+
const { gff } = await this.configure(opts);
|
|
52
|
+
return gff.getHeader();
|
|
35
53
|
}
|
|
36
54
|
getFeatures(query, opts = {}) {
|
|
37
55
|
return ObservableCreate(async (observer) => {
|
|
38
|
-
const
|
|
56
|
+
const { gff } = await this.configure(opts);
|
|
57
|
+
const metadata = await gff.getMetadata();
|
|
39
58
|
await this.getFeaturesHelper(query, opts, metadata, observer, true);
|
|
40
59
|
}, opts.stopToken);
|
|
41
60
|
}
|
|
42
61
|
async getFeaturesHelper(query, opts, metadata, observer, allowRedispatch, originalQuery = query) {
|
|
43
62
|
var _a, _b;
|
|
63
|
+
const { statusCallback = () => { } } = opts;
|
|
44
64
|
try {
|
|
45
65
|
const lines = [];
|
|
46
|
-
|
|
66
|
+
const { dontRedispatch, gff } = await this.configure(opts);
|
|
67
|
+
await updateStatus('Downloading features', statusCallback, () => gff.getLines(query.refName, query.start, query.end, (line, fileOffset) => {
|
|
47
68
|
lines.push(this.parseLine(metadata.columnNumbers, line, fileOffset));
|
|
48
|
-
});
|
|
69
|
+
}));
|
|
49
70
|
if (allowRedispatch && lines.length) {
|
|
50
71
|
let minStart = Number.POSITIVE_INFINITY;
|
|
51
72
|
let maxEnd = Number.NEGATIVE_INFINITY;
|
|
52
73
|
for (const line of lines) {
|
|
53
74
|
const featureType = line.fields[2];
|
|
54
|
-
if (!
|
|
75
|
+
if (!dontRedispatch.includes(featureType)) {
|
|
55
76
|
const start = line.start - 1;
|
|
56
77
|
if (start < minStart) {
|
|
57
78
|
minStart = start;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-gff3",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"description": "JBrowse 2 gff3.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@flatten-js/interval-tree": "^1.0.15",
|
|
40
40
|
"@gmod/bgzf-filehandle": "^2.0.1",
|
|
41
41
|
"@gmod/tabix": "^2.0.0",
|
|
42
|
-
"@jbrowse/core": "^3.0.
|
|
43
|
-
"@jbrowse/plugin-linear-genome-view": "^3.0.
|
|
42
|
+
"@jbrowse/core": "^3.0.2",
|
|
43
|
+
"@jbrowse/plugin-linear-genome-view": "^3.0.2",
|
|
44
44
|
"@mui/material": "^6.0.0",
|
|
45
45
|
"gff-nostream": "^1.3.3",
|
|
46
46
|
"mobx": "^6.0.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"distModule": "esm/index.js",
|
|
54
54
|
"srcModule": "src/index.ts",
|
|
55
55
|
"module": "esm/index.js",
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "c01a35edcb2612e94661af8793f09c95c0b13c75"
|
|
57
57
|
}
|