L6 VMD Tutorial
L6 VMD Tutorial
Contents
1 Basics of VMD 5
1.1 Loading a Molecule . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.2 Displaying the Protein . . . . . . . . . . . . . . . . . . . . . . . . 6
1.3 Exploring Different Drawing Styles . . . . . . . . . . . . . . . . . 7
1.4 Exploring Different Coloring Methods . . . . . . . . . . . . . . . 9
1.5 Exploring Different Selections . . . . . . . . . . . . . . . . . . . . 9
1.6 Multiple Representations . . . . . . . . . . . . . . . . . . . . . . . 11
1.7 Sequence Viewer Extension . . . . . . . . . . . . . . . . . . . . . 12
1.8 Saving your Work . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Introduction
This tutorial introduces new users to VMD and its capabilities. It can also
be used as a refresher course for the occasional VMD user wishing to employ
this program more productively. This tutorial has been designed specifically for
VMD 1.8.3 and should take about 3 hours to complete in its entirety.
The examples in the tutorial will focus on the study of ubiquitin – a small
protein with interesting properties. Throughout the text, some material will be
presented in separate “boxes”. These boxes include complementary information
to the tutorial, such as information about the biological role of ubiquitin, and
tips or shortcuts for using VMD.
Getting Started
You can find the files for this tutorial in the vmd-tutorial-files directory in
/Desktop/Workshop/vmd-tutorial/. Below you can see in Fig. 1 the files and
directories of vmd-tutorial-files.
1 Basics of VMD
In this unit you will build a nice image of ubiquitin while becoming accustomed
to basic VMD commands. In addition, you will learn how to look for interesting
structural properties of proteins using VMD.
Now, ubiquitin is shown in your screen in the OpenGL Display window. You
may close the Molecule File Browser window at any time.
Webpdb. VMD can download a pdb file from the Protein Data
Bank if a network connection is available. Just type the four letter
code of the protein in the File Name text entry of the Molecule File
Browser window and press the Load button. VMD will download it
automatically.
2 If you press the second (right) button and repeat the previous step, the
rotation will be done around an axis perpendicular to your screen (b) (For
Mac users, the second button is equivalent to hitting the command key
while pressing the mouse button).
5 The Scale mode will allow you to zoom in or out by moving the mouse
horizontally while holding the first (left) button down.
It should be noted that the previous actions performed with the mouse do
not change the actual coordinates of the molecule atoms.
Mouse modes. Note that each mouse mode has its own charac-
teristic cursor and its own shortcut key (r: Rotate, t: Translate, s:
Scale) that could be used instead of the Mouse menu. (Be sure to
have the OpenGL Display window active when using the shortcuts.)
Additional information can be found in the VMD user’s guide.
1 BASICS OF VMD 7
Another useful option is the Mouse → Center menu item. It allows you to
specify the point around which rotations are done.
6 Select the Center menu item and pick one atom at one of the ends of the
protein; The cursor should display a cross.
7 Now, press r, rotate the molecule with the mouse and see how your
molecule moves around the point you have selected.
5 To see the arrangements of atoms in the interior of the protein, use the
new controls on the right bottom part of the window (e) to change the
1 BASICS OF VMD 8
Sphere Scale to 0.5 and the Sphere Resolution to 13. Be aware that the
higher the resolution, the slower the display of your molecule will be.
6 Note in Coloring Method → Name, each atom has its own color, i.e: O is
red, N is blue, C is cyan and S is yellow.
7 Press the Default button. This allows you to return to the default prop-
erties of the drawing method.
8 Choose the Tube style under Drawing Method and observe the backbone
of your protein. Set the Radius at 0.8.
9 By looking at your protein in the tube mode, can you distinguish how
many helices, β sheets and coils are present in the protein?
11 Identify now how many helices, betasheets and coils are present in the
protein.
2 Select Coloring Method → Structure (c) and confirm that the NewCartoon
representation displays colors consistent with secondary structure.
1 In the Selected Atoms text entry Fig. 5(f) of the Graphical Representations
window delete the word all, type helix and press the Apply button or
hit the Enter/Return key on your keyboard. (Do this every time you type
something.) VMD will show just the helices present in our molecule.
3 In order to see the molecule without helices and β sheets, type the follow-
ing in Selected Atoms: (not helix)and(not betasheet)
4 In the section Keyword (c) of the Selections tab (a) you can see properties
that can be used to select parts of a protein with their possible values.
Look at possible values of the Keyword resname (d). Display all the Lysines
and Glycines presents in the protein by typing (resname LYS)or(resname
GLY). Lysines play a fundamental role in the configuration of polyubiquitin
chains.
Selection Action
protein Shows the Protein
resid 1 The first residues
(resid 1 76) and (not water) The first and last residues
(resid 23 to 34) and (protein) The α helix
1 BASICS OF VMD 11
All the previous options provide you with a powerful tool to explore different
parts of your protein or molecule.
4 Repeating the previous procedure, create the following two new represen-
tations:
6 Note, that with the mouse, you can select the different representations you
have created and modify each one independently. Also, you can switch
each one on/off by double-clicking on it or delete each one by using the
Delete Rep button (b). At the end of this section, the Graphical Repre-
sentations window should look like Fig. 8.
T Turn
E Extended conformation (β sheets)
B Isolated bridge
H Alpha helix
G 3-10 helix
I Pi helix
C Coil
1 In the VMD Main window, choose the File → Save State menu item. Write
an appropriate name (e.g., myfirststate.vmd) and save it.
The File → Load State menu item will allow you to load a previously saved
VMD state, just like the file you saved. Although the VMD state allows you to
work with the image and explore the properties of our protein using VMD, you
usually need pictures that can be used in articles or other kind of documents.
VMD can render the image you created and generate an image file that can be
used in other applications, as it is shown in the following steps.
1 BASICS OF VMD 14
2 Using all that you have learned until now, find an appropriate view of
the protein by scaling, rotating and translating the molecule. Turn dif-
ferent representations on and off and improve the resolution and different
properties of the selections you have made. If you want an image of high
quality, put special attention to the resolution of each representation.
3 Be aware of the new representations you created with the Sequence Viewer
Extension and hide or delete them if necessary.
4 Before rendering the image, change the background color by choosing the
Graphics → Colors menu item. There, Choose the Display category, the
Background name and the 8 white color. The background should be white
now.
5 Choose the File → Render... menu item. A window called File Render
Controls will appear in your screen.
6 You can render the image using different packages. Pick TachyonInternal
in the Render using menu.
7 Write the name of the file where the image will be saved in the Filename
text entry, i.e., picture.tga (default is plot.tga).
8 Press the Start Rendering button and the file with your image will be
created. Note that this could take some time. You should end up with an
image file named picture.tga (MacOS X or Unix) or picture.bmp (on
Windows).
9 Close the application that opened the image file in order to continue using
VMD.
Now you are done with the first unit of the tutorial. We hope you have learned
the basic commands of VMD. Also, you have generated two files. The first one
is a VMD state that allows you to restart a VMD session, and use or modify all
that you did in this unit. The second file is an image file of your protein that
can be used in other image-viewing applications.
2 MULTIPLE MOLECULES AND SCRIPTING 15
1 Open the Molecule File Browser from the File → New Molecule. . . menu
item.
You need to load the X-ray crystal structure of ubiquitin. You can do this in
the same way you did in Unit 1, or directly in the command line:
You should now see two superimposed and unaligned molecules. One is the
original crystal ubiquitin. The other one is surrounded by a cube full of water
molecules.
1 Double-click on the name of the first molecule in the Main window molecule
listing. The Rename Molecule dialog box should pop up. Type in crystal.
Do the same thing for the second molecule, and call it simulation.
At this point, your Main window should look like Fig. 10. In front of the
molecule name, there are four letters that you can use to manipulate your
molecules.
Figure 10: Main window with initial and final coordinates loaded into two
separate molecules.
F stands for “Fixed,” meaning that that molecule won’t move when you move
the scene around. When the F is black, the molecule is fixed; when it is grayed
out, the molecule is mobile.
5 When you are done, make sure that only the crystal molecule is “Dis-
played” and that none of the molecules are “Fixed.”
6 Finally, double-click under the T column to the left of the crystal molecule.
The letter T should now appear in front of it. This makes it the unique
“top” molecule. Making a molecule top makes it a target for scripting
commands.
To execute Tcl commands, you will be using a convenient text console called
Tk Console.
You will initially focus on the very basic of Tcl/Tk. Here are Tcl’s set and
puts commands:
2 MULTIPLE MOLECULES AND SCRIPTING 18
One of the most important aspects of Tcl is that you can embed Tcl commands
into others by using brackets. A bracketed expression will automatically be sub-
stituted by the return value of the expression inside the brackets:
4 Create some commands using brackets and test them. Here is an example:
set result [ expr -3 * $x ]
puts $result
1 After making sure that the crystal molecule is the top molecule (if not,
double-click on T). Open the Graphical Representations window using the
Graphics → Representations. . . menu item.
2 MULTIPLE MOLECULES AND SCRIPTING 19
The PDB B-factor field. The “B” field of a PDB file typically
stores the “temperature factor” for a crystal structure and is read
into VMD’s “Beta” field. Since we are not currently interested in
this information, we can recycle this field to store our own numerical
values. VMD has a “Beta” coloring method, which colors atoms
according to their B-factors. By replacing the Beta values for various
atoms, you can control the color in which they are drawn. This is
very useful when you want to show a property of the system that
you have computed, which is not supported out-of-the-box by VMD.
The first argument to atomselect is the molecule ID (shown to the very left of
the Main form), the second argument is a textual atom selection like what you
have been using to describe graphical representations in unit 1. The selection
returned by atomselect is itself a command which you will learn to use.
4 Type $crystal num. Passing num to an atom selection returns the number
of atoms in that selection. Check that this number matches the number
of atoms for that molecule (as read from the Main form).
5 Type $crystal set beta 0. This resets the “beta” field (which is dis-
played) to be zero for all atoms. As you do this, you should observe that
the atoms on your screen will suddenly change to a uniform color (since
they all have the same beta values).
Atom selections are just references to the atoms in the original molecule. When
you change a property (e.g. beta value) of some atoms through a selection, that
change is reflected in all the other selections that contain those atoms.
2 MULTIPLE MOLECULES AND SCRIPTING 20
7 Let’s label all hydrophobic atoms by setting their beta values to 1. You
should know how to do this now: $sel set beta 1. If the colors in the
OpenGL Display do not get updated, click on the Apply button at the
bottom of the Graphical Representations window.
Examples of atomic properties. You can get and set many atomic
properties using atom selections, including segment, residue and
atom names, position (x, y and z), charge, mass, occupancy and
radius, just to name a few.
8 You will now change a physical property of the atoms to further illustrate
the distribution of hydrophobic residues. Type $crystal set radius
1.0 to make all the atoms smaller and easier to see through, and then $sel
set radius 1.5 to make the hydrophobic residues larger. The radius field
affects the way that some representations (e.g., VDW, CPK) are drawn.
You have now created a visual state that clearly distinguishes which parts of
the protein are hydrophobic and which are hydrophilic. If you have followed the
instructions correctly, your protein should resemble Fig. 12.
Figure 12: Ubiquitin in the VDW representation, colored according to the hy-
drophobicity of its residues.
2 MULTIPLE MOLECULES AND SCRIPTING 21
Atom selections are useful not only for setting atomic data, but also for get-
ting information. Let’s say that you wish to communicate which residues are
hydrophobic, all you need to do is to create a hydrophobic selection and use get
instead of set.
10 Let’s try this solution. Each residue has one and only one α-carbon
(name CA = alpha):
set sel [atomselect top "hydrophobic and alpha"]
$sel get resname
Aha! It worked.
11 You can also get multiple properties simultaneously. Try the following:
$sel get resid
$sel get {resname resid}
$sel get {x y z}
12 Once you are done with a selection, it is always convinient to delete them
in order to save memory by typing:
$sel delete
Even though the two molecules are very different (the crystal structure has no
hydrogens), the selections that you created both contain the exact same atoms.
VMD provides a command – measure fit – for finding the best fit between
two selections corresponding to the same atoms:
5 Find the transformation matrix M that will best map the first selection
onto the second by typing:
set M [measure fit $atomsel1 $atomsel2]
6 Apply the matrix you just found to the entire initial molecule (you had
previously defined an atom selection called crystal for this), by typing:
$crystal move $M
In the OpenGL window, the two molecules should now be aligned based on
the positions of their α-carbons. Notice that some parts of the molecule are
well-aligned, whereas other dangling ends and loops seem more floppy (they
have moved more during the equilibration). Realigning the molecules using the
β strands, in addition to the α-helices, results in an alignment resembling Fig 13.
2 MULTIPLE MOLECULES AND SCRIPTING 23
Figure 13: Initial and final states of ubiquitin after spatial alignment.
2 To see the new beta values, you need to set the Coloring Method of the
crystal molecule to Beta, and hide the simulation molecule (by double-
clicking on D in the VMD Main window).
The crystal molecule should now be colored according to the total displace-
ment that occurred during the simulation. To have a better idea of what went
on, we would like to adjust the color scale in a useful way.
values used for the beta values color scale. Make sure that the right rep-
resentation (of the crystal molecule) is selected, then enter 0 and 5 and
click on Set. This sets the color range to scale between 0 and 5 Å.
4 Now, bring up the Color Controls window (Fig. 15) by choosing the
Graphics → Colors. . . menu item from the VMD Main window. Then
select the Color Scale tab.
Figure 15: The Color Controls window showing the Color Scale tab.
5 In the color scale Method menu, select the BWR color scheme. This will
show residues with a low displacement (0 Å) in blue, those with a high
displacement (5 Å) in red, and those in between as white.
6 You can now also adjust the color scale Midpoint to shift the level of atomic
displacement that will be assigned to white. Try assigning a midpoint of
0.1.
You have now seen how to manipulate continuous color scales on custom data.
Look at your molecule (it should resemble Fig. 16). You should now be able
to determine which parts of ubiquitin are stable (blue) and which are floppy
2 MULTIPLE MOLECULES AND SCRIPTING 25
(red). In general, the dangling ends and loops are flexible, whereas the helices
and β strands are much more rigid.
Trajectory files are normally binary files that contain several sets of coordinates
for the system. Each set of coordinates corresponds to one frame in time. An
example of a trajectory file is a DCD file. The trajectory files do not contain
information of the system contained in the protein structure files (PSF). So we
first need to load the parameter file, and then add the trajectory data to this
file, as explained in Unit 2.
3 In the Molecule File Browser window, click on the Browse button. Make
sure that ubiquitin.psf is selected on the menu. Browse for pulling.dcd
in vmd-tutorial-files, click OK, and click on the Load button again.
You will be able to see the frames as they are loaded into the molecule.
4 After the trajectory finishes loading, you will be will be looking at the last
frame of your trajectory. To go to the beginning of the trajectory, you will
use one of the Animation Tools that will be explained extensively later in
the tutorial. In the Main menu, click on the button in the lower left.
In the next section, you will learn how to create representations with a useful
feature called macros. Once you create some representations relevant to this
trajectory, the following section will teach you how to use the Animation Tools
to look at trajectories.
3.2 Macros
You will now create similar representations to the ones you generated in Unit
1. While creating these representations, you will learn macros. A macro is text
that represents a selection. It is useful to create macros when you use certain
selections often. Macros are created with the atomselect command you learned
in unit 2.
Ubiquitin has a mixed β sheet with five strands. The β sheet play a major role
in the unfolding of the protein. To create a macro for these strands:
This will create a macro for the first β strand, which includes residues 2 to 6.
3 TRAJECTORIES, MACROS AND LABELS 28
For the other strands, you will find out which residues belong to them by using
the sequence viewer introduced in Unit 1, and then create similar macros:
3 Make sure you are in the first frame of the trajectory, as STRIDE (the
program that calculates secondary structure in VMD) will determine the
structure on that frame.
5 With the mouse, click and drag to highlight the second β strand. This
action will create a representation in the Graphical Representations win-
dow.
This will create a macro called bstrand2 that will contain residues 12 to 16
of chain U, which corresponds to the protein.
8 Note that the sequence viewer extension locates five β strands. You have
created macros for the first two; create similar macros for the other three
β strands using the sequence extension as done for bstrand2.
Once a macro is created, you can refer to it both in the Tk Console, and in the
Representations selections.
Macros you have created and other macros that come with VMD can be seen
in the Selections tab of the Graphical Representations window. The macros are
listed in the Singlewords window. Clicking on a macro will show its definition
in the Macro Definition window. Double-clicking on it will select it and put its
definition on the Selected Atoms form.
You will now create a representation with the third and fifth β strands:
3 TRAJECTORIES, MACROS AND LABELS 29
As you can see, macros can be very useful. When saving your work in a saved
state, macros are included in the saved state file.
Macros. You can create several macros and store them in a VMD
preferences file .vmdrc in your home directory (Windows uses the file
vmd.rc). VMD will look for this file upon startup and will recognize
all your macros. For more information of the VMD startup files, refer
to the VMD user’s guide.
To finish this section, you will create a very interesting representation, that
shows a key feature of the trajectory we are looking at. This is an H-bonds
representation.
17 Save a VMD state of this session, so if you want to come back and keep
on working in this tutorial, you don’t have to work through those repre-
sentations again. Do this with the File → Save State... menu item, as
done in Unit 1.
Reusing saved states. When you have a saved state for a system,
you can use it later for viewing different coordinates (PDB or a
different trajectory), if these have the same PSF file. You can do
this by following these steps:
1 Try using the button to jump to the end of the trajectory and go back
to the beginning with the button. You can see the final and initial
states of the trajectory, that correspond to the unfolded and folded states
of the protein.
You can click on the slider and drag it back and forth to navigate
through your trajectory. You can stop at anytime you want, or go at the speed
you need. This is helpful when you are looking at a trajectory and want to spot
the time when something interesting happens.
3 Using the slider, observe the behavior of the water around the protein at
the beginning of the trajectory.
Minimizing free energy. Note how the shape of the water box
changes from a cube to a sphere. To minimize free energy, the water
adopts the configuration that exposes less surface to the vacuo, that
is, a sphere! Check how fast the water comes to this configuration
(Each frame step corresponds to 10 ps. )
On the lower part of the Animation tools, you will find all the tools necessary to
play an animation without using the slider. This is done with the Play buttons,
that go forward and backward.
5 Play the trajectory backward. Do you think this is the way the protein
would fold in nature?
There are two ways to change the speed of your animation. You can adjust the
speed of the play using the Speed Slider. You can also adjust the step size. This
is done using the Step Window. If this step is set to 3, the animation will show
every 3rd frame, so it will make it faster.
6 Set the step to 5, and play the trajectory. Note that it plays faster, but it
also looks less smooth than before. However, this can come handy if you
are looking at long trajectories.
3 TRAJECTORIES, MACROS AND LABELS 33
You can also jump to a frame in your trajectory, by entering the frame number
in the window at the left of the Animation Tools.
NOTE: The Animation Tools you learned cycle through the frames of the Top
molecule, but apply to all Active molecules.
3.4 Labels
In VMD, you can place labels to get information on a particular selection. We
will now make use of those labels for fun and profit. Labels are selected with
the mouse. In this example, we will cover labels that can be placed on atoms
and bonds, although angle and dihedral labeling are also possible.
1 Choose the Mouse → Labels → Atoms menu item. The mouse is now set
to “Display Label for Atom” mode. You can now click on any atom on
your molecule and a label will be placed into this atom. Clicking again on
it will erase the label.
2 Choose the Mouse → Label → Bonds menu item. This selects the “Display
Label for Bond” mode.
3 TRAJECTORIES, MACROS AND LABELS 34
You will make a VDW Representation for the α carbon of Lysine 48 and of the
C terminus. In the pulling simulation, the former is kept fixed, and the latter
is pulled at constant force of 500 pN.
PDB and VMD atom numbering. Note that the atom number of
these atoms in the pdb file is 771 and 1243. VMD starts counting
the index from zero, so the text in the Representation should be
the numbers that VMD understands. This is only the case for index,
since VMD does not read them from the PDB file. Other keywords,
such as residue, are consistent with the PDB file.
6 Now that you can see them, click on both atoms (one after the other). You
should get a line connecting the two atoms. The number appearing next
to the line is the distance between the two atoms in angstroms (Fig. 20).
Labels. The shortcut keys for labels are 1: Atoms and 2: Bonds.
You can use these instead of the Mouse menu. Be sure the Open
GL display window is active when using these shortcuts.
3 TRAJECTORIES, MACROS AND LABELS 35
Figure 20: Bond selection of fixed and pulled atom in simulation. Both atoms
selected display labels in black. The bond is shown in blue, with the value of
the distance between the atoms in angstroms displayed.
7 There are more things you can do with labels, in the Graphics → Labels
menu item. In the left side of the window (Fig. 21), there is a pull-down
menu where you can choose the type of label (Atoms, Bonds, Angles,
3 TRAJECTORIES, MACROS AND LABELS 36
Dihedrals). For now, keep it in Atoms. You can see the list of atoms for
which you made a label.
8 Click on one of the atoms. You can see all the information of the atom
displayed. You can delete, hide, or show the label by clicking on these
buttons.
Note that this information is useful to make selections. The information about
the atom corresponds to the current frame, and is updated as the frame is
changed.
9 Now, in the Label window, choose the label type Bonds, and select the
bond you labeled. Note that the information given corresponds to only
the first atom in the bond, but the number in the Value field corresponds
to the length of the bond in angstroms. Click on the Graph tab. Select
the bond you labeled between atoms 770 and 1242. Click on the Graph
button. This will create the plot of the distance between these two atoms
over time. You can also save this data to a file by clicking on the Save
button.
xmgrace. VMD uses the 2-D plotting program xmgrace. This pro-
gram is available from http://plasma-gate.weizmann.ac.il/Grace/.
In Mac OSX, xmgrace runs in the X11 environment. Make sure
X11 is running in order for xmgrace to start.
Figure 22: Label window Plot of selected bond over time created with the Graph
button.
equilibration of the ubiquitin system. You will use a short script to calculate
the RMSD of the protein during the MD run, and determine if the system is
equilibrated and ready to simulate.
3 TRAJECTORIES, MACROS AND LABELS 38
2 Load the equilibration trajectory into the psf file by going to the File → Load
Data Into Molecule. The file is equilibration.dcd.
3 Turn on the water representation and take a look at the trajectory with
the Animation tools that you learned before.
Now you will find out how to determine if the protein is equilibrated. One
important factor to determine this is looking at the RMSD of a protein in a
trajectory.
4 The script we are going to use is called rmsd.tcl. This is the script con-
tent:
3 TRAJECTORIES, MACROS AND LABELS 39
• Get the number of frames in the trajectory and assign this value to
the variable nf
set nf [molinfo top get numframes]
• Select the first frame of the molecule to be the one other frames will
compare to. The selection contains the atoms in the backbone of the
protein, excluding hydrogens:
set frame0 [atomselect top "protein and backbone and noh" frame 0]
• Calculate the matrix that will fit both selections. Apply this matrix
to the second selection to align the molecules:
$all move [measure fit $sel $frame0]
• Calculate the RMSD value between these two selections, and write
it to file:
puts $outfile "[measure rmsd $sel $frame0]"
You can use the script for the system to test for equilibration.
6 Type source rmsd.tcl in the Tk Console. This will perform all the
commands in the script. The script will write a file rmsd.dat that will
contain the value of the RMSD of the protein backbone against time.
Outside of VMD, you can use some plotting program to see this data. Exam-
ples of these are gnuplot, xmgrace, excel, Mathematica.
7 Use one of the above programs to plot the file rmsd.dat (For example, in
Unix, you can type xmgrace rmsd.dat in a terminal). Can you see the
RMSD curve flattening? This means your system is equilibrated!
This ends the VMD tutorial. We hope that you learned a lot with it, and that
you will make a great use of all the capabilities VMD has to offer.