jbrowse-plugin-msaview 2.10.2 → 3.1.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.
- package/dist/LaunchMsaView/components/BlastQuery/BlastManualPanel.d.ts +11 -0
- package/dist/LaunchMsaView/components/BlastQuery/BlastManualPanel.js +73 -16
- package/dist/LaunchMsaView/components/BlastQuery/consts.d.ts +8 -1
- package/dist/LaunchMsaView/components/BlastQuery/consts.js +8 -1
- package/dist/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.js +7 -14
- package/dist/LaunchMsaView/components/QueryRowSelector.d.ts +16 -0
- package/dist/LaunchMsaView/components/QueryRowSelector.js +38 -0
- package/dist/LaunchMsaView/detectQueryRow.d.ts +23 -0
- package/dist/LaunchMsaView/detectQueryRow.js +94 -0
- package/dist/LaunchMsaView/detectQueryRow.test.d.ts +1 -0
- package/dist/LaunchMsaView/detectQueryRow.test.js +65 -0
- package/dist/LaunchMsaView/useQueryRowName.d.ts +15 -0
- package/dist/LaunchMsaView/useQueryRowName.js +26 -0
- package/dist/MsaViewPanel/afterCreateAutoruns.d.ts +28 -12
- package/dist/MsaViewPanel/afterCreateAutoruns.js +99 -50
- package/dist/MsaViewPanel/model.d.ts +12 -76
- package/dist/MsaViewPanel/model.js +1 -1
- package/dist/MsaViewPanel/observeProteinHighlights.test.d.ts +1 -0
- package/dist/MsaViewPanel/observeProteinHighlights.test.js +209 -0
- package/dist/MsaViewPanel/structureConnection.d.ts +6 -0
- package/dist/jbrowse-plugin-msaview.umd.production.min.js +29 -29
- package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +4 -4
- package/dist/utils/ncbiDomains.d.ts +2 -30
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +5 -3
- package/src/LaunchMsaView/components/BlastQuery/BlastManualPanel.tsx +126 -30
- package/src/LaunchMsaView/components/BlastQuery/consts.ts +8 -1
- package/src/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.tsx +7 -37
- package/src/LaunchMsaView/components/QueryRowSelector.tsx +93 -0
- package/src/LaunchMsaView/detectQueryRow.test.ts +79 -0
- package/src/LaunchMsaView/detectQueryRow.ts +132 -0
- package/src/LaunchMsaView/useQueryRowName.ts +33 -0
- package/src/MsaViewPanel/afterCreateAutoruns.ts +109 -54
- package/src/MsaViewPanel/model.ts +1 -1
- package/src/MsaViewPanel/observeProteinHighlights.test.ts +264 -0
- package/src/MsaViewPanel/structureConnection.ts +7 -0
- package/src/version.ts +1 -1
|
@@ -121,14 +121,14 @@ export function launchBlastIfNeeded(self) {
|
|
|
121
121
|
* Once an accession-bearing alignment is present (fresh from BLAST or restored
|
|
122
122
|
* from cache), fetch NCBI CDD domains for those accessions and overlay them.
|
|
123
123
|
* Runs once per view; the domainsRequested guard prevents refiring when NCBI
|
|
124
|
-
* returns no domains (which leaves
|
|
124
|
+
* returns no domains (which leaves the annotation list empty).
|
|
125
125
|
*/
|
|
126
126
|
export function autoLoadProteinDomains(self) {
|
|
127
|
-
const { rows, domainsRequested,
|
|
127
|
+
const { rows, domainsRequested, annotations } = self;
|
|
128
128
|
const hasAccessions = self.data.treeMetadata?.includes('"Accession"') ?? false;
|
|
129
129
|
if (rows.length > 0 &&
|
|
130
130
|
hasAccessions &&
|
|
131
|
-
|
|
131
|
+
annotations.length === 0 &&
|
|
132
132
|
!domainsRequested) {
|
|
133
133
|
self.setDomainsRequested(true);
|
|
134
134
|
void (async () => {
|
|
@@ -212,60 +212,109 @@ export function syncGenomeHoverToMsaColumn(self) {
|
|
|
212
212
|
};
|
|
213
213
|
}
|
|
214
214
|
/**
|
|
215
|
-
*
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
|
|
215
|
+
* Translate genome regions published by a 3D protein view into this MSA's
|
|
216
|
+
* visible columns. The genome is the only coordinate space the two plugins
|
|
217
|
+
* share, so the hops are genome coord -> protein position (the transcript's g2p
|
|
218
|
+
* map) -> global alignment column -> visible column.
|
|
219
|
+
*/
|
|
220
|
+
function genomeHighlightsToVisibleColumns(self, field) {
|
|
221
|
+
const { connectedViewId, transcriptToMsaMap, querySeqName } = self;
|
|
222
|
+
if (!transcriptToMsaMap) {
|
|
223
|
+
return [];
|
|
224
|
+
}
|
|
225
|
+
const { g2p } = transcriptToMsaMap;
|
|
226
|
+
const columns = new Set();
|
|
227
|
+
for (const view of getProteinViews(getSession(self).views)) {
|
|
228
|
+
for (const structure of view.structures) {
|
|
229
|
+
if (structure.connectedViewId !== connectedViewId) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
for (const highlight of structure[field] ?? []) {
|
|
233
|
+
for (let coord = highlight.start; coord < highlight.end; coord++) {
|
|
234
|
+
const proteinPos = g2p[coord];
|
|
235
|
+
if (proteinPos !== undefined) {
|
|
236
|
+
columns.add(self.seqPosToGlobalCol(querySeqName, proteinPos));
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return [...columns]
|
|
243
|
+
.map(col => self.globalColToVisibleCol(col))
|
|
244
|
+
.filter((col) => col !== undefined);
|
|
245
|
+
}
|
|
246
|
+
function sameColumns(a, b) {
|
|
247
|
+
if (!a || !b) {
|
|
248
|
+
return a === b;
|
|
249
|
+
}
|
|
250
|
+
return a.length === b.length && a.every((col, i) => col === b[i]);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Mirror a connected 3D protein view's highlights onto the MSA's highlighted
|
|
254
|
+
* columns, from either of the two channels protein3d publishes:
|
|
255
|
+
*
|
|
256
|
+
* - `hoverGenomeHighlights` — the residue under the pointer, transient.
|
|
257
|
+
* - `clickGenomeHighlights` — the domain the user clicked, persistent. Also
|
|
258
|
+
* what protein3d's declarative `initialSelection` lights on load, so a session
|
|
259
|
+
* spec that pre-selects a domain in the structure now lands in the alignment
|
|
260
|
+
* too, instead of the caller having to author the same range a second time as
|
|
261
|
+
* the MSA's own `highlightColumns`.
|
|
262
|
+
*
|
|
263
|
+
* Highest-priority non-empty source wins: a hover reads as a transient probe on
|
|
264
|
+
* top of the standing selection, and letting it win means moving the pointer
|
|
265
|
+
* over the structure previews a residue without destroying what was selected.
|
|
266
|
+
* Releasing the hover falls back to the click selection, then to the declarative
|
|
267
|
+
* `highlightColumns` seed.
|
|
220
268
|
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* the bug that made the BRAF/TP53
|
|
226
|
-
*
|
|
269
|
+
* Resolving the seed as the last rung of that stack is what replaced a
|
|
270
|
+
* `proteinDriven` flag this function used to carry. The flag existed because the
|
|
271
|
+
* body could not otherwise tell "no protein highlight, leave the seed alone"
|
|
272
|
+
* from "the protein highlight ended, restore the seed", and getting that wrong
|
|
273
|
+
* wiped the seed on the very first run — the bug that made the BRAF/TP53
|
|
274
|
+
* genome-browser links open with no V600/R248 column lit. Now every source is in
|
|
275
|
+
* one expression, so the result depends only on what the sources currently say
|
|
276
|
+
* and there is no ordering to get wrong.
|
|
277
|
+
*
|
|
278
|
+
* A closure remains, but it decides nothing: `written` only suppresses a
|
|
279
|
+
* redundant redraw. Delete it and the highlight is identical, just recomputed
|
|
280
|
+
* more often — where deleting the old flag changed which columns lit.
|
|
227
281
|
*/
|
|
228
282
|
export function observeProteinHighlights(self) {
|
|
229
|
-
|
|
283
|
+
// The columns this reaction last wrote, kept to skip a write that would not
|
|
284
|
+
// change anything: protein3d recomputes hoverGenomeHighlights on every mouse
|
|
285
|
+
// move over the structure, and moving within one codon yields a fresh array of
|
|
286
|
+
// the same columns, which would redraw the overlay canvas for nothing.
|
|
287
|
+
//
|
|
288
|
+
// Deliberately a closure rather than a read of `self.highlightedColumns` --
|
|
289
|
+
// reading it would put this reaction's own output in its dependency set, so
|
|
290
|
+
// every write would re-trigger it. It converges, but the dependencies should be
|
|
291
|
+
// the sources the highlight derives FROM, not the highlight itself.
|
|
292
|
+
let written;
|
|
230
293
|
return () => {
|
|
231
|
-
const { connectedViewId, transcriptToMsaMap
|
|
294
|
+
const { connectedViewId, transcriptToMsaMap } = self;
|
|
232
295
|
if (!connectedViewId || !transcriptToMsaMap) {
|
|
233
296
|
return;
|
|
234
297
|
}
|
|
235
|
-
const
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
const visibleColumns = Array.from(columns)
|
|
258
|
-
.map(col => self.globalColToVisibleCol(col))
|
|
259
|
-
.filter((col) => col !== undefined);
|
|
260
|
-
if (visibleColumns.length > 0) {
|
|
261
|
-
self.setHighlightedColumns(visibleColumns);
|
|
262
|
-
proteinDriven = true;
|
|
263
|
-
}
|
|
264
|
-
else if (proteinDriven) {
|
|
265
|
-
// our protein-hover highlight ended — fall back to the declarative seed
|
|
266
|
-
// instead of wiping a column the URL/user asked to keep lit
|
|
267
|
-
self.setHighlightedColumns(self.highlightColumns?.length ? self.highlightColumns : undefined);
|
|
268
|
-
proteinDriven = false;
|
|
298
|
+
const hover = genomeHighlightsToVisibleColumns(self, 'hoverGenomeHighlights');
|
|
299
|
+
// Skipping the click channel while hovering is worth the subtlety it costs:
|
|
300
|
+
// a hover recomputes on every mouse move, and a clicked domain can be
|
|
301
|
+
// hundreds of residues, so translating a selection that cannot win would
|
|
302
|
+
// walk thousands of genome coordinates per pointer move.
|
|
303
|
+
//
|
|
304
|
+
// The subtlety is that not reading clickGenomeHighlights leaves it out of
|
|
305
|
+
// this reaction's dependencies until the hover clears. Changing the
|
|
306
|
+
// selection mid-hover therefore does not re-run us -- which is harmless,
|
|
307
|
+
// because the hover would have outranked it anyway, and releasing the hover
|
|
308
|
+
// re-runs and picks up whatever the selection now says.
|
|
309
|
+
const click = hover.length
|
|
310
|
+
? []
|
|
311
|
+
: genomeHighlightsToVisibleColumns(self, 'clickGenomeHighlights');
|
|
312
|
+
const seed = self.highlightColumns ?? [];
|
|
313
|
+
const winner = hover.length ? hover : click.length ? click : seed;
|
|
314
|
+
const next = winner.length > 0 ? winner : undefined;
|
|
315
|
+
if (!sameColumns(written, next)) {
|
|
316
|
+
written = next;
|
|
317
|
+
self.setHighlightedColumns(next);
|
|
269
318
|
}
|
|
270
319
|
};
|
|
271
320
|
}
|
|
@@ -552,7 +552,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
|
|
|
552
552
|
conservationTrackHeight: number;
|
|
553
553
|
marginLeft: number;
|
|
554
554
|
error: unknown;
|
|
555
|
-
|
|
555
|
+
annotations: import("msa-parsers").Annotation[];
|
|
556
556
|
} & {
|
|
557
557
|
drawRelativeTo(id: string | undefined): void;
|
|
558
558
|
setHideGaps(arg: boolean): void;
|
|
@@ -571,7 +571,6 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
|
|
|
571
571
|
setMouseClickPos(col?: number, row?: number): void;
|
|
572
572
|
setRowHeight(n: number): void;
|
|
573
573
|
setColWidth(n: number): void;
|
|
574
|
-
setScrollY(n: number): void;
|
|
575
574
|
setCurrentAlignment(n: number): void;
|
|
576
575
|
toggleCollapsed(node: string): void;
|
|
577
576
|
setShowOnly(node?: string): void;
|
|
@@ -628,7 +627,6 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
|
|
|
628
627
|
readonly msaAreaWidth: number;
|
|
629
628
|
readonly treeAreaWidthMinusMargin: number;
|
|
630
629
|
readonly blanks: number[];
|
|
631
|
-
readonly blanksSet: Set<number>;
|
|
632
630
|
readonly insertionPositions: Map<string, {
|
|
633
631
|
pos: number;
|
|
634
632
|
letters: string;
|
|
@@ -641,7 +639,6 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
|
|
|
641
639
|
readonly columns2d: string[];
|
|
642
640
|
readonly fontSize: number;
|
|
643
641
|
readonly colStats: import("react-msaview").ColumnCounts;
|
|
644
|
-
readonly colStatsSums: Uint32Array<ArrayBufferLike>;
|
|
645
642
|
readonly sequenceType: "dna" | "rna" | "amino";
|
|
646
643
|
readonly colConsensus: {
|
|
647
644
|
letter: string;
|
|
@@ -684,7 +681,9 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
|
|
|
684
681
|
zoomOut(): void;
|
|
685
682
|
zoomToPos(scaleFactor: number, offsetX: number, offsetY: number): void;
|
|
686
683
|
doScrollY(deltaY: number): void;
|
|
687
|
-
|
|
684
|
+
setScrollY(n: number): void;
|
|
685
|
+
setAnnotations(annotations: import("msa-parsers").Annotation[]): void;
|
|
686
|
+
setDomains(data?: Record<string, import("msa-parsers").InterProScanResults>): void;
|
|
688
687
|
applyGFFText(gffText: string): void;
|
|
689
688
|
doScrollX(deltaX: number): void;
|
|
690
689
|
setScrollX(n: number): void;
|
|
@@ -712,70 +711,16 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
|
|
|
712
711
|
} & {
|
|
713
712
|
readonly msaAreaHeight: number;
|
|
714
713
|
readonly totalTrackAreaHeight: number;
|
|
715
|
-
readonly
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
accession: string;
|
|
719
|
-
description: string;
|
|
720
|
-
featureType: string | undefined;
|
|
721
|
-
start: number;
|
|
722
|
-
end: number;
|
|
723
|
-
strand: number | undefined;
|
|
724
|
-
}>;
|
|
725
|
-
readonly tidyInterProAnnotations: {
|
|
726
|
-
id: string;
|
|
727
|
-
name: string;
|
|
728
|
-
accession: string;
|
|
729
|
-
description: string;
|
|
730
|
-
featureType: string | undefined;
|
|
731
|
-
start: number;
|
|
732
|
-
end: number;
|
|
733
|
-
strand: number | undefined;
|
|
734
|
-
}[];
|
|
735
|
-
readonly tidyFilteredInterProAnnotations: {
|
|
736
|
-
id: string;
|
|
737
|
-
name: string;
|
|
738
|
-
accession: string;
|
|
739
|
-
description: string;
|
|
740
|
-
featureType: string | undefined;
|
|
741
|
-
start: number;
|
|
742
|
-
end: number;
|
|
743
|
-
strand: number | undefined;
|
|
744
|
-
}[];
|
|
745
|
-
readonly tidyFilteredGatheredInterProAnnotations: Record<string, {
|
|
746
|
-
id: string;
|
|
747
|
-
name: string;
|
|
748
|
-
accession: string;
|
|
749
|
-
description: string;
|
|
750
|
-
featureType: string | undefined;
|
|
751
|
-
start: number;
|
|
752
|
-
end: number;
|
|
753
|
-
strand: number | undefined;
|
|
754
|
-
}[]>;
|
|
714
|
+
readonly annotationTypes: Map<string, import("msa-parsers").Annotation>;
|
|
715
|
+
readonly filteredAnnotations: import("msa-parsers").Annotation[];
|
|
716
|
+
readonly annotationsByRow: Record<string, import("msa-parsers").Annotation[]>;
|
|
755
717
|
} & {
|
|
756
718
|
readonly showVerticalScrollbar: boolean;
|
|
757
719
|
} & {
|
|
758
720
|
readonly verticalScrollbarWidth: 0 | 20;
|
|
759
|
-
readonly
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
accession: string;
|
|
763
|
-
description: string;
|
|
764
|
-
featureType: string | undefined;
|
|
765
|
-
start: number;
|
|
766
|
-
end: number;
|
|
767
|
-
strand: number | undefined;
|
|
768
|
-
}[];
|
|
769
|
-
readonly categoricalDomainTypes: {
|
|
770
|
-
id: string;
|
|
771
|
-
name: string;
|
|
772
|
-
accession: string;
|
|
773
|
-
description: string;
|
|
774
|
-
featureType: string | undefined;
|
|
775
|
-
start: number;
|
|
776
|
-
end: number;
|
|
777
|
-
strand: number | undefined;
|
|
778
|
-
}[];
|
|
721
|
+
readonly msaCanvasWidth: number;
|
|
722
|
+
readonly segmentDomainTypes: import("msa-parsers").Annotation[];
|
|
723
|
+
readonly categoricalDomainTypes: import("msa-parsers").Annotation[];
|
|
779
724
|
readonly fillPalette: {
|
|
780
725
|
[x: string]: string;
|
|
781
726
|
};
|
|
@@ -783,19 +728,10 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
|
|
|
783
728
|
[k: string]: string;
|
|
784
729
|
};
|
|
785
730
|
readonly segmentLabels: Map<string, string>;
|
|
786
|
-
readonly visibleDomainTypes:
|
|
787
|
-
id: string;
|
|
788
|
-
name: string;
|
|
789
|
-
accession: string;
|
|
790
|
-
description: string;
|
|
791
|
-
featureType: string | undefined;
|
|
792
|
-
start: number;
|
|
793
|
-
end: number;
|
|
794
|
-
strand: number | undefined;
|
|
795
|
-
}[];
|
|
731
|
+
readonly visibleDomainTypes: import("msa-parsers").Annotation[];
|
|
796
732
|
readonly domainBands: Map<string, import("react-msaview").DomainBand[]>;
|
|
797
733
|
readonly domainBandsByStart: Map<string, import("react-msaview").DomainBand[]>;
|
|
798
|
-
readonly mouseOverDomains: import("
|
|
734
|
+
readonly mouseOverDomains: import("msa-parsers").Annotation[];
|
|
799
735
|
readonly referenceRowIndex: number | undefined;
|
|
800
736
|
readonly hoveredRowIndices: number[];
|
|
801
737
|
readonly highlightedColumnRuns: {
|
|
@@ -85,7 +85,7 @@ export default function stateModelFactory() {
|
|
|
85
85
|
/**
|
|
86
86
|
* #volatile
|
|
87
87
|
* guards the one-shot auto-fetch of protein domains so it doesn't refire
|
|
88
|
-
* when NCBI returns no domains (leaving
|
|
88
|
+
* when NCBI returns no domains (leaving the annotation list empty)
|
|
89
89
|
*/
|
|
90
90
|
domainsRequested: false,
|
|
91
91
|
}))
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { getSession } from '@jbrowse/core/util';
|
|
2
|
+
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
|
3
|
+
import { observeProteinHighlights } from './afterCreateAutoruns';
|
|
4
|
+
// Mock only getSession; keep the rest of the util module real so the
|
|
5
|
+
// afterCreateAutoruns import graph still loads.
|
|
6
|
+
vi.mock('@jbrowse/core/util', async (importOriginal) => ({
|
|
7
|
+
...(await importOriginal()),
|
|
8
|
+
getSession: vi.fn(),
|
|
9
|
+
}));
|
|
10
|
+
const mockGetSession = vi.mocked(getSession);
|
|
11
|
+
const CONNECTED = 'lgv-1';
|
|
12
|
+
/**
|
|
13
|
+
* A model with an identity genome->protein->column mapping, so an asserted
|
|
14
|
+
* column equals the genome coordinate that produced it and the test reads as
|
|
15
|
+
* "these genome coords lit these columns".
|
|
16
|
+
*/
|
|
17
|
+
function makeModel({ highlightColumns } = {}) {
|
|
18
|
+
const calls = [];
|
|
19
|
+
const model = {
|
|
20
|
+
querySeqName: 'query',
|
|
21
|
+
connectedViewId: CONNECTED,
|
|
22
|
+
// g2p is indexed by genome coord; identity keeps the arithmetic out of the way
|
|
23
|
+
transcriptToMsaMap: {
|
|
24
|
+
g2p: Object.fromEntries([...Array(200).keys()].map(i => [i, i])),
|
|
25
|
+
},
|
|
26
|
+
highlightColumns,
|
|
27
|
+
highlightedColumns: undefined,
|
|
28
|
+
seqPosToGlobalCol: (_name, pos) => pos,
|
|
29
|
+
globalColToVisibleCol: (col) => col,
|
|
30
|
+
setHighlightedColumns: (cols) => {
|
|
31
|
+
calls.push(cols);
|
|
32
|
+
model.highlightedColumns = cols;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
return { model, calls };
|
|
36
|
+
}
|
|
37
|
+
/** publish highlight channels on a ProteinView structure in the session */
|
|
38
|
+
function session({ hover, click, connectedViewId = CONNECTED, }) {
|
|
39
|
+
mockGetSession.mockReturnValue({
|
|
40
|
+
views: [
|
|
41
|
+
{
|
|
42
|
+
type: 'ProteinView',
|
|
43
|
+
id: 'pv-1',
|
|
44
|
+
structures: [
|
|
45
|
+
{
|
|
46
|
+
connectedViewId,
|
|
47
|
+
hoverGenomeHighlights: hover,
|
|
48
|
+
clickGenomeHighlights: click,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function noProteinView() {
|
|
56
|
+
mockGetSession.mockReturnValue({
|
|
57
|
+
views: [{ type: 'LinearGenomeView', id: CONNECTED }],
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
vi.clearAllMocks();
|
|
62
|
+
});
|
|
63
|
+
describe('the hover channel', () => {
|
|
64
|
+
test('a hovered residue lights its column', () => {
|
|
65
|
+
const { model, calls } = makeModel();
|
|
66
|
+
const run = observeProteinHighlights(model);
|
|
67
|
+
session({ hover: [{ start: 10, end: 13 }] });
|
|
68
|
+
run();
|
|
69
|
+
expect(calls).toEqual([[10, 11, 12]]);
|
|
70
|
+
});
|
|
71
|
+
test('releasing the hover clears the highlight', () => {
|
|
72
|
+
const { model, calls } = makeModel();
|
|
73
|
+
const run = observeProteinHighlights(model);
|
|
74
|
+
session({ hover: [{ start: 10, end: 12 }] });
|
|
75
|
+
run();
|
|
76
|
+
session({ hover: [] });
|
|
77
|
+
run();
|
|
78
|
+
expect(calls).toEqual([[10, 11], undefined]);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe('the click channel', () => {
|
|
82
|
+
test('a clicked domain lights its columns', () => {
|
|
83
|
+
const { model, calls } = makeModel();
|
|
84
|
+
const run = observeProteinHighlights(model);
|
|
85
|
+
session({ click: [{ start: 30, end: 34 }] });
|
|
86
|
+
run();
|
|
87
|
+
expect(calls).toEqual([[30, 31, 32, 33]]);
|
|
88
|
+
});
|
|
89
|
+
test('a hover wins over the standing click selection', () => {
|
|
90
|
+
const { model, calls } = makeModel();
|
|
91
|
+
const run = observeProteinHighlights(model);
|
|
92
|
+
session({ click: [{ start: 30, end: 32 }], hover: [{ start: 5, end: 6 }] });
|
|
93
|
+
run();
|
|
94
|
+
expect(calls).toEqual([[5]]);
|
|
95
|
+
});
|
|
96
|
+
test('a selection changed during a hover is picked up when the hover releases', () => {
|
|
97
|
+
const { model, calls } = makeModel();
|
|
98
|
+
const run = observeProteinHighlights(model);
|
|
99
|
+
// the reaction skips the click channel while hovering, so it is not watching
|
|
100
|
+
// it; this pins that releasing the hover still lands on the CURRENT selection
|
|
101
|
+
// rather than on the one that was standing when the hover began
|
|
102
|
+
session({ click: [{ start: 30, end: 32 }], hover: [{ start: 5, end: 6 }] });
|
|
103
|
+
run();
|
|
104
|
+
session({ click: [{ start: 60, end: 62 }], hover: [{ start: 5, end: 6 }] });
|
|
105
|
+
run();
|
|
106
|
+
session({ click: [{ start: 60, end: 62 }] });
|
|
107
|
+
run();
|
|
108
|
+
expect(calls).toEqual([[5], [60, 61]]);
|
|
109
|
+
});
|
|
110
|
+
test('releasing the hover falls back to the click selection, not to nothing', () => {
|
|
111
|
+
const { model, calls } = makeModel();
|
|
112
|
+
const run = observeProteinHighlights(model);
|
|
113
|
+
// this is the whole point of the two channels: previewing a residue must not
|
|
114
|
+
// destroy the domain the user selected
|
|
115
|
+
session({ click: [{ start: 30, end: 32 }] });
|
|
116
|
+
run();
|
|
117
|
+
session({ click: [{ start: 30, end: 32 }], hover: [{ start: 5, end: 6 }] });
|
|
118
|
+
run();
|
|
119
|
+
session({ click: [{ start: 30, end: 32 }] });
|
|
120
|
+
run();
|
|
121
|
+
expect(calls).toEqual([[30, 31], [5], [30, 31]]);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
describe('the declarative highlightColumns seed', () => {
|
|
125
|
+
// the regression these guard: the observer used to compute zero columns on its
|
|
126
|
+
// first run and wipe the seed MSAModelF.afterCreate had just applied, which is
|
|
127
|
+
// what made the BRAF/TP53 links open with no V600/R248 column lit
|
|
128
|
+
test('a first run with no protein view leaves the seed alone', () => {
|
|
129
|
+
const { model, calls } = makeModel({ highlightColumns: [77] });
|
|
130
|
+
const run = observeProteinHighlights(model);
|
|
131
|
+
noProteinView();
|
|
132
|
+
run();
|
|
133
|
+
expect(calls).toEqual([[77]]);
|
|
134
|
+
expect(model.highlightedColumns).toEqual([77]);
|
|
135
|
+
});
|
|
136
|
+
test('repeated runs never clobber the seed', () => {
|
|
137
|
+
const { model } = makeModel({ highlightColumns: [77] });
|
|
138
|
+
const run = observeProteinHighlights(model);
|
|
139
|
+
noProteinView();
|
|
140
|
+
run();
|
|
141
|
+
run();
|
|
142
|
+
run();
|
|
143
|
+
expect(model.highlightedColumns).toEqual([77]);
|
|
144
|
+
});
|
|
145
|
+
test('a hover overrides the seed, and releasing it restores the seed', () => {
|
|
146
|
+
const { model, calls } = makeModel({ highlightColumns: [77] });
|
|
147
|
+
const run = observeProteinHighlights(model);
|
|
148
|
+
session({ hover: [{ start: 1, end: 2 }] });
|
|
149
|
+
run();
|
|
150
|
+
session({ hover: [] });
|
|
151
|
+
run();
|
|
152
|
+
expect(calls).toEqual([[1], [77]]);
|
|
153
|
+
});
|
|
154
|
+
test('a click selection outranks the seed', () => {
|
|
155
|
+
const { model, calls } = makeModel({ highlightColumns: [77] });
|
|
156
|
+
const run = observeProteinHighlights(model);
|
|
157
|
+
session({ click: [{ start: 40, end: 42 }] });
|
|
158
|
+
run();
|
|
159
|
+
expect(calls).toEqual([[40, 41]]);
|
|
160
|
+
});
|
|
161
|
+
test('with no seed and no protein highlight, nothing is written at all', () => {
|
|
162
|
+
const { model, calls } = makeModel();
|
|
163
|
+
const run = observeProteinHighlights(model);
|
|
164
|
+
noProteinView();
|
|
165
|
+
run();
|
|
166
|
+
run();
|
|
167
|
+
expect(calls).toEqual([]);
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
describe('scope and redundant writes', () => {
|
|
171
|
+
test('a structure connected to a different view is ignored', () => {
|
|
172
|
+
const { model, calls } = makeModel();
|
|
173
|
+
const run = observeProteinHighlights(model);
|
|
174
|
+
session({
|
|
175
|
+
hover: [{ start: 10, end: 12 }],
|
|
176
|
+
connectedViewId: 'some-other-view',
|
|
177
|
+
});
|
|
178
|
+
run();
|
|
179
|
+
expect(calls).toEqual([]);
|
|
180
|
+
});
|
|
181
|
+
test('an unchanged highlight is not rewritten, so the overlay does not redraw', () => {
|
|
182
|
+
const { model, calls } = makeModel();
|
|
183
|
+
const run = observeProteinHighlights(model);
|
|
184
|
+
session({ hover: [{ start: 10, end: 12 }] });
|
|
185
|
+
run();
|
|
186
|
+
run();
|
|
187
|
+
run();
|
|
188
|
+
expect(calls).toEqual([[10, 11]]);
|
|
189
|
+
});
|
|
190
|
+
test('a genome coord with no protein position contributes no column', () => {
|
|
191
|
+
const { model, calls } = makeModel();
|
|
192
|
+
const run = observeProteinHighlights(model);
|
|
193
|
+
// 500 is past the end of the identity g2p map built above
|
|
194
|
+
session({ hover: [{ start: 500, end: 503 }] });
|
|
195
|
+
run();
|
|
196
|
+
expect(calls).toEqual([]);
|
|
197
|
+
});
|
|
198
|
+
test('nothing happens until the view is connected and mapped', () => {
|
|
199
|
+
const { calls } = makeModel();
|
|
200
|
+
const bare = {
|
|
201
|
+
connectedViewId: undefined,
|
|
202
|
+
transcriptToMsaMap: undefined,
|
|
203
|
+
};
|
|
204
|
+
const run = observeProteinHighlights(bare);
|
|
205
|
+
session({ hover: [{ start: 10, end: 12 }] });
|
|
206
|
+
run();
|
|
207
|
+
expect(calls).toEqual([]);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
@@ -3,10 +3,16 @@ export interface ProteinViewStructure {
|
|
|
3
3
|
connectedViewId?: string;
|
|
4
4
|
uniprotId?: string;
|
|
5
5
|
structureSequences?: string[];
|
|
6
|
+
/** the residue under the pointer, transient */
|
|
6
7
|
hoverGenomeHighlights?: {
|
|
7
8
|
start: number;
|
|
8
9
|
end: number;
|
|
9
10
|
}[];
|
|
11
|
+
/** the clicked domain, persistent; also what `initialSelection` lights */
|
|
12
|
+
clickGenomeHighlights?: {
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
}[];
|
|
10
16
|
}
|
|
11
17
|
export interface ProteinView {
|
|
12
18
|
type: 'ProteinView';
|