0% found this document useful (0 votes)
95 views

PyMol Tutorial

This document provides a quick tutorial on using PyMol to view protein structures and create publication-quality figures. It begins with an overview of PyMol and how to load files. It then demonstrates basic navigation and display settings. The main part of the tutorial focuses on using PyMol scripts to generate figures by defining secondary structure, coloring objects, representing molecules, adding surfaces, setting views, and using ray tracing. Key steps covered include loading files, assigning secondary structure, defining color schemes, representing molecules with cartoons and sticks, adding surfaces, and setting views to create high-quality figures.

Uploaded by

Joel Millan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views

PyMol Tutorial

This document provides a quick tutorial on using PyMol to view protein structures and create publication-quality figures. It begins with an overview of PyMol and how to load files. It then demonstrates basic navigation and display settings. The main part of the tutorial focuses on using PyMol scripts to generate figures by defining secondary structure, coloring objects, representing molecules, adding surfaces, setting views, and using ray tracing. Key steps covered include loading files, assigning secondary structure, defining color schemes, representing molecules with cartoons and sticks, adding surfaces, and setting views to create high-quality figures.

Uploaded by

Joel Millan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Quickie PyMol Tutorial - 30 min?

Stephen Curry
31 March 2006
What are we going to do this morning?

• Brief overview of the program


• Quick introduction to basic features
• Quick explanation of how to make nice figures using
scripts

• Just enough to get you started...


• You need to spend “hands on” time getting to know
the program
Introduction to PyMol
• What is PyMol for?
– looking at pdb files (protein, nucleic acid, ligands etc.)
– making publication quality figures (of models and maps)
– NOT for model building

• System requirements:
– computer (faster is better): PC (Windows/Linux), Mac (OS X)
– a 3-button scroll mouse
– works with hardware stereo

• Where can I get it?


– pymol.sourceforge.net
– current version: 0.99
– pymol.sourceforge.net/html/ - for the manual
Part 1 - loading, moving and displaying

• How do I...?
– Load a pdb file: (1) pdb loader; (2) open file
– Some display settings
– Create an object
– Use the mouse to move, zoom, slab, rotate (modifier keys)
– Use the object menus: A, S, H, L, C
Display options
Colour an object
– Navigate contextual menus
– Display the sequence
– Select residues
– Save my work
How do I start the program?
Double-click the
application icon (?)

or

From a terminal
window, type “pymol”

You should see a


command window and
a graphics window
(may be combined)

DEMO
How do I load a PDB file
• Download a pdb file directly into pymol
– Make sure you are connected to the internet
– Plugin > PDB Loader Service
– type in the PDB ID (e.g. 2bhg)
– object appears with this PDB ID

• Load a “local” pdb file


– File > Open...
– select pdb file
– object appears with same name as pdb file

DEMO
Useful display settings...

Display > Background > white ----set background colour

Display > orthoscopic view ----no perspective distortion


Creating new objects
• To create an object containing just chain A of
2bhg (= FMDV 3Cpro)
– type in command (or graphics) window:
create 3C-a, (2bhg and c;a)

chain A
new
object brackets
required Boolean
name
operator
comma
required

DEMO
Using the mouse in the graphics window

• Unmodified controls
– Left - rotate molecule (x, y and, at edges, z)
– Middle - translate molecule (x, y)
– Right - zoom (=MovZ)
– Wheel - slab/clip
Menu at bottom right
• With shift key
– Right - up/down: clip front
- left/right: clip back

DEMO
Object menus: A, S, H, L, C
A is for Action

Navigation tools

Quick-draw tools

Assigning secondary structure


Object manipulation

NB: some of these


will have sub-menus

DEMO
S is for Show

Useful representations
H is for Hide

Same content as Show menu

Use Show and Hide to toggle


things on and off

L is for Label

Haven’t used this

DEMO
C is for Color

Lots of options

Mostly self-explanatory

Color menu gives names


of ready-made colours that
can be used in scripts

DEMO
Contextual menus
• Left double click or right single
click to activate
– click on object or part of object
you want to manipulate
– more or less the same menus as
ASHLC

DEMO
Display the sequence

From menu:
Display > Sequence
or
click on “S” in mouse menu

Use the sequence to select


residues for modification
Access menus from the
sequence

DEMO
The settings menu

Settings > Edit all...


Lots of options!
Some explained here
Otherwise, make
educated guesses
and see what
happens
Saving your work

File > Save Session...


Enter filename as “my_file.pse”
Will save all your current settings (display objects, maps)

When you return to PyMol, load this file:


File > Open
Part 2 - making figures with scripts

• How do I make nice figures for publication?


– Using scripts
– Load molecules
– Assign/edit SS
– Define colours
– Molecule representation
– Showing sidechains - (problems with β-sheets)
– Colouring atoms by type
– Adding surfaces (as separate objects)
– Drawing maps
– Set view (get view); depth cueing
– Ray tracing
Fig. 1 - protein, ligands, sidechains, bonds

Secondary structure
CPK
Sticks
Surfaces
H-bonds
Domain colouring
Selection of residues
and atoms
Fig. 1 script - pt1
# Script name: hms1-pbz.pml (hsa-myristate-site1-phenylbutazone)
#
# Close-up of drug site 1 in hsa-myr-pbz
#
#define initial, view, cartoon parameters
@pymol_setup.mac Set global parameters (see next)

load ../pdb/hsa-myr-pbz.IIA.pdb, hsa Load pdb file; don’t


hide
display anything
#define secondary structure
Use pymol to do it: dss
#dss hsa
@hm_ss or
rebuild use dssp and append ss definitions to
hide pdb file
or
#define hsa colour-scheme
set_color hsa_red, [1.0, 0.1, 0.5] Do it yourself: @hm_ss (see next slide)
set_color hsa_light_red, [1.0, 0.7, 0.7]
set_color hsa_green, [0.0, 0.65, 0.0]
set_color hsa_light_green, [0.6, 1.0, 0.6]
Define some useful colours (and
set_color hsa_blue, [0.0, 0.5, 1.0] names) - for a consistent look
set_color hsa_light_blue, [0.5, 1.0, 1.0]
RGB triple
Global settings
Script/macro used to set some global parameters

# pymol_setup.mac
#
#initial setup
viewport 600, 600 ---size of graphics window
set auto_zoom, off ---don’t zoom in on new objects
set auto_show_lines, off ---don’t automatically display loaded pdb files
set auto_show_selections, off ---don’t automatically display selections

#cartoon parameters
set cartoon_fancy_helices,1 ---nicer helices (personal choice)
set cartoon_discrete_colors,1 ---can’t remember
set cartoon_highlight_color, grey60 ---inside of helices light gray
set cartoon_dumbbell_length,1.0 ---defines width of helix ribbon!
set cartoon_rect_length,1.40000 ---defines width of β-strands
set cartoon_loop_radius,0.3 ---width of tube used for loops
set cartoon_smooth_loops=0 ---no smoothing (if sidechains needed)
Global settings
pymol_setup.mac continued...

# set radius of dashed lines (i.e. Hbonds)


set dash_radius, 0.1

#view & ray-tracing parameters


set orthoscopic=1 ---no perspective distortion
set ray_shadows=0 ---no shadows
set depth_cue=1 ---depth cueing on (realtime display)
set ray_trace_fog=1 ---ray-trace depth cueing
bg_col white ---white background colour (fashionable)
#set surface_quality=1.0 ---smooth surfaces (off by default - slows things down)
set antialias=1.0 ---smoother lines when ray-tracing
set two_sided_lighting, on ---lighting effect

#memory allocation for faster ray tracing


set hash_max, 400 ---play around with this value to see if it helps!
hm_ss: set the secondary structure
#define secondary structure for HSA-FA
complexes

#set everything to loop


alter 3-584/, ss='L'
...
#now define helices in HSA alter 283-291/, ss='H'
alter 6-14/, ss='H' alter 305-310/, ss='H'
alter 16-29/, ss='H' alter 315-321/, ss='H'
alter 36-55/, ss='H' alter 323-336/, ss='H'
alter 66-74/, ss='H'
alter 343-358/, ss='H'
alter 80-83/, ss='H'
alter 85-92/, ss='H' alter 366-368/, ss='H'
alter 95-102/, ss='H' alter 373-397/, ss='H'
alter 120-129/, ss='H' alter 400-414/, ss='H'
alter 132-145/, ss='H' alter 420-436/, ss='H' For β-strands:
alter 151-168/, ss='H' alter 442-466/, ss='H' alter 100-110/, ss=’S'
alter 174-205/, ss='H' alter 471-478/, ss='H'
alter 208-222/, ss='H' alter 486-490/, ss='H'
alter 228-246/, ss='H' alter 504-507/, ss='H'
alter 250-266/, ss='H'
alter 513-515/, ss='H'
alter 268-270/, ss='H'
alter 276-280/, ss='H' alter 518-535/, ss='H'
... alter 541-559/, ss='H'
alter 566-584/, ss='H'
Fig. 1 script - pt2
#colour dfhsa molecule (typically residues 5-582)
Colour the HSA
color hsa_red, (i;5-106)
color hsa_light_red, (i;107-196) molecule by domain
color hsa_green, (i;197-296) (see next for more
color hsa_light_green, (i;297-383) selection syntax)
color hsa_blue, (i;384-496)
color hsa_light_blue, (i;497-582)

#create dom2 and dom3 based on single structure loaded above Create an object
@hm.dom23.mac containing domains
#define drug colour scheme 2 and 3
@drug_colours.mac

#draw drugs as sticks and colour by atom type Create an object called “drugs”
create drugs, (hsa and (i;2001 or i;1009)) that displays two ligand
show sticks, drugs
@drugs-stick-rad.mac
molecules as sticks
color pbz_col, (i;2001 and e;C)
color fa_col, (i;1009 and e;C) Colour by atom type
color blue, (drugs and e;N)
color red, (drugs and e;O)
color green, (drugs and n;CL)
Selection syntax - some examples

i;99-105 residues 99-105 inclusive (i = index?)


i;99:105 residues 99-105 inclusive
r;tyr all Tyr residues (r = residue name)
c;a chain A (c = chain)
n;N atoms named “N” (= main-chain nitrogen)
n;CA atoms named “CA” (=alpha carbon)
(get to know the atom names in pdb files)

e;C all carbon atoms (e = element)


More macros defined
#hm.dom23.mac
#generate domains 2 and 3 to show drug site 1 in a single structure
#
create dom2, (i;194:297 or i;148:151)
show cartoon, dom2 Boolean
create dom3, (i;340:350 or i;479:483 or i;445:459) algebra
show cartoon, dom3

#drug_colours.mac #drug_stick_rad.mac
# site 1 (primary) set stick_radius, 0.22, drugs
set_color aza_col, [1.0, 1.0, 0.75]
set_color cpf_col, [0.75, 0.75, 0.25]
set_color dzp_col, [1.0, 0.75, 1.0]
set_color hal_col, [0.25, 0.25, 0.25]
set_color imn_col, [1.0, 1.0, 0.5]
set_color iod_col, [1.0, 0.5, 0.5]
set_color oxy_col, [0.25, 0.75, 0.5]
set_color pbz_col, [0.0, 0.75, 1.0]
etc...
Fig. 1 script - pt3
Create an object called “surf”
create surf, (hsa and i;2001)
show surface, surf which shows the surface of
colour lilac, surf residue 2001 (=pbz).
set transparency, 0.6, surf Make semi-transparent.
create surf1, (hsa and i;1009)
show surface, surf1 Create an object called “surf1”
set_color light_yellow, [1.0, 1.0, 0.2] which shows the surface of
colour light_yellow, surf1 residue 1009 (=FA).
set transparency, 0.5, surf1 Colour it differently
# add FA2 Make semi-transparent.
create fa-c, (i;1002 and e;C)
set sphere_scale, 1, fa-c Draw a FA molecule as a CPK
show spheres, fa-c
model by creating 2 objects
create fa-o, (i;1002 and e;O) (“fa-c” and “fa-o”).
set sphere_scale, 0.78, fa-o
show spheres, fa-o Make O atoms smaller than C
atoms (VdW)
color grey70, ((fa-c or fa-o) and e;C)
color red, ((fa-c or fa-o) and e;O)) Colour by atom type.
Fig. 1 script - pt4
# add sidechains for site 1 (sc1.mac) Create an object called “sc”
@sc1.mac
which shows selected
show sticks, sc
@sc-stick-rad.mac sidechains as sticks.
color grey70, (sc and (e;C and not n;CA)) Colour by atom type - but do
color blue, (sc and e;N) not re-colour the CA atom
color red, (sc and e;O)
color yellow, (sc and e;S)

# add sidechains for rest of pocket - based on pbz


create sc2, (hsa and (i;198 or i;206 or i;347 or i;481 or i;450:451 or i;454:455)
and not (n;O or n;C or n;N))
show sticks, sc2
@sc-stick-rad.mac
color grey70, (sc2 and (e;C and not n;CA))
color blue, (sc2 and e;N)
color red, (sc2 and e;O) Same again for another set of
color yellow, (sc2 and e;S) sidechains
More macros defined

#sc1.mac
#drug site 1 sidechains
create sc, ((i;150 or i;195 or i;199 or i;202 or i;211 or i;214:215 or i;218:219 or
i;222:223 or i;234 or i;238 or i;242 or i;257 or i;264 or i;291)
and not (n;O or n;C or n;N))
All one line!

Select specific residues and


exclude the following
mainchain atoms: N, O, C

More complicated Boolean


algebra...
Fig. 1 script - pt5
# add 343-344 to show h-bonds to Glu450
create 343, (hsa and ((i;343 and not (n;O)) or (i;344 and n;N))) Tricky bit to show
show sticks, 343 sidechain and some
@sc-stick-rad.mac
color grey70, (343 and (e;C and not n;CA))
mainchain atoms
color blue, (343 and e;N)
color red, (343 and e;O)

# add hydrogen bonds


distance dst1 = (/sc//A/ARG`218/NH2), (/drugs//A/pbz`2001/O2), 5.0 Define and draw H-
distance dst2 = (/sc//A/ARG`218/NE), (/drugs//A/pbz`2001/O2), 5.0 bonds
distance dst3 = (/sc//A/HIS`242/NE2), (/drugs//A/pbz`2001/O1), 5.0 Atom definitions are
distance dst4 = (/sc2//A/GLU`450/OE1), (/343//A/VAL`343/N), 5.0
distance dst5 = (/sc2//A/GLU`450/OE2), (/343//A/VAL`344/N), 5.0 horrible but you can
distance dst6 = (/sc2//A/ASP`451/OD1), (/sc//A/LYS`195/NZ), 5.0 get them by:
distance dst7 = (/sc//A/ARG`257/NH1), (/drugs//A/pbz`2001/O1), 5.0 Ctrl-shift-left click.
color yellow, dst1 Colour bonds yellow.
set dash_gap=0.4
hide labels

#set view
@s1-hm-cuview.mac
Define the viewpoint (see next)

#ray 1200,1200
Ray-trace and write out file (remove ‘#’ when ready)
#png hms1-pbz.png
Setting the viewpoint
You don’t have to type
# s1-hm-cuview.mac
this!
# close-up view of site 1 in hsa-myr
#
set_view (\ • Set the view you want
0.847002089, 0.519193769, -0.113906674,\ in the graphics window
-0.408921719, 0.773371875, 0.484395087,\ • Click on the “Get View”
0.339599967, -0.363719672, 0.867373824,\ button
-0.001291693, 0.898808300, -70.790878296,\
31.465492249, 12.112967491, 12.206689835,\ • Cut and paste the
52.887966156, 87.986236572, 1.000000000 ) set_view matrix into
your script (or macro)
Fig. 2 - protein with electron density

Loading maps
Display as mesh and/or surface
Controlling extent of map displayed
Fig. 2 script - pt1
# script: 3C_loopmap.pml
#
#setup global parameters Setup and load pdb file
@pymol_setup.mac

load wat4a_060310.2.A.pdb, 3C

set_color light_magenta, [1.0, 0.6, 1.0]


set_color light_orange, [1.0, 0.6, 0.3]
set_color light_green, [0.6, 1.0, 0.6] Define colours
set_color light_blue, [0.5, 0.75, 1.0]
set_color purple, [0.5, 0.25, 0.75]

cartoon loop, 3C Define cartoon representation


set cartoon_loop_radius,0.3, 3C
to be used (loop).
colour light_green, 3C
Create object called “prot”
create prot, (3C and (i;7-135 or i;150-208)) consisting of all residues except
show cartoon, prot
136-149). Draw cartoon
representation (loop)
Fig. 2 script - pt2
create prot-loop, (i;135:150)
hide everything, pro-loop
Draw and object called “prot-
show sticks, pro-loop
loop” showing residues 135-
colour light_orange, (pro-loop and e;C)
colour yellow, (pro-loop and e;S) 150 as sticks.
colour red, (pro-loop and e;O) Colour by atom type
colour blue, (pro-loop and e;N)

load k51e_sa1_fofc.xplor, difmap Load map (CNS format but


isomesh msh1, difmap, 2.0, pro-loop, 1.0, 0, 2.5 with .xplor extension!) and call
colour tv_blue, msh1 it “difmap”.
set mesh_width, 0.6, msh1 From “difmap, draw map as
mesh (creating object “msh1”).
Contour level=2, around object
“prot-loop (plus 1.0 Å buffer),
mesh_width = width of lines state=0 (?), carve=2.5
in the mesh Value of carve parameter is
most important for controlling
extent of map displayed
Fig. 2 script - pt3
isosurface sf1, difmap, 2.0, loop, 1.0, 0, 2.5 From “difmap, draw map as
colour grey90, sf1 a smooth surface (creating
set transparency, 0.5, sf1 object “sf1”). Use same
parameters as for msh1
set_view (\
0.522022903, -0.471787959, -0.710549474,\
-0.766768932, 0.105253145, -0.633219361,\
0.373555541, 0.875387847, -0.306816727,\
-0.000078557, -0.000008190, -75.465362549,\ Set view and ray
-15.310430527, -12.940036774, -9.453201294,\ trace as before
64.074295044, 86.465293884, 1.000000000 )

#ray 1000,1000
#png k51e_loopmap.cu.png

Comment out (to prevent ray


tracing) while you are refining
your script. Restore when you
want to generate an image file.
Summary/Key points

• Scripts can get very complex but once you’ve


done one, you can copy, cut and paste
• For a talk/paper you might make up to 30-40
images
• Use scripts/macros to get a consistent look
and to facilitate changing parameters across
many images
• You need to be organised...
Advanced topics (for next time...?)

• Not included but very useful:


– Setting the image filename within a script
– Making movies
– Aligning 2 molecules
– Displaying symmetry-related objects
– Calculating and displaying electrostatic surfaces

• For next time:


– Define what is meant by “ray-tracing” or “rendering”
– Show use of PyMol alongside nedit

You might also like