This tutorial demonstrates how to instantiate a py3Dmol viewer and set atom styles and colors.
import py3Dmol
py3Dmol downloads PDB structures using the MMTF file format from https://mmtf.rcsb.org. Prepend the 'pdb:" prefix to the 4-letter PDB ID.
viewer = py3Dmol.view(query='pdb:1STP')
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
Styles are specified as nested dictionaries. In this example, 'stick' is the AtomStyleSpec (list of atom styles).
viewer.setStyle({'stick': {}})
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
Colors are specified as a dictionary, e.g., {'color': 'spectrum'} or monochrome colors {'color':'lightgreen'} (list of colors).
viewer.setStyle({'cartoon': {'color': 'spectrum'}})
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
Color schemes can be used to color atoms and residues by properties. A particulary useful color scheme is the
viewer.setStyle({'stick': {'colorscheme': 'greenCarbon'}})
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
Example of coloring by amino acid type
viewer.setStyle({'cartoon': {'colorscheme':'amino'}})
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