@jbrowse/plugin-variants 3.0.3 → 3.0.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.
Files changed (67) hide show
  1. package/dist/MultiLinearVariantMatrixDisplay/components/LinesConnectingMatrixToGenomicPosition.js +37 -3
  2. package/dist/MultiLinearVariantMatrixDisplay/model.d.ts +4 -2
  3. package/dist/MultiLinearVariantMatrixDisplay/model.js +10 -2
  4. package/dist/MultiLinearVariantMatrixRenderer/makeImageData.js +4 -4
  5. package/dist/SplitVcfTabixAdapter/SplitVcfTabixAdapter.d.ts +19 -0
  6. package/dist/SplitVcfTabixAdapter/SplitVcfTabixAdapter.js +93 -0
  7. package/dist/SplitVcfTabixAdapter/configSchema.d.ts +23 -0
  8. package/dist/SplitVcfTabixAdapter/configSchema.js +27 -0
  9. package/dist/SplitVcfTabixAdapter/index.d.ts +3 -0
  10. package/dist/SplitVcfTabixAdapter/index.js +52 -0
  11. package/dist/VariantFeatureWidget/{LaunchBreakendPanel.d.ts → LaunchBreakendPanel/LaunchBreakendPanel.d.ts} +1 -1
  12. package/dist/VariantFeatureWidget/{LaunchBreakendWidgetArea.d.ts → LaunchBreakendPanel/LaunchBreakendWidgetArea.d.ts} +1 -1
  13. package/dist/VariantFeatureWidget/LaunchBreakendPanel/index.d.ts +1 -0
  14. package/dist/VariantFeatureWidget/LaunchBreakendPanel/index.js +8 -0
  15. package/dist/VariantFeatureWidget/VariantFeatureWidget.js +2 -2
  16. package/dist/VariantFeatureWidget/VariantSampleGrid/index.d.ts +1 -0
  17. package/dist/VariantFeatureWidget/VariantSampleGrid/index.js +8 -0
  18. package/dist/VcfFeature/index.js +1 -2
  19. package/dist/VcfTabixAdapter/VcfTabixAdapter.d.ts +1 -0
  20. package/dist/VcfTabixAdapter/VcfTabixAdapter.js +4 -0
  21. package/dist/index.js +2 -0
  22. package/dist/shared/MultiVariantBaseModel.js +3 -4
  23. package/dist/shared/drawAlleleCount.js +9 -4
  24. package/esm/MultiLinearVariantMatrixDisplay/components/LinesConnectingMatrixToGenomicPosition.js +38 -4
  25. package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +4 -2
  26. package/esm/MultiLinearVariantMatrixDisplay/model.js +11 -3
  27. package/esm/MultiLinearVariantMatrixRenderer/makeImageData.js +4 -4
  28. package/esm/SplitVcfTabixAdapter/SplitVcfTabixAdapter.d.ts +19 -0
  29. package/esm/SplitVcfTabixAdapter/SplitVcfTabixAdapter.js +87 -0
  30. package/esm/SplitVcfTabixAdapter/configSchema.d.ts +23 -0
  31. package/esm/SplitVcfTabixAdapter/configSchema.js +25 -0
  32. package/esm/SplitVcfTabixAdapter/index.d.ts +3 -0
  33. package/esm/SplitVcfTabixAdapter/index.js +11 -0
  34. package/esm/VariantFeatureWidget/{LaunchBreakendPanel.d.ts → LaunchBreakendPanel/LaunchBreakendPanel.d.ts} +1 -1
  35. package/esm/VariantFeatureWidget/{LaunchBreakendWidgetArea.d.ts → LaunchBreakendPanel/LaunchBreakendWidgetArea.d.ts} +1 -1
  36. package/esm/VariantFeatureWidget/LaunchBreakendPanel/index.d.ts +1 -0
  37. package/esm/VariantFeatureWidget/LaunchBreakendPanel/index.js +1 -0
  38. package/esm/VariantFeatureWidget/VariantFeatureWidget.js +2 -2
  39. package/esm/VariantFeatureWidget/VariantSampleGrid/index.d.ts +1 -0
  40. package/esm/VariantFeatureWidget/VariantSampleGrid/index.js +1 -0
  41. package/esm/VcfFeature/index.js +1 -2
  42. package/esm/VcfTabixAdapter/VcfTabixAdapter.d.ts +1 -0
  43. package/esm/VcfTabixAdapter/VcfTabixAdapter.js +4 -0
  44. package/esm/index.js +2 -0
  45. package/esm/shared/MultiVariantBaseModel.js +3 -4
  46. package/esm/shared/drawAlleleCount.js +9 -4
  47. package/package.json +6 -6
  48. /package/dist/VariantFeatureWidget/{BreakendMultiLevelOptionDialog.d.ts → LaunchBreakendPanel/BreakendMultiLevelOptionDialog.d.ts} +0 -0
  49. /package/dist/VariantFeatureWidget/{BreakendMultiLevelOptionDialog.js → LaunchBreakendPanel/BreakendMultiLevelOptionDialog.js} +0 -0
  50. /package/dist/VariantFeatureWidget/{BreakendSingleLevelOptionDialog.d.ts → LaunchBreakendPanel/BreakendSingleLevelOptionDialog.d.ts} +0 -0
  51. /package/dist/VariantFeatureWidget/{BreakendSingleLevelOptionDialog.js → LaunchBreakendPanel/BreakendSingleLevelOptionDialog.js} +0 -0
  52. /package/dist/VariantFeatureWidget/{LaunchBreakendPanel.js → LaunchBreakendPanel/LaunchBreakendPanel.js} +0 -0
  53. /package/dist/VariantFeatureWidget/{LaunchBreakendWidgetArea.js → LaunchBreakendPanel/LaunchBreakendWidgetArea.js} +0 -0
  54. /package/dist/VariantFeatureWidget/{VariantSampleFilters.d.ts → VariantSampleGrid/VariantSampleFilters.d.ts} +0 -0
  55. /package/dist/VariantFeatureWidget/{VariantSampleFilters.js → VariantSampleGrid/VariantSampleFilters.js} +0 -0
  56. /package/dist/VariantFeatureWidget/{VariantSampleGrid.d.ts → VariantSampleGrid/VariantSampleGrid.d.ts} +0 -0
  57. /package/dist/VariantFeatureWidget/{VariantSampleGrid.js → VariantSampleGrid/VariantSampleGrid.js} +0 -0
  58. /package/esm/VariantFeatureWidget/{BreakendMultiLevelOptionDialog.d.ts → LaunchBreakendPanel/BreakendMultiLevelOptionDialog.d.ts} +0 -0
  59. /package/esm/VariantFeatureWidget/{BreakendMultiLevelOptionDialog.js → LaunchBreakendPanel/BreakendMultiLevelOptionDialog.js} +0 -0
  60. /package/esm/VariantFeatureWidget/{BreakendSingleLevelOptionDialog.d.ts → LaunchBreakendPanel/BreakendSingleLevelOptionDialog.d.ts} +0 -0
  61. /package/esm/VariantFeatureWidget/{BreakendSingleLevelOptionDialog.js → LaunchBreakendPanel/BreakendSingleLevelOptionDialog.js} +0 -0
  62. /package/esm/VariantFeatureWidget/{LaunchBreakendPanel.js → LaunchBreakendPanel/LaunchBreakendPanel.js} +0 -0
  63. /package/esm/VariantFeatureWidget/{LaunchBreakendWidgetArea.js → LaunchBreakendPanel/LaunchBreakendWidgetArea.js} +0 -0
  64. /package/esm/VariantFeatureWidget/{VariantSampleFilters.d.ts → VariantSampleGrid/VariantSampleFilters.d.ts} +0 -0
  65. /package/esm/VariantFeatureWidget/{VariantSampleFilters.js → VariantSampleGrid/VariantSampleFilters.js} +0 -0
  66. /package/esm/VariantFeatureWidget/{VariantSampleGrid.d.ts → VariantSampleGrid/VariantSampleGrid.d.ts} +0 -0
  67. /package/esm/VariantFeatureWidget/{VariantSampleGrid.js → VariantSampleGrid/VariantSampleGrid.js} +0 -0
@@ -1,8 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const jsx_runtime_1 = require("react/jsx-runtime");
4
+ const react_1 = require("react");
5
+ const ui_1 = require("@jbrowse/core/ui");
4
6
  const util_1 = require("@jbrowse/core/util");
5
7
  const mobx_react_1 = require("mobx-react");
8
+ const mui_1 = require("tss-react/mui");
9
+ const useStyles = (0, mui_1.makeStyles)()({
10
+ resizeHandle: {
11
+ height: 4,
12
+ background: '#ccc',
13
+ boxSizing: 'border-box',
14
+ borderTop: '1px solid #fafafa',
15
+ },
16
+ });
6
17
  const Wrapper = (0, mobx_react_1.observer)(function ({ children, model, exportSVG, }) {
7
18
  const { height } = model;
8
19
  const { width, offsetPx } = (0, util_1.getContainingView)(model);
@@ -11,12 +22,31 @@ const Wrapper = (0, mobx_react_1.observer)(function ({ children, model, exportSV
11
22
  position: 'absolute',
12
23
  top: 0,
13
24
  left,
14
- pointerEvents: 'none',
15
25
  height,
16
26
  width,
17
27
  }, children: children }));
18
28
  });
19
29
  const LinesConnectingMatrixToGenomicPosition = (0, mobx_react_1.observer)(function ({ model, exportSVG, }) {
30
+ var _a;
31
+ const { classes } = useStyles();
32
+ const { assemblyManager } = (0, util_1.getSession)(model);
33
+ const view = (0, util_1.getContainingView)(model);
34
+ const [mouseOverLine, setMouseOverLine] = (0, react_1.useState)();
35
+ const { lineZoneHeight, featuresVolatile } = model;
36
+ const { assemblyNames, dynamicBlocks } = view;
37
+ const assembly = assemblyManager.get(assemblyNames[0]);
38
+ const b0 = ((_a = dynamicBlocks.contentBlocks[0]) === null || _a === void 0 ? void 0 : _a.widthPx) || 0;
39
+ const w = b0 / ((featuresVolatile === null || featuresVolatile === void 0 ? void 0 : featuresVolatile.length) || 1);
40
+ return assembly && featuresVolatile ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)(Wrapper, { exportSVG: exportSVG, model: model, children: [(0, jsx_runtime_1.jsx)(AllLines, { model: model, setMouseOverLine: setMouseOverLine }), mouseOverLine ? ((0, jsx_runtime_1.jsx)("line", { stroke: "#f00c", strokeWidth: 2, style: {
41
+ pointerEvents: 'none',
42
+ }, x1: mouseOverLine.idx * w + w / 2, x2: mouseOverLine.c, y1: lineZoneHeight, y2: 0, onMouseLeave: () => {
43
+ setMouseOverLine(undefined);
44
+ } })) : null] }), !exportSVG ? ((0, jsx_runtime_1.jsx)(ui_1.ResizeHandle, { style: {
45
+ position: 'absolute',
46
+ top: lineZoneHeight - 4,
47
+ }, onDrag: n => model.setLineZoneHeight(lineZoneHeight + n), className: classes.resizeHandle })) : null] })) : null;
48
+ });
49
+ const AllLines = (0, mobx_react_1.observer)(function ({ model, setMouseOverLine, }) {
20
50
  var _a;
21
51
  const { assemblyManager } = (0, util_1.getSession)(model);
22
52
  const view = (0, util_1.getContainingView)(model);
@@ -26,14 +56,18 @@ const LinesConnectingMatrixToGenomicPosition = (0, mobx_react_1.observer)(functi
26
56
  const b0 = ((_a = dynamicBlocks.contentBlocks[0]) === null || _a === void 0 ? void 0 : _a.widthPx) || 0;
27
57
  const w = b0 / ((featuresVolatile === null || featuresVolatile === void 0 ? void 0 : featuresVolatile.length) || 1);
28
58
  const l = Math.max(offsetPx, 0);
29
- return assembly && featuresVolatile ? ((0, jsx_runtime_1.jsx)(Wrapper, { exportSVG: exportSVG, model: model, children: featuresVolatile.map((f, i) => {
59
+ return assembly && featuresVolatile ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: featuresVolatile.map((f, i) => {
30
60
  var _a;
31
61
  const ref = f.get('refName');
32
62
  const c = (((_a = view.bpToPx({
33
63
  refName: assembly.getCanonicalRefName(ref) || ref,
34
64
  coord: f.get('start'),
35
65
  })) === null || _a === void 0 ? void 0 : _a.offsetPx) || 0) - l;
36
- return ((0, jsx_runtime_1.jsx)("line", { stroke: "#0004", x1: i * w + w / 2, x2: c, y1: lineZoneHeight, y2: 0 }, f.id()));
66
+ return ((0, jsx_runtime_1.jsx)("line", { stroke: "#0004", strokeWidth: 1, x1: i * w + w / 2, x2: c, y1: lineZoneHeight, y2: 0, onMouseEnter: () => {
67
+ setMouseOverLine({ f, idx: i, c });
68
+ }, onMouseLeave: () => {
69
+ setMouseOverLine(undefined);
70
+ } }, f.id()));
37
71
  }) })) : null;
38
72
  });
39
73
  exports.default = LinesConnectingMatrixToGenomicPosition;
@@ -92,6 +92,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
92
92
  } & {
93
93
  type: import("mobx-state-tree").ISimpleType<"LinearVariantMatrixDisplay">;
94
94
  rowHeightSetting: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<number>, [undefined]>;
95
+ lineZoneHeight: import("mobx-state-tree").IType<number | undefined, number, number>;
95
96
  }, {
96
97
  rendererTypeName: string;
97
98
  error: unknown;
@@ -338,8 +339,6 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
338
339
  readonly totalHeight: number;
339
340
  } & {
340
341
  renderProps(): any;
341
- } & {
342
- lineZoneHeight: number;
343
342
  } & {
344
343
  readonly nrow: number;
345
344
  readonly blockType: string;
@@ -349,6 +348,9 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
349
348
  renderProps(): any;
350
349
  readonly canDisplayLabels: boolean;
351
350
  } & {
351
+ setLineZoneHeight(n: number): number;
352
+ } & {
353
+ setLineZoneHeight(n: number): number;
352
354
  afterAttach(): void;
353
355
  renderSvg(opts: ExportSvgDisplayOptions): Promise<import("react/jsx-runtime").JSX.Element>;
354
356
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
@@ -45,8 +45,6 @@ function stateModelFactory(configSchema) {
45
45
  .compose('LinearVariantMatrixDisplay', (0, MultiVariantBaseModel_1.default)(configSchema), mobx_state_tree_1.types.model({
46
46
  type: mobx_state_tree_1.types.literal('LinearVariantMatrixDisplay'),
47
47
  rowHeightSetting: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.number, 1),
48
- }))
49
- .volatile(() => ({
50
48
  lineZoneHeight: 20,
51
49
  }))
52
50
  .views(self => ({
@@ -83,10 +81,20 @@ function stateModelFactory(configSchema) {
83
81
  get canDisplayLabels() {
84
82
  return self.rowHeight > 8 && self.showSidebarLabelsSetting;
85
83
  },
84
+ }))
85
+ .actions(self => ({
86
+ setLineZoneHeight(n) {
87
+ self.lineZoneHeight = (0, util_1.clamp)(n, 10, 1000);
88
+ return self.lineZoneHeight;
89
+ },
86
90
  }))
87
91
  .actions(self => {
88
92
  const { renderSvg: superRenderSvg } = self;
89
93
  return {
94
+ setLineZoneHeight(n) {
95
+ self.lineZoneHeight = (0, util_1.clamp)(n, 10, 1000);
96
+ return self.lineZoneHeight;
97
+ },
90
98
  afterAttach() {
91
99
  ;
92
100
  (async () => {
@@ -15,11 +15,11 @@ async function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs, }) {
15
15
  const m = mafs.length;
16
16
  const w = canvasWidth / m;
17
17
  await (0, util_1.updateStatus)('Drawing variant matrix', statusCallback, () => {
18
- var _a, _b;
18
+ var _a, _b, _c;
19
19
  for (let i = 0; i < m; i++) {
20
20
  const arr2 = [];
21
21
  const { feature, mostFrequentAlt } = mafs[i];
22
- const hasPhaseSet = feature.get('format').includes('PS');
22
+ const hasPhaseSet = (_a = feature.get('FORMAT')) === null || _a === void 0 ? void 0 : _a.includes('PS');
23
23
  if (hasPhaseSet) {
24
24
  const samp = feature.get('samples');
25
25
  const x = (i / mafs.length) * canvasWidth;
@@ -29,13 +29,13 @@ async function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs, }) {
29
29
  const { name, HP } = sources[j];
30
30
  const s = samp[name];
31
31
  if (s) {
32
- const genotype = (_a = s.GT) === null || _a === void 0 ? void 0 : _a[0];
32
+ const genotype = (_b = s.GT) === null || _b === void 0 ? void 0 : _b[0];
33
33
  if (genotype) {
34
34
  arr2.push(genotype);
35
35
  const isPhased = genotype.includes('|');
36
36
  if (renderingMode === 'phased') {
37
37
  if (isPhased) {
38
- const PS = (_b = s.PS) === null || _b === void 0 ? void 0 : _b[0];
38
+ const PS = (_c = s.PS) === null || _c === void 0 ? void 0 : _c[0];
39
39
  const alleles = genotype.split('|');
40
40
  (0, drawPhased_1.drawPhased)(alleles, ctx, x, y, w, h, HP, PS);
41
41
  }
@@ -0,0 +1,19 @@
1
+ import { TabixIndexedFile } from '@gmod/tabix';
2
+ import VcfParser from '@gmod/vcf';
3
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
4
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
5
+ import type { Feature } from '@jbrowse/core/util';
6
+ import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
7
+ export default class SplitVcfTabixAdapter extends BaseFeatureDataAdapter {
8
+ private configurePre;
9
+ configure(refName: string, opts?: BaseOptions): Promise<{
10
+ vcf: TabixIndexedFile;
11
+ parser: VcfParser;
12
+ }>;
13
+ getRefNames(): Promise<string[]>;
14
+ getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
15
+ getSources(): Promise<{
16
+ name: string;
17
+ }[]>;
18
+ freeResources(): void;
19
+ }
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const tabix_1 = require("@gmod/tabix");
7
+ const vcf_1 = __importDefault(require("@gmod/vcf"));
8
+ const BaseAdapter_1 = require("@jbrowse/core/data_adapters/BaseAdapter");
9
+ const util_1 = require("@jbrowse/core/util");
10
+ const io_1 = require("@jbrowse/core/util/io");
11
+ const rxjs_1 = require("@jbrowse/core/util/rxjs");
12
+ const VcfFeature_1 = __importDefault(require("../VcfFeature"));
13
+ class SplitVcfTabixAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
14
+ async configurePre(refName) {
15
+ const indexType = this.getConf('indexType');
16
+ const vcfGzLocation = this.getConf('vcfGzLocationMap')[refName];
17
+ const indexLocation = this.getConf('indexLocationMap')[refName] || {
18
+ uri: `${vcfGzLocation.uri}.${indexType.toLowerCase()}`,
19
+ };
20
+ const filehandle = (0, io_1.openLocation)(vcfGzLocation, this.pluginManager);
21
+ const isCSI = indexType === 'CSI';
22
+ const vcf = new tabix_1.TabixIndexedFile({
23
+ filehandle,
24
+ csiFilehandle: isCSI
25
+ ? (0, io_1.openLocation)(indexLocation, this.pluginManager)
26
+ : undefined,
27
+ tbiFilehandle: !isCSI
28
+ ? (0, io_1.openLocation)(indexLocation, this.pluginManager)
29
+ : undefined,
30
+ chunkCacheSize: 50 * 2 ** 20,
31
+ });
32
+ return {
33
+ vcf,
34
+ parser: new vcf_1.default({
35
+ header: await vcf.getHeader(),
36
+ }),
37
+ };
38
+ }
39
+ async configure(refName, opts) {
40
+ const { statusCallback = () => { } } = opts || {};
41
+ return (0, util_1.updateStatus)('Downloading index', statusCallback, () => this.configurePre(refName));
42
+ }
43
+ async getRefNames() {
44
+ return Object.keys(this.getConf('vcfGzLocationMap'));
45
+ }
46
+ getFeatures(query, opts = {}) {
47
+ return (0, rxjs_1.ObservableCreate)(async (observer) => {
48
+ const { refName, start, end } = query;
49
+ const { statusCallback = () => { } } = opts;
50
+ const { vcf, parser } = await this.configure(query.refName, opts);
51
+ await (0, util_1.updateStatus)('Downloading variants', statusCallback, () => vcf.getLines(refName, start, end, {
52
+ lineCallback: (line, fileOffset) => {
53
+ observer.next(new VcfFeature_1.default({
54
+ variant: parser.parseLine(line),
55
+ parser,
56
+ id: `${this.id}-vcf-${fileOffset}`,
57
+ }));
58
+ },
59
+ ...opts,
60
+ }));
61
+ observer.complete();
62
+ }, opts.stopToken);
63
+ }
64
+ async getSources() {
65
+ const conf = this.getConf('samplesTsvLocation');
66
+ const r = Object.keys(this.getConf('vcfGzLocationMap'))[0];
67
+ if (conf.uri === '' || conf.uri === '/path/to/samples.tsv') {
68
+ const { parser } = await this.configure(r);
69
+ return parser.samples.map(name => ({
70
+ name,
71
+ }));
72
+ }
73
+ else {
74
+ const txt = await (0, util_1.fetchAndMaybeUnzipText)((0, io_1.openLocation)(conf, this.pluginManager));
75
+ const lines = txt.split(/\n|\r\n|\r/);
76
+ const header = lines[0].split('\t');
77
+ const { parser } = await this.configure(r);
78
+ const s = new Set(parser.samples);
79
+ return lines
80
+ .slice(1)
81
+ .map(line => {
82
+ const cols = line.split('\t');
83
+ return {
84
+ name: cols[0],
85
+ ...Object.fromEntries(cols.slice(1).map((c, idx) => [header[idx + 1], c])),
86
+ };
87
+ })
88
+ .filter(f => s.has(f.name));
89
+ }
90
+ }
91
+ freeResources() { }
92
+ }
93
+ exports.default = SplitVcfTabixAdapter;
@@ -0,0 +1,23 @@
1
+ declare const SplitVcfTabixAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
+ vcfGzLocationMap: {
3
+ type: string;
4
+ defaultValue: {};
5
+ };
6
+ indexLocationMap: {
7
+ type: string;
8
+ defaultValue: {};
9
+ };
10
+ indexType: {
11
+ type: string;
12
+ defaultValue: string;
13
+ };
14
+ samplesTsvLocation: {
15
+ type: string;
16
+ defaultValue: {
17
+ uri: string;
18
+ description: string;
19
+ locationType: string;
20
+ };
21
+ };
22
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
23
+ export default SplitVcfTabixAdapter;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const configuration_1 = require("@jbrowse/core/configuration");
4
+ function x() { }
5
+ const SplitVcfTabixAdapter = (0, configuration_1.ConfigurationSchema)('SplitVcfTabixAdapter', {
6
+ vcfGzLocationMap: {
7
+ type: 'frozen',
8
+ defaultValue: {},
9
+ },
10
+ indexLocationMap: {
11
+ type: 'frozen',
12
+ defaultValue: {},
13
+ },
14
+ indexType: {
15
+ type: 'string',
16
+ defaultValue: 'TBI',
17
+ },
18
+ samplesTsvLocation: {
19
+ type: 'fileLocation',
20
+ defaultValue: {
21
+ uri: '/path/to/samples.tsv',
22
+ description: 'tsv with header like name\tpopulation\tetc. where the first column is required, and is the sample names',
23
+ locationType: 'UriLocation',
24
+ },
25
+ },
26
+ }, { explicitlyTyped: true });
27
+ exports.default = SplitVcfTabixAdapter;
@@ -0,0 +1,3 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ export { default as configSchema } from './configSchema';
3
+ export default function VcfTabixAdapterF(pluginManager: PluginManager): void;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.configSchema = void 0;
40
+ exports.default = VcfTabixAdapterF;
41
+ const AdapterType_1 = __importDefault(require("@jbrowse/core/pluggableElementTypes/AdapterType"));
42
+ const configSchema_1 = __importDefault(require("./configSchema"));
43
+ var configSchema_2 = require("./configSchema");
44
+ Object.defineProperty(exports, "configSchema", { enumerable: true, get: function () { return __importDefault(configSchema_2).default; } });
45
+ function VcfTabixAdapterF(pluginManager) {
46
+ pluginManager.addAdapterType(() => new AdapterType_1.default({
47
+ name: 'SplitVcfTabixAdapter',
48
+ displayName: 'VCF tabix adapter (split across multiple files)',
49
+ configSchema: configSchema_1.default,
50
+ getAdapterClass: () => Promise.resolve().then(() => __importStar(require('./SplitVcfTabixAdapter'))).then(r => r.default),
51
+ }));
52
+ }
@@ -1,4 +1,4 @@
1
- import type { VariantFeatureWidgetModel } from './stateModelFactory';
1
+ import type { VariantFeatureWidgetModel } from '../stateModelFactory';
2
2
  import type { SimpleFeatureSerialized } from '@jbrowse/core/util';
3
3
  export default function LaunchBreakendPanel(props: {
4
4
  locStrings: string[];
@@ -1,4 +1,4 @@
1
- import type { VariantFeatureWidgetModel } from './stateModelFactory';
1
+ import type { VariantFeatureWidgetModel } from '../stateModelFactory';
2
2
  export default function LaunchBreakendWidgetArea({ model, }: {
3
3
  model: VariantFeatureWidgetModel;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { default } from './LaunchBreakendPanel';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = void 0;
7
+ var LaunchBreakendPanel_1 = require("./LaunchBreakendPanel");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(LaunchBreakendPanel_1).default; } });
@@ -42,9 +42,9 @@ const vcf_1 = require("@gmod/vcf");
42
42
  const FeatureDetails_1 = __importDefault(require("@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail/FeatureDetails"));
43
43
  const material_1 = require("@mui/material");
44
44
  const mobx_react_1 = require("mobx-react");
45
- const VariantSampleGrid_1 = __importDefault(require("./VariantSampleGrid"));
45
+ const VariantSampleGrid_1 = __importDefault(require("./VariantSampleGrid/VariantSampleGrid"));
46
46
  const variantFieldDescriptions_1 = require("./variantFieldDescriptions");
47
- const LaunchBreakendPanel = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./LaunchBreakendPanel'))));
47
+ const LaunchBreakendPanel = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./LaunchBreakendPanel/LaunchBreakendPanel'))));
48
48
  const VariantConsequenceDataGrid = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./VariantConsequenceDataGrid'))));
49
49
  function AnnPanel({ descriptions, feature, }) {
50
50
  var _a, _b, _c, _d, _e;
@@ -0,0 +1 @@
1
+ export { default } from './VariantSampleGrid';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = void 0;
7
+ var VariantSampleGrid_1 = require("./VariantSampleGrid");
8
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(VariantSampleGrid_1).default; } });
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const util_1 = require("./util");
4
4
  function dataFromVariant(variant, parser) {
5
- const { FORMAT, REF = '', ALT, POS, CHROM, ID } = variant;
5
+ const { REF = '', ALT, POS, CHROM, ID } = variant;
6
6
  const start = POS - 1;
7
7
  const [type, description] = (0, util_1.getSOTermAndDescription)(REF, ALT, parser);
8
8
  return {
@@ -13,7 +13,6 @@ function dataFromVariant(variant, parser) {
13
13
  type,
14
14
  name: ID === null || ID === void 0 ? void 0 : ID.join(','),
15
15
  aliases: ID && ID.length > 1 ? ID.slice(1) : undefined,
16
- format: FORMAT,
17
16
  };
18
17
  }
19
18
  function getEnd(variant) {
@@ -17,6 +17,7 @@ export default class VcfTabixAdapter extends BaseFeatureDataAdapter {
17
17
  }>;
18
18
  getRefNames(opts?: BaseOptions): Promise<string[]>;
19
19
  getHeader(opts?: BaseOptions): Promise<string>;
20
+ getMetadata(opts?: BaseOptions): Promise<any>;
20
21
  getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
21
22
  getSources(): Promise<{
22
23
  name: string;
@@ -55,6 +55,10 @@ class VcfTabixAdapter extends BaseAdapter_1.BaseFeatureDataAdapter {
55
55
  const { vcf } = await this.configure(opts);
56
56
  return vcf.getHeader();
57
57
  }
58
+ async getMetadata(opts) {
59
+ const { parser } = await this.configure(opts);
60
+ return parser.getMetadata();
61
+ }
58
62
  getFeatures(query, opts = {}) {
59
63
  return (0, rxjs_1.ObservableCreate)(async (observer) => {
60
64
  const { refName, start, end } = query;
package/dist/index.js CHANGED
@@ -11,6 +11,7 @@ const MultiLinearVariantDisplay_1 = __importDefault(require("./MultiLinearVarian
11
11
  const MultiLinearVariantMatrixDisplay_1 = __importDefault(require("./MultiLinearVariantMatrixDisplay"));
12
12
  const MultiLinearVariantMatrixRenderer_1 = __importDefault(require("./MultiLinearVariantMatrixRenderer"));
13
13
  const MultiLinearVariantRenderer_1 = __importDefault(require("./MultiLinearVariantRenderer"));
14
+ const SplitVcfTabixAdapter_1 = __importDefault(require("./SplitVcfTabixAdapter"));
14
15
  const StructuralVariantChordRenderer_1 = __importDefault(require("./StructuralVariantChordRenderer"));
15
16
  const VariantFeatureWidget_1 = __importDefault(require("./VariantFeatureWidget"));
16
17
  const MultiVariantGetGenotypeMatrix_1 = require("./VariantRPC/MultiVariantGetGenotypeMatrix");
@@ -28,6 +29,7 @@ class VariantsPlugin extends Plugin_1.default {
28
29
  install(pluginManager) {
29
30
  (0, VcfAdapter_1.default)(pluginManager);
30
31
  (0, VcfTabixAdapter_1.default)(pluginManager);
32
+ (0, SplitVcfTabixAdapter_1.default)(pluginManager);
31
33
  (0, VariantFeatureWidget_1.default)(pluginManager);
32
34
  (0, VariantTrack_1.default)(pluginManager);
33
35
  (0, extensionPoints_1.default)(pluginManager);
@@ -229,10 +229,9 @@ function MultiVariantBaseModelF(configSchema) {
229
229
  },
230
230
  },
231
231
  {
232
- label: 'Phased' +
233
- (!self.hasPhased
234
- ? ' (disabled, no phased variants found)'
235
- : ''),
232
+ label: `Phased${!self.hasPhased
233
+ ? ' (disabled, no phased variants found)'
234
+ : ''}`,
236
235
  disabled: !self.hasPhased,
237
236
  checked: self.renderingMode === 'phased',
238
237
  type: 'radio',
@@ -27,14 +27,19 @@ function getColorAlleleCount(alleles, mostFrequentAlt) {
27
27
  return `#ccc`;
28
28
  }
29
29
  else {
30
- let a1 = (0, colord_1.colord)(`hsl(200,50%,${80 - (alt / total) * 50}%)`);
30
+ let a1;
31
+ if (alt) {
32
+ a1 = (0, colord_1.colord)(`hsl(200,50%,${80 - (alt / total) * 50}%)`);
33
+ }
31
34
  if (alt2) {
32
- a1 = a1.mix(`hsla(0,100%,20%,${alt2 / total})`);
35
+ const l = `hsla(0,100%,20%,${alt2 / total})`;
36
+ a1 = a1 ? a1.mix(l) : (0, colord_1.colord)(l);
33
37
  }
34
38
  if (uncalled) {
35
- a1 = a1.mix(`hsla(50,50%,50%,${uncalled / total / 2})`);
39
+ const l = `hsl(50,50%,50%,${uncalled / total})`;
40
+ a1 = a1 ? a1.mix(l) : (0, colord_1.colord)(l);
36
41
  }
37
- return a1.toHex();
42
+ return (a1 === null || a1 === void 0 ? void 0 : a1.toHex()) || 'black';
38
43
  }
39
44
  }
40
45
  function drawColorAlleleCount(alleles, ctx, x, y, w, h, mostFrequentAlt) {
@@ -1,6 +1,17 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useState } from 'react';
3
+ import { ResizeHandle } from '@jbrowse/core/ui';
2
4
  import { getContainingView, getSession } from '@jbrowse/core/util';
3
5
  import { observer } from 'mobx-react';
6
+ import { makeStyles } from 'tss-react/mui';
7
+ const useStyles = makeStyles()({
8
+ resizeHandle: {
9
+ height: 4,
10
+ background: '#ccc',
11
+ boxSizing: 'border-box',
12
+ borderTop: '1px solid #fafafa',
13
+ },
14
+ });
4
15
  const Wrapper = observer(function ({ children, model, exportSVG, }) {
5
16
  const { height } = model;
6
17
  const { width, offsetPx } = getContainingView(model);
@@ -9,12 +20,31 @@ const Wrapper = observer(function ({ children, model, exportSVG, }) {
9
20
  position: 'absolute',
10
21
  top: 0,
11
22
  left,
12
- pointerEvents: 'none',
13
23
  height,
14
24
  width,
15
25
  }, children: children }));
16
26
  });
17
27
  const LinesConnectingMatrixToGenomicPosition = observer(function ({ model, exportSVG, }) {
28
+ var _a;
29
+ const { classes } = useStyles();
30
+ const { assemblyManager } = getSession(model);
31
+ const view = getContainingView(model);
32
+ const [mouseOverLine, setMouseOverLine] = useState();
33
+ const { lineZoneHeight, featuresVolatile } = model;
34
+ const { assemblyNames, dynamicBlocks } = view;
35
+ const assembly = assemblyManager.get(assemblyNames[0]);
36
+ const b0 = ((_a = dynamicBlocks.contentBlocks[0]) === null || _a === void 0 ? void 0 : _a.widthPx) || 0;
37
+ const w = b0 / ((featuresVolatile === null || featuresVolatile === void 0 ? void 0 : featuresVolatile.length) || 1);
38
+ return assembly && featuresVolatile ? (_jsxs(_Fragment, { children: [_jsxs(Wrapper, { exportSVG: exportSVG, model: model, children: [_jsx(AllLines, { model: model, setMouseOverLine: setMouseOverLine }), mouseOverLine ? (_jsx("line", { stroke: "#f00c", strokeWidth: 2, style: {
39
+ pointerEvents: 'none',
40
+ }, x1: mouseOverLine.idx * w + w / 2, x2: mouseOverLine.c, y1: lineZoneHeight, y2: 0, onMouseLeave: () => {
41
+ setMouseOverLine(undefined);
42
+ } })) : null] }), !exportSVG ? (_jsx(ResizeHandle, { style: {
43
+ position: 'absolute',
44
+ top: lineZoneHeight - 4,
45
+ }, onDrag: n => model.setLineZoneHeight(lineZoneHeight + n), className: classes.resizeHandle })) : null] })) : null;
46
+ });
47
+ const AllLines = observer(function ({ model, setMouseOverLine, }) {
18
48
  var _a;
19
49
  const { assemblyManager } = getSession(model);
20
50
  const view = getContainingView(model);
@@ -24,14 +54,18 @@ const LinesConnectingMatrixToGenomicPosition = observer(function ({ model, expor
24
54
  const b0 = ((_a = dynamicBlocks.contentBlocks[0]) === null || _a === void 0 ? void 0 : _a.widthPx) || 0;
25
55
  const w = b0 / ((featuresVolatile === null || featuresVolatile === void 0 ? void 0 : featuresVolatile.length) || 1);
26
56
  const l = Math.max(offsetPx, 0);
27
- return assembly && featuresVolatile ? (_jsx(Wrapper, { exportSVG: exportSVG, model: model, children: featuresVolatile.map((f, i) => {
57
+ return assembly && featuresVolatile ? (_jsx(_Fragment, { children: featuresVolatile.map((f, i) => {
28
58
  var _a;
29
59
  const ref = f.get('refName');
30
60
  const c = (((_a = view.bpToPx({
31
61
  refName: assembly.getCanonicalRefName(ref) || ref,
32
62
  coord: f.get('start'),
33
63
  })) === null || _a === void 0 ? void 0 : _a.offsetPx) || 0) - l;
34
- return (_jsx("line", { stroke: "#0004", x1: i * w + w / 2, x2: c, y1: lineZoneHeight, y2: 0 }, f.id()));
64
+ return (_jsx("line", { stroke: "#0004", strokeWidth: 1, x1: i * w + w / 2, x2: c, y1: lineZoneHeight, y2: 0, onMouseEnter: () => {
65
+ setMouseOverLine({ f, idx: i, c });
66
+ }, onMouseLeave: () => {
67
+ setMouseOverLine(undefined);
68
+ } }, f.id()));
35
69
  }) })) : null;
36
70
  });
37
71
  export default LinesConnectingMatrixToGenomicPosition;
@@ -92,6 +92,7 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
92
92
  } & {
93
93
  type: import("mobx-state-tree").ISimpleType<"LinearVariantMatrixDisplay">;
94
94
  rowHeightSetting: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<number>, [undefined]>;
95
+ lineZoneHeight: import("mobx-state-tree").IType<number | undefined, number, number>;
95
96
  }, {
96
97
  rendererTypeName: string;
97
98
  error: unknown;
@@ -338,8 +339,6 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
338
339
  readonly totalHeight: number;
339
340
  } & {
340
341
  renderProps(): any;
341
- } & {
342
- lineZoneHeight: number;
343
342
  } & {
344
343
  readonly nrow: number;
345
344
  readonly blockType: string;
@@ -349,6 +348,9 @@ export default function stateModelFactory(configSchema: AnyConfigurationSchemaTy
349
348
  renderProps(): any;
350
349
  readonly canDisplayLabels: boolean;
351
350
  } & {
351
+ setLineZoneHeight(n: number): number;
352
+ } & {
353
+ setLineZoneHeight(n: number): number;
352
354
  afterAttach(): void;
353
355
  renderSvg(opts: ExportSvgDisplayOptions): Promise<import("react/jsx-runtime").JSX.Element>;
354
356
  }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
@@ -1,4 +1,4 @@
1
- import { getSession } from '@jbrowse/core/util';
1
+ import { clamp, getSession } from '@jbrowse/core/util';
2
2
  import { isAlive, types } from 'mobx-state-tree';
3
3
  import MultiVariantBaseModelF from '../shared/MultiVariantBaseModel';
4
4
  export default function stateModelFactory(configSchema) {
@@ -6,8 +6,6 @@ export default function stateModelFactory(configSchema) {
6
6
  .compose('LinearVariantMatrixDisplay', MultiVariantBaseModelF(configSchema), types.model({
7
7
  type: types.literal('LinearVariantMatrixDisplay'),
8
8
  rowHeightSetting: types.optional(types.number, 1),
9
- }))
10
- .volatile(() => ({
11
9
  lineZoneHeight: 20,
12
10
  }))
13
11
  .views(self => ({
@@ -44,10 +42,20 @@ export default function stateModelFactory(configSchema) {
44
42
  get canDisplayLabels() {
45
43
  return self.rowHeight > 8 && self.showSidebarLabelsSetting;
46
44
  },
45
+ }))
46
+ .actions(self => ({
47
+ setLineZoneHeight(n) {
48
+ self.lineZoneHeight = clamp(n, 10, 1000);
49
+ return self.lineZoneHeight;
50
+ },
47
51
  }))
48
52
  .actions(self => {
49
53
  const { renderSvg: superRenderSvg } = self;
50
54
  return {
55
+ setLineZoneHeight(n) {
56
+ self.lineZoneHeight = clamp(n, 10, 1000);
57
+ return self.lineZoneHeight;
58
+ },
51
59
  afterAttach() {
52
60
  ;
53
61
  (async () => {
@@ -12,11 +12,11 @@ export async function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs
12
12
  const m = mafs.length;
13
13
  const w = canvasWidth / m;
14
14
  await updateStatus('Drawing variant matrix', statusCallback, () => {
15
- var _a, _b;
15
+ var _a, _b, _c;
16
16
  for (let i = 0; i < m; i++) {
17
17
  const arr2 = [];
18
18
  const { feature, mostFrequentAlt } = mafs[i];
19
- const hasPhaseSet = feature.get('format').includes('PS');
19
+ const hasPhaseSet = (_a = feature.get('FORMAT')) === null || _a === void 0 ? void 0 : _a.includes('PS');
20
20
  if (hasPhaseSet) {
21
21
  const samp = feature.get('samples');
22
22
  const x = (i / mafs.length) * canvasWidth;
@@ -26,13 +26,13 @@ export async function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs
26
26
  const { name, HP } = sources[j];
27
27
  const s = samp[name];
28
28
  if (s) {
29
- const genotype = (_a = s.GT) === null || _a === void 0 ? void 0 : _a[0];
29
+ const genotype = (_b = s.GT) === null || _b === void 0 ? void 0 : _b[0];
30
30
  if (genotype) {
31
31
  arr2.push(genotype);
32
32
  const isPhased = genotype.includes('|');
33
33
  if (renderingMode === 'phased') {
34
34
  if (isPhased) {
35
- const PS = (_b = s.PS) === null || _b === void 0 ? void 0 : _b[0];
35
+ const PS = (_c = s.PS) === null || _c === void 0 ? void 0 : _c[0];
36
36
  const alleles = genotype.split('|');
37
37
  drawPhased(alleles, ctx, x, y, w, h, HP, PS);
38
38
  }
@@ -0,0 +1,19 @@
1
+ import { TabixIndexedFile } from '@gmod/tabix';
2
+ import VcfParser from '@gmod/vcf';
3
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
4
+ import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
5
+ import type { Feature } from '@jbrowse/core/util';
6
+ import type { NoAssemblyRegion } from '@jbrowse/core/util/types';
7
+ export default class SplitVcfTabixAdapter extends BaseFeatureDataAdapter {
8
+ private configurePre;
9
+ configure(refName: string, opts?: BaseOptions): Promise<{
10
+ vcf: TabixIndexedFile;
11
+ parser: VcfParser;
12
+ }>;
13
+ getRefNames(): Promise<string[]>;
14
+ getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
15
+ getSources(): Promise<{
16
+ name: string;
17
+ }[]>;
18
+ freeResources(): void;
19
+ }
@@ -0,0 +1,87 @@
1
+ import { TabixIndexedFile } from '@gmod/tabix';
2
+ import VcfParser from '@gmod/vcf';
3
+ import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
4
+ import { fetchAndMaybeUnzipText, updateStatus } from '@jbrowse/core/util';
5
+ import { openLocation } from '@jbrowse/core/util/io';
6
+ import { ObservableCreate } from '@jbrowse/core/util/rxjs';
7
+ import VcfFeature from '../VcfFeature';
8
+ export default class SplitVcfTabixAdapter extends BaseFeatureDataAdapter {
9
+ async configurePre(refName) {
10
+ const indexType = this.getConf('indexType');
11
+ const vcfGzLocation = this.getConf('vcfGzLocationMap')[refName];
12
+ const indexLocation = this.getConf('indexLocationMap')[refName] || {
13
+ uri: `${vcfGzLocation.uri}.${indexType.toLowerCase()}`,
14
+ };
15
+ const filehandle = openLocation(vcfGzLocation, this.pluginManager);
16
+ const isCSI = indexType === 'CSI';
17
+ const vcf = new TabixIndexedFile({
18
+ filehandle,
19
+ csiFilehandle: isCSI
20
+ ? openLocation(indexLocation, this.pluginManager)
21
+ : undefined,
22
+ tbiFilehandle: !isCSI
23
+ ? openLocation(indexLocation, this.pluginManager)
24
+ : undefined,
25
+ chunkCacheSize: 50 * 2 ** 20,
26
+ });
27
+ return {
28
+ vcf,
29
+ parser: new VcfParser({
30
+ header: await vcf.getHeader(),
31
+ }),
32
+ };
33
+ }
34
+ async configure(refName, opts) {
35
+ const { statusCallback = () => { } } = opts || {};
36
+ return updateStatus('Downloading index', statusCallback, () => this.configurePre(refName));
37
+ }
38
+ async getRefNames() {
39
+ return Object.keys(this.getConf('vcfGzLocationMap'));
40
+ }
41
+ getFeatures(query, opts = {}) {
42
+ return ObservableCreate(async (observer) => {
43
+ const { refName, start, end } = query;
44
+ const { statusCallback = () => { } } = opts;
45
+ const { vcf, parser } = await this.configure(query.refName, opts);
46
+ await updateStatus('Downloading variants', statusCallback, () => vcf.getLines(refName, start, end, {
47
+ lineCallback: (line, fileOffset) => {
48
+ observer.next(new VcfFeature({
49
+ variant: parser.parseLine(line),
50
+ parser,
51
+ id: `${this.id}-vcf-${fileOffset}`,
52
+ }));
53
+ },
54
+ ...opts,
55
+ }));
56
+ observer.complete();
57
+ }, opts.stopToken);
58
+ }
59
+ async getSources() {
60
+ const conf = this.getConf('samplesTsvLocation');
61
+ const r = Object.keys(this.getConf('vcfGzLocationMap'))[0];
62
+ if (conf.uri === '' || conf.uri === '/path/to/samples.tsv') {
63
+ const { parser } = await this.configure(r);
64
+ return parser.samples.map(name => ({
65
+ name,
66
+ }));
67
+ }
68
+ else {
69
+ const txt = await fetchAndMaybeUnzipText(openLocation(conf, this.pluginManager));
70
+ const lines = txt.split(/\n|\r\n|\r/);
71
+ const header = lines[0].split('\t');
72
+ const { parser } = await this.configure(r);
73
+ const s = new Set(parser.samples);
74
+ return lines
75
+ .slice(1)
76
+ .map(line => {
77
+ const cols = line.split('\t');
78
+ return {
79
+ name: cols[0],
80
+ ...Object.fromEntries(cols.slice(1).map((c, idx) => [header[idx + 1], c])),
81
+ };
82
+ })
83
+ .filter(f => s.has(f.name));
84
+ }
85
+ }
86
+ freeResources() { }
87
+ }
@@ -0,0 +1,23 @@
1
+ declare const SplitVcfTabixAdapter: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
2
+ vcfGzLocationMap: {
3
+ type: string;
4
+ defaultValue: {};
5
+ };
6
+ indexLocationMap: {
7
+ type: string;
8
+ defaultValue: {};
9
+ };
10
+ indexType: {
11
+ type: string;
12
+ defaultValue: string;
13
+ };
14
+ samplesTsvLocation: {
15
+ type: string;
16
+ defaultValue: {
17
+ uri: string;
18
+ description: string;
19
+ locationType: string;
20
+ };
21
+ };
22
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
23
+ export default SplitVcfTabixAdapter;
@@ -0,0 +1,25 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ function x() { }
3
+ const SplitVcfTabixAdapter = ConfigurationSchema('SplitVcfTabixAdapter', {
4
+ vcfGzLocationMap: {
5
+ type: 'frozen',
6
+ defaultValue: {},
7
+ },
8
+ indexLocationMap: {
9
+ type: 'frozen',
10
+ defaultValue: {},
11
+ },
12
+ indexType: {
13
+ type: 'string',
14
+ defaultValue: 'TBI',
15
+ },
16
+ samplesTsvLocation: {
17
+ type: 'fileLocation',
18
+ defaultValue: {
19
+ uri: '/path/to/samples.tsv',
20
+ description: 'tsv with header like name\tpopulation\tetc. where the first column is required, and is the sample names',
21
+ locationType: 'UriLocation',
22
+ },
23
+ },
24
+ }, { explicitlyTyped: true });
25
+ export default SplitVcfTabixAdapter;
@@ -0,0 +1,3 @@
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
+ export { default as configSchema } from './configSchema';
3
+ export default function VcfTabixAdapterF(pluginManager: PluginManager): void;
@@ -0,0 +1,11 @@
1
+ import AdapterType from '@jbrowse/core/pluggableElementTypes/AdapterType';
2
+ import configSchema from './configSchema';
3
+ export { default as configSchema } from './configSchema';
4
+ export default function VcfTabixAdapterF(pluginManager) {
5
+ pluginManager.addAdapterType(() => new AdapterType({
6
+ name: 'SplitVcfTabixAdapter',
7
+ displayName: 'VCF tabix adapter (split across multiple files)',
8
+ configSchema,
9
+ getAdapterClass: () => import('./SplitVcfTabixAdapter').then(r => r.default),
10
+ }));
11
+ }
@@ -1,4 +1,4 @@
1
- import type { VariantFeatureWidgetModel } from './stateModelFactory';
1
+ import type { VariantFeatureWidgetModel } from '../stateModelFactory';
2
2
  import type { SimpleFeatureSerialized } from '@jbrowse/core/util';
3
3
  export default function LaunchBreakendPanel(props: {
4
4
  locStrings: string[];
@@ -1,4 +1,4 @@
1
- import type { VariantFeatureWidgetModel } from './stateModelFactory';
1
+ import type { VariantFeatureWidgetModel } from '../stateModelFactory';
2
2
  export default function LaunchBreakendWidgetArea({ model, }: {
3
3
  model: VariantFeatureWidgetModel;
4
4
  }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export { default } from './LaunchBreakendPanel';
@@ -0,0 +1 @@
1
+ export { default } from './LaunchBreakendPanel';
@@ -4,9 +4,9 @@ import { parseBreakend } from '@gmod/vcf';
4
4
  import FeatureDetails from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail/FeatureDetails';
5
5
  import { Paper } from '@mui/material';
6
6
  import { observer } from 'mobx-react';
7
- import VariantSampleGrid from './VariantSampleGrid';
7
+ import VariantSampleGrid from './VariantSampleGrid/VariantSampleGrid';
8
8
  import { variantFieldDescriptions } from './variantFieldDescriptions';
9
- const LaunchBreakendPanel = lazy(() => import('./LaunchBreakendPanel'));
9
+ const LaunchBreakendPanel = lazy(() => import('./LaunchBreakendPanel/LaunchBreakendPanel'));
10
10
  const VariantConsequenceDataGrid = lazy(() => import('./VariantConsequenceDataGrid'));
11
11
  function AnnPanel({ descriptions, feature, }) {
12
12
  var _a, _b, _c, _d, _e;
@@ -0,0 +1 @@
1
+ export { default } from './VariantSampleGrid';
@@ -0,0 +1 @@
1
+ export { default } from './VariantSampleGrid';
@@ -1,6 +1,6 @@
1
1
  import { getSOTermAndDescription } from './util';
2
2
  function dataFromVariant(variant, parser) {
3
- const { FORMAT, REF = '', ALT, POS, CHROM, ID } = variant;
3
+ const { REF = '', ALT, POS, CHROM, ID } = variant;
4
4
  const start = POS - 1;
5
5
  const [type, description] = getSOTermAndDescription(REF, ALT, parser);
6
6
  return {
@@ -11,7 +11,6 @@ function dataFromVariant(variant, parser) {
11
11
  type,
12
12
  name: ID === null || ID === void 0 ? void 0 : ID.join(','),
13
13
  aliases: ID && ID.length > 1 ? ID.slice(1) : undefined,
14
- format: FORMAT,
15
14
  };
16
15
  }
17
16
  function getEnd(variant) {
@@ -17,6 +17,7 @@ export default class VcfTabixAdapter extends BaseFeatureDataAdapter {
17
17
  }>;
18
18
  getRefNames(opts?: BaseOptions): Promise<string[]>;
19
19
  getHeader(opts?: BaseOptions): Promise<string>;
20
+ getMetadata(opts?: BaseOptions): Promise<any>;
20
21
  getFeatures(query: NoAssemblyRegion, opts?: BaseOptions): import("rxjs").Observable<Feature>;
21
22
  getSources(): Promise<{
22
23
  name: string;
@@ -50,6 +50,10 @@ export default class VcfTabixAdapter extends BaseFeatureDataAdapter {
50
50
  const { vcf } = await this.configure(opts);
51
51
  return vcf.getHeader();
52
52
  }
53
+ async getMetadata(opts) {
54
+ const { parser } = await this.configure(opts);
55
+ return parser.getMetadata();
56
+ }
53
57
  getFeatures(query, opts = {}) {
54
58
  return ObservableCreate(async (observer) => {
55
59
  const { refName, start, end } = query;
package/esm/index.js CHANGED
@@ -5,6 +5,7 @@ import MultiLinearVariantDisplayF from './MultiLinearVariantDisplay';
5
5
  import LinearVariantMatrixDisplayF from './MultiLinearVariantMatrixDisplay';
6
6
  import LinearVariantMatrixRendererF from './MultiLinearVariantMatrixRenderer';
7
7
  import MultiVariantRendererF from './MultiLinearVariantRenderer';
8
+ import SplitVcfTabixAdapterF from './SplitVcfTabixAdapter';
8
9
  import StructuralVariantChordRendererF from './StructuralVariantChordRenderer';
9
10
  import VariantFeatureWidgetF from './VariantFeatureWidget';
10
11
  import { MultiVariantGetGenotypeMatrix } from './VariantRPC/MultiVariantGetGenotypeMatrix';
@@ -22,6 +23,7 @@ export default class VariantsPlugin extends Plugin {
22
23
  install(pluginManager) {
23
24
  VcfAdapterF(pluginManager);
24
25
  VcfTabixAdapterF(pluginManager);
26
+ SplitVcfTabixAdapterF(pluginManager);
25
27
  VariantFeatureWidgetF(pluginManager);
26
28
  VariantTrackF(pluginManager);
27
29
  ExtensionPointsF(pluginManager);
@@ -190,10 +190,9 @@ export default function MultiVariantBaseModelF(configSchema) {
190
190
  },
191
191
  },
192
192
  {
193
- label: 'Phased' +
194
- (!self.hasPhased
195
- ? ' (disabled, no phased variants found)'
196
- : ''),
193
+ label: `Phased${!self.hasPhased
194
+ ? ' (disabled, no phased variants found)'
195
+ : ''}`,
197
196
  disabled: !self.hasPhased,
198
197
  checked: self.renderingMode === 'phased',
199
198
  type: 'radio',
@@ -24,14 +24,19 @@ function getColorAlleleCount(alleles, mostFrequentAlt) {
24
24
  return `#ccc`;
25
25
  }
26
26
  else {
27
- let a1 = colord(`hsl(200,50%,${80 - (alt / total) * 50}%)`);
27
+ let a1;
28
+ if (alt) {
29
+ a1 = colord(`hsl(200,50%,${80 - (alt / total) * 50}%)`);
30
+ }
28
31
  if (alt2) {
29
- a1 = a1.mix(`hsla(0,100%,20%,${alt2 / total})`);
32
+ const l = `hsla(0,100%,20%,${alt2 / total})`;
33
+ a1 = a1 ? a1.mix(l) : colord(l);
30
34
  }
31
35
  if (uncalled) {
32
- a1 = a1.mix(`hsla(50,50%,50%,${uncalled / total / 2})`);
36
+ const l = `hsl(50,50%,50%,${uncalled / total})`;
37
+ a1 = a1 ? a1.mix(l) : colord(l);
33
38
  }
34
- return a1.toHex();
39
+ return (a1 === null || a1 === void 0 ? void 0 : a1.toHex()) || 'black';
35
40
  }
36
41
  }
37
42
  export function drawColorAlleleCount(alleles, ctx, x, y, w, h, mostFrequentAlt) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-variants",
3
- "version": "3.0.3",
3
+ "version": "3.0.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": "^2.0.1",
41
41
  "@gmod/tabix": "^2.0.0",
42
42
  "@gmod/vcf": "^6.0.8",
43
- "@jbrowse/core": "^3.0.3",
44
- "@jbrowse/plugin-circular-view": "^3.0.3",
45
- "@jbrowse/plugin-linear-genome-view": "^3.0.3",
46
- "@jbrowse/sv-core": "^3.0.3",
43
+ "@jbrowse/core": "^3.0.5",
44
+ "@jbrowse/plugin-circular-view": "^3.0.5",
45
+ "@jbrowse/plugin-linear-genome-view": "^3.0.5",
46
+ "@jbrowse/sv-core": "^3.0.5",
47
47
  "@mui/icons-material": "^6.0.0",
48
48
  "@mui/material": "^6.0.0",
49
49
  "@mui/x-data-grid": "^7.0.0",
@@ -62,5 +62,5 @@
62
62
  "distModule": "esm/index.js",
63
63
  "srcModule": "src/index.ts",
64
64
  "module": "esm/index.js",
65
- "gitHead": "f516540428282351d26e46743e69a724651bfb2c"
65
+ "gitHead": "a03749efe19e51609922272b845a331897346789"
66
66
  }