jbrowse-plugin-protein3d 1.29.0 → 1.31.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.
- package/dist/LaunchProteinView/components/AlphaFoldComplexesTable.js +101 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js +15 -2
- package/dist/LaunchProteinView/components/UniProtResultsTable.js +1 -1
- package/dist/LaunchProteinView/hooks/useAlphaFoldComplexes.js +31 -0
- package/dist/LaunchProteinView/hooks/useAlphaFoldDBSearch.js +16 -5
- package/dist/LaunchProteinViewExtensionPoint/normalizeLaunch.js +8 -4
- package/dist/ProteinView/components/GenomeTrackColorDialog.js +11 -2
- package/dist/ProteinView/exons.js +4 -2
- package/dist/ProteinView/featureFields.js +89 -0
- package/dist/ProteinView/fieldPredicates.js +111 -0
- package/dist/ProteinView/fileUniProt.js +25 -0
- package/dist/ProteinView/proteinColor.js +12 -5
- package/dist/ProteinView/proteinViewSpec.js +1 -0
- package/dist/ProteinView/residueFilter.js +9 -107
- package/dist/ProteinView/structureLoader.js +28 -9
- package/dist/ProteinView/structureModel.js +42 -11
- package/dist/ProteinView/structureReport.js +8 -2
- package/dist/ProteinView/trackScoresSource.js +12 -33
- package/dist/ProteinView/variantEffectSource.js +4 -2
- package/dist/chunks/{AddStructureDialog-VO35RYOW.js → AddStructureDialog-GZ7YSFJO.js} +2 -2
- package/dist/chunks/GenomeTrackColorDialog-VD5NKKQZ.js +2 -0
- package/dist/chunks/{GenomeTrackColorDialog-JHHQLVBB.js.map → GenomeTrackColorDialog-VD5NKKQZ.js.map} +3 -3
- package/dist/chunks/LaunchProteinViewDialog-332ZRCKH.js +2 -0
- package/dist/chunks/LaunchProteinViewDialog-332ZRCKH.js.map +7 -0
- package/dist/chunks/{ManualAlignmentDialog-VGHPVBF5.js → ManualAlignmentDialog-UN6O2FJS.js} +2 -2
- package/dist/chunks/ProteinView-7F7VEAFI.js +3 -0
- package/dist/chunks/{ProteinView-4JJSYAVY.js.map → ProteinView-7F7VEAFI.js.map} +1 -1
- package/dist/chunks/{chunk-R6VPYHUL.js → chunk-2PBRTULS.js} +2 -2
- package/dist/chunks/chunk-46MRJY2F.js +2 -0
- package/dist/chunks/chunk-46MRJY2F.js.map +7 -0
- package/dist/chunks/{chunk-MHLZDRGW.js → chunk-5Q2KX5AR.js} +2 -2
- package/dist/chunks/chunk-5Q2KX5AR.js.map +7 -0
- package/dist/chunks/{chunk-RQCZWHQQ.js → chunk-7IAHWS5M.js} +2 -2
- package/dist/chunks/{chunk-NAEHT35L.js → chunk-BR44SFC2.js} +2 -2
- package/dist/chunks/{chunk-FNAEADDB.js → chunk-DLVAQOU6.js} +2 -2
- package/dist/chunks/{chunk-AFVOEGWH.js → chunk-E27SMIZ5.js} +2 -2
- package/dist/chunks/chunk-EX3JB7B4.js +2 -0
- package/dist/chunks/chunk-EX3JB7B4.js.map +7 -0
- package/dist/chunks/chunk-F65VCIGM.js +2 -0
- package/dist/chunks/chunk-F65VCIGM.js.map +7 -0
- package/dist/chunks/{chunk-CZ5TRTSY.js → chunk-H5GTPPVG.js} +2 -2
- package/dist/chunks/{chunk-XEZVHJRK.js → chunk-HION7YP4.js} +2 -2
- package/dist/chunks/{chunk-W7K7OD5Z.js → chunk-KEGV4ZRS.js} +2 -2
- package/dist/chunks/{chunk-W7K7OD5Z.js.map → chunk-KEGV4ZRS.js.map} +3 -3
- package/dist/chunks/chunk-NY22OOJ6.js +2 -0
- package/dist/chunks/chunk-NY22OOJ6.js.map +7 -0
- package/dist/chunks/{chunk-MRFSMEU2.js → chunk-Q6MXLDYV.js} +2 -2
- package/dist/chunks/chunk-QPRIEAI4.js +29 -0
- package/dist/chunks/chunk-QPRIEAI4.js.map +7 -0
- package/dist/chunks/{chunk-BIJXO4M2.js → chunk-Y2KQAAF2.js} +2 -2
- package/dist/chunks/{chunk-WGXE3R2M.js → chunk-YXRW2525.js} +2 -2
- package/dist/chunks/chunk-ZCVU73CX.js +2 -0
- package/dist/chunks/chunk-ZCVU73CX.js.map +7 -0
- package/dist/chunks/clinVarSource-MZZ3FS3R.js +2 -0
- package/dist/chunks/esm-P5VQ7RXE.js +2 -0
- package/dist/chunks/isoformRanking-ZNEIFWWG.js +2 -0
- package/dist/chunks/launchAnnotationView-W6TZNXJW.js +2 -0
- package/dist/chunks/{launchAnnotationView-JMO2TEQO.js.map → launchAnnotationView-W6TZNXJW.js.map} +1 -1
- package/dist/chunks/launchProteinView-NMZQQBXU.js +2 -0
- package/dist/chunks/{launchProteinView-GXIFQKNJ.js.map → launchProteinView-NMZQQBXU.js.map} +1 -1
- package/dist/chunks/launchViewUtils-4ZY4L37J.js +2 -0
- package/dist/chunks/model-RPEEIRC2.js +2 -0
- package/dist/chunks/model-RPEEIRC2.js.map +7 -0
- package/dist/chunks/{molstarExports-I4RSPU2N.js → molstarExports-E5KKETWP.js} +2 -2
- package/dist/chunks/resolveGeneLaunch-QZL3HMFN.js +2 -0
- package/dist/jbrowse-plugin-protein3d.esm.js +1 -1
- package/dist/jbrowse-plugin-protein3d.esm.js.map +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
- package/src/LaunchProteinView/components/AlphaFoldComplexesTable.tsx +189 -0
- package/src/LaunchProteinView/components/AlphaFoldDBSearch.tsx +27 -1
- package/src/LaunchProteinView/components/UniProtResultsTable.tsx +1 -1
- package/src/LaunchProteinView/hooks/useAlphaFoldComplexes.test.ts +72 -0
- package/src/LaunchProteinView/hooks/useAlphaFoldComplexes.ts +52 -0
- package/src/LaunchProteinView/hooks/useAlphaFoldDBSearch.ts +20 -4
- package/src/LaunchProteinView/resolveGeneLaunch.ts +1 -1
- package/src/LaunchProteinViewExtensionPoint/normalizeLaunch.test.ts +17 -2
- package/src/LaunchProteinViewExtensionPoint/normalizeLaunch.ts +8 -4
- package/src/ProteinView/components/GenomeTrackColorDialog.tsx +11 -2
- package/src/ProteinView/exons.test.ts +48 -4
- package/src/ProteinView/exons.ts +5 -2
- package/src/ProteinView/featureFields.test.ts +86 -0
- package/src/ProteinView/featureFields.ts +126 -0
- package/src/ProteinView/fieldPredicates.ts +174 -0
- package/src/ProteinView/fileUniProt.test.ts +77 -0
- package/src/ProteinView/fileUniProt.ts +32 -0
- package/src/ProteinView/proteinColor.test.ts +75 -0
- package/src/ProteinView/proteinColor.ts +31 -9
- package/src/ProteinView/proteinViewSpec.ts +4 -1
- package/src/ProteinView/residueFilter.ts +13 -145
- package/src/ProteinView/structureLoader.test.ts +43 -0
- package/src/ProteinView/structureLoader.ts +38 -8
- package/src/ProteinView/structureLocate.test.ts +1 -0
- package/src/ProteinView/structureModel.test.ts +67 -0
- package/src/ProteinView/structureModel.ts +49 -10
- package/src/ProteinView/structureReport.ts +9 -1
- package/src/ProteinView/trackScoresSource.test.ts +60 -5
- package/src/ProteinView/trackScoresSource.ts +22 -39
- package/src/ProteinView/variantEffectSource.test.ts +22 -1
- package/src/ProteinView/variantEffectSource.ts +7 -1
- package/src/version.ts +1 -1
- package/dist/chunks/GenomeTrackColorDialog-JHHQLVBB.js +0 -2
- package/dist/chunks/LaunchProteinViewDialog-AJ62LUV4.js +0 -2
- package/dist/chunks/LaunchProteinViewDialog-AJ62LUV4.js.map +0 -7
- package/dist/chunks/ProteinView-4JJSYAVY.js +0 -3
- package/dist/chunks/chunk-DDPGOM6D.js +0 -29
- package/dist/chunks/chunk-DDPGOM6D.js.map +0 -7
- package/dist/chunks/chunk-IQBGBMGH.js +0 -2
- package/dist/chunks/chunk-IQBGBMGH.js.map +0 -7
- package/dist/chunks/chunk-LJWAVF6V.js +0 -2
- package/dist/chunks/chunk-LJWAVF6V.js.map +0 -7
- package/dist/chunks/chunk-MHLZDRGW.js.map +0 -7
- package/dist/chunks/chunk-QGDO6K2Y.js +0 -2
- package/dist/chunks/chunk-QGDO6K2Y.js.map +0 -7
- package/dist/chunks/chunk-Y72I4AXI.js +0 -2
- package/dist/chunks/chunk-Y72I4AXI.js.map +0 -7
- package/dist/chunks/clinVarSource-4M3NMFEI.js +0 -2
- package/dist/chunks/esm-VXBU2PVU.js +0 -2
- package/dist/chunks/isoformRanking-UGZ5OBYY.js +0 -2
- package/dist/chunks/launchAnnotationView-JMO2TEQO.js +0 -2
- package/dist/chunks/launchProteinView-GXIFQKNJ.js +0 -2
- package/dist/chunks/launchViewUtils-GGC32OOM.js +0 -2
- package/dist/chunks/model-GDYADBRA.js +0 -2
- package/dist/chunks/model-GDYADBRA.js.map +0 -7
- package/dist/chunks/resolveGeneLaunch-NVKHBKVI.js +0 -2
- /package/dist/chunks/{AddStructureDialog-VO35RYOW.js.map → AddStructureDialog-GZ7YSFJO.js.map} +0 -0
- /package/dist/chunks/{ManualAlignmentDialog-VGHPVBF5.js.map → ManualAlignmentDialog-UN6O2FJS.js.map} +0 -0
- /package/dist/chunks/{chunk-R6VPYHUL.js.map → chunk-2PBRTULS.js.map} +0 -0
- /package/dist/chunks/{chunk-RQCZWHQQ.js.map → chunk-7IAHWS5M.js.map} +0 -0
- /package/dist/chunks/{chunk-NAEHT35L.js.map → chunk-BR44SFC2.js.map} +0 -0
- /package/dist/chunks/{chunk-FNAEADDB.js.map → chunk-DLVAQOU6.js.map} +0 -0
- /package/dist/chunks/{chunk-AFVOEGWH.js.map → chunk-E27SMIZ5.js.map} +0 -0
- /package/dist/chunks/{chunk-CZ5TRTSY.js.map → chunk-H5GTPPVG.js.map} +0 -0
- /package/dist/chunks/{chunk-XEZVHJRK.js.map → chunk-HION7YP4.js.map} +0 -0
- /package/dist/chunks/{chunk-MRFSMEU2.js.map → chunk-Q6MXLDYV.js.map} +0 -0
- /package/dist/chunks/{chunk-BIJXO4M2.js.map → chunk-Y2KQAAF2.js.map} +0 -0
- /package/dist/chunks/{chunk-WGXE3R2M.js.map → chunk-YXRW2525.js.map} +0 -0
- /package/dist/chunks/{clinVarSource-4M3NMFEI.js.map → clinVarSource-MZZ3FS3R.js.map} +0 -0
- /package/dist/chunks/{esm-VXBU2PVU.js.map → esm-P5VQ7RXE.js.map} +0 -0
- /package/dist/chunks/{isoformRanking-UGZ5OBYY.js.map → isoformRanking-ZNEIFWWG.js.map} +0 -0
- /package/dist/chunks/{launchViewUtils-GGC32OOM.js.map → launchViewUtils-4ZY4L37J.js.map} +0 -0
- /package/dist/chunks/{molstarExports-I4RSPU2N.js.map → molstarExports-E5KKETWP.js.map} +0 -0
- /package/dist/chunks/{resolveGeneLaunch-NVKHBKVI.js.map → resolveGeneLaunch-QZL3HMFN.js.map} +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Paper, Radio, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip, Typography, } from '@mui/material';
|
|
3
|
+
import { observer } from 'mobx-react';
|
|
4
|
+
import { uniprotEntryUrl } from 'p2s_mapper';
|
|
5
|
+
import { makeStyles } from 'tss-react/mui';
|
|
6
|
+
import ExternalLink from '../../components/ExternalLink';
|
|
7
|
+
const useStyles = makeStyles()(theme => ({
|
|
8
|
+
tableContainer: {
|
|
9
|
+
maxHeight: 300,
|
|
10
|
+
},
|
|
11
|
+
headerCell: {
|
|
12
|
+
fontWeight: 'bold',
|
|
13
|
+
backgroundColor: theme.palette.mode === 'dark'
|
|
14
|
+
? theme.palette.grey[900]
|
|
15
|
+
: theme.palette.grey[100],
|
|
16
|
+
},
|
|
17
|
+
selectedRow: {
|
|
18
|
+
backgroundColor: theme.palette.action.selected,
|
|
19
|
+
},
|
|
20
|
+
clickableRow: {
|
|
21
|
+
cursor: 'pointer',
|
|
22
|
+
'&:hover': {
|
|
23
|
+
backgroundColor: theme.palette.action.hover,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
}));
|
|
27
|
+
export function alphaFoldEntryUrl(entity) {
|
|
28
|
+
return `https://alphafold.ebi.ac.uk/entry/${entity}`;
|
|
29
|
+
}
|
|
30
|
+
function complexKind({ homomer, oligomericState }) {
|
|
31
|
+
return `${homomer ? 'Homo' : 'Hetero'}${oligomericState ?? 'mer'}`;
|
|
32
|
+
}
|
|
33
|
+
function fixed(value, digits) {
|
|
34
|
+
return value === undefined ? '-' : value.toFixed(digits);
|
|
35
|
+
}
|
|
36
|
+
const Member = observer(function Member({ member, }) {
|
|
37
|
+
return (React.createElement("div", null,
|
|
38
|
+
React.createElement("strong", null, member.gene ?? member.accession),
|
|
39
|
+
member.copies > 1 ? ` ×${member.copies}` : '',
|
|
40
|
+
' ',
|
|
41
|
+
member.description ? `${member.description} ` : '',
|
|
42
|
+
React.createElement(ExternalLink, { href: uniprotEntryUrl(member.accession) }, member.accession)));
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* The structures AlphaFold DB predicted for a protein: optionally its monomer
|
|
46
|
+
* first, then each complex with the proteins it pairs with. `selected`
|
|
47
|
+
* undefined is the monomer.
|
|
48
|
+
*/
|
|
49
|
+
const AlphaFoldComplexesTable = observer(function AlphaFoldComplexesTable({ complexes, accession, monomer, selected, onSelect, }) {
|
|
50
|
+
const { classes } = useStyles();
|
|
51
|
+
const entry = accession.replace(/-\d+$/, '');
|
|
52
|
+
const rowClass = (isSelected) => `${classes.clickableRow} ${isSelected ? classes.selectedRow : ''}`;
|
|
53
|
+
return (React.createElement(React.Fragment, null,
|
|
54
|
+
React.createElement(Typography, { variant: "body2", color: "textSecondary" }, complexes.length === 0
|
|
55
|
+
? `AlphaFold DB has predicted no complex with ${entry}`
|
|
56
|
+
: `${complexes.length} complex${complexes.length === 1 ? '' : 'es'} AlphaFold DB predicted with ${entry}, homomers first, then by ipTM`),
|
|
57
|
+
React.createElement(TableContainer, { component: Paper, className: classes.tableContainer },
|
|
58
|
+
React.createElement(Table, { size: "small", stickyHeader: true, "data-testid": "alphafold-complexes-table" },
|
|
59
|
+
React.createElement(TableHead, null,
|
|
60
|
+
React.createElement(TableRow, null,
|
|
61
|
+
React.createElement(TableCell, { className: classes.headerCell, padding: "checkbox" }),
|
|
62
|
+
React.createElement(TableCell, { className: classes.headerCell }, "Structure"),
|
|
63
|
+
React.createElement(TableCell, { className: classes.headerCell }, "With"),
|
|
64
|
+
React.createElement(TableCell, { className: classes.headerCell },
|
|
65
|
+
React.createElement(Tooltip, { title: "Interface predicted TM-score, 0 to 1: how sure the prediction is of how the chains sit against each other. Above 0.8 is confident; below 0.6 the interface is likely wrong." },
|
|
66
|
+
React.createElement("span", null, "ipTM"))),
|
|
67
|
+
React.createElement(TableCell, { className: classes.headerCell },
|
|
68
|
+
React.createElement(Tooltip, { title: "Mean per-residue confidence, 0 to 100" },
|
|
69
|
+
React.createElement("span", null, "pLDDT"))),
|
|
70
|
+
React.createElement(TableCell, { className: classes.headerCell }, "AlphaFold DB"))),
|
|
71
|
+
React.createElement(TableBody, null,
|
|
72
|
+
monomer ? (React.createElement(TableRow, { className: rowClass(selected === undefined), onClick: () => {
|
|
73
|
+
onSelect(undefined);
|
|
74
|
+
} },
|
|
75
|
+
React.createElement(TableCell, { padding: "checkbox" },
|
|
76
|
+
React.createElement(Radio, { checked: selected === undefined, size: "small" })),
|
|
77
|
+
React.createElement(TableCell, null, "Monomer"),
|
|
78
|
+
React.createElement(TableCell, null, "-"),
|
|
79
|
+
React.createElement(TableCell, null, "-"),
|
|
80
|
+
React.createElement(TableCell, null, fixed(monomer.meanPlddt, 1)),
|
|
81
|
+
React.createElement(TableCell, null,
|
|
82
|
+
React.createElement(ExternalLink, { href: alphaFoldEntryUrl(entry) }, entry)))) : null,
|
|
83
|
+
complexes.map(complex => {
|
|
84
|
+
const isSelected = complex.entity === selected;
|
|
85
|
+
const partners = complex.homomer
|
|
86
|
+
? complex.members
|
|
87
|
+
: complex.members.filter(m => m.accession !== entry);
|
|
88
|
+
return (React.createElement(TableRow, { key: complex.entity, className: rowClass(isSelected), onClick: () => {
|
|
89
|
+
onSelect(complex.entity);
|
|
90
|
+
} },
|
|
91
|
+
React.createElement(TableCell, { padding: "checkbox" },
|
|
92
|
+
React.createElement(Radio, { checked: isSelected, size: "small" })),
|
|
93
|
+
React.createElement(TableCell, null, complexKind(complex)),
|
|
94
|
+
React.createElement(TableCell, null, partners.map(m => (React.createElement(Member, { key: m.accession, member: m })))),
|
|
95
|
+
React.createElement(TableCell, null, fixed(complex.iptm, 2)),
|
|
96
|
+
React.createElement(TableCell, null, fixed(complex.meanPlddt, 1)),
|
|
97
|
+
React.createElement(TableCell, null,
|
|
98
|
+
React.createElement(ExternalLink, { href: alphaFoldEntryUrl(complex.entity) }, complex.entity))));
|
|
99
|
+
}))))));
|
|
100
|
+
});
|
|
101
|
+
export default AlphaFoldComplexesTable;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui';
|
|
3
3
|
import { DialogActions, DialogContent, Typography } from '@mui/material';
|
|
4
4
|
import { observer } from 'mobx-react';
|
|
5
5
|
import { makeStyles } from 'tss-react/mui';
|
|
6
|
+
import AlphaFoldComplexesTable from './AlphaFoldComplexesTable';
|
|
6
7
|
import AlphaFoldDBSearchStatus from './AlphaFoldDBSearchStatus';
|
|
7
8
|
import PartialFailureNotice from './PartialFailureNotice';
|
|
8
9
|
import ProteinViewActions from './ProteinViewActions';
|
|
9
10
|
import TranscriptSelector from './TranscriptSelector';
|
|
10
11
|
import UniProtLookupControls from './UniProtLookupControls';
|
|
11
12
|
import UniProtLookupResults from './UniProtLookupResults';
|
|
13
|
+
import { errorMessage } from '../../ProteinView/util';
|
|
14
|
+
import { useAlphaFoldComplexes } from '../hooks/useAlphaFoldComplexes';
|
|
12
15
|
import useAlphaFoldDBSearch from '../hooks/useAlphaFoldDBSearch';
|
|
13
16
|
const useStyles = makeStyles()({
|
|
14
17
|
dialogContent: {
|
|
@@ -29,11 +32,16 @@ const useStyles = makeStyles()({
|
|
|
29
32
|
});
|
|
30
33
|
const AlphaFoldDBSearch = observer(function AlphaFoldDBSearch({ feature, preferredTranscriptId, session, view, handleClose, lookup, sideBySide, onSideBySideChange, }) {
|
|
31
34
|
const { classes } = useStyles();
|
|
35
|
+
const [complexEntity, setComplexEntity] = useState();
|
|
36
|
+
const { complexes, error: complexesError } = useAlphaFoldComplexes(lookup.uniprotId);
|
|
37
|
+
// a choice from another accession's list is no choice
|
|
38
|
+
const chosenComplex = complexes?.find(c => c.entity === complexEntity);
|
|
32
39
|
const state = useAlphaFoldDBSearch({
|
|
33
40
|
feature,
|
|
34
41
|
view,
|
|
35
42
|
lookup,
|
|
36
43
|
preferredTranscriptId,
|
|
44
|
+
complexEntity: chosenComplex?.entity,
|
|
37
45
|
});
|
|
38
46
|
return (React.createElement(React.Fragment, null,
|
|
39
47
|
React.createElement(DialogContent, { className: classes.dialogContent },
|
|
@@ -56,7 +64,12 @@ const AlphaFoldDBSearch = observer(function AlphaFoldDBSearch({ feature, preferr
|
|
|
56
64
|
state.uniprotId ? (React.createElement(React.Fragment, null,
|
|
57
65
|
React.createElement("div", { className: classes.selectorsRow },
|
|
58
66
|
React.createElement(TranscriptSelector, { val: state.userSelection, setVal: state.setUserSelection, structureSequence: state.structureSequence, feature: feature, isoforms: state.transcriptOptions, ranking: state.ranking })),
|
|
59
|
-
React.createElement(AlphaFoldDBSearchStatus, { uniprotId: state.modelAccession ?? state.uniprotId, url: state.url }))) : null
|
|
67
|
+
React.createElement(AlphaFoldDBSearchStatus, { uniprotId: state.modelAccession ?? state.uniprotId, url: state.url }))) : null,
|
|
68
|
+
state.uniprotId && complexes ? (React.createElement(AlphaFoldComplexesTable, { complexes: complexes, accession: state.uniprotId, monomer: state.noModel ? undefined : { meanPlddt: state.meanPlddt }, selected: chosenComplex?.entity, onSelect: setComplexEntity })) : null,
|
|
69
|
+
complexesError ? (React.createElement(Typography, { variant: "body2", color: "textSecondary" },
|
|
70
|
+
"AlphaFold DB's complex list did not answer:",
|
|
71
|
+
' ',
|
|
72
|
+
errorMessage(complexesError))) : null),
|
|
60
73
|
React.createElement(DialogActions, null,
|
|
61
74
|
React.createElement(ProteinViewActions, { handleClose: handleClose, uniprotId: state.modelAccession ?? state.uniprotId, userSelectedProteinSequence: state.userSelectedProteinSequence, selectedTranscript: state.selectedTranscript, url: state.url, confidenceUrl: state.confidenceUrl, feature: feature, view: view, session: session, sideBySide: sideBySide, onSideBySideChange: onSideBySideChange, sequencesMatch: state.sequencesMatch, isLoading: state.isLoading, error: state.error }))));
|
|
62
75
|
});
|
|
@@ -44,7 +44,7 @@ const UniProtResultsTable = observer(function UniProtResultsTable({ entries, sel
|
|
|
44
44
|
entries.length,
|
|
45
45
|
" UniProt entries. Select one:"),
|
|
46
46
|
React.createElement(TableContainer, { component: Paper, className: classes.tableContainer },
|
|
47
|
-
React.createElement(Table, { size: "small", stickyHeader: true },
|
|
47
|
+
React.createElement(Table, { size: "small", stickyHeader: true, "data-testid": "uniprot-results-table" },
|
|
48
48
|
React.createElement(TableHead, null,
|
|
49
49
|
React.createElement(TableRow, null,
|
|
50
50
|
React.createElement(TableCell, { className: classes.headerCell, padding: "checkbox" }),
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { fetchAlphaFoldComplexModel, fetchAlphaFoldComplexes } from 'p2s_mapper';
|
|
3
|
+
import useSWR from 'swr';
|
|
4
|
+
import { STATIC_SWR_OPTIONS } from './swrOptions';
|
|
5
|
+
/** Homomers first, as the protein's own assembly, then the partners AlphaFold
|
|
6
|
+
* is surest of how they sit together */
|
|
7
|
+
export function rankAlphaFoldComplexes(complexes) {
|
|
8
|
+
return [...complexes].sort((a, b) => Number(b.homomer) - Number(a.homomer) || (b.iptm ?? 0) - (a.iptm ?? 0));
|
|
9
|
+
}
|
|
10
|
+
/** Every complex AlphaFold DB predicted with an accession's protein in it.
|
|
11
|
+
* An isoform's complexes are its entry's. */
|
|
12
|
+
export function useAlphaFoldComplexes(uniprotId) {
|
|
13
|
+
const entry = uniprotId?.replace(/-\d+$/, '');
|
|
14
|
+
const { data, error, isLoading } = useSWR(entry ? ['alphafold-complexes', entry] : null, ([, id]) => fetchAlphaFoldComplexes(id), STATIC_SWR_OPTIONS);
|
|
15
|
+
const complexes = useMemo(() => (data ? rankAlphaFoldComplexes(data) : undefined), [data]);
|
|
16
|
+
const complexesError = error;
|
|
17
|
+
return { complexes, error: complexesError, isLoading };
|
|
18
|
+
}
|
|
19
|
+
/** One complex's file and the protein of each of its chains, asked for once
|
|
20
|
+
* the complex is chosen */
|
|
21
|
+
export function useAlphaFoldComplexModel(entity) {
|
|
22
|
+
const { data, error, isLoading } = useSWR(entity ? ['alphafold-complex-model', entity] : null, async ([, id]) => {
|
|
23
|
+
const model = await fetchAlphaFoldComplexModel(id);
|
|
24
|
+
if (!model) {
|
|
25
|
+
throw new Error(`AlphaFold DB has no files for complex ${id}`);
|
|
26
|
+
}
|
|
27
|
+
return model;
|
|
28
|
+
}, STATIC_SWR_OPTIONS);
|
|
29
|
+
const modelError = error;
|
|
30
|
+
return { model: data, error: modelError, isLoading };
|
|
31
|
+
}
|
|
@@ -1,29 +1,38 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { sameProtein } from 'p2s_mapper';
|
|
3
|
+
import { useAlphaFoldComplexModel } from './useAlphaFoldComplexes';
|
|
3
4
|
import useAlphaFoldData from './useAlphaFoldData';
|
|
4
5
|
import useTranscriptIsoformSelection from './useTranscriptIsoformSelection';
|
|
5
|
-
export default function useAlphaFoldDBSearch({ feature, view, lookup, preferredTranscriptId, }) {
|
|
6
|
+
export default function useAlphaFoldDBSearch({ feature, view, lookup, preferredTranscriptId, complexEntity, }) {
|
|
6
7
|
const { uniprotId, isLookupLoading } = lookup;
|
|
7
8
|
const { isLoading: isAlphaFoldLoading, isValidating: isAlphaFoldValidating, modelsUnreachable, model, noModel, } = useAlphaFoldData({ uniprotId, feature, view, preferredTranscriptId });
|
|
9
|
+
const complex = useAlphaFoldComplexModel(complexEntity);
|
|
10
|
+
// the transcripts rank against the gene's own chain of a complex
|
|
11
|
+
const entry = uniprotId?.replace(/-\d+$/, '');
|
|
12
|
+
const complexSequence = complex.model?.chains.find(c => c.accession === entry)?.sequence;
|
|
13
|
+
const url = complexEntity ? complex.model?.url : model?.url;
|
|
8
14
|
// a stable array, or the isoform picker realigns on every render
|
|
9
|
-
const modelSequence =
|
|
15
|
+
const modelSequence = complexEntity
|
|
16
|
+
? complex.model && (complexSequence ?? model?.sequence)
|
|
17
|
+
: model?.sequence;
|
|
10
18
|
const structureSequences = useMemo(() => (modelSequence ? [modelSequence] : undefined), [modelSequence]);
|
|
11
19
|
const { transcripts: transcriptOptions, isoformSequences, structureSequence, ranking, isLoading: isIsoformLoading, isRanking, error: isoformError, partialFailure: isoformPartialFailure, selectedTranscriptId: userSelection, setSelectedTranscriptId: setUserSelection, selectedTranscript, selectedIsoform: userSelectedProteinSequence, } = useTranscriptIsoformSelection({
|
|
12
20
|
feature,
|
|
13
21
|
view,
|
|
14
22
|
structureSequences,
|
|
15
23
|
preferredTranscriptId,
|
|
16
|
-
resetKey:
|
|
24
|
+
resetKey: url,
|
|
17
25
|
});
|
|
18
26
|
const loadingStatuses = [
|
|
19
27
|
isLookupLoading && 'Looking up UniProt ID',
|
|
20
28
|
isIsoformLoading && 'Loading protein sequences from transcript isoforms',
|
|
21
29
|
isRanking && 'Aligning isoforms to the structure',
|
|
22
30
|
isAlphaFoldLoading && 'Asking AlphaFold DB for models',
|
|
31
|
+
complex.isLoading && 'Asking AlphaFold DB for the complex',
|
|
23
32
|
].filter(s => typeof s === 'string');
|
|
24
33
|
const isLoading = loadingStatuses.length > 0;
|
|
25
34
|
// errors wait for loading to finish, so a lookup in flight doesn't flash one
|
|
26
|
-
const rawError = isoformError ?? lookup.lookupError;
|
|
35
|
+
const rawError = isoformError ?? lookup.lookupError ?? complex.error;
|
|
27
36
|
const error = isLoading ? undefined : rawError;
|
|
28
37
|
return {
|
|
29
38
|
...lookup,
|
|
@@ -35,7 +44,8 @@ export default function useAlphaFoldDBSearch({ feature, view, lookup, preferredT
|
|
|
35
44
|
ranking,
|
|
36
45
|
isoformPartialFailure,
|
|
37
46
|
userSelectedProteinSequence,
|
|
38
|
-
url
|
|
47
|
+
url,
|
|
48
|
+
meanPlddt: model?.meanPlddt,
|
|
39
49
|
confidenceUrl: model?.confidenceUrl,
|
|
40
50
|
modelAccession: model?.accession,
|
|
41
51
|
structureSequence,
|
|
@@ -46,6 +56,7 @@ export default function useAlphaFoldDBSearch({ feature, view, lookup, preferredT
|
|
|
46
56
|
// While the structure is refetched, structureSequence is still the previous
|
|
47
57
|
// selection's (keepPreviousData), so a match is unknown until it settles.
|
|
48
58
|
sequencesMatch: !isAlphaFoldValidating &&
|
|
59
|
+
!complex.isLoading &&
|
|
49
60
|
userSelectedProteinSequence?.seq &&
|
|
50
61
|
structureSequence
|
|
51
62
|
? sameProtein(userSelectedProteinSequence.seq, structureSequence)
|
|
@@ -5,6 +5,7 @@ const STRUCTURE_KEY_ROLES = {
|
|
|
5
5
|
url: 'source',
|
|
6
6
|
data: 'source',
|
|
7
7
|
uniprotId: 'source',
|
|
8
|
+
alphaFoldComplexId: 'source',
|
|
8
9
|
pdbId: 'source',
|
|
9
10
|
initialSelection: 'selection',
|
|
10
11
|
initialResidues: 'selection',
|
|
@@ -176,6 +177,7 @@ function readStructure(fields, at, warnings) {
|
|
|
176
177
|
url: read('url', isString, 'a string'),
|
|
177
178
|
data: read('data', isString, 'a string'),
|
|
178
179
|
uniprotId: read('uniprotId', isString, 'a string'),
|
|
180
|
+
alphaFoldComplexId: read('alphaFoldComplexId', isString, 'a string'),
|
|
179
181
|
pdbId: read('pdbId', isString, 'a string'),
|
|
180
182
|
initialSelection: read('initialSelection', isResidueRanges, RANGES),
|
|
181
183
|
initialResidues: read('initialResidues', isResidueRanges, RANGES),
|
|
@@ -195,7 +197,8 @@ function readStructure(fields, at, warnings) {
|
|
|
195
197
|
function namesSource(structure) {
|
|
196
198
|
return (!!resolveStructureUrl(structure) ||
|
|
197
199
|
structure.data !== undefined ||
|
|
198
|
-
!!structure.uniprotId
|
|
200
|
+
!!structure.uniprotId ||
|
|
201
|
+
!!structure.alphaFoldComplexId);
|
|
199
202
|
}
|
|
200
203
|
function withUrl(structure) {
|
|
201
204
|
return { ...structure, url: resolveStructureUrl(structure) };
|
|
@@ -229,7 +232,7 @@ export function normalizeLaunch(launch) {
|
|
|
229
232
|
const looksUpGene = !!linkage.gene && !linkage.userProvidedTranscriptSequence;
|
|
230
233
|
const noStructure = linkage.gene
|
|
231
234
|
? 'the launch names no structure, and `gene` is not looked up beside `userProvidedTranscriptSequence`'
|
|
232
|
-
: 'No url, data, uniprotId, pdbId or gene provided when launching protein view';
|
|
235
|
+
: 'No url, data, uniprotId, alphaFoldComplexId, pdbId or gene provided when launching protein view';
|
|
233
236
|
const given = top.get('structures');
|
|
234
237
|
if (given !== undefined && !Array.isArray(given)) {
|
|
235
238
|
warnings.push('`structures` is not an array and was ignored');
|
|
@@ -245,6 +248,7 @@ export function normalizeLaunch(launch) {
|
|
|
245
248
|
warnings,
|
|
246
249
|
geneModel: looksUpGene &&
|
|
247
250
|
!!structure.uniprotId &&
|
|
251
|
+
structure.alphaFoldComplexId === undefined &&
|
|
248
252
|
structure.url === undefined &&
|
|
249
253
|
structure.data === undefined
|
|
250
254
|
? 'preferred'
|
|
@@ -282,7 +286,7 @@ export function normalizeLaunch(launch) {
|
|
|
282
286
|
}
|
|
283
287
|
const structure = readStructure(fields, key => `\`structures[${i}].${key}\``, warnings);
|
|
284
288
|
if (!namesSource(structure)) {
|
|
285
|
-
warnings.push(`structures[${i}] names no url, data, uniprotId or pdbId and was omitted`);
|
|
289
|
+
warnings.push(`structures[${i}] names no url, data, uniprotId, alphaFoldComplexId or pdbId and was omitted`);
|
|
286
290
|
return [];
|
|
287
291
|
}
|
|
288
292
|
return [withUrl(structure)];
|
|
@@ -301,7 +305,7 @@ export function normalizeLaunch(launch) {
|
|
|
301
305
|
: {
|
|
302
306
|
error: linkage.gene
|
|
303
307
|
? noStructure
|
|
304
|
-
: 'no entry of `structures` names a url, data, uniprotId or pdbId',
|
|
308
|
+
: 'no entry of `structures` names a url, data, uniprotId, alphaFoldComplexId or pdbId',
|
|
305
309
|
warnings,
|
|
306
310
|
};
|
|
307
311
|
}
|
|
@@ -87,13 +87,14 @@ const GenomeTrackColorDialog = observer(function GenomeTrackColorDialog({ model,
|
|
|
87
87
|
React.createElement(Button, { variant: "contained", disabled: !trackId || cutsInvalid, onClick: () => {
|
|
88
88
|
// the same track on the same scale keeps what a session wrote
|
|
89
89
|
// beside it: its palette, labels, title and domain, and the same
|
|
90
|
-
// track its scoreField, which a count does not read
|
|
90
|
+
// track its filter, and its scoreField, which a count does not read
|
|
91
91
|
const sameTrack = color.field === 'track' && color.trackId === trackId;
|
|
92
92
|
const kept = sameTrack &&
|
|
93
93
|
(color.scale === 'threshold') === (scale === 'threshold')
|
|
94
94
|
? color
|
|
95
95
|
: undefined;
|
|
96
96
|
const scoreField = sameTrack && stat !== 'count' ? color.scoreField : undefined;
|
|
97
|
+
const filter = sameTrack ? color.filter : undefined;
|
|
97
98
|
const sameBands = kept?.range?.length === (cuts?.length ?? 0) + 1;
|
|
98
99
|
model.setColor(scale === 'threshold' && cuts
|
|
99
100
|
? {
|
|
@@ -102,6 +103,7 @@ const GenomeTrackColorDialog = observer(function GenomeTrackColorDialog({ model,
|
|
|
102
103
|
trackId,
|
|
103
104
|
stat,
|
|
104
105
|
scoreField,
|
|
106
|
+
filter,
|
|
105
107
|
scale,
|
|
106
108
|
domain: cuts,
|
|
107
109
|
range: sameBands
|
|
@@ -109,7 +111,14 @@ const GenomeTrackColorDialog = observer(function GenomeTrackColorDialog({ model,
|
|
|
109
111
|
: thresholdRange(cuts.length + 1),
|
|
110
112
|
labels: sameBands ? kept.labels : undefined,
|
|
111
113
|
}
|
|
112
|
-
: {
|
|
114
|
+
: {
|
|
115
|
+
...kept,
|
|
116
|
+
field: 'track',
|
|
117
|
+
trackId,
|
|
118
|
+
stat,
|
|
119
|
+
scoreField,
|
|
120
|
+
filter,
|
|
121
|
+
});
|
|
113
122
|
handleClose();
|
|
114
123
|
} }, "Color"))));
|
|
115
124
|
});
|
|
@@ -5,11 +5,12 @@ export const EMPTY_EXON_COLOR = { ...RESIDUE_COLORS.exon };
|
|
|
5
5
|
function isUtr(type) {
|
|
6
6
|
return type !== undefined && /utr/i.test(type);
|
|
7
7
|
}
|
|
8
|
+
export const MAX_ALIGNMENT_GAP_BP = 9;
|
|
8
9
|
function mergedBlocks(rows) {
|
|
9
10
|
const merged = [];
|
|
10
11
|
for (const { start, end } of rows.toSorted((a, b) => a.start - b.start)) {
|
|
11
12
|
const last = merged.at(-1);
|
|
12
|
-
if (last && start
|
|
13
|
+
if (last && start - last.end <= MAX_ALIGNMENT_GAP_BP) {
|
|
13
14
|
last.end = Math.max(last.end, end);
|
|
14
15
|
}
|
|
15
16
|
else {
|
|
@@ -21,7 +22,8 @@ function mergedBlocks(rows) {
|
|
|
21
22
|
/**
|
|
22
23
|
* A transcript's exons in transcript order. Its `exon` rows when it has them;
|
|
23
24
|
* otherwise its CDS and UTR rows, joined where they touch, which rebuilds the
|
|
24
|
-
* exons a BED12 or bigBed transcript implies.
|
|
25
|
+
* exons a BED12 or bigBed transcript implies. Blocks a gap too short to be an
|
|
26
|
+
* intron separates are one exon.
|
|
25
27
|
*/
|
|
26
28
|
export function transcriptExons(feature) {
|
|
27
29
|
const rows = feature.subfeatures ?? [];
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { predicateListProblems } from './fieldPredicates';
|
|
2
|
+
/**
|
|
3
|
+
* A field of a feature by the name jbrowse-components' displays read it by:
|
|
4
|
+
* the whole name first, then a dotted path into a structured field, so
|
|
5
|
+
* `INFO.AF` reads a VCF record's INFO and `INFO.AF.1` its second allele's.
|
|
6
|
+
*/
|
|
7
|
+
export function readFeatureField(feature, name) {
|
|
8
|
+
const whole = feature.get(name);
|
|
9
|
+
const path = name.split('.');
|
|
10
|
+
return whole !== undefined || path.length === 1
|
|
11
|
+
? whole
|
|
12
|
+
: path
|
|
13
|
+
.slice(1)
|
|
14
|
+
.reduce((value, key) => typeof value === 'object' && value !== null
|
|
15
|
+
? Reflect.get(value, key)
|
|
16
|
+
: undefined, feature.get(path[0]));
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A field's value as one number. A list, such as a multi-allelic site's
|
|
20
|
+
* `INFO.AF`, gives its highest entry, as overlapping features give a base
|
|
21
|
+
* their highest score; a string a VCF header left untyped is read as a number.
|
|
22
|
+
*/
|
|
23
|
+
export function numberOfField(value) {
|
|
24
|
+
const items = Array.isArray(value) ? value : [value];
|
|
25
|
+
const numbers = items
|
|
26
|
+
.map(v => typeof v === 'string' && v.trim() !== ''
|
|
27
|
+
? Number(v)
|
|
28
|
+
: typeof v === 'number'
|
|
29
|
+
? v
|
|
30
|
+
: Number.NaN)
|
|
31
|
+
.filter(Number.isFinite);
|
|
32
|
+
return numbers.length > 0 ? Math.max(...numbers) : Number.NaN;
|
|
33
|
+
}
|
|
34
|
+
export function isFeatureFieldName(field) {
|
|
35
|
+
return typeof field === 'string' && field !== '' && !field.startsWith('jexl:');
|
|
36
|
+
}
|
|
37
|
+
const GRAMMAR = {
|
|
38
|
+
kindOf: field => (isFeatureFieldName(field) ? 'string or number' : undefined),
|
|
39
|
+
fields: 'a feature field name such as FILTER or INFO.AF, not a jexl: expression',
|
|
40
|
+
example: "{ field: 'FILTER', equal: 'PASS' }",
|
|
41
|
+
};
|
|
42
|
+
/** What is wrong with a track color's `filter`, one line each; empty when
|
|
43
|
+
* nothing is. */
|
|
44
|
+
export function featureFilterProblems(filter, where = 'filter') {
|
|
45
|
+
return predicateListProblems(filter, where, GRAMMAR);
|
|
46
|
+
}
|
|
47
|
+
function entryEquals(entry, expected) {
|
|
48
|
+
return typeof expected === 'number'
|
|
49
|
+
? numberOfField(entry) === expected
|
|
50
|
+
: entry === expected;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Whether a feature passes one predicate. A list, such as the failed filters
|
|
54
|
+
* a VCF record's FILTER names, passes `equal` and `oneOf` when any entry
|
|
55
|
+
* does; the bounds test the field's number as `scoreField` reads it, a list's
|
|
56
|
+
* highest. A field the feature lacks passes no test.
|
|
57
|
+
*/
|
|
58
|
+
function passes(feature, predicate) {
|
|
59
|
+
const { field, equal, lt, lte, gt, gte, range, oneOf } = predicate;
|
|
60
|
+
const value = readFeatureField(feature, field);
|
|
61
|
+
const entries = Array.isArray(value) ? value : [value];
|
|
62
|
+
const n = numberOfField(value);
|
|
63
|
+
return ((equal === undefined || entries.some(e => entryEquals(e, equal))) &&
|
|
64
|
+
(oneOf === undefined ||
|
|
65
|
+
entries.some(e => oneOf.some(o => entryEquals(e, o)))) &&
|
|
66
|
+
(lt === undefined || n < lt) &&
|
|
67
|
+
(lte === undefined || n <= lte) &&
|
|
68
|
+
(gt === undefined || n > gt) &&
|
|
69
|
+
(gte === undefined || n >= gte) &&
|
|
70
|
+
(range === undefined || (n >= range[0] && n <= range[1])));
|
|
71
|
+
}
|
|
72
|
+
export function passesFeatureFilter(feature, filter) {
|
|
73
|
+
return filter.every(predicate => passes(feature, predicate));
|
|
74
|
+
}
|
|
75
|
+
function predicateLabel({ field, equal, lt, lte, gt, gte, range, oneOf, }) {
|
|
76
|
+
return [
|
|
77
|
+
...(equal === undefined ? [] : [`${field} = ${equal}`]),
|
|
78
|
+
...(oneOf === undefined ? [] : [`${field} = ${oneOf.join(' or ')}`]),
|
|
79
|
+
...(gt === undefined ? [] : [`${field} > ${gt}`]),
|
|
80
|
+
...(gte === undefined ? [] : [`${field} ≥ ${gte}`]),
|
|
81
|
+
...(lt === undefined ? [] : [`${field} < ${lt}`]),
|
|
82
|
+
...(lte === undefined ? [] : [`${field} ≤ ${lte}`]),
|
|
83
|
+
...(range === undefined ? [] : [`${field} ${range[0]}–${range[1]}`]),
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
/** A filter as a legend reads it, such as `FILTER = PASS, INFO.AF ≥ 0.01`. */
|
|
87
|
+
export function featureFilterLabel(filter) {
|
|
88
|
+
return filter.flatMap(predicateLabel).join(', ');
|
|
89
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
const KIND_NAMES = {
|
|
2
|
+
number: { one: 'a number', many: 'numbers' },
|
|
3
|
+
string: { one: 'a string', many: 'strings' },
|
|
4
|
+
'string or number': {
|
|
5
|
+
one: 'a string or a number',
|
|
6
|
+
many: 'strings or numbers',
|
|
7
|
+
},
|
|
8
|
+
};
|
|
9
|
+
const BOUNDS = ['lt', 'lte', 'gt', 'gte', 'range'];
|
|
10
|
+
const OPERATORS = ['equal', ...BOUNDS, 'oneOf'];
|
|
11
|
+
const TAKES = `a predicate takes field and one of ${OPERATORS.join(', ')}`;
|
|
12
|
+
function isRecord(x) {
|
|
13
|
+
return typeof x === 'object' && x !== null && !Array.isArray(x);
|
|
14
|
+
}
|
|
15
|
+
function isNumber(value) {
|
|
16
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
17
|
+
}
|
|
18
|
+
function isValue(value, kind) {
|
|
19
|
+
return kind === 'number'
|
|
20
|
+
? isNumber(value)
|
|
21
|
+
: kind === 'string'
|
|
22
|
+
? typeof value === 'string'
|
|
23
|
+
: typeof value === 'string' || isNumber(value);
|
|
24
|
+
}
|
|
25
|
+
function rangeProblems(where, range) {
|
|
26
|
+
const ends = Array.isArray(range) ? range : [];
|
|
27
|
+
const [low, high] = ends;
|
|
28
|
+
return ends.length === 2 && isNumber(low) && isNumber(high)
|
|
29
|
+
? low <= high
|
|
30
|
+
? []
|
|
31
|
+
: [`${where}.range runs low to high; ${low} is above ${high}`]
|
|
32
|
+
: [
|
|
33
|
+
`${where}.range is two numbers, the low and high ends, not ${JSON.stringify(range)}`,
|
|
34
|
+
];
|
|
35
|
+
}
|
|
36
|
+
function operatorProblems(where, kind, key, value) {
|
|
37
|
+
if (key === 'range') {
|
|
38
|
+
return rangeProblems(where, value);
|
|
39
|
+
}
|
|
40
|
+
if (key === 'oneOf') {
|
|
41
|
+
return Array.isArray(value) &&
|
|
42
|
+
value.length > 0 &&
|
|
43
|
+
value.every(v => isValue(v, kind))
|
|
44
|
+
? []
|
|
45
|
+
: [
|
|
46
|
+
`${where}.oneOf is a list of ${KIND_NAMES[kind].many}, not ${JSON.stringify(value)}`,
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
const expected = key === 'equal' ? kind : 'number';
|
|
50
|
+
return isValue(value, expected)
|
|
51
|
+
? []
|
|
52
|
+
: [
|
|
53
|
+
`${where}.${key} is ${KIND_NAMES[expected].one}, not ${JSON.stringify(value)}`,
|
|
54
|
+
];
|
|
55
|
+
}
|
|
56
|
+
/** The lowest and highest number a predicate's bounds admit; an end no bound
|
|
57
|
+
* names is open. */
|
|
58
|
+
function bounds(predicate) {
|
|
59
|
+
const at = (key) => {
|
|
60
|
+
const value = predicate[key];
|
|
61
|
+
return isNumber(value) ? value : undefined;
|
|
62
|
+
};
|
|
63
|
+
const range = Array.isArray(predicate.range) ? predicate.range : [];
|
|
64
|
+
return {
|
|
65
|
+
low: Math.max(at('gt') ?? -Infinity, at('gte') ?? -Infinity, isNumber(range[0]) ? range[0] : -Infinity),
|
|
66
|
+
high: Math.min(at('lt') ?? Infinity, at('lte') ?? Infinity, isNumber(range[1]) ? range[1] : Infinity),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function predicateProblems(where, predicate, grammar) {
|
|
70
|
+
if (!isRecord(predicate)) {
|
|
71
|
+
return [`${where} is an object such as ${grammar.example}`];
|
|
72
|
+
}
|
|
73
|
+
const { field, ...tests } = predicate;
|
|
74
|
+
const kind = grammar.kindOf(field);
|
|
75
|
+
if (kind === undefined) {
|
|
76
|
+
return [`${where}.field is ${grammar.fields}, not ${JSON.stringify(field)}`];
|
|
77
|
+
}
|
|
78
|
+
const named = Object.keys(tests);
|
|
79
|
+
if (named.length === 0) {
|
|
80
|
+
return [`${where} tests nothing: ${TAKES}`];
|
|
81
|
+
}
|
|
82
|
+
const problems = named.flatMap(key => {
|
|
83
|
+
if (!OPERATORS.some(op => op === key)) {
|
|
84
|
+
return [`${where}.${key} is not an operator: ${TAKES}`];
|
|
85
|
+
}
|
|
86
|
+
if (kind === 'string' && BOUNDS.some(op => op === key)) {
|
|
87
|
+
return [
|
|
88
|
+
`${where}.${key} is refused: ${String(field)} is ${KIND_NAMES[kind].one}, so it takes equal or oneOf`,
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
return operatorProblems(where, kind, key, tests[key]);
|
|
92
|
+
});
|
|
93
|
+
if (problems.length > 0) {
|
|
94
|
+
return problems;
|
|
95
|
+
}
|
|
96
|
+
const { low, high } = bounds(tests);
|
|
97
|
+
return low > high
|
|
98
|
+
? [`${where} selects nothing: its bounds run from ${low} to ${high}`]
|
|
99
|
+
: [];
|
|
100
|
+
}
|
|
101
|
+
/** What is wrong with a list of predicates, one line each; empty when
|
|
102
|
+
* nothing is. */
|
|
103
|
+
export function predicateListProblems(predicates, where, grammar) {
|
|
104
|
+
if (predicates === undefined) {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
if (!Array.isArray(predicates)) {
|
|
108
|
+
return [`${where} is a list of predicates such as [${grammar.example}]`];
|
|
109
|
+
}
|
|
110
|
+
return predicates.flatMap((predicate, i) => predicateProblems(`${where}[${i}]`, predicate, grammar));
|
|
111
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { entityUniProtMappings } from 'p2s_mapper';
|
|
2
|
+
const ISOFORM_SUFFIX = /-\d+$/;
|
|
3
|
+
/**
|
|
4
|
+
* The UniProt mappings a model file states for its entities, as SIFTS would
|
|
5
|
+
* give them, so whichever chain the transcript maps to names its own protein.
|
|
6
|
+
* An isoform's entry publishes no features of its own and its AlphaMissense
|
|
7
|
+
* scores number the canonical entry, so an isoform reference places nothing.
|
|
8
|
+
*/
|
|
9
|
+
export function fileUniProtMappings(entities) {
|
|
10
|
+
return entityUniProtMappings(entities ?? []).filter(m => !ISOFORM_SUFFIX.test(m.accession));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The proteins of a complex as its file names them, `GSTM1 + GSTP1` or
|
|
14
|
+
* `SOD1 ×2`, so the view header says what the structure is rather than a
|
|
15
|
+
* model id. Undefined until the file is loaded or when it names no gene.
|
|
16
|
+
*/
|
|
17
|
+
export function complexMembersLabel(entities) {
|
|
18
|
+
const members = (entities ?? []).flatMap(e => {
|
|
19
|
+
const name = e.uniProt?.gene ?? e.uniProt?.accession;
|
|
20
|
+
return name
|
|
21
|
+
? [e.chains.length > 1 ? `${name} ×${e.chains.length}` : name]
|
|
22
|
+
: [];
|
|
23
|
+
});
|
|
24
|
+
return members.length > 0 ? members.join(' + ') : undefined;
|
|
25
|
+
}
|