jbrowse-plugin-protein3d 0.0.2 → 0.0.4

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 (220) hide show
  1. package/dist/AddHighlightModel/GenomeMouseoverHighlight.js +3 -9
  2. package/dist/AddHighlightModel/GenomeMouseoverHighlight.js.map +1 -1
  3. package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.js +4 -3
  4. package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.js.map +1 -1
  5. package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.d.ts +1 -2
  6. package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.js +4 -3
  7. package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.js.map +1 -1
  8. package/dist/AddHighlightModel/util.js +1 -1
  9. package/dist/AddHighlightModel/util.js.map +1 -1
  10. package/dist/AlphaFoldConfidenceAdapter/AlphaFoldConfidenceAdapter.d.ts +16 -0
  11. package/dist/AlphaFoldConfidenceAdapter/AlphaFoldConfidenceAdapter.js +43 -0
  12. package/dist/AlphaFoldConfidenceAdapter/AlphaFoldConfidenceAdapter.js.map +1 -0
  13. package/dist/AlphaFoldConfidenceAdapter/configSchema.d.ts +13 -0
  14. package/dist/AlphaFoldConfidenceAdapter/configSchema.js +16 -0
  15. package/dist/AlphaFoldConfidenceAdapter/configSchema.js.map +1 -0
  16. package/dist/AlphaFoldConfidenceAdapter/index.d.ts +2 -0
  17. package/dist/AlphaFoldConfidenceAdapter/index.js +11 -0
  18. package/dist/AlphaFoldConfidenceAdapter/index.js.map +1 -0
  19. package/dist/AlphaMissensePathogenicityAdapter/AlphaMissensePathogenicityAdapter.d.ts +30 -0
  20. package/dist/AlphaMissensePathogenicityAdapter/AlphaMissensePathogenicityAdapter.js +78 -0
  21. package/dist/AlphaMissensePathogenicityAdapter/AlphaMissensePathogenicityAdapter.js.map +1 -0
  22. package/dist/AlphaMissensePathogenicityAdapter/configSchema.d.ts +13 -0
  23. package/dist/AlphaMissensePathogenicityAdapter/configSchema.js +16 -0
  24. package/dist/AlphaMissensePathogenicityAdapter/configSchema.js.map +1 -0
  25. package/dist/AlphaMissensePathogenicityAdapter/index.d.ts +2 -0
  26. package/dist/AlphaMissensePathogenicityAdapter/index.js +11 -0
  27. package/dist/AlphaMissensePathogenicityAdapter/index.js.map +1 -0
  28. package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js +201 -34
  29. package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js.map +1 -1
  30. package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.d.ts +7 -4
  31. package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js +35 -14
  32. package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js.map +1 -1
  33. package/dist/LaunchProteinView/components/HelpButton.js +6 -2
  34. package/dist/LaunchProteinView/components/HelpButton.js.map +1 -1
  35. package/dist/LaunchProteinView/components/HelpDialog.js +13 -4
  36. package/dist/LaunchProteinView/components/HelpDialog.js.map +1 -1
  37. package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js +9 -9
  38. package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js.map +1 -1
  39. package/dist/LaunchProteinView/components/MSATable.d.ts +10 -0
  40. package/dist/LaunchProteinView/components/MSATable.js +55 -0
  41. package/dist/LaunchProteinView/components/MSATable.js.map +1 -0
  42. package/dist/LaunchProteinView/components/TranscriptSelector.d.ts +7 -3
  43. package/dist/LaunchProteinView/components/TranscriptSelector.js +25 -8
  44. package/dist/LaunchProteinView/components/TranscriptSelector.js.map +1 -1
  45. package/dist/LaunchProteinView/components/UserProvidedStructure.js +67 -47
  46. package/dist/LaunchProteinView/components/UserProvidedStructure.js.map +1 -1
  47. package/dist/LaunchProteinView/{calculateProteinSequence.js → components/calculateProteinSequence.js} +5 -3
  48. package/dist/LaunchProteinView/components/calculateProteinSequence.js.map +1 -0
  49. package/dist/LaunchProteinView/components/useIsoformProteinSequences.d.ts +14 -0
  50. package/dist/LaunchProteinView/{useProteinSequences.js → components/useIsoformProteinSequences.js} +11 -6
  51. package/dist/LaunchProteinView/components/useIsoformProteinSequences.js.map +1 -0
  52. package/dist/LaunchProteinView/components/useLocalStructureFileSequence.d.ts +7 -0
  53. package/dist/LaunchProteinView/components/useLocalStructureFileSequence.js +64 -0
  54. package/dist/LaunchProteinView/components/useLocalStructureFileSequence.js.map +1 -0
  55. package/dist/LaunchProteinView/{useMyGeneInfo.d.ts → components/useMyGeneInfoUniprotIdLookup.d.ts} +2 -2
  56. package/dist/LaunchProteinView/{useMyGeneInfo.js → components/useMyGeneInfoUniprotIdLookup.js} +15 -10
  57. package/dist/LaunchProteinView/components/useMyGeneInfoUniprotIdLookup.js.map +1 -0
  58. package/dist/LaunchProteinView/components/useRemoteStructureFileSequence.d.ts +7 -0
  59. package/dist/LaunchProteinView/components/useRemoteStructureFileSequence.js +59 -0
  60. package/dist/LaunchProteinView/components/useRemoteStructureFileSequence.js.map +1 -0
  61. package/dist/LaunchProteinView/{util.d.ts → components/util.d.ts} +0 -10
  62. package/dist/LaunchProteinView/{util.js → components/util.js} +4 -25
  63. package/dist/LaunchProteinView/components/util.js.map +1 -0
  64. package/dist/LaunchProteinView/index.js +6 -2
  65. package/dist/LaunchProteinView/index.js.map +1 -1
  66. package/dist/ProteinView/{loadStructureFromData.d.ts → addStructureFromData.d.ts} +2 -2
  67. package/dist/ProteinView/{loadStructureFromData.js → addStructureFromData.js} +3 -8
  68. package/dist/ProteinView/addStructureFromData.js.map +1 -0
  69. package/dist/ProteinView/{loadStructureFromURL.d.ts → addStructureFromURL.d.ts} +2 -2
  70. package/dist/ProteinView/{loadStructureFromURL.js → addStructureFromURL.js} +11 -9
  71. package/dist/ProteinView/addStructureFromURL.js.map +1 -0
  72. package/dist/ProteinView/clearSelection.js +1 -1
  73. package/dist/ProteinView/clearSelection.js.map +1 -1
  74. package/dist/ProteinView/components/ProteinAlignment.d.ts +2 -2
  75. package/dist/ProteinView/components/ProteinAlignment.js +37 -26
  76. package/dist/ProteinView/components/ProteinAlignment.js.map +1 -1
  77. package/dist/ProteinView/components/ProteinAlignmentHelpButton.d.ts +2 -2
  78. package/dist/ProteinView/components/ProteinAlignmentHelpButton.js +6 -4
  79. package/dist/ProteinView/components/ProteinAlignmentHelpButton.js.map +1 -1
  80. package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js +6 -5
  81. package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js.map +1 -1
  82. package/dist/ProteinView/components/ProteinView.js +18 -60
  83. package/dist/ProteinView/components/ProteinView.js.map +1 -1
  84. package/dist/ProteinView/components/{Header.js → ProteinViewHeader.js} +29 -12
  85. package/dist/ProteinView/components/ProteinViewHeader.js.map +1 -0
  86. package/dist/ProteinView/components/SplitString.d.ts +4 -4
  87. package/dist/ProteinView/components/SplitString.js +4 -4
  88. package/dist/ProteinView/components/SplitString.js.map +1 -1
  89. package/dist/ProteinView/genomeToProtein.d.ts +2 -2
  90. package/dist/ProteinView/genomeToProtein.js +4 -5
  91. package/dist/ProteinView/genomeToProtein.js.map +1 -1
  92. package/dist/ProteinView/highlightResidue.js +2 -2
  93. package/dist/ProteinView/highlightResidue.js.map +1 -1
  94. package/dist/ProteinView/launchRemotePairwiseAlignment.d.ts +2 -5
  95. package/dist/ProteinView/launchRemotePairwiseAlignment.js +7 -3
  96. package/dist/ProteinView/launchRemotePairwiseAlignment.js.map +1 -1
  97. package/dist/ProteinView/model.d.ts +496 -156
  98. package/dist/ProteinView/model.js +66 -225
  99. package/dist/ProteinView/model.js.map +1 -1
  100. package/dist/ProteinView/proteinToGenomeMapping.d.ts +6 -6
  101. package/dist/ProteinView/proteinToGenomeMapping.js +29 -28
  102. package/dist/ProteinView/proteinToGenomeMapping.js.map +1 -1
  103. package/dist/ProteinView/selectResidue.js +1 -1
  104. package/dist/ProteinView/selectResidue.js.map +1 -1
  105. package/dist/ProteinView/structureModel.d.ts +183 -0
  106. package/dist/ProteinView/structureModel.js +407 -0
  107. package/dist/ProteinView/structureModel.js.map +1 -0
  108. package/dist/ProteinView/useProteinView.d.ts +1 -4
  109. package/dist/ProteinView/useProteinView.js +3 -15
  110. package/dist/ProteinView/useProteinView.js.map +1 -1
  111. package/dist/ProteinView/util.d.ts +3 -3
  112. package/dist/ProteinView/util.js +8 -6
  113. package/dist/ProteinView/util.js.map +1 -1
  114. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.d.ts +15 -0
  115. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.js +55 -0
  116. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.js.map +1 -0
  117. package/dist/UniProtVariationAdapter/configSchema.d.ts +17 -0
  118. package/dist/UniProtVariationAdapter/configSchema.js +20 -0
  119. package/dist/UniProtVariationAdapter/configSchema.js.map +1 -0
  120. package/dist/UniProtVariationAdapter/index.d.ts +2 -0
  121. package/dist/UniProtVariationAdapter/index.js +11 -0
  122. package/dist/UniProtVariationAdapter/index.js.map +1 -0
  123. package/dist/genomeToTranscriptMapping.d.ts +2 -2
  124. package/dist/genomeToTranscriptMapping.js +3 -3
  125. package/dist/genomeToTranscriptMapping.js.map +1 -1
  126. package/dist/index.js +6 -9
  127. package/dist/index.js.map +1 -1
  128. package/dist/jbrowse-plugin-protein3d.umd.production.min.js +1473 -1489
  129. package/dist/jbrowse-plugin-protein3d.umd.production.min.js.map +4 -4
  130. package/dist/mappings.d.ts +12 -10
  131. package/dist/mappings.js +7 -7
  132. package/dist/mappings.js.map +1 -1
  133. package/dist/mappings.test.js +7 -5
  134. package/dist/mappings.test.js.map +1 -1
  135. package/dist/test_data/gene.d.ts +577 -64
  136. package/dist/test_data/gene.js +1 -1
  137. package/dist/test_data/gene.js.map +1 -1
  138. package/package.json +17 -16
  139. package/src/AddHighlightModel/GenomeMouseoverHighlight.tsx +4 -17
  140. package/src/AddHighlightModel/ProteinToGenomeClickHighlight.tsx +17 -14
  141. package/src/AddHighlightModel/ProteinToGenomeHoverHighlight.tsx +18 -17
  142. package/src/AddHighlightModel/util.ts +1 -1
  143. package/src/AlphaFoldConfidenceAdapter/AlphaFoldConfidenceAdapter.ts +63 -0
  144. package/src/AlphaFoldConfidenceAdapter/configSchema.ts +21 -0
  145. package/src/AlphaFoldConfidenceAdapter/index.ts +19 -0
  146. package/src/AlphaMissensePathogenicityAdapter/AlphaMissensePathogenicityAdapter.ts +109 -0
  147. package/src/AlphaMissensePathogenicityAdapter/configSchema.ts +21 -0
  148. package/src/AlphaMissensePathogenicityAdapter/index.ts +19 -0
  149. package/src/LaunchProteinView/components/AlphaFoldDBSearch.tsx +266 -53
  150. package/src/LaunchProteinView/components/AlphaFoldDBSearchStatus.tsx +71 -29
  151. package/src/LaunchProteinView/components/HelpButton.tsx +10 -2
  152. package/src/LaunchProteinView/components/HelpDialog.tsx +41 -8
  153. package/src/LaunchProteinView/components/LaunchProteinViewDialog.tsx +10 -12
  154. package/src/LaunchProteinView/components/MSATable.tsx +98 -0
  155. package/src/LaunchProteinView/components/TranscriptSelector.tsx +39 -11
  156. package/src/LaunchProteinView/components/UserProvidedStructure.tsx +119 -68
  157. package/src/LaunchProteinView/{calculateProteinSequence.ts → components/calculateProteinSequence.ts} +6 -4
  158. package/src/LaunchProteinView/{useProteinSequences.ts → components/useIsoformProteinSequences.ts} +12 -7
  159. package/src/LaunchProteinView/components/useLocalStructureFileSequence.ts +72 -0
  160. package/src/LaunchProteinView/{useMyGeneInfo.ts → components/useMyGeneInfoUniprotIdLookup.ts} +16 -11
  161. package/src/LaunchProteinView/components/useRemoteStructureFileSequence.ts +59 -0
  162. package/src/LaunchProteinView/{util.ts → components/util.ts} +4 -36
  163. package/src/LaunchProteinView/index.ts +36 -26
  164. package/src/ProteinView/{loadStructureFromData.ts → addStructureFromData.ts} +2 -8
  165. package/src/ProteinView/{loadStructureFromURL.ts → addStructureFromURL.ts} +11 -11
  166. package/src/ProteinView/clearSelection.ts +1 -1
  167. package/src/ProteinView/components/ProteinAlignment.tsx +51 -35
  168. package/src/ProteinView/components/ProteinAlignmentHelpButton.tsx +4 -4
  169. package/src/ProteinView/components/ProteinAlignmentHelpDialog.tsx +15 -11
  170. package/src/ProteinView/components/ProteinView.tsx +22 -82
  171. package/src/ProteinView/components/{Header.tsx → ProteinViewHeader.tsx} +44 -21
  172. package/src/ProteinView/components/SplitString.tsx +9 -9
  173. package/src/ProteinView/genomeToProtein.ts +5 -9
  174. package/src/ProteinView/highlightResidue.ts +2 -2
  175. package/src/ProteinView/launchRemotePairwiseAlignment.ts +6 -3
  176. package/src/ProteinView/model.ts +80 -265
  177. package/src/ProteinView/proteinToGenomeMapping.ts +40 -38
  178. package/src/ProteinView/selectResidue.ts +1 -1
  179. package/src/ProteinView/structureModel.ts +512 -0
  180. package/src/ProteinView/useProteinView.ts +2 -19
  181. package/src/ProteinView/util.ts +20 -9
  182. package/src/UniProtVariationAdapter/UniProtVariationAdapter.ts +99 -0
  183. package/src/UniProtVariationAdapter/configSchema.ts +25 -0
  184. package/src/UniProtVariationAdapter/index.ts +17 -0
  185. package/src/__snapshots__/mappings.test.ts.snap +224 -224
  186. package/src/genomeToTranscriptMapping.ts +9 -9
  187. package/src/index.ts +7 -12
  188. package/src/mappings.test.ts +7 -5
  189. package/src/mappings.ts +25 -23
  190. package/src/test_data/gene.ts +3 -3
  191. package/dist/LaunchProteinView/calculateProteinSequence.js.map +0 -1
  192. package/dist/LaunchProteinView/components/PreLoadedStructureMapping.d.ts +0 -8
  193. package/dist/LaunchProteinView/components/PreLoadedStructureMapping.js +0 -72
  194. package/dist/LaunchProteinView/components/PreLoadedStructureMapping.js.map +0 -1
  195. package/dist/LaunchProteinView/components/useCheckAlphaFoldDBExistence.d.ts +0 -7
  196. package/dist/LaunchProteinView/components/useCheckAlphaFoldDBExistence.js +0 -26
  197. package/dist/LaunchProteinView/components/useCheckAlphaFoldDBExistence.js.map +0 -1
  198. package/dist/LaunchProteinView/useMyGeneInfo.js.map +0 -1
  199. package/dist/LaunchProteinView/useProteinSequences.d.ts +0 -10
  200. package/dist/LaunchProteinView/useProteinSequences.js.map +0 -1
  201. package/dist/LaunchProteinView/util.js.map +0 -1
  202. package/dist/ProteinModelSessionExtension.d.ts +0 -11
  203. package/dist/ProteinModelSessionExtension.js +0 -53
  204. package/dist/ProteinModelSessionExtension.js.map +0 -1
  205. package/dist/ProteinView/components/Header.js.map +0 -1
  206. package/dist/ProteinView/loadStructureFromData.js.map +0 -1
  207. package/dist/ProteinView/loadStructureFromURL.js.map +0 -1
  208. package/dist/ProteinView/useProteinViewClickBehavior.d.ts +0 -8
  209. package/dist/ProteinView/useProteinViewClickBehavior.js +0 -34
  210. package/dist/ProteinView/useProteinViewClickBehavior.js.map +0 -1
  211. package/dist/ProteinView/useProteinViewHoverBehavior.d.ts +0 -6
  212. package/dist/ProteinView/useProteinViewHoverBehavior.js +0 -31
  213. package/dist/ProteinView/useProteinViewHoverBehavior.js.map +0 -1
  214. package/src/LaunchProteinView/components/PreLoadedStructureMapping.tsx +0 -153
  215. package/src/LaunchProteinView/components/useCheckAlphaFoldDBExistence.ts +0 -31
  216. package/src/ProteinModelSessionExtension.ts +0 -71
  217. package/src/ProteinView/useProteinViewClickBehavior.ts +0 -48
  218. package/src/ProteinView/useProteinViewHoverBehavior.ts +0 -44
  219. /package/dist/LaunchProteinView/{calculateProteinSequence.d.ts → components/calculateProteinSequence.d.ts} +0 -0
  220. /package/dist/ProteinView/components/{Header.d.ts → ProteinViewHeader.d.ts} +0 -0
@@ -1,5 +1,6 @@
1
1
  import React from 'react'
2
2
  import { observer } from 'mobx-react'
3
+ import { LoadingEllipses } from '@jbrowse/core/ui'
3
4
  import CascadingMenuButton from '@jbrowse/core/ui/CascadingMenuButton'
4
5
 
5
6
  // icons
@@ -9,46 +10,62 @@ import Visibility from '@mui/icons-material/Visibility'
9
10
  // locals
10
11
  import { JBrowsePluginProteinViewModel } from '../model'
11
12
  import ProteinAlignment from './ProteinAlignment'
12
- import { LoadingEllipses } from '@jbrowse/core/ui'
13
13
 
14
14
  const ProteinViewHeader = observer(function ({
15
15
  model,
16
16
  }: {
17
17
  model: JBrowsePluginProteinViewModel
18
18
  }) {
19
- const { alignment, showAlignment } = model
19
+ const { structures, showAlignment } = model
20
20
  return (
21
21
  <div>
22
22
  <InformativeHeaderArea model={model} />
23
- {showAlignment && alignment ? (
24
- <ProteinAlignment model={model} />
25
- ) : (
26
- <LoadingEllipses message="Loading pairwise alignment" />
27
- )}
23
+ {showAlignment
24
+ ? structures.map((structure, idx) => {
25
+ const { pairwiseAlignment } = structure
26
+ return (
27
+ <div key={idx}>
28
+ {pairwiseAlignment ? (
29
+ <ProteinAlignment key={idx} model={structure} />
30
+ ) : (
31
+ <LoadingEllipses message="Loading pairwise alignment" />
32
+ )}
33
+ </div>
34
+ )
35
+ })
36
+ : null}
28
37
  </div>
29
38
  )
30
39
  })
31
40
 
32
- const InformativeHeaderArea = observer(function ({
41
+ const StructureInfoHeaderArea = observer(function ({
33
42
  model,
34
43
  }: {
35
44
  model: JBrowsePluginProteinViewModel
36
45
  }) {
37
- const {
38
- showAlignment,
39
- clickString,
40
- hoverString,
41
- showHighlight,
42
- zoomToBaseLevel,
43
- } = model
44
- return (
45
- <div style={{ display: 'flex' }}>
46
- <span>
46
+ return model.structures.map((s, id) => {
47
+ const { clickString, hoverString } = s
48
+
49
+ return (
50
+ <span key={id}>
47
51
  {[
48
52
  clickString ? `Click: ${clickString}` : '',
49
53
  hoverString ? `Hover: ${hoverString}` : '',
50
54
  ].join(' ')}
51
55
  </span>
56
+ )
57
+ })
58
+ })
59
+
60
+ const InformativeHeaderArea = observer(function ({
61
+ model,
62
+ }: {
63
+ model: JBrowsePluginProteinViewModel
64
+ }) {
65
+ const { showAlignment, showHighlight, zoomToBaseLevel } = model
66
+ return (
67
+ <div style={{ display: 'flex' }}>
68
+ <StructureInfoHeaderArea model={model} />
52
69
  <span style={{ flexGrow: 1 }} />
53
70
  <CascadingMenuButton
54
71
  menuItems={[
@@ -57,21 +74,27 @@ const InformativeHeaderArea = observer(function ({
57
74
  type: 'checkbox',
58
75
  checked: showAlignment,
59
76
  icon: Visibility,
60
- onClick: () => model.setShowAlignment(!showAlignment),
77
+ onClick: () => {
78
+ model.setShowAlignment(!showAlignment)
79
+ },
61
80
  },
62
81
  {
63
82
  label: 'Show pairwise alignment as highlight',
64
83
  type: 'checkbox',
65
84
  checked: showHighlight,
66
85
  icon: Visibility,
67
- onClick: () => model.setShowHighlight(!showHighlight),
86
+ onClick: () => {
87
+ model.setShowHighlight(!showHighlight)
88
+ },
68
89
  },
69
90
  {
70
91
  label: 'Zoom to base level on click',
71
92
  type: 'checkbox',
72
93
  checked: zoomToBaseLevel,
73
94
  icon: Visibility,
74
- onClick: () => model.setZoomToBaseLevel(!zoomToBaseLevel),
95
+ onClick: () => {
96
+ model.setZoomToBaseLevel(!zoomToBaseLevel)
97
+ },
75
98
  },
76
99
  ]}
77
100
  >
@@ -2,18 +2,18 @@ import React from 'react'
2
2
 
3
3
  export default function SplitString({
4
4
  str,
5
- col,
6
- set,
5
+ gapSet,
6
+ hoveredPosition,
7
+ showHighlight,
7
8
  onMouseOver,
8
9
  onClick,
9
- showHighlight,
10
10
  }: {
11
11
  str: string
12
- col?: number
13
- set?: Set<number>
12
+ gapSet?: Set<number>
13
+ hoveredPosition?: number
14
+ showHighlight: boolean
14
15
  onMouseOver?: (arg: number) => void
15
16
  onClick?: (arg: number) => void
16
- showHighlight: boolean
17
17
  }) {
18
18
  return str.split('').map((d, i) => (
19
19
  <span
@@ -22,9 +22,9 @@ export default function SplitString({
22
22
  onClick={() => onClick?.(i)}
23
23
  style={{
24
24
  background:
25
- col !== undefined && i === col
26
- ? '#f69'
27
- : set?.has(i) && showHighlight
25
+ hoveredPosition !== undefined && i === hoveredPosition
26
+ ? '#f698'
27
+ : gapSet?.has(i) && showHighlight
28
28
  ? '#33ff19'
29
29
  : undefined,
30
30
  }}
@@ -1,21 +1,17 @@
1
1
  import { getSession } from '@jbrowse/core/util'
2
2
  import { checkHovered } from './util'
3
- import { JBrowsePluginProteinViewModel } from './model'
3
+ import { JBrowsePluginProteinStructureModel } from './model'
4
4
 
5
5
  export function genomeToProtein({
6
6
  model,
7
7
  }: {
8
- model: JBrowsePluginProteinViewModel
8
+ model: JBrowsePluginProteinStructureModel
9
9
  }): number | undefined {
10
10
  const { hovered } = getSession(model)
11
11
  const { genomeToTranscriptSeqMapping, connectedView } = model
12
- if (
13
- !connectedView?.initialized ||
12
+ return !connectedView?.initialized ||
14
13
  !genomeToTranscriptSeqMapping ||
15
14
  !checkHovered(hovered)
16
- ) {
17
- return undefined
18
- }
19
-
20
- return genomeToTranscriptSeqMapping.g2p[hovered.hoverPosition.coord]
15
+ ? undefined
16
+ : genomeToTranscriptSeqMapping.g2p[hovered.hoverPosition.coord]
21
17
  }
@@ -16,8 +16,8 @@ export default function highlightResidue({
16
16
  selectedResidue: selectedResidue + 1,
17
17
  })
18
18
  const loci = StructureSelection.toLociWithSourceUnits(sel)
19
- plugin?.managers.interactivity.lociHighlights.clearHighlights()
20
- plugin?.managers.interactivity.lociHighlights.highlight({
19
+ plugin.managers.interactivity.lociHighlights.clearHighlights()
20
+ plugin.managers.interactivity.lociHighlights.highlight({
21
21
  loci,
22
22
  })
23
23
  }
@@ -27,7 +27,7 @@ async function runEmbossMatcher({
27
27
  })
28
28
  const ret = await textfetch(`${base}/emboss_matcher/result/${jobId}/aln`)
29
29
  return {
30
- alignment: parsePairwise(
30
+ pairwiseAlignment: parsePairwise(
31
31
  ret
32
32
  .split('\n')
33
33
  .filter(line => !line.startsWith('#'))
@@ -61,7 +61,7 @@ async function runEmbossNeedle({
61
61
 
62
62
  const ret = await textfetch(`${base}/emboss_needle/result/${jobId}/aln`)
63
63
  return {
64
- alignment: parsePairwise(
64
+ pairwiseAlignment: parsePairwise(
65
65
  ret
66
66
  .split('\n')
67
67
  .filter(line => !line.startsWith('#'))
@@ -78,15 +78,18 @@ async function wait({
78
78
  algorithm: string
79
79
  onProgress: (arg: string) => void
80
80
  }) {
81
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
81
82
  while (true) {
82
83
  for (let i = 0; i < 10; i++) {
83
84
  await timeout(1000)
84
- onProgress(`Re-checking alignment to PDB seq1,seq2 in... ${10 - i}`)
85
+ onProgress(`Re-checking pairwiseAlignment to PDB seq1,seq2 in... ${10 - i}`)
85
86
  }
86
87
  const result = await textfetch(`${base}/${algorithm}/status/${jobId}`)
87
88
 
88
89
  if (result === 'FINISHED') {
89
90
  break
91
+ } else if (result.includes('FAILED')) {
92
+ throw new Error('Remote returned FAILED')
90
93
  }
91
94
  }
92
95
  }
@@ -1,28 +1,14 @@
1
1
  import { autorun } from 'mobx'
2
2
  import { BaseViewModel } from '@jbrowse/core/pluggableElementTypes'
3
- import { ElementId, Region } from '@jbrowse/core/util/types/mst'
4
- import { Region as IRegion } from '@jbrowse/core/util/types'
5
- import { Instance, addDisposer, cast, types } from 'mobx-state-tree'
6
- import {
7
- SimpleFeature,
8
- SimpleFeatureSerialized,
9
- getSession,
10
- } from '@jbrowse/core/util'
11
- import { parsePairwise } from 'clustal-js'
12
- import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
3
+ import { ElementId } from '@jbrowse/core/util/types/mst'
4
+ import { Instance, addDisposer, types } from 'mobx-state-tree'
13
5
 
14
6
  // locals
15
- import { checkHovered, invertMap, toStr } from './util'
16
- import { launchPairwiseAlignment } from './launchRemotePairwiseAlignment'
17
- import {
18
- structureSeqVsTranscriptSeqMap,
19
- genomeToTranscriptSeqMapping,
20
- structurePositionToAlignmentMap,
21
- transcriptPositionToAlignmentMap,
22
- } from '../mappings'
23
-
24
- type LGV = LinearGenomeViewModel
25
- type MaybeLGV = LGV | undefined
7
+ import { PluginContext } from 'molstar/lib/mol-plugin/context'
8
+ import { addStructureFromData } from './addStructureFromData'
9
+ import { addStructureFromURL } from './addStructureFromURL'
10
+ import Structure from './structureModel'
11
+ import highlightResidue from './highlightResidue'
26
12
 
27
13
  /**
28
14
  * #stateModel Protein3dViewPlugin
@@ -32,6 +18,7 @@ type MaybeLGV = LGV | undefined
32
18
  function stateModelFactory() {
33
19
  return types
34
20
  .compose(
21
+ 'ProteinView',
35
22
  BaseViewModel,
36
23
  types.model({
37
24
  /**
@@ -42,188 +29,77 @@ function stateModelFactory() {
42
29
  * #property
43
30
  */
44
31
  type: types.literal('ProteinView'),
45
- /**
46
- * #property
47
- * url to structure file
48
- */
49
- url: types.maybe(types.string),
50
- /**
51
- * #property
52
- * full string for structure data
53
- */
54
- data: types.maybe(types.string),
55
32
  /**
56
33
  * #property
57
34
  */
58
- clickGenomeHighlights: types.array(Region),
59
- /**
60
- * #property
61
- */
62
- hoverGenomeHighlights: types.array(Region),
35
+ structures: types.array(Structure),
36
+
63
37
  /**
64
38
  * #property
65
39
  */
66
- showControls: true,
40
+ showControls: false,
67
41
  /**
68
42
  * #property
69
43
  */
70
44
  height: types.optional(types.number, 650),
71
- /**
72
- * #property
73
- */
74
- feature: types.frozen<SimpleFeatureSerialized>(),
75
- /**
76
- * #property
77
- */
78
- seq1: types.maybe(types.string),
79
- /**
80
- * #property
81
- */
82
- seq2: types.maybe(types.string),
83
- /**
84
- * #property
85
- */
86
- alignment: types.frozen<ReturnType<typeof parsePairwise> | undefined>(),
87
45
 
88
46
  /**
89
47
  * #property
90
48
  */
91
- connectedViewId: types.maybe(types.string),
49
+ showHighlight: false,
92
50
  /**
93
51
  * #property
94
52
  */
95
- showHighlight: true,
53
+ zoomToBaseLevel: true,
96
54
  /**
97
55
  * #property
98
56
  */
99
- zoomToBaseLevel: false,
100
- /**
101
- * #property
102
- */
103
- showAlignment: true,
57
+ showAlignment: false,
104
58
  }),
105
59
  )
106
60
  .volatile(() => ({
107
61
  /**
108
62
  * #volatile
109
63
  */
110
- error: undefined as unknown,
111
- /**
112
- * #volatile
113
- */
114
- clickPosition: undefined as
115
- | {
116
- structureSeqPos: number
117
- code: string
118
- chain: string
119
- }
120
- | undefined,
64
+ progress: '',
121
65
  /**
122
66
  * #volatile
123
67
  */
124
- hoverPosition: undefined as
125
- | {
126
- structureSeqPos: number
127
- code?: string
128
- chain?: string
129
- }
130
- | undefined,
68
+ error: undefined as unknown,
131
69
  /**
132
70
  * #volatile
133
71
  */
134
- progress: '',
135
- }))
136
- .views(self => ({
137
- /**
138
- * #getter
139
- */
140
- get connectedView() {
141
- const { views } = getSession(self)
142
- return views.find(f => f.id === self.connectedViewId) as MaybeLGV
143
- },
72
+ molstarPluginContext: undefined as PluginContext | undefined,
144
73
  }))
74
+
145
75
  .actions(self => ({
146
76
  /**
147
77
  * #action
148
78
  */
149
- setShowAlignment(f: boolean) {
150
- self.showAlignment = f
151
- },
152
- /**
153
- * #action
154
- */
155
- setHoveredPosition(arg?: {
156
- structureSeqPos: number
157
- chain?: string
158
- code?: string
159
- }) {
160
- self.hoverPosition = arg
79
+ setHeight(n: number) {
80
+ self.height = n
161
81
  },
162
82
  /**
163
83
  * #action
164
84
  */
165
- setSeqs(str1?: string, str2?: string) {
166
- self.seq1 = str1
167
- self.seq2 = str2
85
+ setShowAlignment(f: boolean) {
86
+ self.showAlignment = f
168
87
  },
88
+
169
89
  /**
170
90
  * #action
171
91
  */
172
92
  setShowControls(arg: boolean) {
173
93
  self.showControls = arg
174
94
  },
175
- /**
176
- * #action
177
- */
178
- setProgress(str: string) {
179
- self.progress = str
180
- },
181
- /**
182
- * #action
183
- */
184
- setClickedPosition(arg?: {
185
- structureSeqPos: number
186
- code: string
187
- chain: string
188
- }) {
189
- self.clickPosition = arg
190
- },
191
- /**
192
- * #action
193
- */
194
- setClickGenomeHighlights(r: IRegion[]) {
195
- self.clickGenomeHighlights = cast(r)
196
- },
197
- /**
198
- * #action
199
- */
200
- clearClickGenomeHighlights() {
201
- self.clickGenomeHighlights = cast([])
202
- },
203
- /**
204
- * #action
205
- */
206
- setHoverGenomeHighlights(r: IRegion[]) {
207
- self.hoverGenomeHighlights = cast(r)
208
- },
209
- /**
210
- * #action
211
- */
212
- clearHoverGenomeHighlights() {
213
- self.hoverGenomeHighlights = cast([])
214
- },
95
+
215
96
  /**
216
97
  * #action
217
98
  */
218
99
  setError(e: unknown) {
219
100
  self.error = e
220
101
  },
221
- /**
222
- * #action
223
- */
224
- setAlignment(r?: ReturnType<typeof parsePairwise>) {
225
- self.alignment = r
226
- },
102
+
227
103
  /**
228
104
  * #action
229
105
  */
@@ -236,139 +112,73 @@ function stateModelFactory() {
236
112
  setZoomToBaseLevel(arg: boolean) {
237
113
  self.zoomToBaseLevel = arg
238
114
  },
239
- }))
240
- .views(self => ({
241
- /**
242
- * #getter
243
- */
244
- get structureSeqToTranscriptSeqPosition() {
245
- return self.alignment
246
- ? structureSeqVsTranscriptSeqMap(self.alignment)
247
- .structureSeqToTranscriptSeqPosition
248
- : undefined
249
- },
250
- /**
251
- * #getter
252
- */
253
- get transcriptSeqToStructureSeqPosition() {
254
- return self.alignment
255
- ? structureSeqVsTranscriptSeqMap(self.alignment)
256
- .transcriptSeqToStructureSeqPosition
257
- : undefined
258
- },
259
115
  /**
260
- * #getter
261
- */
262
- get structurePositionToAlignmentMap() {
263
- return self.alignment
264
- ? structurePositionToAlignmentMap(self.alignment)
265
- : undefined
266
- },
267
- /**
268
- * #getter
269
- */
270
- get transcriptPositionToAlignmentMap() {
271
- return self.alignment
272
- ? transcriptPositionToAlignmentMap(self.alignment)
273
- : undefined
274
- },
275
- /**
276
- * #getter
277
- */
278
- get alignmentToTranscriptPosition() {
279
- return this.transcriptPositionToAlignmentMap
280
- ? invertMap(this.transcriptPositionToAlignmentMap)
281
- : undefined
282
- },
283
- /**
284
- * #getter
285
- */
286
- get alignmentToStructurePosition() {
287
- return this.structurePositionToAlignmentMap
288
- ? invertMap(this.structurePositionToAlignmentMap)
289
- : undefined
290
- },
291
- /**
292
- * #getter
293
- */
294
- get clickString() {
295
- const r = self.clickPosition
296
- return r ? toStr(r) : ''
297
- },
298
- /**
299
- * #getter
300
- */
301
- get hoverString() {
302
- const r = self.hoverPosition
303
- return r ? toStr(r) : ''
304
- },
305
- /**
306
- * #getter
307
- */
308
- get genomeToTranscriptSeqMapping() {
309
- return self.feature
310
- ? genomeToTranscriptSeqMapping(new SimpleFeature(self.feature))
311
- : undefined
312
- },
313
- /**
314
- * #getter
116
+ * #action
315
117
  */
316
- get structureSeqHoverPos(): number | undefined {
317
- return self.hoverPosition?.structureSeqPos
118
+ setMolstarPluginContext(p?: PluginContext) {
119
+ self.molstarPluginContext = p
318
120
  },
319
121
  }))
320
122
  .actions(self => ({
321
123
  afterAttach() {
322
- // pairwise align transcript sequence to structure sequence
323
124
  addDisposer(
324
125
  self,
325
126
  autorun(async () => {
326
- try {
327
- const { seq1, seq2 } = self
328
- if (!!self.alignment || !seq1 || !seq2) {
329
- return
127
+ const { structures, molstarPluginContext } = self
128
+ if (molstarPluginContext) {
129
+ for (const structure of structures) {
130
+ try {
131
+ const { model } = structure.data
132
+ ? await addStructureFromData({
133
+ data: structure.data,
134
+ plugin: molstarPluginContext,
135
+ })
136
+ : structure.url
137
+ ? await addStructureFromURL({
138
+ url: structure.url,
139
+ plugin: molstarPluginContext,
140
+ })
141
+ : { model: undefined }
142
+
143
+ const sequences = model?.obj?.data.sequence.sequences.map(
144
+ s => {
145
+ let seq = ''
146
+ const arr = s.sequence.label.toArray()
147
+ // eslint-disable-next-line unicorn/no-for-loop,@typescript-eslint/prefer-for-of
148
+ for (let i = 0; i < arr.length; i++) {
149
+ seq += arr[i]!
150
+ }
151
+ return seq
152
+ },
153
+ )
154
+ structure.setSequences(sequences)
155
+ } catch (e) {
156
+ self.setError(e)
157
+ console.error(e)
158
+ }
330
159
  }
331
- const alignment = await launchPairwiseAlignment({
332
- seq1,
333
- seq2,
334
- algorithm: 'emboss_needle',
335
- onProgress: arg => self.setProgress(arg),
336
- })
337
- self.setAlignment(alignment.alignment)
338
- } catch (e) {
339
- console.error(e)
340
- self.setError(e)
341
160
  }
342
161
  }),
343
162
  )
344
163
 
345
- // convert hover over the genome to structure position
346
164
  addDisposer(
347
165
  self,
348
166
  autorun(() => {
349
- const { hovered } = getSession(self)
350
- const {
351
- transcriptSeqToStructureSeqPosition,
352
- genomeToTranscriptSeqMapping,
353
- connectedView,
354
- } = self
355
- if (
356
- !connectedView?.initialized ||
357
- !genomeToTranscriptSeqMapping ||
358
- !checkHovered(hovered)
359
- ) {
360
- return undefined
361
- }
362
-
363
- const pos =
364
- genomeToTranscriptSeqMapping.g2p[hovered.hoverPosition.coord]
365
- const c0 = pos
366
- ? transcriptSeqToStructureSeqPosition?.[pos]
367
- : undefined
368
- if (c0 !== undefined) {
369
- self.setHoveredPosition({
370
- structureSeqPos: c0,
371
- })
167
+ const { structures, molstarPluginContext } = self
168
+ if (molstarPluginContext) {
169
+ for (const [i, s0] of structures.entries()) {
170
+ const structure =
171
+ molstarPluginContext.managers.structure.hierarchy.current
172
+ .structures[i]?.cell.obj?.data
173
+ const pos = s0.structureSeqHoverPos
174
+ if (structure && pos !== undefined) {
175
+ highlightResidue({
176
+ structure,
177
+ plugin: molstarPluginContext,
178
+ selectedResidue: pos,
179
+ })
180
+ }
181
+ }
372
182
  }
373
183
  }),
374
184
  )
@@ -377,8 +187,13 @@ function stateModelFactory() {
377
187
  }
378
188
 
379
189
  export default stateModelFactory
190
+
380
191
  export type JBrowsePluginProteinViewStateModel = ReturnType<
381
192
  typeof stateModelFactory
382
193
  >
383
194
  export type JBrowsePluginProteinViewModel =
384
195
  Instance<JBrowsePluginProteinViewStateModel>
196
+
197
+ export type JBrowsePluginProteinStructureStateModel = typeof Structure
198
+ export type JBrowsePluginProteinStructureModel =
199
+ Instance<JBrowsePluginProteinStructureStateModel>