py3Dmol

2.5.4 · active · verified Thu Apr 16

py3Dmol is an IPython interface for embedding 3Dmol.js views in Jupyter notebooks. It enables dependency-free interactive molecular visualization, as a minified version of the 3Dmol.js library is included directly. It supports rendering various molecular objects and is currently at version 2.5.4, with active development under the 3Dmol.js ecosystem.

Common errors

Warnings

Install

Imports

Quickstart

Initializes a 3Dmol viewer, loads a protein structure (PDB ID: 1ubq), styles it as a spectrum-colored cartoon, zooms to fit, and displays the interactive viewer in a Jupyter notebook cell.

import py3Dmol

# Create a viewer instance and load a PDB structure by query
view = py3Dmol.view(query='pdb:1ubq')

# Set a cartoon style with spectrum coloring
view.setStyle({'cartoon':{'color':'spectrum'}})

# Zoom to fit the entire molecule
view.zoomTo()

# Display the visualization in the notebook
view

view raw JSON →