Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Molecular structure

import py3Dmol
import veloxchem as vlx

The structure of a molecular system can be visualized with py3Dmol, using an xyz-file:

thymine_xyz = """15
*
 C     0.095722    -0.037785    -1.093615
 C    -0.011848     1.408694    -1.113404
 C    -0.204706     2.048475     0.052807
 N    -0.302595     1.390520     1.249226
 C    -0.214596     0.023933     1.378238
 N    -0.017387    -0.607231     0.171757
 O     0.270287    -0.735594    -2.076393
 C     0.098029     2.096194    -2.424990
 H     1.052976     1.874860    -2.891573
 H     0.002157     3.170639    -2.310554
 H    -0.671531     1.743694    -3.104794
 O    -0.301905    -0.554734     2.440234
 H    -0.292790     3.119685     0.106201
 H     0.053626    -1.612452     0.215637
 H    -0.446827     1.892203     2.107092
"""

viewer = py3Dmol.view(width=400, height=300)
# black outline for nicer-looking figures
viewer.setViewStyle({"style": "outline", "width": 0.05})
viewer.addModel(thymine_xyz)
# visualize with the sticks and spheres
viewer.setStyle({"stick":{},"sphere": {"scale":0.25}})
# rotate for a better initial view
viewer.rotate(-90, "y")
viewer.show()
Loading...

This creates a dynamic view which can be rotated and zoomed in and out.

This functionality is available through VeloxChem using molecule.show():

molecule = vlx.Molecule.read_xyz_string(thymine_xyz)
molecule.show()
Loading...

Alternatively, PDF-files can be loaded directly from the PDB-library, and illustrated with different models (here looking at an XRD structure of photosystem II):

viewer = py3Dmol.view(
    query="pdb:6W1O", viewergrid=(1, 3), width=800, height=300, linked=False
)
viewer.setStyle({"cartoon": {"color": "spectrum"}}, viewer=(0, 1))
viewer.setStyle({"cartoon": {}}, viewer=(0, 2))
viewer.addStyle({"elem": "Mn"}, {"sphere": {"color": "red"}}, viewer=(0, 2))
viewer.addStyle({"elem": "Ca"}, {"sphere": {"color": "yellow"}}, viewer=(0, 2))
viewer.show()
Loading...

Here we illustrate this by line structure, and more cartoonish image with and without coloring different strands differently. To the right we see white ribbons with manganese and calcium atoms colored in red and yellow, respectively. These shows the position of the oxygen-evolving complex of photosystem II, which is the site of water-splitting and oxygen generation.

References
  1. Ibrahim, M., Fransson, T., Chatterjee, R., Cheah, M. H., Hussein, R., Lassalle, L., Sutherlin, K. D., Young, I. D., Fuller, F. D., Gul, S., Kim, I.-S., Simon, P. S., de Lichtenberg, C., Chernev, P., Bogacz, I., Pham, C. C., Orville, A. M., Saichek, N., Northen, T., … Yano, J. (2020). Untangling the sequence of events during the S            2            → S            3            transition in photosystem II and implications for the water oxidation mechanism. Proceedings of the National Academy of Sciences, 117(23), 12624–12635. 10.1073/pnas.2000529117