jbrowse-plugin-msaview 2.9.0 → 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 (35) hide show
  1. package/dist/LaunchMsaView/components/OrthologQuery/OrthologPanel.js +14 -34
  2. package/dist/LaunchMsaView/components/OrthologQuery/QuerySpeciesSelect.d.ts +15 -0
  3. package/dist/LaunchMsaView/components/OrthologQuery/QuerySpeciesSelect.js +67 -0
  4. package/dist/LaunchMsaView/index.js +19 -1
  5. package/dist/MsaViewPanel/doLaunchOrthologs.js +43 -12
  6. package/dist/MsaViewPanel/doLaunchOrthologs.test.js +93 -19
  7. package/dist/MsaViewPanel/model.d.ts +19 -8
  8. package/dist/jbrowse-plugin-msaview.umd.production.min.js +30 -32
  9. package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +4 -4
  10. package/dist/utils/ebiJobDispatcher.js +26 -1
  11. package/dist/utils/ebiJobDispatcher.test.d.ts +1 -0
  12. package/dist/utils/ebiJobDispatcher.test.js +46 -0
  13. package/dist/utils/eutils.d.ts +9 -0
  14. package/dist/utils/eutils.js +18 -0
  15. package/dist/utils/ncbiOrthologs.d.ts +17 -75
  16. package/dist/utils/ncbiOrthologs.js +67 -63
  17. package/dist/utils/ncbiOrthologs.test.js +82 -2
  18. package/dist/utils/ncbiTaxonomy.d.ts +11 -0
  19. package/dist/utils/ncbiTaxonomy.js +33 -0
  20. package/dist/version.d.ts +1 -1
  21. package/dist/version.js +1 -1
  22. package/package.json +3 -3
  23. package/src/LaunchMsaView/components/OrthologQuery/OrthologPanel.tsx +33 -71
  24. package/src/LaunchMsaView/components/OrthologQuery/QuerySpeciesSelect.tsx +92 -0
  25. package/src/LaunchMsaView/index.ts +20 -2
  26. package/src/MsaViewPanel/doLaunchOrthologs.test.ts +109 -21
  27. package/src/MsaViewPanel/doLaunchOrthologs.ts +56 -13
  28. package/src/MsaViewPanel/model.ts +9 -2
  29. package/src/utils/ebiJobDispatcher.test.ts +54 -0
  30. package/src/utils/ebiJobDispatcher.ts +32 -3
  31. package/src/utils/eutils.ts +19 -0
  32. package/src/utils/ncbiOrthologs.test.ts +96 -2
  33. package/src/utils/ncbiOrthologs.ts +83 -71
  34. package/src/utils/ncbiTaxonomy.ts +37 -0
  35. package/src/version.ts +1 -1
@@ -1,10 +1,11 @@
1
1
  import React, { useMemo, useState } from 'react';
2
- import { Checkbox, FormControlLabel, MenuItem, Typography } from '@mui/material';
2
+ import { Typography } from '@mui/material';
3
3
  import { observer } from 'mobx-react';
4
4
  import { makeStyles } from 'tss-react/mui';
5
+ import QuerySpeciesSelect from './QuerySpeciesSelect';
5
6
  import { orthologLaunchView } from './orthologLaunchView';
6
7
  import TextField2 from '../../../components/TextField2';
7
- import { COMMON_SPECIES } from '../../../utils/ncbiOrthologs';
8
+ import { defaultMaxSpecies } from '../../../utils/ncbiOrthologs';
8
9
  import { getGeneDisplayName, getGeneIdentifiers, getLinearGenomeView, getTranscriptDisplayName, } from '../../util';
9
10
  import MsaAlgorithmSelect from '../BlastQuery/MsaAlgorithmSelect';
10
11
  import LaunchPanelContent from '../LaunchPanelContent';
@@ -15,23 +16,6 @@ const useStyles = makeStyles()({
15
16
  selectField: {
16
17
  width: 180,
17
18
  },
18
- // A GRID, not a wrapping flex row of fixed-width items. The old form was three
19
- // 160px columns inside a 560px box, which is five rows for thirteen species and
20
- // eight for twenty-three -- and the checkbox list is the tallest thing in the
21
- // dialog, so those rows are the dialog's height. Five auto-fitted columns is
22
- // five rows for twenty-three, i.e. more species in less space, and it reflows
23
- // rather than being pinned to a width the dialog may not have.
24
- speciesBox: {
25
- display: 'grid',
26
- gridTemplateColumns: 'repeat(auto-fit, minmax(130px, 1fr))',
27
- maxWidth: 700,
28
- marginTop: 4,
29
- },
30
- // The label carries the row height; the default control padding is what makes
31
- // 23 rows of it tall.
32
- species: {
33
- marginRight: 0,
34
- },
35
19
  });
36
20
  const OrthologPanel = observer(function ({ handleClose, feature, model, }) {
37
21
  const { classes } = useStyles();
@@ -39,28 +23,24 @@ const OrthologPanel = observer(function ({ handleClose, feature, model, }) {
39
23
  const [launchViewError, setLaunchViewError] = useState();
40
24
  const [taxId, setTaxId] = useState(9606);
41
25
  const [msaAlgorithm, setMsaAlgorithm] = useState('clustalo');
42
- const [excluded, setExcluded] = useState([]);
26
+ const [maxSpecies, setMaxSpecies] = useState(String(defaultMaxSpecies));
43
27
  const geneCandidates = useMemo(() => getGeneIdentifiers(feature), [feature]);
44
28
  const transcriptSelection = useTranscriptSelection({ feature, view });
45
29
  const { selectedTranscript, proteinSequence } = transcriptSelection;
46
30
  const e = transcriptSelection.error ?? launchViewError;
47
- const taxa = COMMON_SPECIES.map(s => s.taxId).filter(t => !excluded.includes(t));
31
+ const rowCount = Number(maxSpecies);
32
+ const rowCountValid = Number.isInteger(rowCount) && rowCount >= 2;
48
33
  return (React.createElement(React.Fragment, null,
49
34
  React.createElement(LaunchPanelContent, { error: e },
50
- React.createElement(Typography, { variant: "body2" }, "NCBI's precomputed orthologs, one gene per species, aligned at EBI in seconds rather than the 10+ minutes BLAST takes."),
35
+ React.createElement(Typography, { variant: "body2" }, "NCBI's precomputed orthologs, one gene per species, looked up rather than searched for. No BLAST job to queue."),
51
36
  React.createElement("div", null,
52
- React.createElement(TextField2, { variant: "outlined", label: "Query species", className: classes.selectField, select: true, value: taxId, onChange: event => {
53
- setTaxId(Number(event.target.value));
54
- }, helperText: "the species this gene is from" }, COMMON_SPECIES.map(s => (React.createElement(MenuItem, { value: s.taxId, key: s.taxId }, s.label)))),
55
- React.createElement(MsaAlgorithmSelect, { className: classes.selectField, value: msaAlgorithm, onChange: setMsaAlgorithm })),
56
- React.createElement(Typography, { variant: "subtitle2", style: { marginTop: 8 } }, "Species to include (those without an ortholog are skipped)"),
57
- React.createElement("div", { className: classes.speciesBox }, COMMON_SPECIES.map(s => (React.createElement(FormControlLabel, { className: classes.species, key: s.taxId, control: React.createElement(Checkbox, { checked: !excluded.includes(s.taxId), onChange: event => {
58
- setExcluded(event.target.checked
59
- ? excluded.filter(t => t !== s.taxId)
60
- : [...excluded, s.taxId]);
61
- } }), label: s.label })))),
37
+ React.createElement(QuerySpeciesSelect, { className: classes.selectField, value: taxId, onChange: setTaxId }),
38
+ React.createElement(MsaAlgorithmSelect, { className: classes.selectField, value: msaAlgorithm, onChange: setMsaAlgorithm }),
39
+ React.createElement(TextField2, { variant: "outlined", label: "Rows to align", className: classes.selectField, type: "number", value: maxSpecies, onChange: event => {
40
+ setMaxSpecies(event.target.value);
41
+ }, error: !rowCountValid, helperText: "the closest N species NCBI has" })),
62
42
  React.createElement(TranscriptSelector, { feature: feature, ...transcriptSelection })),
63
- React.createElement(SubmitCancelActions, { submitDisabled: !proteinSequence || taxa.length < 2, onSubmit: () => {
43
+ React.createElement(SubmitCancelActions, { submitDisabled: !proteinSequence || !rowCountValid, onSubmit: () => {
64
44
  try {
65
45
  if (selectedTranscript) {
66
46
  setLaunchViewError(undefined);
@@ -70,7 +50,7 @@ const OrthologPanel = observer(function ({ handleClose, feature, model, }) {
70
50
  newViewTitle: `Orthologs - ${getGeneDisplayName(feature)} - ${getTranscriptDisplayName(selectedTranscript)}`,
71
51
  orthologParams: {
72
52
  taxId,
73
- taxa,
53
+ maxSpecies: rowCount,
74
54
  geneCandidates,
75
55
  msaAlgorithm,
76
56
  selectedTranscript,
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ /**
3
+ * The species the query gene came from, as free text resolved against NCBI's
4
+ * taxonomy rather than picked from a fixed list.
5
+ *
6
+ * The resolved taxon is shown back as helper text, which is the whole point of
7
+ * resolving on a debounce instead of on submit: a typo resolves to some other
8
+ * organism rather than to nothing, and the only place that surfaces is the gene
9
+ * lookup, as "could not resolve NLRP1 in taxon 9986".
10
+ */
11
+ export default function QuerySpeciesSelect({ value, onChange, className, }: {
12
+ value: number;
13
+ onChange: (taxId: number) => void;
14
+ className?: string;
15
+ }): React.JSX.Element;
@@ -0,0 +1,67 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import TextField2 from '../../../components/TextField2';
3
+ import { resolveTaxId } from '../../../utils/ncbiTaxonomy';
4
+ import { fetchTaxonomyInfo } from '../../../utils/taxonomyNames';
5
+ /**
6
+ * The species the query gene came from, as free text resolved against NCBI's
7
+ * taxonomy rather than picked from a fixed list.
8
+ *
9
+ * The resolved taxon is shown back as helper text, which is the whole point of
10
+ * resolving on a debounce instead of on submit: a typo resolves to some other
11
+ * organism rather than to nothing, and the only place that surfaces is the gene
12
+ * lookup, as "could not resolve NLRP1 in taxon 9986".
13
+ */
14
+ export default function QuerySpeciesSelect({ value, onChange, className, }) {
15
+ const [text, setText] = useState('human');
16
+ const [resolved, setResolved] = useState();
17
+ const [error, setError] = useState();
18
+ useEffect(() => {
19
+ // read through a call rather than as a property: the cleanup writes it from
20
+ // another turn of the loop, and a bare `run.live` narrows to true after the
21
+ // first check, which reads to the compiler as a redundant second one
22
+ const run = { live: true };
23
+ const cancelled = () => !run.live;
24
+ async function lookup() {
25
+ try {
26
+ setError(undefined);
27
+ const taxId = await resolveTaxId(text);
28
+ if (cancelled()) {
29
+ return;
30
+ }
31
+ if (!taxId) {
32
+ setResolved(undefined);
33
+ setError(new Error(`No NCBI taxon matches "${text}"`));
34
+ return;
35
+ }
36
+ const info = (await fetchTaxonomyInfo([taxId])).get(taxId);
37
+ if (cancelled()) {
38
+ return;
39
+ }
40
+ setResolved([info?.sciname, info?.commonName && `(${info.commonName})`]
41
+ .filter(Boolean)
42
+ .join(' ') || `taxon ${taxId}`);
43
+ onChange(taxId);
44
+ }
45
+ catch (e) {
46
+ if (!cancelled()) {
47
+ setError(e);
48
+ }
49
+ }
50
+ }
51
+ const timer = setTimeout(() => {
52
+ void lookup();
53
+ }, 400);
54
+ return () => {
55
+ run.live = false;
56
+ clearTimeout(timer);
57
+ };
58
+ // onChange is a setState updater from the parent and stable in practice;
59
+ // including it would re-run the lookup on every parent render
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
+ }, [text]);
62
+ return (React.createElement(TextField2, { variant: "outlined", label: "Query species", className: className, value: text, onChange: event => {
63
+ setText(event.target.value);
64
+ }, error: !!error, helperText: error
65
+ ? `${error}`
66
+ : (resolved ?? `the species this gene is from (taxon ${value})`) }));
67
+ }
@@ -4,6 +4,24 @@ import LaunchMsaViewDialog from './components/LaunchMsaViewDialog';
4
4
  function isDisplay(elt) {
5
5
  return elt.name === 'LinearBasicDisplay';
6
6
  }
7
+ // Read off the clicked item rather than off the display.
8
+ //
9
+ // LinearBasicDisplay used to publish an `isGeneLike` getter and this gated on
10
+ // it. jbrowse-components 684142b3 (2026-08-16) inlined that getter into its own
11
+ // `contextMenuItems`, and every host built after it returns `undefined` here --
12
+ // so the gate was never satisfied, `onClick` stayed undefined, and the item
13
+ // silently left the right-click menu on every gene track. Nothing failed loudly:
14
+ // the display still had contextMenuInfo and fetchFullFeature, and the menu still
15
+ // opened with its own items in it.
16
+ //
17
+ // A predicate over the type we were already given cannot go the same way, and it
18
+ // costs one comparison. Deliberately the same loose case-insensitive test the
19
+ // host applies (`isGeneLikeType` in collapseIntronsMenu.ts): real GFFs carry
20
+ // 'mRNA', 'lnc_RNA', 'protein_coding_gene', 'transcript'.
21
+ function isGeneLikeType(type) {
22
+ const t = (type ?? '').toLowerCase();
23
+ return t.includes('gene') || t.includes('rna') || t.includes('transcript');
24
+ }
7
25
  const GENE_LIKE_TYPES = new Set(['gene', 'mRNA', 'transcript']);
8
26
  function extendStateModel(stateModel) {
9
27
  return stateModel.views((self) => {
@@ -21,7 +39,7 @@ function extendStateModel(stateModel) {
21
39
  const info = self.contextMenuInfo;
22
40
  const fetchFullFeature = self.fetchFullFeature;
23
41
  const legacyFeature = self.contextMenuFeature;
24
- const onClick = info && fetchFullFeature && self.isGeneLike
42
+ const onClick = info && fetchFullFeature && isGeneLikeType(info.item.type)
25
43
  ? () => {
26
44
  fetchFullFeature(info.item.featureId, info.displayedRegionIndex)
27
45
  .then(feature => {
@@ -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
@@ -1,12 +1,13 @@
1
1
  import { beforeEach, describe, expect, test, vi } from 'vitest';
2
2
  import { doLaunchOrthologs } from './doLaunchOrthologs';
3
3
  import { launchMSA } from '../utils/msa';
4
- import { COMMON_SPECIES, fetchOrthologRows, fetchProteinForGene, resolveGeneId, } from '../utils/ncbiOrthologs';
4
+ import { defaultMaxSpecies, fetchOrthologRows, fetchProteinForGene, resolveGeneId, } from '../utils/ncbiOrthologs';
5
+ import { fetchTaxonomyInfo } from '../utils/taxonomyNames';
5
6
  // Every network call is mocked and nothing else is. What is under test is the
6
- // argument shaping either side of those calls -- which taxa get asked for, what
7
- // becomes the QUERY row, and whether the row earns the Accession that drives the
8
- // CDD overlay -- so the real COMMON_SPECIES list and the real
9
- // cleanProteinSequence stay in the picture.
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.
10
11
  vi.mock('../utils/ncbiOrthologs', async (importOriginal) => ({
11
12
  ...(await importOriginal()),
12
13
  resolveGeneId: vi.fn(),
@@ -14,17 +15,21 @@ vi.mock('../utils/ncbiOrthologs', async (importOriginal) => ({
14
15
  fetchOrthologRows: vi.fn(),
15
16
  }));
16
17
  vi.mock('../utils/msa', () => ({ launchMSA: vi.fn() }));
18
+ vi.mock('../utils/taxonomyNames', () => ({ fetchTaxonomyInfo: vi.fn() }));
17
19
  const mockResolveGeneId = vi.mocked(resolveGeneId);
18
20
  const mockFetchProtein = vi.mocked(fetchProteinForGene);
19
21
  const mockFetchRows = vi.mocked(fetchOrthologRows);
20
22
  const mockLaunchMSA = vi.mocked(launchMSA);
23
+ const mockFetchTaxonomy = vi.mocked(fetchTaxonomyInfo);
21
24
  const HUMAN = 9606;
22
25
  const GENE_ID = '22861';
23
26
  const REPRESENTATIVE = { accession: 'NP_127497.1', sequence: 'MAGGAWGRLACY' };
27
+ const setQuerySeqName = vi.fn();
24
28
  function makeModel(orthologParams) {
25
29
  return {
26
30
  orthologParams,
27
31
  setProgress: () => { },
32
+ setQuerySeqName,
28
33
  };
29
34
  }
30
35
  function params(extra = {}) {
@@ -35,18 +40,29 @@ function params(extra = {}) {
35
40
  ...extra,
36
41
  };
37
42
  }
38
- // What fetchOrthologRows was asked for, which is the only place the taxa
39
- // default is observable.
40
- function taxaAskedFor() {
41
- return [...mockFetchRows.mock.calls[0][0].taxa].sort((a, b) => a - b);
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
+ };
42
52
  }
43
53
  // The QUERY row as it went to the aligner, read back out of the FASTA rather
44
54
  // than out of an intermediate, since the FASTA is what the alignment is of.
45
55
  function queryRowSent() {
46
56
  return mockLaunchMSA.mock.calls[0][0].sequence.split('\n')[1];
47
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.
48
61
  function queryMetadata(result) {
49
- return JSON.parse(result.treeMetadata).QUERY;
62
+ return JSON.parse(result.treeMetadata)[queryRowName()];
63
+ }
64
+ function queryRowName() {
65
+ return mockLaunchMSA.mock.calls[0][0].sequence.split('\n')[0].slice(1);
50
66
  }
51
67
  beforeEach(() => {
52
68
  vi.clearAllMocks();
@@ -54,26 +70,84 @@ beforeEach(() => {
54
70
  mockFetchProtein.mockResolvedValue(REPRESENTATIVE);
55
71
  mockFetchRows.mockResolvedValue([]);
56
72
  mockLaunchMSA.mockResolvedValue({ msa: '', tree: '' });
73
+ mockFetchTaxonomy.mockResolvedValue(new Map([[HUMAN, { sciname: 'Homo sapiens', commonName: 'human' }]]));
57
74
  });
58
- describe('taxa', () => {
59
- test('omitted asks for every species the dialog offers, less the query', async () => {
75
+ describe('which species become rows', () => {
76
+ test('omitted taxa asks for no restriction at all, which is every ortholog NCBI has', async () => {
60
77
  await doLaunchOrthologs({ self: makeModel(params()) });
61
- expect(taxaAskedFor()).toEqual(COMMON_SPECIES.map(s => s.taxId)
62
- .filter(t => t !== HUMAN)
63
- .sort((a, b) => a - b));
78
+ expect(rowRequest().taxa).toBeUndefined();
64
79
  });
65
- test('given is taken as written, less the query', async () => {
80
+ test('given taxa is taken as written', async () => {
66
81
  await doLaunchOrthologs({
67
82
  self: makeModel(params({ taxa: [HUMAN, 10090, 9615] })),
68
83
  });
69
- expect(taxaAskedFor()).toEqual([9615, 10090]);
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);
70
101
  });
71
102
  test('an empty list is a request for no rows, not a request for all of them', async () => {
72
103
  await doLaunchOrthologs({ self: makeModel(params({ taxa: [] })) });
73
- expect(taxaAskedFor()).toEqual([]);
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');
74
148
  });
75
149
  });
76
- describe('the QUERY row', () => {
150
+ describe('the query row sequence', () => {
77
151
  test('omitted proteinSequence falls back to the representative protein', async () => {
78
152
  await doLaunchOrthologs({ self: makeModel(params()) });
79
153
  expect(queryRowSent()).toBe(REPRESENTATIVE.sequence);
@@ -22,10 +22,17 @@ export interface OrthologParams {
22
22
  taxId: number;
23
23
  /**
24
24
  * taxon ids to include as rows (the query taxon is represented by QUERY).
25
- * Omitted means every species the launch dialog offers, which is what a
26
- * 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.
27
27
  */
28
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;
29
36
  /** candidate gene identifiers off the feature, tried in order */
30
37
  geneCandidates: string[];
31
38
  msaAlgorithm: MsaAlgorithm;
@@ -48,7 +55,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
48
55
  id: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<string>, [undefined]>;
49
56
  displayName: import("@jbrowse/mobx-state-tree").IMaybe<import("@jbrowse/mobx-state-tree").ISimpleType<string>>;
50
57
  minimized: import("@jbrowse/mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
51
- }, "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"> & {
52
59
  drawLabels: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
53
60
  labelsAlignRight: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
54
61
  treeAreaWidth: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<number>, [undefined]>;
@@ -61,10 +68,11 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
61
68
  bgColor: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
62
69
  colorSchemeName: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<string>, [undefined]>;
63
70
  showColumnStats: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
64
- msaFormat: import("@jbrowse/mobx-state-tree").IMaybe<import("@jbrowse/mobx-state-tree").ISimpleType<import("react-msaview").MSAFormat>>;
65
- }, "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"> & {
66
73
  id: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<string>, [undefined]>;
67
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]>;
68
76
  hideGaps: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
69
77
  allowedGappyness: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<number>, [undefined]>;
70
78
  subFeatureRows: import("@jbrowse/mobx-state-tree").IOptionalIType<import("@jbrowse/mobx-state-tree").ISimpleType<boolean>, [undefined]>;
@@ -515,7 +523,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
515
523
  setColorSchemeName(name: string): void;
516
524
  setBgColor(arg: boolean): void;
517
525
  setShowColumnStats(arg: boolean): void;
518
- setMSAFormat(arg?: import("react-msaview").MSAFormat): void;
526
+ setMSAFormat(arg?: import("msa-parsers").MSAFormat): void;
519
527
  } & {
520
528
  headerHeight: number;
521
529
  status: {
@@ -556,6 +564,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
556
564
  setMousePos(col?: number, row?: number): void;
557
565
  setHighlightedColumns(columns?: number[]): void;
558
566
  setShowDomains(arg: boolean): void;
567
+ setShowDomainLegend(arg: boolean): void;
559
568
  setSubFeatureRows(arg: boolean): void;
560
569
  setMouseClickPos(col?: number, row?: number): void;
561
570
  setRowHeight(n: number): void;
@@ -602,7 +611,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
602
611
  readonly noDomains: boolean;
603
612
  menuItems(): never[];
604
613
  readonly treeMetadata: Record<string, Record<string, string> | undefined>;
605
- readonly MSA: import("react-msaview").MSAParserType | null;
614
+ readonly MSA: import("msa-parsers").MSAParserType | null;
606
615
  readonly numColumns: number;
607
616
  readonly tree: import("react-msaview").NodeWithIds;
608
617
  readonly rowNames: string[];
@@ -964,7 +973,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
964
973
  bgColor: boolean;
965
974
  colorSchemeName: string;
966
975
  showColumnStats: boolean;
967
- msaFormat: import("react-msaview").MSAFormat | undefined;
976
+ msaFormat: import("msa-parsers").MSAFormat | undefined;
968
977
  drawLabels: boolean;
969
978
  labelsAlignRight: boolean;
970
979
  treeAreaWidth: number;
@@ -975,6 +984,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
975
984
  autoTreeAreaWidth: boolean;
976
985
  id: string;
977
986
  showDomains: boolean;
987
+ showDomainLegend: boolean;
978
988
  hideGaps: boolean;
979
989
  allowedGappyness: number;
980
990
  subFeatureRows: boolean;
@@ -1077,6 +1087,7 @@ export default function stateModelFactory(): import("@jbrowse/mobx-state-tree").
1077
1087
  tree?: string | undefined;
1078
1088
  msa?: string | undefined;
1079
1089
  treeMetadata?: string | undefined;
1090
+ gff?: string | undefined;
1080
1091
  };
1081
1092
  } & import("@jbrowse/mobx-state-tree")._NotCustomized>;
1082
1093
  export type JBrowsePluginMsaViewStateModel = ReturnType<typeof stateModelFactory>;