Gabriele Lanaro

4 Dec 2014

Chemview: 3D Chemistry for IPython Notebook

IPython Notebook is one of the most popular tools for data analysis. It basically lets your run Python scripts with an interactive notebook interface, allowing for runnable ‘‘notebook’’ that contains both text and data. I personally use it all the time for my research.

In the past month I’ve developed Chemview, an IPython notebook extensions that lets you display chemical system directly in the browser. This means that:


Viewing stuff in chemview is fairly easy. But since it deals only with visualization we will use another program (mdtraj) to pull data from the web.

import mdtraj as md
traj = md.load_pdb('2M6K.pdb')
print traj
<mdtraj.Trajectory with 30 frames, 4462 atoms, 292 residues, and unitcells>

Chemview provides a class MolecularViewer and helpers to let you easily display the protein using a cylinder and strand representation.

from chemview import MolecularViewer, enable_notebook
from chemview.contrib import topology_mdtraj

mv = MolecularViewer([0], topology_mdtraj(traj))

This will provide an interactive output. Left Click to rotate, Wheel to zoom, Right Click to pan.

Want to know more? Check out the handcrafted docs.

If you like the idea, give it a test and tell me how it goes :)

Share this Post