jbrowse-plugin-protein3d 1.28.0 → 1.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist/LaunchProteinView/components/FoldseekResultsTable.js +7 -8
  2. package/dist/LaunchProteinView/components/UserProvidedStructure.js +2 -2
  3. package/dist/LaunchProteinView/hooks/useAlphaFoldDBSearch.js +2 -2
  4. package/dist/LaunchProteinView/resolveGeneLaunch.js +2 -2
  5. package/dist/LaunchProteinViewExtensionPoint/normalizeLaunch.js +1 -13
  6. package/dist/Protein1DLinkage/linkage.js +3 -17
  7. package/dist/ProteinView/alignOffThread.js +0 -10
  8. package/dist/ProteinView/alignmentDecision.js +3 -4
  9. package/dist/ProteinView/alignmentDomains.js +4 -3
  10. package/dist/ProteinView/components/AlignmentRuler.js +3 -2
  11. package/dist/ProteinView/components/ColumnOverlays.js +1 -1
  12. package/dist/ProteinView/components/HeaderStructureRow.js +1 -2
  13. package/dist/ProteinView/components/ManualAlignmentDialog.js +2 -2
  14. package/dist/ProteinView/hooks/useProteinFeatureTrackData.js +8 -11
  15. package/dist/ProteinView/hoverReadout.js +2 -2
  16. package/dist/ProteinView/proteinToGenomeMapping.js +5 -18
  17. package/dist/ProteinView/residueRanges.js +1 -70
  18. package/dist/ProteinView/residueTracks.js +6 -5
  19. package/dist/ProteinView/residueValuesStatus.js +2 -1
  20. package/dist/ProteinView/sessionHighlights.js +5 -2
  21. package/dist/ProteinView/structureModel.js +30 -56
  22. package/dist/ProteinView/trackScoresSource.js +2 -1
  23. package/dist/ProteinView/variantEffectSource.js +6 -4
  24. package/dist/ProteinView/variantEffectStatus.js +2 -1
  25. package/dist/ProteinView/variantEffects.js +2 -2
  26. package/dist/chunks/AddStructureDialog-ULCEZKZU.js +2 -0
  27. package/dist/chunks/{AddStructureDialog-XBFIHSU5.js.map → AddStructureDialog-ULCEZKZU.js.map} +1 -1
  28. package/dist/chunks/LaunchProteinViewDialog-CDPFZULN.js +2 -0
  29. package/dist/chunks/LaunchProteinViewDialog-CDPFZULN.js.map +7 -0
  30. package/dist/chunks/ManualAlignmentDialog-HBABVXDB.js +8 -0
  31. package/dist/chunks/ManualAlignmentDialog-HBABVXDB.js.map +7 -0
  32. package/dist/chunks/ProteinView-BCN7C33U.js +3 -0
  33. package/dist/chunks/ProteinView-BCN7C33U.js.map +7 -0
  34. package/dist/chunks/{chunk-KWT5KKAF.js → chunk-2PZKTNPH.js} +2 -2
  35. package/dist/chunks/{chunk-6MN7XAFE.js → chunk-3UIC6A5M.js} +2 -2
  36. package/dist/chunks/chunk-4J5OYV7J.js +2 -0
  37. package/dist/chunks/chunk-4J5OYV7J.js.map +7 -0
  38. package/dist/chunks/{chunk-FPWCCN23.js → chunk-574DQWSJ.js} +2 -2
  39. package/dist/chunks/chunk-5EXV6CRQ.js +2 -0
  40. package/dist/chunks/chunk-5EXV6CRQ.js.map +7 -0
  41. package/dist/chunks/chunk-5M46KQDX.js +29 -0
  42. package/dist/chunks/chunk-5M46KQDX.js.map +7 -0
  43. package/dist/chunks/{chunk-N5KPBXO6.js → chunk-GUJUAAT4.js} +2 -2
  44. package/dist/chunks/chunk-KCEADJTV.js +2 -0
  45. package/dist/chunks/chunk-KCEADJTV.js.map +7 -0
  46. package/dist/chunks/chunk-L7FVAJ2Y.js +2 -0
  47. package/dist/chunks/chunk-L7FVAJ2Y.js.map +7 -0
  48. package/dist/chunks/chunk-LKERPWLH.js +2 -0
  49. package/dist/chunks/chunk-LKERPWLH.js.map +7 -0
  50. package/dist/chunks/chunk-MYRDDDAG.js +2 -0
  51. package/dist/chunks/chunk-MYRDDDAG.js.map +7 -0
  52. package/dist/chunks/chunk-OU2GWGJP.js +2 -0
  53. package/dist/chunks/{chunk-SPXMXPSC.js.map → chunk-OU2GWGJP.js.map} +4 -4
  54. package/dist/chunks/chunk-OVHBAJZM.js +2 -0
  55. package/dist/chunks/chunk-OVHBAJZM.js.map +7 -0
  56. package/dist/chunks/{chunk-WTF2AB6N.js → chunk-SBJ4OFE4.js} +2 -2
  57. package/dist/chunks/{chunk-WTF2AB6N.js.map → chunk-SBJ4OFE4.js.map} +1 -1
  58. package/dist/chunks/{chunk-6IENEKLK.js → chunk-USQU7AH7.js} +2 -2
  59. package/dist/chunks/chunk-XKSFDKNL.js +2 -0
  60. package/dist/chunks/chunk-XKSFDKNL.js.map +7 -0
  61. package/dist/chunks/clinVarSource-G2UG6KEO.js +2 -0
  62. package/dist/chunks/esm-Z5EZPASY.js +2 -0
  63. package/dist/chunks/isoformRanking-Y7NHBYRP.js +2 -0
  64. package/dist/chunks/launchAnnotationView-K22EHL52.js +2 -0
  65. package/dist/chunks/{launchAnnotationView-VUGR5OIR.js.map → launchAnnotationView-K22EHL52.js.map} +1 -1
  66. package/dist/chunks/launchProteinView-LZ43ZLHO.js +2 -0
  67. package/dist/chunks/{launchProteinView-55YIRF5P.js.map → launchProteinView-LZ43ZLHO.js.map} +1 -1
  68. package/dist/chunks/launchViewUtils-6HYT7VPY.js +2 -0
  69. package/dist/chunks/model-J2OOWXRV.js +2 -0
  70. package/dist/chunks/model-J2OOWXRV.js.map +7 -0
  71. package/dist/chunks/{molstarExports-QQY35YRX.js → molstarExports-SML72HMS.js} +2 -2
  72. package/dist/chunks/{molstarExports-QQY35YRX.js.map → molstarExports-SML72HMS.js.map} +1 -1
  73. package/dist/chunks/resolveGeneLaunch-RRRCTCIE.js +2 -0
  74. package/dist/jbrowse-plugin-protein3d.esm.js +1 -1
  75. package/dist/jbrowse-plugin-protein3d.esm.js.map +2 -2
  76. package/dist/mappings.js +1 -23
  77. package/dist/test_data/positionLookups.js +27 -0
  78. package/dist/version.js +1 -1
  79. package/package.json +2 -2
  80. package/src/LaunchProteinView/components/FoldseekActionMenu.tsx +2 -3
  81. package/src/LaunchProteinView/components/FoldseekResultsTable.tsx +7 -10
  82. package/src/LaunchProteinView/components/UserProvidedStructure.tsx +2 -2
  83. package/src/LaunchProteinView/hooks/useAlphaFoldDBSearch.ts +2 -2
  84. package/src/LaunchProteinView/resolveGeneLaunch.ts +2 -2
  85. package/src/LaunchProteinViewExtensionPoint/normalizeLaunch.ts +2 -25
  86. package/src/Protein1DLinkage/linkage.ts +5 -20
  87. package/src/ProteinView/alignOffThread.ts +0 -12
  88. package/src/ProteinView/alignmentDecision.ts +3 -4
  89. package/src/ProteinView/alignmentDomains.test.ts +28 -6
  90. package/src/ProteinView/alignmentDomains.ts +9 -6
  91. package/src/ProteinView/components/AlignmentRuler.tsx +5 -3
  92. package/src/ProteinView/components/ColumnOverlays.tsx +1 -1
  93. package/src/ProteinView/components/HeaderStructureRow.tsx +1 -1
  94. package/src/ProteinView/components/ManualAlignmentDialog.tsx +2 -3
  95. package/src/ProteinView/components/rulerTicks.test.ts +3 -2
  96. package/src/ProteinView/geneExplorerLinkage.test.ts +1 -2
  97. package/src/ProteinView/hooks/layoutFeature.test.ts +14 -5
  98. package/src/ProteinView/hooks/useProteinFeatureTrackData.ts +10 -12
  99. package/src/ProteinView/hoverReadout.test.ts +5 -4
  100. package/src/ProteinView/hoverReadout.ts +4 -4
  101. package/src/ProteinView/proteinToGenomeMapping.ts +11 -21
  102. package/src/ProteinView/proteinViewSpec.ts +5 -2
  103. package/src/ProteinView/residueRanges.ts +1 -88
  104. package/src/ProteinView/residueTracks.test.ts +6 -2
  105. package/src/ProteinView/residueTracks.ts +8 -5
  106. package/src/ProteinView/residueValuesStatus.test.ts +4 -3
  107. package/src/ProteinView/residueValuesStatus.ts +5 -2
  108. package/src/ProteinView/sessionHighlights.test.ts +3 -2
  109. package/src/ProteinView/sessionHighlights.ts +7 -4
  110. package/src/ProteinView/structureModel.test.ts +16 -12
  111. package/src/ProteinView/structureModel.ts +47 -71
  112. package/src/ProteinView/structureVariantEffects.test.ts +1 -1
  113. package/src/ProteinView/trackScoresSource.ts +2 -1
  114. package/src/ProteinView/variantEffectSource.ts +7 -5
  115. package/src/ProteinView/variantEffectStatus.test.ts +1 -1
  116. package/src/ProteinView/variantEffectStatus.ts +5 -3
  117. package/src/ProteinView/variantEffects.ts +2 -3
  118. package/src/mappings.ts +1 -26
  119. package/src/test_data/positionLookups.ts +42 -0
  120. package/src/version.ts +1 -1
  121. package/dist/ProteinView/describeCoverage.js +0 -22
  122. package/dist/ProteinView/entityAlignedTo.js +0 -37
  123. package/dist/chunks/AddStructureDialog-XBFIHSU5.js +0 -2
  124. package/dist/chunks/LaunchProteinViewDialog-C7JQASEL.js +0 -2
  125. package/dist/chunks/LaunchProteinViewDialog-C7JQASEL.js.map +0 -7
  126. package/dist/chunks/ManualAlignmentDialog-2YD3422Y.js +0 -8
  127. package/dist/chunks/ManualAlignmentDialog-2YD3422Y.js.map +0 -7
  128. package/dist/chunks/ProteinView-FDVDHAW2.js +0 -3
  129. package/dist/chunks/ProteinView-FDVDHAW2.js.map +0 -7
  130. package/dist/chunks/chunk-26MHV63N.js +0 -2
  131. package/dist/chunks/chunk-26MHV63N.js.map +0 -7
  132. package/dist/chunks/chunk-2MXFJYQ7.js +0 -30
  133. package/dist/chunks/chunk-2MXFJYQ7.js.map +0 -7
  134. package/dist/chunks/chunk-4PLPY3PU.js +0 -2
  135. package/dist/chunks/chunk-4PLPY3PU.js.map +0 -7
  136. package/dist/chunks/chunk-6PWLDC4Q.js +0 -2
  137. package/dist/chunks/chunk-6PWLDC4Q.js.map +0 -7
  138. package/dist/chunks/chunk-CGLM5Z55.js +0 -2
  139. package/dist/chunks/chunk-CGLM5Z55.js.map +0 -7
  140. package/dist/chunks/chunk-IQ6B4VQT.js +0 -2
  141. package/dist/chunks/chunk-IQ6B4VQT.js.map +0 -7
  142. package/dist/chunks/chunk-PCTHFY7A.js +0 -2
  143. package/dist/chunks/chunk-PCTHFY7A.js.map +0 -7
  144. package/dist/chunks/chunk-RA7XMMBU.js +0 -2
  145. package/dist/chunks/chunk-RA7XMMBU.js.map +0 -7
  146. package/dist/chunks/chunk-SJSF6PGN.js +0 -2
  147. package/dist/chunks/chunk-SJSF6PGN.js.map +0 -7
  148. package/dist/chunks/chunk-SPXMXPSC.js +0 -2
  149. package/dist/chunks/chunk-SYKHVKDJ.js +0 -2
  150. package/dist/chunks/chunk-SYKHVKDJ.js.map +0 -7
  151. package/dist/chunks/chunk-UVDYWAS6.js +0 -2
  152. package/dist/chunks/chunk-UVDYWAS6.js.map +0 -7
  153. package/dist/chunks/clinVarSource-IAETOBYO.js +0 -2
  154. package/dist/chunks/esm-MAGKKLBP.js +0 -2
  155. package/dist/chunks/isoformRanking-NAVCMU5I.js +0 -2
  156. package/dist/chunks/launchAnnotationView-VUGR5OIR.js +0 -2
  157. package/dist/chunks/launchProteinView-55YIRF5P.js +0 -2
  158. package/dist/chunks/launchViewUtils-AXQYQAXZ.js +0 -2
  159. package/dist/chunks/model-SIMP65W6.js +0 -2
  160. package/dist/chunks/model-SIMP65W6.js.map +0 -7
  161. package/dist/chunks/resolveGeneLaunch-BY5N46HC.js +0 -2
  162. package/src/ProteinView/describeCoverage.test.ts +0 -72
  163. package/src/ProteinView/describeCoverage.ts +0 -24
  164. package/src/ProteinView/entityAlignedTo.test.ts +0 -56
  165. package/src/ProteinView/entityAlignedTo.ts +0 -62
  166. package/src/ProteinView/residueRanges.test.ts +0 -118
  167. /package/dist/chunks/{chunk-KWT5KKAF.js.map → chunk-2PZKTNPH.js.map} +0 -0
  168. /package/dist/chunks/{chunk-6MN7XAFE.js.map → chunk-3UIC6A5M.js.map} +0 -0
  169. /package/dist/chunks/{chunk-FPWCCN23.js.map → chunk-574DQWSJ.js.map} +0 -0
  170. /package/dist/chunks/{chunk-N5KPBXO6.js.map → chunk-GUJUAAT4.js.map} +0 -0
  171. /package/dist/chunks/{chunk-6IENEKLK.js.map → chunk-USQU7AH7.js.map} +0 -0
  172. /package/dist/chunks/{clinVarSource-IAETOBYO.js.map → clinVarSource-G2UG6KEO.js.map} +0 -0
  173. /package/dist/chunks/{esm-MAGKKLBP.js.map → esm-Z5EZPASY.js.map} +0 -0
  174. /package/dist/chunks/{isoformRanking-NAVCMU5I.js.map → isoformRanking-Y7NHBYRP.js.map} +0 -0
  175. /package/dist/chunks/{launchViewUtils-AXQYQAXZ.js.map → launchViewUtils-6HYT7VPY.js.map} +0 -0
  176. /package/dist/chunks/{resolveGeneLaunch-BY5N46HC.js.map → resolveGeneLaunch-RRRCTCIE.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip, Typography, } from '@mui/material';
3
3
  import { observer } from 'mobx-react';
4
- import { getStructureUrlFromTarget } from 'p2s_mapper';
4
+ import { foldseekHits, getStructureUrlFromTarget } from 'p2s_mapper';
5
5
  import { makeStyles } from 'tss-react/mui';
6
6
  import FoldseekActionMenu from './FoldseekActionMenu';
7
7
  const useStyles = makeStyles()(theme => ({
@@ -26,13 +26,12 @@ const useStyles = makeStyles()(theme => ({
26
26
  }));
27
27
  const MAX_HITS = 100;
28
28
  function flattenResults(results) {
29
- const hits = results.results.flatMap(dbResult => (dbResult.alignments ?? []).flat().map(alignment => ({
30
- ...alignment,
31
- db: dbResult.db,
32
- structureUrl: getStructureUrlFromTarget(alignment.target, dbResult.db),
33
- })));
34
- hits.sort((a, b) => (a.eval ?? Infinity) - (b.eval ?? Infinity));
35
- return hits;
29
+ return foldseekHits(results)
30
+ .map(hit => ({
31
+ ...hit,
32
+ structureUrl: getStructureUrlFromTarget(hit.target, hit.db),
33
+ }))
34
+ .toSorted((a, b) => (a.eval ?? Infinity) - (b.eval ?? Infinity));
36
35
  }
37
36
  const FoldseekResultsTable = observer(function FoldseekResultsTable({ results, session, view, feature, selectedTranscript, userProvidedTranscriptSequence, onClose, }) {
38
37
  const { classes } = useStyles();
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
2
2
  import { ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui';
3
3
  import { Button, DialogActions, DialogContent } from '@mui/material';
4
4
  import { observer } from 'mobx-react';
5
- import { stripStopCodon } from 'p2s_mapper';
5
+ import { sameProtein } from 'p2s_mapper';
6
6
  import { makeStyles } from 'tss-react/mui';
7
7
  import PartialFailureNotice from './PartialFailureNotice';
8
8
  import SequenceMismatchNotice from './SequenceMismatchNotice';
@@ -68,7 +68,7 @@ const UserProvidedStructure = observer(function UserProvidedStructure({ feature,
68
68
  !launching;
69
69
  const sequencesDiffer = !!protein?.seq &&
70
70
  !!structureSequence &&
71
- stripStopCodon(protein.seq) !== structureSequence;
71
+ !sameProtein(protein.seq, structureSequence);
72
72
  const handleLaunch = runLaunch(async () => {
73
73
  if (protein && selectedTranscript) {
74
74
  const structureData = activeFile
@@ -1,5 +1,5 @@
1
1
  import { useMemo } from 'react';
2
- import { stripStopCodon } from 'p2s_mapper';
2
+ import { sameProtein } from 'p2s_mapper';
3
3
  import useAlphaFoldData from './useAlphaFoldData';
4
4
  import useTranscriptIsoformSelection from './useTranscriptIsoformSelection';
5
5
  export default function useAlphaFoldDBSearch({ feature, view, lookup, preferredTranscriptId, }) {
@@ -48,7 +48,7 @@ export default function useAlphaFoldDBSearch({ feature, view, lookup, preferredT
48
48
  sequencesMatch: !isAlphaFoldValidating &&
49
49
  userSelectedProteinSequence?.seq &&
50
50
  structureSequence
51
- ? stripStopCodon(userSelectedProteinSequence.seq) === structureSequence
51
+ ? sameProtein(userSelectedProteinSequence.seq, structureSequence)
52
52
  : undefined,
53
53
  isLoading,
54
54
  };
@@ -1,5 +1,5 @@
1
1
  import { readConfObject } from '@jbrowse/core/configuration';
2
- import { fetchAlphaFoldModels, getAlphaFoldStructureUrl, pickAlphaFoldModel, searchUniProtEntries, stripStopCodon, } from 'p2s_mapper';
2
+ import { fetchAlphaFoldModels, getAlphaFoldStructureUrl, pickAlphaFoldModel, sameProtein, searchUniProtEntries, } 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';
@@ -20,7 +20,7 @@ export function launchAlphaFoldModel(uniprotId, models, isoformSequences, prefer
20
20
  const preferred = preferredTranscriptId === undefined
21
21
  ? undefined
22
22
  : isoformSequences?.[preferredTranscriptId];
23
- const own = preferred && models.find(m => m.sequence === stripStopCodon(preferred.seq));
23
+ const own = preferred && models.find(m => sameProtein(preferred.seq, m.sequence));
24
24
  return own ?? pickAlphaFoldModel(models, isoformSequences);
25
25
  }
26
26
  /** Why a resolved gene has no structure to open. */
@@ -1,4 +1,4 @@
1
- import { resolveStructureUrl } from 'p2s_mapper';
1
+ import { isPairwiseAlignment, resolveStructureUrl } from 'p2s_mapper';
2
2
  const STRUCTURE_KEY_ROLES = {
3
3
  url: 'source',
4
4
  data: 'source',
@@ -60,18 +60,6 @@ function isResidueRanges(value) {
60
60
  ? value.every(isResidueRange)
61
61
  : isResidueRange(value);
62
62
  }
63
- function isAlignmentRow(value) {
64
- return (isRecord(value) &&
65
- typeof value.id === 'string' &&
66
- typeof value.seq === 'string');
67
- }
68
- export function isPairwiseAlignment(value) {
69
- return (isRecord(value) &&
70
- typeof value.consensus === 'string' &&
71
- Array.isArray(value.alns) &&
72
- value.alns.length === 2 &&
73
- value.alns.every(isAlignmentRow));
74
- }
75
63
  function isTrackSpec(value) {
76
64
  return isString(value) || isRecord(value);
77
65
  }
@@ -1,8 +1,7 @@
1
1
  import { SimpleFeature } from '@jbrowse/core/util';
2
- import { DEFAULT_ALIGNMENT_ALGORITHM, alignTranscriptToEntity, alignmentQuality, isLowSimilarity, keepSharedStretches, mappedStructureIdentity, structurePos, transcriptPos, } from 'p2s_mapper';
3
- import { isIdentical } from '../ProteinView/alignOffThread';
2
+ import { DEFAULT_ALIGNMENT_ALGORITHM, alignTranscriptToEntity, alignmentQuality, codingSpans, isLowSimilarity, isoformAlignment, sameProtein, structurePos, transcriptPos, } from 'p2s_mapper';
4
3
  import { assemblyNaming, genomeHoverToTranscriptPos, viewAssemblyName, } from '../ProteinView/util';
5
- import { codingSpans, genomeToTranscriptSeqMapping } from '../mappings';
4
+ import { genomeToTranscriptSeqMapping } from '../mappings';
6
5
  function isLinkableView(view) {
7
6
  return typeof view === 'object' && view !== null && 'proteinLinkage' in view;
8
7
  }
@@ -79,19 +78,6 @@ export function genomeHighlightsForUniProtPosition(views, uniprotPos) {
79
78
  ...new Map(spans.map(s => [`${s.refName}:${s.start}-${s.end}`, s])).values(),
80
79
  ];
81
80
  }
82
- // Two isoforms of one protein differ only in their alternative exons, so the
83
- // shared-stretch rule keeps most of their alignment: 92% for PKM1 on PKM2, 94%
84
- // for FGFR2 IIIc on IIIb. A homolog a Foldseek hit opened differs everywhere,
85
- // and the rule shreds it: mouse TP53 keeps 41%, HBB 28%, BRCA1 9%. Below this
86
- // the entry is another protein, and the alignment maps it column for column.
87
- const ISOFORM_KEPT_FRACTION = 0.8;
88
- function isoformAlignment(pa) {
89
- const kept = keepSharedStretches(pa);
90
- return mappedStructureIdentity(kept).size >=
91
- ISOFORM_KEPT_FRACTION * mappedStructureIdentity(pa).size
92
- ? kept
93
- : pa;
94
- }
95
81
  /**
96
82
  * Align the linked transcript's translation to the sequence the 1D view
97
83
  * shows. Where that is another isoform, only the stretches the two spell
@@ -113,7 +99,7 @@ export async function resolveLinkageAlignment(host) {
113
99
  if (!uniprot) {
114
100
  return { problem: 'the UniProt sequence could not be read' };
115
101
  }
116
- const scored = isIdentical(transcript, uniprot)
102
+ const scored = sameProtein(transcript, uniprot)
117
103
  ? alignTranscriptToEntity(transcript, uniprot, DEFAULT_ALIGNMENT_ALGORITHM)
118
104
  : await host.align(transcript, uniprot);
119
105
  if (!scored) {
@@ -1,4 +1,3 @@
1
- import { stripStopCodon } from 'p2s_mapper';
2
1
  const ALIGNMENT_RPC_SESSION = 'protein3d-alignment';
3
2
  /**
4
3
  * Run an alignment in the host's RPC worker. A worker that cannot, say one an
@@ -18,12 +17,3 @@ export async function alignOffThread({ rpcManager, name, args, inPlace, current
18
17
  return inPlace();
19
18
  }
20
19
  }
21
- /**
22
- * Whether the alignment is free: p2s_mapper skips the DP for an identical
23
- * sequence, so there is nothing to send to the worker, and the answer does not
24
- * wait behind the track renders queued there at launch.
25
- */
26
- export function isIdentical(transcript, seq) {
27
- const t = stripStopCodon(transcript);
28
- return t.length > 0 && t === stripStopCodon(seq);
29
- }
@@ -1,5 +1,4 @@
1
- import { isIdentical } from './alignOffThread';
2
- import { entityAlignedTo } from './entityAlignedTo';
1
+ import { entityAlignedTo, sameProtein } from 'p2s_mapper';
3
2
  /**
4
3
  * Keeps an alignment computed here. Maps an imported one onto the chain it
5
4
  * spells, realigns one that spells none against the stored protein chain, and
@@ -27,7 +26,7 @@ export function decideAlignment(state) {
27
26
  problem: fit.problem,
28
27
  transcript,
29
28
  entity,
30
- identical: isIdentical(transcript, entity.seq),
29
+ identical: sameProtein(transcript, entity.seq),
31
30
  }
32
31
  : { kind: 'discard', problem: fit.problem };
33
32
  }
@@ -35,6 +34,6 @@ export function decideAlignment(state) {
35
34
  kind: 'choose',
36
35
  transcript,
37
36
  entities,
38
- identical: entities.some(e => !e.nucleicAcid && isIdentical(transcript, e.seq)),
37
+ identical: entities.some(e => !e.nucleicAcid && sameProtein(transcript, e.seq)),
39
38
  };
40
39
  }
@@ -20,6 +20,7 @@
20
20
  * domains cover shows the smaller. A site never hides its domain, since the
21
21
  * two layers use different marks.
22
22
  */
23
+ import { transcriptPos } from 'p2s_mapper';
23
24
  import { placeValues } from './variantEffects';
24
25
  const ATOM_MARKS = new Set(['ball-and-stick', 'spacefill', 'line', 'point']);
25
26
  /** The mark a Mol* representation type draws, for the color it takes */
@@ -207,7 +208,7 @@ export function alignmentDomainStatus({ views, connectedViewId, mapping, naming,
207
208
  };
208
209
  }
209
210
  const layer = (kind) => entity && transcriptToStructure
210
- ? placeValues(layerByTranscriptPos(placed, kind), pos => transcriptToStructure[pos], entity)
211
+ ? placeValues(layerByTranscriptPos(placed, kind), pos => transcriptToStructure(transcriptPos(pos)), entity)
211
212
  : undefined;
212
213
  return { domains, placed: layer('domain'), placedSites: layer('site') };
213
214
  }
@@ -223,10 +224,10 @@ export function domainRows({ domains, mapping, naming, transcriptToStructure, st
223
224
  .flatMap(({ feature, index, positions }) => {
224
225
  const cells = [...positions]
225
226
  .flatMap(pos => {
226
- const structurePos = transcriptToStructure[pos];
227
+ const structurePos = transcriptToStructure(transcriptPos(pos));
227
228
  const column = structurePos === undefined
228
229
  ? undefined
229
- : structureToAlignment[structurePos];
230
+ : structureToAlignment(structurePos);
230
231
  return structurePos === undefined || column === undefined
231
232
  ? []
232
233
  : [{ structurePos, column }];
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import { observer } from 'mobx-react';
3
+ import { alignmentCol } from 'p2s_mapper';
3
4
  import { ROW_HEIGHT } from '../constants';
4
5
  /** Which alignment columns get a tick, and which of those a label, in the
5
6
  * structure's author residue numbering (see residueNumber), so the ruler reads
@@ -11,7 +12,7 @@ export function rulerTicks(alignmentToStructure, columns, residueNumber) {
11
12
  return ticks;
12
13
  }
13
14
  for (let col = 0; col < columns; col++) {
14
- const pos = alignmentToStructure[col];
15
+ const pos = alignmentToStructure(alignmentCol(col));
15
16
  if (pos === undefined) {
16
17
  continue;
17
18
  }
@@ -27,7 +28,7 @@ export function rulerTicks(alignmentToStructure, columns, residueNumber) {
27
28
  }
28
29
  const AlignmentRuler = observer(function AlignmentRuler({ model, columns, }) {
29
30
  const { columnWidth } = model;
30
- const ticks = rulerTicks(model.pairwiseAlignmentToStructurePosition, columns, pos => model.residueNumber(pos));
31
+ const ticks = rulerTicks(model.coordinateMapper?.alignmentToStructure, columns, pos => model.residueNumber(pos));
31
32
  return (React.createElement("div", { style: {
32
33
  position: 'relative',
33
34
  height: '100%',
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { observer } from 'mobx-react';
3
+ import { positionRuns } from 'p2s_mapper';
3
4
  import { HOVER_COLOR, HOVER_RANGE_COLOR, MATCH_COLOR, SELECTION_COLOR, SELECTION_OUTLINE, } from '../constants';
4
- import { positionRuns } from '../residueRanges';
5
5
  const Band = observer(function Band({ start, end, columnWidth, background, border, }) {
6
6
  return (React.createElement("div", { style: {
7
7
  position: 'absolute',
@@ -10,9 +10,8 @@ import Link from '@mui/material/Link';
10
10
  import Tooltip from '@mui/material/Tooltip';
11
11
  import Typography from '@mui/material/Typography';
12
12
  import { observer } from 'mobx-react';
13
- import { LOW_IDENTITY_OVER_SHORTER, SHORT_ALIGNMENT_IDENTITY, SHORT_ALIGNMENT_RESIDUES, describeAlignmentQuality, describeCoveredRange, describeTranscriptCoverage, isLowSimilarity, uniprotEntryUrl, } from 'p2s_mapper';
13
+ import { LOW_IDENTITY_OVER_SHORTER, SHORT_ALIGNMENT_IDENTITY, SHORT_ALIGNMENT_RESIDUES, describeAlignmentQuality, describeCoverage, describeCoveredRange, describeTranscriptCoverage, isLowSimilarity, uniprotEntryUrl, } from 'p2s_mapper';
14
14
  import ChainSelect from './ChainSelect';
15
- import { describeCoverage } from '../describeCoverage';
16
15
  const LOW_SIMILARITY_EXPLANATION = `Under ${Math.round(LOW_IDENTITY_OVER_SHORTER * 100)}% of the shorter sequence is identical (${Math.round(SHORT_ALIGNMENT_IDENTITY * 100)}% for an alignment of fewer than ${SHORT_ALIGNMENT_RESIDUES} residues): an alignment this weak is what two unrelated proteins produce, so the positions it maps may be unrelated. Check the mapped chain, the transcript isoform, or import a curated alignment.`;
17
16
  // Which UniProt entry the structure's mapped chain is, and so which one its
18
17
  // feature tracks annotate. For an AlphaFold model that is in the filename, but
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
2
2
  import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField, Typography, } from '@mui/material';
3
3
  import { parsePairwise } from 'clustal-js';
4
4
  import { observer } from 'mobx-react';
5
- import { entityAlignedTo, withoutStopColumn } from '../entityAlignedTo';
5
+ import { entityAlignedTo, withoutStopColumns } from 'p2s_mapper';
6
6
  const ManualAlignmentDialog = observer(function ManualAlignmentDialog({ model, handleClose, }) {
7
7
  const [alignment, setAlignment] = useState('');
8
8
  const [parseError, setParseError] = useState();
@@ -26,7 +26,7 @@ const ManualAlignmentDialog = observer(function ManualAlignmentDialog({ model, h
26
26
  setParseError(fit.problem);
27
27
  }
28
28
  else {
29
- alignmentStructure.importAlignment(withoutStopColumn(parsed));
29
+ alignmentStructure.importAlignment(withoutStopColumns(parsed));
30
30
  handleClose();
31
31
  }
32
32
  }
@@ -1,4 +1,5 @@
1
1
  import { useMemo } from 'react';
2
+ import { structurePos as toStructurePos } from 'p2s_mapper';
2
3
  import useUniProtFeatures from './useUniProtFeatures';
3
4
  // A bond's two positions are its whole meaning, so one residue of a pair says
4
5
  // nothing true about the structure.
@@ -15,12 +16,12 @@ const ENDPOINT_PAIR_TYPES = new Set(['Disulfide bond', 'Cross-link']);
15
16
  * lose every region straddling the construct's ends. Returns undefined when no
16
17
  * residue of the feature has an alignment column.
17
18
  */
18
- export function layoutFeature(feature, structurePositionToAlignmentMap, mapUniProtPosition) {
19
+ export function layoutFeature(feature, structureToAlignment, mapUniProtPosition) {
19
20
  const placed = (uniprotPos) => {
20
21
  const structurePos = mapUniProtPosition(uniprotPos);
21
22
  const column = structurePos === undefined
22
23
  ? undefined
23
- : structurePositionToAlignmentMap[structurePos];
24
+ : structureToAlignment(toStructurePos(structurePos));
24
25
  return structurePos === undefined || column === undefined
25
26
  ? undefined
26
27
  : { structurePos, column };
@@ -80,15 +81,16 @@ export function widestFirst(layouts) {
80
81
  }
81
82
  export default function useProteinFeatureTrackData(model, uniprotId, mapUniProtPosition) {
82
83
  const { features, isLoading, error } = useUniProtFeatures(uniprotId);
83
- const { omittedFeatureTypes, structurePositionToAlignmentMap } = model;
84
+ const { omittedFeatureTypes, coordinateMapper } = model;
85
+ const structureToAlignment = coordinateMapper?.structureToAlignment;
84
86
  const groups = useMemo(() => {
85
- if (!features || !structurePositionToAlignmentMap) {
87
+ if (!features || !structureToAlignment) {
86
88
  return undefined;
87
89
  }
88
90
  const byType = new Map();
89
91
  for (const feature of features) {
90
92
  if (!omittedFeatureTypes.has(feature.type)) {
91
- const layout = layoutFeature(feature, structurePositionToAlignmentMap, mapUniProtPosition);
93
+ const layout = layoutFeature(feature, structureToAlignment, mapUniProtPosition);
92
94
  if (layout) {
93
95
  const list = byType.get(feature.type);
94
96
  if (list) {
@@ -105,11 +107,6 @@ export default function useProteinFeatureTrackData(model, uniprotId, mapUniProtP
105
107
  laneCount: packLanes(layouts),
106
108
  layouts: widestFirst(layouts),
107
109
  }));
108
- }, [
109
- features,
110
- omittedFeatureTypes,
111
- structurePositionToAlignmentMap,
112
- mapUniProtPosition,
113
- ]);
110
+ }, [features, omittedFeatureTypes, structureToAlignment, mapUniProtPosition]);
114
111
  return { groups, isLoading, error };
115
112
  }
@@ -1,4 +1,4 @@
1
- import { codonGenomeSpan, residueNumber } from 'p2s_mapper';
1
+ import { codonGenomeSpan, residueNumber, structurePos } from 'p2s_mapper';
2
2
  /**
3
3
  * A transcript residue's codon as a 1-based locString on the transcript's own
4
4
  * refName, outer bounds included when an intron splits it.
@@ -17,7 +17,7 @@ export function codonLocus(mapping, transcriptPos) {
17
17
  */
18
18
  export function hoverReadout({ hover, entity, structureToTranscript, transcript, locus, }) {
19
19
  const pos = hover.structureSeqPos;
20
- const transcriptPos = pos === undefined ? undefined : structureToTranscript?.[pos];
20
+ const transcriptPos = pos === undefined ? undefined : structureToTranscript?.(structurePos(pos));
21
21
  const structureLetter = pos === undefined ? undefined : entity?.seq[pos];
22
22
  const genomeLetter = transcriptPos === undefined ? undefined : transcript[transcriptPos];
23
23
  const parts = [];
@@ -1,22 +1,9 @@
1
1
  import { getSession } from '@jbrowse/core/util';
2
- import { codingSpans } from '../mappings';
3
- // The coding spans under structure-residue ranges, through the residues the
4
- // alignment pairs with the transcript
5
- function structureRangeSpans(model, ranges) {
6
- const mapping = model.genomeToTranscriptSeqMapping;
7
- if (!mapping) {
8
- return [];
9
- }
10
- const transcriptPositions = [];
11
- for (const range of ranges) {
12
- for (let pos = range.start; pos < range.end; pos++) {
13
- const transcriptPos = model.structureSeqToTranscriptSeqPosition?.[pos];
14
- if (transcriptPos !== undefined) {
15
- transcriptPositions.push(transcriptPos);
16
- }
17
- }
18
- }
19
- return codingSpans(mapping.p2gCodon, transcriptPositions);
2
+ import { structureCodingSpans } from 'p2s_mapper';
3
+ function structureRangeSpans({ genomeToTranscriptSeqMapping, coordinateMapper }, ranges) {
4
+ return genomeToTranscriptSeqMapping && coordinateMapper
5
+ ? structureCodingSpans(genomeToTranscriptSeqMapping.p2gCodon, coordinateMapper, ranges)
6
+ : [];
20
7
  }
21
8
  /**
22
9
  * The genome structure-residue ranges cover, one region per stretch of
@@ -1,70 +1 @@
1
- import { residueNumber } from 'p2s_mapper';
2
- export function rangeList(ranges) {
3
- return ranges === undefined ? [] : 'start' in ranges ? [ranges] : ranges;
4
- }
5
- /**
6
- * Collapse a set of positions into sorted, contiguous [start, end) runs.
7
- */
8
- export function positionRuns(positions) {
9
- const sorted = [...new Set(positions)].sort((a, b) => a - b);
10
- const runs = [];
11
- for (const pos of sorted) {
12
- const last = runs.at(-1);
13
- if (last?.end === pos) {
14
- last.end = pos + 1;
15
- }
16
- else {
17
- runs.push({ start: pos, end: pos + 1 });
18
- }
19
- }
20
- return runs;
21
- }
22
- /**
23
- * The runs of positions whose author number falls in any of the ranges. A
24
- * fusion numbers its partner apart (2RH1's lysozyme is 1002–1161), so a range
25
- * across the fusion site selects the receptor on both sides and not the
26
- * partner between.
27
- */
28
- export function residueRuns(entity, ranges) {
29
- const list = rangeList(ranges);
30
- const positions = [];
31
- for (let pos = 0; pos < (entity?.seq.length ?? 0); pos++) {
32
- const n = residueNumber(entity, pos);
33
- if (list.some(r => n >= r.start && n <= r.end)) {
34
- positions.push(pos);
35
- }
36
- }
37
- return positionRuns(positions);
38
- }
39
- /**
40
- * The runs of structure positions the alignment pairs with any of the
41
- * transcript ranges. A structure residue the transcript lacks, an inserted tag
42
- * or a fusion partner SIFTS unmaps, splits the run rather than being selected.
43
- */
44
- export function transcriptRuns(mapper, ranges) {
45
- const list = rangeList(ranges);
46
- const positions = [];
47
- for (const [transcript, structure] of Object.entries(mapper.maps.transcriptSeqToStructureSeqPosition)) {
48
- const residue = Number(transcript) + 1;
49
- if (list.some(r => residue >= r.start && residue <= r.end)) {
50
- positions.push(structure);
51
- }
52
- }
53
- return positionRuns(positions);
54
- }
55
- /** Sorted [start, end) runs covering the ranges, overlaps and neighbours merged. */
56
- export function positionRangeRuns(ranges) {
57
- const runs = [];
58
- for (const { start, end } of rangeList(ranges)
59
- .filter(r => r.end > r.start)
60
- .toSorted((a, b) => a.start - b.start)) {
61
- const last = runs.at(-1);
62
- if (last && start <= last.end) {
63
- last.end = Math.max(last.end, end);
64
- }
65
- else {
66
- runs.push({ start, end });
67
- }
68
- }
69
- return runs;
70
- }
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import { structurePos } from 'p2s_mapper';
1
2
  // Kyte-Doolittle hydropathy index. Positive = hydrophobic, negative =
2
3
  // hydrophilic. Residues absent from the table (X, gaps, non-standard) map to
3
4
  // undefined so they render as gaps in the track.
@@ -31,13 +32,13 @@ export function kyteDoolittleScores(seq) {
31
32
  }
32
33
  /**
33
34
  * Maps per-structure-residue values (indexed by 0-based structure sequence
34
- * position) onto alignment columns via structurePositionToAlignmentMap.
35
+ * position) onto alignment columns through `structureToAlignment`.
35
36
  * Residues with no value or no alignment column (gaps) are dropped.
36
37
  */
37
- export function mapResidueValuesToColumns(values, structurePositionToAlignmentMap) {
38
- return structurePositionToAlignmentMap
39
- ? values.flatMap((value, structurePos) => {
40
- const col = structurePositionToAlignmentMap[structurePos];
38
+ export function mapResidueValuesToColumns(values, structureToAlignment) {
39
+ return structureToAlignment
40
+ ? values.flatMap((value, pos) => {
41
+ const col = structureToAlignment(structurePos(pos));
41
42
  return value !== undefined && col !== undefined ? [{ col, value }] : [];
42
43
  })
43
44
  : [];
@@ -1,3 +1,4 @@
1
+ import { transcriptPos } from 'p2s_mapper';
1
2
  import { placeValues } from './variantEffects';
2
3
  /** A session's values by 0-based transcript position. */
3
4
  export function valuesByPosition(values) {
@@ -24,7 +25,7 @@ export function residueValuesStatus({ values, entity, transcriptToStructure, })
24
25
  if (!entity || !transcriptToStructure) {
25
26
  return {};
26
27
  }
27
- const placed = placeValues(valuesByPosition(values), pos => transcriptToStructure[pos], entity);
28
+ const placed = placeValues(valuesByPosition(values), pos => transcriptToStructure(transcriptPos(pos)), entity);
28
29
  return placed.byLabelSeqId.size > 0
29
30
  ? { placed }
30
31
  : { message: "None of the values fall on this structure's residues" };
@@ -13,6 +13,7 @@
13
13
  * a few.
14
14
  */
15
15
  import { colord } from '@jbrowse/core/util/colord';
16
+ import { labelSeqIdAt, transcriptPos } from 'p2s_mapper';
16
17
  import loadMolstar from './loadMolstar';
17
18
  import { drawnTests } from './residueFilter';
18
19
  import { serialPerPlugin } from './serialPerPlugin';
@@ -78,8 +79,10 @@ export function sessionHighlightResidues({ highlights, mapping, naming, entity,
78
79
  let firstPos;
79
80
  for (let base = h.start; base < h.end; base++) {
80
81
  const residue = mapping.g2p[base];
81
- const structurePos = residue === undefined ? undefined : transcriptToStructure[residue];
82
- const labelSeqId = structurePos === undefined ? undefined : entity.seqIds[structurePos];
82
+ const structurePos = residue === undefined
83
+ ? undefined
84
+ : transcriptToStructure(transcriptPos(residue));
85
+ const labelSeqId = labelSeqIdAt(entity, structurePos);
83
86
  if (structurePos !== undefined && labelSeqId !== undefined) {
84
87
  labelSeqIds.add(labelSeqId);
85
88
  firstPos = Math.min(firstPos ?? structurePos, structurePos);