jbrowse-plugin-protein3d 1.26.0 → 1.27.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 (149) hide show
  1. package/dist/LaunchProteinView/components/PdbSearch.js +14 -3
  2. package/dist/LaunchProteinView/components/StructureSourcePicker.js +7 -4
  3. package/dist/LaunchProteinView/components/UserProvidedStructure.js +7 -3
  4. package/dist/LaunchProteinView/components/clinVarTrack.js +2 -1
  5. package/dist/LaunchProteinView/components/proteinTrackSetup.js +7 -6
  6. package/dist/LaunchProteinView/hooks/useAlphaFoldDBSearch.js +1 -1
  7. package/dist/LaunchProteinView/hooks/useAlphaFoldData.js +3 -3
  8. package/dist/LaunchProteinView/resolveGeneLaunch.js +14 -7
  9. package/dist/LaunchProteinViewExtensionPoint/launchProteinView.js +3 -3
  10. package/dist/LaunchProteinViewExtensionPoint/normalizeAnnotationLaunch.js +1 -11
  11. package/dist/LaunchProteinViewExtensionPoint/normalizeLaunch.js +46 -6
  12. package/dist/ProteinView/alignmentDomains.js +15 -8
  13. package/dist/ProteinView/alignmentSites.js +20 -12
  14. package/dist/ProteinView/applyColorTheme.js +17 -21
  15. package/dist/ProteinView/clinVarSource.js +4 -2
  16. package/dist/ProteinView/colorScale.js +18 -1
  17. package/dist/ProteinView/components/GenomeTrackColorDialog.js +14 -2
  18. package/dist/ProteinView/measurements.js +1 -1
  19. package/dist/ProteinView/model.js +17 -0
  20. package/dist/ProteinView/proteinColor.js +2 -1
  21. package/dist/ProteinView/removeStructure.js +25 -17
  22. package/dist/ProteinView/residueMarks.js +5 -5
  23. package/dist/ProteinView/serialPerPlugin.js +10 -12
  24. package/dist/ProteinView/sessionHighlights.js +18 -18
  25. package/dist/ProteinView/structureCells.js +25 -0
  26. package/dist/ProteinView/structureModel.js +19 -2
  27. package/dist/ProteinView/structurePipeline.js +24 -7
  28. package/dist/ProteinView/structureVisibility.js +13 -8
  29. package/dist/ProteinView/superposeStructures.js +5 -1
  30. package/dist/ProteinView/surface.js +7 -3
  31. package/dist/ProteinView/valueScale.js +14 -3
  32. package/dist/chunks/GenomeTrackColorDialog-NSDPRP6S.js +2 -0
  33. package/dist/chunks/{GenomeTrackColorDialog-FDQKUBYA.js.map → GenomeTrackColorDialog-NSDPRP6S.js.map} +3 -3
  34. package/dist/chunks/LaunchProteinViewDialog-3UHJJ4F3.js +2 -0
  35. package/dist/chunks/LaunchProteinViewDialog-3UHJJ4F3.js.map +7 -0
  36. package/dist/chunks/ProteinView-NKCTUMHE.js +3 -0
  37. package/dist/chunks/{ProteinView-56FHBQSV.js.map → ProteinView-NKCTUMHE.js.map} +1 -1
  38. package/dist/chunks/chunk-4HEBT2RK.js +2 -0
  39. package/dist/chunks/chunk-4HEBT2RK.js.map +7 -0
  40. package/dist/chunks/chunk-4PLPY3PU.js +2 -0
  41. package/dist/chunks/chunk-4PLPY3PU.js.map +7 -0
  42. package/dist/chunks/{chunk-WHJFF2WE.js → chunk-4QUS35JT.js} +2 -2
  43. package/dist/chunks/chunk-6QS4ICXE.js +2 -0
  44. package/dist/chunks/{chunk-ZJ4MV3RK.js.map → chunk-6QS4ICXE.js.map} +2 -2
  45. package/dist/chunks/chunk-6YJLVGGT.js +3 -0
  46. package/dist/chunks/chunk-6YJLVGGT.js.map +7 -0
  47. package/dist/chunks/chunk-BSUQY5VT.js +2 -0
  48. package/dist/chunks/chunk-BSUQY5VT.js.map +7 -0
  49. package/dist/chunks/chunk-HOQSHQW5.js +2 -0
  50. package/dist/chunks/chunk-HOQSHQW5.js.map +7 -0
  51. package/dist/chunks/chunk-JUL2TQ5C.js +2 -0
  52. package/dist/chunks/chunk-JUL2TQ5C.js.map +7 -0
  53. package/dist/chunks/chunk-QMVZ4V22.js +2 -0
  54. package/dist/chunks/{chunk-6B7WZJO7.js.map → chunk-QMVZ4V22.js.map} +4 -4
  55. package/dist/chunks/{chunk-2WSEMZUR.js → chunk-RYRIX2KR.js} +2 -2
  56. package/dist/chunks/{chunk-2WSEMZUR.js.map → chunk-RYRIX2KR.js.map} +3 -3
  57. package/dist/chunks/chunk-XCP2SLKI.js +2 -0
  58. package/dist/chunks/chunk-XCP2SLKI.js.map +7 -0
  59. package/dist/chunks/{clinVarSource-YZSKOR5L.js → clinVarSource-XTPLVQDM.js} +2 -2
  60. package/dist/chunks/launchAnnotationView-TJRIXGO3.js +2 -0
  61. package/dist/chunks/launchAnnotationView-TJRIXGO3.js.map +7 -0
  62. package/dist/chunks/launchProteinView-RLALOTVC.js +2 -0
  63. package/dist/chunks/launchProteinView-RLALOTVC.js.map +7 -0
  64. package/dist/chunks/{launchViewUtils-JLW2J4TI.js → launchViewUtils-EHIAKANZ.js} +2 -2
  65. package/dist/chunks/model-SF6EKGZI.js +2 -0
  66. package/dist/chunks/model-SF6EKGZI.js.map +7 -0
  67. package/dist/chunks/{molstarExports-ZC2DCGMF.js → molstarExports-KVLWAU7L.js} +3 -3
  68. package/dist/chunks/{molstarExports-ZC2DCGMF.js.map → molstarExports-KVLWAU7L.js.map} +1 -1
  69. package/dist/chunks/{resolveGeneLaunch-NI4BGFX5.js → resolveGeneLaunch-VBVWSDZI.js} +2 -2
  70. package/dist/jbrowse-plugin-protein3d.esm.js +1 -1
  71. package/dist/jbrowse-plugin-protein3d.esm.js.map +1 -1
  72. package/dist/version.js +1 -1
  73. package/package.json +1 -1
  74. package/src/LaunchProteinView/components/PdbSearch.tsx +16 -4
  75. package/src/LaunchProteinView/components/StructureSourcePicker.tsx +6 -1
  76. package/src/LaunchProteinView/components/UserProvidedStructure.tsx +7 -2
  77. package/src/LaunchProteinView/components/clinVarTrack.test.ts +35 -31
  78. package/src/LaunchProteinView/components/clinVarTrack.ts +2 -1
  79. package/src/LaunchProteinView/components/proteinTrackSetup.test.ts +42 -25
  80. package/src/LaunchProteinView/components/proteinTrackSetup.ts +7 -6
  81. package/src/LaunchProteinView/hooks/useAlphaFoldDBSearch.ts +1 -1
  82. package/src/LaunchProteinView/hooks/useAlphaFoldData.ts +4 -1
  83. package/src/LaunchProteinView/resolveGeneLaunch.test.ts +13 -0
  84. package/src/LaunchProteinView/resolveGeneLaunch.ts +16 -4
  85. package/src/LaunchProteinViewExtensionPoint/launchProteinView.ts +11 -13
  86. package/src/LaunchProteinViewExtensionPoint/normalizeAnnotationLaunch.ts +1 -15
  87. package/src/LaunchProteinViewExtensionPoint/normalizeLaunch.test.ts +26 -0
  88. package/src/LaunchProteinViewExtensionPoint/normalizeLaunch.ts +82 -7
  89. package/src/ProteinView/alignmentDomains.test.ts +15 -1
  90. package/src/ProteinView/alignmentDomains.ts +19 -9
  91. package/src/ProteinView/alignmentSites.test.ts +32 -0
  92. package/src/ProteinView/alignmentSites.ts +30 -12
  93. package/src/ProteinView/applyColorTheme.ts +24 -39
  94. package/src/ProteinView/clinVarSource.ts +4 -2
  95. package/src/ProteinView/colorScale.ts +33 -1
  96. package/src/ProteinView/components/GenomeTrackColorDialog.tsx +15 -2
  97. package/src/ProteinView/measurements.ts +1 -1
  98. package/src/ProteinView/model.test.ts +20 -0
  99. package/src/ProteinView/model.ts +21 -0
  100. package/src/ProteinView/proteinColor.test.ts +15 -0
  101. package/src/ProteinView/proteinColor.ts +2 -1
  102. package/src/ProteinView/removeStructure.ts +34 -20
  103. package/src/ProteinView/residueMarks.ts +9 -5
  104. package/src/ProteinView/serialPerPlugin.ts +11 -14
  105. package/src/ProteinView/sessionHighlights.test.ts +90 -0
  106. package/src/ProteinView/sessionHighlights.ts +34 -29
  107. package/src/ProteinView/structureCells.ts +46 -0
  108. package/src/ProteinView/structureModel.test.ts +24 -0
  109. package/src/ProteinView/structureModel.ts +19 -2
  110. package/src/ProteinView/structurePipeline.ts +25 -7
  111. package/src/ProteinView/structureVisibility.test.ts +40 -0
  112. package/src/ProteinView/structureVisibility.ts +17 -12
  113. package/src/ProteinView/superposeStructures.ts +9 -1
  114. package/src/ProteinView/surface.ts +8 -3
  115. package/src/ProteinView/valueScale.test.ts +28 -0
  116. package/src/ProteinView/valueScale.ts +16 -3
  117. package/src/version.ts +1 -1
  118. package/dist/chunks/GenomeTrackColorDialog-FDQKUBYA.js +0 -2
  119. package/dist/chunks/LaunchProteinViewDialog-PC5HYIE3.js +0 -2
  120. package/dist/chunks/LaunchProteinViewDialog-PC5HYIE3.js.map +0 -7
  121. package/dist/chunks/ProteinView-56FHBQSV.js +0 -3
  122. package/dist/chunks/chunk-6B7WZJO7.js +0 -2
  123. package/dist/chunks/chunk-6OAZLCO5.js +0 -2
  124. package/dist/chunks/chunk-6OAZLCO5.js.map +0 -7
  125. package/dist/chunks/chunk-DFLRALX5.js +0 -2
  126. package/dist/chunks/chunk-DFLRALX5.js.map +0 -7
  127. package/dist/chunks/chunk-FRK6X72I.js +0 -3
  128. package/dist/chunks/chunk-FRK6X72I.js.map +0 -7
  129. package/dist/chunks/chunk-JPWY4VW7.js +0 -2
  130. package/dist/chunks/chunk-JPWY4VW7.js.map +0 -7
  131. package/dist/chunks/chunk-LK7TA465.js +0 -2
  132. package/dist/chunks/chunk-LK7TA465.js.map +0 -7
  133. package/dist/chunks/chunk-NUJCOEJ3.js +0 -2
  134. package/dist/chunks/chunk-NUJCOEJ3.js.map +0 -7
  135. package/dist/chunks/chunk-RL54DUYZ.js +0 -2
  136. package/dist/chunks/chunk-RL54DUYZ.js.map +0 -7
  137. package/dist/chunks/chunk-W7HIE2HJ.js +0 -2
  138. package/dist/chunks/chunk-W7HIE2HJ.js.map +0 -7
  139. package/dist/chunks/chunk-ZJ4MV3RK.js +0 -2
  140. package/dist/chunks/launchAnnotationView-XEUIILD5.js +0 -2
  141. package/dist/chunks/launchAnnotationView-XEUIILD5.js.map +0 -7
  142. package/dist/chunks/launchProteinView-XUNPJWEY.js +0 -2
  143. package/dist/chunks/launchProteinView-XUNPJWEY.js.map +0 -7
  144. package/dist/chunks/model-QDSVZCTN.js +0 -2
  145. package/dist/chunks/model-QDSVZCTN.js.map +0 -7
  146. /package/dist/chunks/{chunk-WHJFF2WE.js.map → chunk-4QUS35JT.js.map} +0 -0
  147. /package/dist/chunks/{clinVarSource-YZSKOR5L.js.map → clinVarSource-XTPLVQDM.js.map} +0 -0
  148. /package/dist/chunks/{launchViewUtils-JLW2J4TI.js.map → launchViewUtils-EHIAKANZ.js.map} +0 -0
  149. /package/dist/chunks/{resolveGeneLaunch-NI4BGFX5.js.map → resolveGeneLaunch-VBVWSDZI.js.map} +0 -0
@@ -95,10 +95,16 @@ const PdbSearch = observer(function PdbSearch({ feature, preferredTranscriptId,
95
95
  // whichever entry the table had selected instead
96
96
  const launchWaiting = typedPdbIdInvalid ||
97
97
  (typedIdOverrides ? isoformStatuses.some(Boolean) : isLoading);
98
+ // RCSB answering that it has no such entry, as opposed to failing to
99
+ // answer, means the launch would open a view on a 404
100
+ const typedIdUnknown = typedIdOverrides &&
101
+ entryError instanceof Error &&
102
+ 'status' in entryError &&
103
+ entryError.status === 404;
98
104
  const launchError = typedIdOverrides
99
105
  ? launchWaiting
100
106
  ? undefined
101
- : isoformError
107
+ : (isoformError ?? (typedIdUnknown ? entryError : undefined))
102
108
  : error;
103
109
  // Loading or failed, the lookup can still hold the previous query's
104
110
  // accession, which would name the view and its 1D entry
@@ -112,10 +118,15 @@ const PdbSearch = observer(function PdbSearch({ feature, preferredTranscriptId,
112
118
  React.createElement(UniProtLookupResults, { lookup: lookup }),
113
119
  React.createElement(TextField, { size: "small", label: "PDB ID", placeholder: "e.g. 1TUP", helperText: typedPdbIdInvalid
114
120
  ? 'A PDB ID is four characters beginning with a digit'
115
- : 'Overrides the selection below', error: typedPdbIdInvalid, value: typedPdbId, onChange: event => {
121
+ : typedIdUnknown
122
+ ? `RCSB has no entry ${debouncedTypedPdbId.toUpperCase()}`
123
+ : 'Overrides the selection below', error: typedPdbIdInvalid || typedIdUnknown, value: typedPdbId, onChange: event => {
116
124
  setTypedPdbId(event.target.value);
117
125
  }, slotProps: { inputLabel: { shrink: true } }, sx: { width: 240 } }),
118
- uniprotId && entries && !isPdbLoading ? (entries.length > 0 ? (React.createElement(PdbResultsTable, { entries: entries, selectedPdbId: selectedPdbId, onSelect: setUserPdbId })) : (React.createElement(Typography, null,
126
+ uniprotId && entries && !isPdbLoading ? (entries.length > 0 ? (React.createElement(PdbResultsTable, { entries: entries, selectedPdbId: selectedPdbId, onSelect: pdbId => {
127
+ setUserPdbId(pdbId);
128
+ setTypedPdbId('');
129
+ } })) : (React.createElement(Typography, null,
119
130
  "RCSB lists no experimental structure for",
120
131
  ' ',
121
132
  React.createElement(ExternalLink, { href: uniprotEntryUrl(uniprotId) }, uniprotId),
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { Button, FormControl, FormControlLabel, Radio, RadioGroup, TextField, Typography, } from '@mui/material';
3
3
  import HelpButton from './HelpButton';
4
4
  import { STRUCTURE_FILE_ACCEPT } from '../utils/readStructureFile';
5
- export default function StructureSourcePicker({ choice, setChoice, structureURL, setStructureURL, setFile, }) {
5
+ export default function StructureSourcePicker({ choice, setChoice, structureURL, setStructureURL, file, setFile, }) {
6
6
  return (React.createElement("div", { style: { display: 'flex', margin: 30 } },
7
7
  React.createElement(Typography, null,
8
8
  "Open your structure file ",
@@ -11,8 +11,8 @@ export default function StructureSourcePicker({ choice, setChoice, structureURL,
11
11
  React.createElement(RadioGroup, { value: choice, onChange: event => {
12
12
  setChoice(event.target.value);
13
13
  } },
14
- React.createElement(FormControlLabel, { value: "url", control: React.createElement(Radio, null), label: "URL" }),
15
- React.createElement(FormControlLabel, { value: "file", control: React.createElement(Radio, null), label: "File" }))),
14
+ React.createElement(FormControlLabel, { value: "file", control: React.createElement(Radio, null), label: "File" }),
15
+ React.createElement(FormControlLabel, { value: "url", control: React.createElement(Radio, null), label: "URL" }))),
16
16
  choice === 'url' ? (React.createElement("div", null,
17
17
  React.createElement(Typography, null, "Open a PDB/mmCIF/etc. file from remote URL"),
18
18
  React.createElement(TextField, { label: "URL", value: structureURL, onChange: event => {
@@ -26,5 +26,8 @@ export default function StructureSourcePicker({ choice, setChoice, structureURL,
26
26
  if (f) {
27
27
  setFile(f);
28
28
  }
29
- } }))))));
29
+ // picking the same file again, edited, fires a change
30
+ target.value = '';
31
+ } })),
32
+ file ? React.createElement(Typography, { variant: "body2" }, file.name) : null))));
30
33
  }
@@ -51,7 +51,10 @@ const UserProvidedStructure = observer(function UserProvidedStructure({ feature,
51
51
  structureSequences,
52
52
  preferredTranscriptId,
53
53
  });
54
- const error = isoformError ?? fileError ?? launchError;
54
+ const error = launchError ?? isoformError ?? fileError;
55
+ // a structure that failed to read would open an empty view; an error from
56
+ // the url as it stood before the latest typing does not count
57
+ const readFailed = !!fileError && activeURL === debouncedURL;
55
58
  // Until the structure is read the ranking has none and orders the isoforms
56
59
  // by length, so a launch that takes the ranked default waits. The
57
60
  // right-clicked isoform needs no ranking and launches at once.
@@ -61,6 +64,7 @@ const UserProvidedStructure = observer(function UserProvidedStructure({ feature,
61
64
  !!protein &&
62
65
  !!selectedTranscript &&
63
66
  !awaitsStructure &&
67
+ !readFailed &&
64
68
  !launching;
65
69
  const sequencesDiffer = !!protein?.seq &&
66
70
  !!structureSequence &&
@@ -85,12 +89,12 @@ const UserProvidedStructure = observer(function UserProvidedStructure({ feature,
85
89
  React.createElement(DialogContent, { className: classes.dialogContent },
86
90
  error ? React.createElement(ErrorMessage, { error: error }) : null,
87
91
  React.createElement(HelpText, null),
88
- React.createElement(StructureSourcePicker, { choice: choice, setChoice: setChoice, structureURL: structureURL, setStructureURL: setStructureURL, setFile: setFile }),
92
+ React.createElement(StructureSourcePicker, { choice: choice, setChoice: setChoice, structureURL: structureURL, setStructureURL: setStructureURL, file: file, setFile: setFile }),
89
93
  React.createElement("div", { style: { margin: 20 } },
90
94
  isStructureLoading ? (React.createElement(LoadingEllipses, { variant: "subtitle2", message: "Reading residues from the structure" })) : null,
91
95
  React.createElement(PartialFailureNotice, { message: isoformPartialFailure }),
92
96
  isRanking ? (React.createElement(LoadingEllipses, { variant: "subtitle2", message: "Aligning isoforms to the structure" })) : null,
93
- isoformSequences ? (structureSequence && ranking ? (React.createElement(TranscriptSelector, { val: userSelection, setVal: setUserSelection, structureSequence: structureSequence, isoforms: options, feature: feature, ranking: ranking })) : null) : (React.createElement(LoadingEllipses, { title: "Loading protein sequences", variant: "h6" })))),
97
+ isoformSequences ? (ranking ? (React.createElement(TranscriptSelector, { val: userSelection, setVal: setUserSelection, structureSequence: structureSequence, isoforms: options, feature: feature, ranking: ranking })) : null) : (React.createElement(LoadingEllipses, { title: "Loading protein sequences", variant: "h6" })))),
94
98
  React.createElement(DialogActions, null,
95
99
  sequencesDiffer ? React.createElement(SequenceMismatchNotice, null) : null,
96
100
  React.createElement(Button, { variant: "contained", color: "secondary", onClick: () => {
@@ -1,4 +1,5 @@
1
1
  import { CLINVAR_CATEGORIES, clinVarCategory } from '../../ProteinView/clinVar';
2
+ import { colorChannel } from '../../ProteinView/colorScale';
2
3
  // The structure's ClinVar coloring counts pathogenic calls in reds; the track
3
4
  // shows every classification, so the reds are kept for the pathogenic end,
4
5
  // greens for the benign end, and greys for what ClinVar cannot decide.
@@ -74,7 +75,7 @@ export function clinVarTrackConf({ uniprotId, idPrefix, features, }) {
74
75
  {
75
76
  type: 'LinearBasicDisplay',
76
77
  displayId: `${trackId}-LinearBasicDisplay`,
77
- color: CLINVAR_CATEGORY_COLOR,
78
+ encoding: { color: colorChannel(CLINVAR_CATEGORY_COLOR) },
78
79
  },
79
80
  ],
80
81
  };
@@ -1,14 +1,15 @@
1
1
  import { myfetch, uniprotGffUrl } from 'p2s_mapper';
2
+ import { colorChannel } from '../../ProteinView/colorScale';
2
3
  import { RESIDUE_COLORS } from '../../ProteinView/residueColors';
3
4
  import { UNIPROT_FEATURE_COLOR } from '../../ProteinView/uniprotFeatureTypes';
4
5
  // A quantitative display's color reads only `score`, and a linear one ramps
5
6
  // across the plot's y domain, so it takes the ramp's stops, middle and title
6
7
  function wiggleColor(color) {
7
8
  if (color.scale === 'threshold') {
8
- return { ...color, field: 'score' };
9
+ return colorChannel({ ...color, field: 'score' });
9
10
  }
10
11
  const { scale, range, domainMid, title } = color;
11
- return { field: 'score', scale, range, domainMid, title };
12
+ return colorChannel({ field: 'score', scale, range, domainMid, title });
12
13
  }
13
14
  export async function fetchUniProtFeatureTypes(uniprotId) {
14
15
  const data = await (await myfetch(uniprotGffUrl(uniprotId))).text();
@@ -41,8 +42,8 @@ function uniProtFeatureTrackConf({ uniprotId, featureTypes, idPrefix, }) {
41
42
  {
42
43
  displayId: `${trackId}-LinearBasicDisplay`,
43
44
  type: 'LinearBasicDisplay',
44
- color: UNIPROT_FEATURE_COLOR,
45
- facet: { field: 'type', domain: UNIPROT_FEATURE_COLOR.domain },
45
+ encoding: { color: colorChannel(UNIPROT_FEATURE_COLOR) },
46
+ facet: { field: 'type', sort: UNIPROT_FEATURE_COLOR.domain },
46
47
  height: Math.min(450, 60 + 26 * featureTypes.length),
47
48
  },
48
49
  ],
@@ -78,7 +79,7 @@ function alphaFoldConfidenceTrackConf({ uniprotId, confidenceUrl, idPrefix, }) {
78
79
  {
79
80
  type: 'LinearWiggleDisplay',
80
81
  displayId: `${idPrefix}-AlphaFold-confidence-LinearWiggleDisplay`,
81
- color: wiggleColor(RESIDUE_COLORS.plddt),
82
+ encoding: { color: wiggleColor(RESIDUE_COLORS.plddt) },
82
83
  },
83
84
  ],
84
85
  };
@@ -100,7 +101,7 @@ function alphaMissenseTrackConf(uniprotId, idPrefix) {
100
101
  type: 'LinearWiggleDisplay',
101
102
  displayId: `${idPrefix}-AlphaMissense-scores-LinearWiggleDisplay`,
102
103
  defaultRendering: 'density',
103
- color: wiggleColor(RESIDUE_COLORS.alphaMissense),
104
+ encoding: { color: wiggleColor(RESIDUE_COLORS.alphaMissense) },
104
105
  },
105
106
  ],
106
107
  };
@@ -4,7 +4,7 @@ import useAlphaFoldData from './useAlphaFoldData';
4
4
  import useTranscriptIsoformSelection from './useTranscriptIsoformSelection';
5
5
  export default function useAlphaFoldDBSearch({ feature, view, lookup, preferredTranscriptId, }) {
6
6
  const { uniprotId, isLookupLoading } = lookup;
7
- const { isLoading: isAlphaFoldLoading, isValidating: isAlphaFoldValidating, modelsUnreachable, model, noModel, } = useAlphaFoldData({ uniprotId, feature, view });
7
+ const { isLoading: isAlphaFoldLoading, isValidating: isAlphaFoldValidating, modelsUnreachable, model, noModel, } = useAlphaFoldData({ uniprotId, feature, view, preferredTranscriptId });
8
8
  // a stable array, or the isoform picker realigns on every render
9
9
  const modelSequence = model?.sequence;
10
10
  const structureSequences = useMemo(() => (modelSequence ? [modelSequence] : undefined), [modelSequence]);
@@ -8,14 +8,14 @@ import { launchAlphaFoldModel } from '../resolveGeneLaunch';
8
8
  * The AlphaFold DB model a launch opens for this gene's accession, the
9
9
  * canonical file when the API does not answer.
10
10
  */
11
- export default function useAlphaFoldData({ uniprotId, feature, view, }) {
11
+ export default function useAlphaFoldData({ uniprotId, feature, view, preferredTranscriptId, }) {
12
12
  const { data, isLoading, isValidating, error } = useSWR(uniprotId ? ['alphafold-models', uniprotId] : null, ([, id]) => fetchAlphaFoldModels(id), { ...STATIC_SWR_OPTIONS, keepPreviousData: true });
13
13
  const { isoformSequences } = useIsoformProteinSequences({ feature, view });
14
14
  // keepPreviousData hands back the last accession's models after an error
15
15
  // and after the accession is cleared, when the key is null
16
16
  const model = useMemo(() => uniprotId && (data || error)
17
- ? launchAlphaFoldModel(uniprotId, error ? undefined : data, isoformSequences)
18
- : undefined, [uniprotId, data, error, isoformSequences]);
17
+ ? launchAlphaFoldModel(uniprotId, error ? undefined : data, isoformSequences, preferredTranscriptId)
18
+ : undefined, [uniprotId, data, error, isoformSequences, preferredTranscriptId]);
19
19
  const modelsUnreachable = uniprotId ? error : undefined;
20
20
  return {
21
21
  isLoading,
@@ -1,5 +1,5 @@
1
1
  import { getConf } from '@jbrowse/core/configuration';
2
- import { fetchAlphaFoldModels, getAlphaFoldStructureUrl, pickAlphaFoldModel, searchUniProtEntries, } from 'p2s_mapper';
2
+ import { fetchAlphaFoldModels, getAlphaFoldStructureUrl, pickAlphaFoldModel, searchUniProtEntries, stripStopCodon, } from 'p2s_mapper';
3
3
  import { codingTranscripts, flaggedTranscriptId } from './codingFeature';
4
4
  import { rankIsoforms, rankedTranscriptId, } from '../AlignTranscriptRpc/isoformRanking';
5
5
  import { fetchTranscriptProteinSeqs } from './utils/translateTranscripts';
@@ -9,12 +9,19 @@ import { alignOffThread } from '../ProteinView/alignOffThread';
9
9
  * The AlphaFold file a launch opens, `models` undefined when the API did not
10
10
  * answer. That says nothing about the accession, so the spelled canonical
11
11
  * filename is worth a try; an API answering with no models has said there is
12
- * nothing to open. The structure loader draws the same line.
12
+ * nothing to open. The structure loader draws the same line. An isoform the
13
+ * user right-clicked opens its own model when AlphaFold DB has one, where the
14
+ * pick over every isoform would take the canonical model first.
13
15
  */
14
- export function launchAlphaFoldModel(uniprotId, models, isoformSequences) {
15
- return models
16
- ? pickAlphaFoldModel(models, isoformSequences)
17
- : { accession: uniprotId, url: getAlphaFoldStructureUrl(uniprotId) };
16
+ export function launchAlphaFoldModel(uniprotId, models, isoformSequences, preferredTranscriptId) {
17
+ if (!models) {
18
+ return { accession: uniprotId, url: getAlphaFoldStructureUrl(uniprotId) };
19
+ }
20
+ const preferred = preferredTranscriptId === undefined
21
+ ? undefined
22
+ : isoformSequences?.[preferredTranscriptId];
23
+ const own = preferred && models.find(m => m.sequence === stripStopCodon(preferred.seq));
24
+ return own ?? pickAlphaFoldModel(models, isoformSequences);
18
25
  }
19
26
  /** Why a resolved gene has no structure to open. */
20
27
  export function describeMissingStructure(geneName, { uniprotId, lookupError }) {
@@ -113,7 +120,7 @@ export async function resolveGeneLaunch({ host, feature, preferredTranscriptId,
113
120
  seq: t.seq,
114
121
  }));
115
122
  const model = uniprotId
116
- ? launchAlphaFoldModel(uniprotId, await host.fetchAlphaFoldModels(uniprotId).catch(() => undefined), Object.fromEntries(isoforms.map(i => [i.id, { seq: i.seq ?? '' }])))
123
+ ? launchAlphaFoldModel(uniprotId, await host.fetchAlphaFoldModels(uniprotId).catch(() => undefined), Object.fromEntries(isoforms.map(i => [i.id, { seq: i.seq ?? '' }])), preferredTranscriptId)
117
124
  : undefined;
118
125
  const url = model?.url;
119
126
  const structureSequences = model?.sequence ? [model.sequence] : [];
@@ -31,8 +31,7 @@ export function launchViewSettings({ alignmentAlgorithm, color, colorScheme, ...
31
31
  * `jb.addView` the launch failed rather than that it opened a genome view.
32
32
  */
33
33
  export async function launchProteinView(args) {
34
- const { session, uniprotId, transcriptId, userProvidedTranscriptSequence, feature, connectedViewId, connectedView: givenConnectedView, gene, sideBySide, } = args;
35
- const { session: _session, ...launch } = args;
34
+ const { session, ...launch } = args;
36
35
  const normalized = normalizeLaunch(launch);
37
36
  for (const warning of normalized.warnings) {
38
37
  console.warn(warning);
@@ -41,7 +40,8 @@ export async function launchProteinView(args) {
41
40
  if ('error' in normalized) {
42
41
  throw new Error(normalized.error);
43
42
  }
44
- const { geneModel } = normalized;
43
+ const { geneModel, linkage } = normalized;
44
+ const { uniprotId, transcriptId, userProvidedTranscriptSequence, feature, connectedViewId, connectedView: givenConnectedView, gene, sideBySide, } = linkage;
45
45
  const settings = launchViewSettings(normalized.settings);
46
46
  // A gene name alone: the host's text search finds the gene, and the
47
47
  // launch dialog's defaults pick its isoform and AlphaFold model. A
@@ -1,4 +1,4 @@
1
- import { isRecord, isString } from './normalizeLaunch';
1
+ import { isConnectedViewSpec, isString } from './normalizeLaunch';
2
2
  const ANNOTATION_KEYS = [
3
3
  'uniprotId',
4
4
  'gene',
@@ -9,16 +9,6 @@ const ANNOTATION_KEYS = [
9
9
  function isAnnotationKey(key) {
10
10
  return ANNOTATION_KEYS.some(k => k === key);
11
11
  }
12
- function isTrackSpec(value) {
13
- return isString(value) || isRecord(value);
14
- }
15
- function isConnectedViewSpec(value) {
16
- return (isRecord(value) &&
17
- (value.loc === undefined || isString(value.loc)) &&
18
- (value.assembly === undefined || isString(value.assembly)) &&
19
- (value.tracks === undefined ||
20
- (Array.isArray(value.tracks) && value.tracks.every(isTrackSpec))));
21
- }
22
12
  /**
23
13
  * A `ProteinAnnotationView` spec out of untyped fields. An unknown key or a
24
14
  * value of the wrong type is reported and left out; only a launch naming no
@@ -72,6 +72,16 @@ export function isPairwiseAlignment(value) {
72
72
  value.alns.length === 2 &&
73
73
  value.alns.every(isAlignmentRow));
74
74
  }
75
+ function isTrackSpec(value) {
76
+ return isString(value) || isRecord(value);
77
+ }
78
+ export function isConnectedViewSpec(value) {
79
+ return (isRecord(value) &&
80
+ (value.loc === undefined || isString(value.loc)) &&
81
+ (value.assembly === undefined || isString(value.assembly)) &&
82
+ (value.tracks === undefined ||
83
+ (Array.isArray(value.tracks) && value.tracks.every(isTrackSpec))));
84
+ }
75
85
  const RANGES = '{ start, end } numbers or an array of them';
76
86
  /**
77
87
  * Launch text comes from a url, and the view model throws on a wrongly typed
@@ -95,6 +105,22 @@ const LAUNCH_KEYS = [
95
105
  'connectedView',
96
106
  'sideBySide',
97
107
  ];
108
+ // `uniprotId` is a structure's source too, which readStructure reports, so
109
+ // a wrongly typed one is left out here without a second warning
110
+ function readLinkage(fields, warnings) {
111
+ const read = fieldReader(fields, key => `\`${key}\``, warnings);
112
+ const uniprotId = fields.get('uniprotId');
113
+ return {
114
+ gene: read('gene', isString, 'a string'),
115
+ transcriptId: read('transcriptId', isString, 'a string'),
116
+ uniprotId: isString(uniprotId) ? uniprotId : undefined,
117
+ connectedView: read('connectedView', isConnectedViewSpec, '{ assembly, loc, tracks }'),
118
+ connectedViewId: read('connectedViewId', isString, 'a string'),
119
+ sideBySide: read('sideBySide', isBoolean, 'true or false'),
120
+ feature: read('feature', isFeature, 'a feature object'),
121
+ userProvidedTranscriptSequence: read('userProvidedTranscriptSequence', isString, 'a string'),
122
+ };
123
+ }
98
124
  function readViewSettings(fields, warnings) {
99
125
  const read = fieldReader(fields, key => `\`${key}\``, warnings);
100
126
  const flag = (key) => read(key, isBoolean, 'true or false');
@@ -155,6 +181,7 @@ export function normalizeLaunch(launch) {
155
181
  const top = new Map(Object.entries(launch));
156
182
  const warnings = [];
157
183
  const settings = readViewSettings(top, warnings);
184
+ const linkage = readLinkage(top, warnings);
158
185
  const known = new Set([
159
186
  ...Object.keys(settings),
160
187
  ...STRUCTURE_KEYS,
@@ -164,8 +191,8 @@ export function normalizeLaunch(launch) {
164
191
  if (unknownKeys.length > 0) {
165
192
  warnings.push(`ignored unknown key(s): ${unknownKeys.join(', ')}`);
166
193
  }
167
- const looksUpGene = !!top.get('gene') && !top.get('userProvidedTranscriptSequence');
168
- const noStructure = top.get('gene')
194
+ const looksUpGene = !!linkage.gene && !linkage.userProvidedTranscriptSequence;
195
+ const noStructure = linkage.gene
169
196
  ? 'the launch names no structure, and `gene` is not looked up beside `userProvidedTranscriptSequence`'
170
197
  : 'No url, data, uniprotId, pdbId or gene provided when launching protein view';
171
198
  const given = top.get('structures');
@@ -179,6 +206,7 @@ export function normalizeLaunch(launch) {
179
206
  return {
180
207
  requested: [withUrl(structure)],
181
208
  settings,
209
+ linkage,
182
210
  warnings,
183
211
  geneModel: looksUpGene &&
184
212
  !!structure.uniprotId &&
@@ -189,7 +217,13 @@ export function normalizeLaunch(launch) {
189
217
  };
190
218
  }
191
219
  return looksUpGene
192
- ? { requested: [structure], settings, warnings, geneModel: 'required' }
220
+ ? {
221
+ requested: [structure],
222
+ settings,
223
+ linkage,
224
+ warnings,
225
+ geneModel: 'required',
226
+ }
193
227
  : { error: noStructure, warnings };
194
228
  }
195
229
  for (const key of STRUCTURE_KEYS) {
@@ -219,12 +253,18 @@ export function normalizeLaunch(launch) {
219
253
  return [withUrl(structure)];
220
254
  });
221
255
  if (requested.length > 0) {
222
- return { requested, settings, warnings };
256
+ return { requested, settings, linkage, warnings };
223
257
  }
224
258
  return looksUpGene
225
- ? { requested: [{}], settings, warnings, geneModel: 'required' }
259
+ ? {
260
+ requested: [{}],
261
+ settings,
262
+ linkage,
263
+ warnings,
264
+ geneModel: 'required',
265
+ }
226
266
  : {
227
- error: top.get('gene')
267
+ error: linkage.gene
228
268
  ? noStructure
229
269
  : 'no entry of `structures` names a url, data, uniprotId or pdbId',
230
270
  warnings,
@@ -60,11 +60,17 @@ function featureOf(value) {
60
60
  }
61
61
  /**
62
62
  * The one reader of msaview's `connectedDomains`, duck-typed because a store
63
- * install can pair any two versions. Takes the current shape, features plus a
64
- * color object, and msaview 5.5.0's, an array of features each carrying its
65
- * own `color` and no `kind`, which it reads as domains. Undefined for anything
66
- * else and for no features. An accession past the end of `range` has no color,
67
- * so the reader drops it from `domain` and its feature is not drawn.
63
+ * install can pair any two versions. Takes three shapes:
64
+ *
65
+ * - features plus a color channel, `{ field, scale: { domain, range, names } }`
66
+ * - msaview 5.6.0 to 5.13.0's features plus a flat color object, `{ field,
67
+ * domain, range, labels }`
68
+ * - msaview 5.5.0's array of features, each carrying its own `color` and no
69
+ * `kind`, read as domains
70
+ *
71
+ * Undefined for anything else and for no features. An accession past the end
72
+ * of `range` has no color, so the reader drops it from `domain` and its
73
+ * feature is not drawn.
68
74
  */
69
75
  export function readConnectedDomains(value) {
70
76
  if (Array.isArray(value)) {
@@ -99,8 +105,9 @@ export function readConnectedDomains(value) {
99
105
  }
100
106
  const features = value.features.flatMap(f => featureOf(f) ?? []);
101
107
  const color = isRecord(value.color) ? value.color : {};
102
- const domain = strings(color.domain);
103
- const range = strings(color.range);
108
+ const scale = isRecord(color.scale) ? color.scale : color;
109
+ const domain = strings(scale.domain);
110
+ const range = strings(scale.range);
104
111
  if (features.length === 0 || !domain || !range) {
105
112
  return undefined;
106
113
  }
@@ -111,7 +118,7 @@ export function readConnectedDomains(value) {
111
118
  field: 'accession',
112
119
  domain: drawn,
113
120
  range,
114
- labels: strings(color.labels) ?? drawn,
121
+ labels: strings(scale.names) ?? strings(scale.labels) ?? drawn,
115
122
  },
116
123
  };
117
124
  }
@@ -11,8 +11,10 @@
11
11
  * from the live state tree, as color and removal read them.
12
12
  */
13
13
  import loadMolstar from './loadMolstar';
14
- import { structureRootCell } from './structureCells';
15
- export const SITES_TAG = 'jbrowse-alignment-sites';
14
+ import { drawnTests } from './residueFilter';
15
+ import { serialPerPlugin } from './serialPerPlugin';
16
+ import { SITES_TAG, drawnUnder, structureRootCell } from './structureCells';
17
+ export { SITES_TAG } from './structureCells';
16
18
  // Over twice the preset's 0.15, so a site's side chains stand out from the
17
19
  // ligand and focus sticks around them
18
20
  export const SITE_STICKS = { sizeFactor: 0.35, sizeAspectRatio: 0.6 };
@@ -21,13 +23,13 @@ let revision = 0;
21
23
  * Make each structure's sticks match its sites: create, update, or remove
22
24
  * them when `sites` is empty or undefined.
23
25
  */
24
- export async function syncSiteSticks({ plugin, structures, }) {
26
+ async function drawSiteSticks({ plugin, structures, }) {
25
27
  const molstar = await loadMolstar();
26
28
  const { MolScriptBuilder: MS, ProteinBackboneAtoms, StateSelection, StateTransforms, createStructureColorThemeParams, createStructureRepresentationParams, registerPlacedValues, } = molstar;
27
29
  revision++;
28
30
  const update = plugin.state.data.build();
29
31
  let changed = false;
30
- for (const { molstarStructure, sites, color } of structures) {
32
+ for (const { molstarStructure, sites, color, chains, filter } of structures) {
31
33
  const root = structureRootCell(plugin, molstar, molstarStructure);
32
34
  if (!root) {
33
35
  continue;
@@ -43,6 +45,11 @@ export async function syncSiteSticks({ plugin, structures, }) {
43
45
  continue;
44
46
  }
45
47
  const atom = (name) => MS.core.rel.eq([MS.ammp('label_atom_id'), name]);
48
+ const { chainTest, residueTest } = drawnTests(MS, { chains, filter });
49
+ const isSite = MS.core.set.has([
50
+ MS.set(...labelSeqIds),
51
+ MS.ammp('label_seq_id'),
52
+ ]);
46
53
  const component = {
47
54
  type: {
48
55
  name: 'expression',
@@ -51,10 +58,10 @@ export async function syncSiteSticks({ plugin, structures, }) {
51
58
  MS.ammp('label_entity_id'),
52
59
  sites.entityId,
53
60
  ]),
54
- 'residue-test': MS.core.set.has([
55
- MS.set(...labelSeqIds),
56
- MS.ammp('label_seq_id'),
57
- ]),
61
+ 'residue-test': residueTest
62
+ ? MS.core.logic.and([isSite, residueTest])
63
+ : isSite,
64
+ ...(chainTest ? { 'chain-test': chainTest } : {}),
58
65
  'atom-test': MS.core.logic.or([
59
66
  MS.core.logic.not([
60
67
  MS.core.set.has([
@@ -90,10 +97,8 @@ export async function syncSiteSticks({ plugin, structures, }) {
90
97
  else {
91
98
  update
92
99
  .to(root)
93
- .apply(StateTransforms.Model.StructureComponent, component, {
94
- tags: [SITES_TAG],
95
- })
96
- .apply(StateTransforms.Representation.StructureRepresentation3D, representation, { tags: [SITES_TAG] });
100
+ .apply(StateTransforms.Model.StructureComponent, component, drawnUnder(root, SITES_TAG))
101
+ .apply(StateTransforms.Representation.StructureRepresentation3D, representation, drawnUnder(root, SITES_TAG));
97
102
  }
98
103
  changed = true;
99
104
  }
@@ -101,3 +106,6 @@ export async function syncSiteSticks({ plugin, structures, }) {
101
106
  await update.commit();
102
107
  }
103
108
  }
109
+ export function syncSiteSticks(args) {
110
+ return serialPerPlugin(args.plugin, () => drawSiteSticks(args));
111
+ }
@@ -1,10 +1,8 @@
1
1
  import { EMPTY_DOMAIN_COLOR, domainMarkOf } from './alignmentDomains';
2
- import { SITES_TAG } from './alignmentSites';
3
2
  import loadMolstar from './loadMolstar';
4
3
  import { molstarThemeOf, resolvedColor } from './proteinColor';
5
- import { RESIDUE_MARKS_TAG } from './residueMarks';
6
- import { SESSION_HIGHLIGHTS_TAG } from './sessionHighlights';
7
- import { structureRootCell } from './structureCells';
4
+ import { serialPerPlugin } from './serialPerPlugin';
5
+ import { structureRepresentations, structureRootCell } from './structureCells';
8
6
  import { VARIANT_EFFECT_SCHEMES } from './variantEffects';
9
7
  /**
10
8
  * The themes that color by values placed on each structure's residues, which
@@ -45,9 +43,9 @@ let revision = 0;
45
43
  * placedValueRegistry), registered for each structure before the update; a
46
44
  * structure without values is drawn grey.
47
45
  */
48
- export async function applyColorTheme({ plugin, color, structures, }) {
46
+ async function recolor({ plugin, color, structures, }) {
49
47
  const molstar = await loadMolstar();
50
- const { StateSelection, StateTransforms, createStructureColorThemeParams, registerPlacedValues, } = molstar;
48
+ const { createStructureColorThemeParams, registerPlacedValues } = molstar;
51
49
  const theme = molstarThemeOf(color);
52
50
  const placed = isPlacedValueScheme(theme);
53
51
  if (placed) {
@@ -64,29 +62,27 @@ export async function applyColorTheme({ plugin, color, structures, }) {
64
62
  }
65
63
  const cell = structureRootCell(plugin, molstar, molstarStructure);
66
64
  const representations = cell
67
- ? plugin.state.data.select(StateSelection.Generators.ofTransformer(StateTransforms.Representation.StructureRepresentation3D, cell.transform.ref))
65
+ ? structureRepresentations(plugin, molstar, cell)
68
66
  : [];
69
67
  for (const representation of representations) {
70
- if (!representation.state.isGhost &&
71
- !representation.transform.tags?.includes(SITES_TAG) &&
72
- !representation.transform.tags?.includes(SESSION_HIGHLIGHTS_TAG) &&
73
- !representation.transform.tags?.includes(RESIDUE_MARKS_TAG)) {
74
- update.to(representation).update(prev => {
75
- prev.colorTheme = createStructureColorThemeParams(plugin, molstarStructure, prev.type.name, theme, themeParams(color, {
76
- entityId,
77
- domainColor,
78
- revision,
79
- representationType: prev.type.name,
80
- }));
81
- });
82
- recolored++;
83
- }
68
+ update.to(representation).update(prev => {
69
+ prev.colorTheme = createStructureColorThemeParams(plugin, molstarStructure, prev.type.name, theme, themeParams(color, {
70
+ entityId,
71
+ domainColor,
72
+ revision,
73
+ representationType: prev.type.name,
74
+ }));
75
+ });
76
+ recolored++;
84
77
  }
85
78
  }
86
79
  if (recolored > 0) {
87
80
  await update.commit();
88
81
  }
89
82
  }
83
+ export function applyColorTheme(args) {
84
+ return serialPerPlugin(args.plugin, () => recolor(args));
85
+ }
90
86
  /**
91
87
  * The key Mol* itself would show for a color, which its viewport never draws
92
88
  * and its hidden-by-default controls panel buries. Built on one structure, so a
@@ -47,8 +47,10 @@ export async function placeClinVarOnTranscript({ build, feature, assemblyName, s
47
47
  if (positions.length === 0) {
48
48
  throw new Error('the transcript has no coding sequence');
49
49
  }
50
- const start = Math.min(...positions);
51
- const end = Math.max(...positions) + 1;
50
+ // reduced, not spread: TTN's 100k coding bases pass JavaScriptCore's
51
+ // argument limit
52
+ const start = positions.reduce((a, b) => Math.min(a, b));
53
+ const end = positions.reduce((a, b) => Math.max(a, b)) + 1;
52
54
  const assembly = await session.assemblyManager.waitForAssembly(assemblyName);
53
55
  const [variants, genome] = await Promise.all([
54
56
  readMissense(build, [refName, ...(assembly?.getAliasesForRefName(refName) ?? [])], start, end, signal),
@@ -1,4 +1,20 @@
1
1
  import { colord } from '@jbrowse/core/util/colord';
2
+ /**
3
+ * A color object as a display's `encoding.color`, the spelling JBrowse 5
4
+ * reads: the scale's members under `scale`, `categorical` as `ordinal`,
5
+ * `labels` as `scale.names` and `title` as the key's `legend.title`.
6
+ */
7
+ export function colorChannel({ field, scale, labels, title, ...members }) {
8
+ return {
9
+ field,
10
+ scale: {
11
+ type: scale === 'categorical' ? 'ordinal' : scale,
12
+ ...Object.fromEntries(Object.entries(members).filter(([, value]) => value !== undefined)),
13
+ ...(labels ? { names: labels } : {}),
14
+ },
15
+ ...(title === undefined ? {} : { legend: { title } }),
16
+ };
17
+ }
2
18
  /** A CSS color as RGB. */
3
19
  export function rgbOf(css) {
4
20
  const { r, g, b } = colord(css).toRgb();
@@ -25,7 +41,8 @@ function rampPosition(color, value) {
25
41
  : 0.5 +
26
42
  (value - domainMid) /
27
43
  (2 * Math.max(domainMid - domainMin, domainMax - domainMid));
28
- return Math.max(0, Math.min(1, p));
44
+ // a zero-width domain gives NaN, which would index no stop
45
+ return Number.isNaN(p) ? 0 : Math.max(0, Math.min(1, p));
29
46
  }
30
47
  function rampRgb(color) {
31
48
  const stops = color.range.map(rgbOf);