@jbrowse/plugin-variants 2.3.2 → 2.3.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/VariantFeatureWidget/VariantSampleGrid.d.ts +1 -1
- package/dist/VariantFeatureWidget/VariantSampleGrid.js +28 -21
- package/dist/VariantFeatureWidget/VariantSampleGrid.js.map +1 -1
- package/dist/VcfTabixAdapter/VcfTabixAdapter.d.ts +2 -19
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js +0 -34
- package/dist/VcfTabixAdapter/VcfTabixAdapter.js.map +1 -1
- package/esm/VariantFeatureWidget/VariantSampleGrid.d.ts +1 -1
- package/esm/VariantFeatureWidget/VariantSampleGrid.js +28 -21
- package/esm/VariantFeatureWidget/VariantSampleGrid.js.map +1 -1
- package/esm/VcfTabixAdapter/VcfTabixAdapter.d.ts +2 -19
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js +0 -34
- package/esm/VcfTabixAdapter/VcfTabixAdapter.js.map +1 -1
- package/package.json +3 -3
- package/src/VariantFeatureWidget/VariantFeatureWidget.test.tsx +42 -0
- package/src/VariantFeatureWidget/VariantSampleGrid.tsx +47 -36
- package/src/VariantFeatureWidget/__snapshots__/{VariantFeatureWidget.test.js.snap → VariantFeatureWidget.test.tsx.snap} +13 -13
- package/src/VcfAdapter/VcfAdapter.test.ts +4 -3
- package/src/VcfTabixAdapter/VcfTabixAdapter.test.ts +9 -10
- package/src/VcfTabixAdapter/VcfTabixAdapter.ts +2 -50
- package/src/__snapshots__/{index.test.js.snap → index.test.ts.snap} +0 -0
- package/src/{index.test.js → index.test.ts} +0 -1
- package/src/LinearVariantDisplay/configSchema.test.js +0 -55
- package/src/VariantFeatureWidget/VariantFeatureWidget.test.js +0 -41
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { SimpleFeatureSerialized } from '@jbrowse/core/util
|
|
2
|
+
import { SimpleFeatureSerialized } from '@jbrowse/core/util';
|
|
3
3
|
export default function VariantSamples(props: {
|
|
4
4
|
feature: SimpleFeatureSerialized;
|
|
5
5
|
descriptions: any;
|
|
@@ -23,27 +23,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
27
26
|
const react_1 = __importStar(require("react"));
|
|
28
27
|
const material_1 = require("@mui/material");
|
|
29
28
|
const x_data_grid_1 = require("@mui/x-data-grid");
|
|
30
29
|
const BaseFeatureDetail_1 = require("@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail");
|
|
30
|
+
const util_1 = require("@jbrowse/core/util");
|
|
31
|
+
const ResizeBar_1 = __importStar(require("@jbrowse/core/ui/ResizeBar"));
|
|
31
32
|
function VariantSamples(props) {
|
|
32
|
-
|
|
33
|
+
var _a;
|
|
34
|
+
const { feature, descriptions = {} } = props;
|
|
35
|
+
const { ref, scrollLeft } = (0, ResizeBar_1.useResizeBar)();
|
|
33
36
|
const [filter, setFilter] = (0, react_1.useState)({});
|
|
34
37
|
const [showFilters, setShowFilters] = (0, react_1.useState)(false);
|
|
35
|
-
const
|
|
38
|
+
const samples = (feature.samples || {});
|
|
36
39
|
const preFilteredRows = Object.entries(samples);
|
|
37
|
-
if (!preFilteredRows.length) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const infoFields = ['sample', ...Object.keys(preFilteredRows[0][1])].map(field => {
|
|
41
|
-
var _a, _b;
|
|
42
|
-
return ({
|
|
43
|
-
field,
|
|
44
|
-
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
40
|
let error;
|
|
48
41
|
let rows = [];
|
|
49
42
|
const filters = Object.keys(filter);
|
|
@@ -52,11 +45,13 @@ function VariantSamples(props) {
|
|
|
52
45
|
// sortable by the data-grid
|
|
53
46
|
try {
|
|
54
47
|
rows = preFilteredRows
|
|
55
|
-
.map(row =>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
48
|
+
.map(row => {
|
|
49
|
+
return {
|
|
50
|
+
...Object.fromEntries(Object.entries(row[1]).map(e => [e[0], `${e[1]}`])),
|
|
51
|
+
sample: row[0],
|
|
52
|
+
id: row[0],
|
|
53
|
+
};
|
|
54
|
+
})
|
|
60
55
|
.filter(row => filters.length
|
|
61
56
|
? filters.every(key => {
|
|
62
57
|
const val = row[key];
|
|
@@ -68,16 +63,28 @@ function VariantSamples(props) {
|
|
|
68
63
|
catch (e) {
|
|
69
64
|
error = e;
|
|
70
65
|
}
|
|
66
|
+
const keys = ['sample', ...Object.keys(((_a = preFilteredRows[0]) === null || _a === void 0 ? void 0 : _a[1]) || {})];
|
|
67
|
+
const [widths, setWidths] = (0, react_1.useState)(keys.map(e => (0, util_1.measureGridWidth)(rows.map(r => r[e]))));
|
|
68
|
+
const infoFields = keys.map((field, index) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
return ({
|
|
71
|
+
field,
|
|
72
|
+
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
73
|
+
width: widths[index],
|
|
74
|
+
});
|
|
75
|
+
});
|
|
71
76
|
// disableSelectionOnClick helps avoid
|
|
72
77
|
// https://github.com/mui-org/material-ui-x/issues/1197
|
|
73
|
-
return (react_1.default.createElement(BaseFeatureDetail_1.BaseCard, { ...props, title: "Samples" },
|
|
78
|
+
return !preFilteredRows.length ? null : (react_1.default.createElement(BaseFeatureDetail_1.BaseCard, { ...props, title: "Samples" },
|
|
74
79
|
error ? react_1.default.createElement(material_1.Typography, { color: "error" }, `${error}`) : null,
|
|
75
80
|
react_1.default.createElement(material_1.FormControlLabel, { control: react_1.default.createElement(material_1.Checkbox, { checked: showFilters, onChange: () => setShowFilters(f => !f) }), label: "Show sample filters" }),
|
|
76
81
|
showFilters ? (react_1.default.createElement(react_1.default.Fragment, null,
|
|
77
82
|
react_1.default.createElement(material_1.Typography, null, "These filters can use a plain text search or regex style query, e.g. in the genotype field, entering 1 will query for all genotypes that include the first alternate allele e.g. 0|1 or 1|1, entering [1-9]\\d* will find any non-zero allele e.g. 0|2 or 2/33"),
|
|
78
83
|
infoFields.map(({ field }) => (react_1.default.createElement(material_1.TextField, { key: `filter-${field}`, placeholder: `Filter ${field}`, value: filter[field] || '', onChange: event => setFilter({ ...filter, [field]: event.target.value }) }))))) : null,
|
|
79
|
-
react_1.default.createElement("div", {
|
|
80
|
-
react_1.default.createElement(
|
|
84
|
+
react_1.default.createElement("div", { ref: ref },
|
|
85
|
+
react_1.default.createElement(ResizeBar_1.default, { widths: widths, setWidths: setWidths, scrollLeft: scrollLeft }),
|
|
86
|
+
react_1.default.createElement("div", { ref: ref, style: { height: 600, width: '100%', overflow: 'auto' } },
|
|
87
|
+
react_1.default.createElement(x_data_grid_1.DataGrid, { rows: rows, columns: infoFields, disableSelectionOnClick: true, rowHeight: 25, headerHeight: 35, disableColumnMenu: true })))));
|
|
81
88
|
}
|
|
82
89
|
exports.default = VariantSamples;
|
|
83
90
|
//# sourceMappingURL=VariantSampleGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariantSampleGrid.js","sourceRoot":"","sources":["../../src/VariantFeatureWidget/VariantSampleGrid.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"VariantSampleGrid.js","sourceRoot":"","sources":["../../src/VariantFeatureWidget/VariantSampleGrid.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAuC;AAEvC,4CAKsB;AAEtB,kDAA2C;AAC3C,yFAA4E;AAC5E,6CAA8E;AAC9E,wEAAoE;AAWpE,SAAwB,cAA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
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import { NoAssemblyRegion
|
|
3
|
-
import { Feature } from '@jbrowse/core/util
|
|
2
|
+
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
|
+
import { Feature } from '@jbrowse/core/util';
|
|
4
4
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
5
5
|
import VcfParser from '@gmod/vcf';
|
|
6
|
-
import { GenericFilehandle } from 'generic-filehandle';
|
|
7
6
|
export default class extends BaseFeatureDataAdapter {
|
|
8
7
|
private configured?;
|
|
9
8
|
private configurePre;
|
|
10
9
|
protected configure(): Promise<{
|
|
11
|
-
filehandle: GenericFilehandle;
|
|
12
10
|
vcf: TabixIndexedFile;
|
|
13
11
|
parser: VcfParser;
|
|
14
12
|
}>;
|
|
@@ -16,20 +14,5 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
16
14
|
getHeader(): Promise<string>;
|
|
17
15
|
getMetadata(): Promise<any>;
|
|
18
16
|
getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if the data source has data for the given reference sequence,
|
|
21
|
-
* and then gets the features in the region if it does
|
|
22
|
-
*
|
|
23
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
24
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
25
|
-
* implement a more efficient custom version of this method.
|
|
26
|
-
*
|
|
27
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
28
|
-
* of a VCF
|
|
29
|
-
* @param regions - Regions
|
|
30
|
-
* @param opts - Feature adapter options
|
|
31
|
-
* @returns Observable of Feature objects in the regions
|
|
32
|
-
*/
|
|
33
|
-
getFeaturesInMultipleRegions(regions: Region[], opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
34
17
|
freeResources(): void;
|
|
35
18
|
}
|
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
|
|
7
7
|
const io_1 = require("@jbrowse/core/util/io");
|
|
8
|
-
const util_1 = require("@jbrowse/core/util");
|
|
9
8
|
const rxjs_1 = require("@jbrowse/core/util/rxjs");
|
|
10
9
|
const tabix_1 = require("@gmod/tabix");
|
|
11
10
|
const vcf_1 = __importDefault(require("@gmod/vcf"));
|
|
@@ -28,7 +27,6 @@ class default_1 extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
28
27
|
});
|
|
29
28
|
const header = await vcf.getHeader();
|
|
30
29
|
return {
|
|
31
|
-
filehandle,
|
|
32
30
|
vcf,
|
|
33
31
|
parser: new vcf_1.default({ header }),
|
|
34
32
|
};
|
|
@@ -71,38 +69,6 @@ class default_1 extends BaseAdapter_1.BaseFeatureDataAdapter {
|
|
|
71
69
|
observer.complete();
|
|
72
70
|
}, opts.signal);
|
|
73
71
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Checks if the data source has data for the given reference sequence,
|
|
76
|
-
* and then gets the features in the region if it does
|
|
77
|
-
*
|
|
78
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
79
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
80
|
-
* implement a more efficient custom version of this method.
|
|
81
|
-
*
|
|
82
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
83
|
-
* of a VCF
|
|
84
|
-
* @param regions - Regions
|
|
85
|
-
* @param opts - Feature adapter options
|
|
86
|
-
* @returns Observable of Feature objects in the regions
|
|
87
|
-
*/
|
|
88
|
-
getFeaturesInMultipleRegions(regions, opts = {}) {
|
|
89
|
-
return (0, rxjs_1.ObservableCreate)(async (observer) => {
|
|
90
|
-
const { vcf } = await this.configure();
|
|
91
|
-
// @ts-ignore
|
|
92
|
-
const bytes = await (0, util_1.bytesForRegions)(regions, vcf.index);
|
|
93
|
-
const { filehandle } = await this.configure();
|
|
94
|
-
const stat = await filehandle.stat();
|
|
95
|
-
let pct = Math.round((bytes / stat.size) * 100);
|
|
96
|
-
if (pct > 100) {
|
|
97
|
-
// this is just a bad estimate, make 100% if it goes over
|
|
98
|
-
pct = 100;
|
|
99
|
-
}
|
|
100
|
-
if (pct > 60) {
|
|
101
|
-
console.warn(`getFeaturesInMultipleRegions fetching ${pct}% of VCF file, but whole-file streaming not yet implemented`);
|
|
102
|
-
}
|
|
103
|
-
super.getFeaturesInMultipleRegions(regions, opts).subscribe(observer);
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
72
|
freeResources( /* { region } */) { }
|
|
107
73
|
}
|
|
108
74
|
exports.default = default_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VcfTabixAdapter.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfTabixAdapter.ts"],"names":[],"mappings":";;;;;AAAA,yEAGgD;
|
|
1
|
+
{"version":3,"file":"VcfTabixAdapter.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfTabixAdapter.ts"],"names":[],"mappings":";;;;;AAAA,yEAGgD;AAEhD,8CAAoD;AACpD,kDAA0D;AAE1D,uCAA8C;AAC9C,oDAAiC;AAEjC,QAAQ;AACR,+DAAsC;AAEtC,eAAqB,SAAQ,oCAAsB;IAMzC,KAAK,CAAC,YAAY;QACxB,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,CAAA;QAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;QACpD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAA;QAEtD,MAAM,UAAU,GAAG,IAAA,iBAAY,EAAC,aAA6B,EAAE,EAAE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B,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;QACzC,OAAO,MAAM,CAAC,WAAW,EAAE,CAAA;IAC7B,CAAC;IAEM,WAAW,CAAC,KAAuB,EAAE,OAAoB,EAAE;QAChE,OAAO,IAAA,uBAAgB,EAAU,KAAK,EAAC,QAAQ,EAAC,EAAE;YAChD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,CAAA;YACrC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;YAC9C,MAAM,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE;gBACtC,YAAY,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE;oBACjC,QAAQ,CAAC,IAAI,CACX,IAAI,oBAAU,CAAC;wBACb,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;wBAC/B,MAAM;wBACN,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,QAAQ,UAAU,EAAE;qBACnC,CAAC,CACH,CAAA;gBACH,CAAC;gBACD,GAAG,IAAI;aACR,CAAC,CAAA;YACF,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC;IAEM,aAAa,EAAC,gBAAgB,IAAS,CAAC;CAChD;AA3ED,4BA2EC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { SimpleFeatureSerialized } from '@jbrowse/core/util
|
|
2
|
+
import { SimpleFeatureSerialized } from '@jbrowse/core/util';
|
|
3
3
|
export default function VariantSamples(props: {
|
|
4
4
|
feature: SimpleFeatureSerialized;
|
|
5
5
|
descriptions: any;
|
|
@@ -1,24 +1,17 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import React, { useState } from 'react';
|
|
3
2
|
import { FormControlLabel, Checkbox, TextField, Typography, } from '@mui/material';
|
|
4
3
|
import { DataGrid } from '@mui/x-data-grid';
|
|
5
4
|
import { BaseCard } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail';
|
|
5
|
+
import { measureGridWidth } from '@jbrowse/core/util';
|
|
6
|
+
import ResizeBar, { useResizeBar } from '@jbrowse/core/ui/ResizeBar';
|
|
6
7
|
export default function VariantSamples(props) {
|
|
7
|
-
|
|
8
|
+
var _a;
|
|
9
|
+
const { feature, descriptions = {} } = props;
|
|
10
|
+
const { ref, scrollLeft } = useResizeBar();
|
|
8
11
|
const [filter, setFilter] = useState({});
|
|
9
12
|
const [showFilters, setShowFilters] = useState(false);
|
|
10
|
-
const
|
|
13
|
+
const samples = (feature.samples || {});
|
|
11
14
|
const preFilteredRows = Object.entries(samples);
|
|
12
|
-
if (!preFilteredRows.length) {
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
const infoFields = ['sample', ...Object.keys(preFilteredRows[0][1])].map(field => {
|
|
16
|
-
var _a, _b;
|
|
17
|
-
return ({
|
|
18
|
-
field,
|
|
19
|
-
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
15
|
let error;
|
|
23
16
|
let rows = [];
|
|
24
17
|
const filters = Object.keys(filter);
|
|
@@ -27,11 +20,13 @@ export default function VariantSamples(props) {
|
|
|
27
20
|
// sortable by the data-grid
|
|
28
21
|
try {
|
|
29
22
|
rows = preFilteredRows
|
|
30
|
-
.map(row =>
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
23
|
+
.map(row => {
|
|
24
|
+
return {
|
|
25
|
+
...Object.fromEntries(Object.entries(row[1]).map(e => [e[0], `${e[1]}`])),
|
|
26
|
+
sample: row[0],
|
|
27
|
+
id: row[0],
|
|
28
|
+
};
|
|
29
|
+
})
|
|
35
30
|
.filter(row => filters.length
|
|
36
31
|
? filters.every(key => {
|
|
37
32
|
const val = row[key];
|
|
@@ -43,15 +38,27 @@ export default function VariantSamples(props) {
|
|
|
43
38
|
catch (e) {
|
|
44
39
|
error = e;
|
|
45
40
|
}
|
|
41
|
+
const keys = ['sample', ...Object.keys(((_a = preFilteredRows[0]) === null || _a === void 0 ? void 0 : _a[1]) || {})];
|
|
42
|
+
const [widths, setWidths] = useState(keys.map(e => measureGridWidth(rows.map(r => r[e]))));
|
|
43
|
+
const infoFields = keys.map((field, index) => {
|
|
44
|
+
var _a, _b;
|
|
45
|
+
return ({
|
|
46
|
+
field,
|
|
47
|
+
description: (_b = (_a = descriptions.FORMAT) === null || _a === void 0 ? void 0 : _a[field]) === null || _b === void 0 ? void 0 : _b.Description,
|
|
48
|
+
width: widths[index],
|
|
49
|
+
});
|
|
50
|
+
});
|
|
46
51
|
// disableSelectionOnClick helps avoid
|
|
47
52
|
// https://github.com/mui-org/material-ui-x/issues/1197
|
|
48
|
-
return (React.createElement(BaseCard, { ...props, title: "Samples" },
|
|
53
|
+
return !preFilteredRows.length ? null : (React.createElement(BaseCard, { ...props, title: "Samples" },
|
|
49
54
|
error ? React.createElement(Typography, { color: "error" }, `${error}`) : null,
|
|
50
55
|
React.createElement(FormControlLabel, { control: React.createElement(Checkbox, { checked: showFilters, onChange: () => setShowFilters(f => !f) }), label: "Show sample filters" }),
|
|
51
56
|
showFilters ? (React.createElement(React.Fragment, null,
|
|
52
57
|
React.createElement(Typography, null, "These filters can use a plain text search or regex style query, e.g. in the genotype field, entering 1 will query for all genotypes that include the first alternate allele e.g. 0|1 or 1|1, entering [1-9]\\d* will find any non-zero allele e.g. 0|2 or 2/33"),
|
|
53
58
|
infoFields.map(({ field }) => (React.createElement(TextField, { key: `filter-${field}`, placeholder: `Filter ${field}`, value: filter[field] || '', onChange: event => setFilter({ ...filter, [field]: event.target.value }) }))))) : null,
|
|
54
|
-
React.createElement("div", {
|
|
55
|
-
React.createElement(
|
|
59
|
+
React.createElement("div", { ref: ref },
|
|
60
|
+
React.createElement(ResizeBar, { widths: widths, setWidths: setWidths, scrollLeft: scrollLeft }),
|
|
61
|
+
React.createElement("div", { ref: ref, style: { height: 600, width: '100%', overflow: 'auto' } },
|
|
62
|
+
React.createElement(DataGrid, { rows: rows, columns: infoFields, disableSelectionOnClick: true, rowHeight: 25, headerHeight: 35, disableColumnMenu: true })))));
|
|
56
63
|
}
|
|
57
64
|
//# sourceMappingURL=VariantSampleGrid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VariantSampleGrid.js","sourceRoot":"","sources":["../../src/VariantFeatureWidget/VariantSampleGrid.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"VariantSampleGrid.js","sourceRoot":"","sources":["../../src/VariantFeatureWidget/VariantSampleGrid.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEvC,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,SAAS,EACT,UAAU,GACX,MAAM,eAAe,CAAA;AAEtB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mDAAmD,CAAA;AAC5E,OAAO,EAAE,gBAAgB,EAA2B,MAAM,oBAAoB,CAAA;AAC9E,OAAO,SAAS,EAAE,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAWpE,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAItC;;IACC,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,KAAK,CAAA;IAC5C,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,YAAY,EAAE,CAAA;IAC1C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAA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qB,GAC3B;QACD,WAAW,CAAC,CAAC,CAAC,CACb;YACE,oBAAC,UAAU,yQAKE;YACZ,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAC7B,oBAAC,SAAS,IACR,GAAG,EAAE,UAAU,KAAK,EAAE,EACtB,WAAW,EAAE,UAAU,KAAK,EAAE,EAC9B,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,EAC1B,QAAQ,EAAE,KAAK,CAAC,EAAE,CAChB,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAEvD,CACH,CAAC,CACD,CACJ,CAAC,CAAC,CAAC,IAAI;QACR,6BAAK,GAAG,EAAE,GAAG;YACX,oBAAC,SAAS,IACR,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,UAAU,GACtB;YACF,6BAAK,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE;gBACpE,oBAAC,QAAQ,IACP,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,UAAU,EACnB,uBAAuB,QACvB,SAAS,EAAE,EAAE,EACb,YAAY,EAAE,EAAE,EAChB,iBAAiB,SACjB,CACE,CACF,CACG,CACZ,CAAA;AACH,CAAC"}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { BaseFeatureDataAdapter, BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
|
-
import { NoAssemblyRegion
|
|
3
|
-
import { Feature } from '@jbrowse/core/util
|
|
2
|
+
import { NoAssemblyRegion } from '@jbrowse/core/util/types';
|
|
3
|
+
import { Feature } from '@jbrowse/core/util';
|
|
4
4
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
5
5
|
import VcfParser from '@gmod/vcf';
|
|
6
|
-
import { GenericFilehandle } from 'generic-filehandle';
|
|
7
6
|
export default class extends BaseFeatureDataAdapter {
|
|
8
7
|
private configured?;
|
|
9
8
|
private configurePre;
|
|
10
9
|
protected configure(): Promise<{
|
|
11
|
-
filehandle: GenericFilehandle;
|
|
12
10
|
vcf: TabixIndexedFile;
|
|
13
11
|
parser: VcfParser;
|
|
14
12
|
}>;
|
|
@@ -16,20 +14,5 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
16
14
|
getHeader(): Promise<string>;
|
|
17
15
|
getMetadata(): Promise<any>;
|
|
18
16
|
getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
19
|
-
/**
|
|
20
|
-
* Checks if the data source has data for the given reference sequence,
|
|
21
|
-
* and then gets the features in the region if it does
|
|
22
|
-
*
|
|
23
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
24
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
25
|
-
* implement a more efficient custom version of this method.
|
|
26
|
-
*
|
|
27
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
28
|
-
* of a VCF
|
|
29
|
-
* @param regions - Regions
|
|
30
|
-
* @param opts - Feature adapter options
|
|
31
|
-
* @returns Observable of Feature objects in the regions
|
|
32
|
-
*/
|
|
33
|
-
getFeaturesInMultipleRegions(regions: Region[], opts?: BaseOptions): import("rxjs").Observable<Feature>;
|
|
34
17
|
freeResources(): void;
|
|
35
18
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { BaseFeatureDataAdapter, } from '@jbrowse/core/data_adapters/BaseAdapter';
|
|
2
2
|
import { openLocation } from '@jbrowse/core/util/io';
|
|
3
|
-
import { bytesForRegions } from '@jbrowse/core/util';
|
|
4
3
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs';
|
|
5
4
|
import { TabixIndexedFile } from '@gmod/tabix';
|
|
6
5
|
import VcfParser from '@gmod/vcf';
|
|
@@ -23,7 +22,6 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
23
22
|
});
|
|
24
23
|
const header = await vcf.getHeader();
|
|
25
24
|
return {
|
|
26
|
-
filehandle,
|
|
27
25
|
vcf,
|
|
28
26
|
parser: new VcfParser({ header }),
|
|
29
27
|
};
|
|
@@ -66,38 +64,6 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
66
64
|
observer.complete();
|
|
67
65
|
}, opts.signal);
|
|
68
66
|
}
|
|
69
|
-
/**
|
|
70
|
-
* Checks if the data source has data for the given reference sequence,
|
|
71
|
-
* and then gets the features in the region if it does
|
|
72
|
-
*
|
|
73
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
74
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
75
|
-
* implement a more efficient custom version of this method.
|
|
76
|
-
*
|
|
77
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
78
|
-
* of a VCF
|
|
79
|
-
* @param regions - Regions
|
|
80
|
-
* @param opts - Feature adapter options
|
|
81
|
-
* @returns Observable of Feature objects in the regions
|
|
82
|
-
*/
|
|
83
|
-
getFeaturesInMultipleRegions(regions, opts = {}) {
|
|
84
|
-
return ObservableCreate(async (observer) => {
|
|
85
|
-
const { vcf } = await this.configure();
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
const bytes = await bytesForRegions(regions, vcf.index);
|
|
88
|
-
const { filehandle } = await this.configure();
|
|
89
|
-
const stat = await filehandle.stat();
|
|
90
|
-
let pct = Math.round((bytes / stat.size) * 100);
|
|
91
|
-
if (pct > 100) {
|
|
92
|
-
// this is just a bad estimate, make 100% if it goes over
|
|
93
|
-
pct = 100;
|
|
94
|
-
}
|
|
95
|
-
if (pct > 60) {
|
|
96
|
-
console.warn(`getFeaturesInMultipleRegions fetching ${pct}% of VCF file, but whole-file streaming not yet implemented`);
|
|
97
|
-
}
|
|
98
|
-
super.getFeaturesInMultipleRegions(regions, opts).subscribe(observer);
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
67
|
freeResources( /* { region } */) { }
|
|
102
68
|
}
|
|
103
69
|
//# sourceMappingURL=VcfTabixAdapter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VcfTabixAdapter.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfTabixAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,GAEvB,MAAM,yCAAyC,CAAA;
|
|
1
|
+
{"version":3,"file":"VcfTabixAdapter.js","sourceRoot":"","sources":["../../src/VcfTabixAdapter/VcfTabixAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,GAEvB,MAAM,yCAAyC,CAAA;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,SAAS,MAAM,WAAW,CAAA;AAEjC,QAAQ;AACR,OAAO,UAAU,MAAM,eAAe,CAAA;AAEtC,MAAM,CAAC,OAAO,MAAO,SAAQ,sBAAsB;IAMzC,KAAK,CAAC,YAAY;QACxB,MAAM,EAAE,GAAG,IAAI,CAAC,aAAa,CAAA;QAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;QACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAA;QACpD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAA;QAEtD,MAAM,UAAU,GAAG,YAAY,CAAC,aAA6B,EAAE,EAAE,CAAC,CAAA;QAClE,MAAM,KAAK,GAAG,SAAS,KAAK,KAAK,CAAA;QACjC,MAAM,GAAG,GAAG,IAAI,gBAAgB,CAAC;YAC/B,UAAU;YACV,aAAa,EAAE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B,CAAC;IAEM,WAAW,CAAC,KAAuB,EAAE,OAAoB,EAAE;QAChE,OAAO,gBAAgB,CAAU,KAAK,EAAC,QAAQ,EAAC,EAAE;YAChD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,KAAK,CAAA;YACrC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;YAC9C,MAAM,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE;gBACtC,YAAY,EAAE,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE;oBACjC,QAAQ,CAAC,IAAI,CACX,IAAI,UAAU,CAAC;wBACb,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC;wBAC/B,MAAM;wBACN,EAAE,EAAE,GAAG,IAAI,CAAC,EAAE,QAAQ,UAAU,EAAE;qBACnC,CAAC,CACH,CAAA;gBACH,CAAC;gBACD,GAAG,IAAI;aACR,CAAC,CAAA;YACF,QAAQ,CAAC,QAAQ,EAAE,CAAA;QACrB,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IACjB,CAAC;IAEM,aAAa,EAAC,gBAAgB,IAAS,CAAC;CAChD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-variants",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"description": "JBrowse 2 variant adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"mobx-react": "^7.0.0",
|
|
56
56
|
"mobx-state-tree": "^5.0.0",
|
|
57
57
|
"react": ">=16.8.0",
|
|
58
|
-
"rxjs": "^
|
|
58
|
+
"rxjs": "^7.0.0",
|
|
59
59
|
"tss-react": "^4.0.0"
|
|
60
60
|
},
|
|
61
61
|
"publishConfig": {
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"distModule": "esm/index.js",
|
|
65
65
|
"srcModule": "src/index.ts",
|
|
66
66
|
"module": "esm/index.js",
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "98ae48be91ee2371e1b2768a907b4997995e9915"
|
|
68
68
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import { types } from 'mobx-state-tree'
|
|
4
|
+
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
5
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
6
|
+
|
|
7
|
+
// locals
|
|
8
|
+
import { stateModelFactory } from '.'
|
|
9
|
+
import VariantFeatureDetails from './VariantFeatureWidget'
|
|
10
|
+
|
|
11
|
+
test('renders with just the required model elements', () => {
|
|
12
|
+
const pluginManager = new PluginManager([])
|
|
13
|
+
const Session = types.model({
|
|
14
|
+
rpcManager: types.optional(types.frozen(), {}),
|
|
15
|
+
configuration: ConfigurationSchema('test', {}),
|
|
16
|
+
widget: stateModelFactory(pluginManager),
|
|
17
|
+
})
|
|
18
|
+
const model = Session.create(
|
|
19
|
+
{
|
|
20
|
+
widget: {
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
type: 'VariantFeatureWidget',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{ pluginManager },
|
|
26
|
+
)
|
|
27
|
+
model.widget.setFeatureData({
|
|
28
|
+
refName: 'ctgA',
|
|
29
|
+
start: 176,
|
|
30
|
+
end: 177,
|
|
31
|
+
name: 'rs123',
|
|
32
|
+
REF: 'A',
|
|
33
|
+
ALT: ['<TRA>'],
|
|
34
|
+
QUAL: 10.4,
|
|
35
|
+
INFO: {
|
|
36
|
+
MQ: 5,
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const { container } = render(<VariantFeatureDetails model={model.widget} />)
|
|
41
|
+
expect(container.firstChild).toMatchSnapshot()
|
|
42
|
+
})
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import React, { useState } from 'react'
|
|
3
2
|
|
|
4
3
|
import {
|
|
@@ -10,7 +9,8 @@ import {
|
|
|
10
9
|
|
|
11
10
|
import { DataGrid } from '@mui/x-data-grid'
|
|
12
11
|
import { BaseCard } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail'
|
|
13
|
-
import { SimpleFeatureSerialized } from '@jbrowse/core/util
|
|
12
|
+
import { measureGridWidth, SimpleFeatureSerialized } from '@jbrowse/core/util'
|
|
13
|
+
import ResizeBar, { useResizeBar } from '@jbrowse/core/ui/ResizeBar'
|
|
14
14
|
|
|
15
15
|
interface Entry {
|
|
16
16
|
sample: string
|
|
@@ -18,28 +18,20 @@ interface Entry {
|
|
|
18
18
|
[key: string]: string
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
+
type InfoFields = Record<string, unknown>
|
|
22
|
+
type Filters = Record<string, string>
|
|
23
|
+
|
|
21
24
|
export default function VariantSamples(props: {
|
|
22
25
|
feature: SimpleFeatureSerialized
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
27
|
descriptions: any
|
|
24
28
|
}) {
|
|
25
|
-
const { feature, descriptions } = props
|
|
26
|
-
const
|
|
29
|
+
const { feature, descriptions = {} } = props
|
|
30
|
+
const { ref, scrollLeft } = useResizeBar()
|
|
31
|
+
const [filter, setFilter] = useState<Filters>({})
|
|
27
32
|
const [showFilters, setShowFilters] = useState(false)
|
|
28
|
-
const
|
|
29
|
-
string,
|
|
30
|
-
Record<string, Record<string, unknown>>
|
|
31
|
-
>
|
|
33
|
+
const samples = (feature.samples || {}) as Record<string, InfoFields>
|
|
32
34
|
const preFilteredRows = Object.entries(samples)
|
|
33
|
-
if (!preFilteredRows.length) {
|
|
34
|
-
return null
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const infoFields = ['sample', ...Object.keys(preFilteredRows[0][1])].map(
|
|
38
|
-
field => ({
|
|
39
|
-
field,
|
|
40
|
-
description: descriptions.FORMAT?.[field]?.Description,
|
|
41
|
-
}),
|
|
42
|
-
)
|
|
43
35
|
|
|
44
36
|
let error
|
|
45
37
|
let rows = [] as Entry[]
|
|
@@ -50,16 +42,15 @@ export default function VariantSamples(props: {
|
|
|
50
42
|
// sortable by the data-grid
|
|
51
43
|
try {
|
|
52
44
|
rows = preFilteredRows
|
|
53
|
-
.map(
|
|
54
|
-
|
|
55
|
-
(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
)
|
|
45
|
+
.map(row => {
|
|
46
|
+
return {
|
|
47
|
+
...Object.fromEntries(
|
|
48
|
+
Object.entries(row[1]).map(e => [e[0], `${e[1]}`]),
|
|
49
|
+
),
|
|
50
|
+
sample: row[0],
|
|
51
|
+
id: row[0],
|
|
52
|
+
} as Entry
|
|
53
|
+
})
|
|
63
54
|
.filter(row =>
|
|
64
55
|
filters.length
|
|
65
56
|
? filters.every(key => {
|
|
@@ -72,9 +63,21 @@ export default function VariantSamples(props: {
|
|
|
72
63
|
} catch (e) {
|
|
73
64
|
error = e
|
|
74
65
|
}
|
|
66
|
+
|
|
67
|
+
const keys = ['sample', ...Object.keys(preFilteredRows[0]?.[1] || {})]
|
|
68
|
+
|
|
69
|
+
const [widths, setWidths] = useState(
|
|
70
|
+
keys.map(e => measureGridWidth(rows.map(r => r[e]))),
|
|
71
|
+
)
|
|
72
|
+
const infoFields = keys.map((field, index) => ({
|
|
73
|
+
field,
|
|
74
|
+
description: descriptions.FORMAT?.[field]?.Description,
|
|
75
|
+
width: widths[index],
|
|
76
|
+
}))
|
|
77
|
+
|
|
75
78
|
// disableSelectionOnClick helps avoid
|
|
76
79
|
// https://github.com/mui-org/material-ui-x/issues/1197
|
|
77
|
-
return (
|
|
80
|
+
return !preFilteredRows.length ? null : (
|
|
78
81
|
<BaseCard {...props} title="Samples">
|
|
79
82
|
{error ? <Typography color="error">{`${error}`}</Typography> : null}
|
|
80
83
|
|
|
@@ -107,14 +110,22 @@ export default function VariantSamples(props: {
|
|
|
107
110
|
))}
|
|
108
111
|
</>
|
|
109
112
|
) : null}
|
|
110
|
-
<div
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
rowHeight={25}
|
|
116
|
-
disableColumnMenu
|
|
113
|
+
<div ref={ref}>
|
|
114
|
+
<ResizeBar
|
|
115
|
+
widths={widths}
|
|
116
|
+
setWidths={setWidths}
|
|
117
|
+
scrollLeft={scrollLeft}
|
|
117
118
|
/>
|
|
119
|
+
<div ref={ref} style={{ height: 600, width: '100%', overflow: 'auto' }}>
|
|
120
|
+
<DataGrid
|
|
121
|
+
rows={rows}
|
|
122
|
+
columns={infoFields}
|
|
123
|
+
disableSelectionOnClick
|
|
124
|
+
rowHeight={25}
|
|
125
|
+
headerHeight={35}
|
|
126
|
+
disableColumnMenu
|
|
127
|
+
/>
|
|
128
|
+
</div>
|
|
118
129
|
</div>
|
|
119
130
|
</BaseCard>
|
|
120
131
|
)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`renders with just the required model elements 1`] = `
|
|
4
4
|
<div
|
|
5
5
|
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 css-1ps6pg7-MuiPaper-root"
|
|
6
6
|
data-testid="variant-side-drawer"
|
|
@@ -87,9 +87,9 @@ exports[`VariantTrack widget renders with just the required model elements 1`] =
|
|
|
87
87
|
<div
|
|
88
88
|
class="css-1omt041-fieldValue"
|
|
89
89
|
>
|
|
90
|
-
<
|
|
90
|
+
<span>
|
|
91
91
|
rs123
|
|
92
|
-
</
|
|
92
|
+
</span>
|
|
93
93
|
</div>
|
|
94
94
|
</div>
|
|
95
95
|
<div
|
|
@@ -103,9 +103,9 @@ exports[`VariantTrack widget renders with just the required model elements 1`] =
|
|
|
103
103
|
<div
|
|
104
104
|
class="css-1omt041-fieldValue"
|
|
105
105
|
>
|
|
106
|
-
<
|
|
106
|
+
<span>
|
|
107
107
|
1
|
|
108
|
-
</
|
|
108
|
+
</span>
|
|
109
109
|
</div>
|
|
110
110
|
</div>
|
|
111
111
|
<hr
|
|
@@ -129,9 +129,9 @@ exports[`VariantTrack widget renders with just the required model elements 1`] =
|
|
|
129
129
|
<div
|
|
130
130
|
class="css-1omt041-fieldValue"
|
|
131
131
|
>
|
|
132
|
-
<
|
|
132
|
+
<span>
|
|
133
133
|
A
|
|
134
|
-
</
|
|
134
|
+
</span>
|
|
135
135
|
</div>
|
|
136
136
|
</div>
|
|
137
137
|
<div
|
|
@@ -147,9 +147,9 @@ exports[`VariantTrack widget renders with just the required model elements 1`] =
|
|
|
147
147
|
<div
|
|
148
148
|
class="css-1omt041-fieldValue"
|
|
149
149
|
>
|
|
150
|
-
<
|
|
150
|
+
<span>
|
|
151
151
|
<TRA>
|
|
152
|
-
</
|
|
152
|
+
</span>
|
|
153
153
|
</div>
|
|
154
154
|
</div>
|
|
155
155
|
<div
|
|
@@ -165,9 +165,9 @@ exports[`VariantTrack widget renders with just the required model elements 1`] =
|
|
|
165
165
|
<div
|
|
166
166
|
class="css-1omt041-fieldValue"
|
|
167
167
|
>
|
|
168
|
-
<
|
|
168
|
+
<span>
|
|
169
169
|
10.4
|
|
170
|
-
</
|
|
170
|
+
</span>
|
|
171
171
|
</div>
|
|
172
172
|
</div>
|
|
173
173
|
<div
|
|
@@ -182,9 +182,9 @@ exports[`VariantTrack widget renders with just the required model elements 1`] =
|
|
|
182
182
|
<div
|
|
183
183
|
class="css-1omt041-fieldValue"
|
|
184
184
|
>
|
|
185
|
-
<
|
|
185
|
+
<span>
|
|
186
186
|
5
|
|
187
|
-
</
|
|
187
|
+
</span>
|
|
188
188
|
</div>
|
|
189
189
|
</div>
|
|
190
190
|
<div
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toArray } from 'rxjs/operators'
|
|
2
|
+
import { firstValueFrom } from 'rxjs'
|
|
2
3
|
import Adapter from './VcfAdapter'
|
|
3
4
|
import configSchema from './configSchema'
|
|
4
5
|
|
|
@@ -12,7 +13,7 @@ test('adapter can fetch variants from volvox.vcf', async () => {
|
|
|
12
13
|
}),
|
|
13
14
|
)
|
|
14
15
|
|
|
15
|
-
const
|
|
16
|
+
const feat = adapter.getFeatures({
|
|
16
17
|
assemblyName: 'volvox',
|
|
17
18
|
refName: 'ctgA',
|
|
18
19
|
start: 0,
|
|
@@ -22,6 +23,6 @@ test('adapter can fetch variants from volvox.vcf', async () => {
|
|
|
22
23
|
const names = await adapter.getRefNames()
|
|
23
24
|
expect(names).toMatchSnapshot()
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
-
expect(
|
|
26
|
+
const featArray = await firstValueFrom(feat.pipe(toArray()))
|
|
27
|
+
expect(featArray.slice(0, 5)).toMatchSnapshot()
|
|
27
28
|
})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { toArray } from 'rxjs/operators'
|
|
2
|
+
import { firstValueFrom } from 'rxjs'
|
|
2
3
|
import Adapter from './VcfTabixAdapter'
|
|
3
4
|
import configSchema from './configSchema'
|
|
4
5
|
|
|
@@ -46,25 +47,23 @@ test('adapter can fetch variants from volvox.vcf.gz', async () => {
|
|
|
46
47
|
expect(names).toEqual(csiNames)
|
|
47
48
|
expect(names).toMatchSnapshot()
|
|
48
49
|
|
|
49
|
-
const
|
|
50
|
+
const feat = adapter.getFeatures({
|
|
50
51
|
refName: 'ctgA',
|
|
51
52
|
start: 0,
|
|
52
53
|
end: 20000,
|
|
53
54
|
})
|
|
54
55
|
|
|
55
|
-
const
|
|
56
|
-
const csiFeaturesArray = await csiFeatures.pipe(toArray())
|
|
57
|
-
expect(
|
|
58
|
-
expect(csiFeaturesArray.slice(0, 5)).toEqual(
|
|
56
|
+
const featArray = await firstValueFrom(feat.pipe(toArray()))
|
|
57
|
+
const csiFeaturesArray = await firstValueFrom(csiFeatures.pipe(toArray()))
|
|
58
|
+
expect(featArray.slice(0, 5)).toMatchSnapshot()
|
|
59
|
+
expect(csiFeaturesArray.slice(0, 5)).toEqual(featArray.slice(0, 5))
|
|
59
60
|
|
|
60
|
-
const
|
|
61
|
+
const featNonExist = adapter.getFeatures({
|
|
61
62
|
refName: 'ctgC',
|
|
62
63
|
start: 0,
|
|
63
64
|
end: 20000,
|
|
64
65
|
})
|
|
65
66
|
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
.toPromise()
|
|
69
|
-
expect(featuresArrayNonExist).toEqual([])
|
|
67
|
+
const featArrayNonExist = await firstValueFrom(featNonExist.pipe(toArray()))
|
|
68
|
+
expect(featArrayNonExist).toEqual([])
|
|
70
69
|
})
|
|
@@ -2,26 +2,18 @@ import {
|
|
|
2
2
|
BaseFeatureDataAdapter,
|
|
3
3
|
BaseOptions,
|
|
4
4
|
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
5
|
-
import {
|
|
6
|
-
FileLocation,
|
|
7
|
-
NoAssemblyRegion,
|
|
8
|
-
Region,
|
|
9
|
-
} from '@jbrowse/core/util/types'
|
|
5
|
+
import { FileLocation, NoAssemblyRegion } from '@jbrowse/core/util/types'
|
|
10
6
|
import { openLocation } from '@jbrowse/core/util/io'
|
|
11
|
-
import { bytesForRegions } from '@jbrowse/core/util'
|
|
12
7
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
13
|
-
import { Feature } from '@jbrowse/core/util
|
|
8
|
+
import { Feature } from '@jbrowse/core/util'
|
|
14
9
|
import { TabixIndexedFile } from '@gmod/tabix'
|
|
15
10
|
import VcfParser from '@gmod/vcf'
|
|
16
|
-
import { Observer } from 'rxjs'
|
|
17
|
-
import { GenericFilehandle } from 'generic-filehandle'
|
|
18
11
|
|
|
19
12
|
// local
|
|
20
13
|
import VcfFeature from '../VcfFeature'
|
|
21
14
|
|
|
22
15
|
export default class extends BaseFeatureDataAdapter {
|
|
23
16
|
private configured?: Promise<{
|
|
24
|
-
filehandle: GenericFilehandle
|
|
25
17
|
vcf: TabixIndexedFile
|
|
26
18
|
parser: VcfParser
|
|
27
19
|
}>
|
|
@@ -44,7 +36,6 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
44
36
|
|
|
45
37
|
const header = await vcf.getHeader()
|
|
46
38
|
return {
|
|
47
|
-
filehandle,
|
|
48
39
|
vcf,
|
|
49
40
|
parser: new VcfParser({ header }),
|
|
50
41
|
}
|
|
@@ -95,44 +86,5 @@ export default class extends BaseFeatureDataAdapter {
|
|
|
95
86
|
}, opts.signal)
|
|
96
87
|
}
|
|
97
88
|
|
|
98
|
-
/**
|
|
99
|
-
* Checks if the data source has data for the given reference sequence,
|
|
100
|
-
* and then gets the features in the region if it does
|
|
101
|
-
*
|
|
102
|
-
* Currently this just calls getFeatureInRegion for each region. Adapters that
|
|
103
|
-
* are frequently called on multiple regions simultaneously may want to
|
|
104
|
-
* implement a more efficient custom version of this method.
|
|
105
|
-
*
|
|
106
|
-
* Also includes a bit of extra logging to warn when fetching a large portion
|
|
107
|
-
* of a VCF
|
|
108
|
-
* @param regions - Regions
|
|
109
|
-
* @param opts - Feature adapter options
|
|
110
|
-
* @returns Observable of Feature objects in the regions
|
|
111
|
-
*/
|
|
112
|
-
public getFeaturesInMultipleRegions(
|
|
113
|
-
regions: Region[],
|
|
114
|
-
opts: BaseOptions = {},
|
|
115
|
-
) {
|
|
116
|
-
return ObservableCreate<Feature>(async (observer: Observer<Feature>) => {
|
|
117
|
-
const { vcf } = await this.configure()
|
|
118
|
-
|
|
119
|
-
// @ts-ignore
|
|
120
|
-
const bytes = await bytesForRegions(regions, vcf.index)
|
|
121
|
-
const { filehandle } = await this.configure()
|
|
122
|
-
const stat = await filehandle.stat()
|
|
123
|
-
let pct = Math.round((bytes / stat.size) * 100)
|
|
124
|
-
if (pct > 100) {
|
|
125
|
-
// this is just a bad estimate, make 100% if it goes over
|
|
126
|
-
pct = 100
|
|
127
|
-
}
|
|
128
|
-
if (pct > 60) {
|
|
129
|
-
console.warn(
|
|
130
|
-
`getFeaturesInMultipleRegions fetching ${pct}% of VCF file, but whole-file streaming not yet implemented`,
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
super.getFeaturesInMultipleRegions(regions, opts).subscribe(observer)
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
89
|
public freeResources(/* { region } */): void {}
|
|
138
90
|
}
|
|
File without changes
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import BoxRendererType from '@jbrowse/core/pluggableElementTypes/renderers/BoxRendererType'
|
|
2
|
-
import Plugin from '@jbrowse/core/Plugin'
|
|
3
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
4
|
-
import PileupRenderer from '@jbrowse/plugin-alignments/src/PileupRenderer'
|
|
5
|
-
import {
|
|
6
|
-
configSchema as svgFeatureRendererConfigSchema,
|
|
7
|
-
ReactComponent as SvgFeatureRendererReactComponent,
|
|
8
|
-
} from '@jbrowse/plugin-svg/src/SvgFeatureRenderer'
|
|
9
|
-
import configSchemaFactory from './configSchema'
|
|
10
|
-
|
|
11
|
-
// mock warnings to avoid unnecessary outputs
|
|
12
|
-
beforeEach(() => {
|
|
13
|
-
jest.spyOn(console, 'warn').mockImplementation(() => {})
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
console.warn.mockRestore()
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
class PileupRendererPlugin extends Plugin {
|
|
21
|
-
install(pluginManager) {
|
|
22
|
-
PileupRenderer(pluginManager)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
class SvgFeatureRendererPlugin extends Plugin {
|
|
27
|
-
install(pluginManager) {
|
|
28
|
-
pluginManager.addRendererType(
|
|
29
|
-
() =>
|
|
30
|
-
new BoxRendererType({
|
|
31
|
-
name: 'SvgFeatureRenderer',
|
|
32
|
-
ReactComponent: SvgFeatureRendererReactComponent,
|
|
33
|
-
configSchema: svgFeatureRendererConfigSchema,
|
|
34
|
-
pluginManager,
|
|
35
|
-
}),
|
|
36
|
-
)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
test('has a viewType attr', () => {
|
|
41
|
-
const configSchema = configSchemaFactory(
|
|
42
|
-
new PluginManager([
|
|
43
|
-
new PileupRendererPlugin(),
|
|
44
|
-
new SvgFeatureRendererPlugin(),
|
|
45
|
-
])
|
|
46
|
-
.createPluggableElements()
|
|
47
|
-
.configure(),
|
|
48
|
-
)
|
|
49
|
-
const config = configSchema.create({
|
|
50
|
-
type: 'LinearVariantDisplay',
|
|
51
|
-
displayId: 'displayId0',
|
|
52
|
-
name: 'Zonker Display',
|
|
53
|
-
})
|
|
54
|
-
expect(config.type).toEqual('LinearVariantDisplay')
|
|
55
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
|
-
import { render } from '@testing-library/react'
|
|
3
|
-
import { types } from 'mobx-state-tree'
|
|
4
|
-
import { ConfigurationSchema } from '@jbrowse/core/configuration'
|
|
5
|
-
import PluginManager from '@jbrowse/core/PluginManager'
|
|
6
|
-
import { stateModelFactory } from '.'
|
|
7
|
-
|
|
8
|
-
import VariantFeatureDetails from './VariantFeatureWidget'
|
|
9
|
-
|
|
10
|
-
describe('VariantTrack widget', () => {
|
|
11
|
-
it('renders with just the required model elements', () => {
|
|
12
|
-
console.warn = jest.fn()
|
|
13
|
-
const pluginManager = new PluginManager([])
|
|
14
|
-
const Session = types.model({
|
|
15
|
-
rpcManager: types.optional(types.frozen(), {}),
|
|
16
|
-
configuration: ConfigurationSchema('test', {}),
|
|
17
|
-
widget: stateModelFactory(pluginManager),
|
|
18
|
-
})
|
|
19
|
-
const model = Session.create(
|
|
20
|
-
{
|
|
21
|
-
widget: { type: 'VariantFeatureWidget' },
|
|
22
|
-
},
|
|
23
|
-
{ pluginManager },
|
|
24
|
-
)
|
|
25
|
-
model.widget.setFeatureData({
|
|
26
|
-
refName: 'ctgA',
|
|
27
|
-
start: 176,
|
|
28
|
-
end: 177,
|
|
29
|
-
name: 'rs123',
|
|
30
|
-
REF: 'A',
|
|
31
|
-
ALT: ['<TRA>'],
|
|
32
|
-
QUAL: 10.4,
|
|
33
|
-
INFO: {
|
|
34
|
-
MQ: 5,
|
|
35
|
-
},
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const { container } = render(<VariantFeatureDetails model={model.widget} />)
|
|
39
|
-
expect(container.firstChild).toMatchSnapshot()
|
|
40
|
-
})
|
|
41
|
-
})
|