jbrowse-plugin-msaview 2.5.1 → 2.5.2

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.
@@ -20,5 +20,19 @@ export declare function processInit(self: JBrowsePluginMsaViewModel): void;
20
20
  export declare function syncGenomeHoverToMsaColumn(self: JBrowsePluginMsaViewModel): () => void;
21
21
  export declare function highlightConnectedStructures(self: JBrowsePluginMsaViewModel): void;
22
22
  export declare function autoConnectStructures(self: JBrowsePluginMsaViewModel): void;
23
- export declare function observeProteinHighlights(self: JBrowsePluginMsaViewModel): void;
23
+ /**
24
+ * Mirror a connected 3D protein view's hovered residue onto the MSA's
25
+ * highlighted columns. Returns the autorun body and keeps a flag tracking
26
+ * whether the current highlight was set by THIS sync: when a protein hover ends
27
+ * we restore the declarative highlightColumns seed (or clear) rather than
28
+ * blindly wiping it.
29
+ *
30
+ * Without the flag this autorun fires once on creation — with the view connected
31
+ * to a *genome* LGV but no 3D protein structure attached — computes zero columns,
32
+ * and calls setHighlightedColumns(undefined), clobbering the seed that
33
+ * MSAModelF.afterCreate just set from the declarative `highlightColumns`. That is
34
+ * the bug that made the BRAF/TP53 genome-browser links open with no V600/R248
35
+ * column lit (SRC has no highlightColumns, so nothing was there to wipe).
36
+ */
37
+ export declare function observeProteinHighlights(self: JBrowsePluginMsaViewModel): () => void;
24
38
  export declare function runCleanup(): void;
@@ -249,37 +249,63 @@ export function autoConnectStructures(self) {
249
249
  }
250
250
  }
251
251
  }
252
+ /**
253
+ * Mirror a connected 3D protein view's hovered residue onto the MSA's
254
+ * highlighted columns. Returns the autorun body and keeps a flag tracking
255
+ * whether the current highlight was set by THIS sync: when a protein hover ends
256
+ * we restore the declarative highlightColumns seed (or clear) rather than
257
+ * blindly wiping it.
258
+ *
259
+ * Without the flag this autorun fires once on creation — with the view connected
260
+ * to a *genome* LGV but no 3D protein structure attached — computes zero columns,
261
+ * and calls setHighlightedColumns(undefined), clobbering the seed that
262
+ * MSAModelF.afterCreate just set from the declarative `highlightColumns`. That is
263
+ * the bug that made the BRAF/TP53 genome-browser links open with no V600/R248
264
+ * column lit (SRC has no highlightColumns, so nothing was there to wipe).
265
+ */
252
266
  export function observeProteinHighlights(self) {
253
- const { connectedViewId, transcriptToMsaMap, querySeqName } = self;
254
- if (!connectedViewId || !transcriptToMsaMap) {
255
- return;
256
- }
257
- const columns = new Set();
258
- for (const view of getProteinViews(getSession(self).views)) {
259
- for (const structure of view.structures) {
260
- if (structure.connectedViewId !== connectedViewId) {
261
- continue;
262
- }
263
- const highlights = structure.hoverGenomeHighlights;
264
- if (!highlights || highlights.length === 0) {
265
- continue;
266
- }
267
- const { g2p } = transcriptToMsaMap;
268
- for (const highlight of highlights) {
269
- for (let coord = highlight.start; coord < highlight.end; coord++) {
270
- const proteinPos = g2p[coord];
271
- if (proteinPos !== undefined) {
272
- const col = self.seqPosToGlobalCol(querySeqName, proteinPos);
273
- columns.add(col);
267
+ let proteinDriven = false;
268
+ return () => {
269
+ const { connectedViewId, transcriptToMsaMap, querySeqName } = self;
270
+ if (!connectedViewId || !transcriptToMsaMap) {
271
+ return;
272
+ }
273
+ const columns = new Set();
274
+ for (const view of getProteinViews(getSession(self).views)) {
275
+ for (const structure of view.structures) {
276
+ if (structure.connectedViewId !== connectedViewId) {
277
+ continue;
278
+ }
279
+ const highlights = structure.hoverGenomeHighlights;
280
+ if (!highlights || highlights.length === 0) {
281
+ continue;
282
+ }
283
+ const { g2p } = transcriptToMsaMap;
284
+ for (const highlight of highlights) {
285
+ for (let coord = highlight.start; coord < highlight.end; coord++) {
286
+ const proteinPos = g2p[coord];
287
+ if (proteinPos !== undefined) {
288
+ const col = self.seqPosToGlobalCol(querySeqName, proteinPos);
289
+ columns.add(col);
290
+ }
274
291
  }
275
292
  }
276
293
  }
277
294
  }
278
- }
279
- const visibleColumns = Array.from(columns)
280
- .map(col => self.globalColToVisibleCol(col))
281
- .filter((col) => col !== undefined);
282
- self.setHighlightedColumns(visibleColumns.length > 0 ? visibleColumns : undefined);
295
+ const visibleColumns = Array.from(columns)
296
+ .map(col => self.globalColToVisibleCol(col))
297
+ .filter((col) => col !== undefined);
298
+ if (visibleColumns.length > 0) {
299
+ self.setHighlightedColumns(visibleColumns);
300
+ proteinDriven = true;
301
+ }
302
+ else if (proteinDriven) {
303
+ // our protein-hover highlight ended — fall back to the declarative seed
304
+ // instead of wiping a column the URL/user asked to keep lit
305
+ self.setHighlightedColumns(self.highlightColumns?.length ? self.highlightColumns : undefined);
306
+ proteinDriven = false;
307
+ }
308
+ };
283
309
  }
284
310
  export function runCleanup() {
285
311
  cleanupOldData().catch((e) => {
@@ -363,13 +363,15 @@ export default function stateModelFactory() {
363
363
  highlightConnectedStructures,
364
364
  autoConnectStructures,
365
365
  autoLoadProteinDomains,
366
- observeProteinHighlights,
367
366
  ]) {
368
367
  addDisposer(self, autorun(() => {
369
368
  fn(self);
370
369
  }));
371
370
  }
371
+ // these two keep per-reaction state across runs (a "did I set it?" flag),
372
+ // so they're factories returning the autorun body rather than plain fns
372
373
  addDisposer(self, autorun(syncGenomeHoverToMsaColumn(self)));
374
+ addDisposer(self, autorun(observeProteinHighlights(self)));
373
375
  },
374
376
  }));
375
377
  }