Pymol Tutorial: Part of Biochemistry 712 and Biochemistry 660
Pymol Tutorial: Part of Biochemistry 712 and Biochemistry 660
MAJOR PROFESSOR:
Ann Palmenberg
Institute for Molecular Virology & Department of Biochemistry
acpalmen@wisc.edu
Adam Steinberg
Department of Biochemistry Medialab
hsteinbe@wisc.edu
version 11/2006
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
=========================================
From the preface of the User’s guide: “PyMOL was created in an efficient but highly pragmatic
manner, with heavy emphasis on delivering powerful features to end users. Expediency has
almost always taken precedence over elegance, and adherence to established software
development practices is inconsistent. PyMOL is about getting the job done now, as fast as
possible, by whatever means were available.”
PyMol is a multiplatform molecular graphics software with many advanced features such as
rendered cartoon ribbons and surfaces, internal ray tracing and movie tools and is fast
becoming the new “standard” in molecular graphics. The PyMol web site is located at
http://pymol.sourceforge.net/
=========================================
Note: within the exercises, Bold text shows what actions are taken by the user : typing text or
clicking the mouse.
=========================================
Reminder: Structures have a PDB ID code made of 4 letters and numbers. PDB files contain
coordinates pertinent to the crystallographic arrangement of the molecules within the crystal.
The biological functional entity can be either a multimer of the deposited structure, or just one
of multiple copies within the file. In the following example we will download one functional
biological subunit, in this case a monomer.
L02 – page 1
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
=========================================
2) Type the next commands after PyMOL> within the top line command:
L02 – page 2
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
This will load the structure and echo TITLE CRYSTAL STRUCTURE OF APOCAROTENOID CLEAVAGE
OXYGENASE FROM
information in the text panel as TITLE 2 SYNECHOCYSTIS, NATIVE ENZYME
COMPND APOCAROTENOID-CLEAVING OXYGENASE
reproduced to the right. ObjectMolecule: Read secondary structure assignments.
ObjectMolecule: Read crystal symmetry information.
Symmetry: Found 4 symmetry operators.
Note: file name is case sensitive CmdLoad: "2BIW.pdb2" loaded as"2BIW.pdb2".
Note: why not use the File> Open menu sequence? Good question…
You can actually try that option and it might work on your current
system. However you will likely find that when you get to the Open
form the files you want to open are listed in gray and therefore cannot
be opened. The easy fix is to simply rename the file from *.pdb1 or
*.pdb2 to simply *.pdb before you try to open it.
=========================================
The menu bar might be attached to the external GUI in systems other than Mac.
By default PyMol will display the molecule(s) contained within the PDB file as a wireframe.
The 3D molecule is represented within a virtual 3D world. The flat surface of the screen
represents the X and Y axes while the Z, depth axis is perpendicular to the screen.
L02 – page 3
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
PyMol is optimized for a 3-button mouse but most basic functions can still be achieved by a
one-button mouse, in particular the rotations around X, Y, and Z.
By default PyMol assumes that you have a 3-button mouse. If you have a 2-
or one-button mouse you can change the setting accordingly with the
“Mouse” menu in the top menu bar.
Note the updating of the “Mouse Mode” button mapping at the bottom right
within the “Internal GUI” if you change the mouse setting.
PyMol can open more than one molecule at a time, or separate complex PDB files into
individual components. Each opened or loaded molecule is given a name within the “Names
Panel” (see picture above). The first name is always “all.” Clicking on the name itself will
undisplay the corresponding molecule(s) (temporarily invisible).
The ASHLC menu ( ) is abbreviated for Action, Show, Hide Lablel and Color.
Some menu items have submenu components. Selections made under the “all” line will affect
all the opened molecules.
Rule: Once a selection is shown (S) it must be selectively hidden (H) as it is not removed
when another selection (S) is made. Selections are therefore additive, which allows for the
creation of images with mixed graphical representations.
(Note that within the S menu list, the “as” menu contains a lot of
redundancies.)
L02 – page 4
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
Testing other cartoon settings: Engaging the option Smooth Loops will simplify the drawing.
Removing the option Highlight Color will make the edges of strands and inside helices
surfaces a gray color (default).
Black backgrounds look very nice on the screen but do not print well on paper and do not
photocopy well. Changing the backgroud to white is usually very useful:
The “Display” menu within the top menu bar contains options for
most options pertinent to displaying the image witin the PyMol
viewer.
Note that there is “fog” within the back of the molecule, which can
be toggled on and off with the Depth Cue menu item within this
same menu list.
Changing the color of the ribbon is easy with the following cascade
menu within the PyMol “Names Panel” of the “Internal GUI” under the C
menu as shown in the following menu cascade:
2BIW.pdb2 > C > by ss > Helix Sheet Loop (choose one of the the 2
color options displayed e.g. pink and cyan.
When we opted to show the molecule as a cartoon above, one thing happened: the protein
was shown as the familiar cartoon represenation, but if any ligand is present (which is the true
for this file) it simply disappears as it is not part of the cartoon representation of the protein.
Here we will “rescue” the ligand!
This menu cascade is also within the “ASHLC” menus of the PyMol
“Internal GUI” “Names Panel.” Since ligands are usually small, organic
molecules, the following cascade within the Show menu for line 2BIW
will show the ligand. Perform the following cascade:
This cascade will select the carotenoid present witin the PDB file.
Note that it is the same color as other parts of the protein, as it is part of the name
2BIW.pdb2 line. It will be either orange or the color for loops in the C/ss/Helix-Sheet-
Loop color scheme chosen in the step above.
5) Mouse selection
Now that we have made the ligand visible, it becomes easier to select it with the mouse to
make further changes.
Click on one of the spheres of the carotenoid ligand. This simple click makes various things
happen:
a. pink, square dots appear onto all the spheres of the lignad, indicating that it has
been selected.
b. A new name line appears within the “Names Panel” GUI called “(sele)” and is
now dedicated to this subset of atoms. Note that the content of (sele) changes as
other atoms are clicked
c. The name of the atom that was clicked appears within the top text window of the
“external GUI.” For example:
You clicked /2BIW.pdb2//B/TYR`322/OH
Selector: selection "sele" defined with 12 atoms.
This could be read as “you clicked atom OH which is on the 322nd atom in the file, and
belongs to Tyrosine 322 of chain B in the object created when opening file 2BIW.pdb2.
The complete selection contains 12 atoms (which make up the complete Tyrosine
without the hydrogens, since these are usually not present in PDB files.)
Now that the ligand atoms are segregated within the name of (sele) we can change its color if
we want by the following cascade within the Names Panel:
L02 – page 6
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
6) Final image(s)
If you still see the selection dots over the ligand from the previous section simply click
anywhere on the white background to unselect. Alternatively click on the “Hide-Sele” button at
the top right hand side of the “external GUI.”
Rotate the molecule to find a perspective that you deem instructive of the conformation of the
protein and it’s bound ligand.
However this image is rather crude in terms of graphics and resolution. PyMol offers an
internal “ray tracer” to create stunning rendered images with a high visual quality much more
pleasant to the eye and ideal for publication.
Zoomed side-by-side comparison between the pymol image and the ray-traced image: note the jagginess
of the original image and the smooth appearance of the ray-traced image, with shadows as a bonus.
L02 – page 7
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
This is useful to create preview images for slide presentations, but is still one step short of the
quality needed for high resolution publication, as the image created by the default setting is the
same size as that of the current Viewer (default size is 640 x 480 pixels when PyMol is first
opened.) The default file format is the new PNG standard. All we need to do at this point is
change the default setting of the ray-traced file size.
=========================================
This is mostly a self-paced exploration of one of the menus that is sure to change over time as
PyMol evolves.
If you are not continuing this exercise from the previous exercise load the structure
2BIW.pdb2 as in Exercise B, then click S> Cartoon to be in a similar sate as in the previous
exercise.
The preset menu is part of the Action set of the ASHLC menus controlling the aspect of
molecules from the Names Panel.
Follow this menu cascade sequence to return to the default view, as when you just opened the
molecule. However no rotation occurs:
L02 – page 8
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
Note: to get back to the original opening view simply type reset at the PyMOL> line command.
2) Exploring more
simple
b factor putty
L02 – page 9
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
ligands
This option will zoom in on the ligand site and show the
protein as backbone except in the near vicinity of the
ligand where side chains are shown. The ligand is
depicted as a thicker cylinder.
ligand sites
You should obtain a centered, zoomed view of the ligand shown as a stick model within a
partial molecular surface pocket. The colors are the scheme of previously chosen colors, for
example if you tried the “technical” preset earlier the coloring would likely be like a rainbow.
The following quick changes will make a much nicer image: 2BIW.pdb2 > C > yellows > sand
Now with the mouse click carefully anywhere on the ligand stick to select it. As before you will
have a (sele) name within the Names Panel. You can now change the color with the following
menu cascade: sele > C > blues > slate
Of course you can pick your own colors. Make sure that there is sufficient contrast between the
color of the surface and the color of the ligand.
L02 – page 10
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
=========================================
We are still working with the 2BIW.pdb2 file loaded above. Review exercise B if you need to
reload the structure.
This exercise assumes you have just completed creating the above view with the preset menu
cascade: 2BIW.pdb2 > A > preset > ligand sites > solid surface
1) Sequence viewer
The molecule sequence can be shown at the top of the graphical area. To do this follow the
top menu: Display > Sequence on
The sequence appears just below the PyMOL> line command at the top of the Viewer. The
slide cursor underneath can be used to move the sequence viewed further.
L02 – page 11
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
Note: when you clicked, information about the clicked atom appeared within the text box of the
“external GUI,” e.g.:“You clicked /2BIW.pdb2//B/TYR`322/CG.”
Therefore we know that Tyrosine 322 is the one we chose.
Now slide the sequence cursor to the right to move the sequence displayed until you find
the region of the selected TYR. If you have the one-letter code engaged, it appears under the
number 321. However we know it is 322. If you have engaged the three-letter code as
instructed above TYR 322 is shown highlighted within the sequence line.
Now display the sequence line to see residues PHE 303 and HIS 304. With the mouse click
on residue 303 and residue 304 within the sequence line. Note that they are selected
within the graphical window. The arrows within the following image show where you should
look. As before, transform those side chains to a thicker stick with the menu cascade:
(sele) > S > sticks
Quiz question: We just selected amino acids TYR 322, PHE 303, and HIS 304. Can you
describe with one word one important quality of this binding pocket?
Answer: This binding pocket has the following quality: _____________________________
2) Measuring distances
Distances are measured between two atoms and are expressed in the same unit as the XYZ
coordinates within the PDB file: Angstroms (1Å = 10–10 m).
As an example we shall measure the distance between two atoms within the carotenoid ligand.
(you can select the same atoms as 2 examples within the image
at right, or select alternate atoms)
Quiz exercise: you can also measure the distance between the OH at the tip of TYR 322 and
the nearest ligand atom (C30). Answer: ___________________________________________
When you are done using the “Measurement” panel on the bottom right click Done.
If you no longer need to display the distance object, click Delete All Measurements.
Alternatively you can use the corresponding “A” menu and select the delete option.
3) Clipping planes
Clipping planes are imaginary planes in the front and back of the molecule. Parts of the
molecule that are outside the planes are “clipped” and therefore invisible. This is very useful for
complex or large structures.
The BNMC computers are equipped with 3-button mice. To move clipping planes press shift
and the right mouse button simultaneously while dragging up and down. As an exercise, try
to remove some of the molecular surface covering the ligand to create a picture similar to
this:
L02 – page 13
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
Note: we have seen previously that the top menu “Mouse” contains all the possible options,
with a reminder displayed at the bottom right of the “Internal GUI.” The method to adjust the
clipping plane will depend on the number of buttons on your mouse. Use the “Mouse” menu to
adapt your display to your mouse.
4) Labels
A label containing the residue type and sequence number (e.g. TYR 322) can be added to a
selected residue with the menu cascade (sele) > L > residues
For publications or slide making, labels could be added with e.g. Adobe (PhotoShop,
Illustrator) or Microsoft (PowerPoint) graphic editing software.
At this point you can explore the L menu, knowing that “clear” will remove the mess that may
occur!
A session file is a binary file containing all the information and graphical displays currently
within PyMol. It is a way to save the “current state”of the software with all that it contains.
Later, the file can be opened and everything is restored.
While it is possible to simply double click on the MySession.pse icon, this could create
problems if there are multiple copies of PyMol within your computer and even more so if they
are various versions of the software. It is therefore best to first open the PyMol software copy
you want to utilize.
For this exercise: double click on the Applications > Classes > MacPyMol software to open
it.
Within the PyMol top menu follow the menu cascade: File > Open…..
and then select Mysession.pse from the Desktop.
All the PyMol names and selected items are restored as if you had just made them, even if
days have passed since you saved the file. How convenient!
Note: the file has a binary format. There is no information within the file that is useful for any other purpose. The
file for this exercise should likely be slightly less than 1Mb in size.
=========================================
There are various ways to animate and create movies within PyMol. This short exercise is
meant as a simple option to both create a rotation within the PyMol Viewer, and a simple
option for generating a movie suitable for PowerPoint.
At this point you should have the simple pocket surface with the carotenoid shown as stick as
in the previous exercise.
The command mset defines a movie. Since our current level of visualization only contains
one PDB file, the value of mset will be 1. The command mdo defines an action, here this
action will consist of a rotation about the Y axis.
The purpose of this set of command is to create a perpetual rotation within the Viewer around
the Y axis with an increment of 5 degrees.
Within the top PyMOL> command line, type the following commands:
mset 1
mdo 1: turn y,5;
Once the commands have been typed, the “vcr” buttons at
the bottom right of the “Internal GUI” become active. We
only need to use the Play (triangle) and Stop (square)
buttons to activate the animation. |Stop|Play
L02 – page 15
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
Note: the mdo command is followed by a colon (:). However in previous versions of PyMol it
was followed by a comma (,). The ending semi-colon (;) is necessary only if other commands
are required. For example, a rotation both within the Y and X axes of 5 degrees each would
be written as: mdo 1: turn y,5; turn x,5;
The purpose of this short exercise is the creation of a single movie file suitable to be played
independently or imported within PowerPoint.
The creation of movies within PyMol is different depending on the version and on the operating
system. The MacPyMol version of PyMol contains a built-in function to tap within the
QuickTimePRO engine (even if you do not have the PRO license) and can be used to create
movie files. On other systems, the movie is saved as a series of images (in PNG format) which
then need to be assembled manually with e.g. QuickTimePRO, Adobe Premiere or similar
movie making software, meant to compile a series of images (frames) into a single file movie.
This aspect of movie making as well as the indiosyncracies of PowerPoint and movie
compatibility were reviewed in a previous lab or module.
Since we were using some movie/animation features above, the first command to use is
mclear to remove functions and frames that might have been saved.
Modification of the command mset: since we are going to save the file into a QuickTime
movie, we need to define how many frames the movie will contain. For example, to have 36
frames the command will be written as mset 1 x36
Modification of the mdo command: for each frame we need to specify that we want a rotation
around the (e.g.) Y axis of (e.g) 5 degrees. However this would require to declare each of the
(e.g.) 36 frames and for each frame declare the action we want to take (for example a
rotation). Within PyMol the undocumented command util.mroll(start, finish,
loop-flag) does all of this if we have declared the number of frames with mset. A complete
360 degrees rotation is assumed.
Within the top PyMOL> command line, type the following commands:
mclear
mset 1 x36
util.mroll(1,36,1)
L02 – page 16
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
(Note: this menu available for native Mac version only, usually called
MacPyMol)
The ray tracing option is also available when making movies. The movie making is almost
identical as the previous section, but each image is ray-traced before it is saved. The movie
can then be saved as a series of images or as a movie file from the File menu.
L02 – page 17
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
To create a ray-traced movie type the following commands within the top PyMOL>
command line:
viewport 320,240
set ray_trace_frames=1
set cache_frames=0
mclear
mset 1 x36
util.mroll(1,36,1)
a. if you want to save the individual images use the following command:
b. If you want to save the movie with QuickTime follow the same procedure as
above.
Note however that the progression bar ( ) will remain active, indicating
that the ray-traced images are still available for other commands (for example the mpng save
command above).
Note: ray-tracing is computationally intensive. The bigger the images (viewport size) the longer
it takes. You can see which frame is being rendered by looking at the bottom right of the
“Internal GUI.”
=========================================
GUI interfaces are nice, but they are slow and cumbersome. Like Rasmol, PyMol also has a
line-command interface that we have already used to type specific commands. These
commands are simply lines of text, and therefore can be placed sequentially within a plain text
file called a script. When the script is invoked from the PyMol line command, the commands on
each line of the script are executed, and the final image is shown within the Viewer.
Note: The Py in PyMol refers to Python, a graphical scripting language, and PyMol can be used as a
PyMol algorithm interpreter. However, this is beyond the scope of these exercises. It is useful to know
this, as you might encounter Python scripts for PyMol. The following exercises are restricted to PyMol-
only commands.
On the hard drive, information is arranged in files and folders, and each operating system has
its own way of organizing and calling on files. As a reminder, files contain information such as
lines of text or binary numbers making up an image or a software algorithm, and are organized
throughout the hard drive within directories, also called folders. When you want to invoke a
L02 – page 18
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
script, PyMol needs to know where it is! There are two fundamentals ways to make sure PyMol
knows where the script you want to use is located:
a. Give the full path to the script such as
/Users/BNMC/Desktop/PyMol/myfirstscript.pml on a Mac OSX or
Unix/Linux system, or perhaps something like
D:\Data\My Datafiles\PMscripts\myfirstscript.pml for Windows.
These long lines give the absolute path to the location of the script, and must be
present at each invocation.
b. Set the default working directory to where scripts (and PDB files) are located. We
did something very similar when we gave the command cd desktop in exercise
B, so that PyMol would automatically look onto the desktop for the necessary
file(s). In some respect this is easier because once the path has been set with
the cd command, the path does not have to be repeated again each time we
want to run this or another script at the same location.
You should be (or become) familiar to the ways directories and paths are dealt with on your computer,
which are essentially the Unix/Linux/OS X family or the Windows operating systems.
This is rather simple but better repeated here for sake of clarity.
A file containing text that is bold, underlined, or italicized it NOT a plain text file (note: there
are exceptions to this rule in Macintosh world not covered here).
a. contains ONLY printable characters that can be typed from the simplest of
keyboards (ASCII characters): letters, numbers and symbols such as !, @, and $.
b. is not specific to any particular word processor format and is displayed with the
default font within any word processor (some will choose courier by default for
this)
c. contains a “line break” or “end-of-line” code (specific to the operating system) that
signifies that the line has terminated “here” and that a new line will begin “next.”
Options to create text-only files:
c. Mac OS X:
i. The included Applications > TextEdit can be used
only after the proper menu has been called:
Format > Make Plain Text
L02 – page 19
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
d. General Unix/Linux/MacOSX
Any file created with vi, pico, xedit, or a redirect command such as
cat > is created as a plain text files.
A “hard-return” is coded within the text file. A “soft-return” is the apparent wrapping of a
long text file to the next line, but in fact is a very long, single line. When saving from
MSWord, one of the options is to save the file with Line Breaks that will in fact transform
the soft- into hard-returns. For scripts this is not a good idea.
If you import a file from another system or the web, it may be a good idea to verify it’s end-of-
line / hard-return status if it does not work as expected or not at all within PyMol.
4) If PyMol is running, Quit PyMol and restart it again, to have a fresh start. If you are
starting here to learn about scripts, review how to find and start PyMol in exercise B.
5) Use TextEdit (as detailed above) or BBEdit to create a new script that we shall call
abc.pml. Save abc.pml on the desktop.
Within abc.pml file type the following lines (comment lines which start with #. You can
omit typing anything after the comment sign # for these exercises. However, placing
comments within your script is a good practice for your future reference or for those with
whom you share your scripts with, and can save hours of frustrations!)
color red, ss h
color cyan, ss s
color yellow, not ss h and not ss s
Note the use of the comma (,) after the name of the color.
ss signifies secondary structure
h signifies helix. (Note that the word “helix” would not be recognized.)
s signifies sheet. (Note that the word “sheet” would not be recognized.)
not h and not s are be the loops or turns.
6) In your new PyMol session, set the default directory by typing the cd Desktop
command within the top line command. Then verify that the path is correct with the
command pwd (present working directory):
cd Desktop
pwd
Activating the script will create the image as you could have done it by either typing each of the
script commands within the line command, or by using some of the mouse options as we have
done before. The advantage of scripts is that they are an easy way to create images in a
reproducible fashion, but most importantly, it can be an easy way to remember how the images
were created.
This image was created with the default orientation that the molecule takes when it is opened.
But very often, one important aspect of an image is the orientation of the molecule. PyMol
offers a very nice way to return to an existing orientation and build it within a script: the “Get
View” button, located at the top right of the “External GUI.”
L02 – page 21
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
The PDB file will not be reloaded since we commented out the line with the load command (#).
The formatting and coloring of the protein will occur unnoticed since they are already in the
cartoon state colored by our chosen secondary structure colors. But the orientation of the
molecule will be restored.
The PyMol way: this is a nice way to work with PyMol. Simply create and modify a script as you
go, commenting out the loading of the PDB file(s) after the first run. It is a preferred way of working
with PyMol that leaves the legacy of a finished script with complex commands. Therefore you can
create your own repository of complex scripts, as a way to safeguard these commands for future
use and reference. In addition, you can run the script again and again as you build it, line by line.
=========================================
Understanding the content of this exercise can be beneficial to your PyMol skills!
The PyMol “select” command has the special property to create atom selections with names
appearing within the Names Panel. This is a nice feature, but some confusion can arise
depending on the words that are used. For example, in the abc.pml script we have just used
the command “color red, ss h” to colors red only the secondary structures (ss) that are
in helix (h) form. However the command “color red, ss helix” would not at this time
have any effect, and PyMol might give us an error message. The reason is that “helix” has no
meaning at this point. Interestingly this command CAN work if “helix” is defined first. “helix” can
be defined when an atom selection is created with the “select” command. Any subsequent
command can then contain the chosen word, and the commands will only apply to that atom
L02 – page 22
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
selection, which can be a subset of a larger selection. When switching from Rasmol this can
be confusing, as the command “select helix” is a valid command on the Rasmol command line.
First let’s assume that you just ran the abc.pml script above on a fresh start of PyMol. If not, simply quit and
restart PyMol, then in the line-command area type cd desktop, press return and then type @abc.pml to be in
the same state as if you just had done the previous exercise. In the script the helices are made red. Here we will
make them green.
Within the line command type: Two things will happen: a new name “(helix)” will appear
within the Names Panel, and all the atoms participating in a
select helix, ss h helix structure will be selected within the Viewer (pink
squares):
Within the line command type: Note: this time it worked and the helices were colored green.
color green, helix
Important lesson: the word “helix” here could have been any
other word such as “MyHelixSelection.” Using a “My” prefix
before some of the selections might help avoid confusing
words that are commands and words that are the names of
created selections. This can be important when writing or
deciphering other people’s scripts! …any word can do…
Reminder: PDB (and other) 3D coordinate files are structured with certain fields arranged in columns. PyMol
can detect and interpret some of these fields. For example, in the ATOM records, the “atom name column” or
“atom name field” is the column where the atoms are given a name, such as C, CA, CB, CG, or CD for example,
corresponding to the asymmetric carbon, the alpha-, beta-, gamma- and delta- carbons of an amino acid
respectively. Similarly, there will be columns with the name of amino acids, and clearly more than one line of
ATOM records make up for all the atoms of one amino acid. Finally, a chain and sequence number are also in
column.
L02 – page 23
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
In summary, here are the most relevant selectors for working with macromolecules (proteins
and nucleic acids)
(Each definition below is followed by an example. Remember: as above, the word after the
word “select” is of your own creation. Adding “My” to the word may be a good reminder of that.)
residue-identifier-list
list of up to 4-digit residue numbers
PyMol> select Myresidues , resi 1+2+20+8590
resi
Residue-identifier-range
PyMol> select MyNterm , resi 1-25
chain-identifier-list
chain list of single letter (rarely numbers) of the chain
PyMol> select MyChain , chain a
Secondary-structure-type
ss list of single letters
PyMol> select Myalphas , ss h+s+l+””
Lets make a last script to wrap it up. Create a script file called abc2.pml with BBEdit or other
means, and save it on the desktop.
Within abc2.pml type the following script. At this point you can omit typing the commented (#)
lines, but remember that placing comments within your scripts (annotation) can save (lots of)
time and remove headaches in the future…
L02 – page 24
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
Writing a script may seem tedious at first, but once it’s written it can be saved, rerun,
upgraded, placed on the web, and exchanged with other people.
Learning by example: this is what we have done so far, at a slow pace. However there are
many web sites that offer PyMol help and scripts, often annotated with the # comments to
explain what is inside. Studying other’s scripts is a way to learn some fancy options. Here are
a few web sites to study at your own pace:
L02 – page 26
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
End of PyMol tutorial. Close or Quit all programs before leaving the classroom.
=========================================
PyMol Q&A
(does not have to be completed in class)
The Display > Quality menu cascade allows you to adapt to the Display
speed of you machine CPU depending on the quality of the image
displayed in the Viewer. This option MAY affect the result of ray-
traced images.
2) Labels are created the same color as the atom. How can I change only the label color without changing
the display of the atom or molecule?
You can change the label color with the following line command: set label_color, yellow, sele
• Yellow can be changed for other colors (can be chosen from the names within the C menu)
• Sele can be either the current selection, or can be switched the the name of the object you are working on.
• note the use of the comma (,) within the line command
The current selection (sele) as well as other subsets (e.g. (MyHelix)) are shown within parentheses and represent
subsets of the current PDB file we are working on (e.g. 2BIW2.pdb2). Any selection can be copied into an
independent object with the “A” Actions: create object menu cascade. This will create a new entry within the
“Names Panel” without the parentheses that becomes independent of the original PDB file.
Surfaces are reserved for ATOM records only. Typically ligands are always HETATM records (but authors of the
PDB file may choose otherwise, hence always check within the file with a word processor.)
One way to circumvent this is to make the ligand into an independent object (see question above about creating
object), save it from PyMol into a text file, replace the ATOM word with HETATM and reopen the file with PyMol:
Assuming you have created obj01 as described above, use the menu cascade
File > Save Molecule….
Choose a file name and save the file e.g. obj01.pdb. The file will be a PDB file
with only the object 3D data and contains HETATM and CONECT records.
Using a word processor open the PDB file and change replace “HETATM” with “ATOM “ (ATOM with 2 blank
space to respect the column positions!!!!!)
Delete the current obj01 with the menu cascade: Names Panel: obj01 > A >
delete object
Open the PDB file obj01.pdb with PyMol (menu cascade File> Open or use the
“load” line command)
A new obj01 now appears within the Names Panel, and the S > surface menu is
now working for this object!
ray-traced example
5) How can I turn off the automatic zooming and clipping when I make a new object?
When we created object obj01 from (sele) above (see question about creating
objects), the default action of PyMol was to automatically zoom to the new object
(in that case the ligand) and reduce the clipping planes. That can be annoying in
some cases, but could always be reversed with the line command “reset” or with
the menu Display > Clip > None or with the Display > Zoom menu options.
To turn off this option is turned off by un-checking the menu item:
Setting > Auto-Zoom New Objects
PyMol will have no problem aligning 2 similar structures. PyMol firsts creates a sequence alignment the then tries
to align the structures accordingly. If 2 proteins are named struct1 and struct2 within the Names Panel, the simple
line command will align them: align struct1, struct2 (note the use of the comma after struct1)
For more complex alignment questions, see the following web site:
http://adelie.biochem.queensu.ca/~rlc/work/teaching/BCHM823/pymol/alignment/
L02 – page 28
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
Some on-line web content can be called from the Help menu in PyMol.
PyMol also offers an internal summary of all the command derived from the manual. These are called from the
line command help xxx where xxx is the name of the command, e.g. help align or help color.
8) I have an NMR file called 1NYZ with 20 structures… How can I see or work on a specific state?
If you open the PDB file with a word processor, you can see that each structural state starts with the MODEL
keyword and is separated from the next with the ENDMDL keyword. PyMol will read all molecule states, in this
example 20. This is also echoed within the text panel:
e.g. ObjectMolReadPDBStr: read MODEL 17
All commands are echoed on the Text panel together with any additional text
triggered by the command. While it is possible to use Copy/Paste from this panel, it
is much more convenient to have a separate file logging all the typed commands
only. Furthermore, this log file is de facto a script!
The logging can start after the File > Log… command is requested and a file name
is given, e.g. test.log. The file can be saved anywhere on the hard drive, for
example the desktop. The menus allow to close the current log, resume logging or
append to any previously created plain text file.
cd desktop
You can try to create a log file while typing the commands on the right hand side load 2BIW.pdb2
select hetatm
on the PyMol line command.
show stick
hide stick
You can then quit and re-open PyMol and run this test.log file with the following show stick, sele
command: cd desktop; @test.log color yellow, sele
Note: if you want to run it from the File > Run… menu, you may need to rename the file with a .pml file extention
e.g. test.log.pml otherwise the file cannot be opened.
Practical note: previously typed command on the line-command can be recalled by using the “up-arrow” key.
L02 – page 29
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
10) When I make a cartoon helix, part of the helix color bleeds on to the turns, how can I fix that?
Turning the variable cartoon_discrete_colors on makes the helix color ends abruptly at the end of the helix. The
default value is off. The change can be done manully with the menu cascade Setting > Edit All… or can be given
as a typed command: set cartoon_discrete_colors = on (space on either side of the = sign is optional)
Setting
Edit All…
11) I want to build a model helix from a sequence, how can I do that?
PyMol offers modeling options for small molecules and proteins. For example you can build an alpha helix from
scratch with a specific sequence. The “builder” interface to accomplish this is different depending on the operating
system. On Windows and X11 versions of PyMol, the “External GUI” has an extra set of buttons to build by
clicking on the various components to be assembled such as amino acids. The MacPyMol version has the same
capability but instead of clicking icons menu items are chosen.
continued…>
L02 – page 30
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
a. (Windows: click on “Builder” button at right and then on “Protein button at left.)
b. Choose the helix form (bottom of menu Build>Residue. (Windows: click on “Next”)
c. Select the sequence you want to build from the Build (Windows: clicking residue name)
d. The model will be built withint the Viewer.
e. Save the molecule with the File > Save Molecule menu. The name of the molecule will be the
name of the first amino acid used e.g. ala.pdb
The menu cascade Wizard > Mutagenesis opens a new panel below the Names Panel and above the mouse
control reminder. Directions will be prompted with text overlaid on the Viewer:
“Pick a residue” and “Select a conformational state, or pick a new residue…”
13) I’d like to try various way of orienting, drawing and coloring a structure. How can I compare them?
While PyMol cannot show all the versions at the same time, the Scene menu has very nice feature to save the
structure in various states of representations and toggle between them. The transition from one scene to the next
creates also a beautiful screen animation.
a. Create a first version of a representation: show as cartoon (S > cartoon) and color by secondary
structure (C > by ss > pick-a-color-scheme). Now orient the molecule with the mouse in a way
you like.
b. Store this view in the F1 keyboard key with the menu cascade Scene > Store > F1
c. Create a second presentation for example change the cartoon color (C > spectrum) and rotate
the molecule in a different orientation. For a more stunning effect you can zoom in.
d. Store this new view into the F2 key: Scene > Store > F2
e. Now you can recall the previous scene with the menu cascade Scene > Recall > F1 and you
should witness a beautiful animation and color change while the scene is changing.
There are 2 ways to accomplish this task: with the mouse or with line command.
Mouse method:
L02 – page 31
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
c. Apply the proper mouse/keystroke combination for rotation, translation, or moving along Z
(toward or away from you)
Provided the PDB file 1FJ1.pdb (http://www.rcsb.org) is available, this script called split.pml can be run from the
line command with @split.pml or called from the File>Run… menu cascade IF the filename extension is .pml.
The most accurate potential maps can be calculated by external software (Grasp, Delphi, APBS, MEAD) and
displayed in PyMol. Search the web or the Pymol usergroup archive for details on using external software to
create a map http://sourceforge.net/mailarchive/forum.php?forum_id=60 or see this posting
from PyMol author: http://imsb.au.dk/pipermail/o-info/2004-December/007601.htm
L02 – page 32
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
2BIW.pdb2 > A > generate > vacuum electrostatics > protein contact potential (local)
The process creates 3 new entries within the
Names Panel: 2BIW.pdb2_e_chg,
2BIW.pdb2_e_map, and 2BIW.pdb2_e_pot
(2BIW.pdb2 is subsequently abbreviated X
below.)
If two proteins are present, the process has to be applied to each individual protein, and the same _e_ objects are
created for each one. The values within the X_e_pot color ramp may be different for each protein. Therefore it is
useful to know how to change the value within. Smaller numbers will increase the blue and red strength and
contrast within the blend of white surface, while larger numbers will dim the colors. To change the color range
within the ramp: (example): ramp_new 2BIW.pdb2_e_pot , 2BIW.pdb2_e_map, [-100,0,100]
The default colors are red/white/blue, hence the above command could also be rewritten to change ramp values
and specify colors:
where [ [1,0,0], [1,1,1] , [0,0,1] ] represents the [R, G, B] (red/green/blue channels) values for each of the 3
displayed colors. To change the displayed color, simply change the definition of the colors. For example, the
values [ [1,1,0], [1,1,1] , [0,1,1] ] would create a ramp as yellow/white/cyan.
Note: an alphabetical list of all PyMol-defined color names can be found under the top menu “Setting > Colors…”
Within that window the colors can also be edited.
The C menu within the Names Panel offers a list of color names grouped by tint and can serve as a preview.
c. Default display:
Note that when the calculation first takes place, the surface is shown but the original PDB file is hidden. In the
case of 2BIW it means that the carotenoïd becomes invisible. To restore it, simply click on button 2BIW.pdb2
within the Names Panel: this will restore the display of the protein and ligand as lines or sticks. Since the protein
is under the surface it will remain invisible (but some odd side chains might stick out of the surfaces.) To make
more complex images it may be useful to create a new object containing the ligand alone (see questions above:
How can I make a new object? and Why can’t I make a surface for the ligand itself?)
L02 – page 33
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
helix-1 > A > find > polar contacts > within selection
A new objects 2BIW.pdb2_polar_conts will be created. The yellow default color for the dashed line is easily
changed with the C menu for this object. For example a darker color can be chosen for display against a white
background.
Note: choosing to other atoms in object would show additional hydrogen bonds of the helix side-chains to other
parts of the protein.
Note: for more complex issues regarding hydrogen bonds or adding hydrogen atoms refer to the web link above.
=========================================
L02 – page 34
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
For a rotation within PyMol it’s easy, and the command is:
I agree with you that the PyMol movie making is not as straight forward as it sounds for more
elaborate movies.
First, we shall assume that you are using a PDB file with one "state." In other words you are
not using an NMR file that contains multiple structures (refer to the addendum I gave in class
if that confuses you, relative to NMR file 1NYZ.pdb.)
For movies in PyMol, the first thing to understand is that you have to specify the number of
frames at the begining of the movie commands. THis is done with mset, but mset is defined
in different ways depending on what you are doing. Assuming you are using a one state PDB
file, you need to state how many frames the movie is going to be:
you can review more mset options on the following link, but I think that you should not need
any of the other options for your rotations.
http://pymol.sourceforge.net/newman/user/S0300movies.html
After some research on the net here are some solutions I have found to your question about
rotating about the 3 axes at the same time. The answers were not as easy to find and I am
not sure if they completely answser what you want.
1) the easiest:
===========
In some way I assume that you want to make a "nice" rotation that is not as boring as the
simple Y rotation. In this case the command movie.nutate would be helpful and most likely
what you are looking for. With a small angle it resembles the default movement "lemniscate"
in VMD movie maker. Here is an example: (# is the comment symbol and everything is ignore
by PyMol after it.)
Of course the movie looks better with more frames and more angles:
L02 – page 35
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
mclear
mset 1 x360
movie.nutate 1,360,360
movie.nutate belongs to the built-in PyMol Python script movie.py and has more options
as I have found at the following site:
http://www.koders.com/python/fid54F75215FAB3B81AE8E0824786C2FD828C60845C.aspx
def nutate(first,last,angle=30,phase=0,loop=1,shift=math.pi/2.0,factor=0.01)
so you can see that the first number is the first frame that will be affected. You could decide to
start moving only after frame 10 for example. The second number is the last frame that is
going to be moving with the rotations. The third number is the rotation desired. If you use e.g.
20 instead of 360 you will have the "Leminscate" effect seen in VMD. The next numbers can
be played with to test their effect(s) but are not mandatory to the command.
NOTE: the use of movie.nutate was suggested to a similar question by a user to the
PyMol author Warren Delano. See:
http://sourceforge.net/mailarchive/message.php?msg_id=2078718
2) Using cmd.mdo
==============
This one is inspired from the following answer on the sourceforge archive:
http://sourceforge.net/mailarchive/message.php?msg_id=9881931
mclear
mset 1 x360
for a in range(1,360): cmd.mdo(a,"rotate x,5;rotate y,5;rotate z,5")
You will note that the rotation is not as smooth as the movie.nutate option, even with a
rotation of 1 rather than 5.
!mset 1 x360
!movie.roll 1,180,1,axis=y
!movie.roll 181,360,1,axis=x
Frames 1 to 180 are for Y rotation and frames 181 to 360 are for X rotation. You could
decompose the frames in such a way to add a Z rotation as well:
!mset 1 x360
!movie.roll 1,120,1,axis=y
!movie.roll 121,240,1,axis=x
!movie.roll 241,360,1,axis=z
L02 – page 36
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
However there is another command that can do all that in one line: movie.tdroll:
AUTHOR
Byron DeLaBarre
USAGE
movie.tdroll(rangx,rangey,rangez,skip=1,mset=0)
rangex/y/z = rotation range on respective axis
enter 0 for no rotation.
skip is angle increment in each frame
Use skip to reduce final movie size or to speed up rotation. EXAMPLE
movie.tdroll 360,360,360,5
as shown on link:
http://sourceforge.net/mailarchive/message.php?msg_id=1534644
movie.tdroll ("Three-Dimensional roll") will allow you to use make a quick movie
of rotation along multiple axes of whatever is showing on the pymol screen. You
can speed it up or slow it down by changing the "skip" value. Play with setting
different axes to 0 until you achieve what you want. I like movie.tdroll
180,180,0,5 for a cool display of the molecule.
If you are on a Mac, the menu File > Save Movie > As QuickTime should work with all the
examples above.
If you are on a PC the files will be saved as single PNG files that need to be assembled, e.g.
with QuickTimePro on a PC.
You can also export the individual frames with the line-command mpng NAME which would
save frames NAME0001.png, NAME0002.png etc until the last frame.
I hope this will get you to what you wanted to do....As you can see, a simple question can
lead to a very long answer....
Jean-Yves
P.S. I almost forgot.... There is a separate Python module that can be downloaded and then
invoked within PyMol. This module is not part of PyMol and needs to be downloaded, and
then activated within PyMol before the new commands are available
However the download link is not working, but I found the following link that contains the
Python script, but it is INCLUDED within the following archive at the bottom of the archive.
http://sourceforge.net/mailarchive/message.php?msg_id=4272454
The assumed name of the script is movie.py, however it is a different movie.py python script
than the one I mentioned above in the movie.nutate paragraph.
L02 – page 37
BIOCHEMISTRY 660 / 712 – FALL 2006 J.Y. SGRO
This link also contains an example script on the usage of this. THe command "run movie.py"
activates the script which is simply kept in a text file.
NOTE: movie.py is not part of the standard PyMol installation, and any script making use of
movie.py commands would only work movie.py is available on the PyMol that is running.
=========================================
L02 – page 38