jbrowse-plugin-protein3d 0.0.2
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.
- package/README.md +3 -0
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.d.ts +6 -0
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.js +24 -0
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.js.map +1 -0
- package/dist/AddHighlightModel/Highlight.d.ts +10 -0
- package/dist/AddHighlightModel/Highlight.js +24 -0
- package/dist/AddHighlightModel/Highlight.js.map +1 -0
- package/dist/AddHighlightModel/HighlightComponents.d.ts +7 -0
- package/dist/AddHighlightModel/HighlightComponents.js +14 -0
- package/dist/AddHighlightModel/HighlightComponents.js.map +1 -0
- package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.d.ts +7 -0
- package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.js +13 -0
- package/dist/AddHighlightModel/ProteinToGenomeClickHighlight.js.map +1 -0
- package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.d.ts +7 -0
- package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.js +13 -0
- package/dist/AddHighlightModel/ProteinToGenomeHoverHighlight.js.map +1 -0
- package/dist/AddHighlightModel/index.d.ts +2 -0
- package/dist/AddHighlightModel/index.js +14 -0
- package/dist/AddHighlightModel/index.js.map +1 -0
- package/dist/AddHighlightModel/util.d.ts +9 -0
- package/dist/AddHighlightModel/util.js +17 -0
- package/dist/AddHighlightModel/util.js.map +1 -0
- package/dist/LaunchProteinView/calculateProteinSequence.d.ts +28 -0
- package/dist/LaunchProteinView/calculateProteinSequence.js +77 -0
- package/dist/LaunchProteinView/calculateProteinSequence.js.map +1 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearch.d.ts +8 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js +71 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearch.js.map +1 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.d.ts +8 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js +19 -0
- package/dist/LaunchProteinView/components/AlphaFoldDBSearchStatus.js.map +1 -0
- package/dist/LaunchProteinView/components/HelpButton.d.ts +2 -0
- package/dist/LaunchProteinView/components/HelpButton.js +15 -0
- package/dist/LaunchProteinView/components/HelpButton.js.map +1 -0
- package/dist/LaunchProteinView/components/HelpDialog.d.ts +4 -0
- package/dist/LaunchProteinView/components/HelpDialog.js +16 -0
- package/dist/LaunchProteinView/components/HelpDialog.js.map +1 -0
- package/dist/LaunchProteinView/components/LaunchProteinViewDialog.d.ts +7 -0
- package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js +23 -0
- package/dist/LaunchProteinView/components/LaunchProteinViewDialog.js.map +1 -0
- package/dist/LaunchProteinView/components/PreLoadedStructureMapping.d.ts +8 -0
- package/dist/LaunchProteinView/components/PreLoadedStructureMapping.js +72 -0
- package/dist/LaunchProteinView/components/PreLoadedStructureMapping.js.map +1 -0
- package/dist/LaunchProteinView/components/TabPanel.d.ts +6 -0
- package/dist/LaunchProteinView/components/TabPanel.js +6 -0
- package/dist/LaunchProteinView/components/TabPanel.js.map +1 -0
- package/dist/LaunchProteinView/components/TranscriptSelector.d.ts +9 -0
- package/dist/LaunchProteinView/components/TranscriptSelector.js +28 -0
- package/dist/LaunchProteinView/components/TranscriptSelector.js.map +1 -0
- package/dist/LaunchProteinView/components/UserProvidedStructure.d.ts +8 -0
- package/dist/LaunchProteinView/components/UserProvidedStructure.js +118 -0
- package/dist/LaunchProteinView/components/UserProvidedStructure.js.map +1 -0
- package/dist/LaunchProteinView/components/useCheckAlphaFoldDBExistence.d.ts +7 -0
- package/dist/LaunchProteinView/components/useCheckAlphaFoldDBExistence.js +26 -0
- package/dist/LaunchProteinView/components/useCheckAlphaFoldDBExistence.js.map +1 -0
- package/dist/LaunchProteinView/index.d.ts +2 -0
- package/dist/LaunchProteinView/index.js +45 -0
- package/dist/LaunchProteinView/index.js.map +1 -0
- package/dist/LaunchProteinView/useMyGeneInfo.d.ts +7 -0
- package/dist/LaunchProteinView/useMyGeneInfo.js +29 -0
- package/dist/LaunchProteinView/useMyGeneInfo.js.map +1 -0
- package/dist/LaunchProteinView/useProteinSequences.d.ts +10 -0
- package/dist/LaunchProteinView/useProteinSequences.js +30 -0
- package/dist/LaunchProteinView/useProteinSequences.js.map +1 -0
- package/dist/LaunchProteinView/util.d.ts +18 -0
- package/dist/LaunchProteinView/util.js +54 -0
- package/dist/LaunchProteinView/util.js.map +1 -0
- package/dist/ProteinModelSessionExtension.d.ts +11 -0
- package/dist/ProteinModelSessionExtension.js +53 -0
- package/dist/ProteinModelSessionExtension.js.map +1 -0
- package/dist/ProteinView/clearSelection.d.ts +4 -0
- package/dist/ProteinView/clearSelection.js +4 -0
- package/dist/ProteinView/clearSelection.js.map +1 -0
- package/dist/ProteinView/components/Header.d.ts +6 -0
- package/dist/ProteinView/components/Header.js +49 -0
- package/dist/ProteinView/components/Header.js.map +1 -0
- package/dist/ProteinView/components/ProteinAlignment.d.ts +6 -0
- package/dist/ProteinView/components/ProteinAlignment.js +62 -0
- package/dist/ProteinView/components/ProteinAlignment.js.map +1 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpButton.d.ts +5 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpButton.js +14 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpButton.js.map +1 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpDialog.d.ts +4 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js +20 -0
- package/dist/ProteinView/components/ProteinAlignmentHelpDialog.js.map +1 -0
- package/dist/ProteinView/components/ProteinView.d.ts +6 -0
- package/dist/ProteinView/components/ProteinView.js +79 -0
- package/dist/ProteinView/components/ProteinView.js.map +1 -0
- package/dist/ProteinView/components/SplitString.d.ts +9 -0
- package/dist/ProteinView/components/SplitString.js +11 -0
- package/dist/ProteinView/components/SplitString.js.map +1 -0
- package/dist/ProteinView/css/molstar.d.ts +2 -0
- package/dist/ProteinView/css/molstar.js +3137 -0
- package/dist/ProteinView/css/molstar.js.map +1 -0
- package/dist/ProteinView/genomeToProtein.d.ts +4 -0
- package/dist/ProteinView/genomeToProtein.js +13 -0
- package/dist/ProteinView/genomeToProtein.js.map +1 -0
- package/dist/ProteinView/highlightResidue.d.ts +7 -0
- package/dist/ProteinView/highlightResidue.js +14 -0
- package/dist/ProteinView/highlightResidue.js.map +1 -0
- package/dist/ProteinView/index.d.ts +2 -0
- package/dist/ProteinView/index.js +15 -0
- package/dist/ProteinView/index.js.map +1 -0
- package/dist/ProteinView/launchRemotePairwiseAlignment.d.ts +14 -0
- package/dist/ProteinView/launchRemotePairwiseAlignment.js +72 -0
- package/dist/ProteinView/launchRemotePairwiseAlignment.js.map +1 -0
- package/dist/ProteinView/loadStructureFromData.d.ts +17 -0
- package/dist/ProteinView/loadStructureFromData.js +20 -0
- package/dist/ProteinView/loadStructureFromData.js.map +1 -0
- package/dist/ProteinView/loadStructureFromURL.d.ts +17 -0
- package/dist/ProteinView/loadStructureFromURL.js +17 -0
- package/dist/ProteinView/loadStructureFromURL.js.map +1 -0
- package/dist/ProteinView/model.d.ts +226 -0
- package/dist/ProteinView/model.js +324 -0
- package/dist/ProteinView/model.js.map +1 -0
- package/dist/ProteinView/proteinAbbreviationMapping.d.ts +7 -0
- package/dist/ProteinView/proteinAbbreviationMapping.js +23 -0
- package/dist/ProteinView/proteinAbbreviationMapping.js.map +1 -0
- package/dist/ProteinView/proteinToGenomeMapping.d.ts +13 -0
- package/dist/ProteinView/proteinToGenomeMapping.js +69 -0
- package/dist/ProteinView/proteinToGenomeMapping.js.map +1 -0
- package/dist/ProteinView/selectResidue.d.ts +7 -0
- package/dist/ProteinView/selectResidue.js +10 -0
- package/dist/ProteinView/selectResidue.js.map +1 -0
- package/dist/ProteinView/useProteinView.d.ts +11 -0
- package/dist/ProteinView/useProteinView.js +57 -0
- package/dist/ProteinView/useProteinView.js.map +1 -0
- package/dist/ProteinView/useProteinViewClickBehavior.d.ts +8 -0
- package/dist/ProteinView/useProteinViewClickBehavior.js +34 -0
- package/dist/ProteinView/useProteinViewClickBehavior.js.map +1 -0
- package/dist/ProteinView/useProteinViewHoverBehavior.d.ts +6 -0
- package/dist/ProteinView/useProteinViewHoverBehavior.js +31 -0
- package/dist/ProteinView/useProteinViewHoverBehavior.js.map +1 -0
- package/dist/ProteinView/util.d.ts +19 -0
- package/dist/ProteinView/util.js +32 -0
- package/dist/ProteinView/util.js.map +1 -0
- package/dist/fetchUtils.d.ts +5 -0
- package/dist/fetchUtils.js +23 -0
- package/dist/fetchUtils.js.map +1 -0
- package/dist/genomeToTranscriptMapping.d.ts +7 -0
- package/dist/genomeToTranscriptMapping.js +36 -0
- package/dist/genomeToTranscriptMapping.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/jbrowse-plugin-protein3d.umd.production.min.js +9298 -0
- package/dist/jbrowse-plugin-protein3d.umd.production.min.js.map +7 -0
- package/dist/mappings.d.ts +19 -0
- package/dist/mappings.js +67 -0
- package/dist/mappings.js.map +1 -0
- package/dist/mappings.test.d.ts +1 -0
- package/dist/mappings.test.js +27 -0
- package/dist/mappings.test.js.map +1 -0
- package/dist/test_data/gene.d.ts +67 -0
- package/dist/test_data/gene.js +603 -0
- package/dist/test_data/gene.js.map +1 -0
- package/package.json +70 -0
- package/src/AddHighlightModel/GenomeMouseoverHighlight.tsx +45 -0
- package/src/AddHighlightModel/Highlight.tsx +46 -0
- package/src/AddHighlightModel/HighlightComponents.tsx +26 -0
- package/src/AddHighlightModel/ProteinToGenomeClickHighlight.tsx +39 -0
- package/src/AddHighlightModel/ProteinToGenomeHoverHighlight.tsx +39 -0
- package/src/AddHighlightModel/index.tsx +25 -0
- package/src/AddHighlightModel/util.ts +17 -0
- package/src/LaunchProteinView/calculateProteinSequence.ts +127 -0
- package/src/LaunchProteinView/components/AlphaFoldDBSearch.tsx +141 -0
- package/src/LaunchProteinView/components/AlphaFoldDBSearchStatus.tsx +44 -0
- package/src/LaunchProteinView/components/HelpButton.tsx +23 -0
- package/src/LaunchProteinView/components/HelpDialog.tsx +43 -0
- package/src/LaunchProteinView/components/LaunchProteinViewDialog.tsx +57 -0
- package/src/LaunchProteinView/components/PreLoadedStructureMapping.tsx +153 -0
- package/src/LaunchProteinView/components/TabPanel.tsx +19 -0
- package/src/LaunchProteinView/components/TranscriptSelector.tsx +54 -0
- package/src/LaunchProteinView/components/UserProvidedStructure.tsx +226 -0
- package/src/LaunchProteinView/components/useCheckAlphaFoldDBExistence.ts +31 -0
- package/src/LaunchProteinView/index.ts +56 -0
- package/src/LaunchProteinView/useMyGeneInfo.ts +37 -0
- package/src/LaunchProteinView/useProteinSequences.ts +36 -0
- package/src/LaunchProteinView/util.ts +74 -0
- package/src/ProteinModelSessionExtension.ts +71 -0
- package/src/ProteinView/clearSelection.ts +5 -0
- package/src/ProteinView/components/Header.tsx +84 -0
- package/src/ProteinView/components/ProteinAlignment.tsx +119 -0
- package/src/ProteinView/components/ProteinAlignmentHelpButton.tsx +33 -0
- package/src/ProteinView/components/ProteinAlignmentHelpDialog.tsx +59 -0
- package/src/ProteinView/components/ProteinView.tsx +131 -0
- package/src/ProteinView/components/SplitString.tsx +35 -0
- package/src/ProteinView/css/molstar.ts +3136 -0
- package/src/ProteinView/genomeToProtein.ts +21 -0
- package/src/ProteinView/highlightResidue.ts +23 -0
- package/src/ProteinView/index.ts +18 -0
- package/src/ProteinView/launchRemotePairwiseAlignment.ts +113 -0
- package/src/ProteinView/loadStructureFromData.ts +48 -0
- package/src/ProteinView/loadStructureFromURL.ts +50 -0
- package/src/ProteinView/model.ts +384 -0
- package/src/ProteinView/proteinAbbreviationMapping.ts +24 -0
- package/src/ProteinView/proteinToGenomeMapping.ts +99 -0
- package/src/ProteinView/selectResidue.ts +19 -0
- package/src/ProteinView/useProteinView.ts +70 -0
- package/src/ProteinView/useProteinViewClickBehavior.ts +48 -0
- package/src/ProteinView/useProteinViewHoverBehavior.ts +44 -0
- package/src/ProteinView/util.ts +56 -0
- package/src/__snapshots__/mappings.test.ts.snap +1351 -0
- package/src/declare.d.ts +1 -0
- package/src/fetchUtils.ts +30 -0
- package/src/genomeToTranscriptMapping.ts +46 -0
- package/src/index.ts +32 -0
- package/src/mappings.test.ts +32 -0
- package/src/mappings.ts +89 -0
- package/src/test_data/gene.ts +604 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { getSession } from '@jbrowse/core/util'
|
|
2
|
+
import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
|
|
3
|
+
|
|
4
|
+
// locals
|
|
5
|
+
import { JBrowsePluginProteinViewModel } from './model'
|
|
6
|
+
|
|
7
|
+
export function proteinToGenomeMapping({
|
|
8
|
+
model,
|
|
9
|
+
structureSeqPos,
|
|
10
|
+
}: {
|
|
11
|
+
structureSeqPos: number
|
|
12
|
+
model: JBrowsePluginProteinViewModel
|
|
13
|
+
}) {
|
|
14
|
+
const {
|
|
15
|
+
genomeToTranscriptSeqMapping,
|
|
16
|
+
alignment,
|
|
17
|
+
structureSeqToTranscriptSeqPosition,
|
|
18
|
+
} = model
|
|
19
|
+
if (!genomeToTranscriptSeqMapping || !alignment) {
|
|
20
|
+
return undefined
|
|
21
|
+
}
|
|
22
|
+
const { p2g, strand } = genomeToTranscriptSeqMapping
|
|
23
|
+
const r1 = structureSeqToTranscriptSeqPosition?.[structureSeqPos]
|
|
24
|
+
if (r1 === undefined) {
|
|
25
|
+
return undefined
|
|
26
|
+
}
|
|
27
|
+
const s0 = p2g[r1]
|
|
28
|
+
if (s0 === undefined) {
|
|
29
|
+
return undefined
|
|
30
|
+
}
|
|
31
|
+
const start = s0
|
|
32
|
+
const end = start + 3 * strand
|
|
33
|
+
return [Math.min(start, end), Math.max(start, end)]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function clickProteinToGenome({
|
|
37
|
+
model,
|
|
38
|
+
structureSeqPos,
|
|
39
|
+
}: {
|
|
40
|
+
structureSeqPos: number
|
|
41
|
+
model: JBrowsePluginProteinViewModel
|
|
42
|
+
}) {
|
|
43
|
+
const session = getSession(model)
|
|
44
|
+
const result = proteinToGenomeMapping({ structureSeqPos, model })
|
|
45
|
+
const { genomeToTranscriptSeqMapping, zoomToBaseLevel } = model
|
|
46
|
+
const { assemblyManager } = session
|
|
47
|
+
if (!genomeToTranscriptSeqMapping || result === undefined) {
|
|
48
|
+
return undefined
|
|
49
|
+
}
|
|
50
|
+
const [s1, s2] = result
|
|
51
|
+
const lgv = session.views[0] as LinearGenomeViewModel
|
|
52
|
+
const { strand, refName } = genomeToTranscriptSeqMapping
|
|
53
|
+
model.setClickGenomeHighlights([
|
|
54
|
+
{
|
|
55
|
+
assemblyName: 'hg38',
|
|
56
|
+
refName,
|
|
57
|
+
start: s1,
|
|
58
|
+
end: s2,
|
|
59
|
+
},
|
|
60
|
+
])
|
|
61
|
+
|
|
62
|
+
if (!zoomToBaseLevel) {
|
|
63
|
+
const assembly = assemblyManager.get(lgv.assemblyNames[0])
|
|
64
|
+
const r = assembly?.getCanonicalRefName(refName) ?? refName
|
|
65
|
+
lgv.centerAt(s1, r)
|
|
66
|
+
} else {
|
|
67
|
+
await lgv.navToLocString(
|
|
68
|
+
`${refName}:${s1}-${s2}${strand === -1 ? '[rev]' : ''}`,
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function hoverProteinToGenome({
|
|
74
|
+
model,
|
|
75
|
+
structureSeqPos,
|
|
76
|
+
}: {
|
|
77
|
+
structureSeqPos: number
|
|
78
|
+
model: JBrowsePluginProteinViewModel
|
|
79
|
+
}) {
|
|
80
|
+
const session = getSession(model)
|
|
81
|
+
const result = proteinToGenomeMapping({ structureSeqPos, model })
|
|
82
|
+
const { genomeToTranscriptSeqMapping } = model
|
|
83
|
+
if (!genomeToTranscriptSeqMapping || !result) {
|
|
84
|
+
return
|
|
85
|
+
}
|
|
86
|
+
if (!result) {
|
|
87
|
+
session.notify('Genome position not found')
|
|
88
|
+
}
|
|
89
|
+
const [s1, s2] = result
|
|
90
|
+
const { refName } = genomeToTranscriptSeqMapping
|
|
91
|
+
model.setHoverGenomeHighlights([
|
|
92
|
+
{
|
|
93
|
+
assemblyName: 'hg38',
|
|
94
|
+
refName,
|
|
95
|
+
start: s1,
|
|
96
|
+
end: s2,
|
|
97
|
+
},
|
|
98
|
+
])
|
|
99
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { PluginContext } from 'molstar/lib/mol-plugin/context'
|
|
2
|
+
import { Structure, StructureSelection } from 'molstar/lib/mol-model/structure'
|
|
3
|
+
import { getMolstarStructureSelection } from './util'
|
|
4
|
+
|
|
5
|
+
export default function selectResidue({
|
|
6
|
+
structure,
|
|
7
|
+
selectedResidue,
|
|
8
|
+
plugin,
|
|
9
|
+
}: {
|
|
10
|
+
structure: Structure
|
|
11
|
+
selectedResidue: number
|
|
12
|
+
plugin: PluginContext
|
|
13
|
+
}) {
|
|
14
|
+
const sel = getMolstarStructureSelection({ structure, selectedResidue })
|
|
15
|
+
const loci = StructureSelection.toLociWithSourceUnits(sel)
|
|
16
|
+
plugin?.managers.interactivity.lociSelects.select({
|
|
17
|
+
loci,
|
|
18
|
+
})
|
|
19
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useState, useEffect, useRef } from 'react'
|
|
2
|
+
// molstar
|
|
3
|
+
import { PluginContext } from 'molstar/lib/mol-plugin/context'
|
|
4
|
+
import { createPluginUI } from 'molstar/lib/mol-plugin-ui'
|
|
5
|
+
import { renderReact18 } from 'molstar/lib/mol-plugin-ui/react18'
|
|
6
|
+
import { DefaultPluginUISpec } from 'molstar/lib/mol-plugin-ui/spec'
|
|
7
|
+
|
|
8
|
+
// locals
|
|
9
|
+
import { loadStructureFromURL } from './loadStructureFromURL'
|
|
10
|
+
import { loadStructureFromData } from './loadStructureFromData'
|
|
11
|
+
|
|
12
|
+
export default function useProteinView({
|
|
13
|
+
url,
|
|
14
|
+
data,
|
|
15
|
+
showControls,
|
|
16
|
+
}: {
|
|
17
|
+
url?: string
|
|
18
|
+
data?: string
|
|
19
|
+
showControls: boolean
|
|
20
|
+
}) {
|
|
21
|
+
const parentRef = useRef<HTMLDivElement>(null)
|
|
22
|
+
const [plugin, setPlugin] = useState<PluginContext>()
|
|
23
|
+
const [error, setError] = useState<unknown>()
|
|
24
|
+
const [seq, setSeq] = useState('')
|
|
25
|
+
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
let p: PluginContext | undefined
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
29
|
+
;(async () => {
|
|
30
|
+
try {
|
|
31
|
+
if (!parentRef.current) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
const d = document.createElement('div')
|
|
35
|
+
parentRef.current.append(d)
|
|
36
|
+
p = await createPluginUI({
|
|
37
|
+
target: d,
|
|
38
|
+
render: renderReact18,
|
|
39
|
+
spec: {
|
|
40
|
+
...DefaultPluginUISpec(),
|
|
41
|
+
layout: {
|
|
42
|
+
initial: {
|
|
43
|
+
controlsDisplay: 'reactive',
|
|
44
|
+
showControls,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
await p.initialized
|
|
50
|
+
setPlugin(p)
|
|
51
|
+
|
|
52
|
+
if (url) {
|
|
53
|
+
const { seq } = await loadStructureFromURL({ url, plugin: p })
|
|
54
|
+
setSeq(seq)
|
|
55
|
+
} else if (data) {
|
|
56
|
+
const { seq } = await loadStructureFromData({ data, plugin: p })
|
|
57
|
+
setSeq(seq)
|
|
58
|
+
}
|
|
59
|
+
} catch (e) {
|
|
60
|
+
console.error(e)
|
|
61
|
+
setError(e)
|
|
62
|
+
}
|
|
63
|
+
})()
|
|
64
|
+
return () => {
|
|
65
|
+
p?.unmount()
|
|
66
|
+
}
|
|
67
|
+
}, [url, data, showControls])
|
|
68
|
+
|
|
69
|
+
return { parentRef, error, plugin, seq }
|
|
70
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
import { getSession } from '@jbrowse/core/util'
|
|
3
|
+
import { PluginContext } from 'molstar/lib/mol-plugin/context'
|
|
4
|
+
|
|
5
|
+
// local
|
|
6
|
+
import { JBrowsePluginProteinViewModel } from './model'
|
|
7
|
+
import { clickProteinToGenome } from './proteinToGenomeMapping'
|
|
8
|
+
import {
|
|
9
|
+
StructureElement,
|
|
10
|
+
StructureProperties as Props,
|
|
11
|
+
} from 'molstar/lib/mol-model/structure'
|
|
12
|
+
|
|
13
|
+
export default function useProteinViewClickActionBehavior({
|
|
14
|
+
plugin,
|
|
15
|
+
model,
|
|
16
|
+
}: {
|
|
17
|
+
plugin?: PluginContext
|
|
18
|
+
model: JBrowsePluginProteinViewModel
|
|
19
|
+
}) {
|
|
20
|
+
const [error, setError] = useState<unknown>()
|
|
21
|
+
const session = getSession(model)
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
if (!plugin) {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
plugin.behaviors.interaction.click.subscribe(event => {
|
|
27
|
+
if (StructureElement.Loci.is(event.current.loci)) {
|
|
28
|
+
const loc = StructureElement.Loci.getFirstLocation(event.current.loci)
|
|
29
|
+
if (loc) {
|
|
30
|
+
const pos = Props.residue.auth_seq_id(loc)
|
|
31
|
+
const code = Props.atom.label_comp_id(loc)
|
|
32
|
+
const chain = Props.chain.auth_asym_id(loc)
|
|
33
|
+
model.setHoveredPosition({
|
|
34
|
+
structureSeqPos: pos - 1,
|
|
35
|
+
code,
|
|
36
|
+
chain,
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
clickProteinToGenome({ model, structureSeqPos: pos - 1 }).catch(e => {
|
|
40
|
+
console.error(e)
|
|
41
|
+
setError(e)
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}, [plugin, session, model])
|
|
47
|
+
return { error }
|
|
48
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useEffect } from 'react'
|
|
2
|
+
import { getSession } from '@jbrowse/core/util'
|
|
3
|
+
import { PluginContext } from 'molstar/lib/mol-plugin/context'
|
|
4
|
+
|
|
5
|
+
// local
|
|
6
|
+
import { JBrowsePluginProteinViewModel } from './model'
|
|
7
|
+
import {
|
|
8
|
+
StructureElement,
|
|
9
|
+
StructureProperties as Props,
|
|
10
|
+
} from 'molstar/lib/mol-model/structure'
|
|
11
|
+
import { hoverProteinToGenome } from './proteinToGenomeMapping'
|
|
12
|
+
|
|
13
|
+
export default function useProteinViewClickActionBehavior({
|
|
14
|
+
plugin,
|
|
15
|
+
model,
|
|
16
|
+
}: {
|
|
17
|
+
plugin?: PluginContext
|
|
18
|
+
model: JBrowsePluginProteinViewModel
|
|
19
|
+
}) {
|
|
20
|
+
const session = getSession(model)
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!plugin) {
|
|
23
|
+
return
|
|
24
|
+
}
|
|
25
|
+
plugin.behaviors.interaction.hover.subscribe(event => {
|
|
26
|
+
if (StructureElement.Loci.is(event.current.loci)) {
|
|
27
|
+
const loc = StructureElement.Loci.getFirstLocation(event.current.loci)
|
|
28
|
+
if (loc) {
|
|
29
|
+
// example code for this label
|
|
30
|
+
// https://github.com/molstar/molstar/blob/60550cfea1f62a50a764d5714307d6d1049be71d/src/mol-theme/label.ts#L255-L264
|
|
31
|
+
const structureSeqPos = Props.residue.auth_seq_id(loc)
|
|
32
|
+
const code = Props.atom.label_comp_id(loc)
|
|
33
|
+
const chain = Props.chain.auth_asym_id(loc)
|
|
34
|
+
model.setHoveredPosition({
|
|
35
|
+
structureSeqPos: structureSeqPos - 1,
|
|
36
|
+
code,
|
|
37
|
+
chain,
|
|
38
|
+
})
|
|
39
|
+
hoverProteinToGenome({ model, structureSeqPos: structureSeqPos - 1 })
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}, [plugin, session, model])
|
|
44
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Feature } from '@jbrowse/core/util'
|
|
2
|
+
import { Structure } from 'molstar/lib/mol-model/structure'
|
|
3
|
+
import { Script } from 'molstar/lib/mol-script/script'
|
|
4
|
+
import { proteinAbbreviationMapping } from './proteinAbbreviationMapping'
|
|
5
|
+
|
|
6
|
+
export function checkHovered(hovered: unknown): hovered is {
|
|
7
|
+
hoverFeature: Feature
|
|
8
|
+
hoverPosition: { coord: number; refName: string }
|
|
9
|
+
} {
|
|
10
|
+
return (
|
|
11
|
+
!!hovered &&
|
|
12
|
+
typeof hovered == 'object' &&
|
|
13
|
+
'hoverFeature' in hovered &&
|
|
14
|
+
'hoverPosition' in hovered
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function getMolstarStructureSelection({
|
|
19
|
+
structure,
|
|
20
|
+
selectedResidue,
|
|
21
|
+
}: {
|
|
22
|
+
structure: Structure
|
|
23
|
+
selectedResidue: number
|
|
24
|
+
}) {
|
|
25
|
+
return Script.getStructureSelection(
|
|
26
|
+
Q =>
|
|
27
|
+
Q.struct.generator.atomGroups({
|
|
28
|
+
'residue-test': Q.core.rel.eq([
|
|
29
|
+
Q.struct.atomProperty.macromolecular.label_seq_id(),
|
|
30
|
+
selectedResidue,
|
|
31
|
+
]),
|
|
32
|
+
'group-by': Q.struct.atomProperty.macromolecular.residueKey(),
|
|
33
|
+
}),
|
|
34
|
+
structure,
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function toStr(r: {
|
|
39
|
+
structureSeqPos: number
|
|
40
|
+
code?: string
|
|
41
|
+
chain?: string
|
|
42
|
+
}) {
|
|
43
|
+
return [
|
|
44
|
+
`Position: ${r.structureSeqPos}`,
|
|
45
|
+
r.code
|
|
46
|
+
? `Letter: ${r.code} (${proteinAbbreviationMapping[r.code]?.singleLetterCode})`
|
|
47
|
+
: '',
|
|
48
|
+
r.chain ? `Chain: ${r.chain}` : '',
|
|
49
|
+
]
|
|
50
|
+
.filter(f => !!f)
|
|
51
|
+
.join(', ')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function invertMap(arg: Record<number, number | undefined>) {
|
|
55
|
+
return Object.fromEntries(Object.entries(arg).map(([a, b]) => [b, a]))
|
|
56
|
+
}
|