jbrowse-plugin-msaview 2.6.7 → 2.6.8

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 (23) hide show
  1. package/dist/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.js +0 -3
  2. package/dist/LaunchMsaView/components/ManualMSALoader/launchView.d.ts +2 -3
  3. package/dist/LaunchMsaView/components/ManualMSALoader/launchView.js +3 -2
  4. package/dist/LaunchMsaView/components/NCBIBlastQuery/CachedBlastResults.js +10 -1
  5. package/dist/LaunchMsaView/components/NCBIBlastQuery/blastLaunchView.d.ts +2 -1
  6. package/dist/LaunchMsaView/components/NCBIBlastQuery/blastLaunchView.js +2 -1
  7. package/dist/LaunchMsaView/components/PreLoadedMSA/PreLoadedMSADataPanel.js +0 -1
  8. package/dist/LaunchMsaView/components/PreLoadedMSA/preCalculatedLaunchView.d.ts +2 -3
  9. package/dist/LaunchMsaView/components/PreLoadedMSA/preCalculatedLaunchView.js +3 -2
  10. package/dist/LaunchMsaView/components/useTranscriptSelection.js +14 -11
  11. package/dist/jbrowse-plugin-msaview.umd.production.min.js +25 -25
  12. package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +3 -3
  13. package/dist/version.d.ts +1 -1
  14. package/dist/version.js +1 -1
  15. package/package.json +1 -1
  16. package/src/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.tsx +0 -3
  17. package/src/LaunchMsaView/components/ManualMSALoader/launchView.ts +4 -8
  18. package/src/LaunchMsaView/components/NCBIBlastQuery/CachedBlastResults.tsx +17 -1
  19. package/src/LaunchMsaView/components/NCBIBlastQuery/blastLaunchView.ts +3 -0
  20. package/src/LaunchMsaView/components/PreLoadedMSA/PreLoadedMSADataPanel.tsx +0 -1
  21. package/src/LaunchMsaView/components/PreLoadedMSA/preCalculatedLaunchView.ts +4 -4
  22. package/src/LaunchMsaView/components/useTranscriptSelection.ts +16 -16
  23. package/src/version.ts +1 -1
@@ -1,6 +1,5 @@
1
1
  import React, { useState } from 'react';
2
2
  import { FileSelector } from '@jbrowse/core/ui';
3
- import { getSession } from '@jbrowse/core/util';
4
3
  import { Alert, FormControl, FormControlLabel, Radio, RadioGroup, } from '@mui/material';
5
4
  import { observer } from 'mobx-react';
6
5
  import { makeStyles } from 'tss-react/mui';
@@ -32,7 +31,6 @@ const useStyles = makeStyles()({
32
31
  },
33
32
  });
34
33
  const ManualMSALoader = observer(function PreLoadedMSA2({ model, feature, handleClose, }) {
35
- const session = getSession(model);
36
34
  const view = getLinearGenomeView(model);
37
35
  const { classes } = useStyles();
38
36
  const [launchViewError, setLaunchViewError] = useState();
@@ -74,7 +72,6 @@ const ManualMSALoader = observer(function PreLoadedMSA2({ model, feature, handle
74
72
  if (selectedTranscript) {
75
73
  setLaunchViewError(undefined);
76
74
  launchView({
77
- session,
78
75
  newViewTitle: getGeneDisplayName(selectedTranscript),
79
76
  view,
80
77
  feature: selectedTranscript,
@@ -1,7 +1,6 @@
1
- import type { AbstractSessionModel, Feature, FileLocation } from '@jbrowse/core/util';
1
+ import type { Feature, FileLocation } from '@jbrowse/core/util';
2
2
  import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
3
- export declare function launchView({ session, newViewTitle, view, feature, msaFilehandle, treeFilehandle, querySeqName, data, }: {
4
- session: AbstractSessionModel;
3
+ export declare function launchView({ newViewTitle, view, feature, msaFilehandle, treeFilehandle, querySeqName, data, }: {
5
4
  newViewTitle: string;
6
5
  view: LinearGenomeViewModel;
7
6
  feature: Feature;
@@ -1,5 +1,6 @@
1
- export function launchView({ session, newViewTitle, view, feature, msaFilehandle, treeFilehandle, querySeqName, data, }) {
2
- session.addView('MsaView', {
1
+ import { getSession } from '@jbrowse/core/util';
2
+ export function launchView({ newViewTitle, view, feature, msaFilehandle, treeFilehandle, querySeqName, data, }) {
3
+ getSession(view).addView('MsaView', {
3
4
  type: 'MsaView',
4
5
  displayName: newViewTitle,
5
6
  connectedViewId: view.id,
@@ -6,7 +6,7 @@ import { observer } from 'mobx-react';
6
6
  import { makeStyles } from 'tss-react/mui';
7
7
  import { blastLaunchViewFromCache } from './blastLaunchView';
8
8
  import { useCachedBlastResults } from './useCachedBlastResults';
9
- import { getGeneIdentifiers, getLinearGenomeView } from '../../util';
9
+ import { featureMatchesId, getGeneIdentifiers, getLinearGenomeView, getSortedTranscriptFeatures, } from '../../util';
10
10
  const useStyles = makeStyles()({
11
11
  header: {
12
12
  display: 'flex',
@@ -37,10 +37,19 @@ const CachedBlastResults = observer(function ({ model, handleClose, feature, })
37
37
  const geneIds = useMemo(() => getGeneIdentifiers(feature), [feature]);
38
38
  const { results, error, isLoading, handleDelete, handleClearAll } = useCachedBlastResults(geneIds);
39
39
  const handleUseCached = (cached) => {
40
+ // reconnect the cached MSA to the genome: the cached query row is named
41
+ // 'QUERY' (react-msaview's default querySeqName) and corresponds to the
42
+ // transcript stored as transcriptId. Resolving it here restores the
43
+ // MSA<->genome navigation and hover-sync a fresh BLAST gets.
44
+ const { transcriptId } = cached;
45
+ const transcript = transcriptId
46
+ ? getSortedTranscriptFeatures(feature).find(t => featureMatchesId(t, transcriptId))
47
+ : undefined;
40
48
  blastLaunchViewFromCache({
41
49
  view,
42
50
  cached,
43
51
  newViewTitle: `BLAST - ${getResultDisplayName(cached)}`,
52
+ connectedFeature: transcript?.toJSON(),
44
53
  });
45
54
  handleClose();
46
55
  };
@@ -8,8 +8,9 @@ export declare function blastLaunchView({ newViewTitle, view, feature, blastPara
8
8
  feature: Feature;
9
9
  blastParams: BlastParams;
10
10
  }): void;
11
- export declare function blastLaunchViewFromCache({ newViewTitle, view, cached, }: {
11
+ export declare function blastLaunchViewFromCache({ newViewTitle, view, cached, connectedFeature, }: {
12
12
  newViewTitle: string;
13
13
  view: LinearGenomeViewModel;
14
14
  cached: CachedBlastResult;
15
+ connectedFeature?: ReturnType<Feature['toJSON']>;
15
16
  }): void;
@@ -11,11 +11,12 @@ export function blastLaunchView({ newViewTitle, view, feature, blastParams, }) {
11
11
  blastParams,
12
12
  });
13
13
  }
14
- export function blastLaunchViewFromCache({ newViewTitle, view, cached, }) {
14
+ export function blastLaunchViewFromCache({ newViewTitle, view, cached, connectedFeature, }) {
15
15
  getSession(view).addView('MsaView', {
16
16
  type: 'MsaView',
17
17
  displayName: newViewTitle,
18
18
  connectedViewId: view.id,
19
+ connectedFeature,
19
20
  drawNodeBubbles: true,
20
21
  colWidth: 10,
21
22
  rowHeight: 12,
@@ -64,7 +64,6 @@ const PreLoadedMSA = observer(function ({ model, feature, handleClose, }) {
64
64
  if (selectedTranscript && msaData) {
65
65
  const querySeqName = `${selectedId}_${assemblyNames[0]}`;
66
66
  preCalculatedLaunchView({
67
- session,
68
67
  newViewTitle: getGeneDisplayName(selectedTranscript),
69
68
  view,
70
69
  querySeqName,
@@ -1,10 +1,9 @@
1
- import type { AbstractSessionModel, Feature } from '@jbrowse/core/util';
1
+ import type { Feature } from '@jbrowse/core/util';
2
2
  import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
3
- export declare function preCalculatedLaunchView({ session, newViewTitle, view, feature, data, querySeqName, }: {
3
+ export declare function preCalculatedLaunchView({ newViewTitle, view, feature, data, querySeqName, }: {
4
4
  data: {
5
5
  msa: string;
6
6
  };
7
- session: AbstractSessionModel;
8
7
  newViewTitle: string;
9
8
  view: LinearGenomeViewModel;
10
9
  feature: Feature;
@@ -1,5 +1,6 @@
1
- export function preCalculatedLaunchView({ session, newViewTitle, view, feature, data, querySeqName, }) {
2
- session.addView('MsaView', {
1
+ import { getSession } from '@jbrowse/core/util';
2
+ export function preCalculatedLaunchView({ newViewTitle, view, feature, data, querySeqName, }) {
3
+ getSession(view).addView('MsaView', {
3
4
  type: 'MsaView',
4
5
  displayName: newViewTitle,
5
6
  treeAreaWidth: 200,
@@ -1,22 +1,25 @@
1
1
  import { useMemo, useState } from 'react';
2
2
  import { featureMatchesId, getId, getSortedTranscriptFeatures } from '../util';
3
3
  import { useFeatureSequence } from './useFeatureSequence';
4
- function findValidSelection(currentId, options, validIds) {
5
- if (validIds && validIds.length > 0) {
6
- const currentFeature = options.find(opt => getId(opt) === currentId);
7
- const currentIsValid = currentFeature &&
8
- validIds.some(id => featureMatchesId(currentFeature, id));
9
- if (currentFeature && !currentIsValid) {
10
- const validOption = options.find(opt => validIds.some(id => featureMatchesId(opt, id)));
11
- return validOption ? getId(validOption) : undefined;
12
- }
4
+ // Keep the current selection if it's valid for the given validIds, otherwise
5
+ // fall back to the first valid option (or the current id if none qualify). With
6
+ // no validIds constraint the current selection always stands.
7
+ function pickSelectedId(currentId, options, validIds) {
8
+ if (!validIds?.length) {
9
+ return currentId;
13
10
  }
14
- return undefined;
11
+ const isValid = (opt) => validIds.some(id => featureMatchesId(opt, id));
12
+ const current = options.find(opt => getId(opt) === currentId);
13
+ if (current && isValid(current)) {
14
+ return currentId;
15
+ }
16
+ const firstValid = options.find(isValid);
17
+ return firstValid ? getId(firstValid) : currentId;
15
18
  }
16
19
  export function useTranscriptSelection({ feature, view, validIds, }) {
17
20
  const options = useMemo(() => getSortedTranscriptFeatures(feature), [feature]);
18
21
  const [selectedId, setSelectedId] = useState(() => getId(options[0]));
19
- const validatedSelectedId = findValidSelection(selectedId, options, validIds) ?? selectedId;
22
+ const validatedSelectedId = pickSelectedId(selectedId, options, validIds);
20
23
  const selectedTranscript = options.find(val => getId(val) === validatedSelectedId);
21
24
  const { proteinSequence, error } = useFeatureSequence({
22
25
  view,