jbrowse-plugin-msaview 2.8.2 → 2.10.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 (108) hide show
  1. package/dist/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastRIDPanel.d.ts → BlastQuery/BlastAutomaticPanel.d.ts} +2 -3
  2. package/dist/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastAutomaticPanel.js → BlastQuery/BlastAutomaticPanel.js} +6 -25
  3. package/dist/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastManualPanel.d.ts → BlastQuery/BlastManualPanel.d.ts} +2 -3
  4. package/dist/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastManualPanel.js → BlastQuery/BlastManualPanel.js} +7 -4
  5. package/dist/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastMethodSelector.d.ts → BlastQuery/BlastMethodSelector.d.ts} +2 -2
  6. package/dist/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastMethodSelector.js → BlastQuery/BlastMethodSelector.js} +1 -2
  7. package/dist/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastPanel.d.ts → BlastQuery/BlastPanel.d.ts} +3 -12
  8. package/dist/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastPanel.js → BlastQuery/BlastPanel.js} +14 -16
  9. package/dist/LaunchMsaView/components/BlastQuery/BlastSettingsDialog.d.ts +8 -0
  10. package/dist/LaunchMsaView/components/{NCBIBlastQuery/NCBISettingsDialog.js → BlastQuery/BlastSettingsDialog.js} +13 -9
  11. package/dist/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/CachedBlastResults.js +1 -1
  12. package/dist/LaunchMsaView/components/BlastQuery/consts.d.ts +12 -0
  13. package/dist/LaunchMsaView/components/BlastQuery/consts.js +17 -0
  14. package/dist/LaunchMsaView/components/LaunchMsaViewDialog.js +3 -3
  15. package/dist/LaunchMsaView/components/OrthologQuery/OrthologPanel.js +15 -35
  16. package/dist/LaunchMsaView/components/OrthologQuery/QuerySpeciesSelect.d.ts +15 -0
  17. package/dist/LaunchMsaView/components/OrthologQuery/QuerySpeciesSelect.js +67 -0
  18. package/dist/LaunchMsaView/index.js +19 -1
  19. package/dist/MsaViewPanel/components/JobLink.d.ts +5 -0
  20. package/dist/MsaViewPanel/components/JobLink.js +13 -0
  21. package/dist/MsaViewPanel/components/LoadingBLAST.d.ts +1 -2
  22. package/dist/MsaViewPanel/components/LoadingBLAST.js +8 -15
  23. package/dist/MsaViewPanel/components/MsaViewPanel.js +1 -1
  24. package/dist/MsaViewPanel/doLaunchBlast.js +11 -19
  25. package/dist/MsaViewPanel/doLaunchOrthologs.js +43 -12
  26. package/dist/MsaViewPanel/doLaunchOrthologs.test.d.ts +1 -0
  27. package/dist/MsaViewPanel/doLaunchOrthologs.test.js +201 -0
  28. package/dist/MsaViewPanel/model.d.ts +20 -12
  29. package/dist/jbrowse-plugin-msaview.umd.production.min.js +31 -33
  30. package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +4 -4
  31. package/dist/utils/blastCache.d.ts +8 -4
  32. package/dist/utils/blastCache.js +4 -5
  33. package/dist/utils/ebiBlast.d.ts +52 -0
  34. package/dist/utils/ebiBlast.js +63 -0
  35. package/dist/utils/ebiJobDispatcher.d.ts +33 -0
  36. package/dist/utils/ebiJobDispatcher.js +80 -0
  37. package/dist/utils/ebiJobDispatcher.test.d.ts +1 -0
  38. package/dist/utils/ebiJobDispatcher.test.js +46 -0
  39. package/dist/utils/eutils.d.ts +9 -0
  40. package/dist/utils/eutils.js +18 -0
  41. package/dist/utils/fetch.js +24 -1
  42. package/dist/utils/msa.d.ts +1 -1
  43. package/dist/utils/msa.js +25 -32
  44. package/dist/utils/ncbiOrthologs.d.ts +17 -75
  45. package/dist/utils/ncbiOrthologs.js +67 -63
  46. package/dist/utils/ncbiOrthologs.test.js +82 -2
  47. package/dist/utils/ncbiTaxonomy.d.ts +11 -0
  48. package/dist/utils/ncbiTaxonomy.js +33 -0
  49. package/dist/utils/types.d.ts +9 -14
  50. package/dist/utils/useLocalStorage.d.ts +1 -0
  51. package/dist/utils/useLocalStorage.js +1 -1
  52. package/dist/version.d.ts +1 -1
  53. package/dist/version.js +1 -1
  54. package/package.json +3 -3
  55. package/src/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastAutomaticPanel.tsx → BlastQuery/BlastAutomaticPanel.tsx} +13 -59
  56. package/src/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastManualPanel.tsx → BlastQuery/BlastManualPanel.tsx} +7 -6
  57. package/src/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastMethodSelector.tsx → BlastQuery/BlastMethodSelector.tsx} +2 -7
  58. package/src/LaunchMsaView/components/{NCBIBlastQuery/NCBIBlastPanel.tsx → BlastQuery/BlastPanel.tsx} +21 -25
  59. package/src/LaunchMsaView/components/{NCBIBlastQuery/NCBISettingsDialog.tsx → BlastQuery/BlastSettingsDialog.tsx} +26 -13
  60. package/src/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/CachedBlastResults.tsx +1 -1
  61. package/src/LaunchMsaView/components/BlastQuery/consts.ts +22 -0
  62. package/src/LaunchMsaView/components/LaunchMsaViewDialog.tsx +5 -7
  63. package/src/LaunchMsaView/components/OrthologQuery/OrthologPanel.tsx +35 -73
  64. package/src/LaunchMsaView/components/OrthologQuery/QuerySpeciesSelect.tsx +92 -0
  65. package/src/LaunchMsaView/index.ts +20 -2
  66. package/src/MsaViewPanel/components/JobLink.tsx +17 -0
  67. package/src/MsaViewPanel/components/LoadingBLAST.tsx +10 -41
  68. package/src/MsaViewPanel/components/MsaViewPanel.tsx +1 -1
  69. package/src/MsaViewPanel/doLaunchBlast.ts +12 -28
  70. package/src/MsaViewPanel/doLaunchOrthologs.test.ts +247 -0
  71. package/src/MsaViewPanel/doLaunchOrthologs.ts +56 -13
  72. package/src/MsaViewPanel/model.ts +10 -7
  73. package/src/utils/blastCache.ts +8 -9
  74. package/src/utils/ebiBlast.ts +114 -0
  75. package/src/utils/ebiJobDispatcher.test.ts +54 -0
  76. package/src/utils/ebiJobDispatcher.ts +120 -0
  77. package/src/utils/eutils.ts +19 -0
  78. package/src/utils/fetch.ts +26 -1
  79. package/src/utils/msa.ts +26 -47
  80. package/src/utils/ncbiOrthologs.test.ts +96 -2
  81. package/src/utils/ncbiOrthologs.ts +83 -71
  82. package/src/utils/ncbiTaxonomy.ts +37 -0
  83. package/src/utils/types.ts +8 -13
  84. package/src/utils/useLocalStorage.ts +1 -1
  85. package/src/version.ts +1 -1
  86. package/dist/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastAutomaticPanel.d.ts +0 -10
  87. package/dist/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastRIDPanel.js +0 -74
  88. package/dist/LaunchMsaView/components/NCBIBlastQuery/NCBISettingsDialog.d.ts +0 -5
  89. package/dist/LaunchMsaView/components/NCBIBlastQuery/consts.d.ts +0 -7
  90. package/dist/LaunchMsaView/components/NCBIBlastQuery/consts.js +0 -4
  91. package/dist/MsaViewPanel/components/RIDLink.d.ts +0 -6
  92. package/dist/MsaViewPanel/components/RIDLink.js +0 -12
  93. package/dist/utils/ncbiBlast.d.ts +0 -30
  94. package/dist/utils/ncbiBlast.js +0 -84
  95. package/src/LaunchMsaView/components/NCBIBlastQuery/NCBIBlastRIDPanel.tsx +0 -137
  96. package/src/LaunchMsaView/components/NCBIBlastQuery/consts.ts +0 -10
  97. package/src/MsaViewPanel/components/RIDLink.tsx +0 -19
  98. package/src/utils/ncbiBlast.ts +0 -143
  99. /package/dist/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/CachedBlastResults.d.ts +0 -0
  100. /package/dist/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/MsaAlgorithmSelect.d.ts +0 -0
  101. /package/dist/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/MsaAlgorithmSelect.js +0 -0
  102. /package/dist/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/blastLaunchView.d.ts +0 -0
  103. /package/dist/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/blastLaunchView.js +0 -0
  104. /package/dist/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/useCachedBlastResults.d.ts +0 -0
  105. /package/dist/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/useCachedBlastResults.js +0 -0
  106. /package/src/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/MsaAlgorithmSelect.tsx +0 -0
  107. /package/src/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/blastLaunchView.ts +0 -0
  108. /package/src/LaunchMsaView/components/{NCBIBlastQuery → BlastQuery}/useCachedBlastResults.ts +0 -0
@@ -3,7 +3,7 @@ import { ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui';
3
3
  import { Typography } from '@mui/material';
4
4
  import { observer } from 'mobx-react';
5
5
  import { makeStyles } from 'tss-react/mui';
6
- import RIDLink from './RIDLink';
6
+ import JobLink from './JobLink';
7
7
  const useStyles = makeStyles()(theme => ({
8
8
  margin: {
9
9
  padding: 20,
@@ -12,22 +12,15 @@ const useStyles = makeStyles()(theme => ({
12
12
  background: theme.palette.background.paper,
13
13
  },
14
14
  }));
15
- function RIDError({ baseUrl, rid, error, }) {
16
- return (React.createElement("div", null,
17
- rid ? React.createElement(RIDLink, { rid: rid, baseUrl: baseUrl }) : null,
18
- React.createElement(ErrorMessage, { error: error })));
19
- }
20
- function RIDProgress({ baseUrl, rid, progress, }) {
21
- const { classes } = useStyles();
22
- return (React.createElement("div", { className: classes.loading },
23
- rid ? React.createElement(RIDLink, { baseUrl: baseUrl, rid: rid }) : null,
24
- React.createElement(Typography, null, progress)));
25
- }
26
- const LoadingBLAST = observer(function LoadingBLAST2({ model, baseUrl, }) {
15
+ const LoadingBLAST = observer(function LoadingBLAST2({ model, }) {
27
16
  const { progress, rid, error } = model;
28
17
  const { classes } = useStyles();
29
18
  return (React.createElement("div", { className: classes.margin },
30
- React.createElement(LoadingEllipses, { message: "Running NCBI BLAST", variant: "h5" }),
31
- error ? (React.createElement(RIDError, { baseUrl: baseUrl, rid: rid, error: error })) : rid ? (React.createElement(RIDProgress, { baseUrl: baseUrl, rid: rid, progress: progress })) : (React.createElement(Typography, null, progress || 'Initializing BLAST query'))));
19
+ React.createElement(LoadingEllipses, { message: "Running EBI BLAST", variant: "h5" }),
20
+ error ? (React.createElement("div", null,
21
+ rid ? React.createElement(JobLink, { jobId: rid }) : null,
22
+ React.createElement(ErrorMessage, { error: error }))) : rid ? (React.createElement("div", { className: classes.loading },
23
+ React.createElement(JobLink, { jobId: rid }),
24
+ React.createElement(Typography, null, progress))) : (React.createElement(Typography, null, progress || 'Initializing BLAST query'))));
32
25
  });
33
26
  export default LoadingBLAST;
@@ -14,7 +14,7 @@ const MsaViewPanel = observer(function MsaViewPanel2({ model, }) {
14
14
  const { classes } = useStyles();
15
15
  const { blastParams, loadingStoredData } = model;
16
16
  return (React.createElement(ErrorBoundary, null,
17
- React.createElement("div", null, blastParams ? (React.createElement(LoadingBLAST, { model: model, baseUrl: blastParams.baseUrl })) : loadingStoredData ? (React.createElement("div", { className: classes.loadingContainer },
17
+ React.createElement("div", null, blastParams ? (React.createElement(LoadingBLAST, { model: model })) : loadingStoredData ? (React.createElement("div", { className: classes.loadingContainer },
18
18
  React.createElement(LoadingEllipses, { message: "Loading MSA data", variant: "h6" }))) : (React.createElement(MSAView, { model: model })))));
19
19
  });
20
20
  export default MsaViewPanel;
@@ -1,32 +1,25 @@
1
1
  import { makeId, strip } from '../LaunchMsaView/components/util';
2
2
  import { cleanProteinSequence } from '../LaunchMsaView/util';
3
3
  import { saveBlastResult } from '../utils/blastCache';
4
+ import { queryEbiBlast } from '../utils/ebiBlast';
4
5
  import { launchMSA } from '../utils/msa';
5
- import { queryBlast, queryBlastFromRid } from '../utils/ncbiBlast';
6
6
  import { fetchTaxonomyInfo } from '../utils/taxonomyNames';
7
7
  export async function doLaunchBlast({ self, }) {
8
- const { baseUrl, blastDatabase, blastProgram, msaAlgorithm, proteinSequence, selectedTranscript, rid: existingRid, } = self.blastParams;
8
+ const { blastDatabase, msaAlgorithm, proteinSequence, selectedTranscript } = self.blastParams;
9
9
  const cleanedSeq = cleanProteinSequence(proteinSequence);
10
10
  const onProgress = (arg) => {
11
11
  self.setProgress(arg);
12
12
  };
13
- if (existingRid) {
14
- // publish it before the first poll so the view can link out to NCBI while
13
+ const { hits, rid } = await queryEbiBlast({
14
+ query: cleanedSeq,
15
+ blastDatabase,
16
+ onProgress,
17
+ // publish the job id before the first poll so the view can link out while
15
18
  // the job is still running
16
- self.setRid(existingRid);
17
- }
18
- const { hits, rid } = existingRid
19
- ? await queryBlastFromRid({ rid: existingRid, baseUrl, onProgress })
20
- : await queryBlast({
21
- query: cleanedSeq,
22
- blastDatabase,
23
- blastProgram,
24
- baseUrl,
25
- onProgress,
26
- onRid: r => {
27
- self.setRid(r);
28
- },
29
- });
19
+ onRid: r => {
20
+ self.setRid(r);
21
+ },
22
+ });
30
23
  self.setProgress('Fetching species taxonomy info...');
31
24
  const taxids = hits
32
25
  .map(h => h.description[0]?.taxid)
@@ -53,7 +46,6 @@ export async function doLaunchBlast({ self, }) {
53
46
  await saveBlastResult({
54
47
  proteinSequence: cleanedSeq,
55
48
  blastDatabase,
56
- blastProgram,
57
49
  msaAlgorithm,
58
50
  msa: result.msa,
59
51
  tree: result.tree,
@@ -1,6 +1,7 @@
1
1
  import { cleanProteinSequence } from '../LaunchMsaView/util';
2
2
  import { launchMSA } from '../utils/msa';
3
- import { COMMON_SPECIES, fetchOrthologRows, fetchProteinForGene, resolveGeneId, } from '../utils/ncbiOrthologs';
3
+ import { dedupeLabels, fetchOrthologRows, fetchProteinForGene, resolveGeneId, } from '../utils/ncbiOrthologs';
4
+ import { fetchTaxonomyInfo } from '../utils/taxonomyNames';
4
5
  /**
5
6
  * The no-search-job alternative to doLaunchBlast.
6
7
  *
@@ -17,7 +18,7 @@ import { COMMON_SPECIES, fetchOrthologRows, fetchProteinForGene, resolveGeneId,
17
18
  * excluded from the ortholog set rather than appearing twice.
18
19
  */
19
20
  export async function doLaunchOrthologs({ self, }) {
20
- const { taxId, taxa, geneCandidates, msaAlgorithm, proteinSequence } = self.orthologParams;
21
+ const { taxId, taxa, maxSpecies, geneCandidates, msaAlgorithm, proteinSequence, } = self.orthologParams;
21
22
  const onProgress = (arg) => {
22
23
  self.setProgress(arg);
23
24
  };
@@ -39,20 +40,33 @@ export async function doLaunchOrthologs({ self, }) {
39
40
  if (!cleanedSeq) {
40
41
  throw new Error(`No query protein: none was supplied and NCBI returned no representative protein for gene ${resolved.geneId}.`);
41
42
  }
42
- // Every species the panel offers, when a launch names none. A spec that wants
43
- // a narrower comparison says so; one that just wants "this gene across
44
- // species" should not have to enumerate the list the dialog would have
45
- // checked for it.
46
- const wantedTaxa = taxa ?? COMMON_SPECIES.map(s => s.taxId);
47
- // the query species is represented by the query row above
48
- const wanted = new Set(wantedTaxa.filter(t => t !== taxId));
43
+ // Every species NCBI has an ortholog for, when a launch names none, capped at
44
+ // maxSpecies. A launch that wants specific species lists them; one that just
45
+ // wants "this gene across species" gets NCBI's own order, which leads with the
46
+ // reference organisms.
49
47
  const rows = await fetchOrthologRows({
50
48
  geneId: resolved.geneId,
51
- taxa: wanted,
49
+ taxa: taxa ? new Set(taxa) : undefined,
50
+ // the query species is represented by the query row above
51
+ exclude: taxId,
52
+ limit: maxSpecies,
52
53
  onProgress,
53
54
  });
55
+ // The query row is named for its species like every other row, with a suffix
56
+ // marking it as the one the genome view is linked to. A bare `QUERY` among
57
+ // ninety-nine named species reads as a row whose species failed to resolve,
58
+ // and there is nothing else in the picture saying which row the hover
59
+ // highlight travels through -- react-msaview has no notion of a query row, it
60
+ // only looks one up by name.
61
+ //
62
+ // Deduped against the ortholog labels rather than assumed unique: the query
63
+ // taxon is excluded from that set, but a subspecies can sanitize to the same
64
+ // token, and a collision would silently point the coordinate mapping at
65
+ // another animal's row.
66
+ const queryLabel = await queryRowLabel(taxId, rows);
67
+ self.setQuerySeqName(queryLabel);
54
68
  const treeMetadata = {
55
- QUERY: buildQueryMetadata(self, resolved.geneId, cleanedSeq, representative),
69
+ [queryLabel]: buildQueryMetadata(self, resolved.geneId, cleanedSeq, representative),
56
70
  };
57
71
  for (const row of rows) {
58
72
  treeMetadata[row.label] = buildRowMetadata(row);
@@ -60,7 +74,7 @@ export async function doLaunchOrthologs({ self, }) {
60
74
  const result = await launchMSA({
61
75
  algorithm: msaAlgorithm,
62
76
  sequence: [
63
- `>QUERY\n${cleanedSeq}`,
77
+ `>${queryLabel}\n${cleanedSeq}`,
64
78
  ...rows.map(r => `>${r.label}\n${r.sequence}`),
65
79
  ].join('\n'),
66
80
  onProgress,
@@ -70,6 +84,23 @@ export async function doLaunchOrthologs({ self, }) {
70
84
  treeMetadata: JSON.stringify(treeMetadata),
71
85
  };
72
86
  }
87
+ /**
88
+ * `<species>_query`, unique against the ortholog labels. Falls back to the bare
89
+ * marker when NCBI cannot name the taxon, which is a naming failure and must not
90
+ * take down the launch.
91
+ */
92
+ async function queryRowLabel(taxId, rows) {
93
+ let name;
94
+ try {
95
+ const info = (await fetchTaxonomyInfo([taxId])).get(taxId);
96
+ name = info?.commonName ?? info?.sciname;
97
+ }
98
+ catch (e) {
99
+ console.warn('[msaview-orthologs] taxonomy name lookup failed:', e);
100
+ }
101
+ return dedupeLabels([...rows.map(r => r.label), `${name ?? 'query'}_query`])
102
+ .at(-1);
103
+ }
73
104
  /**
74
105
  * A failed lookup only costs the query row its domain overlay and, for a launch
75
106
  * that supplied no sequence of its own, the alignment — so it is reported by
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,201 @@
1
+ import { beforeEach, describe, expect, test, vi } from 'vitest';
2
+ import { doLaunchOrthologs } from './doLaunchOrthologs';
3
+ import { launchMSA } from '../utils/msa';
4
+ import { defaultMaxSpecies, fetchOrthologRows, fetchProteinForGene, resolveGeneId, } from '../utils/ncbiOrthologs';
5
+ import { fetchTaxonomyInfo } from '../utils/taxonomyNames';
6
+ // Every network call is mocked and nothing else is. What is under test is the
7
+ // argument shaping either side of those calls -- which species get asked for,
8
+ // what becomes the QUERY row, and whether the row earns the Accession that
9
+ // drives the CDD overlay -- so the real cleanProteinSequence stays in the
10
+ // picture.
11
+ vi.mock('../utils/ncbiOrthologs', async (importOriginal) => ({
12
+ ...(await importOriginal()),
13
+ resolveGeneId: vi.fn(),
14
+ fetchProteinForGene: vi.fn(),
15
+ fetchOrthologRows: vi.fn(),
16
+ }));
17
+ vi.mock('../utils/msa', () => ({ launchMSA: vi.fn() }));
18
+ vi.mock('../utils/taxonomyNames', () => ({ fetchTaxonomyInfo: vi.fn() }));
19
+ const mockResolveGeneId = vi.mocked(resolveGeneId);
20
+ const mockFetchProtein = vi.mocked(fetchProteinForGene);
21
+ const mockFetchRows = vi.mocked(fetchOrthologRows);
22
+ const mockLaunchMSA = vi.mocked(launchMSA);
23
+ const mockFetchTaxonomy = vi.mocked(fetchTaxonomyInfo);
24
+ const HUMAN = 9606;
25
+ const GENE_ID = '22861';
26
+ const REPRESENTATIVE = { accession: 'NP_127497.1', sequence: 'MAGGAWGRLACY' };
27
+ const setQuerySeqName = vi.fn();
28
+ function makeModel(orthologParams) {
29
+ return {
30
+ orthologParams,
31
+ setProgress: () => { },
32
+ setQuerySeqName,
33
+ };
34
+ }
35
+ function params(extra = {}) {
36
+ return {
37
+ taxId: HUMAN,
38
+ geneCandidates: ['NLRP1'],
39
+ msaAlgorithm: 'clustalo',
40
+ ...extra,
41
+ };
42
+ }
43
+ // What fetchOrthologRows was asked for, which is the only place the species
44
+ // defaults are observable.
45
+ function rowRequest() {
46
+ const { taxa, exclude, limit } = mockFetchRows.mock.calls[0][0];
47
+ return {
48
+ taxa: taxa && [...taxa].sort((a, b) => a - b),
49
+ exclude,
50
+ limit,
51
+ };
52
+ }
53
+ // The QUERY row as it went to the aligner, read back out of the FASTA rather
54
+ // than out of an intermediate, since the FASTA is what the alignment is of.
55
+ function queryRowSent() {
56
+ return mockLaunchMSA.mock.calls[0][0].sequence.split('\n')[1];
57
+ }
58
+ // Keyed by the row's own label, which has to be the name the FASTA header
59
+ // carries -- the tree comes back from the aligner naming its leaves that way,
60
+ // and the metadata is paired to a leaf by name.
61
+ function queryMetadata(result) {
62
+ return JSON.parse(result.treeMetadata)[queryRowName()];
63
+ }
64
+ function queryRowName() {
65
+ return mockLaunchMSA.mock.calls[0][0].sequence.split('\n')[0].slice(1);
66
+ }
67
+ beforeEach(() => {
68
+ vi.clearAllMocks();
69
+ mockResolveGeneId.mockResolvedValue({ geneId: GENE_ID, matched: 'NLRP1' });
70
+ mockFetchProtein.mockResolvedValue(REPRESENTATIVE);
71
+ mockFetchRows.mockResolvedValue([]);
72
+ mockLaunchMSA.mockResolvedValue({ msa: '', tree: '' });
73
+ mockFetchTaxonomy.mockResolvedValue(new Map([[HUMAN, { sciname: 'Homo sapiens', commonName: 'human' }]]));
74
+ });
75
+ describe('which species become rows', () => {
76
+ test('omitted taxa asks for no restriction at all, which is every ortholog NCBI has', async () => {
77
+ await doLaunchOrthologs({ self: makeModel(params()) });
78
+ expect(rowRequest().taxa).toBeUndefined();
79
+ });
80
+ test('given taxa is taken as written', async () => {
81
+ await doLaunchOrthologs({
82
+ self: makeModel(params({ taxa: [HUMAN, 10090, 9615] })),
83
+ });
84
+ expect(rowRequest().taxa).toEqual([9606, 9615, 10090]);
85
+ });
86
+ // Not folded into the taxa list before the call, so that "restrict to these"
87
+ // and "the query row already covers this one" stay separable -- an unrestricted
88
+ // launch still has to drop the query species.
89
+ test('the query species is excluded whether or not taxa was given', async () => {
90
+ await doLaunchOrthologs({ self: makeModel(params()) });
91
+ expect(rowRequest().exclude).toBe(HUMAN);
92
+ vi.clearAllMocks();
93
+ mockResolveGeneId.mockResolvedValue({ geneId: GENE_ID, matched: 'NLRP1' });
94
+ mockFetchProtein.mockResolvedValue(REPRESENTATIVE);
95
+ mockFetchRows.mockResolvedValue([]);
96
+ mockLaunchMSA.mockResolvedValue({ msa: '', tree: '' });
97
+ await doLaunchOrthologs({
98
+ self: makeModel(params({ taxa: [HUMAN, 10090] })),
99
+ });
100
+ expect(rowRequest().exclude).toBe(HUMAN);
101
+ });
102
+ test('an empty list is a request for no rows, not a request for all of them', async () => {
103
+ await doLaunchOrthologs({ self: makeModel(params({ taxa: [] })) });
104
+ expect(rowRequest().taxa).toEqual([]);
105
+ });
106
+ });
107
+ // The cap is the only thing standing between a launch and a 7 minute EBI job:
108
+ // NCBI publishes 865 orthologs for CFTR and the aligner runs at roughly half a
109
+ // second a row.
110
+ describe('the row cap', () => {
111
+ test('is passed through when given', async () => {
112
+ await doLaunchOrthologs({ self: makeModel(params({ maxSpecies: 12 })) });
113
+ expect(rowRequest().limit).toBe(12);
114
+ });
115
+ test('omitted leaves the default to fetchOrthologGenes rather than sending Infinity', async () => {
116
+ await doLaunchOrthologs({ self: makeModel(params()) });
117
+ expect(rowRequest().limit).toBeUndefined();
118
+ expect(defaultMaxSpecies).toBeGreaterThan(2);
119
+ });
120
+ });
121
+ // The row's name is load bearing three times over: it is the FASTA header, it
122
+ // is therefore the tree leaf the aligner returns, and it is what
123
+ // `seqPosToVisibleCol` looks up to turn a genome hover into a column. So the
124
+ // model's querySeqName and the header have to be the same string.
125
+ describe('the query row name', () => {
126
+ test('is the species, marked, rather than a bare QUERY among named rows', async () => {
127
+ await doLaunchOrthologs({ self: makeModel(params()) });
128
+ expect(queryRowName()).toBe('human_query');
129
+ expect(setQuerySeqName).toHaveBeenCalledWith('human_query');
130
+ });
131
+ test('cannot collide with an ortholog row that sanitizes to the same token', async () => {
132
+ mockFetchRows.mockResolvedValue([
133
+ { label: 'human_query', sequence: 'MM' },
134
+ ]);
135
+ await doLaunchOrthologs({ self: makeModel(params()) });
136
+ expect(queryRowName()).toBe('human_query_2');
137
+ expect(setQuerySeqName).toHaveBeenCalledWith('human_query_2');
138
+ });
139
+ test('falls back rather than throwing when NCBI cannot name the taxon', async () => {
140
+ vi.spyOn(console, 'warn').mockImplementation(() => { });
141
+ mockFetchTaxonomy.mockRejectedValue(new Error('429'));
142
+ await doLaunchOrthologs({ self: makeModel(params()) });
143
+ expect(queryRowName()).toBe('query_query');
144
+ });
145
+ test('the metadata that drives the domain overlay is keyed to that same name', async () => {
146
+ const result = await doLaunchOrthologs({ self: makeModel(params()) });
147
+ expect(Object.keys(JSON.parse(result.treeMetadata))).toContain('human_query');
148
+ });
149
+ });
150
+ describe('the query row sequence', () => {
151
+ test('omitted proteinSequence falls back to the representative protein', async () => {
152
+ await doLaunchOrthologs({ self: makeModel(params()) });
153
+ expect(queryRowSent()).toBe(REPRESENTATIVE.sequence);
154
+ });
155
+ test('a supplied sequence is used, and is cleaned first', async () => {
156
+ await doLaunchOrthologs({
157
+ self: makeModel(params({ proteinSequence: 'MAGG*AWGR&' })),
158
+ });
159
+ expect(queryRowSent()).toBe('MAGGAWGR');
160
+ });
161
+ test('throws when neither a sequence nor a representative is available', async () => {
162
+ mockFetchProtein.mockResolvedValue(undefined);
163
+ await expect(doLaunchOrthologs({ self: makeModel(params()) })).rejects.toThrow(/No query protein/);
164
+ expect(mockLaunchMSA).not.toHaveBeenCalled();
165
+ });
166
+ test('a failed representative lookup does not take down a launch that brought its own sequence', async () => {
167
+ vi.spyOn(console, 'warn').mockImplementation(() => { });
168
+ mockFetchProtein.mockRejectedValue(new Error('429'));
169
+ await doLaunchOrthologs({
170
+ self: makeModel(params({ proteinSequence: REPRESENTATIVE.sequence })),
171
+ });
172
+ expect(queryRowSent()).toBe(REPRESENTATIVE.sequence);
173
+ });
174
+ });
175
+ // The Accession is what afterCreateAutoruns.autoLoadProteinDomains keys the CDD
176
+ // overlay off, and attaching it to a row that is NOT the protein it names draws
177
+ // every domain box at an offset. So the byte-identity guard is the assertion
178
+ // here, in both directions.
179
+ describe('the Accession that drives the domain overlay', () => {
180
+ test('is attached when the query row IS the representative protein', async () => {
181
+ const result = await doLaunchOrthologs({ self: makeModel(params()) });
182
+ expect(queryMetadata(result)).toMatchObject({
183
+ 'Gene ID': GENE_ID,
184
+ Accession: REPRESENTATIVE.accession,
185
+ });
186
+ });
187
+ test('is withheld from a non-representative isoform', async () => {
188
+ const result = await doLaunchOrthologs({
189
+ self: makeModel(params({ proteinSequence: 'MDIFFERENTISOFORM' })),
190
+ });
191
+ expect(queryMetadata(result).Accession).toBeUndefined();
192
+ });
193
+ test('is withheld when the representative lookup failed', async () => {
194
+ vi.spyOn(console, 'warn').mockImplementation(() => { });
195
+ mockFetchProtein.mockRejectedValue(new Error('429'));
196
+ const result = await doLaunchOrthologs({
197
+ self: makeModel(params({ proteinSequence: REPRESENTATIVE.sequence })),
198
+ });
199
+ expect(queryMetadata(result).Accession).toBeUndefined();
200
+ });
201
+ });
@@ -1,6 +1,6 @@
1
1
  export type { MSAFormat } from 'msa-parsers';
2
2
  import type { MafRegion, MsaViewInitState } from './types';
3
- import type { BlastDatabase, BlastProgram, MsaAlgorithm } from '../LaunchMsaView/components/NCBIBlastQuery/consts';
3
+ import type { BlastDatabase, MsaAlgorithm } from '../LaunchMsaView/components/BlastQuery/consts';
4
4
  import type { Feature } from '@jbrowse/core/util';
5
5
  import type { Instance } from '@jbrowse/mobx-state-tree';
6
6
  import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
@@ -12,23 +12,27 @@ export interface IRegion {
12
12
  end: number;
13
13
  }
14
14
  export interface BlastParams {
15
- baseUrl: string;
16
15
  blastDatabase: BlastDatabase;
17
16
  msaAlgorithm: MsaAlgorithm;
18
- blastProgram: BlastProgram;
19
17
  selectedTranscript?: Feature;
20
18
  proteinSequence: string;
21
- rid?: string;
22
19
  }
23
20
  export interface OrthologParams {
24
21
  /** NCBI taxon id of the assembly the query gene came from */
25
22
  taxId: number;
26
23
  /**
27
24
  * taxon ids to include as rows (the query taxon is represented by QUERY).
28
- * Omitted means every species the launch dialog offers, which is what a
29
- * launch that just wants "this gene across species" wants.
25
+ * Omitted means every species NCBI has an ortholog for, in its report order,
26
+ * which is what a launch that just wants "this gene across species" wants.
30
27
  */
31
28
  taxa?: number[];
29
+ /**
30
+ * how many ortholog rows to align, `defaultMaxSpecies` when omitted. The
31
+ * aligner is what this bounds: EBI runs at roughly half a second per row for
32
+ * a ~1400aa protein, so a gene with 865 orthologs is a 7 minute job at no
33
+ * cap.
34
+ */
35
+ maxSpecies?: number;
32
36
  /** candidate gene identifiers off the feature, tried in order */
33
37
  geneCandidates: string[];
34
38
  msaAlgorithm: MsaAlgorithm;
@@ -51,7 +55,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
51
55
  id: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<string>, [undefined]>;
52
56
  displayName: import("@jbrowse/mobx-state-tree").IMaybe<import("@jbrowse/mobx-state-tree").ISimpleType<string>>;
53
57
  minimized: import("@jbrowse/mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
54
- }, "height" | "id" | "type" | "autoTreeAreaWidth" | "drawLabels" | "drawNodeBubbles" | "drawTree" | "labelsAlignRight" | "showBranchLen" | "treeAreaWidth" | "treeWidth" | "bgColor" | "colorSchemeName" | "msaFormat" | "showColumnStats" | "allowedGappyness" | "colWidth" | "collapsed" | "currentAlignment" | "data" | "drawMsaLetters" | "featureFilters" | "gffFilehandle" | "hideGaps" | "highlightColumns" | "msaFilehandle" | "relativeTo" | "rowHeight" | "scrollX" | "scrollY" | "scrollZoom" | "showDomains" | "showOnly" | "subFeatureRows" | "treeFilehandle" | "treeMetadataFilehandle" | "turnedOffTracks"> & Omit<Omit<Omit<{}, "autoTreeAreaWidth" | "drawLabels" | "drawNodeBubbles" | "drawTree" | "labelsAlignRight" | "showBranchLen" | "treeAreaWidth" | "treeWidth"> & {
58
+ }, "height" | "id" | "type" | "autoTreeAreaWidth" | "drawLabels" | "drawNodeBubbles" | "drawTree" | "labelsAlignRight" | "showBranchLen" | "treeAreaWidth" | "treeWidth" | "bgColor" | "colorSchemeName" | "msaFormat" | "showColumnStats" | "allowedGappyness" | "colWidth" | "collapsed" | "currentAlignment" | "data" | "drawMsaLetters" | "featureFilters" | "gffFilehandle" | "hideGaps" | "highlightColumns" | "msaFilehandle" | "relativeTo" | "rowHeight" | "scrollX" | "scrollY" | "scrollZoom" | "showDomainLegend" | "showDomains" | "showOnly" | "subFeatureRows" | "treeFilehandle" | "treeMetadataFilehandle" | "turnedOffTracks"> & Omit<Omit<Omit<{}, "autoTreeAreaWidth" | "drawLabels" | "drawNodeBubbles" | "drawTree" | "labelsAlignRight" | "showBranchLen" | "treeAreaWidth" | "treeWidth"> & {
55
59
  drawLabels: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
56
60
  labelsAlignRight: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
57
61
  treeAreaWidth: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<number>, [undefined]>;
@@ -64,10 +68,11 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
64
68
  bgColor: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
65
69
  colorSchemeName: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<string>, [undefined]>;
66
70
  showColumnStats: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
67
- msaFormat: import("@jbrowse/mobx-state-tree").IMaybe<import("@jbrowse/mobx-state-tree").ISimpleType<import("react-msaview").MSAFormat>>;
68
- }, "height" | "id" | "type" | "allowedGappyness" | "colWidth" | "collapsed" | "currentAlignment" | "data" | "drawMsaLetters" | "featureFilters" | "gffFilehandle" | "hideGaps" | "highlightColumns" | "msaFilehandle" | "relativeTo" | "rowHeight" | "scrollX" | "scrollY" | "scrollZoom" | "showDomains" | "showOnly" | "subFeatureRows" | "treeFilehandle" | "treeMetadataFilehandle" | "turnedOffTracks"> & {
71
+ msaFormat: import("@jbrowse/mobx-state-tree").IMaybe<import("@jbrowse/mobx-state-tree").ISimpleType<import("msa-parsers").MSAFormat>>;
72
+ }, "height" | "id" | "type" | "allowedGappyness" | "colWidth" | "collapsed" | "currentAlignment" | "data" | "drawMsaLetters" | "featureFilters" | "gffFilehandle" | "hideGaps" | "highlightColumns" | "msaFilehandle" | "relativeTo" | "rowHeight" | "scrollX" | "scrollY" | "scrollZoom" | "showDomainLegend" | "showDomains" | "showOnly" | "subFeatureRows" | "treeFilehandle" | "treeMetadataFilehandle" | "turnedOffTracks"> & {
69
73
  id: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<string>, [undefined]>;
70
74
  showDomains: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
75
+ showDomainLegend: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
71
76
  hideGaps: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
72
77
  allowedGappyness: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<number>, [undefined]>;
73
78
  subFeatureRows: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
@@ -518,7 +523,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
518
523
  setColorSchemeName(name: string): void;
519
524
  setBgColor(arg: boolean): void;
520
525
  setShowColumnStats(arg: boolean): void;
521
- setMSAFormat(arg?: import("react-msaview").MSAFormat): void;
526
+ setMSAFormat(arg?: import("msa-parsers").MSAFormat): void;
522
527
  } & {
523
528
  headerHeight: number;
524
529
  status: {
@@ -559,6 +564,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
559
564
  setMousePos(col?: number, row?: number): void;
560
565
  setHighlightedColumns(columns?: number[]): void;
561
566
  setShowDomains(arg: boolean): void;
567
+ setShowDomainLegend(arg: boolean): void;
562
568
  setSubFeatureRows(arg: boolean): void;
563
569
  setMouseClickPos(col?: number, row?: number): void;
564
570
  setRowHeight(n: number): void;
@@ -605,7 +611,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
605
611
  readonly noDomains: boolean;
606
612
  menuItems(): never[];
607
613
  readonly treeMetadata: Record<string, Record<string, string> | undefined>;
608
- readonly MSA: import("react-msaview").MSAParserType | null;
614
+ readonly MSA: import("msa-parsers").MSAParserType | null;
609
615
  readonly numColumns: number;
610
616
  readonly tree: import("react-msaview").NodeWithIds;
611
617
  readonly rowNames: string[];
@@ -967,7 +973,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
967
973
  bgColor: boolean;
968
974
  colorSchemeName: string;
969
975
  showColumnStats: boolean;
970
- msaFormat: import("react-msaview").MSAFormat | undefined;
976
+ msaFormat: import("msa-parsers").MSAFormat | undefined;
971
977
  drawLabels: boolean;
972
978
  labelsAlignRight: boolean;
973
979
  treeAreaWidth: number;
@@ -978,6 +984,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
978
984
  autoTreeAreaWidth: boolean;
979
985
  id: string;
980
986
  showDomains: boolean;
987
+ showDomainLegend: boolean;
981
988
  hideGaps: boolean;
982
989
  allowedGappyness: number;
983
990
  subFeatureRows: boolean;
@@ -1080,6 +1087,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
1080
1087
  tree?: string | undefined;
1081
1088
  msa?: string | undefined;
1082
1089
  treeMetadata?: string | undefined;
1090
+ gff?: string | undefined;
1083
1091
  };
1084
1092
  } & import("@jbrowse/mobx-state-tree")._NotCustomized>;
1085
1093
  export type JBrowsePluginMsaViewStateModel = ReturnType<typeof stateModelFactory>;