jbrowse-plugin-protein3d 0.0.3 → 0.0.5

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 (196) hide show
  1. package/dist/AddHighlightModel/GenomeMouseoverHighlight.js +3 -9
  2. package/dist/AddHighlightModel/GenomeMouseoverHighlight.js.map +1 -1
  3. package/dist/AddHighlightModel/HighlightComponents.d.ts +1 -2
  4. package/dist/AddHighlightModel/HighlightComponents.js.map +1 -1
  5. package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.js +4 -3
  6. package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.js.map +1 -1
  7. package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.d.ts +1 -2
  8. package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.js +4 -3
  9. package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.js.map +1 -1
  10. package/dist/AddHighlightModel/util.js +1 -1
  11. package/dist/AddHighlightModel/util.js.map +1 -1
  12. package/dist/AlphaFoldConfidenceAdapter/AlphaFoldConfidenceAdapter.d.ts +16 -0
  13. package/dist/AlphaFoldConfidenceAdapter/AlphaFoldConfidenceAdapter.js +43 -0
  14. package/dist/AlphaFoldConfidenceAdapter/AlphaFoldConfidenceAdapter.js.map +1 -0
  15. package/dist/AlphaFoldConfidenceAdapter/configSchema.d.ts +13 -0
  16. package/dist/AlphaFoldConfidenceAdapter/configSchema.js +16 -0
  17. package/dist/AlphaFoldConfidenceAdapter/configSchema.js.map +1 -0
  18. package/dist/AlphaFoldConfidenceAdapter/index.d.ts +2 -0
  19. package/dist/AlphaFoldConfidenceAdapter/index.js +11 -0
  20. package/dist/AlphaFoldConfidenceAdapter/index.js.map +1 -0
  21. package/dist/AlphaMissensePathogenicityAdapter/AlphaMissensePathogenicityAdapter.d.ts +30 -0
  22. package/dist/AlphaMissensePathogenicityAdapter/AlphaMissensePathogenicityAdapter.js +78 -0
  23. package/dist/AlphaMissensePathogenicityAdapter/AlphaMissensePathogenicityAdapter.js.map +1 -0
  24. package/dist/AlphaMissensePathogenicityAdapter/configSchema.d.ts +13 -0
  25. package/dist/AlphaMissensePathogenicityAdapter/configSchema.js +16 -0
  26. package/dist/AlphaMissensePathogenicityAdapter/configSchema.js.map +1 -0
  27. package/dist/AlphaMissensePathogenicityAdapter/index.d.ts +2 -0
  28. package/dist/AlphaMissensePathogenicityAdapter/index.js +11 -0
  29. package/dist/AlphaMissensePathogenicityAdapter/index.js.map +1 -0
  30. package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js +162 -13
  31. package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js.map +1 -1
  32. package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js +8 -6
  33. package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js.map +1 -1
  34. package/dist/LaunchProteinView/components/HelpButton.js +6 -2
  35. package/dist/LaunchProteinView/components/HelpButton.js.map +1 -1
  36. package/dist/LaunchProteinView/components/HelpDialog.js +3 -1
  37. package/dist/LaunchProteinView/components/HelpDialog.js.map +1 -1
  38. package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js +12 -4
  39. package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js.map +1 -1
  40. package/dist/LaunchProteinView/components/MSATable.js +3 -1
  41. package/dist/LaunchProteinView/components/MSATable.js.map +1 -1
  42. package/dist/LaunchProteinView/components/ManualUniProtIDEntry.d.ts +8 -0
  43. package/dist/LaunchProteinView/components/ManualUniProtIDEntry.js +225 -0
  44. package/dist/LaunchProteinView/components/ManualUniProtIDEntry.js.map +1 -0
  45. package/dist/LaunchProteinView/components/TranscriptSelector.js +3 -1
  46. package/dist/LaunchProteinView/components/TranscriptSelector.js.map +1 -1
  47. package/dist/LaunchProteinView/components/UserProvidedStructure.js +19 -12
  48. package/dist/LaunchProteinView/components/UserProvidedStructure.js.map +1 -1
  49. package/dist/LaunchProteinView/components/calculateProteinSequence.js +5 -3
  50. package/dist/LaunchProteinView/components/calculateProteinSequence.js.map +1 -1
  51. package/dist/LaunchProteinView/components/useLocalStructureFileSequence.d.ts +1 -1
  52. package/dist/LaunchProteinView/components/useLocalStructureFileSequence.js +29 -9
  53. package/dist/LaunchProteinView/components/useLocalStructureFileSequence.js.map +1 -1
  54. package/dist/LaunchProteinView/components/useRemoteStructureFileSequence.d.ts +1 -1
  55. package/dist/LaunchProteinView/components/useRemoteStructureFileSequence.js +25 -8
  56. package/dist/LaunchProteinView/components/useRemoteStructureFileSequence.js.map +1 -1
  57. package/dist/LaunchProteinView/components/util.js +1 -1
  58. package/dist/LaunchProteinView/index.js +7 -3
  59. package/dist/LaunchProteinView/index.js.map +1 -1
  60. package/dist/ProteinView/{loadStructureFromData.d.ts → addStructureFromData.d.ts} +2 -2
  61. package/dist/ProteinView/{loadStructureFromData.js → addStructureFromData.js} +3 -8
  62. package/dist/ProteinView/addStructureFromData.js.map +1 -0
  63. package/dist/ProteinView/{loadStructureFromURL.d.ts → addStructureFromURL.d.ts} +2 -2
  64. package/dist/ProteinView/{loadStructureFromURL.js → addStructureFromURL.js} +11 -9
  65. package/dist/ProteinView/addStructureFromURL.js.map +1 -0
  66. package/dist/ProteinView/clearSelection.js +1 -1
  67. package/dist/ProteinView/clearSelection.js.map +1 -1
  68. package/dist/ProteinView/components/ProteinAlignment.d.ts +2 -2
  69. package/dist/ProteinView/components/ProteinAlignment.js +37 -26
  70. package/dist/ProteinView/components/ProteinAlignment.js.map +1 -1
  71. package/dist/ProteinView/components/ProteinAlignmentHelpButton.d.ts +2 -2
  72. package/dist/ProteinView/components/ProteinAlignmentHelpButton.js +6 -4
  73. package/dist/ProteinView/components/ProteinAlignmentHelpButton.js.map +1 -1
  74. package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js +6 -5
  75. package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js.map +1 -1
  76. package/dist/ProteinView/components/ProteinView.js +18 -60
  77. package/dist/ProteinView/components/ProteinView.js.map +1 -1
  78. package/dist/ProteinView/components/{Header.js → ProteinViewHeader.js} +29 -12
  79. package/dist/ProteinView/components/ProteinViewHeader.js.map +1 -0
  80. package/dist/ProteinView/components/SplitString.d.ts +4 -4
  81. package/dist/ProteinView/components/SplitString.js +3 -3
  82. package/dist/ProteinView/components/SplitString.js.map +1 -1
  83. package/dist/ProteinView/genomeToProtein.d.ts +2 -2
  84. package/dist/ProteinView/genomeToProtein.js +4 -5
  85. package/dist/ProteinView/genomeToProtein.js.map +1 -1
  86. package/dist/ProteinView/highlightResidue.js +2 -2
  87. package/dist/ProteinView/highlightResidue.js.map +1 -1
  88. package/dist/ProteinView/launchRemotePairwiseAlignment.d.ts +2 -5
  89. package/dist/ProteinView/launchRemotePairwiseAlignment.js +7 -3
  90. package/dist/ProteinView/launchRemotePairwiseAlignment.js.map +1 -1
  91. package/dist/ProteinView/model.d.ts +492 -160
  92. package/dist/ProteinView/model.js +62 -246
  93. package/dist/ProteinView/model.js.map +1 -1
  94. package/dist/ProteinView/proteinToGenomeMapping.d.ts +6 -6
  95. package/dist/ProteinView/proteinToGenomeMapping.js +29 -28
  96. package/dist/ProteinView/proteinToGenomeMapping.js.map +1 -1
  97. package/dist/ProteinView/selectResidue.js +1 -1
  98. package/dist/ProteinView/selectResidue.js.map +1 -1
  99. package/dist/ProteinView/structureModel.d.ts +183 -0
  100. package/dist/ProteinView/structureModel.js +407 -0
  101. package/dist/ProteinView/structureModel.js.map +1 -0
  102. package/dist/ProteinView/useProteinView.d.ts +1 -4
  103. package/dist/ProteinView/useProteinView.js +3 -15
  104. package/dist/ProteinView/useProteinView.js.map +1 -1
  105. package/dist/ProteinView/util.d.ts +3 -3
  106. package/dist/ProteinView/util.js +8 -6
  107. package/dist/ProteinView/util.js.map +1 -1
  108. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.d.ts +15 -0
  109. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.js +55 -0
  110. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.js.map +1 -0
  111. package/dist/UniProtVariationAdapter/configSchema.d.ts +17 -0
  112. package/dist/UniProtVariationAdapter/configSchema.js +20 -0
  113. package/dist/UniProtVariationAdapter/configSchema.js.map +1 -0
  114. package/dist/UniProtVariationAdapter/index.d.ts +2 -0
  115. package/dist/UniProtVariationAdapter/index.js +11 -0
  116. package/dist/UniProtVariationAdapter/index.js.map +1 -0
  117. package/dist/genomeToTranscriptMapping.d.ts +2 -2
  118. package/dist/genomeToTranscriptMapping.js +3 -3
  119. package/dist/genomeToTranscriptMapping.js.map +1 -1
  120. package/dist/index.js +6 -0
  121. package/dist/index.js.map +1 -1
  122. package/dist/jbrowse-plugin-protein3d.umd.production.min.js +2506 -1658
  123. package/dist/jbrowse-plugin-protein3d.umd.production.min.js.map +4 -4
  124. package/dist/mappings.d.ts +12 -10
  125. package/dist/mappings.js +7 -7
  126. package/dist/mappings.js.map +1 -1
  127. package/dist/mappings.test.js +7 -5
  128. package/dist/mappings.test.js.map +1 -1
  129. package/dist/test_data/gene.d.ts +577 -64
  130. package/dist/test_data/gene.js +1 -1
  131. package/dist/test_data/gene.js.map +1 -1
  132. package/package.json +20 -19
  133. package/src/AddHighlightModel/GenomeMouseoverHighlight.tsx +4 -17
  134. package/src/AddHighlightModel/HighlightComponents.tsx +1 -3
  135. package/src/AddHighlightModel/ProteinToGenomeClickHighlight.tsx +17 -14
  136. package/src/AddHighlightModel/ProteinToGenomeHoverHighlight.tsx +18 -17
  137. package/src/AddHighlightModel/util.ts +1 -1
  138. package/src/AlphaFoldConfidenceAdapter/AlphaFoldConfidenceAdapter.ts +63 -0
  139. package/src/AlphaFoldConfidenceAdapter/configSchema.ts +21 -0
  140. package/src/AlphaFoldConfidenceAdapter/index.ts +19 -0
  141. package/src/AlphaMissensePathogenicityAdapter/AlphaMissensePathogenicityAdapter.ts +109 -0
  142. package/src/AlphaMissensePathogenicityAdapter/configSchema.ts +21 -0
  143. package/src/AlphaMissensePathogenicityAdapter/index.ts +19 -0
  144. package/src/LaunchProteinView/components/AlphaFoldDBSearch.tsx +173 -12
  145. package/src/LaunchProteinView/components/AlphaFoldDBSearchStatus.tsx +8 -6
  146. package/src/LaunchProteinView/components/HelpButton.tsx +10 -2
  147. package/src/LaunchProteinView/components/HelpDialog.tsx +6 -1
  148. package/src/LaunchProteinView/components/LaunchProteinViewDialog.tsx +20 -4
  149. package/src/LaunchProteinView/components/MSATable.tsx +3 -1
  150. package/src/LaunchProteinView/components/ManualUniProtIDEntry.tsx +332 -0
  151. package/src/LaunchProteinView/components/TranscriptSelector.tsx +9 -7
  152. package/src/LaunchProteinView/components/UserProvidedStructure.tsx +18 -13
  153. package/src/LaunchProteinView/components/calculateProteinSequence.ts +6 -4
  154. package/src/LaunchProteinView/components/useLocalStructureFileSequence.ts +28 -9
  155. package/src/LaunchProteinView/components/useRemoteStructureFileSequence.ts +23 -8
  156. package/src/LaunchProteinView/components/util.ts +1 -1
  157. package/src/LaunchProteinView/index.ts +36 -26
  158. package/src/ProteinView/{loadStructureFromData.ts → addStructureFromData.ts} +2 -8
  159. package/src/ProteinView/{loadStructureFromURL.ts → addStructureFromURL.ts} +11 -11
  160. package/src/ProteinView/clearSelection.ts +1 -1
  161. package/src/ProteinView/components/ProteinAlignment.tsx +51 -35
  162. package/src/ProteinView/components/ProteinAlignmentHelpButton.tsx +4 -4
  163. package/src/ProteinView/components/ProteinAlignmentHelpDialog.tsx +15 -11
  164. package/src/ProteinView/components/ProteinView.tsx +22 -82
  165. package/src/ProteinView/components/{Header.tsx → ProteinViewHeader.tsx} +44 -23
  166. package/src/ProteinView/components/SplitString.tsx +8 -8
  167. package/src/ProteinView/genomeToProtein.ts +5 -9
  168. package/src/ProteinView/highlightResidue.ts +2 -2
  169. package/src/ProteinView/launchRemotePairwiseAlignment.ts +6 -3
  170. package/src/ProteinView/model.ts +75 -287
  171. package/src/ProteinView/proteinToGenomeMapping.ts +40 -38
  172. package/src/ProteinView/selectResidue.ts +1 -1
  173. package/src/ProteinView/structureModel.ts +512 -0
  174. package/src/ProteinView/useProteinView.ts +2 -19
  175. package/src/ProteinView/util.ts +20 -9
  176. package/src/UniProtVariationAdapter/UniProtVariationAdapter.ts +99 -0
  177. package/src/UniProtVariationAdapter/configSchema.ts +25 -0
  178. package/src/UniProtVariationAdapter/index.ts +17 -0
  179. package/src/__snapshots__/mappings.test.ts.snap +224 -224
  180. package/src/genomeToTranscriptMapping.ts +9 -9
  181. package/src/index.ts +6 -0
  182. package/src/mappings.test.ts +7 -5
  183. package/src/mappings.ts +25 -23
  184. package/src/test_data/gene.ts +3 -3
  185. package/dist/ProteinView/components/Header.js.map +0 -1
  186. package/dist/ProteinView/loadStructureFromData.js.map +0 -1
  187. package/dist/ProteinView/loadStructureFromURL.js.map +0 -1
  188. package/dist/ProteinView/useProteinViewClickBehavior.d.ts +0 -8
  189. package/dist/ProteinView/useProteinViewClickBehavior.js +0 -34
  190. package/dist/ProteinView/useProteinViewClickBehavior.js.map +0 -1
  191. package/dist/ProteinView/useProteinViewHoverBehavior.d.ts +0 -6
  192. package/dist/ProteinView/useProteinViewHoverBehavior.js +0 -31
  193. package/dist/ProteinView/useProteinViewHoverBehavior.js.map +0 -1
  194. package/src/ProteinView/useProteinViewClickBehavior.ts +0 -48
  195. package/src/ProteinView/useProteinViewHoverBehavior.ts +0 -44
  196. /package/dist/ProteinView/components/{Header.d.ts → ProteinViewHeader.d.ts} +0 -0
@@ -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
25
+ hoveredPosition !== undefined && i === hoveredPosition
26
26
  ? '#f698'
27
- : set?.has(i) && showHighlight
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
@@ -45,51 +31,18 @@ function stateModelFactory() {
45
31
  type: types.literal('ProteinView'),
46
32
  /**
47
33
  * #property
48
- * url to structure file
49
- */
50
- url: types.maybe(types.string),
51
- /**
52
- * #property
53
- * full string for structure data
54
34
  */
55
- data: types.maybe(types.string),
56
- /**
57
- * #property
58
- */
59
- clickGenomeHighlights: types.array(Region),
60
- /**
61
- * #property
62
- */
63
- hoverGenomeHighlights: types.array(Region),
35
+ structures: types.array(Structure),
36
+
64
37
  /**
65
38
  * #property
66
39
  */
67
- showControls: true,
40
+ showControls: false,
68
41
  /**
69
42
  * #property
70
43
  */
71
44
  height: types.optional(types.number, 650),
72
- /**
73
- * #property
74
- */
75
- feature: types.frozen<SimpleFeatureSerialized>(),
76
- /**
77
- * #property
78
- */
79
- seq1: types.maybe(types.string),
80
- /**
81
- * #property
82
- */
83
- seq2: types.maybe(types.string),
84
- /**
85
- * #property
86
- */
87
- alignment: types.frozen<ReturnType<typeof parsePairwise> | undefined>(),
88
45
 
89
- /**
90
- * #property
91
- */
92
- connectedViewId: types.maybe(types.string),
93
46
  /**
94
47
  * #property
95
48
  */
@@ -108,123 +61,46 @@ function stateModelFactory() {
108
61
  /**
109
62
  * #volatile
110
63
  */
111
- error: undefined as unknown,
112
- /**
113
- * #volatile
114
- */
115
- clickPosition: undefined as
116
- | {
117
- structureSeqPos: number
118
- code: string
119
- chain: string
120
- }
121
- | undefined,
64
+ progress: '',
122
65
  /**
123
66
  * #volatile
124
67
  */
125
- hoverPosition: undefined as
126
- | {
127
- structureSeqPos: number
128
- code?: string
129
- chain?: string
130
- }
131
- | undefined,
68
+ error: undefined as unknown,
132
69
  /**
133
70
  * #volatile
134
71
  */
135
- progress: '',
136
- }))
137
- .views(self => ({
138
- /**
139
- * #getter
140
- */
141
- get connectedView() {
142
- const { views } = getSession(self)
143
- return views.find(f => f.id === self.connectedViewId) as MaybeLGV
144
- },
72
+ molstarPluginContext: undefined as PluginContext | undefined,
145
73
  }))
74
+
146
75
  .actions(self => ({
147
76
  /**
148
77
  * #action
149
78
  */
150
- setShowAlignment(f: boolean) {
151
- self.showAlignment = f
152
- },
153
- /**
154
- * #action
155
- */
156
- setHoveredPosition(arg?: {
157
- structureSeqPos: number
158
- chain?: string
159
- code?: string
160
- }) {
161
- self.hoverPosition = arg
79
+ setHeight(n: number) {
80
+ self.height = n
81
+ return n
162
82
  },
163
83
  /**
164
84
  * #action
165
85
  */
166
- setSeqs(str1?: string, str2?: string) {
167
- self.seq1 = str1
168
- self.seq2 = str2
86
+ setShowAlignment(f: boolean) {
87
+ self.showAlignment = f
169
88
  },
89
+
170
90
  /**
171
91
  * #action
172
92
  */
173
93
  setShowControls(arg: boolean) {
174
94
  self.showControls = arg
175
95
  },
176
- /**
177
- * #action
178
- */
179
- setProgress(str: string) {
180
- self.progress = str
181
- },
182
- /**
183
- * #action
184
- */
185
- setClickedPosition(arg?: {
186
- structureSeqPos: number
187
- code: string
188
- chain: string
189
- }) {
190
- self.clickPosition = arg
191
- },
192
- /**
193
- * #action
194
- */
195
- setClickGenomeHighlights(r: IRegion[]) {
196
- self.clickGenomeHighlights = cast(r)
197
- },
198
- /**
199
- * #action
200
- */
201
- clearClickGenomeHighlights() {
202
- self.clickGenomeHighlights = cast([])
203
- },
204
- /**
205
- * #action
206
- */
207
- setHoverGenomeHighlights(r: IRegion[]) {
208
- self.hoverGenomeHighlights = cast(r)
209
- },
210
- /**
211
- * #action
212
- */
213
- clearHoverGenomeHighlights() {
214
- self.hoverGenomeHighlights = cast([])
215
- },
96
+
216
97
  /**
217
98
  * #action
218
99
  */
219
100
  setError(e: unknown) {
220
101
  self.error = e
221
102
  },
222
- /**
223
- * #action
224
- */
225
- setAlignment(r?: ReturnType<typeof parsePairwise>) {
226
- self.alignment = r
227
- },
103
+
228
104
  /**
229
105
  * #action
230
106
  */
@@ -237,166 +113,73 @@ function stateModelFactory() {
237
113
  setZoomToBaseLevel(arg: boolean) {
238
114
  self.zoomToBaseLevel = arg
239
115
  },
240
- }))
241
- .views(self => ({
242
- /**
243
- * #getter
244
- */
245
- get structureSeqToTranscriptSeqPosition() {
246
- return self.alignment
247
- ? structureSeqVsTranscriptSeqMap(self.alignment)
248
- .structureSeqToTranscriptSeqPosition
249
- : undefined
250
- },
251
- /**
252
- * #getter
253
- */
254
- get transcriptSeqToStructureSeqPosition() {
255
- return self.alignment
256
- ? structureSeqVsTranscriptSeqMap(self.alignment)
257
- .transcriptSeqToStructureSeqPosition
258
- : undefined
259
- },
260
- /**
261
- * #getter
262
- */
263
- get structurePositionToAlignmentMap() {
264
- return self.alignment
265
- ? structurePositionToAlignmentMap(self.alignment)
266
- : undefined
267
- },
268
116
  /**
269
- * #getter
270
- */
271
- get transcriptPositionToAlignmentMap() {
272
- return self.alignment
273
- ? transcriptPositionToAlignmentMap(self.alignment)
274
- : undefined
275
- },
276
- /**
277
- * #getter
278
- */
279
- get alignmentToTranscriptPosition() {
280
- return this.transcriptPositionToAlignmentMap
281
- ? invertMap(this.transcriptPositionToAlignmentMap)
282
- : undefined
283
- },
284
- /**
285
- * #getter
286
- */
287
- get alignmentToStructurePosition() {
288
- return this.structurePositionToAlignmentMap
289
- ? invertMap(this.structurePositionToAlignmentMap)
290
- : undefined
291
- },
292
- /**
293
- * #getter
294
- */
295
- get clickString() {
296
- const r = self.clickPosition
297
- return r ? toStr(r) : ''
298
- },
299
- /**
300
- * #getter
301
- */
302
- get hoverString() {
303
- const r = self.hoverPosition
304
- return r ? toStr(r) : ''
305
- },
306
- /**
307
- * #getter
308
- */
309
- get genomeToTranscriptSeqMapping() {
310
- return self.feature
311
- ? genomeToTranscriptSeqMapping(new SimpleFeature(self.feature))
312
- : undefined
313
- },
314
- /**
315
- * #getter
117
+ * #action
316
118
  */
317
- get structureSeqHoverPos(): number | undefined {
318
- return self.hoverPosition?.structureSeqPos
319
- },
320
-
321
- get exactMatch() {
322
- const r1 = self.seq1?.replaceAll('*', '')
323
- const r2 = self.seq2?.replaceAll('*', '')
324
- return r1 === r2
119
+ setMolstarPluginContext(p?: PluginContext) {
120
+ self.molstarPluginContext = p
325
121
  },
326
122
  }))
327
123
  .actions(self => ({
328
124
  afterAttach() {
329
- // pairwise align transcript sequence to structure residues
330
125
  addDisposer(
331
126
  self,
332
127
  autorun(async () => {
333
- try {
334
- const { seq1, seq2, exactMatch } = self
335
- if (!!self.alignment || !seq1 || !seq2) {
336
- return
337
- }
338
- const r1 = seq1.replaceAll('*', '')
339
- const r2 = seq2.replaceAll('*', '')
340
- if (!exactMatch) {
341
- const alignment = await launchPairwiseAlignment({
342
- seq1: r1,
343
- seq2: r2,
344
- algorithm: 'emboss_needle',
345
- onProgress: arg => self.setProgress(arg),
346
- })
347
- self.setAlignment(alignment.alignment)
128
+ const { structures, molstarPluginContext } = self
129
+ if (molstarPluginContext) {
130
+ for (const structure of structures) {
131
+ try {
132
+ const { model } = structure.data
133
+ ? await addStructureFromData({
134
+ data: structure.data,
135
+ plugin: molstarPluginContext,
136
+ })
137
+ : structure.url
138
+ ? await addStructureFromURL({
139
+ url: structure.url,
140
+ plugin: molstarPluginContext,
141
+ })
142
+ : { model: undefined }
348
143
 
349
- // showHighlight when we are
350
- self.setShowHighlight(true)
351
- self.setShowAlignment(true)
352
- } else {
353
- let consensus = ''
354
- // eslint-disable-next-line @typescript-eslint/prefer-for-of
355
- for (let i = 0; i < r1.length; i++) {
356
- consensus += '|'
144
+ const sequences = model?.obj?.data.sequence.sequences.map(
145
+ s => {
146
+ let seq = ''
147
+ const arr = s.sequence.label.toArray()
148
+ // eslint-disable-next-line unicorn/no-for-loop,@typescript-eslint/prefer-for-of
149
+ for (let i = 0; i < arr.length; i++) {
150
+ seq += arr[i]!
151
+ }
152
+ return seq
153
+ },
154
+ )
155
+ structure.setSequences(sequences)
156
+ } catch (e) {
157
+ self.setError(e)
158
+ console.error(e)
357
159
  }
358
- self.setAlignment({
359
- consensus,
360
- alns: [
361
- { id: 'seq1', seq: r1 },
362
- { id: 'seq2', seq: r2 },
363
- ],
364
- })
365
160
  }
366
- } catch (e) {
367
- console.error(e)
368
- self.setError(e)
369
161
  }
370
162
  }),
371
163
  )
372
164
 
373
- // convert hover over the genome to structure position
374
165
  addDisposer(
375
166
  self,
376
167
  autorun(() => {
377
- const { hovered } = getSession(self)
378
- const {
379
- transcriptSeqToStructureSeqPosition,
380
- genomeToTranscriptSeqMapping,
381
- connectedView,
382
- } = self
383
- if (
384
- !connectedView?.initialized ||
385
- !genomeToTranscriptSeqMapping ||
386
- !checkHovered(hovered)
387
- ) {
388
- return undefined
389
- }
390
-
391
- const pos =
392
- genomeToTranscriptSeqMapping.g2p[hovered.hoverPosition.coord]
393
- const c0 = pos
394
- ? transcriptSeqToStructureSeqPosition?.[pos]
395
- : undefined
396
- if (c0 !== undefined) {
397
- self.setHoveredPosition({
398
- structureSeqPos: c0,
399
- })
168
+ const { structures, molstarPluginContext } = self
169
+ if (molstarPluginContext) {
170
+ for (const [i, s0] of structures.entries()) {
171
+ const structure =
172
+ molstarPluginContext.managers.structure.hierarchy.current
173
+ .structures[i]?.cell.obj?.data
174
+ const pos = s0.structureSeqHoverPos
175
+ if (structure && pos !== undefined) {
176
+ highlightResidue({
177
+ structure,
178
+ plugin: molstarPluginContext,
179
+ selectedResidue: pos,
180
+ })
181
+ }
182
+ }
400
183
  }
401
184
  }),
402
185
  )
@@ -405,8 +188,13 @@ function stateModelFactory() {
405
188
  }
406
189
 
407
190
  export default stateModelFactory
191
+
408
192
  export type JBrowsePluginProteinViewStateModel = ReturnType<
409
193
  typeof stateModelFactory
410
194
  >
411
195
  export type JBrowsePluginProteinViewModel =
412
196
  Instance<JBrowsePluginProteinViewStateModel>
197
+
198
+ export type JBrowsePluginProteinStructureStateModel = typeof Structure
199
+ export type JBrowsePluginProteinStructureModel =
200
+ Instance<JBrowsePluginProteinStructureStateModel>