@jbrowse/plugin-gff3 3.6.3 → 3.6.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.
|
@@ -11,6 +11,7 @@ const rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
|
11
11
|
const simpleFeature_1 = __importDefault(require("@jbrowse/core/util/simpleFeature"));
|
|
12
12
|
const gff_nostream_1 = require("gff-nostream");
|
|
13
13
|
const featureData_1 = require("../featureData");
|
|
14
|
+
const gffParser_1 = require("./gffParser");
|
|
14
15
|
class Gff3Adapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
15
16
|
constructor() {
|
|
16
17
|
super(...arguments);
|
|
@@ -19,36 +20,7 @@ class Gff3Adapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
19
20
|
async loadDataP(opts) {
|
|
20
21
|
const { statusCallback = () => { } } = opts || {};
|
|
21
22
|
const buffer = await (0, util_1.fetchAndMaybeUnzip)((0, io_1.openLocation)(this.getConf('gffLocation'), this.pluginManager), opts);
|
|
22
|
-
const
|
|
23
|
-
const featureMap = {};
|
|
24
|
-
const decoder = new TextDecoder('utf8');
|
|
25
|
-
let blockStart = 0;
|
|
26
|
-
let i = 0;
|
|
27
|
-
while (blockStart < buffer.length) {
|
|
28
|
-
const n = buffer.indexOf(10, blockStart);
|
|
29
|
-
const b = n === -1 ? buffer.subarray(blockStart) : buffer.subarray(blockStart, n);
|
|
30
|
-
const line = decoder.decode(b).trim();
|
|
31
|
-
if (line) {
|
|
32
|
-
if (line.startsWith('#')) {
|
|
33
|
-
headerLines.push(line);
|
|
34
|
-
}
|
|
35
|
-
else if (line.startsWith('>')) {
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const ret = line.indexOf('\t');
|
|
40
|
-
const refName = line.slice(0, ret);
|
|
41
|
-
if (!featureMap[refName]) {
|
|
42
|
-
featureMap[refName] = '';
|
|
43
|
-
}
|
|
44
|
-
featureMap[refName] += `${line}\n`;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (i++ % 10000 === 0) {
|
|
48
|
-
statusCallback(`Loading ${(0, util_1.getProgressDisplayStr)(blockStart, buffer.length)}`);
|
|
49
|
-
}
|
|
50
|
-
blockStart = n + 1;
|
|
51
|
-
}
|
|
23
|
+
const { header, featureMap } = (0, gffParser_1.parseGffBuffer)(buffer, statusCallback);
|
|
52
24
|
const intervalTreeMap = Object.fromEntries(Object.entries(featureMap).map(([refName, lines]) => [
|
|
53
25
|
refName,
|
|
54
26
|
(sc) => {
|
|
@@ -69,7 +41,7 @@ class Gff3Adapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
69
41
|
},
|
|
70
42
|
]));
|
|
71
43
|
return {
|
|
72
|
-
header
|
|
44
|
+
header,
|
|
73
45
|
intervalTreeMap,
|
|
74
46
|
};
|
|
75
47
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StatusCallback } from '@jbrowse/core/util/parseLineByLine';
|
|
2
|
+
interface GffParseResult {
|
|
3
|
+
header: string;
|
|
4
|
+
featureMap: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseGffBuffer(buffer: Uint8Array, statusCallback?: StatusCallback): GffParseResult;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseGffBuffer = parseGffBuffer;
|
|
4
|
+
const parseLineByLine_1 = require("@jbrowse/core/util/parseLineByLine");
|
|
5
|
+
function parseGffBuffer(buffer, statusCallback = () => { }) {
|
|
6
|
+
const headerLines = [];
|
|
7
|
+
const featureMap = {};
|
|
8
|
+
(0, parseLineByLine_1.parseLineByLine)(buffer, line => {
|
|
9
|
+
if (line.startsWith('#')) {
|
|
10
|
+
headerLines.push(line);
|
|
11
|
+
}
|
|
12
|
+
else if (line.startsWith('>')) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const ret = line.indexOf('\t');
|
|
17
|
+
const refName = line.slice(0, ret);
|
|
18
|
+
if (!featureMap[refName]) {
|
|
19
|
+
featureMap[refName] = '';
|
|
20
|
+
}
|
|
21
|
+
featureMap[refName] += `${line}\n`;
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
|
+
}, statusCallback);
|
|
25
|
+
return {
|
|
26
|
+
header: headerLines.join('\n'),
|
|
27
|
+
featureMap,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import IntervalTree from '@flatten-js/interval-tree';
|
|
2
2
|
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
3
|
-
import { fetchAndMaybeUnzip
|
|
3
|
+
import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
|
|
4
4
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
5
5
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
6
6
|
import SimpleFeature from '@jbrowse/core/util/simpleFeature';
|
|
7
7
|
import { parseStringSync } from 'gff-nostream';
|
|
8
8
|
import { featureData } from '../featureData';
|
|
9
|
+
import { parseGffBuffer } from './gffParser';
|
|
9
10
|
export default class Gff3Adapter extends BaseFeatureDataAdapter {
|
|
10
11
|
constructor() {
|
|
11
12
|
super(...arguments);
|
|
@@ -14,36 +15,7 @@ export default class Gff3Adapter extends BaseFeatureDataAdapter {
|
|
|
14
15
|
async loadDataP(opts) {
|
|
15
16
|
const { statusCallback = () => { } } = opts || {};
|
|
16
17
|
const buffer = await fetchAndMaybeUnzip(openLocation(this.getConf('gffLocation'), this.pluginManager), opts);
|
|
17
|
-
const
|
|
18
|
-
const featureMap = {};
|
|
19
|
-
const decoder = new TextDecoder('utf8');
|
|
20
|
-
let blockStart = 0;
|
|
21
|
-
let i = 0;
|
|
22
|
-
while (blockStart < buffer.length) {
|
|
23
|
-
const n = buffer.indexOf(10, blockStart);
|
|
24
|
-
const b = n === -1 ? buffer.subarray(blockStart) : buffer.subarray(blockStart, n);
|
|
25
|
-
const line = decoder.decode(b).trim();
|
|
26
|
-
if (line) {
|
|
27
|
-
if (line.startsWith('#')) {
|
|
28
|
-
headerLines.push(line);
|
|
29
|
-
}
|
|
30
|
-
else if (line.startsWith('>')) {
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
const ret = line.indexOf('\t');
|
|
35
|
-
const refName = line.slice(0, ret);
|
|
36
|
-
if (!featureMap[refName]) {
|
|
37
|
-
featureMap[refName] = '';
|
|
38
|
-
}
|
|
39
|
-
featureMap[refName] += `${line}\n`;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (i++ % 10000 === 0) {
|
|
43
|
-
statusCallback(`Loading ${getProgressDisplayStr(blockStart, buffer.length)}`);
|
|
44
|
-
}
|
|
45
|
-
blockStart = n + 1;
|
|
46
|
-
}
|
|
18
|
+
const { header, featureMap } = parseGffBuffer(buffer, statusCallback);
|
|
47
19
|
const intervalTreeMap = Object.fromEntries(Object.entries(featureMap).map(([refName, lines]) => [
|
|
48
20
|
refName,
|
|
49
21
|
(sc) => {
|
|
@@ -64,7 +36,7 @@ export default class Gff3Adapter extends BaseFeatureDataAdapter {
|
|
|
64
36
|
},
|
|
65
37
|
]));
|
|
66
38
|
return {
|
|
67
|
-
header
|
|
39
|
+
header,
|
|
68
40
|
intervalTreeMap,
|
|
69
41
|
};
|
|
70
42
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StatusCallback } from '@jbrowse/core/util/parseLineByLine';
|
|
2
|
+
interface GffParseResult {
|
|
3
|
+
header: string;
|
|
4
|
+
featureMap: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseGffBuffer(buffer: Uint8Array, statusCallback?: StatusCallback): GffParseResult;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { parseLineByLine } from '@jbrowse/core/util/parseLineByLine';
|
|
2
|
+
export function parseGffBuffer(buffer, statusCallback = () => { }) {
|
|
3
|
+
const headerLines = [];
|
|
4
|
+
const featureMap = {};
|
|
5
|
+
parseLineByLine(buffer, line => {
|
|
6
|
+
if (line.startsWith('#')) {
|
|
7
|
+
headerLines.push(line);
|
|
8
|
+
}
|
|
9
|
+
else if (line.startsWith('>')) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
const ret = line.indexOf('\t');
|
|
14
|
+
const refName = line.slice(0, ret);
|
|
15
|
+
if (!featureMap[refName]) {
|
|
16
|
+
featureMap[refName] = '';
|
|
17
|
+
}
|
|
18
|
+
featureMap[refName] += `${line}\n`;
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}, statusCallback);
|
|
22
|
+
return {
|
|
23
|
+
header: headerLines.join('\n'),
|
|
24
|
+
featureMap,
|
|
25
|
+
};
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-gff3",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.4",
|
|
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": "^4.0.0",
|
|
41
41
|
"@gmod/tabix": "^3.0.1",
|
|
42
|
-
"@jbrowse/core": "^3.6.
|
|
43
|
-
"@jbrowse/plugin-linear-genome-view": "^3.6.
|
|
42
|
+
"@jbrowse/core": "^3.6.4",
|
|
43
|
+
"@jbrowse/plugin-linear-genome-view": "^3.6.4",
|
|
44
44
|
"@mui/material": "^7.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": "3db8e50ce2bd9c081efbf6c2e7ae5f342380a25a"
|
|
57
57
|
}
|