jbrowse-plugin-msaview 3.3.0 → 3.4.1
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.
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.js +1 -1
- package/dist/AddHighlightModel/MsaToGenomeHighlight.js +1 -1
- package/dist/AddHighlightModel/index.js +1 -1
- package/dist/LaunchMsaView/components/BlastQuery/BlastAutomaticPanel.js +60 -18
- package/dist/LaunchMsaView/components/BlastQuery/BlastManualPanel.js +1 -1
- package/dist/LaunchMsaView/components/BlastQuery/BlastPanel.js +2 -2
- package/dist/LaunchMsaView/components/BlastQuery/CachedBlastResults.d.ts +12 -0
- package/dist/LaunchMsaView/components/BlastQuery/CachedBlastResults.js +21 -2
- package/dist/LaunchMsaView/components/BlastQuery/CachedBlastResults.test.d.ts +1 -0
- package/dist/LaunchMsaView/components/BlastQuery/CachedBlastResults.test.js +29 -0
- package/dist/LaunchMsaView/components/BlastQuery/MsaAlgorithmSelect.js +1 -1
- package/dist/LaunchMsaView/components/BlastQuery/consts.d.ts +28 -0
- package/dist/LaunchMsaView/components/BlastQuery/consts.js +21 -0
- package/dist/LaunchMsaView/components/BlastQuery/searchChoiceStorage.d.ts +7 -0
- package/dist/LaunchMsaView/components/BlastQuery/searchChoiceStorage.js +42 -0
- package/dist/LaunchMsaView/components/BlastQuery/searchChoiceStorage.test.d.ts +1 -0
- package/dist/LaunchMsaView/components/BlastQuery/searchChoiceStorage.test.js +32 -0
- package/dist/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.js +1 -1
- package/dist/LaunchMsaView/components/OrthologQuery/OrthologPanel.js +5 -4
- package/dist/LaunchMsaView/components/SubmitCancelActions.test.js +1 -1
- package/dist/LaunchMsaView/components/useFeatureSequence.js +1 -1
- package/dist/LaunchMsaView/detectQueryRow.d.ts +15 -2
- package/dist/LaunchMsaView/detectQueryRow.js +20 -21
- package/dist/LaunchMsaView/detectQueryRow.test.js +15 -15
- package/dist/LaunchMsaView/useQueryRowName.js +5 -8
- package/dist/LaunchMsaViewExtensionPoint/index.js +11 -6
- package/dist/LaunchMsaViewExtensionPoint/index.test.d.ts +1 -0
- package/dist/LaunchMsaViewExtensionPoint/index.test.js +43 -0
- package/dist/MsaViewPanel/afterCreateAutoruns.d.ts +15 -0
- package/dist/MsaViewPanel/afterCreateAutoruns.js +95 -72
- package/dist/MsaViewPanel/components/ErrorBoundary.d.ts +2 -2
- package/dist/MsaViewPanel/components/JobLink.js +7 -1
- package/dist/MsaViewPanel/components/LaunchProgress.d.ts +17 -0
- package/dist/MsaViewPanel/components/LaunchProgress.js +50 -0
- package/dist/MsaViewPanel/components/MsaViewPanel.js +6 -3
- package/dist/MsaViewPanel/components/MsaViewPanel.test.d.ts +1 -0
- package/dist/MsaViewPanel/components/MsaViewPanel.test.js +87 -0
- package/dist/MsaViewPanel/doLaunchBlast.d.ts +4 -2
- package/dist/MsaViewPanel/doLaunchBlast.js +86 -56
- package/dist/MsaViewPanel/doLaunchOrthologs.d.ts +3 -1
- package/dist/MsaViewPanel/doLaunchOrthologs.js +6 -5
- package/dist/MsaViewPanel/doLaunchOrthologs.test.js +39 -25
- package/dist/MsaViewPanel/genomeToMSA.js +4 -2
- package/dist/MsaViewPanel/genomeToMSA.test.js +34 -0
- package/dist/MsaViewPanel/model.d.ts +190 -19
- package/dist/MsaViewPanel/model.js +51 -1
- package/dist/MsaViewPanel/msaDataStore.d.ts +5 -3
- package/dist/MsaViewPanel/msaDataStore.js +16 -7
- package/dist/MsaViewPanel/msaDataStore.test.d.ts +1 -0
- package/dist/MsaViewPanel/msaDataStore.test.js +44 -0
- package/dist/MsaViewPanel/observeProteinHighlights.test.js +11 -0
- package/dist/MsaViewPanel/runLaunch.d.ts +38 -0
- package/dist/MsaViewPanel/runLaunch.js +65 -0
- package/dist/MsaViewPanel/runLaunch.test.d.ts +1 -0
- package/dist/MsaViewPanel/runLaunch.test.js +129 -0
- package/dist/MsaViewPanel/storedData.test.d.ts +1 -0
- package/dist/MsaViewPanel/storedData.test.js +160 -0
- package/dist/MsaViewPanel/syncGenomeHoverToMsaColumn.test.js +1 -0
- package/dist/MsaViewPanel/util.d.ts +18 -0
- package/dist/MsaViewPanel/util.js +17 -0
- package/dist/jbrowse-plugin-msaview.umd.production.min.js +47 -35
- package/dist/jbrowse-plugin-msaview.umd.production.min.js.map +4 -4
- package/dist/utils/blastCache.d.ts +10 -6
- package/dist/utils/blastCache.js +47 -3
- package/dist/utils/blastCache.test.d.ts +1 -0
- package/dist/utils/blastCache.test.js +72 -0
- package/dist/utils/ebiBlast.d.ts +5 -3
- package/dist/utils/ebiBlast.js +6 -4
- package/dist/utils/ebiJobDispatcher.d.ts +6 -3
- package/dist/utils/ebiJobDispatcher.js +13 -6
- package/dist/utils/fetch.d.ts +8 -1
- package/dist/utils/fetch.js +28 -2
- package/dist/utils/msa.d.ts +15 -1
- package/dist/utils/msa.js +40 -13
- package/dist/utils/msaRows.d.ts +31 -0
- package/dist/utils/msaRows.js +67 -0
- package/dist/utils/ncbiDomains.d.ts +2 -2
- package/dist/utils/ncbiOrthologs.d.ts +11 -1
- package/dist/utils/ncbiOrthologs.js +26 -7
- package/dist/utils/ncbiOrthologs.test.js +23 -1
- package/dist/utils/pantherOrthologs.js +2 -10
- package/dist/utils/phmmer.d.ts +54 -0
- package/dist/utils/phmmer.js +120 -0
- package/dist/utils/poll.d.ts +6 -1
- package/dist/utils/poll.js +7 -2
- package/dist/utils/taxonomyNames.d.ts +1 -1
- package/dist/utils/taxonomyNames.js +6 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +30 -24
- package/src/AddHighlightModel/GenomeMouseoverHighlight.tsx +1 -1
- package/src/AddHighlightModel/MsaToGenomeHighlight.tsx +1 -1
- package/src/AddHighlightModel/index.tsx +1 -1
- package/src/LaunchMsaView/components/BlastQuery/BlastAutomaticPanel.tsx +85 -31
- package/src/LaunchMsaView/components/BlastQuery/BlastManualPanel.tsx +1 -1
- package/src/LaunchMsaView/components/BlastQuery/BlastPanel.tsx +4 -4
- package/src/LaunchMsaView/components/BlastQuery/CachedBlastResults.test.ts +50 -0
- package/src/LaunchMsaView/components/BlastQuery/CachedBlastResults.tsx +23 -3
- package/src/LaunchMsaView/components/BlastQuery/MsaAlgorithmSelect.tsx +1 -1
- package/src/LaunchMsaView/components/BlastQuery/consts.ts +40 -0
- package/src/LaunchMsaView/components/BlastQuery/searchChoiceStorage.test.ts +43 -0
- package/src/LaunchMsaView/components/BlastQuery/searchChoiceStorage.ts +64 -0
- package/src/LaunchMsaView/components/ManualMSALoader/ManualMSALoader.tsx +1 -1
- package/src/LaunchMsaView/components/OrthologQuery/OrthologPanel.tsx +7 -7
- package/src/LaunchMsaView/components/SubmitCancelActions.test.tsx +1 -1
- package/src/LaunchMsaView/components/useFeatureSequence.ts +1 -1
- package/src/LaunchMsaView/detectQueryRow.test.ts +17 -15
- package/src/LaunchMsaView/detectQueryRow.ts +34 -23
- package/src/LaunchMsaView/useQueryRowName.ts +6 -9
- package/src/LaunchMsaViewExtensionPoint/index.test.ts +51 -0
- package/src/LaunchMsaViewExtensionPoint/index.ts +21 -6
- package/src/MsaViewPanel/afterCreateAutoruns.ts +102 -68
- package/src/MsaViewPanel/components/ErrorBoundary.tsx +2 -1
- package/src/MsaViewPanel/components/JobLink.tsx +7 -2
- package/src/MsaViewPanel/components/LaunchProgress.tsx +80 -0
- package/src/MsaViewPanel/components/MsaViewPanel.test.tsx +104 -0
- package/src/MsaViewPanel/components/MsaViewPanel.tsx +7 -4
- package/src/MsaViewPanel/doLaunchBlast.ts +134 -72
- package/src/MsaViewPanel/doLaunchOrthologs.test.ts +43 -28
- package/src/MsaViewPanel/doLaunchOrthologs.ts +9 -5
- package/src/MsaViewPanel/genomeToMSA.test.ts +37 -0
- package/src/MsaViewPanel/genomeToMSA.ts +6 -2
- package/src/MsaViewPanel/model.ts +82 -6
- package/src/MsaViewPanel/msaDataStore.test.ts +54 -0
- package/src/MsaViewPanel/msaDataStore.ts +22 -13
- package/src/MsaViewPanel/observeProteinHighlights.test.ts +13 -0
- package/src/MsaViewPanel/runLaunch.test.ts +154 -0
- package/src/MsaViewPanel/runLaunch.ts +102 -0
- package/src/MsaViewPanel/storedData.test.ts +196 -0
- package/src/MsaViewPanel/syncGenomeHoverToMsaColumn.test.ts +1 -0
- package/src/MsaViewPanel/util.ts +18 -0
- package/src/utils/blastCache.test.ts +86 -0
- package/src/utils/blastCache.ts +67 -13
- package/src/utils/ebiBlast.ts +9 -3
- package/src/utils/ebiJobDispatcher.ts +18 -3
- package/src/utils/fetch.ts +29 -2
- package/src/utils/msa.ts +51 -12
- package/src/utils/msaRows.ts +95 -0
- package/src/utils/ncbiDomains.ts +4 -2
- package/src/utils/ncbiOrthologs.test.ts +25 -0
- package/src/utils/ncbiOrthologs.ts +27 -7
- package/src/utils/pantherOrthologs.ts +6 -11
- package/src/utils/phmmer.ts +178 -0
- package/src/utils/poll.ts +8 -1
- package/src/utils/taxonomyNames.ts +6 -1
- package/src/version.ts +1 -1
- package/dist/MsaViewPanel/components/LoadingBLAST.d.ts +0 -6
- package/dist/MsaViewPanel/components/LoadingBLAST.js +0 -26
- package/src/MsaViewPanel/components/LoadingBLAST.tsx +0 -48
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { getSession } from '@jbrowse/core/util';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
|
-
import { hasHoverPosition, useStyles } from './util';
|
|
5
4
|
import { isMsaView } from '../MsaViewPanel/model';
|
|
5
|
+
import { hasHoverPosition, useStyles } from './util';
|
|
6
6
|
const GenomeMouseoverHighlight = observer(function ({ model, }) {
|
|
7
7
|
const { hovered, views } = getSession(model);
|
|
8
8
|
const hasMsaView = views.some(s => isMsaView(s) && s.connectedViewId === model.id);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { getSession } from '@jbrowse/core/util';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
|
-
import { hasHoverPosition, useStyles } from './util';
|
|
5
4
|
import { isMsaView } from '../MsaViewPanel/model';
|
|
5
|
+
import { hasHoverPosition, useStyles } from './util';
|
|
6
6
|
const MsaToGenomeHighlight = observer(function MsaToGenomeHighlight2({ model, }) {
|
|
7
7
|
const { views, hovered } = getSession(model);
|
|
8
8
|
const msaView = views
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { getSession } from '@jbrowse/core/util';
|
|
3
|
-
import HighlightComponents from './HighlightComponents';
|
|
4
3
|
import { isMsaView } from '../MsaViewPanel/model';
|
|
4
|
+
import HighlightComponents from './HighlightComponents';
|
|
5
5
|
export default function AddHighlightComponentsModelF(pluginManager) {
|
|
6
6
|
pluginManager.addToExtensionPoint('LinearGenomeView-TracksContainerComponent',
|
|
7
7
|
// @ts-expect-error
|
|
@@ -3,21 +3,28 @@ import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
|
|
3
3
|
import { Accordion, AccordionDetails, AccordionSummary, MenuItem, Typography, } from '@mui/material';
|
|
4
4
|
import { observer } from 'mobx-react';
|
|
5
5
|
import { makeStyles } from 'tss-react/mui';
|
|
6
|
-
import CachedBlastResults from './CachedBlastResults';
|
|
7
|
-
import MsaAlgorithmSelect from './MsaAlgorithmSelect';
|
|
8
|
-
import { blastLaunchView } from './blastLaunchView';
|
|
9
|
-
import { blastDatabaseOptions, defaultBlastDatabase } from './consts';
|
|
10
|
-
import { useCachedBlastResults } from './useCachedBlastResults';
|
|
11
6
|
import TextField2 from '../../../components/TextField2';
|
|
12
7
|
import { getBlastViewTitle, getGeneIdentifiers, getLinearGenomeView, } from '../../util';
|
|
13
8
|
import LaunchPanelContent from '../LaunchPanelContent';
|
|
14
9
|
import SubmitCancelActions from '../SubmitCancelActions';
|
|
15
10
|
import TranscriptSelector from '../TranscriptSelector';
|
|
16
11
|
import { useTranscriptSelection } from '../useTranscriptSelection';
|
|
12
|
+
import CachedBlastResults from './CachedBlastResults';
|
|
13
|
+
import MsaAlgorithmSelect from './MsaAlgorithmSelect';
|
|
14
|
+
import { blastLaunchView } from './blastLaunchView';
|
|
15
|
+
import { databaseOptionsFor, defaultSearchFor, searchPrograms } from './consts';
|
|
16
|
+
import { useStoredMsaAlgorithm, useStoredSearchChoice, } from './searchChoiceStorage';
|
|
17
|
+
import { useCachedBlastResults } from './useCachedBlastResults';
|
|
17
18
|
const useStyles = makeStyles()({
|
|
18
19
|
selectField: {
|
|
19
20
|
width: 150,
|
|
20
21
|
},
|
|
22
|
+
// wider than the rest because the values are what the user came to read, and
|
|
23
|
+
// `uniprotkb_swissprot` is 19 characters — at 150 the field showed
|
|
24
|
+
// `uniprotkb_swis…`, which does not distinguish it from `uniprotkb_trembl`
|
|
25
|
+
databaseField: {
|
|
26
|
+
width: 230,
|
|
27
|
+
},
|
|
21
28
|
cachedResultsAccordion: {
|
|
22
29
|
marginTop: 20,
|
|
23
30
|
},
|
|
@@ -29,8 +36,12 @@ const BlastAutomaticPanel = observer(function ({ handleClose, feature, model, ch
|
|
|
29
36
|
const { classes } = useStyles();
|
|
30
37
|
const view = getLinearGenomeView(model);
|
|
31
38
|
const [launchViewError, setLaunchViewError] = useState();
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
// one piece of state, not two: a program and a database that program does not
|
|
40
|
+
// have is a 400 from EBI minutes after Submit, and holding them apart is what
|
|
41
|
+
// would let them drift into that
|
|
42
|
+
const [search, setSearch] = useStoredSearchChoice();
|
|
43
|
+
const [selectedMsaAlgorithm, setSelectedMsaAlgorithm] = useStoredMsaAlgorithm();
|
|
44
|
+
const isPhmmer = search.program === 'phmmer';
|
|
34
45
|
const geneIds = useMemo(() => getGeneIdentifiers(feature), [feature]);
|
|
35
46
|
const { results: cachedResults, error: cachedResultsError } = useCachedBlastResults(geneIds);
|
|
36
47
|
const transcriptSelection = useTranscriptSelection({ feature, view });
|
|
@@ -39,12 +50,35 @@ const BlastAutomaticPanel = observer(function ({ handleClose, feature, model, ch
|
|
|
39
50
|
return (React.createElement(React.Fragment, null,
|
|
40
51
|
React.createElement(LaunchPanelContent, { error: e },
|
|
41
52
|
children,
|
|
42
|
-
React.createElement(TextField2, { variant: "outlined", label: "
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
53
|
+
React.createElement(TextField2, { variant: "outlined", label: "Search program", className: classes.selectField, select: true, value: search.program, onChange: event => {
|
|
54
|
+
// the two services name their databases differently, so switching
|
|
55
|
+
// program replaces the database rather than keeping a name the new
|
|
56
|
+
// one has never heard of
|
|
57
|
+
setSearch(defaultSearchFor(event.target.value));
|
|
58
|
+
} }, searchPrograms.map(val => (React.createElement(MenuItem, { value: val, key: val }, val)))),
|
|
59
|
+
React.createElement(TextField2, { variant: "outlined", label: "Database", className: classes.databaseField, select: true, value: search.database, onChange: event => {
|
|
60
|
+
setSearch({
|
|
61
|
+
program: search.program,
|
|
62
|
+
database: event.target.value,
|
|
63
|
+
});
|
|
64
|
+
} }, databaseOptionsFor(search.program).map(val => (React.createElement(MenuItem, { value: val, key: val }, val)))),
|
|
65
|
+
isPhmmer ? null : (React.createElement(MsaAlgorithmSelect, { className: classes.selectField, value: selectedMsaAlgorithm, onChange: setSelectedMsaAlgorithm })),
|
|
46
66
|
React.createElement(TranscriptSelector, { feature: feature, ...transcriptSelection }),
|
|
47
|
-
React.createElement(Typography, { className: classes.infoText },
|
|
67
|
+
React.createElement(Typography, { className: classes.infoText },
|
|
68
|
+
isPhmmer
|
|
69
|
+
? `phmmer searches UniProtKB with a profile HMM built from the query,
|
|
70
|
+
so it aligns the hits as it finds them and that alignment is used
|
|
71
|
+
directly — nothing is realigned afterwards. The tree is then built
|
|
72
|
+
from it by neighbour-joining. A hit matching the query in more
|
|
73
|
+
than one place appears once per matched region.`
|
|
74
|
+
: `This panel will automatically submit a blastp query to EBI, which
|
|
75
|
+
searches UniProtKB. Searches usually finish in under a minute, and
|
|
76
|
+
swissprot returns curated sequences that align more cleanly than
|
|
77
|
+
the many near-identical entries a TrEMBL search brings back. After
|
|
78
|
+
completion, all the hits will be run through a multiple sequence
|
|
79
|
+
alignment.`,
|
|
80
|
+
' ',
|
|
81
|
+
"Searching NCBI's nr needs the manual approach: NCBI no longer lets a browser read responses from Blast.cgi."),
|
|
48
82
|
cachedResults.length > 0 ? (React.createElement(Accordion, { className: classes.cachedResultsAccordion },
|
|
49
83
|
React.createElement(AccordionSummary, { expandIcon: React.createElement(ExpandMoreIcon, null) },
|
|
50
84
|
React.createElement(Typography, null, "Previous BLAST Results")),
|
|
@@ -58,12 +92,20 @@ const BlastAutomaticPanel = observer(function ({ handleClose, feature, model, ch
|
|
|
58
92
|
feature: selectedTranscript,
|
|
59
93
|
view,
|
|
60
94
|
newViewTitle: getBlastViewTitle(feature, selectedTranscript),
|
|
61
|
-
blastParams:
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
95
|
+
blastParams: search.program === 'phmmer'
|
|
96
|
+
? {
|
|
97
|
+
searchProgram: 'phmmer',
|
|
98
|
+
blastDatabase: search.database,
|
|
99
|
+
selectedTranscript,
|
|
100
|
+
proteinSequence,
|
|
101
|
+
}
|
|
102
|
+
: {
|
|
103
|
+
searchProgram: 'blastp',
|
|
104
|
+
blastDatabase: search.database,
|
|
105
|
+
msaAlgorithm: selectedMsaAlgorithm,
|
|
106
|
+
selectedTranscript,
|
|
107
|
+
proteinSequence,
|
|
108
|
+
},
|
|
67
109
|
});
|
|
68
110
|
handleClose();
|
|
69
111
|
}
|
|
@@ -3,7 +3,6 @@ import { shorten2 } from '@jbrowse/core/util';
|
|
|
3
3
|
import { Alert, Typography } from '@mui/material';
|
|
4
4
|
import { observer } from 'mobx-react';
|
|
5
5
|
import { makeStyles } from 'tss-react/mui';
|
|
6
|
-
import { BASE_BLAST_URL } from './consts';
|
|
7
6
|
import ExternalLink from '../../../components/ExternalLink';
|
|
8
7
|
import TextField2 from '../../../components/TextField2';
|
|
9
8
|
import { useQueryRowName } from '../../useQueryRowName';
|
|
@@ -14,6 +13,7 @@ import QueryRowSelector from '../QueryRowSelector';
|
|
|
14
13
|
import SubmitCancelActions from '../SubmitCancelActions';
|
|
15
14
|
import TranscriptSelector from '../TranscriptSelector';
|
|
16
15
|
import { useTranscriptSelection } from '../useTranscriptSelection';
|
|
16
|
+
import { BASE_BLAST_URL } from './consts';
|
|
17
17
|
const useStyles = makeStyles()({
|
|
18
18
|
ncbiLink: {
|
|
19
19
|
wordBreak: 'break-all',
|
|
@@ -2,12 +2,12 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import SettingsIcon from '@mui/icons-material/Settings';
|
|
3
3
|
import { IconButton } from '@mui/material';
|
|
4
4
|
import { makeStyles } from 'tss-react/mui';
|
|
5
|
+
import { DEFAULT_EBI_EMAIL, EBI_EMAIL_STORAGE_KEY, } from '../../../utils/ebiJobDispatcher';
|
|
6
|
+
import { useLocalStorage } from '../../../utils/useLocalStorage';
|
|
5
7
|
import BlastAutomaticPanel from './BlastAutomaticPanel';
|
|
6
8
|
import BlastManualPanel from './BlastManualPanel';
|
|
7
9
|
import BlastMethodSelector from './BlastMethodSelector';
|
|
8
10
|
import BlastSettingsDialog from './BlastSettingsDialog';
|
|
9
|
-
import { DEFAULT_EBI_EMAIL, EBI_EMAIL_STORAGE_KEY, } from '../../../utils/ebiJobDispatcher';
|
|
10
|
-
import { useLocalStorage } from '../../../utils/useLocalStorage';
|
|
11
11
|
const useStyles = makeStyles()({
|
|
12
12
|
settingsButton: {
|
|
13
13
|
float: 'right',
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import type { CachedBlastResult } from '../../../utils/blastCache';
|
|
2
3
|
import type { AbstractTrackModel, Feature } from '@jbrowse/core/util';
|
|
4
|
+
/**
|
|
5
|
+
* How the row was produced: `uniprotkb_swissprot / blastp / clustalo`, or
|
|
6
|
+
* `swissprot / phmmer` for a row phmmer aligned as it searched and that
|
|
7
|
+
* therefore ran no aligner. Each part is dropped when absent rather than
|
|
8
|
+
* printed empty — `msaAlgorithm` became optional when phmmer arrived, and a
|
|
9
|
+
* phmmer row read `(undefined)` until this stopped assuming one.
|
|
10
|
+
*
|
|
11
|
+
* `blastProgram` is the older field, written only while the plugin still
|
|
12
|
+
* queried NCBI directly and blastp/quick-blastp was a real choice.
|
|
13
|
+
*/
|
|
14
|
+
export declare function describeSearch(result: CachedBlastResult): string;
|
|
3
15
|
declare const CachedBlastResults: ({ model, handleClose, feature, }: {
|
|
4
16
|
model: AbstractTrackModel;
|
|
5
17
|
handleClose: () => void;
|
|
@@ -4,9 +4,9 @@ import DeleteIcon from '@mui/icons-material/Delete';
|
|
|
4
4
|
import { Button, IconButton, List, ListItem, ListItemButton, ListItemText, Typography, } from '@mui/material';
|
|
5
5
|
import { observer } from 'mobx-react';
|
|
6
6
|
import { makeStyles } from 'tss-react/mui';
|
|
7
|
+
import { featureMatchesId, getGeneIdentifiers, getLinearGenomeView, getSortedTranscriptFeatures, } from '../../util';
|
|
7
8
|
import { blastLaunchViewFromCache } from './blastLaunchView';
|
|
8
9
|
import { useCachedBlastResults } from './useCachedBlastResults';
|
|
9
|
-
import { featureMatchesId, getGeneIdentifiers, getLinearGenomeView, getSortedTranscriptFeatures, } from '../../util';
|
|
10
10
|
const useStyles = makeStyles()({
|
|
11
11
|
header: {
|
|
12
12
|
display: 'flex',
|
|
@@ -30,6 +30,25 @@ function getResultDisplayName(result) {
|
|
|
30
30
|
? parts.join(' - ')
|
|
31
31
|
: (result.geneId ?? result.transcriptId ?? 'Unknown');
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* How the row was produced: `uniprotkb_swissprot / blastp / clustalo`, or
|
|
35
|
+
* `swissprot / phmmer` for a row phmmer aligned as it searched and that
|
|
36
|
+
* therefore ran no aligner. Each part is dropped when absent rather than
|
|
37
|
+
* printed empty — `msaAlgorithm` became optional when phmmer arrived, and a
|
|
38
|
+
* phmmer row read `(undefined)` until this stopped assuming one.
|
|
39
|
+
*
|
|
40
|
+
* `blastProgram` is the older field, written only while the plugin still
|
|
41
|
+
* queried NCBI directly and blastp/quick-blastp was a real choice.
|
|
42
|
+
*/
|
|
43
|
+
export function describeSearch(result) {
|
|
44
|
+
return [
|
|
45
|
+
result.blastDatabase,
|
|
46
|
+
result.searchProgram ?? result.blastProgram ?? 'blastp',
|
|
47
|
+
result.msaAlgorithm,
|
|
48
|
+
]
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.join(' / ');
|
|
51
|
+
}
|
|
33
52
|
const CachedBlastResults = observer(function ({ model, handleClose, feature, }) {
|
|
34
53
|
const { classes } = useStyles();
|
|
35
54
|
const view = getLinearGenomeView(model);
|
|
@@ -83,6 +102,6 @@ const CachedBlastResults = observer(function ({ model, handleClose, feature, })
|
|
|
83
102
|
React.createElement(ListItemButton, { onClick: () => {
|
|
84
103
|
handleUseCached(result);
|
|
85
104
|
} },
|
|
86
|
-
React.createElement(ListItemText, { primary: `${getResultDisplayName(result)} - ${
|
|
105
|
+
React.createElement(ListItemText, { primary: `${getResultDisplayName(result)} - ${describeSearch(result)}`, secondary: `${new Date(result.timestamp).toLocaleString()} - Seq: ${result.proteinSequence.slice(0, 30)}...` }))))))));
|
|
87
106
|
});
|
|
88
107
|
export default CachedBlastResults;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
|
+
import { describeSearch } from './CachedBlastResults';
|
|
3
|
+
const base = {
|
|
4
|
+
id: 'k',
|
|
5
|
+
proteinSequence: 'MKV',
|
|
6
|
+
blastDatabase: 'uniprotkb_swissprot',
|
|
7
|
+
msa: '',
|
|
8
|
+
tree: '',
|
|
9
|
+
treeMetadata: '{}',
|
|
10
|
+
rid: 'r',
|
|
11
|
+
timestamp: 0,
|
|
12
|
+
};
|
|
13
|
+
function row(fields) {
|
|
14
|
+
return { ...base, ...fields };
|
|
15
|
+
}
|
|
16
|
+
test('a blastp row names its database, program and aligner', () => {
|
|
17
|
+
expect(describeSearch(row({ searchProgram: 'blastp', msaAlgorithm: 'muscle' }))).toBe('uniprotkb_swissprot / blastp / muscle');
|
|
18
|
+
});
|
|
19
|
+
// phmmer aligns as it searches, so its rows carry no msaAlgorithm at all --
|
|
20
|
+
// which read as "(undefined)" while this assumed one
|
|
21
|
+
test('a phmmer row names no aligner, because none ran', () => {
|
|
22
|
+
expect(describeSearch(row({ blastDatabase: 'swissprot', searchProgram: 'phmmer' }))).toBe('swissprot / phmmer');
|
|
23
|
+
});
|
|
24
|
+
test('a row cached before searchProgram existed reads as blastp', () => {
|
|
25
|
+
expect(describeSearch(row({ msaAlgorithm: 'clustalo' }))).toBe('uniprotkb_swissprot / blastp / clustalo');
|
|
26
|
+
});
|
|
27
|
+
test('a row from the NCBI era keeps the program it recorded', () => {
|
|
28
|
+
expect(describeSearch(row({ blastProgram: 'quick-blastp', msaAlgorithm: 'clustalo' }))).toBe('uniprotkb_swissprot / quick-blastp / clustalo');
|
|
29
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { MenuItem } from '@mui/material';
|
|
3
|
-
import { msaAlgorithms } from './consts';
|
|
4
3
|
import TextField2 from '../../../components/TextField2';
|
|
4
|
+
import { msaAlgorithms } from './consts';
|
|
5
5
|
export default function MsaAlgorithmSelect({ value, onChange, className, }) {
|
|
6
6
|
return (React.createElement(TextField2, { variant: "outlined", label: "MSA Algorithm", className: className, select: true, value: value, onChange: event => {
|
|
7
7
|
onChange(event.target.value);
|
|
@@ -17,3 +17,31 @@ export type MsaAlgorithm = (typeof msaAlgorithms)[number];
|
|
|
17
17
|
export declare const blastDatabaseOptions: readonly ["uniprotkb_swissprot", "uniprotkb", "pan_proteomes", "uniprotkb_trembl"];
|
|
18
18
|
export type BlastDatabase = (typeof blastDatabaseOptions)[number];
|
|
19
19
|
export declare const defaultBlastDatabase: BlastDatabase;
|
|
20
|
+
export declare const searchPrograms: readonly ["blastp", "phmmer"];
|
|
21
|
+
export type SearchProgram = (typeof searchPrograms)[number];
|
|
22
|
+
/**
|
|
23
|
+
* phmmer offers PDB, AlphaFold, Ensembl Genomes, MEROPS and ChEMBL too, but
|
|
24
|
+
* targets outside UniProt carry no OS=/OX= in their description, so those rows
|
|
25
|
+
* would lose their species and common name. Only the databases that label their
|
|
26
|
+
* hits are offered.
|
|
27
|
+
*/
|
|
28
|
+
export declare const phmmerDatabaseOptions: readonly ["swissprot", "uniprotkb", "uniprotrefprot"];
|
|
29
|
+
export type PhmmerDatabase = (typeof phmmerDatabaseOptions)[number];
|
|
30
|
+
export declare const defaultPhmmerDatabase: PhmmerDatabase;
|
|
31
|
+
/**
|
|
32
|
+
* A program together with a database that program actually has.
|
|
33
|
+
*
|
|
34
|
+
* The pair travels as one value because neither service knows the other's
|
|
35
|
+
* database names — `swissprot` is a phmmer database and `uniprotkb_swissprot` a
|
|
36
|
+
* blastp one — so a program held apart from its database can drift into a
|
|
37
|
+
* combination EBI answers with a 400, minutes after the user pressed Submit.
|
|
38
|
+
*/
|
|
39
|
+
export type SearchChoice = {
|
|
40
|
+
program: 'blastp';
|
|
41
|
+
database: BlastDatabase;
|
|
42
|
+
} | {
|
|
43
|
+
program: 'phmmer';
|
|
44
|
+
database: PhmmerDatabase;
|
|
45
|
+
};
|
|
46
|
+
export declare function defaultSearchFor(program: SearchProgram): SearchChoice;
|
|
47
|
+
export declare function databaseOptionsFor(program: SearchProgram): readonly ["uniprotkb_swissprot", "uniprotkb", "pan_proteomes", "uniprotkb_trembl"] | readonly ["swissprot", "uniprotkb", "uniprotrefprot"];
|
|
@@ -22,3 +22,24 @@ export const blastDatabaseOptions = [
|
|
|
22
22
|
// curated, so it returns roughly one good sequence per species rather than the
|
|
23
23
|
// many near-identical TrEMBL entries an alignment reads poorly
|
|
24
24
|
export const defaultBlastDatabase = 'uniprotkb_swissprot';
|
|
25
|
+
export const searchPrograms = ['blastp', 'phmmer'];
|
|
26
|
+
/**
|
|
27
|
+
* phmmer offers PDB, AlphaFold, Ensembl Genomes, MEROPS and ChEMBL too, but
|
|
28
|
+
* targets outside UniProt carry no OS=/OX= in their description, so those rows
|
|
29
|
+
* would lose their species and common name. Only the databases that label their
|
|
30
|
+
* hits are offered.
|
|
31
|
+
*/
|
|
32
|
+
export const phmmerDatabaseOptions = [
|
|
33
|
+
'swissprot',
|
|
34
|
+
'uniprotkb',
|
|
35
|
+
'uniprotrefprot',
|
|
36
|
+
];
|
|
37
|
+
export const defaultPhmmerDatabase = 'swissprot';
|
|
38
|
+
export function defaultSearchFor(program) {
|
|
39
|
+
return program === 'phmmer'
|
|
40
|
+
? { program, database: defaultPhmmerDatabase }
|
|
41
|
+
: { program, database: defaultBlastDatabase };
|
|
42
|
+
}
|
|
43
|
+
export function databaseOptionsFor(program) {
|
|
44
|
+
return program === 'phmmer' ? phmmerDatabaseOptions : blastDatabaseOptions;
|
|
45
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MsaAlgorithm, SearchChoice } from './consts';
|
|
2
|
+
export declare const SEARCH_CHOICE_STORAGE_KEY = "msaView-blastSearch";
|
|
3
|
+
export declare const MSA_ALGORITHM_STORAGE_KEY = "msaView-msaAlgorithm";
|
|
4
|
+
export declare function validSearchChoice(stored: unknown): SearchChoice;
|
|
5
|
+
export declare function validMsaAlgorithm(stored: unknown): MsaAlgorithm;
|
|
6
|
+
export declare function useStoredSearchChoice(): readonly [SearchChoice, (choice: SearchChoice) => void];
|
|
7
|
+
export declare function useStoredMsaAlgorithm(): readonly ["clustalo" | "muscle" | "kalign" | "mafft", (algorithm: MsaAlgorithm) => void];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useLocalStorage } from '../../../utils/useLocalStorage';
|
|
2
|
+
import { databaseOptionsFor, defaultSearchFor, msaAlgorithms, searchPrograms, } from './consts';
|
|
3
|
+
// The panel reopens on the last search run rather than on the defaults, the way
|
|
4
|
+
// the Orthologs tab remembers its source.
|
|
5
|
+
//
|
|
6
|
+
// The program and its database stay ONE stored value for the reason consts.ts
|
|
7
|
+
// keeps them one state: neither service knows the other's database names. What
|
|
8
|
+
// comes back is checked against the current options before it is used — an
|
|
9
|
+
// option this plugin has since dropped would otherwise reach EBI and come back
|
|
10
|
+
// a 400, minutes after the user pressed Submit.
|
|
11
|
+
export const SEARCH_CHOICE_STORAGE_KEY = 'msaView-blastSearch';
|
|
12
|
+
export const MSA_ALGORITHM_STORAGE_KEY = 'msaView-msaAlgorithm';
|
|
13
|
+
const defaultSearch = defaultSearchFor('blastp');
|
|
14
|
+
const defaultMsaAlgorithm = 'clustalo';
|
|
15
|
+
export function validSearchChoice(stored) {
|
|
16
|
+
const { program, database } = (stored ?? {});
|
|
17
|
+
const known = searchPrograms.find(p => p === program);
|
|
18
|
+
return known && databaseOptionsFor(known).some(d => d === database)
|
|
19
|
+
? { program: known, database }
|
|
20
|
+
: defaultSearch;
|
|
21
|
+
}
|
|
22
|
+
export function validMsaAlgorithm(stored) {
|
|
23
|
+
return msaAlgorithms.find(a => a === stored) ?? defaultMsaAlgorithm;
|
|
24
|
+
}
|
|
25
|
+
export function useStoredSearchChoice() {
|
|
26
|
+
const [stored, setStored] = useLocalStorage(SEARCH_CHOICE_STORAGE_KEY, defaultSearch);
|
|
27
|
+
return [
|
|
28
|
+
validSearchChoice(stored),
|
|
29
|
+
(choice) => {
|
|
30
|
+
setStored(choice);
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
}
|
|
34
|
+
export function useStoredMsaAlgorithm() {
|
|
35
|
+
const [stored, setStored] = useLocalStorage(MSA_ALGORITHM_STORAGE_KEY, defaultMsaAlgorithm);
|
|
36
|
+
return [
|
|
37
|
+
validMsaAlgorithm(stored),
|
|
38
|
+
(algorithm) => {
|
|
39
|
+
setStored(algorithm);
|
|
40
|
+
},
|
|
41
|
+
];
|
|
42
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
|
+
import { validMsaAlgorithm, validSearchChoice } from './searchChoiceStorage';
|
|
3
|
+
test('a stored pair both services recognise comes back as it went in', () => {
|
|
4
|
+
expect(validSearchChoice({ program: 'phmmer', database: 'swissprot' })).toEqual({
|
|
5
|
+
program: 'phmmer',
|
|
6
|
+
database: 'swissprot',
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
test('a database the stored program does not have falls back to the defaults', () => {
|
|
10
|
+
// uniprotkb_swissprot is blastp's name for it; sending it to phmmer is a 400
|
|
11
|
+
// from EBI minutes after Submit
|
|
12
|
+
expect(validSearchChoice({ program: 'phmmer', database: 'uniprotkb_swissprot' })).toEqual({ program: 'blastp', database: 'uniprotkb_swissprot' });
|
|
13
|
+
// uniprotkb_reference_proteomes shipped as a menu entry EBI rejects, and 3.0.0
|
|
14
|
+
// is old enough that someone's storage still holds it
|
|
15
|
+
expect(validSearchChoice({
|
|
16
|
+
program: 'blastp',
|
|
17
|
+
database: 'uniprotkb_reference_proteomes',
|
|
18
|
+
})).toEqual({ program: 'blastp', database: 'uniprotkb_swissprot' });
|
|
19
|
+
});
|
|
20
|
+
test('storage holding something else entirely falls back rather than throwing', () => {
|
|
21
|
+
for (const stored of [null, undefined, 'blastp', 42, {}, []]) {
|
|
22
|
+
expect(validSearchChoice(stored)).toEqual({
|
|
23
|
+
program: 'blastp',
|
|
24
|
+
database: 'uniprotkb_swissprot',
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
test('an unknown algorithm falls back to clustalo', () => {
|
|
29
|
+
expect(validMsaAlgorithm('mafft')).toBe('mafft');
|
|
30
|
+
expect(validMsaAlgorithm('t_coffee')).toBe('clustalo');
|
|
31
|
+
expect(validMsaAlgorithm(null)).toBe('clustalo');
|
|
32
|
+
});
|
|
@@ -3,7 +3,6 @@ import { FileSelector } from '@jbrowse/core/ui';
|
|
|
3
3
|
import { FormControl, FormControlLabel, Radio, RadioGroup } from '@mui/material';
|
|
4
4
|
import { observer } from 'mobx-react';
|
|
5
5
|
import { makeStyles } from 'tss-react/mui';
|
|
6
|
-
import { launchView } from './launchView';
|
|
7
6
|
import TextField2 from '../../../components/TextField2';
|
|
8
7
|
import { useQueryRowName } from '../../useQueryRowName';
|
|
9
8
|
import { getGeneDisplayName, getLinearGenomeView } from '../../util';
|
|
@@ -12,6 +11,7 @@ import QueryRowSelector from '../QueryRowSelector';
|
|
|
12
11
|
import SubmitCancelActions from '../SubmitCancelActions';
|
|
13
12
|
import TranscriptSelector from '../TranscriptSelector';
|
|
14
13
|
import { useTranscriptSelection } from '../useTranscriptSelection';
|
|
14
|
+
import { launchView } from './launchView';
|
|
15
15
|
const useStyles = makeStyles()({
|
|
16
16
|
textAreaFont: {
|
|
17
17
|
fontFamily: 'Courier New',
|
|
@@ -2,18 +2,19 @@ import React, { useMemo, useState } from 'react';
|
|
|
2
2
|
import { Typography } from '@mui/material';
|
|
3
3
|
import { observer } from 'mobx-react';
|
|
4
4
|
import { makeStyles } from 'tss-react/mui';
|
|
5
|
-
import OrthologSourceSelect, { ORTHOLOG_SOURCE_STORAGE_KEY, } from './OrthologSourceSelect';
|
|
6
|
-
import QuerySpeciesSelect from './QuerySpeciesSelect';
|
|
7
|
-
import { orthologLaunchView } from './orthologLaunchView';
|
|
8
5
|
import TextField2 from '../../../components/TextField2';
|
|
9
6
|
import { defaultMaxSpecies } from '../../../utils/ncbiOrthologs';
|
|
10
7
|
import { useLocalStorage } from '../../../utils/useLocalStorage';
|
|
11
8
|
import { getGeneDisplayName, getGeneIdentifiers, getLinearGenomeView, getTranscriptDisplayName, } from '../../util';
|
|
12
9
|
import MsaAlgorithmSelect from '../BlastQuery/MsaAlgorithmSelect';
|
|
10
|
+
import { useStoredMsaAlgorithm } from '../BlastQuery/searchChoiceStorage';
|
|
13
11
|
import LaunchPanelContent from '../LaunchPanelContent';
|
|
14
12
|
import SubmitCancelActions from '../SubmitCancelActions';
|
|
15
13
|
import TranscriptSelector from '../TranscriptSelector';
|
|
16
14
|
import { useTranscriptSelection } from '../useTranscriptSelection';
|
|
15
|
+
import OrthologSourceSelect, { ORTHOLOG_SOURCE_STORAGE_KEY, } from './OrthologSourceSelect';
|
|
16
|
+
import QuerySpeciesSelect from './QuerySpeciesSelect';
|
|
17
|
+
import { orthologLaunchView } from './orthologLaunchView';
|
|
17
18
|
const useStyles = makeStyles()({
|
|
18
19
|
selectField: {
|
|
19
20
|
width: 180,
|
|
@@ -25,7 +26,7 @@ const OrthologPanel = observer(function ({ handleClose, feature, model, }) {
|
|
|
25
26
|
const [launchViewError, setLaunchViewError] = useState();
|
|
26
27
|
const [taxId, setTaxId] = useState(9606);
|
|
27
28
|
const [source, setSource] = useLocalStorage(ORTHOLOG_SOURCE_STORAGE_KEY, 'ncbi');
|
|
28
|
-
const [msaAlgorithm, setMsaAlgorithm] =
|
|
29
|
+
const [msaAlgorithm, setMsaAlgorithm] = useStoredMsaAlgorithm();
|
|
29
30
|
const [maxSpecies, setMaxSpecies] = useState(String(defaultMaxSpecies));
|
|
30
31
|
const geneCandidates = useMemo(() => getGeneIdentifiers(feature), [feature]);
|
|
31
32
|
const transcriptSelection = useTranscriptSelection({ feature, view });
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { cleanup, render, screen } from '@testing-library/react';
|
|
4
4
|
import { afterEach, beforeEach, expect, test, vi } from 'vitest';
|
|
5
|
-
import SubmitCancelActions from './SubmitCancelActions';
|
|
6
5
|
import { LAUNCH_PLACEMENT_KEY } from '../../utils/workspaces';
|
|
6
|
+
import SubmitCancelActions from './SubmitCancelActions';
|
|
7
7
|
// getSession walks the MST tree, and this component only wants the two actions
|
|
8
8
|
// off the far end of that walk
|
|
9
9
|
vi.mock('@jbrowse/core/util', () => ({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getSession } from '@jbrowse/core/util';
|
|
2
|
+
import { useFetch } from '../../utils/useFetch';
|
|
2
3
|
import { getProteinSequenceFromFeature } from './calculateProteinSequence';
|
|
3
4
|
import { fetchSeq } from './fetchSeq';
|
|
4
|
-
import { useFetch } from '../../utils/useFetch';
|
|
5
5
|
export function useFeatureSequence({ view, feature, }) {
|
|
6
6
|
const assemblyName = view?.assemblyNames?.[0];
|
|
7
7
|
const { data: sequence, error } = useFetch(feature && assemblyName
|
|
@@ -19,5 +19,18 @@ export interface QueryRowMatch {
|
|
|
19
19
|
/** identity over the compared region, 0-1 */
|
|
20
20
|
identity: number;
|
|
21
21
|
}
|
|
22
|
-
export
|
|
23
|
-
|
|
22
|
+
export interface MsaQueryRow {
|
|
23
|
+
/** every row name, in file order, for the picker to offer */
|
|
24
|
+
names: string[];
|
|
25
|
+
/** the row whose residues are the query's, if one of them is */
|
|
26
|
+
match?: QueryRowMatch;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The picker's whole answer for a pasted alignment: its row names, and which of
|
|
30
|
+
* them is the query.
|
|
31
|
+
*
|
|
32
|
+
* One function rather than two because there is one parse. Both answers were
|
|
33
|
+
* wanted on every keystroke in the paste box, and asking separately parsed a
|
|
34
|
+
* few-hundred-row alignment twice per character.
|
|
35
|
+
*/
|
|
36
|
+
export declare function findQueryRow(msaText: string, proteinSequence: string): MsaQueryRow;
|
|
@@ -36,23 +36,32 @@ const SIMILARITY_FLOOR = 0.9;
|
|
|
36
36
|
* user is still typing.
|
|
37
37
|
*/
|
|
38
38
|
const PARTIAL_COVERAGE_FLOOR = 0.5;
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
/**
|
|
40
|
+
* The picker's whole answer for a pasted alignment: its row names, and which of
|
|
41
|
+
* them is the query.
|
|
42
|
+
*
|
|
43
|
+
* One function rather than two because there is one parse. Both answers were
|
|
44
|
+
* wanted on every keystroke in the paste box, and asking separately parsed a
|
|
45
|
+
* few-hundred-row alignment twice per character.
|
|
46
|
+
*/
|
|
47
|
+
export function findQueryRow(msaText, proteinSequence) {
|
|
48
|
+
if (!msaText.trim()) {
|
|
49
|
+
return { names: [] };
|
|
43
50
|
}
|
|
44
|
-
let names;
|
|
45
51
|
let parsed;
|
|
46
52
|
try {
|
|
47
|
-
|
|
48
|
-
names = msa.getNames();
|
|
49
|
-
parsed = msa;
|
|
53
|
+
parsed = parseMSA(msaText);
|
|
50
54
|
}
|
|
51
55
|
catch {
|
|
52
56
|
// a half-pasted alignment throws here on every keystroke; the caller shows
|
|
53
57
|
// the field rather than an error
|
|
54
|
-
return
|
|
58
|
+
return { names: [] };
|
|
55
59
|
}
|
|
60
|
+
const names = parsed.getNames();
|
|
61
|
+
const query = normalize(proteinSequence);
|
|
62
|
+
return { names, match: query ? bestMatch(parsed, names, query) : undefined };
|
|
63
|
+
}
|
|
64
|
+
function bestMatch(parsed, names, query) {
|
|
56
65
|
const candidates = [];
|
|
57
66
|
for (const name of names) {
|
|
58
67
|
const row = normalize(getUngappedSequence(parsed.getRow(name)));
|
|
@@ -77,18 +86,8 @@ export function detectQueryRow(msaText, proteinSequence) {
|
|
|
77
86
|
candidates.push({ name, quality: 'similar', identity });
|
|
78
87
|
}
|
|
79
88
|
}
|
|
80
|
-
|
|
89
|
+
// an exact match returns above, so only these two can be here
|
|
90
|
+
const order = ['partial', 'similar'];
|
|
81
91
|
return candidates.sort((a, b) => order.indexOf(a.quality) - order.indexOf(b.quality) ||
|
|
82
92
|
b.identity - a.identity)[0];
|
|
83
93
|
}
|
|
84
|
-
export function getMsaRowNames(msaText) {
|
|
85
|
-
if (!msaText.trim()) {
|
|
86
|
-
return [];
|
|
87
|
-
}
|
|
88
|
-
try {
|
|
89
|
-
return parseMSA(msaText).getNames();
|
|
90
|
-
}
|
|
91
|
-
catch {
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
}
|