Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
pdbe
web-components
pdb-ligand-env
Commits
30faff7a
Commit
30faff7a
authored
Jul 22, 2020
by
Lukas Pravda
Browse files
fix broken reinitialize from ligend view when bm was active
parent
1aa7bf07
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
20 deletions
+38
-20
src/plugin/manager.ts
src/plugin/manager.ts
+38
-20
No files found.
src/plugin/manager.ts
View file @
30faff7a
...
...
@@ -21,7 +21,8 @@ class Visualization {
// #region data properties
private
environment
:
Model
.
Environment
;
private
pdbId
:
string
;
private
bindingSite
:
Model
.
BindingSite
;
private
bindingSites
:
Model
.
BindingSite
[];
private
presentBindingSite
:
Model
.
BindingSite
;
private
depiction
:
Depiction
;
private
visualsMapper
:
VisualsMapper
;
...
...
@@ -41,6 +42,7 @@ class Visualization {
this
.
visualsMapper
=
new
VisualsMapper
(
this
.
environment
);
this
.
rProvider
=
ResidueProvider
.
getInstance
(
this
.
environment
);
this
.
fullScreen
=
false
;
this
.
bindingSites
=
new
Array
<
Model
.
BindingSite
>
();
if
(
uiParameters
===
undefined
)
uiParameters
=
new
Config
.
UIParameters
();
...
...
@@ -295,11 +297,13 @@ class Visualization {
if
(
this
.
depiction
===
undefined
||
this
.
depiction
.
ccdId
!==
body
.
ligand
.
chem_comp_id
)
{
this
.
initLigandDisplay
(
body
.
ligand
.
chem_comp_id
).
then
(()
=>
{
this
.
bindingSite
=
new
Model
.
BindingSite
().
fromLigand
(
key
,
body
,
this
.
depiction
);
this
.
presentBindingSite
=
new
Model
.
BindingSite
().
fromLigand
(
key
,
body
,
this
.
depiction
);
this
.
bindingSites
.
push
(
this
.
presentBindingSite
);
this
.
setupLigandScene
();
});
}
else
{
this
.
bindingSite
=
new
Model
.
BindingSite
().
fromLigand
(
key
,
body
,
this
.
depiction
);
this
.
presentBindingSite
=
new
Model
.
BindingSite
().
fromLigand
(
key
,
body
,
this
.
depiction
);
this
.
bindingSites
.
push
(
this
.
presentBindingSite
);
this
.
setupLigandScene
();
}
}
...
...
@@ -316,10 +320,11 @@ class Visualization {
public
addBoundMoleculeInteractions
(
data
:
any
,
bmId
:
string
)
{
let
key
=
Object
.
keys
(
data
)[
0
];
this
.
interactionsData
=
data
;
this
.
presentBindingSite
=
new
Model
.
BindingSite
().
fromBoundMolecule
(
key
,
data
[
key
][
0
]);
this
.
bindingSite
=
new
Model
.
BindingSite
().
fromBoundMolecule
(
key
,
data
[
key
][
0
]
);
this
.
b
indingSite
.
bmId
=
bmId
;
let
ligands
=
this
.
b
indingSite
.
residues
.
filter
(
x
=>
x
.
isLigand
);
this
.
bindingSite
s
.
push
(
this
.
presentBindingSite
);
this
.
presentB
indingSite
.
bmId
=
bmId
;
let
ligands
=
this
.
presentB
indingSite
.
residues
.
filter
(
x
=>
x
.
isLigand
);
if
(
ligands
.
length
===
1
)
this
.
initLigandInteractions
(
this
.
pdbId
,
ligands
[
0
].
authorResidueNumber
,
ligands
[
0
].
chainId
);
else
this
.
setupScene
();
...
...
@@ -362,7 +367,7 @@ class Visualization {
let
dataBlob
=
new
Blob
([
JSON
.
stringify
(
this
.
interactionsData
,
null
,
4
)],
{
type
:
'
application/json
'
});
downloadLink
.
href
=
URL
.
createObjectURL
(
dataBlob
);
downloadLink
.
download
=
this
.
interactionsData
===
undefined
?
'
no name.json
'
:
`
${
this
.
pdbId
}
_
${
this
.
b
indingSite
.
bmId
}
_interactions.json`
;
downloadLink
.
download
=
this
.
interactionsData
===
undefined
?
'
no name.json
'
:
`
${
this
.
pdbId
}
_
${
this
.
presentB
indingSite
.
bmId
}
_interactions.json`
;
document
.
body
.
appendChild
(
downloadLink
);
downloadLink
.
click
();
document
.
body
.
removeChild
(
downloadLink
);
...
...
@@ -376,8 +381,21 @@ class Visualization {
*/
public
reinitialize
()
{
if
(
this
.
depiction
===
undefined
)
this
.
setupScene
();
else
this
.
setupLigandScene
();
if
(
this
.
bindingSites
.
length
>
1
&&
this
.
depiction
!==
undefined
)
{
this
.
presentBindingSite
=
this
.
bindingSites
[
0
];
this
.
bindingSites
.
pop
();
this
.
depictionRoot
.
selectAll
(
'
*
'
).
remove
();
this
.
depiction
=
undefined
;
this
.
setupScene
().
then
(()
=>
this
.
centerScene
());
}
else
if
(
this
.
depiction
===
undefined
)
{
this
.
setupScene
().
then
(()
=>
this
.
centerScene
());
}
else
{
this
.
setupLigandScene
().
then
(()
=>
this
.
centerScene
());
}
this
.
hideLigandLabel
();
}
...
...
@@ -462,7 +480,7 @@ class Visualization {
}
private
getSVGName
():
string
{
if
(
this
.
b
indingSite
!==
undefined
)
return
`
${
this
.
b
indingSite
.
bmId
}
.svg`
;
if
(
this
.
presentB
indingSite
!==
undefined
)
return
`
${
this
.
presentB
indingSite
.
bmId
}
.svg`
;
if
(
this
.
depiction
!==
undefined
)
return
`
${
this
.
depiction
.
ccdId
}
.svg`
;
return
'
blank.svg
'
;
...
...
@@ -562,7 +580,7 @@ class Visualization {
private
setupLinks
()
{
this
.
links
=
this
.
linksRoot
.
selectAll
()
.
data
(
this
.
b
indingSite
.
links
)
.
data
(
this
.
presentB
indingSite
.
links
)
.
enter
().
append
(
'
g
'
);
this
.
links
...
...
@@ -657,10 +675,10 @@ class Visualization {
this
.
wipeOutVisuals
();
this
.
setupLinks
();
this
.
b
indingSite
.
interactionNodes
this
.
presentB
indingSite
.
interactionNodes
.
filter
((
x
:
Model
.
InteractionNode
)
=>
!
x
.
residue
.
isLigand
)
.
forEach
((
x
:
Model
.
InteractionNode
)
=>
{
let
lnks
=
this
.
b
indingSite
.
links
let
lnks
=
this
.
presentB
indingSite
.
links
.
filter
((
y
:
Model
.
LigandResidueLink
)
=>
y
.
containsInteractionNode
(
x
))
.
map
((
y
:
Model
.
LigandResidueLink
)
=>
[].
concat
.
apply
([],
y
.
interaction
.
map
(
z
=>
z
.
sourceAtoms
)));
...
...
@@ -673,13 +691,13 @@ class Visualization {
// setup nodes; wait for resources to be ready
this
.
b
indingSite
.
interactionNodes
.
forEach
(
x
=>
this
.
rProvider
.
downloadAnnotation
(
x
.
residue
));
this
.
presentB
indingSite
.
interactionNodes
.
forEach
(
x
=>
this
.
rProvider
.
downloadAnnotation
(
x
.
residue
));
await
Promise
.
all
(
this
.
rProvider
.
downloadPromises
);
await
Promise
.
all
([
this
.
visualsMapper
.
graphicsPromise
,
this
.
visualsMapper
.
mappingPromise
]);
this
.
nodes
=
this
.
nodesRoot
.
append
(
'
g
'
)
.
selectAll
()
.
data
(
this
.
b
indingSite
.
interactionNodes
)
.
data
(
this
.
presentB
indingSite
.
interactionNodes
)
.
enter
().
append
(
'
g
'
);
...
...
@@ -708,7 +726,7 @@ class Visualization {
let
charge
=
d3
.
forceManyBody
().
strength
(
-
100
).
distanceMin
(
40
).
distanceMax
(
80
);
let
collision
=
d3
.
forceCollide
().
radius
(
45
);
this
.
simulation
=
d3
.
forceSimulation
(
this
.
b
indingSite
.
interactionNodes
)
this
.
simulation
=
d3
.
forceSimulation
(
this
.
presentB
indingSite
.
interactionNodes
)
.
force
(
'
link
'
,
forceLink
)
.
force
(
'
charge
'
,
charge
)
//strength
.
force
(
'
collision
'
,
collision
)
...
...
@@ -732,13 +750,13 @@ class Visualization {
this
.
setupLinks
();
// setup nodes; wait for resources to be ready
this
.
b
indingSite
.
interactionNodes
.
forEach
(
x
=>
ResidueProvider
.
getInstance
(
this
.
environment
).
downloadAnnotation
(
x
.
residue
));
this
.
presentB
indingSite
.
interactionNodes
.
forEach
(
x
=>
ResidueProvider
.
getInstance
(
this
.
environment
).
downloadAnnotation
(
x
.
residue
));
await
Promise
.
all
(
this
.
rProvider
.
downloadPromises
);
await
Promise
.
all
([
this
.
visualsMapper
.
graphicsPromise
,
this
.
visualsMapper
.
mappingPromise
]);
this
.
nodes
=
this
.
nodesRoot
.
selectAll
()
.
data
(
this
.
b
indingSite
.
interactionNodes
)
.
data
(
this
.
presentB
indingSite
.
interactionNodes
)
.
enter
().
append
(
'
g
'
)
.
attr
(
'
class
'
,
(
e
:
Model
.
InteractionNode
)
=>
`pdb-lig-env-svg-node pdb-lig-env-svg-
${
e
.
residue
.
getResidueType
()}
-res`
)
.
on
(
'
click
'
,
(
x
:
Model
.
InteractionNode
,
i
:
number
,
g
:
any
)
=>
this
.
selectLigand
(
x
,
i
,
g
))
...
...
@@ -757,7 +775,7 @@ class Visualization {
this
.
addNodeLabels
(
this
.
nodes
);
let
forceLink
=
d3
.
forceLink
()
.
links
(
this
.
b
indingSite
.
links
)
.
links
(
this
.
presentB
indingSite
.
links
)
.
distance
((
x
:
Model
.
Link
)
=>
(
<
Model
.
InteractionNode
>
x
.
source
).
residue
.
isLigand
&&
(
<
Model
.
InteractionNode
>
x
.
target
).
residue
.
isLigand
?
55
:
150
)
.
strength
(
0.5
);
...
...
@@ -765,7 +783,7 @@ class Visualization {
let
collision
=
d3
.
forceCollide
(
45
);
let
center
=
d3
.
forceCenter
(
this
.
parent
.
offsetWidth
/
2
,
this
.
parent
.
offsetHeight
/
2
);
this
.
simulation
=
d3
.
forceSimulation
(
this
.
b
indingSite
.
interactionNodes
)
this
.
simulation
=
d3
.
forceSimulation
(
this
.
presentB
indingSite
.
interactionNodes
)
.
force
(
'
link
'
,
forceLink
)
.
force
(
'
charge
'
,
charge
)
//strength
.
force
(
'
collision
'
,
collision
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment