Faster image creation in PyMOL: Shortcuts and Docker


PyMOL command scripts are available natively and within Docker images.

Various Escherichia coli dUTPase representations.

PyMOL Scripts

PyMOL offers a very easy-to-use graphical user interface (GUI) to manipulate loaded molecule, and alter the appearance and coloring options. However, while this is easy, it is not the “best way” to use PyMOL if one wants to be able to reproduce a scene in the furture.

The “best way” is to create a series of PyMOL commands that can be saved within a simple text file. As stated in a previous post (No GUI PyMOL for high troughput images and optional Docker):

The use of script is very well illustrated in the book PyMOL in book Exploring Protein Structure – Principles and Practice which provides a script for each of the molecular images within the book. I also made an example of this in my “PyMOL scripts book” illustrating the COVID19 spike protein.


I recently discovered this publication: Shortcuts for faster image creation in PyMOL (Mooers, 2020) which provides a series of 2-letter shortcut commands some of which can replace multiple lines of commands. (More details are also on the github repository at MooersLab/PyMOLshortcuts.)

For example the command AO creates an ambient occlusion image, and BW creates a black-and white-ribbon cartoon on a white background.

Docker images

I created Docker images to use use the open-source versions of pymol that also contain the shortcut scripts. These are available on the Docker Hub: jysgro/pymol for PyMOL versions that use either Python 2 or Python 3.

One specific shortcut command:  BUcomputes the “Biological Unit” and works in all the versions except the one tagged 2.5.0_sc. However, users can retrieve the biological unit (as opposed to the crystallographic unit) with a PyMOL command. For example: fetch 1dud, type=pdb1 will retrieve the biological assembly for the 1dud entry, but users will not see all segments until PyMOL command set all_state, on is given. Here is an example:

1. Prepare a PyMOL script file, e.g. commands.pml in current directory of your local computer (Mac/Windows/Linux.)

fetch 1dud, type=pdb
# load 1dud.pdb
remove solvent
turn z, -10
png test.png

2. Start a container:

docker run -it --rm -v ${PWD}:/data -w /data jysgro/pymol:1.8.4_sc

3. Within the container command-line type:

pymol -qc commands.pml

3. Exit container by typing: exit

4. open the file (on a Mac simply type open test.png) to see the results:


Cartoon representation of 1DUD biological unit.


Mooers BHM. “Shortcuts for faster image creation in PyMOL.” Protein science : a publication of the Protein Society.” 2020 Jan;29(1):268-276. doi: 10.1002/pro.3781. Epub 2019 Nov 27.  PMID: 31710740; PMCID: PMC6933860.

Larsson, G., Svensson, L. & Nyman, P. Crystal structure of the Escherichia coli dUTPase in complex with a substrate analogue (dUDP). Nat Struct Mol Biol 3, 532–538 (1996). doi: 10.1038/nsb0696-532