IPyMOL allows you to control PyMOL sessions via IPython. This tool is ideal for situations where you'd like to present your work neatly in a Jupyter Notebook or conveniently prototype PyMOL scripts.
Please ensure that PyMOL is in your $PATH
as pymol
or you can start PyMOL in server mode:
$ pymol -R #-cKRQ to run it without a GUI
pip install ipymol
You can fire up an IPython or IPython Notebook session and start using IPyMOL. For example:
from ipymol import viewer as pymol
pymol.start() # Start PyMOL RPC server
pymol.do('fetch 3odu; as cartoon; bg white')
pymol.show()
This series of commands will define a variable pymol
of class MolViewer
, which can pass commands to PyMOL, and then create an image of PDBID:3odu
in your IPython session.
Any additional commands can be invoked via pymol.do("[ENTER YOUR COMMAND HERE]")
.
Here's an additional example.
Enjoy!