Skip to content

Commit 10ce55a

Browse files
fix up 3d visualisation
previously spheres were shown in the middle, not on either side
1 parent 3e397a3 commit 10ce55a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

openfe/utils/visualization_3D.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,17 @@ def show_3D_mapping(
150150
molA = mapping.componentA.to_rdkit()
151151
molB = mapping.componentB.to_rdkit()
152152

153-
mblock1 = Chem.MolToMolBlock(_translate(molA, -1 * shift))
154-
mblock2 = Chem.MolToMolBlock(_translate(molB, shift))
153+
# 0 * shift is the centrepoint
154+
# shift either side of the mapping +- a shift to clear the centre view
155+
lmol = _translate(molA, -1 * shift)
156+
rmol = _translate(molB, +1 * shift)
155157

156158
view = py3Dmol.view(width=600, height=600)
157-
view.addModel(mblock1, "molA")
158-
view.addModel(mblock2, "molB")
159+
view.addModel(Chem.MolToMolBlock(lmol), "molA")
160+
view.addModel(Chem.MolToMolBlock(rmol), "molB")
159161

160162
if spheres:
161-
_add_spheres(view, molA, molB, mapping.componentA_to_componentB)
163+
_add_spheres(view, lmol, rmol, mapping.componentA_to_componentB)
162164

163165
if show_atomIDs:
164166
view.addPropertyLabels(
@@ -174,11 +176,8 @@ def show_3D_mapping(
174176
)
175177

176178
# middle fig
177-
overlay_mblock1 = Chem.MolToMolBlock(_translate(molA, 1 * shift))
178-
overlay_mblock2 = Chem.MolToMolBlock(_translate(molB, -1 * shift))
179-
180-
view.addModel(overlay_mblock1, "molA_overlay")
181-
view.addModel(overlay_mblock2, "molB_overlay")
179+
view.addModel(Chem.MolToMolBlock(molA), "molA_overlay")
180+
view.addModel(Chem.MolToMolBlock(molB), "molB_overlay")
182181

183182
view.setStyle({style: {}})
184183

0 commit comments

Comments
 (0)