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.
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!.
This 'basic' example outputs an image of an amino acid.
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:
#!/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.
!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.
from IPython.display import Image Image("test_a.png")