@jbrowse/plugin-variants 3.6.3 → 3.6.5
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/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.js +1 -2
- package/dist/VcfAdapter/VcfAdapter.js +2 -28
- package/dist/VcfAdapter/vcfParser.d.ts +7 -0
- package/dist/VcfAdapter/vcfParser.js +26 -0
- package/esm/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.js +1 -2
- package/esm/VcfAdapter/VcfAdapter.js +3 -29
- package/esm/VcfAdapter/vcfParser.d.ts +7 -0
- package/esm/VcfAdapter/vcfParser.js +23 -0
- package/package.json +6 -6
|
@@ -12,8 +12,7 @@ const rbush_1 = __importDefault(require("rbush"));
|
|
|
12
12
|
const util_2 = require("./util");
|
|
13
13
|
const util_3 = require("../../VcfFeature/util");
|
|
14
14
|
const MultiVariantRendering = (0, mobx_react_1.observer)(function (props) {
|
|
15
|
-
const { featureGenotypeMap, totalHeight, scrollTop } = props;
|
|
16
|
-
const { rbush, displayModel } = props;
|
|
15
|
+
const { rbush, displayModel, featureGenotypeMap, totalHeight, scrollTop } = props;
|
|
17
16
|
const ref = (0, react_1.useRef)(null);
|
|
18
17
|
const rbush2 = (0, react_1.useMemo)(() => new rbush_1.default().fromJSON(rbush), [rbush]);
|
|
19
18
|
function getFeatureUnderMouse(eventClientX, eventClientY) {
|
|
@@ -10,6 +10,7 @@ const util_1 = require("@jbrowse/core/util");
|
|
|
10
10
|
const io_1 = require("@jbrowse/core/util/io");
|
|
11
11
|
const rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
12
12
|
const VcfFeature_1 = __importDefault(require("../VcfFeature"));
|
|
13
|
+
const vcfParser_1 = require("./vcfParser");
|
|
13
14
|
class VcfAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
14
15
|
constructor() {
|
|
15
16
|
super(...arguments);
|
|
@@ -27,34 +28,7 @@ class VcfAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
27
28
|
const { statusCallback = () => { } } = opts || {};
|
|
28
29
|
const loc = (0, io_1.openLocation)(this.getConf('vcfLocation'), this.pluginManager);
|
|
29
30
|
const buffer = await (0, util_1.fetchAndMaybeUnzip)(loc, opts);
|
|
30
|
-
const
|
|
31
|
-
const featureMap = {};
|
|
32
|
-
let blockStart = 0;
|
|
33
|
-
const decoder = new TextDecoder('utf8');
|
|
34
|
-
let i = 0;
|
|
35
|
-
while (blockStart < buffer.length) {
|
|
36
|
-
const n = buffer.indexOf(10, blockStart);
|
|
37
|
-
const b = n === -1 ? buffer.subarray(blockStart) : buffer.subarray(blockStart, n);
|
|
38
|
-
const line = decoder.decode(b).trim();
|
|
39
|
-
if (line) {
|
|
40
|
-
if (line.startsWith('#')) {
|
|
41
|
-
headerLines.push(line);
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
const ret = line.indexOf('\t');
|
|
45
|
-
const refName = line.slice(0, ret);
|
|
46
|
-
if (!featureMap[refName]) {
|
|
47
|
-
featureMap[refName] = [];
|
|
48
|
-
}
|
|
49
|
-
featureMap[refName].push(line);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
if (i++ % 10000 === 0) {
|
|
53
|
-
statusCallback(`Loading ${(0, util_1.getProgressDisplayStr)(blockStart, buffer.length)}`);
|
|
54
|
-
}
|
|
55
|
-
blockStart = n + 1;
|
|
56
|
-
}
|
|
57
|
-
const header = headerLines.join('\n');
|
|
31
|
+
const { header, featureMap } = (0, vcfParser_1.parseVcfBuffer)(buffer, statusCallback);
|
|
58
32
|
const parser = new vcf_1.default({ header });
|
|
59
33
|
const intervalTreeMap = Object.fromEntries(Object.entries(featureMap).map(([refName, lines]) => [
|
|
60
34
|
refName,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StatusCallback } from '@jbrowse/core/util/parseLineByLine';
|
|
2
|
+
interface VcfParseResult {
|
|
3
|
+
header: string;
|
|
4
|
+
featureMap: Record<string, string[]>;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseVcfBuffer(buffer: Uint8Array, statusCallback?: StatusCallback): VcfParseResult;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseVcfBuffer = parseVcfBuffer;
|
|
4
|
+
const parseLineByLine_1 = require("@jbrowse/core/util/parseLineByLine");
|
|
5
|
+
function parseVcfBuffer(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 {
|
|
13
|
+
const ret = line.indexOf('\t');
|
|
14
|
+
const refName = line.slice(0, ret);
|
|
15
|
+
if (!featureMap[refName]) {
|
|
16
|
+
featureMap[refName] = [];
|
|
17
|
+
}
|
|
18
|
+
featureMap[refName].push(line);
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}, statusCallback);
|
|
22
|
+
return {
|
|
23
|
+
header: headerLines.join('\n'),
|
|
24
|
+
featureMap,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -7,8 +7,7 @@ import RBush from 'rbush';
|
|
|
7
7
|
import { minElt } from './util';
|
|
8
8
|
import { makeSimpleAltString } from '../../VcfFeature/util';
|
|
9
9
|
const MultiVariantRendering = observer(function (props) {
|
|
10
|
-
const { featureGenotypeMap, totalHeight, scrollTop } = props;
|
|
11
|
-
const { rbush, displayModel } = props;
|
|
10
|
+
const { rbush, displayModel, featureGenotypeMap, totalHeight, scrollTop } = props;
|
|
12
11
|
const ref = useRef(null);
|
|
13
12
|
const rbush2 = useMemo(() => new RBush().fromJSON(rbush), [rbush]);
|
|
14
13
|
function getFeatureUnderMouse(eventClientX, eventClientY) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import IntervalTree from '@flatten-js/interval-tree';
|
|
2
2
|
import VcfParser from '@gmod/vcf';
|
|
3
3
|
import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
4
|
-
import { fetchAndMaybeUnzip
|
|
4
|
+
import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
|
|
5
5
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
6
6
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
7
7
|
import VcfFeature from '../VcfFeature';
|
|
8
|
+
import { parseVcfBuffer } from './vcfParser';
|
|
8
9
|
class VcfAdapter extends BaseFeatureDataAdapter {
|
|
9
10
|
constructor() {
|
|
10
11
|
super(...arguments);
|
|
@@ -22,34 +23,7 @@ class VcfAdapter extends BaseFeatureDataAdapter {
|
|
|
22
23
|
const { statusCallback = () => { } } = opts || {};
|
|
23
24
|
const loc = openLocation(this.getConf('vcfLocation'), this.pluginManager);
|
|
24
25
|
const buffer = await fetchAndMaybeUnzip(loc, opts);
|
|
25
|
-
const
|
|
26
|
-
const featureMap = {};
|
|
27
|
-
let blockStart = 0;
|
|
28
|
-
const decoder = new TextDecoder('utf8');
|
|
29
|
-
let i = 0;
|
|
30
|
-
while (blockStart < buffer.length) {
|
|
31
|
-
const n = buffer.indexOf(10, blockStart);
|
|
32
|
-
const b = n === -1 ? buffer.subarray(blockStart) : buffer.subarray(blockStart, n);
|
|
33
|
-
const line = decoder.decode(b).trim();
|
|
34
|
-
if (line) {
|
|
35
|
-
if (line.startsWith('#')) {
|
|
36
|
-
headerLines.push(line);
|
|
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].push(line);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (i++ % 10000 === 0) {
|
|
48
|
-
statusCallback(`Loading ${getProgressDisplayStr(blockStart, buffer.length)}`);
|
|
49
|
-
}
|
|
50
|
-
blockStart = n + 1;
|
|
51
|
-
}
|
|
52
|
-
const header = headerLines.join('\n');
|
|
26
|
+
const { header, featureMap } = parseVcfBuffer(buffer, statusCallback);
|
|
53
27
|
const parser = new VcfParser({ header });
|
|
54
28
|
const intervalTreeMap = Object.fromEntries(Object.entries(featureMap).map(([refName, lines]) => [
|
|
55
29
|
refName,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { StatusCallback } from '@jbrowse/core/util/parseLineByLine';
|
|
2
|
+
interface VcfParseResult {
|
|
3
|
+
header: string;
|
|
4
|
+
featureMap: Record<string, string[]>;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseVcfBuffer(buffer: Uint8Array, statusCallback?: StatusCallback): VcfParseResult;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { parseLineByLine } from '@jbrowse/core/util/parseLineByLine';
|
|
2
|
+
export function parseVcfBuffer(buffer, statusCallback = () => { }) {
|
|
3
|
+
const headerLines = [];
|
|
4
|
+
const featureMap = {};
|
|
5
|
+
parseLineByLine(buffer, line => {
|
|
6
|
+
if (line.startsWith('#')) {
|
|
7
|
+
headerLines.push(line);
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
const ret = line.indexOf('\t');
|
|
11
|
+
const refName = line.slice(0, ret);
|
|
12
|
+
if (!featureMap[refName]) {
|
|
13
|
+
featureMap[refName] = [];
|
|
14
|
+
}
|
|
15
|
+
featureMap[refName].push(line);
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
}, statusCallback);
|
|
19
|
+
return {
|
|
20
|
+
header: headerLines.join('\n'),
|
|
21
|
+
featureMap,
|
|
22
|
+
};
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-variants",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.5",
|
|
4
4
|
"description": "JBrowse 2 variant adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -40,10 +40,10 @@
|
|
|
40
40
|
"@gmod/bgzf-filehandle": "^4.0.0",
|
|
41
41
|
"@gmod/tabix": "^3.0.1",
|
|
42
42
|
"@gmod/vcf": "^6.0.8",
|
|
43
|
-
"@jbrowse/core": "^3.6.
|
|
44
|
-
"@jbrowse/plugin-circular-view": "^3.6.
|
|
45
|
-
"@jbrowse/plugin-linear-genome-view": "^3.6.
|
|
46
|
-
"@jbrowse/sv-core": "^3.6.
|
|
43
|
+
"@jbrowse/core": "^3.6.5",
|
|
44
|
+
"@jbrowse/plugin-circular-view": "^3.6.5",
|
|
45
|
+
"@jbrowse/plugin-linear-genome-view": "^3.6.5",
|
|
46
|
+
"@jbrowse/sv-core": "^3.6.5",
|
|
47
47
|
"@mui/icons-material": "^7.0.0",
|
|
48
48
|
"@mui/material": "^7.0.0",
|
|
49
49
|
"@mui/x-data-grid": "^8.0.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"distModule": "esm/index.js",
|
|
64
64
|
"srcModule": "src/index.ts",
|
|
65
65
|
"module": "esm/index.js",
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "354d0a87b757b4d84f824b47507662f6f3a1693f"
|
|
67
67
|
}
|