@jbrowse/plugin-variants 3.6.4 → 3.7.0

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 (83) hide show
  1. package/dist/LinearVariantDisplay/model.d.ts +17 -2
  2. package/dist/MultiLinearVariantDisplay/model.d.ts +17 -2
  3. package/dist/MultiLinearVariantMatrixDisplay/model.d.ts +17 -2
  4. package/dist/MultiLinearVariantMatrixRenderer/makeImageData.js +6 -4
  5. package/dist/MultiLinearVariantRenderer/MultiVariantRenderer.d.ts +6 -3
  6. package/dist/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.d.ts +7 -2
  7. package/dist/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.js +14 -17
  8. package/dist/MultiLinearVariantRenderer/makeImageData.d.ts +2 -1
  9. package/dist/MultiLinearVariantRenderer/makeImageData.js +32 -22
  10. package/dist/StructuralVariantChordRenderer/ReactComponent.js +1 -1
  11. package/dist/VariantFeatureWidget/AltFormatter.d.ts +2 -2
  12. package/dist/VariantFeatureWidget/AltFormatter.js +3 -3
  13. package/dist/VariantFeatureWidget/VariantFeatureWidget.js +1 -1
  14. package/dist/VariantFeatureWidget/stateModelFactory.d.ts +4 -4
  15. package/dist/VcfAdapter/VcfAdapter.d.ts +5 -5
  16. package/dist/VcfAdapter/VcfAdapter.js +2 -2
  17. package/dist/VcfFeature/index.d.ts +1 -1
  18. package/dist/VcfFeature/index.js +21 -5
  19. package/dist/shared/MultiVariantBaseModel.d.ts +17 -2
  20. package/dist/shared/SharedVariantMixin.d.ts +17 -2
  21. package/dist/shared/components/MultiVariantClusterDialog/ClusterDialogManual.js +3 -3
  22. package/dist/shared/components/SetColorDialog.js +2 -45
  23. package/dist/shared/components/SetColorDialogBulkEditPanel.d.ts +10 -0
  24. package/dist/shared/components/{BulkEditPanel.js → SetColorDialogBulkEditPanel.js} +2 -2
  25. package/dist/shared/components/SetColorDialogHelpfulTips.d.ts +1 -0
  26. package/dist/shared/components/{HelpfulTips.js → SetColorDialogHelpfulTips.js} +2 -2
  27. package/dist/shared/components/SetColorDialogRowPalettizer.d.ts +10 -0
  28. package/dist/shared/components/{RowPalettizer.js → SetColorDialogRowPalettizer.js} +13 -12
  29. package/dist/shared/components/ui/SetColorDialog.d.ts +31 -0
  30. package/dist/shared/components/ui/SetColorDialog.js +51 -0
  31. package/dist/shared/components/ui/SetColorDialogBulkEditPanel.d.ts +10 -0
  32. package/dist/shared/components/ui/SetColorDialogBulkEditPanel.js +84 -0
  33. package/dist/shared/components/ui/SetColorDialogHelpfulTips.d.ts +1 -0
  34. package/dist/shared/components/ui/SetColorDialogHelpfulTips.js +7 -0
  35. package/dist/shared/components/ui/SetColorDialogRowPalettizer.d.ts +10 -0
  36. package/dist/shared/components/ui/SetColorDialogRowPalettizer.js +41 -0
  37. package/dist/shared/util.d.ts +0 -1
  38. package/dist/shared/util.js +0 -8
  39. package/esm/LinearVariantDisplay/model.d.ts +17 -2
  40. package/esm/MultiLinearVariantDisplay/model.d.ts +17 -2
  41. package/esm/MultiLinearVariantMatrixDisplay/model.d.ts +17 -2
  42. package/esm/MultiLinearVariantMatrixRenderer/makeImageData.js +6 -4
  43. package/esm/MultiLinearVariantRenderer/MultiVariantRenderer.d.ts +6 -3
  44. package/esm/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.d.ts +7 -2
  45. package/esm/MultiLinearVariantRenderer/components/MultiLinearVariantRendering.js +14 -17
  46. package/esm/MultiLinearVariantRenderer/makeImageData.d.ts +2 -1
  47. package/esm/MultiLinearVariantRenderer/makeImageData.js +32 -22
  48. package/esm/StructuralVariantChordRenderer/ReactComponent.js +1 -1
  49. package/esm/VariantFeatureWidget/AltFormatter.d.ts +2 -2
  50. package/esm/VariantFeatureWidget/AltFormatter.js +4 -4
  51. package/esm/VariantFeatureWidget/VariantFeatureWidget.js +1 -1
  52. package/esm/VariantFeatureWidget/stateModelFactory.d.ts +4 -4
  53. package/esm/VcfAdapter/VcfAdapter.d.ts +5 -5
  54. package/esm/VcfAdapter/VcfAdapter.js +1 -1
  55. package/esm/VcfFeature/index.d.ts +1 -1
  56. package/esm/VcfFeature/index.js +19 -3
  57. package/esm/shared/MultiVariantBaseModel.d.ts +17 -2
  58. package/esm/shared/SharedVariantMixin.d.ts +17 -2
  59. package/esm/shared/components/MultiVariantClusterDialog/ClusterDialogManual.js +3 -3
  60. package/esm/shared/components/SetColorDialog.js +3 -46
  61. package/esm/shared/components/SetColorDialogBulkEditPanel.d.ts +10 -0
  62. package/esm/shared/components/{BulkEditPanel.js → SetColorDialogBulkEditPanel.js} +1 -1
  63. package/esm/shared/components/SetColorDialogHelpfulTips.d.ts +1 -0
  64. package/esm/shared/components/{HelpfulTips.js → SetColorDialogHelpfulTips.js} +1 -1
  65. package/esm/shared/components/SetColorDialogRowPalettizer.d.ts +10 -0
  66. package/esm/shared/components/{RowPalettizer.js → SetColorDialogRowPalettizer.js} +11 -10
  67. package/esm/shared/components/ui/SetColorDialog.d.ts +31 -0
  68. package/esm/shared/components/ui/SetColorDialog.js +45 -0
  69. package/esm/shared/components/ui/SetColorDialogBulkEditPanel.d.ts +10 -0
  70. package/esm/shared/components/ui/SetColorDialogBulkEditPanel.js +81 -0
  71. package/esm/shared/components/ui/SetColorDialogHelpfulTips.d.ts +1 -0
  72. package/esm/shared/components/ui/SetColorDialogHelpfulTips.js +4 -0
  73. package/esm/shared/components/ui/SetColorDialogRowPalettizer.d.ts +10 -0
  74. package/esm/shared/components/ui/SetColorDialogRowPalettizer.js +38 -0
  75. package/esm/shared/util.d.ts +0 -1
  76. package/esm/shared/util.js +0 -7
  77. package/package.json +7 -7
  78. package/dist/shared/components/BulkEditPanel.d.ts +0 -5
  79. package/dist/shared/components/HelpfulTips.d.ts +0 -1
  80. package/dist/shared/components/RowPalettizer.d.ts +0 -5
  81. package/esm/shared/components/BulkEditPanel.d.ts +0 -5
  82. package/esm/shared/components/HelpfulTips.d.ts +0 -1
  83. package/esm/shared/components/RowPalettizer.d.ts +0 -5
@@ -50,7 +50,8 @@ export async function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs
50
50
  }
51
51
  }
52
52
  else {
53
- let c = colorCache[genotype];
53
+ const cacheKey = `${genotype}:${mostFrequentAlt}`;
54
+ let c = colorCache[cacheKey];
54
55
  if (c === undefined) {
55
56
  let alt = 0;
56
57
  let uncalled = 0;
@@ -74,7 +75,7 @@ export async function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs
74
75
  }
75
76
  }
76
77
  c = getColorAlleleCount(ref, alt, alt2, uncalled, total, true);
77
- colorCache[genotype] = c;
78
+ colorCache[cacheKey] = c;
78
79
  }
79
80
  if (c) {
80
81
  drawColorAlleleCount(c, ctx, x, y, w, h);
@@ -106,7 +107,8 @@ export async function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs
106
107
  }
107
108
  }
108
109
  else {
109
- let c = colorCache[genotype];
110
+ const cacheKey = `${genotype}:${mostFrequentAlt}`;
111
+ let c = colorCache[cacheKey];
110
112
  if (c === undefined) {
111
113
  let alt = 0;
112
114
  let uncalled = 0;
@@ -130,7 +132,7 @@ export async function makeImageData({ ctx, canvasWidth, canvasHeight, renderArgs
130
132
  }
131
133
  }
132
134
  c = getColorAlleleCount(ref, alt, alt2, uncalled, total, true);
133
- colorCache[genotype] = c;
135
+ colorCache[cacheKey] = c;
134
136
  }
135
137
  if (c) {
136
138
  drawColorAlleleCount(c, ctx, x, y, w, h);
@@ -8,7 +8,8 @@ export default class MultiVariantBaseRenderer extends FeatureRendererType {
8
8
  height: number;
9
9
  width: number;
10
10
  containsNoTransferables: boolean;
11
- rbush: any;
11
+ flatbush: ArrayBufferLike;
12
+ items: any[];
12
13
  featureGenotypeMap: {
13
14
  [k: string]: {
14
15
  alt: any;
@@ -26,7 +27,8 @@ export default class MultiVariantBaseRenderer extends FeatureRendererType {
26
27
  height: number;
27
28
  width: number;
28
29
  containsNoTransferables: boolean;
29
- rbush: any;
30
+ flatbush: ArrayBufferLike;
31
+ items: any[];
30
32
  featureGenotypeMap: {
31
33
  [k: string]: {
32
34
  alt: any;
@@ -44,7 +46,8 @@ export default class MultiVariantBaseRenderer extends FeatureRendererType {
44
46
  height: number;
45
47
  width: number;
46
48
  containsNoTransferables: boolean;
47
- rbush: any;
49
+ flatbush: ArrayBufferLike;
50
+ items: any[];
48
51
  featureGenotypeMap: {
49
52
  [k: string]: {
50
53
  alt: any;
@@ -1,7 +1,11 @@
1
1
  import type { Source } from '../../shared/types';
2
2
  import type { Feature } from '@jbrowse/core/util';
3
3
  import type { Region } from '@jbrowse/core/util/types';
4
- type SerializedRBush = any;
4
+ interface Item {
5
+ genotype: string;
6
+ featureId: string;
7
+ bpLen: number;
8
+ }
5
9
  interface MinimizedVariantRecord {
6
10
  alt: string[];
7
11
  ref: string;
@@ -19,7 +23,8 @@ declare const MultiVariantRendering: (props: {
19
23
  scrollTop: number;
20
24
  featureGenotypeMap: Record<string, MinimizedVariantRecord>;
21
25
  totalHeight: number;
22
- rbush: SerializedRBush;
26
+ flatbush: any;
27
+ items: Item[];
23
28
  displayModel: any;
24
29
  onMouseLeave?: (event: React.MouseEvent) => void;
25
30
  onMouseMove?: (event: React.MouseEvent, arg?: Feature) => void;
@@ -2,33 +2,30 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useMemo, useRef } from 'react';
3
3
  import { PrerenderedCanvas } from '@jbrowse/core/ui';
4
4
  import { getBpDisplayStr } from '@jbrowse/core/util';
5
+ import Flatbush from '@jbrowse/core/util/flatbush';
5
6
  import { observer } from 'mobx-react';
6
- import RBush from 'rbush';
7
7
  import { minElt } from './util';
8
8
  import { makeSimpleAltString } from '../../VcfFeature/util';
9
9
  const MultiVariantRendering = observer(function (props) {
10
- const { featureGenotypeMap, totalHeight, scrollTop } = props;
11
- const { rbush, displayModel } = props;
10
+ const { flatbush, items, displayModel, featureGenotypeMap, totalHeight, scrollTop, } = props;
12
11
  const ref = useRef(null);
13
- const rbush2 = useMemo(() => new RBush().fromJSON(rbush), [rbush]);
12
+ const flatbush2 = useMemo(() => Flatbush.from(flatbush), [flatbush]);
14
13
  function getFeatureUnderMouse(eventClientX, eventClientY) {
14
+ var _a;
15
15
  let offsetX = 0;
16
16
  let offsetY = 0;
17
- if (ref.current) {
18
- const r = ref.current.getBoundingClientRect();
19
- offsetX = eventClientX - r.left;
20
- offsetY = eventClientY - r.top - ((displayModel === null || displayModel === void 0 ? void 0 : displayModel.scrollTop) || 0);
17
+ if (!ref.current) {
18
+ return;
21
19
  }
22
- const x = rbush2.search({
23
- minX: offsetX,
24
- maxX: offsetX + 1,
25
- minY: offsetY,
26
- maxY: offsetY + 1,
27
- });
20
+ const rect = ref.current.getBoundingClientRect();
21
+ offsetX = eventClientX - rect.left;
22
+ offsetY = eventClientY - rect.top - ((displayModel === null || displayModel === void 0 ? void 0 : displayModel.scrollTop) || 0);
23
+ const x = flatbush2.search(offsetX, offsetY, offsetX + 1, offsetY + 1);
28
24
  if (x.length) {
29
- const { minX, minY, maxX, maxY, genotype, featureId, ...rest } = minElt(x, elt => elt.maxX - elt.minX);
30
- const ret = featureGenotypeMap[featureId];
31
- if (ret) {
25
+ const res = minElt(x, idx => { var _a, _b; return (_b = (_a = items[idx]) === null || _a === void 0 ? void 0 : _a.bpLen) !== null && _b !== void 0 ? _b : 0; });
26
+ const { bpLen, genotype, featureId, ...rest } = (_a = items[res]) !== null && _a !== void 0 ? _a : {};
27
+ const ret = featureId !== undefined ? featureGenotypeMap[featureId] : undefined;
28
+ if (ret && genotype) {
32
29
  const { ref, alt, name, description, length } = ret;
33
30
  const alleles = makeSimpleAltString(genotype, ref, alt);
34
31
  return {
@@ -1,6 +1,7 @@
1
1
  import type { MultiRenderArgsDeserialized } from './types';
2
2
  export declare function makeImageData(ctx: CanvasRenderingContext2D, props: MultiRenderArgsDeserialized): Promise<{
3
- rbush: any;
3
+ flatbush: ArrayBufferLike;
4
+ items: any[];
4
5
  featureGenotypeMap: {
5
6
  [k: string]: {
6
7
  alt: any;
@@ -1,6 +1,6 @@
1
1
  import { featureSpanPx, forEachWithStopTokenCheck, updateStatus, } from '@jbrowse/core/util';
2
+ import Flatbush from '@jbrowse/core/util/flatbush';
2
3
  import { checkStopToken } from '@jbrowse/core/util/stopToken';
3
- import RBush from 'rbush';
4
4
  import { f2 } from '../shared/constants';
5
5
  import { drawColorAlleleCount, getColorAlleleCount, } from '../shared/drawAlleleCount';
6
6
  import { drawPhased } from '../shared/drawPhased';
@@ -17,11 +17,14 @@ export async function makeImageData(ctx, props) {
17
17
  lengthCutoffFilter,
18
18
  }));
19
19
  checkStopToken(stopToken);
20
- const rbush = new RBush();
20
+ const coords = [];
21
+ const items = [];
22
+ const colorCache = {};
21
23
  await updateStatus('Drawing variants', statusCallback, () => {
22
24
  forEachWithStopTokenCheck(mafs, stopToken, ({ mostFrequentAlt, feature }) => {
23
25
  const [leftPx, rightPx] = featureSpanPx(feature, region, bpPerPx);
24
- const flen = feature.get('end') - feature.get('start');
26
+ const featureId = feature.id();
27
+ const bpLen = feature.get('end') - feature.get('start');
25
28
  const w = Math.max(Math.round(rightPx - leftPx), 2);
26
29
  const samp = feature.get('genotypes');
27
30
  let y = -scrollTop;
@@ -37,15 +40,13 @@ export async function makeImageData(ctx, props) {
37
40
  if (isPhased) {
38
41
  const alleles = genotype.split('|');
39
42
  if (drawPhased(alleles, ctx, x, y, w, h, HP, undefined, referenceDrawingMode === 'draw')) {
40
- rbush.insert({
41
- minX: x,
42
- maxX: x + w,
43
- minY: y,
44
- maxY: y + h,
45
- genotype,
43
+ items.push({
46
44
  name,
47
- featureId: feature.id(),
45
+ genotype,
46
+ featureId,
47
+ bpLen,
48
48
  });
49
+ coords.push(x, y, x + w, y + h);
49
50
  }
50
51
  }
51
52
  else {
@@ -57,14 +58,14 @@ export async function makeImageData(ctx, props) {
57
58
  }
58
59
  }
59
60
  else {
60
- const colorCache = {};
61
61
  for (let j = 0; j < s; j++) {
62
62
  const { name } = sources[j];
63
63
  const genotype = samp[name];
64
64
  const x = Math.floor(leftPx);
65
65
  const h = Math.max(rowHeight, 1);
66
66
  if (genotype) {
67
- let c = colorCache[genotype];
67
+ const cacheKey = `${genotype}:${mostFrequentAlt}`;
68
+ let c = colorCache[cacheKey];
68
69
  if (c === undefined) {
69
70
  let alt = 0;
70
71
  let uncalled = 0;
@@ -88,19 +89,17 @@ export async function makeImageData(ctx, props) {
88
89
  }
89
90
  }
90
91
  c = getColorAlleleCount(ref, alt, alt2, uncalled, total, referenceDrawingMode === 'draw');
91
- colorCache[genotype] = c;
92
+ colorCache[cacheKey] = c;
92
93
  }
93
94
  if (c) {
94
- drawColorAlleleCount(c, ctx, x, y, w, h, feature.get('type'), feature.get('strand'), flen > 5 ? 0.75 : 1);
95
- rbush.insert({
96
- minX: x,
97
- maxX: x + w,
98
- minY: y,
99
- maxY: y + h,
100
- genotype,
95
+ drawColorAlleleCount(c, ctx, x, y, w, h, feature.get('type'), feature.get('strand'), bpLen > 5 ? 0.75 : 1);
96
+ items.push({
101
97
  name,
102
- featureId: feature.id(),
98
+ genotype,
99
+ featureId,
100
+ bpLen,
103
101
  });
102
+ coords.push(x, y, x + w, y + h);
104
103
  }
105
104
  }
106
105
  y += rowHeight;
@@ -108,8 +107,19 @@ export async function makeImageData(ctx, props) {
108
107
  }
109
108
  });
110
109
  });
110
+ const flatbush = new Flatbush(Math.max(items.length, 1));
111
+ if (items.length) {
112
+ for (let i = 0; i < coords.length; i += 4) {
113
+ flatbush.add(coords[i], coords[i + 1], coords[i + 2], coords[i + 3]);
114
+ }
115
+ }
116
+ else {
117
+ flatbush.add(0, 0);
118
+ }
119
+ flatbush.finish();
111
120
  return {
112
- rbush: rbush.toJSON(),
121
+ flatbush: flatbush.data,
122
+ items,
113
123
  featureGenotypeMap: Object.fromEntries(mafs.map(({ feature }) => [
114
124
  feature.id(),
115
125
  {
@@ -18,7 +18,7 @@ const StructuralVariantChordsReactComponent = observer(function ({ features, con
18
18
  }, [blockDefinitions]);
19
19
  return (_jsx("g", { "data-testid": "structuralVariantChordRenderer", children: [...features.values()].map(feature => {
20
20
  const id = feature.id();
21
- const selected = String(selectedFeatureId) === String(id);
21
+ const selected = selectedFeatureId === id;
22
22
  return (_jsx(Chord, { feature: feature, config: config, radius: radius, bezierRadius: bezierRadius, blocksForRefs: blocksForRefsMemo, selected: selected, onClick: onChordClick }, id));
23
23
  }) }));
24
24
  });
@@ -1,4 +1,4 @@
1
- export default function AltFormatter({ value, ref, }: {
1
+ export default function AltFormatter({ value, refString, }: {
2
2
  value: string;
3
- ref: string;
3
+ refString: string;
4
4
  }): string | import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,10 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from 'react';
2
+ import { useMemo, useState } from 'react';
3
3
  import { getMinimalDesc } from '../VcfFeature/util';
4
- export default function AltFormatter({ value, ref, }) {
4
+ export default function AltFormatter({ value, refString, }) {
5
5
  const [show, setShow] = useState(false);
6
- const alt = getMinimalDesc(ref, value);
6
+ const alt = useMemo(() => getMinimalDesc(refString, value), [refString, value]);
7
7
  return alt !== value ? (_jsxs("div", { children: [_jsx("button", { onClick: () => {
8
8
  setShow(!show);
9
- }, children: show ? 'Show simplified ALT' : 'Show raw ALT' }), ' ', show ? value : getMinimalDesc(ref, value)] })) : (value);
9
+ }, children: show ? 'Show simplified ALT' : 'Show raw ALT' }), ' ', show ? value : alt] })) : (value);
10
10
  }
@@ -53,7 +53,7 @@ const FeatDefined = observer(function (props) {
53
53
  ...variantFieldDescriptions,
54
54
  ...descriptions,
55
55
  }, formatter: (value, key) => {
56
- return key === 'ALT' ? (_jsx(AltFormatter, { value: `${value}`, ref: REF })) : (_jsx(Formatter, { value: value }));
56
+ return key === 'ALT' ? (_jsx(AltFormatter, { value: `${value}`, refString: REF })) : (_jsx(Formatter, { value: value }));
57
57
  }, ...props }), _jsxs(Suspense, { fallback: null, children: [_jsx(CsqPanel, { feature: rest, descriptions: descriptions }), _jsx(AnnPanel, { feature: rest, descriptions: descriptions }), _jsx(LaunchBreakendWidgetArea, { model: model })] }), _jsx(VariantSampleGrid, { feature: feat, ...props, descriptions: descriptions })] }));
58
58
  });
59
59
  const VariantFeatureWidget = observer(function (props) {
@@ -18,14 +18,14 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
18
18
  upperCaseCDS: boolean;
19
19
  charactersPerRow: number;
20
20
  feature: import("@jbrowse/core/util").SimpleFeatureSerialized | undefined;
21
- mode: string;
21
+ mode: "" | "genomic" | "gene" | "gene_collapsed_intron" | "gene_updownstream" | "cdna" | "cds" | "genomic_sequence_updownstream" | "protein";
22
22
  } & {
23
23
  setFeature(f: import("@jbrowse/core/util").SimpleFeatureSerialized): void;
24
24
  setUpDownBp(f: number): void;
25
25
  setIntronBp(f: number): void;
26
26
  setUpperCaseCDS(f: boolean): void;
27
27
  setShowCoordinates(f: "none" | "relative" | "genomic"): void;
28
- setMode(mode: string): void;
28
+ setMode(mode: "" | "genomic" | "gene" | "gene_collapsed_intron" | "gene_updownstream" | "cdna" | "cds" | "genomic_sequence_updownstream" | "protein"): void;
29
29
  } & {
30
30
  readonly showCoordinates: boolean;
31
31
  readonly showGenomicCoordsOption: boolean;
@@ -69,14 +69,14 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
69
69
  upperCaseCDS: boolean;
70
70
  charactersPerRow: number;
71
71
  feature: import("@jbrowse/core/util").SimpleFeatureSerialized | undefined;
72
- mode: string;
72
+ mode: "" | "genomic" | "gene" | "gene_collapsed_intron" | "gene_updownstream" | "cdna" | "cds" | "genomic_sequence_updownstream" | "protein";
73
73
  } & {
74
74
  setFeature(f: import("@jbrowse/core/util").SimpleFeatureSerialized): void;
75
75
  setUpDownBp(f: number): void;
76
76
  setIntronBp(f: number): void;
77
77
  setUpperCaseCDS(f: boolean): void;
78
78
  setShowCoordinates(f: "none" | "relative" | "genomic"): void;
79
- setMode(mode: string): void;
79
+ setMode(mode: "" | "genomic" | "gene" | "gene_collapsed_intron" | "gene_updownstream" | "cdna" | "cds" | "genomic_sequence_updownstream" | "protein"): void;
80
80
  } & {
81
81
  readonly showCoordinates: boolean;
82
82
  readonly showGenomicCoordsOption: boolean;
@@ -1,15 +1,15 @@
1
- import IntervalTree from '@flatten-js/interval-tree';
1
+ import { IntervalTree } from '@flatten-js/interval-tree';
2
2
  import VcfParser from '@gmod/vcf';
3
3
  import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
4
4
  import type { BaseOptions } from '@jbrowse/core/data_adapters/BaseAdapter';
5
5
  import type { Feature, Region } from '@jbrowse/core/util';
6
6
  type StatusCallback = (arg: string) => void;
7
7
  export default class VcfAdapter extends BaseFeatureDataAdapter {
8
- calculatedIntervalTreeMap: Record<string, IntervalTree>;
8
+ calculatedIntervalTreeMap: Record<string, IntervalTree<Feature>>;
9
9
  vcfFeatures?: Promise<{
10
10
  header: string;
11
11
  parser: VcfParser;
12
- intervalTreeMap: Record<string, (sc?: StatusCallback) => IntervalTree>;
12
+ intervalTreeMap: Record<string, (sc?: StatusCallback) => IntervalTree<Feature>>;
13
13
  }>;
14
14
  static capabilities: string[];
15
15
  getHeader(): Promise<string>;
@@ -18,13 +18,13 @@ export default class VcfAdapter extends BaseFeatureDataAdapter {
18
18
  header: string;
19
19
  parser: VcfParser;
20
20
  intervalTreeMap: {
21
- [k: string]: (sc?: (arg: string) => void) => IntervalTree<any>;
21
+ [k: string]: (sc?: (arg: string) => void) => IntervalTree<Feature>;
22
22
  };
23
23
  }>;
24
24
  setup(): Promise<{
25
25
  header: string;
26
26
  parser: VcfParser;
27
- intervalTreeMap: Record<string, (sc?: StatusCallback) => IntervalTree>;
27
+ intervalTreeMap: Record<string, (sc?: StatusCallback) => IntervalTree<Feature>>;
28
28
  }>;
29
29
  getRefNames(_?: BaseOptions): Promise<string[]>;
30
30
  getFeatures(region: Region, opts?: BaseOptions): import("rxjs").Observable<Feature>;
@@ -1,4 +1,4 @@
1
- import IntervalTree from '@flatten-js/interval-tree';
1
+ import { IntervalTree } from '@flatten-js/interval-tree';
2
2
  import VcfParser from '@gmod/vcf';
3
3
  import { BaseFeatureDataAdapter } from '@jbrowse/core/data_adapters/BaseAdapter';
4
4
  import { fetchAndMaybeUnzip } from '@jbrowse/core/util';
@@ -1,6 +1,6 @@
1
+ import { type Feature } from '@jbrowse/core/util';
1
2
  import type VCFParser from '@gmod/vcf';
2
3
  import type { Variant } from '@gmod/vcf';
3
- import type { Feature } from '@jbrowse/core/util';
4
4
  export default class VCFFeature implements Feature {
5
5
  private variant;
6
6
  private parser;
@@ -1,3 +1,4 @@
1
+ import { max } from '@jbrowse/core/util';
1
2
  import { getSOTermAndDescription } from './util';
2
3
  function dataFromVariant(variant, parser) {
3
4
  const { REF = '', ALT, POS, CHROM, ID } = variant;
@@ -13,15 +14,30 @@ function dataFromVariant(variant, parser) {
13
14
  };
14
15
  }
15
16
  function getEnd(variant) {
16
- const { POS, REF = '', ALT } = variant;
17
- const isTRA = ALT === null || ALT === void 0 ? void 0 : ALT.includes('<TRA>');
17
+ var _a;
18
+ const { POS, REF = '', ALT = [] } = variant;
19
+ const isTRA = ALT.includes('<TRA>');
18
20
  const start = POS - 1;
19
- const isSymbolic = ALT === null || ALT === void 0 ? void 0 : ALT.some(f => f.includes('<'));
21
+ const isSymbolic = ALT.some(f => f.includes('<'));
20
22
  if (isSymbolic) {
21
23
  const info = variant.INFO;
22
24
  if (info.END && !isTRA) {
23
25
  return +info.END[0];
24
26
  }
27
+ const lens = [];
28
+ if (info.SVLEN && !isTRA) {
29
+ const svlens = info.SVLEN;
30
+ for (let i = 0; i < svlens.length; i++) {
31
+ const svlen = svlens[i];
32
+ if ((_a = ALT[i]) === null || _a === void 0 ? void 0 : _a.startsWith('<INS')) {
33
+ lens.push(1);
34
+ }
35
+ else {
36
+ lens.push(Math.abs(+svlen));
37
+ }
38
+ }
39
+ return start + max(lens);
40
+ }
25
41
  }
26
42
  return start + REF.length;
27
43
  }
@@ -186,6 +186,7 @@ export default function MultiVariantBaseModelF(configSchema: AnyConfigurationSch
186
186
  regionCannotBeRenderedText(_region: import("@jbrowse/core/util").Region): "" | "Force load to see features";
187
187
  regionCannotBeRendered(_region: import("@jbrowse/core/util").Region): import("react/jsx-runtime").JSX.Element | null;
188
188
  } & {
189
+ mouseoverExtraInformation: string | undefined;
189
190
  featureIdUnderMouse: undefined | string;
190
191
  contextMenuFeature: undefined | Feature;
191
192
  } & {
@@ -200,9 +201,22 @@ export default function MultiVariantBaseModelF(configSchema: AnyConfigurationSch
200
201
  } & {
201
202
  readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
202
203
  readonly featureUnderMouse: Feature | undefined;
204
+ readonly layoutFeatures: import("@jbrowse/core/util/compositeMap").default<string, [number, number, number, number] | [number, number, number, number, {
205
+ label?: string;
206
+ description?: string;
207
+ refName: string;
208
+ }]>;
203
209
  getFeatureOverlapping(blockKey: string, x: number, y: number): string | undefined;
204
- getFeatureByID(blockKey: string, id: string): [number, number, number, number] | undefined;
205
- searchFeatureByID(id: string): [number, number, number, number] | undefined;
210
+ getFeatureByID(blockKey: string, id: string): ([number, number, number, number] | [number, number, number, number, {
211
+ label?: string;
212
+ description?: string;
213
+ refName: string;
214
+ }]) | undefined;
215
+ searchFeatureByID(id: string): ([number, number, number, number] | [number, number, number, number, {
216
+ label?: string;
217
+ description?: string;
218
+ refName: string;
219
+ }]) | undefined;
206
220
  } & {
207
221
  addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
208
222
  deleteBlock(key: string): void;
@@ -211,6 +225,7 @@ export default function MultiVariantBaseModelF(configSchema: AnyConfigurationSch
211
225
  clearFeatureSelection(): void;
212
226
  setFeatureIdUnderMouse(feature?: string): void;
213
227
  setContextMenuFeature(feature?: Feature): void;
228
+ setMouseoverExtraInformation(extra?: string): void;
214
229
  } & {
215
230
  reload(): Promise<void>;
216
231
  } & {
@@ -174,6 +174,7 @@ export default function SharedVariantMixin(configSchema: AnyConfigurationSchemaT
174
174
  regionCannotBeRenderedText(_region: import("@jbrowse/core/util").Region): "" | "Force load to see features";
175
175
  regionCannotBeRendered(_region: import("@jbrowse/core/util").Region): import("react/jsx-runtime").JSX.Element | null;
176
176
  } & {
177
+ mouseoverExtraInformation: string | undefined;
177
178
  featureIdUnderMouse: undefined | string;
178
179
  contextMenuFeature: undefined | Feature;
179
180
  } & {
@@ -188,9 +189,22 @@ export default function SharedVariantMixin(configSchema: AnyConfigurationSchemaT
188
189
  } & {
189
190
  readonly features: import("@jbrowse/core/util/compositeMap").default<string, Feature>;
190
191
  readonly featureUnderMouse: Feature | undefined;
192
+ readonly layoutFeatures: import("@jbrowse/core/util/compositeMap").default<string, [number, number, number, number] | [number, number, number, number, {
193
+ label?: string;
194
+ description?: string;
195
+ refName: string;
196
+ }]>;
191
197
  getFeatureOverlapping(blockKey: string, x: number, y: number): string | undefined;
192
- getFeatureByID(blockKey: string, id: string): [number, number, number, number] | undefined;
193
- searchFeatureByID(id: string): [number, number, number, number] | undefined;
198
+ getFeatureByID(blockKey: string, id: string): ([number, number, number, number] | [number, number, number, number, {
199
+ label?: string;
200
+ description?: string;
201
+ refName: string;
202
+ }]) | undefined;
203
+ searchFeatureByID(id: string): ([number, number, number, number] | [number, number, number, number, {
204
+ label?: string;
205
+ description?: string;
206
+ refName: string;
207
+ }]) | undefined;
194
208
  } & {
195
209
  addBlock(key: string, block: import("@jbrowse/core/util/blockTypes").BaseBlock): void;
196
210
  deleteBlock(key: string): void;
@@ -199,6 +213,7 @@ export default function SharedVariantMixin(configSchema: AnyConfigurationSchemaT
199
213
  clearFeatureSelection(): void;
200
214
  setFeatureIdUnderMouse(feature?: string): void;
201
215
  setContextMenuFeature(feature?: Feature): void;
216
+ setMouseoverExtraInformation(extra?: string): void;
202
217
  } & {
203
218
  reload(): Promise<void>;
204
219
  } & {
@@ -63,7 +63,7 @@ const ClusterDialogManuals = observer(function ({ model, handleClose, children,
63
63
  })();
64
64
  }, [model]);
65
65
  const results = ret
66
- ? `inputMatrix<-matrix(c(${Object.values(ret)
66
+ ? String.raw `inputMatrix<-matrix(c(${Object.values(ret)
67
67
  .map(val => val.join(','))
68
68
  .join(',\n')}
69
69
  ),nrow=${Object.values(ret).length},byrow=TRUE)
@@ -71,7 +71,7 @@ rownames(inputMatrix)<-c(${Object.keys(ret)
71
71
  .map(key => `'${key}'`)
72
72
  .join(',')})
73
73
  resultClusters<-hclust(dist(inputMatrix), method='${clusterMethod}')
74
- cat(resultClusters$order,sep='\\n')`
74
+ cat(resultClusters$order,sep='\n')`
75
75
  : undefined;
76
76
  const resultsTsv = ret
77
77
  ? Object.entries(ret)
@@ -102,7 +102,7 @@ cat(resultClusters$order,sep='\\n')`
102
102
  complete: 'Complete',
103
103
  }).map(([key, val]) => (_jsx(FormControlLabel, { control: _jsx(Radio, { checked: clusterMethod === key, onChange: () => {
104
104
  setClusterMethod(key);
105
- } }), label: val }, key))) })] })) : null, results ? (_jsx("div", {})) : loading ? (_jsx(LoadingEllipses, { variant: "h6", title: "Generating genotype matrix" })) : error ? (_jsx(ErrorMessage, { error: error })) : null] }), _jsxs("div", { children: [_jsx(Typography, { variant: "subtitle2", gutterBottom: true, style: { marginTop: '16px' }, children: "Clustering Results:" }), _jsx(TextField, { multiline: true, fullWidth: true, variant: "outlined", placeholder: "Paste results from Rscript here (sequence of numbers, one per line, specifying the new ordering)", rows: 10, value: paste, onChange: event => {
105
+ } }), label: val }, key))) })] })) : null, results ? (_jsx("div", {})) : loading ? (_jsx(LoadingEllipses, { variant: "h6", message: "Generating genotype matrix" })) : error ? (_jsx(ErrorMessage, { error: error })) : null] }), _jsxs("div", { children: [_jsx(Typography, { variant: "subtitle2", gutterBottom: true, style: { marginTop: '16px' }, children: "Clustering Results:" }), _jsx(TextField, { multiline: true, fullWidth: true, variant: "outlined", placeholder: "Paste results from Rscript here (sequence of numbers, one per line, specifying the new ordering)", rows: 10, value: paste, onChange: event => {
106
106
  setPaste(event.target.value);
107
107
  }, slotProps: {
108
108
  input: {
@@ -1,49 +1,6 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useState } from 'react';
3
- import DraggableDialog from '@jbrowse/core/ui/DraggableDialog';
4
- import { useLocalStorage } from '@jbrowse/core/util';
5
- import { Button, DialogActions, DialogContent } from '@mui/material';
6
- import { makeStyles } from 'tss-react/mui';
7
- import BulkEditPanel from './BulkEditPanel';
8
- import HelpfulTips from './HelpfulTips';
9
- import RowPalettizer from './RowPalettizer';
1
+ import { jsx as _jsx } from "react/jsx-runtime";
10
2
  import SourcesGrid from './SourcesGrid';
11
- const useStyles = makeStyles()({
12
- content: {
13
- minWidth: 800,
14
- },
15
- fr: {
16
- float: 'right',
17
- display: 'flex',
18
- gap: 8,
19
- },
20
- textAreaFont: {
21
- fontFamily: 'Courier New',
22
- },
23
- });
3
+ import SharedSetColorDialog from './ui/SetColorDialog';
24
4
  export default function SetColorDialog({ model, handleClose, }) {
25
- const { classes } = useStyles();
26
- const { sources } = model;
27
- const [showBulkEditor, setShowBulkEditor] = useState(false);
28
- const [currLayout, setCurrLayout] = useState(sources || []);
29
- const [showTips, setShowTips] = useLocalStorage('multivariant-showTips', false);
30
- return (_jsx(DraggableDialog, { open: true, onClose: handleClose, maxWidth: "xl", title: "Multi-sample variant display - Color/arrangement editor", children: showBulkEditor ? (_jsx(BulkEditPanel, { currLayout: currLayout, onClose: arg => {
31
- if (arg) {
32
- setCurrLayout(arg);
33
- }
34
- setShowBulkEditor(false);
35
- } })) : (_jsxs(_Fragment, { children: [_jsxs(DialogContent, { className: classes.content, children: [_jsxs("div", { className: classes.fr, children: [_jsx(Button, { variant: "contained", onClick: () => {
36
- setShowTips(!showTips);
37
- }, children: showTips ? 'Hide tips' : 'Show tips' }), _jsx(Button, { color: "secondary", variant: "contained", onClick: () => {
38
- setShowBulkEditor(!showBulkEditor);
39
- }, children: "Show Bulk row editor" })] }), showTips ? _jsx(HelpfulTips, {}) : null, _jsx("br", {}), _jsx(RowPalettizer, { currLayout: currLayout, setCurrLayout: setCurrLayout }), _jsx(SourcesGrid, { rows: currLayout, onChange: setCurrLayout, showTips: showTips })] }), _jsxs(DialogActions, { children: [_jsx(Button, { variant: "contained", type: "submit", color: "inherit", onClick: () => {
40
- model.clearLayout();
41
- setCurrLayout(model.sources || []);
42
- }, children: "Clear custom settings" }), _jsx(Button, { variant: "contained", color: "secondary", onClick: () => {
43
- handleClose();
44
- setCurrLayout([...(model.sources || [])]);
45
- }, children: "Cancel" }), _jsx(Button, { variant: "contained", color: "primary", type: "submit", onClick: () => {
46
- model.setLayout(currLayout);
47
- handleClose();
48
- }, children: "Submit" })] })] })) }));
5
+ return (_jsx(SharedSetColorDialog, { model: model, handleClose: handleClose, title: "Multi-sample variant display - Color/arrangement editor", enableBulkEdit: true, enableRowPalettizer: true, showTipsStorageKey: "multivariant-showTips", SourcesGridComponent: SourcesGrid }));
49
6
  }
@@ -0,0 +1,10 @@
1
+ export default function SetColorDialogBulkEditPanel({ onClose, currLayout, }: {
2
+ currLayout: {
3
+ name: string;
4
+ [key: string]: unknown;
5
+ }[];
6
+ onClose: (arg?: {
7
+ name: string;
8
+ [key: string]: unknown;
9
+ }[]) => void;
10
+ }): import("react/jsx-runtime").JSX.Element;
@@ -8,7 +8,7 @@ const useStyles = makeStyles()({
8
8
  fontFamily: 'Courier New',
9
9
  },
10
10
  });
11
- export default function BulkEditPanel({ onClose, currLayout, }) {
11
+ export default function SetColorDialogBulkEditPanel({ onClose, currLayout, }) {
12
12
  const { classes } = useStyles();
13
13
  const [val, setVal] = useState('');
14
14
  const [error, setError] = useState();
@@ -0,0 +1 @@
1
+ export default function SetColorDialogHelpfulTips(): import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- export default function HelpfulTips() {
2
+ export default function SetColorDialogHelpfulTips() {
3
3
  return (_jsxs(_Fragment, { children: ["Helpful tips", _jsxs("ul", { children: [_jsx("li", { children: "You can select rows in the table with the checkboxes" }), _jsx("li", { children: "Multi-select is enabled with shift-click and control-click" }), _jsx("li", { children: "The \"Move selected items up/down\" can re-arrange subtracks" }), _jsx("li", { children: "Sorting the data grid itself can also re-arrange subtracks" }), _jsx("li", { children: "Changes are applied when you hit Submit" }), _jsx("li", { children: "You can click and drag the dialog box to move it on the screen" }), _jsx("li", { children: "Columns in the table can be hidden using a vertical '...' menu on the right side of each column" })] })] }));
4
4
  }