jbrowse-plugin-protein3d 0.0.3 → 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 (189) 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 +161 -11
  29. package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js.map +1 -1
  30. package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js +8 -6
  31. package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js.map +1 -1
  32. package/dist/LaunchProteinView/components/HelpButton.js +6 -2
  33. package/dist/LaunchProteinView/components/HelpButton.js.map +1 -1
  34. package/dist/LaunchProteinView/components/HelpDialog.js +3 -1
  35. package/dist/LaunchProteinView/components/HelpDialog.js.map +1 -1
  36. package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js +6 -2
  37. package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js.map +1 -1
  38. package/dist/LaunchProteinView/components/MSATable.js +3 -1
  39. package/dist/LaunchProteinView/components/MSATable.js.map +1 -1
  40. package/dist/LaunchProteinView/components/TranscriptSelector.js +3 -1
  41. package/dist/LaunchProteinView/components/TranscriptSelector.js.map +1 -1
  42. package/dist/LaunchProteinView/components/UserProvidedStructure.js +18 -11
  43. package/dist/LaunchProteinView/components/UserProvidedStructure.js.map +1 -1
  44. package/dist/LaunchProteinView/components/calculateProteinSequence.js +5 -3
  45. package/dist/LaunchProteinView/components/calculateProteinSequence.js.map +1 -1
  46. package/dist/LaunchProteinView/components/useLocalStructureFileSequence.d.ts +1 -1
  47. package/dist/LaunchProteinView/components/useLocalStructureFileSequence.js +29 -9
  48. package/dist/LaunchProteinView/components/useLocalStructureFileSequence.js.map +1 -1
  49. package/dist/LaunchProteinView/components/useRemoteStructureFileSequence.d.ts +1 -1
  50. package/dist/LaunchProteinView/components/useRemoteStructureFileSequence.js +25 -8
  51. package/dist/LaunchProteinView/components/useRemoteStructureFileSequence.js.map +1 -1
  52. package/dist/LaunchProteinView/components/util.js +1 -1
  53. package/dist/LaunchProteinView/index.js +7 -3
  54. package/dist/LaunchProteinView/index.js.map +1 -1
  55. package/dist/ProteinView/{loadStructureFromData.d.ts → addStructureFromData.d.ts} +2 -2
  56. package/dist/ProteinView/{loadStructureFromData.js → addStructureFromData.js} +3 -8
  57. package/dist/ProteinView/addStructureFromData.js.map +1 -0
  58. package/dist/ProteinView/{loadStructureFromURL.d.ts → addStructureFromURL.d.ts} +2 -2
  59. package/dist/ProteinView/{loadStructureFromURL.js → addStructureFromURL.js} +11 -9
  60. package/dist/ProteinView/addStructureFromURL.js.map +1 -0
  61. package/dist/ProteinView/clearSelection.js +1 -1
  62. package/dist/ProteinView/clearSelection.js.map +1 -1
  63. package/dist/ProteinView/components/ProteinAlignment.d.ts +2 -2
  64. package/dist/ProteinView/components/ProteinAlignment.js +37 -26
  65. package/dist/ProteinView/components/ProteinAlignment.js.map +1 -1
  66. package/dist/ProteinView/components/ProteinAlignmentHelpButton.d.ts +2 -2
  67. package/dist/ProteinView/components/ProteinAlignmentHelpButton.js +6 -4
  68. package/dist/ProteinView/components/ProteinAlignmentHelpButton.js.map +1 -1
  69. package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js +6 -5
  70. package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js.map +1 -1
  71. package/dist/ProteinView/components/ProteinView.js +18 -60
  72. package/dist/ProteinView/components/ProteinView.js.map +1 -1
  73. package/dist/ProteinView/components/{Header.js → ProteinViewHeader.js} +29 -12
  74. package/dist/ProteinView/components/ProteinViewHeader.js.map +1 -0
  75. package/dist/ProteinView/components/SplitString.d.ts +4 -4
  76. package/dist/ProteinView/components/SplitString.js +3 -3
  77. package/dist/ProteinView/components/SplitString.js.map +1 -1
  78. package/dist/ProteinView/genomeToProtein.d.ts +2 -2
  79. package/dist/ProteinView/genomeToProtein.js +4 -5
  80. package/dist/ProteinView/genomeToProtein.js.map +1 -1
  81. package/dist/ProteinView/highlightResidue.js +2 -2
  82. package/dist/ProteinView/highlightResidue.js.map +1 -1
  83. package/dist/ProteinView/launchRemotePairwiseAlignment.d.ts +2 -5
  84. package/dist/ProteinView/launchRemotePairwiseAlignment.js +7 -3
  85. package/dist/ProteinView/launchRemotePairwiseAlignment.js.map +1 -1
  86. package/dist/ProteinView/model.d.ts +496 -160
  87. package/dist/ProteinView/model.js +61 -246
  88. package/dist/ProteinView/model.js.map +1 -1
  89. package/dist/ProteinView/proteinToGenomeMapping.d.ts +6 -6
  90. package/dist/ProteinView/proteinToGenomeMapping.js +29 -28
  91. package/dist/ProteinView/proteinToGenomeMapping.js.map +1 -1
  92. package/dist/ProteinView/selectResidue.js +1 -1
  93. package/dist/ProteinView/selectResidue.js.map +1 -1
  94. package/dist/ProteinView/structureModel.d.ts +183 -0
  95. package/dist/ProteinView/structureModel.js +407 -0
  96. package/dist/ProteinView/structureModel.js.map +1 -0
  97. package/dist/ProteinView/useProteinView.d.ts +1 -4
  98. package/dist/ProteinView/useProteinView.js +3 -15
  99. package/dist/ProteinView/useProteinView.js.map +1 -1
  100. package/dist/ProteinView/util.d.ts +3 -3
  101. package/dist/ProteinView/util.js +8 -6
  102. package/dist/ProteinView/util.js.map +1 -1
  103. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.d.ts +15 -0
  104. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.js +55 -0
  105. package/dist/UniProtVariationAdapter/UniProtVariationAdapter.js.map +1 -0
  106. package/dist/UniProtVariationAdapter/configSchema.d.ts +17 -0
  107. package/dist/UniProtVariationAdapter/configSchema.js +20 -0
  108. package/dist/UniProtVariationAdapter/configSchema.js.map +1 -0
  109. package/dist/UniProtVariationAdapter/index.d.ts +2 -0
  110. package/dist/UniProtVariationAdapter/index.js +11 -0
  111. package/dist/UniProtVariationAdapter/index.js.map +1 -0
  112. package/dist/genomeToTranscriptMapping.d.ts +2 -2
  113. package/dist/genomeToTranscriptMapping.js +3 -3
  114. package/dist/genomeToTranscriptMapping.js.map +1 -1
  115. package/dist/index.js +6 -0
  116. package/dist/index.js.map +1 -1
  117. package/dist/jbrowse-plugin-protein3d.umd.production.min.js +1467 -1482
  118. package/dist/jbrowse-plugin-protein3d.umd.production.min.js.map +4 -4
  119. package/dist/mappings.d.ts +12 -10
  120. package/dist/mappings.js +7 -7
  121. package/dist/mappings.js.map +1 -1
  122. package/dist/mappings.test.js +7 -5
  123. package/dist/mappings.test.js.map +1 -1
  124. package/dist/test_data/gene.d.ts +577 -64
  125. package/dist/test_data/gene.js +1 -1
  126. package/dist/test_data/gene.js.map +1 -1
  127. package/package.json +16 -15
  128. package/src/AddHighlightModel/GenomeMouseoverHighlight.tsx +4 -17
  129. package/src/AddHighlightModel/ProteinToGenomeClickHighlight.tsx +17 -14
  130. package/src/AddHighlightModel/ProteinToGenomeHoverHighlight.tsx +18 -17
  131. package/src/AddHighlightModel/util.ts +1 -1
  132. package/src/AlphaFoldConfidenceAdapter/AlphaFoldConfidenceAdapter.ts +63 -0
  133. package/src/AlphaFoldConfidenceAdapter/configSchema.ts +21 -0
  134. package/src/AlphaFoldConfidenceAdapter/index.ts +19 -0
  135. package/src/AlphaMissensePathogenicityAdapter/AlphaMissensePathogenicityAdapter.ts +109 -0
  136. package/src/AlphaMissensePathogenicityAdapter/configSchema.ts +21 -0
  137. package/src/AlphaMissensePathogenicityAdapter/index.ts +19 -0
  138. package/src/LaunchProteinView/components/AlphaFoldDBSearch.tsx +172 -10
  139. package/src/LaunchProteinView/components/AlphaFoldDBSearchStatus.tsx +8 -6
  140. package/src/LaunchProteinView/components/HelpButton.tsx +10 -2
  141. package/src/LaunchProteinView/components/HelpDialog.tsx +6 -1
  142. package/src/LaunchProteinView/components/LaunchProteinViewDialog.tsx +9 -2
  143. package/src/LaunchProteinView/components/MSATable.tsx +3 -1
  144. package/src/LaunchProteinView/components/TranscriptSelector.tsx +9 -7
  145. package/src/LaunchProteinView/components/UserProvidedStructure.tsx +17 -12
  146. package/src/LaunchProteinView/components/calculateProteinSequence.ts +6 -4
  147. package/src/LaunchProteinView/components/useLocalStructureFileSequence.ts +28 -9
  148. package/src/LaunchProteinView/components/useRemoteStructureFileSequence.ts +23 -8
  149. package/src/LaunchProteinView/components/util.ts +1 -1
  150. package/src/LaunchProteinView/index.ts +36 -26
  151. package/src/ProteinView/{loadStructureFromData.ts → addStructureFromData.ts} +2 -8
  152. package/src/ProteinView/{loadStructureFromURL.ts → addStructureFromURL.ts} +11 -11
  153. package/src/ProteinView/clearSelection.ts +1 -1
  154. package/src/ProteinView/components/ProteinAlignment.tsx +51 -35
  155. package/src/ProteinView/components/ProteinAlignmentHelpButton.tsx +4 -4
  156. package/src/ProteinView/components/ProteinAlignmentHelpDialog.tsx +15 -11
  157. package/src/ProteinView/components/ProteinView.tsx +22 -82
  158. package/src/ProteinView/components/{Header.tsx → ProteinViewHeader.tsx} +44 -23
  159. package/src/ProteinView/components/SplitString.tsx +8 -8
  160. package/src/ProteinView/genomeToProtein.ts +5 -9
  161. package/src/ProteinView/highlightResidue.ts +2 -2
  162. package/src/ProteinView/launchRemotePairwiseAlignment.ts +6 -3
  163. package/src/ProteinView/model.ts +74 -287
  164. package/src/ProteinView/proteinToGenomeMapping.ts +40 -38
  165. package/src/ProteinView/selectResidue.ts +1 -1
  166. package/src/ProteinView/structureModel.ts +512 -0
  167. package/src/ProteinView/useProteinView.ts +2 -19
  168. package/src/ProteinView/util.ts +20 -9
  169. package/src/UniProtVariationAdapter/UniProtVariationAdapter.ts +99 -0
  170. package/src/UniProtVariationAdapter/configSchema.ts +25 -0
  171. package/src/UniProtVariationAdapter/index.ts +17 -0
  172. package/src/__snapshots__/mappings.test.ts.snap +224 -224
  173. package/src/genomeToTranscriptMapping.ts +9 -9
  174. package/src/index.ts +6 -0
  175. package/src/mappings.test.ts +7 -5
  176. package/src/mappings.ts +25 -23
  177. package/src/test_data/gene.ts +3 -3
  178. package/dist/ProteinView/components/Header.js.map +0 -1
  179. package/dist/ProteinView/loadStructureFromData.js.map +0 -1
  180. package/dist/ProteinView/loadStructureFromURL.js.map +0 -1
  181. package/dist/ProteinView/useProteinViewClickBehavior.d.ts +0 -8
  182. package/dist/ProteinView/useProteinViewClickBehavior.js +0 -34
  183. package/dist/ProteinView/useProteinViewClickBehavior.js.map +0 -1
  184. package/dist/ProteinView/useProteinViewHoverBehavior.d.ts +0 -6
  185. package/dist/ProteinView/useProteinViewHoverBehavior.js +0 -31
  186. package/dist/ProteinView/useProteinViewHoverBehavior.js.map +0 -1
  187. package/src/ProteinView/useProteinViewClickBehavior.ts +0 -48
  188. package/src/ProteinView/useProteinViewHoverBehavior.ts +0 -44
  189. /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,45 @@ 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
162
81
  },
163
82
  /**
164
83
  * #action
165
84
  */
166
- setSeqs(str1?: string, str2?: string) {
167
- self.seq1 = str1
168
- self.seq2 = str2
85
+ setShowAlignment(f: boolean) {
86
+ self.showAlignment = f
169
87
  },
88
+
170
89
  /**
171
90
  * #action
172
91
  */
173
92
  setShowControls(arg: boolean) {
174
93
  self.showControls = arg
175
94
  },
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
- },
95
+
216
96
  /**
217
97
  * #action
218
98
  */
219
99
  setError(e: unknown) {
220
100
  self.error = e
221
101
  },
222
- /**
223
- * #action
224
- */
225
- setAlignment(r?: ReturnType<typeof parsePairwise>) {
226
- self.alignment = r
227
- },
102
+
228
103
  /**
229
104
  * #action
230
105
  */
@@ -237,166 +112,73 @@ function stateModelFactory() {
237
112
  setZoomToBaseLevel(arg: boolean) {
238
113
  self.zoomToBaseLevel = arg
239
114
  },
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
115
  /**
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
116
+ * #action
316
117
  */
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
118
+ setMolstarPluginContext(p?: PluginContext) {
119
+ self.molstarPluginContext = p
325
120
  },
326
121
  }))
327
122
  .actions(self => ({
328
123
  afterAttach() {
329
- // pairwise align transcript sequence to structure residues
330
124
  addDisposer(
331
125
  self,
332
126
  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)
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 }
348
142
 
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 += '|'
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)
357
158
  }
358
- self.setAlignment({
359
- consensus,
360
- alns: [
361
- { id: 'seq1', seq: r1 },
362
- { id: 'seq2', seq: r2 },
363
- ],
364
- })
365
159
  }
366
- } catch (e) {
367
- console.error(e)
368
- self.setError(e)
369
160
  }
370
161
  }),
371
162
  )
372
163
 
373
- // convert hover over the genome to structure position
374
164
  addDisposer(
375
165
  self,
376
166
  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
- })
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
+ }
400
182
  }
401
183
  }),
402
184
  )
@@ -405,8 +187,13 @@ function stateModelFactory() {
405
187
  }
406
188
 
407
189
  export default stateModelFactory
190
+
408
191
  export type JBrowsePluginProteinViewStateModel = ReturnType<
409
192
  typeof stateModelFactory
410
193
  >
411
194
  export type JBrowsePluginProteinViewModel =
412
195
  Instance<JBrowsePluginProteinViewStateModel>
196
+
197
+ export type JBrowsePluginProteinStructureStateModel = typeof Structure
198
+ export type JBrowsePluginProteinStructureModel =
199
+ Instance<JBrowsePluginProteinStructureStateModel>