Molecular structure

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()

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol

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()

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol

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()

You appear to be running in JupyterLab (or JavaScript failed to load for some other reason). You need to install the 3dmol extension:
jupyter labextension install jupyterlab_3dmol

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.