jbrowse-plugin-msaview 2.6.5 → 2.6.7

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 (39) hide show
  1. package/dist/AddHighlightModel/MsaToGenomeHighlight.js +9 -4
  2. package/dist/BgzipFastaMsaAdapter/BgzipFastaMsaAdapter.js +1 -1
  3. package/dist/LaunchMsaView/components/NCBIBlastQuery/useCachedBlastResults.js +2 -2
  4. package/dist/LaunchMsaView/components/PreLoadedMSA/PreLoadedMSADataPanel.js +1 -1
  5. package/dist/LaunchMsaView/components/calculateProteinSequence.d.ts +1 -2
  6. package/dist/LaunchMsaView/components/calculateProteinSequence.js +4 -2
  7. package/dist/MsaViewPanel/model.d.ts +13 -0
  8. package/dist/MsaViewPanel/model.js +24 -9
  9. package/dist/MsaViewPanel/msaDataStore.js +7 -2
  10. package/dist/MsaViewPanel/util.d.ts +0 -11
  11. package/dist/MsaViewPanel/util.js +0 -7
  12. package/dist/jbrowse-plugin-msaview.umd.production.min.js +24 -24
  13. package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +3 -3
  14. package/dist/utils/blastCache.js +13 -5
  15. package/dist/utils/domainCache.js +7 -2
  16. package/dist/utils/fetch.d.ts +0 -2
  17. package/dist/utils/fetch.js +0 -21
  18. package/dist/utils/ncbiDomains.js +10 -3
  19. package/dist/utils/taxonomyNames.js +7 -2
  20. package/dist/version.d.ts +1 -1
  21. package/dist/version.js +1 -1
  22. package/package.json +1 -2
  23. package/src/AddHighlightModel/MsaToGenomeHighlight.tsx +13 -4
  24. package/src/BgzipFastaMsaAdapter/BgzipFastaMsaAdapter.ts +1 -1
  25. package/src/LaunchMsaView/components/NCBIBlastQuery/useCachedBlastResults.ts +2 -1
  26. package/src/LaunchMsaView/components/PreLoadedMSA/PreLoadedMSADataPanel.tsx +1 -1
  27. package/src/LaunchMsaView/components/calculateProteinSequence.ts +4 -3
  28. package/src/MsaViewPanel/model.ts +26 -9
  29. package/src/MsaViewPanel/msaDataStore.ts +8 -2
  30. package/src/MsaViewPanel/util.ts +0 -24
  31. package/src/utils/blastCache.ts +14 -3
  32. package/src/utils/domainCache.ts +8 -2
  33. package/src/utils/fetch.ts +0 -28
  34. package/src/utils/ncbiDomains.ts +10 -3
  35. package/src/utils/taxonomyNames.ts +8 -2
  36. package/src/version.ts +1 -1
  37. package/dist/LaunchMsaView/components/ManualMSALoader/fetchGeneList.d.ts +0 -1
  38. package/dist/LaunchMsaView/components/ManualMSALoader/fetchGeneList.js +0 -11
  39. package/src/LaunchMsaView/components/ManualMSALoader/fetchGeneList.ts +0 -13
@@ -8,10 +8,15 @@ const MsaToGenomeHighlight = observer(function MsaToGenomeHighlight2({ model, })
8
8
  const msaView = views
9
9
  .filter(isMsaView)
10
10
  .find(v => v.connectedViewId === model.id);
11
- const highlights = msaView?.connectedHighlights;
12
- // Suppress codon highlight while hovering the LGV — GenomeMouseoverHighlight
13
- // handles the single-bp display in that case
14
- return !hasHoverPosition(hovered) && highlights?.length ? (React.createElement(MsaToGenomeHighlightRenderer, { model: model, highlights: highlights })) : null;
11
+ // The persistent click selection always shows. The hover codon is suppressed
12
+ // while hovering the LGV — GenomeMouseoverHighlight handles the single-bp
13
+ // display in that case, so we don't stack a wider codon band on top of it.
14
+ const clickHighlight = msaView?.connectedClickHighlight;
15
+ const hoverHighlight = hasHoverPosition(hovered)
16
+ ? undefined
17
+ : msaView?.connectedHoverHighlight;
18
+ const highlights = [clickHighlight, hoverHighlight].filter((r) => r !== undefined);
19
+ return highlights.length ? (React.createElement(MsaToGenomeHighlightRenderer, { model: model, highlights: highlights })) : null;
15
20
  });
16
21
  // Inner component: handles the scroll-dependent rendering
17
22
  const MsaToGenomeHighlightRenderer = observer(function ({ model, highlights, }) {
@@ -44,7 +44,7 @@ export default class BgzipFastaMsaAdapter extends BaseAdapter {
44
44
  }
45
45
  async getMSA(id) {
46
46
  const adapter = await this.configure();
47
- const refNames = await adapter.getRefNames();
47
+ const refNames = await this.getMSARefs();
48
48
  const rows = refNames.filter(refName => this.refNameToMsaId(refName) === id);
49
49
  return firstValueFrom(adapter
50
50
  .getFeaturesInMultipleRegions(rows.map(refName => ({
@@ -2,7 +2,7 @@ import useSWR from 'swr';
2
2
  import { clearAllCachedResults, deleteCachedResult, getAllCachedResults, } from '../../../utils/blastCache';
3
3
  import { staticSwrConfig } from '../../../utils/swrConfig';
4
4
  export function useCachedBlastResults(geneIds) {
5
- const { data: results, error, mutate, } = useSWR(`cached-blast-${geneIds.join(',')}`, async () => {
5
+ const { data: results, error, isLoading, mutate, } = useSWR(`cached-blast-${geneIds.join(',')}`, async () => {
6
6
  const cached = await getAllCachedResults();
7
7
  return cached.filter(r => r.geneId && geneIds.includes(r.geneId));
8
8
  }, staticSwrConfig);
@@ -17,7 +17,7 @@ export function useCachedBlastResults(geneIds) {
17
17
  return {
18
18
  results: results ?? [],
19
19
  error,
20
- isLoading: !results && !error,
20
+ isLoading,
21
21
  handleDelete,
22
22
  handleClearAll,
23
23
  };
@@ -38,7 +38,7 @@ const PreLoadedMSA = observer(function ({ model, feature, handleClose, }) {
38
38
  });
39
39
  const { selectedId, selectedTranscript } = transcriptSelection;
40
40
  const { data: msaData, isLoading: msaDataLoading, error: msaDataFetchError, } = useSWR(selectedId && selectedDataset && msaList
41
- ? `${selectedDataset.datasetId}-${selectedId}-${msaList.length}-msa`
41
+ ? `${selectedDataset.datasetId}-${selectedId}-msa`
42
42
  : null, () => fetchMSA({
43
43
  msaId: selectedId,
44
44
  config: selectedDataset.adapter,
@@ -1,10 +1,9 @@
1
1
  import type { Feat } from './types';
2
2
  import type { Feature } from '@jbrowse/core/util';
3
3
  export declare function stitch(subfeats: Feat[], sequence: string): string;
4
- export declare function calculateProteinSequence({ cds, sequence, codonTable, }: {
4
+ export declare function calculateProteinSequence({ cds, sequence, }: {
5
5
  cds: Feat[];
6
6
  sequence: string;
7
- codonTable: Record<string, string>;
8
7
  }): string;
9
8
  export declare function revlist(list: Feat[], seqlen: number): {
10
9
  start: number;
@@ -1,8 +1,11 @@
1
1
  import { dedupe, defaultCodonTable, generateCodonTable, revcom, } from '@jbrowse/core/util';
2
+ // pure constant: the standard codon table never varies, so build it once rather
3
+ // than on every translation (which runs on every panel re-render)
4
+ const codonTable = generateCodonTable(defaultCodonTable);
2
5
  export function stitch(subfeats, sequence) {
3
6
  return subfeats.map(sub => sequence.slice(sub.start, sub.end)).join('');
4
7
  }
5
- export function calculateProteinSequence({ cds, sequence, codonTable, }) {
8
+ export function calculateProteinSequence({ cds, sequence, }) {
6
9
  const str = stitch(cds, sequence);
7
10
  let protein = '';
8
11
  for (let i = 0; i < str.length; i += 3) {
@@ -33,6 +36,5 @@ export function getProteinSequenceFromFeature({ feature, seq, }) {
33
36
  return calculateProteinSequence({
34
37
  cds: strand === -1 ? revlist(cds, seq.length) : cds,
35
38
  sequence: strand === -1 ? revcom(seq) : seq,
36
- codonTable: generateCodonTable(defaultCodonTable),
37
39
  });
38
40
  }
@@ -526,6 +526,19 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
526
526
  */
527
527
  readonly connectedView: MaybeLGV;
528
528
  } & {
529
+ /**
530
+ * #getter
531
+ * Genome region under the current MSA hover column. Suppressed on the LGV
532
+ * while it's being hovered (GenomeMouseoverHighlight shows the crisp 1bp
533
+ * marker there instead of this wider codon band).
534
+ */
535
+ readonly connectedHoverHighlight: IRegion | undefined;
536
+ /**
537
+ * #getter
538
+ * Genome region under the persistent MSA click selection. Shown
539
+ * regardless of LGV hover, so hovering the genome doesn't hide it.
540
+ */
541
+ readonly connectedClickHighlight: IRegion | undefined;
529
542
  /**
530
543
  * #getter
531
544
  */
@@ -111,19 +111,34 @@ export default function stateModelFactory() {
111
111
  },
112
112
  }))
113
113
  .views(self => ({
114
+ /**
115
+ * #getter
116
+ * Genome region under the current MSA hover column. Suppressed on the LGV
117
+ * while it's being hovered (GenomeMouseoverHighlight shows the crisp 1bp
118
+ * marker there instead of this wider codon band).
119
+ */
120
+ get connectedHoverHighlight() {
121
+ const { mouseCol } = self;
122
+ return mouseCol === undefined
123
+ ? undefined
124
+ : msaCoordToGenomeCoord({ model: self, coord: mouseCol });
125
+ },
126
+ /**
127
+ * #getter
128
+ * Genome region under the persistent MSA click selection. Shown
129
+ * regardless of LGV hover, so hovering the genome doesn't hide it.
130
+ */
131
+ get connectedClickHighlight() {
132
+ const { mouseClickCol } = self;
133
+ return mouseClickCol === undefined
134
+ ? undefined
135
+ : msaCoordToGenomeCoord({ model: self, coord: mouseClickCol });
136
+ },
114
137
  /**
115
138
  * #getter
116
139
  */
117
140
  get connectedHighlights() {
118
- const { mouseCol, mouseClickCol } = self;
119
- return [
120
- mouseCol === undefined
121
- ? undefined
122
- : msaCoordToGenomeCoord({ model: self, coord: mouseCol }),
123
- mouseClickCol === undefined
124
- ? undefined
125
- : msaCoordToGenomeCoord({ model: self, coord: mouseClickCol }),
126
- ].filter((r) => r !== undefined);
141
+ return [this.connectedHoverHighlight, this.connectedClickHighlight].filter((r) => r !== undefined);
127
142
  },
128
143
  }))
129
144
  .actions(self => ({
@@ -2,15 +2,20 @@ import { openDB } from 'idb';
2
2
  const DB_NAME = 'jbrowse-msaview-data';
3
3
  const DB_VERSION = 1;
4
4
  const STORE_NAME = 'msa-data';
5
- async function getDB() {
6
- return openDB(DB_NAME, DB_VERSION, {
5
+ let dbPromise;
6
+ function getDB() {
7
+ dbPromise ??= openDB(DB_NAME, DB_VERSION, {
7
8
  upgrade(db) {
8
9
  if (!db.objectStoreNames.contains(STORE_NAME)) {
9
10
  const store = db.createObjectStore(STORE_NAME, { keyPath: 'id' });
10
11
  store.createIndex('timestamp', 'timestamp', { unique: false });
11
12
  }
12
13
  },
14
+ }).catch((e) => {
15
+ dbPromise = undefined;
16
+ throw e;
13
17
  });
18
+ return dbPromise;
14
19
  }
15
20
  export function generateDataStoreId() {
16
21
  return `msa-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
@@ -4,16 +4,6 @@ export declare function hasHoverPosition(hovered: unknown): hovered is {
4
4
  refName: string;
5
5
  };
6
6
  };
7
- interface AssemblyManagerLike {
8
- get: (name: string) => {
9
- getCanonicalRefName: (r: string) => string | undefined;
10
- } | undefined;
11
- }
12
- export declare function getCanonicalRefName({ assemblyManager, assemblyNames, refName, }: {
13
- assemblyManager: AssemblyManagerLike;
14
- assemblyNames: string[] | undefined;
15
- refName: string;
16
- }): string;
17
7
  /**
18
8
  * Extracts UniProt ID from an AlphaFold URL
19
9
  * Examples:
@@ -21,4 +11,3 @@ export declare function getCanonicalRefName({ assemblyManager, assemblyNames, re
21
11
  * - https://alphafold.ebi.ac.uk/files/msa/AF-P12345-F1-msa_v6.a3m -> P12345
22
12
  */
23
13
  export declare function getUniprotIdFromAlphaFoldUrl(url: string): string | undefined;
24
- export {};
@@ -4,13 +4,6 @@ export function hasHoverPosition(hovered) {
4
4
  'hoverPosition' in hovered &&
5
5
  !!hovered.hoverPosition);
6
6
  }
7
- export function getCanonicalRefName({ assemblyManager, assemblyNames, refName, }) {
8
- const assemblyName = assemblyNames?.[0];
9
- if (assemblyName) {
10
- return (assemblyManager.get(assemblyName)?.getCanonicalRefName(refName) ?? refName);
11
- }
12
- return refName;
13
- }
14
7
  /**
15
8
  * Extracts UniProt ID from an AlphaFold URL
16
9
  * Examples: