This is a hands on tutorial - the idea is to walk you through some examples
and then apply these to your own protein of interest with help from the
instructor - so please just get started.
Please note that this tutorial only gives my own
personal preferences of how to do write
PyMol scripts and make movies - there are many other (and perhaps better)
ways of doing this.
So what will you learn:
Specifically, you will be creating the following three movies:
rotating inhibitor complex
alternating between surface and secondary structure
a "morphing" movie (reload page to restart)
First, a few general considerations and pieces of advice:
Why scripts?
Pymol is a freely available program for making some fantastic graphics of your molecular system of interest. Although perhaps initially difficult to learn in this age of "point-and-click" computer usage, the very best way to drive PyMol is not through it's graphical user interface, but through a script. Once you know how to do this and have made a few scripts, it is very easy to adapt these to a new project. More important here is that the PyMol script is a simple text file, which we can modify or even create with some UNIX shell scripts. This allows the automatic generation of complex PyMol scripts that generate a sequence of images in which one or several parameters gradually change, such as surface transparency, protein conformation etc.
Why movies?
In particular for movies, which easily get too "busy", it is important to build a script that shows the things that are worth showing and does not show the things that are not worth showing. Remember - the objective of these movies is NOT to look "cool", but to allow the audience to appreciate the 3D-ness of the molecule. In particular shadows, while they look nice, actually make the picture more "busy" and are therefore distracting. It is perhaps not even necessary to ray trace the images.
Movie formats
There are many different movie formats - .avi, .mpg., .mov, just to name a few. By far the best format for our purposes though is, surprisingly, .gif - a so called "animated" GIF file - if you right click on the movies and save them you will see this. This format has several advantages. First, they are very easy to make by saving individual PyMol frames as .png (your PyMol scripts will do this automatically) - then converting them all individually to GIF images and merging these in only large GIF file - this is done with the convert utility of the freely available ImageMagick package. Secondly, these files are of high quality, but rather small size compared to the other movie formats. Importantly, you do NOT need any "plug-ins" or other additional software to view them, and if you put them into a PowerPoint or on a website the animation will start immediately (as they do above) - without any deadly silences from the audience as you struggle to get your MPEG movie started. You will learn all the details of creating these animated GIF files below.
PyMol and secondary structure
One of the weaker sides of PyMol is its secondary structure analyzer. If you use this you will most likely end up with some weird looking "strands"/"helices". Although secondary structure is stored in the PDB, this is not much help when you are trying to generate that first picture of your protein. The gold standard for secondary structure assignment from coordinates is DSSP - but there is no "plug-in" to PyMol. However, there is a way to nearly automatically write the part of the PyMol script which defines secondary structure, with the help of a little FORTRAN program and output from the WHAT IF program which interfaces with DSSP. Please read the details in this separate document.
PyMol and protein/ligand hydrogen bonds
Have you struggled with finding and showing protein-LIGAND hydrogen bonds? See here on how to do this automatically generating part of a PyMol script for you which will display hydrogen bonds.
Example 1: simple rotation of inhibitor complex
Download this PDB file and this Fo-Fc map first. Then copy and paste the script below to create a file in the same directory as your PDB and map files, calling it p.pml. The script contains detailed comments - please read them to understand what is going on. The next few scripts will not have any comments apart from the new sections.
#
# this gives us a "clean slate" - not so important the first time
# but needs to happen when making movies
#
delete all
reset
#
# load the PDB file. This creates an "object", and PyMol automatically
# zooms in on these coordinates
#
load afcballo.pdb
#
# this loads an Fo-Fc map - the one we used to build a model of the inhibitor
# into.
# A map object fofc_map is created, which we use later for some countouring
#
load fofc.xplor
#
# this sets the size of the PyMol screen. It's a good idea to keep this small
# for your initial tests so things go faster. For movies somewhere between
# 350x350 to 500x500 pixels is useful
#
viewport 390,390
#
# this removes all representations of the objects from the screen
#
hide
#
# PyMol is not very good at detecting secondary structure - DSSP is the
# gold standard for this. Please read the "Secondary structure" section
# above.
#
# The first statement sets everything to LOOP conformation, the subsequent
# statements alter the secondary structure for specific bits to HELIX or
# STRAND
#
alter A/1:500/, ss='L'
alter A/43:49/, ss="S"
alter A/70:78/, ss="S"
alter A/85:86/, ss="S"
alter A/90:94/, ss="H"
alter A/112:123/, ss="H"
alter A/128:134/, ss="S"
alter A/142:146/, ss="H"
alter A/149:166/, ss="H"
alter A/170:174/, ss="S"
alter A/181:205/, ss="H"
alter A/212:217/, ss="S"
alter A/221:226/, ss="H"
alter A/229:233/, ss="H"
alter A/238:241/, ss="S"
alter A/274:283/, ss="H"
alter A/291:296/, ss="S"
alter A/298:302/, ss="S"
alter A/324:326/, ss="S"
alter A/336:340/, ss="S"
alter A/345:350/, ss="S"
alter A/355:358/, ss="S"
alter A/362:375/, ss="H"
alter A/379:383/, ss="S"
alter A/395:403/, ss="H"
alter A/424:427/, ss="H"
#
# by colouring all carbons grey, the ribbons representation also becomes
# grey, as the ribbon colour is coupled to the CA color
#
color grey, (elem C)
#
# color most of the strands marine, all helices firebrick and the whole
# 298-361 section yellow
#
color marine, (ss s and (resi 1:297 or resi 362:500) and name CA)
color firebrick, (ss h and name CA)
color yellow, (resi 298:361 and name CA)
#
# set colors for elements other than carbon
#
color yellow, (elem S)
color red, (elem O)
color blue, (elem N)
#
# require that loops pass as well as possible through CA positions
# this will prevent your side chains appear as "floating" in space
#
set cartoon_smooth_loops = 0
#
# make the ribbons representations better looking
#
set cartoon_fancy_helices = 1
set cartoon_fancy_sheets = 1
#
# this actually displays the ribbon cartoon
#
cartoon automatic
show cartoon
#
# colours all carbons grey, except the CA's (which would also change our
# carefully specified secondary structure colouring)
#
color grey, (elem C and not name CA)
#
# for a list of side chains, show all atoms, except the backbone amide atoms
# as these would overlap with the ribbon/cartoon
#
show sticks, (not name N,C,O and resi 47,51,56,136,137,174,176,177,216,242)
show sticks, (not name N,C,O and resi 244,245,250,298,300,321,322,324,383)
#
# colour all carbon atoms purple in the residue with name DRG (the inhibitor)
#
color purple, (elem C and resn DRG)
#
# show a key water molecule as a sphere and colour it orange
#
show nb_spheres, (resi 2789)
color orange, (resi 2789)
#
# show the inhibitor molecule (residue name DRG) as sticks
#
show sticks, (resn DRG)
#
# this sets the thickness of all shown sticks. Setting this to relatively
# "thin" makes the whole image less "dense"
#
set stick_radius=0.2
#
# these are the hydrogen bonds. Please read "Hydrogen bonds in PyMol" above
# for some tips on how to detect these and automatically generate this
# section of the script.
# Note that each hydrogen bond is an object, which can be coloured
# individually. You will notice that without ray tracing they look rather
# poor.
#
dist d3 = ( resi 176 and name OE1), ( resi 2789)
color yellow, d3
cmd.hide("labels" ,"d3")
dist d4 = ( resn DRG and name C43), ( resi 2789)
color yellow, d4
cmd.hide("labels" ,"d4")
dist d5 = ( resn DRG and name N44), ( resi 174 and name OD2)
color yellow, d5
cmd.hide("labels" ,"d5")
dist d6 = ( resn DRG and name O27), ( resi 245 and name OD2)
color yellow, d6
cmd.hide("labels" ,"d6")
dist d7 = ( resn DRG and name O18), ( resi 137 and name CA)
color yellow, d7
cmd.hide("labels" ,"d7")
dist d8 = ( resn DRG and name O51), ( resi 136 and name CA)
color yellow, d8
cmd.hide("labels" ,"d8")
dist d9 = ( resn DRG and name O37), ( resi 244 and name OH)
color yellow, d9
cmd.hide("labels" ,"d9")
#
# here the map is shown. The first line defines the tickness of the lines
# in the chickenwire (mesh) - it's a good idea to set these as thin as
# possible to increase visibility of the ligand
# The second line shows the map that was read in early on in this script.
# It is contoured at 2.5 sigma, and shown up to 1.75 Angstrom away from
# any atom in the residue DRG.
# The third line colours the map green.
#
set mesh_radius = 0.02
isomesh map_fofc, fofc, 2.5, (resn DRG), carve = 1.75
color green, map_fofc
#
# this defines the viewing matrix. You determine this by writing the
# full script and then orienting / centering / zooming your molecule
# so that you are happy with it - then click the GetView button in the
# GUI and copy and past the resulting matrix into your script - this will
# then always generate the same view from scractch
#
set_view (\
-0.189196035, 0.545788586, -0.816276371,\
0.954002738, 0.299032837, -0.021176450,\
0.232534811, -0.782741010, -0.577261806,\
-0.000353802, -0.000684433, -49.156532288,\
93.860336304, 69.272697449, -6.228833199,\
37.115707397, 62.115707397, 0.000000000 )
#
# these are some settings which describe the level of detail on sticks,
# secondary structure elements, spheres and surface
# It is worth playing with the depth_cue and ray_trace_fog paramaters
# if you have selected a white background (as required now for almost
# all journals)
#
# as an alternative to playing with these numbers, you could use a script,
# and then just before ray tracing selecting Low Performance - High Quality
# in the PyMol GUI - this sets a number of parameters similar to those below
# ton increase the quality of your ray traced objects
#
set antialias=1
set line_smooth = 1.00000
set depth_cue = 1
set specular = 1.00000
set surface_quality = 1.00000
set stick_quality = 25.00000
set sphere_quality = 2.00000
set cartoon_sampling = 14.00000
set ribbon_sampling = 10.00000
set ray_trace_fog = 1
#
# rebuild is required to rebuild all objects after changing quality settings
#
rebuild
#
# this is the ray tracing command - notice it is commented about by a # -
# this is a good idea as you don't want to wait for several minutes for
# PyMol to ray trace your image only to find out you don't quite like the
# color of that second alpha helix!
#
#ray
#
# with the PNG command you can write out your image in the very portable
# PNG format - again, use this only once you're happy with the image on
# your screen
#
#png out.png
If PyMol is installed correctly, you should be able to double click on the
p.pml file you just generated and things should work fine. Otherwise, start
PyMol from the directory containing your PDB file, map and p.pml, and type
@p.pml from the PyMol prompt.Now let's use another PyMol script which will generate images separated by 0.25 degrees rotation around y. Note that the first few images go slower this makes the change in rotation smoother. Save this as m.pml and type @m.pml in your pymol window.
turn y, 0.03125 #ray 390,390 png f1001.png turn y, 0.0625 #ray 390,390 png f1002.png turn y, 0.125 #ray 390,390 png f1003.png turn y, 0.25 #ray 390,390 png f1004.png turn y, 0.25 #ray 390,390 png f1005.png turn y, 0.25 #ray 390,390 png f1006.png turn y, 0.25 #ray 390,390 png f1007.png turn y, 0.25 #ray 390,390 png f1008.png turn y, 0.25 #ray 390,390 png f1009.png turn y, 0.25 #ray 390,390 png f1010.png turn y, 0.25 #ray 390,390 png f1011.png turn y, 0.25 #ray 390,390 png f1012.png turn y, 0.25 #ray 390,390 png f1013.png turn y, 0.25 #ray 390,390 png f1014.png turn y, 0.25 #ray 390,390 png f1015.png turn y, 0.25 #ray 390,390 png f1016.png turn y, 0.25 #ray 390,390 png f1017.png turn y, 0.25 #ray 390,390 png f1018.png turn y, 0.25 #ray 390,390 png f1019.png turn y, 0.25 #ray 390,390 png f1020.png turn y, 0.25 #ray 390,390 png f1021.png turn y, 0.25 #ray 390,390 png f1022.png turn y, 0.25 #ray 390,390 png f1023.png turn y, 0.25 #ray 390,390 png f1024.png turn y, 0.25 #ray 390,390 png f1025.png turn y, 0.25 #ray 390,390 png f1026.png turn y, 0.25 #ray 390,390 png f1027.png turn y, 0.25 #ray 390,390 png f1028.png turn y, 0.25 #ray 390,390 png f1029.png turn y, 0.25 #ray 390,390 png f1030.png turn y, 0.25 #ray 390,390 png f1031.png turn y, 0.25 #ray 390,390 png f1032.png turn y, 0.25 #ray 390,390 png f1033.png turn y, 0.25 #ray 390,390 png f1034.png turn y, 0.25 #ray 390,390 png f1035.png turn y, 0.25 #ray 390,390 png f1036.png turn y, 0.25 #ray 390,390 png f1037.png turn y, 0.25 #ray 390,390 png f1038.png turn y, 0.25 #ray 390,390 png f1039.png turn y, 0.25 #ray 390,390 png f1040.png turn y, 0.25 #ray 390,390 png f1041.png turn y, 0.25 #ray 390,390 png f1042.png turn y, 0.25 #ray 390,390 png f1043.png turn y, 0.25 #ray 390,390 png f1044.png turn y, 0.25 #ray 390,390 png f1045.png turn y, 0.25 #ray 390,390 png f1046.png turn y, 0.25 #ray 390,390 png f1047.png turn y, 0.25 #ray 390,390 png f1048.png turn y, 0.25 #ray 390,390 png f1049.png turn y, 0.25 #ray 390,390 png f1050.png turn y, 0.25 #ray 390,390 png f1051.png turn y, 0.25 #ray 390,390 png f1052.png turn y, 0.25 #ray 390,390 png f1053.png turn y, 0.25 #ray 390,390 png f1054.png turn y, 0.25 #ray 390,390 png f1055.png turn y, 0.25 #ray 390,390 png f1056.png turn y, 0.25 #ray 390,390 png f1057.png turn y, 0.25 #ray 390,390 png f1058.png turn y, 0.25 #ray 390,390 png f1059.png turn y, 0.25 #ray 390,390 png f1060.png turn y, 0.25 #ray 390,390 png f1061.png turn y, 0.25 #ray 390,390 png f1062.png turn y, 0.25 #ray 390,390 png f1063.png turn y, 0.25 #ray 390,390 png f1064.png turn y, 0.25 #ray 390,390 png f1065.png turn y, 0.25 #ray 390,390 png f1066.png turn y, 0.25 #ray 390,390 png f1067.png turn y, 0.25 #ray 390,390 png f1068.png turn y, 0.25 #ray 390,390 png f1069.png turn y, 0.25 #ray 390,390 png f1070.png turn y, 0.25 #ray 390,390 png f1071.png turn y, 0.25 #ray 390,390 png f1072.png turn y, 0.25 #ray 390,390 png f1073.png turn y, 0.25 #ray 390,390 png f1074.png turn y, 0.25 #ray 390,390 png f1075.png turn y, 0.25 #ray 390,390 png f1076.png turn y, 0.25 #ray 390,390 png f1077.png turn y, 0.25 #ray 390,390 png f1078.png turn y, 0.25 #ray 390,390 png f1079.png turn y, 0.25 #ray 390,390 png f1080.png turn y, 0.25 #ray 390,390 png f1081.png turn y, 0.25 #ray 390,390 png f1082.png turn y, 0.25 #ray 390,390 png f1083.png turn y, 0.25 #ray 390,390 png f1084.png turn y, 0.25 #ray 390,390 png f1085.png turn y, 0.25 #ray 390,390 png f1086.png turn y, 0.25 #ray 390,390 png f1087.png turn y, 0.25 #ray 390,390 png f1088.png turn y, 0.25 #ray 390,390 png f1089.png turn y, 0.25 #ray 390,390 png f1090.png turn y, 0.25 #ray 390,390 png f1091.png turn y, 0.25 #ray 390,390 png f1092.png turn y, 0.25 #ray 390,390 png f1093.png turn y, 0.25 #ray 390,390 png f1094.png turn y, 0.25 #ray 390,390 png f1095.png turn y, 0.25 #ray 390,390 png f1096.png turn y, 0.25 #ray 390,390 png f1097.png turn y, 0.125 #ray 390,390 png f1098.png turn y, 0.0625 #ray 390,390 png f1099.png turn y, 0.03125 #ray 390,390 png f1100.png
So now we have our images, how do we make a movie out of this? Copy
this script to your directory, calling it movie.com and run it. The comments in the script explain what's happening.
#!/bin/tcsh # # the line above may need changing depending on your computing environment # # # this line generates a counting variable i # @ i = 1002 # # 100 images will be converted # while ($i < 1100) echo $i @ b = 3000 - $i # # convert each image from PNG to GIF ( you need ImageMagick for this ) # convert -type palette f$i.png f$i.gif # # generate the images "backwards" so we can create a continuous loop. # ln -sf f$i.gif f$b.gif @ i++ end convert -type palette f1001.png f1001.gif convert -type palette f$i.png f$i.gif echo CONVERTING # # this is the key command - it makes a single GIF file out of all separate # GIF files # convert -loop 0 -delay 3 -type palette f*.gif all.gif
You should now have a file called all.gif in your directory. Open it in a web browser and you should see motion!
Example 2: rotation with fading in/out of surface
See this directory for p.pml (the script), the PDB files and the unix scripts (jhack*) to generate the m.pml file and the all.gif movie file.
Example 3: a conformational change (morphing)
See this directory for p.pml (the script), the PDB files (start.pdb is the first, end.pdb is the last and the *.PDB files are the ones used for the script) and the unix scripts (jhack*) to generate the m.pml file. A little FORTRAN program morph.f is here, compile with f77 morph.f -o morph. You can use this to interpolate between two PDB files (i.e. start.pdb and end.pdb).
The final bit
If you got here you are probably quite smart, so now for the final bit - you are on your own now! Using your favourite PDB file with a ligand (if you don't know one, use 1W1A) and using one of the above scripts as a template, generate a movie showing the protein with nicely coloured secondary structure, the hydrogen bonds between protein and ligand, with the complex rotating while a surface representation of the ligand fades in and out. Show me your movies and problems! The winner as judged by a completely crooked judge (me) will win free beers for the rest of the evening. Please feel free to ask for any advice/help.