Pymol tutorial writeup

Basic notes and tutorials
This set of notes and tutorials are a collection of material from
Warren DeLano, DeLano Scientific
Gareth Stockwell, European Bioinformatics institute
Arvind Varsani, University of Cape Town
14th June 2004
PyMOL: Basic notes and tutorials
Contents
1
Introduction ________________________________________________________________3
1.1
Obtaining Pymol _________________________________________________________3
1.1.1
1.1.2
Macintosh OS X _______________________________________________4
1.1.3
Linux __________________________________________________________4
1.1.4
IRIX and Solaris______________________________________________________5
1.1.5
Other Unix __________________________________________________________5
1.2
2
Capabilities______________________________________________________________6
The Basics __________________________________________________________________8
2.1
The PyMol GUI __________________________________________________________8
2.2
Manipulating the View____________________________________________________10
2.2.1
Basic Mouse Control _________________________________________________10
2.2.2
Moving Clipping Planes_______________________________________________10
2.2.3
Changing the Origin of Rotation ________________________________________11
2.2.4
Getting Comfortable__________________________________________________11
2.3
3
Microsoft Windows3
PyMOL command language________________________________________________12
2.3.1
Filename Completion using TAB _______________________________________12
2.3.2
Reading / loading coordinate files _______________________________________13
2.3.3
Selection ___________________________________________________________16
2.3.4
Settings ____________________________________________________________21
2.3.5
Ray tracing and images _______________________________________________22
2.3.6
Online help _________________________________________________________22
2.3.7
Scripts and log files __________________________________________________25
2.3.8
Hydrogen bonds _____________________________________________________26
2.3.9
Density Maps _______________________________________________________27
2.3.10
Movies ____________________________________________________________28
Appendix I_________________________________________________________________30
2
PyMOL: Basic notes and tutorials
1 Introduction
PyMOL was launched to create a viable alternative to high-priced commericial visualization
software. Although many molecular viewers exist today, nearly all place some restriction on how,
when, and where you can use them. PyMOL isn't like that -- it is designed to be as unrestrictive and
useful as possible. Furthermore, because much of PyMOL is Open-Source, you can modify and
extend the program to better meet your needs. PYMOL molecular graphics package is written by
Warren DeLano.
In combination with other software, PyMOL (via Python) has the potential to evolve into a complete
platform for crystallography, computational chemistry, modelling, and informatics. This will occur
by folding in additional capabilities such as model building, energy minimization, conformational
searching, simulation, and analysis.
With the advent of the Internet, there is no reason why we scientists should continue to be as
dependent on high-priced commercial providers for our research software as we are today. Working
together, we can build alternatives like PyMOL which are cost-effective, flexible, and able to meet
our needs in a way no traditional commercial system could do.
1.1
OBTAINING PYMOL
It is available from www.pymol.org , with simple-to-install versions available for Windows, Mac,
SGI and Linux platforms. Since the source code is available, it can in principle be run on any Unix
system, as long as the OpenGL graphics library is installed.
April 3, 2004: PyMOL 0.95 has been released for all platforms. An official 0.95 release of the
MacPyMOL Incentive Product for OS X is also available for download. New features include:
1.1.1
Microsoft Windows
Standalone PyMOL binaries for Windows provide the easiest (one-step) installation.
Download and unzip pymol-0_95-bin-win32.zip (http://prdownloads.sourceforge.net/pymol/)
Install PyMOL by clicking on "Setup.exe".
PyMOL can now be launched from the Start Menu.
If you already have Python installed and wish to use PyMOL with that external interpreter, then
download and install the appropriate python-dependent binary instead:
pymol-0_95-bin-win32-py21.zip
pymol-0_95-bin-win32-py22.zip
pymol-0_95-bin-win32-py23.zip
3
PyMOL: Basic notes and tutorials
1.1.2
Macintosh OS X
1.1.2.1 MacPyMOL Incentive Product
MacPyMOL is a platform-specific enhancement of PyMOL for Mac OS X that includes extra
features such as an Aqua port of the user interface, direct copy-and-paste of images, and automatic
QuickTime movie export. It runs on Jaguar (10.2) and Panther (10.3).
Since MacPyMOL is an incentive product, PyMOL sponsorship via a current PyMOL subscription
is required for research use of MacPyMOL, but you are welcome to try a free 90-day evaluation.
Also note that subscriptions are optional for full-time students, for teaching, or when just viewing
public or published data.
1.1.2.2 Mac OS X/X11 Hybrid Version
This free (sponsorship optional) version of PyMOL provides the cross-platform Tcl/Tk via X11,
which means that you need Mac OS X 10.3 (Panther) with X11 installed in order to use it.
1. Download pymol-0_95-bin-osx-x11-hybrid.dmg.gz
(http://prdownloads.sourceforge.net/pymol/)
2. Double-click on the downloaded file to extract and open the disk image. If the ".dmg" file
does not open after downloading, try restoring the ".gz" extension after the ".dmg" and
double-click again.
3. Copy the PyMOLX11Hybrid application on the disk image to the "Applications" folder on
the System Disk.
4. Double-click /Applications/Utilities/X11 to launch X11 first.
5. Then double-click /Applications/PyMOLX11Hybrid to launch PyMOL.
1.1.2.3 Fink Version
The Fink version of PyMOL is another way to get PyMOL running on your Mac.
1.1.3
Linux
1.1.3.1 Dependency-Free Binary Version
This easiest-to-install and most compatible version of PyMOL for Linux.
1. Download pymol-0_95-bin-linux-libc6-i386.tgz
(http://prdownloads.sourceforge.net/pymol/)
2. Extract the archive
tar -zxvf pymol-0_93-bin-linux-libc6-i386.tgz
to create a "pymol" directory
3. Run the setup script
cd pymol
./setup.sh
4. Launch it
./pymol.com
4
PyMOL: Basic notes and tutorials
1.1.3.2 RedHat RPM Packages (Requires "root" Access)
1. Down the version appropriate for your system (http://prdownloads.sourceforge.net/pymol/):
2. pymol-0.95-1.rh62.py152.i386.rpm
pymol-0.95-1.rh70.py152.i386.rpm
pymol-0.95-1.rh72.py21.i386.rpm
pymol-0.95-1.rh73.py22.i386.rpm
pymol-0.95-1.rh80.py22.i386.rpm
pymol-0.95-1.rh90.py22.i386.rpm
3. Become root, and then issue
rpm -i pymol-0.95-1.rhXX.pyXX.i386.rpm
4. You can then launch PyMOL from /usr/bin/pymol.
1.1.4
IRIX and Solaris
1. Download the binary for your system (http://prdownloads.sourceforge.net/pymol/):
pymol-0_95-bin-irix65-r10k.tgz
pymol-0_95-bin-solaris8-sun4u.tgz
2. Extract the archive into a location of your choice
gunzip < pymol-0_95-bin-irix65r10k.tgz | tar -xvf to create a "pymol" directory
3. Run the setup script
cd pymol
./setup.sh
4. Now try it
./pymol.com
NOTE: PyMOL on IRIX 6.5.18-6.5.21 requires patch 5316, which can be obtained from SGI.
1.1.5
Other Unix
1. Download the source: pymol-0_95-src.tgz. (http://prdownloads.sourceforge.net/pymol/)
2. Either configure PyMOL to use your existing external dependencies, or download and
compile from sources:
ext-0_95-src.tgz includes:
Python-2.3.3
Numeric-22.0
Pmw-1.2
glut-3.7.6
tcl-8.4.6
tk-8.4.6
libpng-1.2.5
zlib-1.2.1
3. Compile pymol (see INSTALL file for details).
5
PyMOL: Basic notes and tutorials
1.2
CAPABILITIES
1) Optimized real-time 3D structure visualization.
2) Eight different molecular representations (lines, sticks, dots, mesh, spheres, ribbons,
cartoons, and surfaces)
3) Input of standard PDB, Macromodel, SDF, & MOL format files, as well as "pickled"
Chemical Python (ChemPy) objects.
4) Input of X-PLOR and CCP4 map files and generation of electron density isosurface meshes.
5) Merging and splitting of molecules using atom selections (much easier than editing files by
hand!).
6) Output of PDB and Macromodel files as well as pickled ChemPy models.
7) Support for real-time manipulation and rendering of Molscript cartoon ribbons (supplement
to above).
8) Support for distance measurement and arbitrary labels.
9) Front and back clipping planes, with optional depth cue/fogging.
10) Mouse driven manipulation of models and views.
11) A molecular editor enables click-and-drag changes to both conformation and chemical
structure.
12) Coarse interactive modelling using "molecular sculpting".
13) Crystallographic symmetry and display of unit cell box.
14) Automatic Python and command script generation via robust logging.
15) Transparent surfaces and spheres.
16) Point mutagenesis with rotamer library.
17) Optional POV-Ray integration and automatic script generation.
18) Display of "carved" electron density about an atom selection.
19) A built-in photorealistic ray tracer with anti-aliasing for Raster3D/PovRay-like quality.
20) Interactive command line with auto-completion, short-cuts, history, and inference logic.
21) A command language optimised for minimum keystrokes, but which maps into Python.
22) Molecular superposition (fitting) capabilities, with on-the-fly sequence alignment (v0.80).
23) Concise hierarchical atoms selections "A/142/", "B//", "*/CB", "ILE/"
24) An algebraic atom selection language based on X-PLOR syntax, but with significant
shortcuts.
25) Execution of arbitrary operations over atom selections (trivial or programmatic).
26) Stereo display on high-end silicon graphics workstations and on some PCs.
6
PyMOL: Basic notes and tutorials
27) A written manual and online help system.
28) A movie specification language enabling unattended batch movie generation of static and
dynamic movies.
29) Image input and output using libPNG ("png" format) -- use ImageMagick to convert to any
format.
30) Support for generic volume data, rendered using one or more solid (v0.80) or mesh
isosurfaces .
31) Hardware accelerated OpenGL rendering (on Windows, SGI, Alpha, and Linux -- soon on
Macs too!).
32) Batch mode for running jobs without a GUI.
33) Python support for two kinds of arbitrary graphics objects ("Compiled Graphics Objects" and
PyOpenGL).
34) Programmable OpenGL-based pop-up menus and OpenGL "developers" GUI.
35) Optional Tcl/Tk (Tkinter based) external GUI, also supports wxPython or your GUI of
choice.
36) An asychronous thread-safe Python programming interface (API) for extensiblity.
37) Modular, object-oriented design incorporating both Python and C components.
New features in version 0.95
38) Presets (in the Action menu) provide common views very quickly.
39) Context-specific pop-up menus now direct actions to where you point.
40) Mouse wheel can now control clipping slab width and position.
41) Improved look-and-feel, including bigger controls and longer names.
42) Appearance wizard facilitates color and representation control.
43) Labels can now be ray traced, with a few new fonts (label_font_id=0,1,2,3,4).
44) Two new surface types: dots (surface_type=1) & tri-mesh (surface_type=2) added.
45) Better handling of alpha-channel for semi-transparent figures.
46) Cartoons and spheres can now be "picked" using the mouse.
47) Roving origin behavior has been improved.
48) New cross-platform build for OS-X uses Tcl/Tk under X11 without Fink.
49) Molecular picking and editing is now more general.
50) Numerous features and tweaks have been added.
51) Various major and minor bugs have been fixed.
7
PyMOL: Basic notes and tutorials
2 The Basics
2.1
THE PYMOL GUI
Figure 1 shows the main parts of the PyMOL window. The object list shows which objects are
currently loaded; each object can be hidden by clicking on the bar containing its name. To the right
of each object name are four buttons which (see Figure 2 for details) produce drop-down menus
when clicked. The first allows you to perform basic actions on any one object (delete it, center the
view on it, etc). The second is the 'show' menu, which turns on various representations (cartoon,
wireframe, spacefill, etc). Conversely, the third menu is the 'hide' menu. The last controls the colour
of each object.
By default, PyMOL comes with a single external GUI window which provides a standard menu bar,
an output region, a command input field, and a series of buttons. One important advantage of the
external GUI window is that standard "cut and paste" functions for text will only work within
the External GUI, and not within in the PyMOL Viewer. Furthermore, you must use Ctrl-X, CtrlC, and Ctrl-V to cut, copy, and paste because a standard Edit menu has not yet been implemented.
PyMOL external GUI
window
GUI menus
Object list
Main PyMOL window
Mouse commands
Command line
Main canvas
Movie controls
FIGURE 1: Components of the PyMol external GUI and main windows
8
PyMOL: Basic notes and tutorials
FIGURE 2: GUI menus in the main PyMOL window
9
PyMOL: Basic notes and tutorials
2.2
MANIPULATING THE VIEW
In PyMOL, the mouse is the primary control device, and keyboard modifier keys (SHIFT, CTRL,
SHIFT+CTRL) are used in order to modulate button behavior. A three button mouse is required
for effective use of PyMOL, but common mice such as the Microsoft Intellimouse and Microsoft
Wheel Mouse will work just fine under Windows.
2.2.1
Basic Mouse Control
On mice with a scroll wheel, you can push down on the wheel in order to use it as a middle button.
Here is a table of the basic mouse button/keyboard combinations for view manipulation:
An abbreviated version of this table, the Mouse Matrix, is always displayed in the Internal GUI, in
order to help you remember which key and mouse button performs which action:
When using PyMOL on a laptop, it may be necessary to attach an external mouse or reassign the
particular mouse controls you plan to use onto the reduced set of buttons that you have available
internally (see reference on the "button" command).
2.2.2
Moving Clipping Planes
PyMOL's clipping plane control is somewhat unusual and may take a few minutes to get used to.
Instead of having separate controls for the front and back clipping planes, controls are combined into
a single mode where up down mouse motion moves the front (near) clipping plane and left right
mouse motion controls the back (far) clipping plane.
10
PyMOL: Basic notes and tutorials
The advantage of the PyMOL clipping plane control is that tedious tandem manipulations of the
clipping planes now becomes easy through the diagonal motions shown below.
You can also use the "clip" command to control the clipping planes.
2.2.3
Changing the Origin of Rotation
When visualizing molecules, it is frequently necessary to change the origin of rotation so that you
can inspect a particular region of the molecule. The fastest way to do this in PyMOL is to
Control Shift Middle Click on a visible atom in the scene.
2.2.4
Getting Comfortable
At this point, we recommend that you spend five or ten minutes getting comfortable with the
controls described in this chapter. Specifically, you should be able to accomplish the following
tasks:
1. Load a PDB file into PyMOL.
2. Rotate, translate, and zoom the camera.
3. Adjust the front and back clipping planes to clearly view a slice of the molecule.
4. Change the origin of rotation about any particular atom of interest.
11
PyMOL: Basic notes and tutorials
2.3
PYMOL COMMAND LANGUAGE
While some simple functions are available via the GUI menus, most interaction with PyMOL is via
a scripting language. This is superficially similar to that used in the RasMol viewer, but substantially
more complex. The basic form of a command is a keyword, followed optionally by one or more
comma-separated arguments. For example:
color red, hetatm
colours all non-protein atoms red. By contrast, the colour command can be used without the second
argument
color red
in which case all atoms are coloured red. In most cases, the first argument is specific to the
command being used (e.g. a filename for load/save, or a colour name for color), while the second, if
specified, is the name of the object or selection to which the command should be applied.
The most commonly used commands are listed in table 1; for a full list, see the PyMOL manual. For
simplicity, here not all optional arguments are listed, just the most commonly-used ones (shown
between square brackets). Again, the official documentation is the place to look.
Table 1: Common PyMOL commands
Command
Function
load
Read in a data file. The file type is (usually) autodetected.
save
Save coordinates to a file.
select
Pick out atoms/residues from an object or existing selection
delete
Delete an object
color
Set colour of an object
show
Turn on a particular representation type (e.g. cartoon, spacefill) for an object
hide
Turn off a particular representation
set
Alter a parameter (e.g. sphere size)
orient
Center the view on a selection or object
distance
Measure distance between two atoms, and draw a dashed line
2.3.1
Filename Completion using TAB
Some of the files you need to load into PyMOL may have long paths and filenames. PyMOL makes
it easier to load such files by automatically completing unambiguous paths and filenames when you
hit the TAB key. For instance,
EXAMPLE
load cry
# If "crystal.pdb" exists in the current directory,
12
PyMOL: Basic notes and tutorials
hitting TAB will generate
load cystal.pdb
If there is some ambiguity in the filename, PyMOL will complete the name up to the point of
ambiguity and then print out the matching files in the directory.
2.3.2
Reading / loading coordinate files
2.3.2.1 Using the External GUI Menu
The default external GUI provides a standard Open... item in the File menu which you can use to
select the file you wish to open. It is important that you go into the right directory where your pdb
files are located.
2.3.2.2 Using Commands
Example 1a
load <filename>
load data pen.pdb
The loaded coordinate file for Human paillomavirus capsid protein capsomer (pentamer) should
appear on your screen as shown in Figure 3
13
PyMOL: Basic notes and tutorials
FIGURE 3: Image on the main canvas after loading pen.pdb file
Using the pull down menu on the right hand side of the main PyMOL window (H and S)
hide everything
show cartoon
Or using syntax type the commands
hide everything
show cartoon
Then in the action pull down menu select the assign sec.
Secondary structure should be assigned to all the chains.
Then select by chain in the colour pull down menus next to pen. You should get an image like that
in Figure 4.
FIGURE 4: Cartoon representation of the HPV capsomer with assigned secondary structure and coloured by
chain.
14
PyMOL: Basic notes and tutorials
You can render the chain differently. Type
hide cartoon, chain a
show ribbon, chain a
set ribbon_width, 3
NOTE: The set command makes the ribbon more visible.
Similarly other representations can be used on the other chains
hide cartoon, chain b
show spheres, chain b
hide cartoon, chain c
show sticks, chain c
hide cartoon, chain d
show surface, chain d
The end result of the above rendering will be as shown in Figure 5.
FIGURE 5: Rendered representation of the HPV capsomer.
15
PyMOL: Basic notes and tutorials
2.3.3
Selection
2.3.3.1 Basic selection parameters/macros
Macros make it possible to represent a long atom selection phrase such as
select pept and segi lig and chain b and resi 142 and name ca
in a more compact form:
select /pept/lig/b/142/ca
An atom selection macro uses slashes to define fields corresponding to identifiers. The macro is
used to select atoms using the boolean "and," that is, the selected atoms must have all the matching
identifiers:
/object name/segi identifier/chain identifier/resi identifier/name identifier
These identifiers form a hierarchy from the object name at the top, down to the name identifier at
the bottom. PyMOL has to be able to recognize the macro as one word, so no spaces are allowed
within it.
Macros come in two flavors: those that begin with a slash and those that don't. The presence or
absence of a slash at the beginning of the macro determines how it is interpreted. If the macro begins
with a slash, PyMOL expects to find the fields starting from the top of the hierarchy: the first field
to the right of the slash is interpreted as an object name; the second field as an identifier to segi; the
third as an identifier to chain, and so on. It may take any of the following forms:
/object
/object
/object
/object
/object
name/segi
name/segi
name/segi
name/segi
name
identifier/chain identifier/resi identifier/name identifier
identifier/chain identifier/resi identifier
identifier/chain identifier
identifier
Examples
zoom /pept
show spheres, /pept/lig/
show cartoon, /pept/lig/a
color pink, /pept/lig/a/10
color yellow, /pept/lig/a/10/ca
If the macro does not begin with a slash, it is interpreted differently. In this case, PyMOL expects to
find the fields ending with the bottom of the hierarchy. Macros that don't start with a slash may take
the following forms:
resi identifier/name identifier
chain identifier/resi identifier/name identifier
segi identifier/chain identifier/resi identifier/name identifier
object name/segi identifier/chain identifier/resi identifier/name identifier
16
PyMOL: Basic notes and tutorials
Examples
zoom 10/cb
show spheres, a/10 12/ca
show cartoon, lig/b/6+8/c+o
color pink, pept/enz/c/3/n
You can also omit fields between slashes. Omitted fields will be interpreted as wildcards, as in the
following forms:
resi identifier/
resi identifier/name identifier
chain identifier//
object name//chain identifier
zoom 142/
show cartoon, a//
color pink, pept//b
# Residue 142 fills the viewer. show spheres, 156/ca
The alpha carbon of residue 156 is shown as a sphere
# Chain "A" is shown as a cartoon.
# Chain "B" in object "pept" is colored pink.
Selection macros must contain at least one forward slash in order to distinguish them from other
words in the selection language. Being words, they must not contain any spaces. When using
macros, it is also important to understand that they are converted into long form before being
submitted to the selection engine. This can help in the interpretation of error messages.
Examples 1b:
hide everything
bg_color white
show surface
color white
before working with the examples below
select ///A/428
# Select residue 428 in chain A
color orange, sel01
#colour residue 428 orange
or
color orange, ///A/428
#colour residue 428 orange
or
in the sel01 menu choose the orange color
#colour residue 428 orange
select ////261-280/CA
color blue, sel02
# Select atoms called CA in residues 261-280
(anychain)
colour CA in residues 261-280 (anychain)
blue
17
PyMOL: Basic notes and tutorials
or as above
select (430/C,N)
# Select atoms C and N in residue 430
color red, sel03
#colour atoms C and N in residue 430 red
FIGURE 6: Resulting image from example 1
Algebraic selections offer a bit more power, at the cost of slightly increased complexity. The idea
here is to use terms (such as 'chain A', 'resn ALA'), which are combined using standard logical
operators (AND, OR, NOT).
Example 2 (carried on with output from example 1):
select chain b
color cyan, sel04
select chain c and resi 428:465
# 'resi' specifies residue number
color yellow, sel05
select chain d
hide surface, sel06
color black, sel06
18
PyMOL: Basic notes and tutorials
select resn PRO and name N
# Select backbone nitrogens from proline
residues
color magenta, sel07
select elem O and not name OH
# Select all oxygen atoms except hydroxyls
color lime, sel08
FIGURE 7: Resulting image from example 2
The keywords (chain, resn, resi) may be substituted with shorthands; the following are equivalent to
the expressions above.
2.3.3.2 Selection with shorthands
Selections are enclosed in parentheses and contain predicates, logical operations, object names,
selection names and nested parenthesis: ( [ [( ) }] )
name <atom names>
resn <residue names>
resi <residue identifiers>
chain <chain ID>
segi <segment identifier>
elem <element symbol>
flag <number>
alt <code>
numeric_type <numeric type>
text_type <text type>
hydrogen
all
visible
n; <atom names>
r; <residue names>
i; <residue identifiers>
c; <chain ID>
s; <segment identifier>
e; <element symbol>
f; <number>
nt; <numeric type>
tt; <text type>
h;
*
v;
19
PyMOL: Basic notes and tutorials
id <original-index>
hetatm
ss <secondary structure>
around <distance>
expand <distance>
gap <distance>
in <selection>
like <selection>
<selection> and <selection>
<selection> or <selection>
<selection> not <selection>
<selection> and not <selection>
byres <selection>
byobject <selection>
a; <distance>
e; <distance>
l; <selection>
<selection> & <selection>
<selection> | <selection>
<selection> ! <selection>
<selection> & ! <selection>
br; <selection>
bo; <selection>
Examples
select (c;A and i;428)
color orange, sel01
select (n;CA and i;261:280)
color blue, sel02
select (n;C,N) and (i;430)
color red sel03
Examples 2 (see page 18)
select (c;B)
color cyan, sel 04
select (c;C and i;428:465)
color yellow, sel05
select (c;D)
hide surface, sel06
color black, sel06
select (r;PRO and n;N)
color magenta, sel07
select (e;O and not n;OH)
color lime, sel07
Similarly, the logical operators can be replaced with symbols:
Examples
select (c;A & i;428)
color orange, sel01
select (n;CA & i;261:280)
color blue, sel02
select (n;C,N) & (i;430)
color red sel03
20
PyMOL: Basic notes and tutorials
Example 2 (see page 20)
select (c;B)
color cyan, sel 04
select (c;C & i;428:465)
color yellow, sel05
select (c;D)
hide surface, sel06
color black, sel06
select (r;PRO & n;N)
color magenta, sel07
select (e;O & ! n;OH)
color lime, sel07
2.3.4
Settings
Much of PyMOL's functionality is controlled by parameters which can be adjusted. For example, the
size of spacefilling spheres generated by the 'show spheres' command is controlled by the parameter
sphere_scale. This can be altered globally, for example
set sphere_scale, 0.5
or just for one object, e.g.
set sphere_scale, 0.5, protein_A
The list of parameters is huge, and is only partly documented on the PyMOL website. In order to see
all available parameters, and change them quickly, the GUI interface can be used - from the menus
on the external window, select Setting->Edit All... (Appendix 1).
A list of the most useful settings is shown in the table 2.
TABLE 2:Common PyMOL settings
Setting
Controls
Type
antialias
Whether antialiasing is used
boolean (0 or 1)
during ray-tracing
fog
Extent of depth-cued fog
float (0-1)
normalize_ccp4_maps
Whether to normalise density
boolean (0 or 1)
maps on loading
sphere_scale
Size of spacefilling spheres
float (0-1)
sphere_transparency
Transparency of spacefilling
float (0-1)
spheres
transparency
Transparency of surfaces
float (0-1)
21
PyMOL: Basic notes and tutorials
2.3.5
Ray tracing and images
One of PyMOL's most useful features is its built-in ray-tracing engine. At any point during use,
simply typing
ray
ray-traces the current scene. In order to save the image as a PNG file, simply type
png <filename>
Figure 8 shows the results before and after ray-tracing a protein surface. The use of the antialias
setting greatly affects the quality of ray-tracing results - but also the time taken to perform the
computation. Another parameter worth experimenting with is
ray_trace_fog
while depth-cued fog can look nice in the raw image, it is sometimes a bit
overpowering after ray-tracing.
FIGURE 8: Ray tracing with specular reflections
2.3.6
Online help
Help can be obtained while using the program simply by using the help command in conjunction
with the name of the function on which you need help. For example, help show generates the screen
showed in Figure 9.
22
PyMOL: Basic notes and tutorials
FIGURE 9: Displayed help options
TUTORIAL 1
1. Load file 1L0T_sidechains
2. Colour code all the chains (a-f)
3. Assign secondary structure (based on crystal structure of HPV-16 L1) from the alignment
information in Figure 10
Secondary structure identifiers:
l
h
s
loop
helix
beta sheet
NOTE: It is important to ask the software to rebuild the secondary structure profile after
assignment/ alteration
23
PyMOL: Basic notes and tutorials
HPV-16
HPV-35
HPV-31
HPV-33
HPV-11
HPV-6
HPV-18
HPV-45
HPV-39
CRPV
BPV1
1
27
38 41
49
68
78
95
109
____ -B1____ __ -B2__
____ -C____
______ -D______
MSLWLPSEATVYLPPV.P.VSKVVSTDEYVARTNIYYHAGTSRLLAVGHPYFPI.KKPN.NNK.ILVPKVSGLQYRVFRIHLPDPNKFGFPDTSFYNPDTQRLVWACVGVEVGRGQPLGVGISGHPLLNKLDDTE
----rsn---------.s.-----------t---------s----------ya-.--qd.s--.-a-------------vk---------------d-as-------t------------------------------r-----------.-.-----------t---------sa---t-----ys-.p-sd.-p-k-v-------------vr-----------------e----------l--------------------f-----v-r-----------.-.-----------s--s---y--s-----------s-.-n-t.-a-kl--------------vr----------------------------l-i------------------f----..-r--ds---v--pn-.-----a--a--k----f---ss----------ys-.--v..-.-.tv------y-----kvv-------al--s-lfd-t--------t-l-----------v--------y--v-..-r--ds---v--pn-.-----a--a--t----f---ss-----------s-.-ra..-.-.tv------y-----kvv-------al--s-lfd-t--------t-l-----------v----f---y--v-a--r--dn------..-s-ar--n--d--t--s-f----s----t--n---rvpaggg.-.-.qdi----ay------vq--------l----i---e--------a---i---------l----fy-------a--r--ds------..-s-ar-----d--s--s-f----s----t--n---rvvpngag-.-.qa-----ay------va--------l--sti---e----------m-i-------i-l----fy-------am-rs-dsm-----..-s-a---n--d--t--g---y--s----t------kvgmngg.r.-.qdi----ay------vt-------si--a-l---e----------------------------y-rq----av--stqnkf----q.-.-t-ip------t---vf-y-ssd---t-----ye-rd-g....t.m------pn-------k-------a-g-kql-d-eke----clr-i--n-------svt-n-if--f--v-a--qqgq.kl----..tp----lcset--q-ks-f---e-e---ti----y-vsigak...t...-----an-----k-q-----q-al--rtvh--ske----pvi--q-s------gtvt---tf-a-l-a-
HPV-16
HPV-35
HPV-31
HPV-33
HPV-11
HPV-6
HPV-18
HPV-45
HPV-39
CRPV
BPV-1
150
162
234 239 243
255
____ -E______
__h1__
_____ -F_____
NASAYAANAG..VDNR.ECISMDYKQTQLCLIGCKPPIGEHWGKGSPCTNVAVNPG.DCPPLELINTVIQDGDMVDTGFGAMDFTTLQANKSEVPLDICTSICKYPDYIKMVSEPYGDSLFFYLRREQMFVRHLF
-snk-vg-s-..t---.-----------------r----------t--nanq-ka-.e------l---l-----------------------d------s--------l---------m----------------snr--ggp-..t---.--------------l----------------s-n-it--.-------k-s------------------a--dt--n------n--------l---a-----t--------------ftgnk-pgqp-..a---.--l-----------l-----t-------va---.-a.-an----------i-e----------c---k-------d--i---g-t------l--t----------f----------f-sgg-gg-p-..q---vn.vg---------mv--a--l-------tq-s-ts-qn-.--------ts---------------n-ad--t---d------gtv------lq-aad----r------k----a--f-sg.sgg-p-..q---vn.vg---------mv--a--l-------kq---tp-qa-.--------ts---------------n-ad--t---d--i---gtt------lq-aad----r---f--k----a--fss..h--tsnvse-v-.dnv-v--------il--a-a-----a--ta-ksrplsq-.-------k---le--------y-----s---dt-c-------q--------lq-sad-----m--c-----l-a-fws-..h--t-vitq-v-.dnv-v--------il--v-a-----a--tl-kpaqlq--.-------k--i-e--------y-----s---dt-c-------q--------lq-sad-----m--c-----l-a-fw-sp.fssttn..k-s-.dnv-v--------i---v-a--------ka-kpnn-st-.-------v--p-e----i---y-----ga--et---------q--------lq-sadv----m--c-----l-a-fw-ptk-yn-hadqq-y-.ksmaf-p--v--lml--v-at----aqakq-aedpp.qqt----i--v----e----cei------hk----sl-----elaq--s-----l--qkdqf---m---a-----ya--f-vnrkvttqt..t-d-.kqtgl-a--q-il-l--t-ae--y-ttar--vtdrlen-.a------k-kh-e----mei----an-kein-s--dl----qne--l----l--aedaa-n-m--fa-k--vy---iw
HPV-16
HPV-35
HPV-31
HPV-33
HPV-11
HPV-6
HPV-18
HPV-45
HPV-39
CRPV
BPV-1
300 304
311 314
327
337
342 348
360
382 384
_ -G1
-G2
___ -H1____
__ -H2_
________ -I____________ ___h2__
NRAGTVGENVPDDLYIKGS..G..STANLASSNYFPTPSGSMVTSDAQIFNKPYWLQRAQGHNNGICWGNQLFVTVVDTTRSTNMSLCAAIS.TS.ETTYKNTNFKEYLRHGEEYDLQFIFQLCKITLTADVMTY
--------t--a------......t-gt-p-ts-----------------------------------s-----------------v-s-v-.s-.ds----d---------------------------------s-----s--t-------..-..---t--n-t----------------------m------------------------------v----a.n-.d--f-ss-----------f-------------s--i-------l--a----------..-..t--siq--af-----------es-l----------------------v-------------t--tqv..--.ds----e-----i--v-------v-----v----e-----------p-----lv--g..n..nrssv---i-vh-----l-s-e--l--------k------------h--------------t---sv-.k-..a--t-sdy---m--v--f---------s---s-e--a----e---p---t-i----..-..nrtsvg--i-vn-----l-s-e--l--------k---------------------------t---svt.--..s--t-sdy---m--v------------s---s-e--a-----m-dt--qs-----t..-..mr-spg-cv-s-s----i----s-l-------hk-------v--h---------------lti--stq.spvpgq-da-k--q-s--v------------t--------s----vm-dt--t------tsan..mretpg-cv-s-s----ii---s-l-------hk----------h---------------lt---stq.npvps--dp-k--q-s--v------------t-----e--s--g-m--dai-aq-----t..d..ir--pg--v-c-s---------s-l-------hk----------h----l----------ft-sts-e.s-ips--dpsk----t--v------------tv---t---ss---gdk---ksra---rtqmqgean--i-td--ci-----l-s--s-v--ra----k---m---v--d--i------n--g-il--vtkskeqikk-hg-tvh-ss----v---e---vl----vk--penlst-g-sek-aptt-f-l-nnkgd...atlkip-vh-gs----l-st-n----r----f----m----a-n-l--l--g-n--g--ltisv-sdg-p.l-e-dssk-nv-h--m---k-a--le--svei-qtvsh-
HPV-16
HPV-35
HPV-31
HPV-33
HPV-11
HPV-6
HPV-18
HPV-45
HPV-39
CRPV
BPV-1
393 395 402
414
429
446 452
462
473
504
___ ___h3___
_____ _h4 ______
__ -J__
_____h5_____
IHSMNSTILEDWNFGLQPPPGGTLEDTYRFVTSQAIACQKH.TP.PAPKEDPL.KKYTFWEVNLKEKFSADLDQFPLGRKFLLQAGLKAKPKFTLG..KRKAT.PTTSSTS.TT..AKRKKRK..L..
-----ps---------t---s--------y-----vt---p.sa.-k--d---.-n------d--------------------------r-n-r--..--a-p.as--kk-.s-..kr--.v-..s..
-----pa---------tt--s-s-------------t---t.a-.qk-----f.-d-v----------------------------yr-r---ka-..--..s.apsa--t.-p..-----t-..k..
--a--pd-----q---t---sas-q-----------t---t.v-.-ke-----g-.------d-----------------------------..-...--..a.ap--trt.ss..-----v-..k..
--t--psv--------s---n--------y-q----t---p.--.eke-q--y.-dms-----------se-------------s-yrgrtsart-i.--..p.a.v-kp-.-a..p---rt-t.k.k
--t--psv--------s---n--------y-q----t---p.--.eke-p--y.-nls-----------se---y---------s-yrgrssirt-v.--..p.a.v-ka-.aa..p---ra-t.kr.
------s--------vp---tts-v------q-v--t---daa-.a.enk--yd-.lk--n-d------l----y-------v----rr--t..i-pr--.....sap-attsskp---vrvrark..
------s---n----vp---tts-v------q-v-vt---dt--.-.e-q--yd-.lk--t-d------s----y-------v----rrr-t..i-pr--..paas--ta-tasrp---vrirskk..
--t---s--dn---ava---sas-v----ylq-a--t---d.a-a-.e-k--ydg.lk--n-d-r----le--------------rvrrr-t..i-pr--..paas---s-.a-k.h---rv.s.k..
l---hp--idn-qlsvsaq-s-----q--ylq-i-tk-pppep-..kent--y.-n-k----d-s--l-dq---y-------n-s--qrigt......--p-pa-vsivk-.....s---r-t.....
lqglmpsv--n-ei-v---tssi------yie-p-tk-asnvi-...a----yag.fk--nid----l-l---------r--a-q-agcstv.....r--r....isqk--..skp--k--k......
FIGURE 10: Major capsid protein sequence alignments of nine HPV types from groups A7, A9 and
A10. The secondary structural elements identified from the crystal structure of N-terminal truncated
HPV-16 L1 ( N10L1) are shown above the sequence; -sheets are represented in blue and -helices
in red. Basic residues that constitute the NLS are indicated in pink and the conserved cysteine
residues 175 and 428 are indicated in yellow.
Here is an example on how to assign secondary structure details
alter 1-10/, ss='l'
alter 10-15/, ss='s'
alter 16/, ss='l'
alter 17-22/, ss='h'
alter 23-33/, ss='s'
alter 34-40/, ss='l'
alter 41-50/, ss='s'
alter 51-55/, ss='l'
rebuild
4. Have a look at the secondary structure assignment.
5. Change color of the whole pdb file output to black and set the background white
6. color the secondary structure elements in different colours
color <colour>, ss <secondary structure identifier>
7. save the image (please get a beautiful view of protein) using the command
png <image name>.png
24
PyMOL: Basic notes and tutorials
NB: make sure you are in the right directory or at least know where the portable network
graphics (png) file will be saved.
8. Ray trace the image using the command
ray
NB:please make use you do not more the image in the main canvas after ray tracing as you
will loose the ray tracing.
9. Save the ray traced image and compare to the non ray traced image in terms of
beauty/prettiness!
10. Colour chains a-e with one color and chain f with another
11. Render the object by surface
12. Select the following residues and color them differently
174-186
131-143
431-443
414-426
81-93
175 and 428
13. Orient the image such that it head first as shown below
14. ray trace and save image
15. get side and bottom views of the rendered protein using the rotate command as follows
rot, x 90
#rotates -90 degrees on the x axis
ray trace images and save them
FYI
move, x 10
#moves the object along the x axis by 10 units
zoom <selection> 10
#zooms out by 10 units
zoom <selection> -10
#zooms in by 10 units
therefore these commands can be added into scripts to generate an output with specific
orientation.
2.3.7
Scripts and log files
A PyMOL script is just a text file, such as a log file, containing typed PyMOL commands separated
by carriage returns. When a script is loaded into PyMOL the commands it contains are executed.
PyMOL expects scripts to have ".pml" file name extensions (this is not strictly required, but it is
good practice).
25
PyMOL: Basic notes and tutorials
You can use log files as scripts, and you can create scripts in a text editor such as emacs, jot, or
notepad. It's often useful to keep a text editor open in a separate window while using PyMOL.
Commands can then be cut and pasted between the two programs.
You can open a new log file by typing log_open log file name, or by clicking on "log" under the
"File" menu and naming the log file in the dialog box. You can also append commands to an
existing log file by choosing "append" or "resume" in the "File" menu. When you "resume" rather
than "append," the existing log file is first loaded as a script, and then subsequent commands are
written to it.
Once you have opened a log file in any of these ways, PyMOL will write and save all your
commands, whether they are typed or given by clicking on the buttons in the GUI. However, to store
the orientation of a molecule into a log file, you need to give the command get_view (type it or use
the GUI button). You may find it convenient to get_view several times in a PyMOL session, and
then edit the log file to select the most useful views.
Scripts can be executed in several ways. Under Windows, scripts can be run in a new PyMOL
session by double clicking on the script's icon. Alternatively, you can run a script using the "File"
menu's "Run" option. PyMOL also understands "@" as the typed command that loads a script:
pymol <script file name.pml>
or
@<script file name.pml>
TUTORIAL 2
Write a script that will carry out the whole tutorial 1 for you and execute it to see if it works.
2.3.8
Hydrogen bonds
(From Gareth Stockwell)
TUTORIAL 3
Load pdb file pdb1a30
# Load in a molecule (HIV protease complexed with a
tripeptide inhibitor)
hide everything
# Hide everything
show cartoon
# Show cartoons for the protein, colouring the two
chains differently
color lime, chain A
color pink, chain B
select inhib, chain C
show sticks, inhib
color red, inhib
# Select the inhibitor
26
PyMOL: Basic notes and tutorials
select bs, (byres inhib expand 4 & !inhib) # Select the binding site
# The 'byres' keyword expands the proximity selection
to consist of whole residues show lines, bs
show nb_spheres, bs
# Render water molecules which are in the binding site
distance hb1, ///C/508/N, ///A/27/O
# Add some dashed lines to represent the hydrogen
bonds
distance hb2, ///A/29/N, ///C/506/O
distance hb3, ///C/506/N, ///A/29/OD2
distance hb4, ///C/507/N, ///A/48/O
distance hb5, ///C/506/N, ////1076/O
# The following h-bond is to a water molecule
hide labels
# These commands clear the distance labels from the hbonds
label (bs &n;ca), "%s-%s-%s" % (chain,resn,resi)
# Label the residues in the binding site
# The first argument specifies which atoms are to be
labelled - here, we specify only C-alpha atoms, so that
each residue gets just one label.
# The second argument specifies the format of the
label, in a pseudo-print format
2.3.9
Density Maps
(From Gareth Stockwell)
PyMOL provides support for loading and contouring density maps, in either CCP4 or X-PLOR
format. In order to load in a map, simply use the 'load' command, e.g.:
1lza.ccp4
This one is from a crystallisation experiment on lysozyme (PDB ID 1lza). A contoured isosurface
can then be generated using the 'isomesh' command, which takes three arguments:
the name of the surface object to be generated
the name of the map object,
the contour level.
By default, maps are normalised when they are loaded, so the contour level is in 'sigmas' - i.e.
number of standard deviations above the mean value.
isomesh mesh, 1lza.ccp4, 2
If we now load in the coordinate file which is deposited in the PDB, we can see how well it fits the
density map
load pdb file pdb1lza
hide lines
show sticks, protein
27
PyMOL: Basic notes and tutorials
TUTORIAL 4
load pdb file: pdb1lza
# Load in a PDB file (lysozyme)
util.cbaw
# Set normal CPK colours and render as sticks so we
can see the coordinates through the mesh
show sticks, coords
set normalize_ccp4_maps, 1
load 1lza.ccp4
isomesh mesh, 1lza.ccp4, 2.0
whole cell
color green, mesh
# Load in the electron density map (CCP4 format)
# This was obtained from the Uppsala Electron Density
server http://fsrv1.bmc.uu.se/eds/
# First we make sure that map normalisation is turned
on - this means that we can contour at sigma levels
(rather than absolute values)
# Contour the map at 2.0 sigma across the
select res, ////87
# Select one residue - ASP 87
isosurface surf, map, 1, res, carve=2
# Create an isosurface at 1.0 sigma, just in the vicinity
of this residue
# (only in a region with 2 angstrom of the selected
residue)
set transparency, 0.5
# Make the isosurface semitransparent
move z, -20
# Zoom out a bit so we can see it better
2.3.10 Movies
(From Gareth Stockwell)
PyMOL can be used to generate movies, using a few simple commands. The output of movie
generation in PyMOL is a series of frames, written out in the PNG image format. In order to
generate a movie from them, an external program is required to encode the series of frames into an
appropriate format (e.g. MPEG or AVI).
Generating the frames themselves is fairly straightforward. Ready-made functions are provided for
generating common sequences, such as rotation about one of the principle axes. There are three
steps required to make a movie in PyMOL:
28
PyMOL: Basic notes and tutorials
2.3.10.1 Reserve space for the frames
After loading in the molecule, execute the following command to reserve space for N frames:
mset 1 xN
2.3.10.2
Generate each frame in the sequence
In order to generate a full 360-degree rotation around the y-axis, over N frames, execute
util.mroll(1,N,1)
Alternatively, this step may be something more involved, such as reading in the results of a
molecular dynamics trajectory or a docking simulation. Or, in order to create something more
complex than a simple rotation, some Python code could be used here.
2.3.10.3
View the results
In order to play the movie in PyMOL, either click on the play button in the VCR-like controls in the
main window, or use the mplay command. To output the movie frames as a series of PNG images,
type
mpng filename_root
This will generate a series of files called filename_root0001.png, filename_root0002.png, etc.
TUTORIAL 5
Load the file 1L0T_sidechains
mset 1 x120
set ray_trace_frames, 0
util.mroll(1,120,1)
mplay
# Reserve space for 120 frames
# Make sure that ray-tracing is turned off for movie
generation - otherwise, this would take a LONG time
# Use a built in utility function to generate a full 360degree rotation round the y-axis, over 120 frames
# Play the movie
29
PyMOL: Basic notes and tutorials
3 Appendix I
30
PyMOL: Basic notes and tutorials
31
This document was created with Win2PDF available at http://www.daneprairie.com.
The unregistered version of Win2PDF is for evaluation or non-commercial use only.