PyMol useable via Binder (no graphical user interface)

My collection demonstrating using Pymol here.

A very basic demo of running PyMol via this interface is included on this page here just below the index.
For more practical uses of PyMol, select a notebook from this index of availabe demostration notebooks below.


Available Notebooks

If you haven't used one of these notebooks before, they're basically web pages in which you can write, edit, and run live code. They're meant to encourage experimentation, so don't feel nervous. Just try running a few cells and see what happens!.

Some tips:

  • Code cells have boxes around them. When you hover over them a icon appears.
  • To run a code cell either click the icon, or click on the cell and then hit Shift+Enter. The Shift+Enter combo will also move you to the next cell, so it's a quick way to work through the notebook.
  • While a cell is running a * appears in the square brackets next to the cell. Once the cell has finished running the asterix will be replaced with a number.
  • In most cases you'll want to start from the top of notebook and work your way down running each cell in turn. Later cells might depend on the results of earlier ones.
  • To edit a code cell, just click on it and type stuff. Remember to run the cell once you've finished editing.

Basic example

This 'basic' example outputs an image of an amino acid.

The following cell generates a script based on Example #2 here, in addition to some features also on that page.

In [1]:
text_2_save = '''#!/usr/bin/python

import sys, os

# pymol environment
moddir='/opt/pymol-svn/modules'
sys.path.insert(0, moddir)
os.environ['PYMOL_PATH'] = os.path.join(moddir, 'pymol/pymol_path')

import pymol
cmd = pymol.cmd
# end of set-up

# things to have PyMol do go below here
cmd.fragment('ala')
cmd.zoom()
cmd.png('~/test_a.png', 800, 640, dpi=300, ray=1)
'''
%store text_2_save >script_a.py
Writing 'text_2_save' (str) to file 'script_a.py'.

Let's look at the first few lines of the script to verify it was made:

In [2]:
!head script_a.py
#!/usr/bin/python

import sys, os

# pymol environment
moddir='/opt/pymol-svn/modules'
sys.path.insert(0, moddir)
os.environ['PYMOL_PATH'] = os.path.join(moddir, 'pymol/pymol_path')

import pymol

With an example script, we are ready to run it.
The following cell will specify to run that script using PyMol. We'll indicate two options with flags in this call. They are the -cq part in between the call to pymol and the script name to have PyMol run. The -q specifies to launch quiet (-q) without all the notes PyMol generates at launch, and the -c specifies to launch without the GUI (-c). The flags can be merged into one with no spaces and then you only need the first -.
(Note that the exclamation point at the start is to tell the Jupyter environment to direct this to the shell. If you are running directly in a shell terminal, you'd leave off the exclamation point.

In [3]:
!pymol -cq script_a.py
 Ray: render time: 0.39 sec. = 9172.6 frames/hour (0.39 sec. accum.).

That will say it rendered and image and we can prove that by displaying the result here by running the next cell.
(Alternatively, the file browser here could be used to view the image.

In [4]:
from IPython.display import Image
Image("test_a.png")
Out[4]: