jbrowse-plugin-protein3d 1.7.0 → 1.9.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 (162) hide show
  1. package/dist/AlignTranscriptRpc/index.js +5 -25
  2. package/dist/AlignTranscriptRpc/isoformRanking.js +24 -0
  3. package/dist/LaunchProteinView/components/FoldseekActionMenu.js +1 -1
  4. package/dist/LaunchProteinView/components/ProteinViewActions.js +1 -3
  5. package/dist/LaunchProteinView/components/UserProvidedStructure.js +1 -1
  6. package/dist/LaunchProteinView/components/clinVarTrack.js +70 -0
  7. package/dist/LaunchProteinView/components/clinVarTrackSource.js +55 -0
  8. package/dist/LaunchProteinView/components/launchProteinAnnotationView.js +26 -9
  9. package/dist/LaunchProteinView/components/proteinTrackSetup.js +5 -18
  10. package/dist/LaunchProteinView/hooks/useIsoformRanking.js +1 -1
  11. package/dist/LaunchProteinView/hooks/useTranscriptSelection.js +1 -1
  12. package/dist/LaunchProteinView/index.js +8 -4
  13. package/dist/LaunchProteinView/resolveGeneLaunch.js +1 -1
  14. package/dist/LaunchProteinView/utils/launchViewUtils.js +5 -2
  15. package/dist/LaunchProteinViewExtensionPoint/annotationView.js +5 -78
  16. package/dist/LaunchProteinViewExtensionPoint/index.js +7 -85
  17. package/dist/LaunchProteinViewExtensionPoint/launchAnnotationView.js +82 -0
  18. package/dist/LaunchProteinViewExtensionPoint/launchProteinView.js +83 -0
  19. package/dist/ProteinView/addProteinView.js +12 -0
  20. package/dist/ProteinView/clinVar.js +101 -32
  21. package/dist/ProteinView/clinVarSource.js +23 -14
  22. package/dist/ProteinView/index.js +1 -2
  23. package/dist/chunks/AddStructureDialog-U6BWWHJW.js +2 -0
  24. package/dist/chunks/{AddStructureDialog-Z5HMGUWS.js.map → AddStructureDialog-U6BWWHJW.js.map} +1 -1
  25. package/dist/chunks/{HelpDialog-GBG7PHDR.js → HelpDialog-XVM5IEP4.js} +2 -2
  26. package/dist/chunks/LaunchProteinViewDialog-KHZEPVNM.js +7 -0
  27. package/dist/chunks/LaunchProteinViewDialog-KHZEPVNM.js.map +7 -0
  28. package/dist/chunks/{ManualAlignmentDialog-B35TUUYU.js → ManualAlignmentDialog-63MGXT7T.js} +2 -2
  29. package/dist/chunks/{ProteinAlignmentHelpDialog-LURGMLCI.js → ProteinAlignmentHelpDialog-BNW2WV6D.js} +2 -2
  30. package/dist/chunks/{ProteinView-DQOR5RTK.js → ProteinView-BDDPQYHT.js} +3 -3
  31. package/dist/chunks/{ProteinView-DQOR5RTK.js.map → ProteinView-BDDPQYHT.js.map} +2 -2
  32. package/dist/chunks/chunk-2VSFBM55.js +2 -0
  33. package/dist/chunks/chunk-2VSFBM55.js.map +7 -0
  34. package/dist/chunks/chunk-56ZPPPNO.js +2 -0
  35. package/dist/chunks/chunk-56ZPPPNO.js.map +7 -0
  36. package/dist/chunks/chunk-C6C6ZP3E.js +2 -0
  37. package/dist/chunks/{clinVarSource-SXH525M3.js.map → chunk-C6C6ZP3E.js.map} +3 -3
  38. package/dist/chunks/chunk-CAYS7ALN.js +2 -0
  39. package/dist/chunks/chunk-CAYS7ALN.js.map +7 -0
  40. package/dist/chunks/chunk-CKT7MHJV.js +2 -0
  41. package/dist/chunks/chunk-CKT7MHJV.js.map +7 -0
  42. package/dist/chunks/chunk-CRY6RO5J.js +2 -0
  43. package/dist/chunks/chunk-CRY6RO5J.js.map +7 -0
  44. package/dist/chunks/{chunk-2CJBOB5B.js → chunk-CU6NAWYQ.js} +2 -2
  45. package/dist/chunks/{chunk-2CJBOB5B.js.map → chunk-CU6NAWYQ.js.map} +1 -1
  46. package/dist/chunks/chunk-GEIZQIY6.js +2 -0
  47. package/dist/chunks/chunk-GEIZQIY6.js.map +7 -0
  48. package/dist/chunks/chunk-HLJP35OE.js +3 -0
  49. package/dist/chunks/chunk-HLJP35OE.js.map +7 -0
  50. package/dist/chunks/chunk-IAAJJTFE.js +2 -0
  51. package/dist/chunks/chunk-IAAJJTFE.js.map +7 -0
  52. package/dist/chunks/chunk-IE75QKW6.js +2 -0
  53. package/dist/chunks/chunk-IE75QKW6.js.map +7 -0
  54. package/dist/chunks/chunk-JGD4QDSN.js +2 -0
  55. package/dist/chunks/chunk-JGD4QDSN.js.map +7 -0
  56. package/dist/chunks/chunk-KMATC3NI.js +2 -0
  57. package/dist/chunks/chunk-KMATC3NI.js.map +7 -0
  58. package/dist/chunks/chunk-LZS4UIBQ.js +2 -0
  59. package/dist/chunks/chunk-LZS4UIBQ.js.map +7 -0
  60. package/dist/chunks/chunk-NC24P2PF.js +2 -0
  61. package/dist/chunks/chunk-NC24P2PF.js.map +7 -0
  62. package/dist/chunks/chunk-NZ3TO6NV.js +2 -0
  63. package/dist/chunks/chunk-NZ3TO6NV.js.map +7 -0
  64. package/dist/chunks/chunk-OGVPIMFY.js +2 -0
  65. package/dist/chunks/chunk-OGVPIMFY.js.map +7 -0
  66. package/dist/chunks/chunk-P24I4JTG.js +2 -0
  67. package/dist/chunks/chunk-P24I4JTG.js.map +7 -0
  68. package/dist/chunks/chunk-Q4RUYXMJ.js +25 -0
  69. package/dist/chunks/chunk-Q4RUYXMJ.js.map +7 -0
  70. package/dist/chunks/chunk-S6PS4I6X.js +2 -0
  71. package/dist/chunks/chunk-S6PS4I6X.js.map +7 -0
  72. package/dist/chunks/{chunk-X5RLRQSB.js → chunk-SIZG3XB4.js} +1 -1
  73. package/dist/chunks/{chunk-X5RLRQSB.js.map → chunk-SIZG3XB4.js.map} +1 -1
  74. package/dist/chunks/{chunk-SQLUPFUS.js → chunk-SPXMXPSC.js} +1 -1
  75. package/dist/chunks/chunk-SPXMXPSC.js.map +7 -0
  76. package/dist/chunks/chunk-TXX67FGG.js +2 -0
  77. package/dist/chunks/chunk-TXX67FGG.js.map +7 -0
  78. package/dist/chunks/chunk-UVDYWAS6.js +2 -0
  79. package/dist/chunks/chunk-UVDYWAS6.js.map +7 -0
  80. package/dist/chunks/chunk-X47I2IB5.js +15 -0
  81. package/dist/chunks/chunk-X47I2IB5.js.map +7 -0
  82. package/dist/chunks/chunk-YCRC6WEC.js +2 -0
  83. package/dist/chunks/chunk-YCRC6WEC.js.map +7 -0
  84. package/dist/chunks/clinVarSource-W77HO5ZQ.js +2 -0
  85. package/dist/chunks/clinVarSource-W77HO5ZQ.js.map +7 -0
  86. package/dist/chunks/esm-AA25HCYO.js +2 -0
  87. package/dist/chunks/esm-AA25HCYO.js.map +7 -0
  88. package/dist/chunks/isoformRanking-BCLW5EL6.js +2 -0
  89. package/dist/chunks/isoformRanking-BCLW5EL6.js.map +7 -0
  90. package/dist/chunks/launchAnnotationView-O4PUPNFA.js +2 -0
  91. package/dist/chunks/launchAnnotationView-O4PUPNFA.js.map +7 -0
  92. package/dist/chunks/launchProteinView-7IHV3Q4W.js +2 -0
  93. package/dist/chunks/launchProteinView-7IHV3Q4W.js.map +7 -0
  94. package/dist/chunks/launchViewUtils-D7FKTS4Q.js +2 -0
  95. package/dist/chunks/launchViewUtils-D7FKTS4Q.js.map +7 -0
  96. package/dist/chunks/model-FQK2TZ5H.js +2 -0
  97. package/dist/chunks/model-FQK2TZ5H.js.map +7 -0
  98. package/dist/chunks/{molstarExports-M6FNLMIU.js → molstarExports-PLBMBP6Q.js} +3 -3
  99. package/dist/chunks/resolveGeneLaunch-FESFI6CM.js +2 -0
  100. package/dist/chunks/resolveGeneLaunch-FESFI6CM.js.map +7 -0
  101. package/dist/index.js +0 -2
  102. package/dist/jbrowse-plugin-protein3d.esm.js +1 -29
  103. package/dist/jbrowse-plugin-protein3d.esm.js.map +4 -4
  104. package/dist/version.js +1 -1
  105. package/package.json +6 -6
  106. package/src/AlignTranscriptRpc/index.ts +6 -48
  107. package/src/AlignTranscriptRpc/isoformRanking.ts +42 -0
  108. package/src/LaunchProteinView/components/FoldseekActionMenu.tsx +1 -1
  109. package/src/LaunchProteinView/components/ProteinViewActions.tsx +3 -3
  110. package/src/LaunchProteinView/components/UserProvidedStructure.tsx +1 -1
  111. package/src/LaunchProteinView/components/clinVarTrack.test.ts +126 -0
  112. package/src/LaunchProteinView/components/clinVarTrack.ts +113 -0
  113. package/src/LaunchProteinView/components/clinVarTrackSource.ts +81 -0
  114. package/src/LaunchProteinView/components/launchProteinAnnotationView.test.ts +78 -4
  115. package/src/LaunchProteinView/components/launchProteinAnnotationView.ts +37 -8
  116. package/src/LaunchProteinView/components/proteinTrackSetup.test.ts +2 -16
  117. package/src/LaunchProteinView/components/proteinTrackSetup.ts +5 -22
  118. package/src/LaunchProteinView/hooks/useIsoformRanking.ts +2 -2
  119. package/src/LaunchProteinView/hooks/useTranscriptSelection.test.ts +1 -1
  120. package/src/LaunchProteinView/hooks/useTranscriptSelection.ts +1 -1
  121. package/src/LaunchProteinView/index.ts +15 -8
  122. package/src/LaunchProteinView/resolveGeneLaunch.test.ts +1 -1
  123. package/src/LaunchProteinView/resolveGeneLaunch.ts +5 -2
  124. package/src/LaunchProteinView/utils/launchViewUtils.ts +6 -2
  125. package/src/LaunchProteinViewExtensionPoint/annotationView.ts +7 -93
  126. package/src/LaunchProteinViewExtensionPoint/index.ts +7 -177
  127. package/src/LaunchProteinViewExtensionPoint/launchAnnotationView.ts +102 -0
  128. package/src/LaunchProteinViewExtensionPoint/launchProteinView.ts +178 -0
  129. package/src/LaunchProteinViewExtensionPoint/launchViewSnapshot.test.ts +1 -1
  130. package/src/ProteinView/addProteinView.ts +18 -0
  131. package/src/ProteinView/clinVar.ts +145 -34
  132. package/src/ProteinView/clinVarMissense.test.ts +131 -0
  133. package/src/ProteinView/clinVarSource.ts +41 -24
  134. package/src/ProteinView/index.ts +1 -3
  135. package/src/index.ts +0 -2
  136. package/src/version.ts +1 -1
  137. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.js +0 -32
  138. package/dist/UniProtVariationAdapter/configSchema.js +0 -19
  139. package/dist/UniProtVariationAdapter/index.js +0 -10
  140. package/dist/chunks/AddStructureDialog-Z5HMGUWS.js +0 -2
  141. package/dist/chunks/UniProtVariationAdapter-2GQU7BV6.js +0 -2
  142. package/dist/chunks/UniProtVariationAdapter-2GQU7BV6.js.map +0 -7
  143. package/dist/chunks/chunk-2U2S5MMZ.js +0 -2
  144. package/dist/chunks/chunk-2U2S5MMZ.js.map +0 -7
  145. package/dist/chunks/chunk-C2KRWQQY.js +0 -2
  146. package/dist/chunks/chunk-C2KRWQQY.js.map +0 -7
  147. package/dist/chunks/chunk-QPR5H2OZ.js +0 -2
  148. package/dist/chunks/chunk-QPR5H2OZ.js.map +0 -7
  149. package/dist/chunks/chunk-RIAQ5NV7.js +0 -2
  150. package/dist/chunks/chunk-RIAQ5NV7.js.map +0 -7
  151. package/dist/chunks/chunk-SQLUPFUS.js.map +0 -7
  152. package/dist/chunks/chunk-TPLXHUOA.js +0 -16
  153. package/dist/chunks/chunk-TPLXHUOA.js.map +0 -7
  154. package/dist/chunks/clinVarSource-SXH525M3.js +0 -2
  155. package/src/UniProtVariationAdapter/UniProtVariationAdapter.ts +0 -65
  156. package/src/UniProtVariationAdapter/configSchema.ts +0 -27
  157. package/src/UniProtVariationAdapter/index.ts +0 -18
  158. package/src/UniProtVariationAdapter/parseUniProtVariants.test.ts +0 -40
  159. /package/dist/chunks/{HelpDialog-GBG7PHDR.js.map → HelpDialog-XVM5IEP4.js.map} +0 -0
  160. /package/dist/chunks/{ManualAlignmentDialog-B35TUUYU.js.map → ManualAlignmentDialog-63MGXT7T.js.map} +0 -0
  161. /package/dist/chunks/{ProteinAlignmentHelpDialog-LURGMLCI.js.map → ProteinAlignmentHelpDialog-BNW2WV6D.js.map} +0 -0
  162. /package/dist/chunks/{molstarExports-M6FNLMIU.js.map → molstarExports-PLBMBP6Q.js.map} +0 -0
@@ -1,47 +1,27 @@
1
1
  import { RpcMethodType } from '@jbrowse/core/pluggableElementTypes';
2
- import { alignTranscriptToEntity, chooseMappedEntity, classifyIsoforms, pickStructureSequence, } from 'p2s_mapper';
3
- /** The launch dialog's isoform order: one alignment per chain to pick the
4
- * chain, then one per isoform that does not match it exactly. */
5
- export function rankIsoforms(isoforms, structureSequences) {
6
- const structureSequence = pickStructureSequence(structureSequences, isoforms);
7
- return {
8
- structureSequence,
9
- ranking: classifyIsoforms({ isoforms, structureSequence }),
10
- };
11
- }
12
- /**
13
- * The isoform to open from a ranking. An exact match to the structure wins;
14
- * the annotation's flagged transcript (MANE Select) breaks a tie between exact
15
- * matches, and leads when there is no structure to rank against, where length
16
- * alone would decide.
17
- */
18
- export function rankedTranscriptId({ matches, nonMatches }, flaggedId) {
19
- const flagged = (list) => list.find(i => i.id === flaggedId);
20
- const unranked = nonMatches.every(i => i.score === undefined);
21
- return (flagged(matches) ??
22
- matches[0] ??
23
- (unranked ? flagged(nonMatches) : undefined) ??
24
- nonMatches[0])?.id;
25
- }
26
2
  // The alignment DP runs ~50 ns a cell, so a 4,000-residue transcript against
27
3
  // its structure is almost a second and a complex of long chains several: on
28
4
  // the main thread, frozen UI. These run it in the host's RPC worker instead,
29
- // or in place on a host whose driver is MainThreadRpcDriver.
5
+ // or in place on a host whose driver is MainThreadRpcDriver. The aligner loads
6
+ // on the first call, so registering the methods costs the plugin's boot nothing.
30
7
  export class ProteinChooseMappedEntity extends RpcMethodType {
31
8
  name = 'ProteinChooseMappedEntity';
32
9
  async execute({ transcript, entities, algorithm }) {
10
+ const { chooseMappedEntity } = await import('p2s_mapper');
33
11
  return chooseMappedEntity(transcript, entities, algorithm);
34
12
  }
35
13
  }
36
14
  export class ProteinAlignTranscriptToEntity extends RpcMethodType {
37
15
  name = 'ProteinAlignTranscriptToEntity';
38
16
  async execute({ transcript, entitySeq, algorithm }) {
17
+ const { alignTranscriptToEntity } = await import('p2s_mapper');
39
18
  return alignTranscriptToEntity(transcript, entitySeq, algorithm);
40
19
  }
41
20
  }
42
21
  export class ProteinRankIsoforms extends RpcMethodType {
43
22
  name = 'ProteinRankIsoforms';
44
23
  async execute({ isoforms, structureSequences }) {
24
+ const { rankIsoforms } = await import('./isoformRanking');
45
25
  return rankIsoforms(isoforms, structureSequences);
46
26
  }
47
27
  }
@@ -0,0 +1,24 @@
1
+ import { classifyIsoforms, pickStructureSequence } from 'p2s_mapper';
2
+ /** The launch dialog's isoform order: one alignment per chain to pick the
3
+ * chain, then one per isoform that does not match it exactly. */
4
+ export function rankIsoforms(isoforms, structureSequences) {
5
+ const structureSequence = pickStructureSequence(structureSequences, isoforms);
6
+ return {
7
+ structureSequence,
8
+ ranking: classifyIsoforms({ isoforms, structureSequence }),
9
+ };
10
+ }
11
+ /**
12
+ * The isoform to open from a ranking. An exact match to the structure wins;
13
+ * the annotation's flagged transcript (MANE Select) breaks a tie between exact
14
+ * matches, and leads when there is no structure to rank against, where length
15
+ * alone would decide.
16
+ */
17
+ export function rankedTranscriptId({ matches, nonMatches }, flaggedId) {
18
+ const flagged = (list) => list.find(i => i.id === flaggedId);
19
+ const unranked = nonMatches.every(i => i.score === undefined);
20
+ return (flagged(matches) ??
21
+ matches[0] ??
22
+ (unranked ? flagged(nonMatches) : undefined) ??
23
+ nonMatches[0])?.id;
24
+ }
@@ -21,7 +21,7 @@ export default function FoldseekActionMenu({ hit, session, view, feature, select
21
21
  const pdbData = !hit.structureUrl && hasValidCaCoords(hit)
22
22
  ? caCoordsToPdb(hit.tCa, hit.tSeq, 'A', hit.target)
23
23
  : undefined;
24
- launch3DProteinView({
24
+ return launch3DProteinView({
25
25
  ...baseParams,
26
26
  url: hit.structureUrl,
27
27
  data: pdbData,
@@ -36,9 +36,7 @@ export default function ProteinViewActions({ handleClose, uniprotId, userSelecte
36
36
  userProvidedTranscriptSequence: userSelectedProteinSequence?.seq,
37
37
  sideBySide,
38
38
  };
39
- const handleLaunch3DView = runLaunch(() => {
40
- launch3DProteinView(launch3DParams);
41
- });
39
+ const handleLaunch3DView = runLaunch(() => launch3DProteinView(launch3DParams));
42
40
  const { launch1D } = getConditionalProteinLaunches({
43
41
  session,
44
42
  view,
@@ -70,7 +70,7 @@ const UserProvidedStructure = observer(function UserProvidedStructure({ feature,
70
70
  const structureData = activeFile
71
71
  ? await readStructureFile(activeFile)
72
72
  : undefined;
73
- launch3DProteinView({
73
+ await launch3DProteinView({
74
74
  session,
75
75
  view,
76
76
  feature,
@@ -0,0 +1,70 @@
1
+ import { clinVarCategory } from '../../ProteinView/clinVar';
2
+ // The structure's clinvar scheme counts pathogenic calls in reds; the track
3
+ // shows every classification, so the reds are kept for the pathogenic end,
4
+ // greens for the benign end, and greys for what ClinVar cannot decide.
5
+ export const CLINVAR_CATEGORY_COLORS = {
6
+ pathogenic: '#a50f15',
7
+ 'likely pathogenic': '#de2d26',
8
+ conflicting: '#fd8d3c',
9
+ uncertain: '#969696',
10
+ 'likely benign': '#74c476',
11
+ benign: '#238b45',
12
+ other: '#bdbdbd',
13
+ };
14
+ /**
15
+ * One feature per placed variant, on the entry's residues. A variant whose
16
+ * residue the entry does not share with the transcript (an isoform's private
17
+ * exon) has nowhere to go and is left out.
18
+ */
19
+ export function clinVarTrackFeatures({ placed, uniprotId, toEntryPosition, }) {
20
+ return placed
21
+ .flatMap(({ variant, residue, from, to }, index) => {
22
+ const position = toEntryPosition(residue);
23
+ if (position === undefined) {
24
+ return [];
25
+ }
26
+ const category = clinVarCategory(variant.significance);
27
+ const name = `${from}${position + 1}${to}`;
28
+ const onTranscript = `${from}${residue + 1}${to}`;
29
+ return [
30
+ {
31
+ uniqueId: `clinvar-${variant.id ?? `${variant.start}${variant.alt}`}-${index}`,
32
+ refName: uniprotId,
33
+ start: position,
34
+ end: position + 1,
35
+ name,
36
+ type: 'missense_variant',
37
+ category,
38
+ color: CLINVAR_CATEGORY_COLORS[category],
39
+ significance: variant.significance.join(', ').replaceAll('_', ' '),
40
+ ...(variant.id === undefined ? {} : { clinvarId: variant.id }),
41
+ ...(onTranscript === name ? {} : { transcriptChange: onTranscript }),
42
+ },
43
+ ];
44
+ })
45
+ .sort((a, b) => a.start - b.start || a.name.localeCompare(b.name));
46
+ }
47
+ export function clinVarTrackConf({ uniprotId, idPrefix, features, }) {
48
+ const trackId = `${idPrefix}-ClinVar`;
49
+ return {
50
+ type: 'FeatureTrack',
51
+ trackId,
52
+ name: 'ClinVar',
53
+ assemblyNames: [uniprotId],
54
+ adapter: {
55
+ type: 'FromConfigAdapter',
56
+ adapterId: trackId,
57
+ features,
58
+ },
59
+ displays: [
60
+ {
61
+ type: 'LinearBasicDisplay',
62
+ displayId: `${trackId}-LinearBasicDisplay`,
63
+ renderer: {
64
+ type: 'SvgFeatureRenderer',
65
+ color1: "jexl:get(feature,'color')",
66
+ },
67
+ },
68
+ ],
69
+ };
70
+ }
@@ -0,0 +1,55 @@
1
+ import { SimpleFeature } from '@jbrowse/core/util';
2
+ import { makeCoordinateMapper, transcriptPos } from 'p2s_mapper';
3
+ import { clinVarTrackConf, clinVarTrackFeatures } from './clinVarTrack';
4
+ import { linkedGenomeAssemblyName, resolveLinkageAlignment, } from '../../Protein1DLinkage/linkage';
5
+ import { sessionLinkageHost } from '../../Protein1DLinkage/sessionLinkageHost';
6
+ import { clinVarBuild, isUnnumberedMitochondrion, } from '../../ProteinView/clinVar';
7
+ import { placeClinVarOnTranscript } from '../../ProteinView/clinVarSource';
8
+ // TP53's slice is under 1 MB; a stalled host should not hold the view open
9
+ // forever on one track
10
+ const CLINVAR_TIMEOUT_MS = 60_000;
11
+ /**
12
+ * The ClinVar track of a 1D view: every missense substitution NCBI's VCF
13
+ * classifies on the linked transcript, each on the entry residue its
14
+ * transcript residue aligns to. Undefined, with no track, when the genome
15
+ * view's assembly is not a build ClinVar numbers, or the transcript and the
16
+ * entry do not align; the view's own linkage reports the latter. A failed
17
+ * read throws, for the opener to report as the track's.
18
+ */
19
+ export async function clinVarTrackConfFor({ session, linkage, idPrefix, }) {
20
+ const { uniprotId, feature } = linkage;
21
+ const assemblyName = linkedGenomeAssemblyName(session, linkage);
22
+ const assembly = assemblyName
23
+ ? session.assemblyManager.get(assemblyName)
24
+ : undefined;
25
+ const build = clinVarBuild([
26
+ ...(assemblyName ? [assemblyName] : []),
27
+ ...(assembly ? [assembly.name, ...assembly.aliases] : []),
28
+ ]);
29
+ if (!assemblyName ||
30
+ !build ||
31
+ isUnnumberedMitochondrion(feature.refName, build)) {
32
+ return undefined;
33
+ }
34
+ const linked = await resolveLinkageAlignment(sessionLinkageHost(session, linkage));
35
+ if (!('alignment' in linked)) {
36
+ return undefined;
37
+ }
38
+ const { placed } = await placeClinVarOnTranscript({
39
+ build,
40
+ feature: new SimpleFeature(feature),
41
+ assemblyName,
42
+ session,
43
+ signal: AbortSignal.timeout(CLINVAR_TIMEOUT_MS),
44
+ });
45
+ const mapper = makeCoordinateMapper(linked.alignment);
46
+ return clinVarTrackConf({
47
+ uniprotId,
48
+ idPrefix,
49
+ features: clinVarTrackFeatures({
50
+ placed,
51
+ uniprotId,
52
+ toEntryPosition: residue => mapper.transcriptToStructure(transcriptPos(residue)),
53
+ }),
54
+ });
55
+ }
@@ -16,7 +16,7 @@ export async function launchProteinAnnotationView(args) {
16
16
  await openProteinAnnotationView({ ...args, featureTypes });
17
17
  }
18
18
  /** The view, once the entry's feature types are in hand. */
19
- export async function openProteinAnnotationView({ session, feature, selectedTranscript, uniprotId, confidenceUrl, connectedViewId, connectedAssemblyName, featureTypes, }) {
19
+ export async function openProteinAnnotationView({ session, feature, selectedTranscript, uniprotId, confidenceUrl, connectedViewId, connectedAssemblyName, featureTypes, clinVar, }) {
20
20
  // A second view of an entry, another isoform's say, shares the first's
21
21
  // assembly; adding it again makes the host warn. `has`, where the host has
22
22
  // it, because `get` reports an unknown name to every plugin that resolves
@@ -47,6 +47,25 @@ export async function openProteinAnnotationView({ session, feature, selectedTran
47
47
  if (!isTrackLaunchingView(view)) {
48
48
  throw new Error('The host added a view that cannot open tracks');
49
49
  }
50
+ const idPrefix = `${view.id}-${uniprotId}`;
51
+ const open = async (conf) => {
52
+ try {
53
+ // the host reports a config it rejects itself and resolves undefined
54
+ await view.launchTrack(conf.trackId, {}, {}, conf);
55
+ }
56
+ catch (e) {
57
+ session.notifyError(`Could not open the ${conf.name} track: ${e}`, e);
58
+ }
59
+ };
60
+ // ClinVar waits on the transcript's alignment to the entry and a range read
61
+ // of NCBI's VCF, so it is asked for first and opened last, after the tracks
62
+ // that need only the entry
63
+ const clinVarTrack = proteinLinkage && clinVar
64
+ ? clinVar(proteinLinkage, idPrefix).catch((e) => {
65
+ session.notifyError(`Could not open the ClinVar track: ${e}`, e);
66
+ return undefined;
67
+ })
68
+ : undefined;
50
69
  // Each config rides on its track in this view, not in the session's track
51
70
  // list: the host rejects a session track naming a temporary assembly, and
52
71
  // the track selector lists session tracks only, so every track opens here
@@ -55,15 +74,13 @@ export async function openProteinAnnotationView({ session, feature, selectedTran
55
74
  uniprotId,
56
75
  featureTypes,
57
76
  confidenceUrl,
58
- idPrefix: `${view.id}-${uniprotId}`,
77
+ idPrefix,
59
78
  })) {
60
- try {
61
- // the host reports a config it rejects itself and resolves undefined
62
- await view.launchTrack(conf.trackId, {}, {}, conf);
63
- }
64
- catch (e) {
65
- session.notifyError(`Could not open the ${conf.name} track: ${e}`, e);
66
- }
79
+ await open(conf);
67
80
  }
68
81
  await view.navToLocString(uniprotId, uniprotId);
82
+ const conf = await clinVarTrack;
83
+ if (conf) {
84
+ await open(conf);
85
+ }
69
86
  }
@@ -52,20 +52,6 @@ function antigenTrackConf(uniprotId, idPrefix) {
52
52
  assemblyNames: [uniprotId],
53
53
  };
54
54
  }
55
- function variationTrackConf(uniprotId, idPrefix) {
56
- return {
57
- type: 'FeatureTrack',
58
- trackId: `${idPrefix}-Variation`,
59
- name: 'Variation',
60
- adapter: {
61
- type: 'UniProtVariationAdapter',
62
- location: {
63
- uri: `https://www.ebi.ac.uk/proteins/api/variation/${uniprotId}.json`,
64
- },
65
- },
66
- assemblyNames: [uniprotId],
67
- };
68
- }
69
55
  function alphaFoldConfidenceTrackConf({ uniprotId, confidenceUrl, idPrefix, }) {
70
56
  return {
71
57
  type: 'QuantitativeTrack',
@@ -115,15 +101,16 @@ function alphaMissenseTrackConf(uniprotId, idPrefix) {
115
101
  };
116
102
  }
117
103
  /**
118
- * Every annotation track of a UniProt entry, as configs for the view to carry.
119
- * `idPrefix` has to be unique to the view: two views of one entry each hold
120
- * their own copy, and a session tree cannot hold one trackId twice.
104
+ * Every annotation track of a UniProt entry that needs only the entry, as
105
+ * configs for the view to carry; the ClinVar track, which needs the linked
106
+ * transcript, is built by clinVarTrackSource. `idPrefix` has to be unique to
107
+ * the view: two views of one entry each hold their own copy, and a session
108
+ * tree cannot hold one trackId twice.
121
109
  */
122
110
  export function proteinTrackConfs({ uniprotId, featureTypes, confidenceUrl, idPrefix, }) {
123
111
  return [
124
112
  ...uniProtFeatureTrackConfs({ uniprotId, featureTypes, idPrefix }),
125
113
  antigenTrackConf(uniprotId, idPrefix),
126
- variationTrackConf(uniprotId, idPrefix),
127
114
  ...(confidenceUrl
128
115
  ? [alphaFoldConfidenceTrackConf({ uniprotId, confidenceUrl, idPrefix })]
129
116
  : []),
@@ -1,7 +1,7 @@
1
1
  import { getSession } from '@jbrowse/core/util';
2
2
  import useSWR from 'swr';
3
3
  import { STATIC_SWR_OPTIONS } from './swrOptions';
4
- import { rankIsoforms } from '../../AlignTranscriptRpc';
4
+ import { rankIsoforms } from '../../AlignTranscriptRpc/isoformRanking';
5
5
  import { alignOffThread } from '../../ProteinView/alignOffThread';
6
6
  /**
7
7
  * The isoforms in the order the picker lists them, ranked in the RPC worker:
@@ -1,5 +1,5 @@
1
1
  import { useState } from 'react';
2
- import { rankedTranscriptId } from '../../AlignTranscriptRpc';
2
+ import { rankedTranscriptId } from '../../AlignTranscriptRpc/isoformRanking';
3
3
  import { flaggedTranscriptId } from '../codingFeature';
4
4
  import { rankableIsoforms } from '../utils/util';
5
5
  /**
@@ -1,10 +1,10 @@
1
+ import { lazy } from 'react';
1
2
  import { getContainingTrack, getContainingView, getSession, isGeneLikeType, } from '@jbrowse/core/util';
2
3
  import AddIcon from '@mui/icons-material/Add';
3
4
  import { isCodingFeature } from './codingFeature';
4
- import LaunchProteinViewDialog from './components/LaunchProteinViewDialog';
5
- import { describeMissingStructure, resolveGeneLaunch, sessionGeneLaunchHost, } from './resolveGeneLaunch';
6
- import { launch3DProteinView } from './utils/launchViewUtils';
7
5
  import { getGeneDisplayName } from './utils/util';
6
+ // the menu items register at boot; what they open loads on the first click
7
+ const LaunchProteinViewDialog = lazy(() => import('./components/LaunchProteinViewDialog'));
8
8
  function isDisplay(elt) {
9
9
  return elt.name === 'LinearBasicDisplay';
10
10
  }
@@ -84,6 +84,10 @@ function openAlphaFoldStructure(self, target) {
84
84
  return;
85
85
  }
86
86
  session.notify(`Looking up the AlphaFold structure of ${name}`, 'info');
87
+ const [{ describeMissingStructure, resolveGeneLaunch, sessionGeneLaunchHost }, { launch3DProteinView },] = await Promise.all([
88
+ import('./resolveGeneLaunch'),
89
+ import('./utils/launchViewUtils'),
90
+ ]);
87
91
  const launch = await resolveGeneLaunch({
88
92
  host: sessionGeneLaunchHost(session, assemblyName),
89
93
  feature,
@@ -91,7 +95,7 @@ function openAlphaFoldStructure(self, target) {
91
95
  });
92
96
  const { transcript, userProvidedTranscriptSequence, uniprotId, url } = launch;
93
97
  if (url) {
94
- launch3DProteinView({
98
+ await launch3DProteinView({
95
99
  session,
96
100
  view,
97
101
  feature,
@@ -1,7 +1,7 @@
1
1
  import { getConf } from '@jbrowse/core/configuration';
2
2
  import { fetchAlphaFoldModels, getAlphaFoldStructureUrl, pickAlphaFoldModel, searchUniProtEntries, } from 'p2s_mapper';
3
3
  import { codingTranscripts, flaggedTranscriptId } from './codingFeature';
4
- import { rankIsoforms, rankedTranscriptId } from '../AlignTranscriptRpc';
4
+ import { rankIsoforms, rankedTranscriptId, } from '../AlignTranscriptRpc/isoformRanking';
5
5
  import { fetchTranscriptProteinSeqs } from './utils/translateTranscripts';
6
6
  import { extractFeatureIdentifiers, extractTaxonId } from './utils/util';
7
7
  import { alignOffThread } from '../ProteinView/alignOffThread';
@@ -1,6 +1,8 @@
1
1
  import { maybeLaunchSideBySide } from './sideBySide';
2
2
  import { getGeneDisplayName, getTranscriptDisplayName } from './util';
3
+ import { addProteinView } from '../../ProteinView/addProteinView';
3
4
  import { proteinViewSnapshot } from '../../ProteinView/proteinViewSpec';
5
+ import { clinVarTrackConfFor } from '../components/clinVarTrackSource';
4
6
  import { launchProteinAnnotationView } from '../components/launchProteinAnnotationView';
5
7
  import { canAddTemporaryAssembly } from '../components/proteinAssemblySetup';
6
8
  export function formatViewName(prefix, feature, selectedTranscript, uniprotId) {
@@ -15,7 +17,7 @@ export function formatViewName(prefix, feature, selectedTranscript, uniprotId) {
15
17
  .filter(s => !!s)
16
18
  .join(' - ');
17
19
  }
18
- export function launch3DProteinView({ session, view, feature, selectedTranscript, uniprotId, url, data, userProvidedTranscriptSequence, sideBySide, }) {
20
+ export async function launch3DProteinView({ session, view, feature, selectedTranscript, uniprotId, url, data, userProvidedTranscriptSequence, sideBySide, }) {
19
21
  const snap = proteinViewSnapshot({
20
22
  displayName: formatViewName('Protein view', feature, selectedTranscript, uniprotId),
21
23
  structures: [
@@ -28,7 +30,7 @@ export function launch3DProteinView({ session, view, feature, selectedTranscript
28
30
  },
29
31
  ],
30
32
  });
31
- const proteinView = session.addView('ProteinView', snap);
33
+ const proteinView = await addProteinView(session, snap);
32
34
  maybeLaunchSideBySide(session, proteinView.id, sideBySide);
33
35
  return proteinView;
34
36
  }
@@ -57,6 +59,7 @@ async function launch1DProteinView({ session, view, feature, selectedTranscript,
57
59
  confidenceUrl: entry === uniprotId ? confidenceUrl : undefined,
58
60
  connectedViewId: view.id,
59
61
  connectedAssemblyName: view.assemblyNames[0],
62
+ clinVar: (linkage, idPrefix) => clinVarTrackConfFor({ session, linkage, idPrefix }),
60
63
  });
61
64
  }
62
65
  // What the launches below are CALLED, shared for the same reason their
@@ -1,89 +1,16 @@
1
- import { SimpleFeature } from '@jbrowse/core/util';
2
- import { fetchAlphaFoldModels } from 'p2s_mapper';
3
- import { normalizeAnnotationLaunch } from './normalizeAnnotationLaunch';
4
- import { connectGenomeView, resolveTranscriptLinkage, } from './transcriptLinkage';
5
- import { openProteinAnnotationView } from '../LaunchProteinView/components/launchProteinAnnotationView';
6
- import { canAddTemporaryAssembly } from '../LaunchProteinView/components/proteinAssemblySetup';
7
- import { fetchUniProtFeatureTypes } from '../LaunchProteinView/components/proteinTrackSetup';
8
- import { describeMissingStructure } from '../LaunchProteinView/resolveGeneLaunch';
9
- import { uniProtEntry } from '../LaunchProteinView/utils/launchViewUtils';
10
- import { viewAssemblyName } from '../ProteinView/util';
11
- // The canonical model's pLDDT is in the entry's numbering; an isoform model's
12
- // is not, and has no place on the entry's track
13
- async function entryConfidenceUrl(uniprotId) {
14
- try {
15
- const models = await fetchAlphaFoldModels(uniprotId);
16
- return models.find(m => m.accession === uniprotId)?.confidenceUrl;
17
- }
18
- catch {
19
- return undefined;
20
- }
21
- }
22
1
  /**
23
2
  * The 1D protein-annotation view of a UniProt entry, from a session spec:
24
3
  * the same view the launch dialog's 1D option opens, linked to the transcript
25
4
  * a `gene` or `transcriptId` names the way a ProteinView spec links its
26
5
  * structures. The view itself is a LinearGenomeView on a temporary assembly,
27
6
  * so the extension point is named for the spec type rather than the view type.
7
+ *
8
+ * The launch itself loads on first use, so registering it costs the plugin's
9
+ * boot nothing.
28
10
  */
29
11
  export default function LaunchProteinAnnotationViewF(pluginManager) {
30
12
  pluginManager.addToExtensionPoint('LaunchView-ProteinAnnotationView', async (args) => {
31
- const { session, ...given } = args;
32
- const fail = (e) => {
33
- console.error(e);
34
- session.notify(`Could not launch protein annotation view: ${e}`, 'error');
35
- return args;
36
- };
37
- const normalized = normalizeAnnotationLaunch(given);
38
- for (const warning of normalized.warnings) {
39
- console.warn(warning);
40
- session.notify(`Protein annotation view launch: ${warning}`, 'warning');
41
- }
42
- if ('error' in normalized) {
43
- return fail(normalized.error);
44
- }
45
- if (!canAddTemporaryAssembly(session)) {
46
- return fail('this session cannot add the temporary assembly the view opens on');
47
- }
48
- const { launch } = normalized;
49
- try {
50
- const { named, resolved, connectedView } = await resolveTranscriptLinkage(session, launch, {
51
- findStructure: !launch.uniprotId,
52
- });
53
- const accession = launch.uniprotId ?? named?.uniprotId;
54
- if (!accession) {
55
- throw new Error(launch.gene && named
56
- ? `${describeMissingStructure(launch.gene, named)}; name a uniprotId`
57
- : 'no UniProt entry to open');
58
- }
59
- const uniprotId = uniProtEntry(accession);
60
- // fetched before anything is added, so a failure leaves no view
61
- const [featureTypes, confidenceUrl] = await Promise.all([
62
- fetchUniProtFeatureTypes(uniprotId),
63
- entryConfidenceUrl(uniprotId),
64
- ]);
65
- const transcript = resolved
66
- ? new SimpleFeature(resolved.feature)
67
- : undefined;
68
- const connectedViewId = transcript
69
- ? connectGenomeView(session, launch.connectedViewId, connectedView)
70
- : undefined;
71
- await openProteinAnnotationView({
72
- session,
73
- feature: transcript,
74
- selectedTranscript: transcript,
75
- uniprotId,
76
- confidenceUrl,
77
- connectedViewId,
78
- connectedAssemblyName: (launch.connectedViewId
79
- ? viewAssemblyName(session, launch.connectedViewId)
80
- : undefined) ?? connectedView?.assembly,
81
- featureTypes,
82
- });
83
- }
84
- catch (e) {
85
- return fail(e);
86
- }
87
- return args;
13
+ const { launchAnnotationView } = await import('./launchAnnotationView');
14
+ return launchAnnotationView(args);
88
15
  });
89
16
  }
@@ -1,88 +1,10 @@
1
- import { coerceAlignmentAlgorithm } from 'p2s_mapper';
2
- import { normalizeLaunch } from './normalizeLaunch';
3
- import { connectGenomeView, resolveTranscriptLinkage, } from './transcriptLinkage';
4
- import { describeMissingStructure } from '../LaunchProteinView/resolveGeneLaunch';
5
- import { maybeLaunchSideBySide } from '../LaunchProteinView/utils/sideBySide';
6
- import { coerceColorScheme } from '../ProteinView/applyColorTheme';
7
- import { proteinViewSnapshot } from '../ProteinView/proteinViewSpec';
8
- export function launchViewSnapshot({ alignmentAlgorithm, colorScheme, ...settings }, structures) {
9
- return proteinViewSnapshot({
10
- ...settings,
11
- alignmentAlgorithm: alignmentAlgorithm === undefined
12
- ? undefined
13
- : coerceAlignmentAlgorithm(alignmentAlgorithm),
14
- colorScheme: colorScheme === undefined ? undefined : coerceColorScheme(colorScheme),
15
- structures,
16
- });
17
- }
1
+ /**
2
+ * The launch itself loads on first use, so registering it costs the plugin's
3
+ * boot nothing.
4
+ */
18
5
  export default function LaunchProteinViewExtensionPointF(pluginManager) {
19
- pluginManager.addToExtensionPoint('LaunchView-ProteinView',
20
- // A LaunchView point is a transformer — the chain hands what each callback
21
- // returns to the next — and JBrowse now warns when one returns undefined
22
- // ("...returned undefined instead of the value it was passed, so its result
23
- // was ignored"), on every launch. This used to return nothing on the
24
- // assumption that the result was ignored; it is not. The handler returns
25
- // its extendee at each exit now, like jbrowse-components' own
26
- // LaunchDotplotView does.
27
- async (args) => {
28
- const { session, structures: _structures, url: _url, data: _data, pdbId: _pdbId, initialSelection: _initialSelection, initialResidues: _initialResidues, initialTranscriptResidues: _initialTranscriptResidues, mappedEntityId: _mappedEntityId, pairwiseAlignment: _pairwiseAlignment, alignmentImported: _alignmentImported, hidden: _hidden, uniprotId, transcriptId, userProvidedTranscriptSequence, feature, connectedViewId, connectedView: givenConnectedView, gene, sideBySide, ...settings } = args;
29
- const fail = (e) => {
30
- console.error(e);
31
- session.notify(`Could not launch protein view: ${e}`, 'error');
32
- return args;
33
- };
34
- const { session: _session, ...launch } = args;
35
- const normalized = normalizeLaunch(launch);
36
- for (const warning of normalized.warnings) {
37
- console.warn(warning);
38
- session.notify(`Protein view launch: ${warning}`, 'warning');
39
- }
40
- if ('error' in normalized) {
41
- return fail(normalized.error);
42
- }
43
- const { geneModel } = normalized;
44
- // A gene name alone: the host's text search finds the gene, and the
45
- // launch dialog's defaults pick its isoform and AlphaFold model. A
46
- // structure, transcript or locus the spec names wins over those. The
47
- // short form instead derives the feature and sequence from the
48
- // connected track, and the same mapping applies to every structure.
49
- let linkage;
50
- try {
51
- linkage = await resolveTranscriptLinkage(session, {
52
- gene,
53
- transcriptId,
54
- uniprotId,
55
- userProvidedTranscriptSequence,
56
- connectedView: givenConnectedView,
57
- connectedViewId,
58
- }, { findStructure: geneModel === 'required' });
59
- }
60
- catch (e) {
61
- return fail(e);
62
- }
63
- const { named, resolved, connectedView } = linkage;
64
- if (gene && named && geneModel === 'required' && !named.url) {
65
- return fail(new Error(`${describeMissingStructure(gene, named)}; name a ${named.uniprotId ? 'pdbId or url' : 'uniprotId or pdbId'}`));
66
- }
67
- const requested = named && geneModel
68
- ? normalized.requested.map(s => ({ ...s, url: named.url }))
69
- : normalized.requested;
70
- // a connected view this launch created itself can be split beside the
71
- // protein view; a pre-existing connectedViewId is left in place
72
- const ownsConnectedView = !connectedViewId && !!connectedView;
73
- const resolvedConnectedViewId = connectGenomeView(session, connectedViewId, connectedView);
74
- const structures = requested.map(s => ({
75
- ...s,
76
- userProvidedTranscriptSequence: s.userProvidedTranscriptSequence ??
77
- resolved?.userProvidedTranscriptSequence ??
78
- userProvidedTranscriptSequence,
79
- feature: s.feature ?? resolved?.feature ?? feature,
80
- connectedViewId: s.connectedViewId ?? resolvedConnectedViewId,
81
- }));
82
- const proteinView = session.addView('ProteinView', launchViewSnapshot({ displayName: named?.displayName, ...settings }, structures));
83
- if (ownsConnectedView) {
84
- maybeLaunchSideBySide(session, proteinView.id, sideBySide);
85
- }
86
- return args;
6
+ pluginManager.addToExtensionPoint('LaunchView-ProteinView', async (args) => {
7
+ const { launchProteinView } = await import('./launchProteinView');
8
+ return launchProteinView(args);
87
9
  });
88
10
  }