VMD Basics for Visualization
Learning objectives
- Learn the basic commands of VMD necessary for exploring 3D
structures.
- Learn how to visually inspect molecular properties, such as bond
distances, angle measurements, and dihedrals.
Use VMD to provide quick trajectory analysis.
Tutorial
1.1 VMD Overview
VMD is a powerful high-performance, cross-platform molecular graphics viewer developed by the Theoretical and Computational Biophysics Group (TCBG) that is widely used (among other things) for displaying static and dynamic structures, viewing sequence information, and performing dynamic analysis. There is an online User’s Guide as well as a number of detailed tutorials available. Further support is provided by the VMD Mailing List.
1.2 How to Access VMD
VMD is accessible through Expanse, or can be downloaded and run locally on your laptop or workstation.
To access from Expanse:
[user@expanse] module spider vmd
Load the appropriate modules required for VMD.
Then, typ the following to access VMD:
[user@expanse] vmd
To Download and Install on your Local Computer:
Dowload from this link here. Once downloaded, you can open VMD through the icon.
If you are having trouble using VMD on a Windows machine, you can install ubuntu as a Windows subsystem for linux (wsl) and install VMD there. A quick guide to do so can be foundhere.
1.3 VMD Basics
This tutorial will introduce you to the 3 systems that will be used throughout the remainder of the tutorials:
Acetic Acid in the Gas Phase
Acetic Acid in Solution
MTR1
TYK2 with 2 ligands
The goal for this tutorial is to practice using both VMD and CPPTRAJ to obtain a visual understanding of each system.
All of the input files for this tutorial can be found in /expanse/projects/qstore/amber_ws/tutorials/VMD_CPPTRAJ_Basics/input_files. Please copy them to your working directory. Additionally, all output files produced by this tutorial can be found in /expanse/projects/qstore/amber_ws/tutorials/VMD_CPPTRAJ_Basics/output_files should you need to access them. You will begin by loading one of our simplest systems, an acetic acid molecule in a solution of water and ions. To do so:
Go to the directory containing the input files for acetic acid: /expanse/projects/qstore/amber_ws/tutorials/VMD_CPPTRAJ_Basics/input_files/acetic_acid.
Loading Through Expanse:
[user@expanse] vmd centered.acetic_acid_aq.pdb
Tutorials/docs/WorkshopTutorials/2024_Amber_Workshop_UCSD/01_vmd_visualization/imgs Loading Through Personal Computer GUI:
Open VMD, find the VMD Main window, go to Main Menu → File → New Molecule → Browse and find within your files, centered.acetic_acid_aq.pdb. Press Load.
You should see something like this:

Figure 1. VMD display windows.
As you can see, VMD consists of 3 windows:
Display
VMD Main
Graphical Representations
The VMD Main is the control window for VMD, and you see which molecules are loaded.
VMD contains a lot of gadgets and options for visualization and analysis, so carefully float your mouse over each menu option in the VMD Main to briefly explore the sub-menus. For example,if you go into the Display menu, you can change the settings of the display…play around with different settings to see how it affects how the system is displayed.
Moving the molecule around in VMD is quite easy; you have the option of going through the Mouse menu, or through keyboard shortcuts:
To rotate molecule: r
To translate molecule: t
To scale (zoom-in or out): s
To center the system in the display: =
1.4 Customizing Representations
Representations are used to separate out the individual components within the system, such as distinguishing the acetic acid (solute) from the surrounding waters and ions (solvent).
Under the Graphics menu, click on Representations.
The Graphical Representations window is typically already up on your screen, but if it is not, selecting it will cause it to appear. This window provides a wide range of different ways to visually represent the molecules in your system, allowing for a more meaningful analysis of the structural organization and interactions.
In the Graphical Representations window, take time to look over the different components.
At the top, you can see which system is selected. If you have multiple systems loaded, you can use the down arrow to toggle through them and view the representations for each system. For now, we only have one system loaded. There are two buttons under Create Rep and Delete Rep. The Create Rep will create a new representation, while the Delete Rep will delete. If you want to simply turn off a representation, double-click on the representation. It will turn red and be off. The Selected Atoms box is where you type what will be your selection for the representation at hand. Underneath that are four tabs:
Draw style
Selections
Trajectory
Periodic
Draw style is where you have the creative ability to change how the selection is represented. The Coloring Method is where you define how the colors are assigned to molecules. The Drawing Method determines the shapes of its atoms, bonds and other components. And the Material can change shading or how the objects appear. The default representation selection is all. If you need additional guidance on the available selection types, the Selections tab provides a list of options that you can browse. When a trajectory is loaded into VMD, you can smooth the animation by changing the settings under the Trajectory tab. Lastly, the Periodic tab is a good place to check if your periodic unit cell box is properly established. Here you can display multiple unit cells.
Make a new representation by clicking Create Rep
Type “all not water”.
Change the Drawing Method to Licorice.
Turn off the other representation “all”.
You should see now that only ions and the acetic acid are selected and displayed:

Figure 2. Representation all not water displayed.
Now, create a representation to select only the acetic acid.
Create a new representation and type “resname L01”.
Change the Drawing Method to CPK.
Turn off the other representations.
Press = to zoom into the molecule.

Figure 3. Acetic acid molecule.
1.5 Measuring Geometrical Properties
Next, find the Mouse menu in VMD Main.
Go to the sub-menu, and find Label.
Here, you can switch-on selection modes to label atoms, bonds or angles in order to obtain metrics about the system. You can either use the selections seen in the sub-menu or you can use these keyboard shortcuts:
To select an atom, press 1 and then make your selection. It will add a label that contains the residue ID and the atom name.
To select and measure a bond distance between two atoms, press 2. First click on one atom, then click on the other. The distance between the two atoms will pop up in Å.
To select and measure an angle, press 3 and carefully select three atoms of choice. A label for the angle will be displayed.
To select and measure a dihedral angle between four atoms, press 4 and carefully select the atoms. A label for the angle will be displayed.
You should get very comfortable switching between the different selection types using the keyboard.
Try adding a label to each of the atoms within the acetic acid molecule. Press 1 on the keyboard and label each atom within the molecule.
If labels are not showing up, try zooming out first.
Rotate the molecule to see the labels.
With the labels displayed, you can now see that the acetic acid molecule is identified by the name “L01”:

Figure 4. Labels of the atoms within acetic acid molecule.
A helpful keyword for selecting and finding atoms within a certain distance is “within”.
Create a new representation: “(all not water) and within 10 of resname L01”.

Figure 5. Closest ions to acetic acid molecule.
This selection will select only the ions that are within 10 Å, due to the selection in parentheses “all not water”.
From here, use the bond selection tool (2 on the keyboard) to label the distance of the closest ion.

Figure 6. Distance between closest ion to acetic acid molecule.
Try measuring the dihedral angle between H4, O2, C2, and C1
Remember: to measure a dihedral, you must press 4 and select 4 atoms.

Figure 7. Dihedral angle of acetic acid molecule.
All of the labels that you create are stored under Graphics → Labels. Here, you can find more specifications regarding the atom, bond or angle that you had labeled. For example, you can see what residue a labeled atom belongs to, turn labels on or off, or remove labels completely. Feel free to explore this window and all of its different components.
1.6 Keywords and Aligning
Learning how to create meaningful representations in VMD that can capture exactly what you need takes time and practice. However, there are a few tricks to quickly and efficiently select your desired components. You already were introduced to the keyword within earlier in the tutorial. This keyword helps to select atoms within a certain spatial proximity. This is an essential element to include in your atom selection when you want a fast way to narrow down certain interactions, distances or spatial relationships.
Another important keyword is same. This keyword groups atoms together based on shared properties. For example, you can type “same chain as resname ALA”, or “same residue as name O”. Both of these keywords will become clearer as you implement them.
For this section, you will be looking at trajectory files from a system containing the protein TYK2 with two chemically distinct ligands with differing compositions, L00 and L26. This system will be used for Alchemical Free Energy Simulations in future tutorials, where you will calculate the relative free binding energies of the two ligands bound to this protein.
Find the directory /expanse/projects/qstore/amber_ws/tutorials/VMD_CPPTRAJ_Basics/input_files/TYK2.
In this directory, there is one topology file and two trajectories, endstate1_.nc and endstate2_.nc, depicting the two end-states. At one end state, ligand L00 is intact, while L26 is a noninteracting, containing “dummy atoms”. The other end state will be the mirrored opposite, in which L00 is the noninteracting dummy atom, while L26 interacts. This will be discussed in further detail in the subsequent tutorials, but for now, understand that this system is unique when compared to the other systems you have investigated thus far. It is not a typical MD simulation trajectory.
Find the terminal once again to open the first endstate of the system:
[user@expanse] vmd TKY2_L00_L26.parm67 endstate1_.nc
If you are using VMD through a Windows operating system: VMD will not recognize the trajectory file, as Windows does not support the NetCDF plugin for VMD. Therefore, you must use the trajectory file with the DCD extension:
[user@expanse] vmd TKY2_L00_L26.parm67 endstate1_.dcd
Once loaded in VMD, create the following representations:
protein
resname L26
resname L00
name CL3
name CL1 CL2
Change the Drawing Method of resname L00 to CPK with Sphere Scale set at 0.8.
Change the Drawing Method of resname L26 to CPK with Sphere Scale set at 0.8.
Change the Coloring Method→ColorID→12 for both name CL3 and name CL1 CL2.
This changes the coloring of chlorine so you can visually distinguish it. The selection is the atom names. You could also change the color of the chlorine in the either L00 or L26 by making a selection based on atom mass, mass 35.450001 . When you turn on ligand L00, only name CL1 CL2 should be on. Ligand L26 should have name CL1 CL2 and name CL3 on.
Align the frames of the trajectory to the first frame, like you did before calculating the RMSD with MTR1.
Extensions→ Analysis→RMSD Trajectory Tool.
Keep the “protein” as the atom selection.
Click the Align button.
Turn off the “protein” representation.
Turn of the representation(s) for L26, in order to isolate L26.
Zoom in on the ligand.
Most likely, the display is of the last frame in the trajectory. To have the display show the first frame:
Click either the rectangle in the animation toolbar at the bottom of VMD Main, and slide it all the way to the left.
Or:
Type “0” in the white box left to the animation toolbar slider.
Visually inspect L00.
Turn off L00 representation(s) and turn on L26 representation(s).
Visually inspect L26.
When visually assessing each ligand, note the difference in their structures. differ in structure.

Figure 8. Ligand L26.
Once you are done with L26, turn it off, and turn L00 representation back on. Do the same inspection.

Figure 9. Ligand L00.
Now, you are going to make use of those special keywords to observe variance in the number of hydrogen-bonding contacts between the ligands and the protein. Hydrogen bonding has the potential to be a factor in the binding affinity.
Add these representations with Licorice as the Drawing Method
same residue as (protein within 3 of resname L26)
same residue as (protein within 3 of resname L00)
The selection in parentheses “protein within 3 of resname L26” will select the atoms that are within that distance. 3 Å is an appropriate distance cutoff to highlight potential hydrogen-bonding contacts. Based on the selection within the parentheses, the “same residue as” will select the entire residue that the selection in parentheses belongs to. Moreover, if you were to just type the selection within the parenthesis, you would see that only the atoms (not entire residues) of the protein that are within 3 Å of ligand L26 pop up. The same keyword will select the entire residue that pops up from that selection.Parentheses and keywords allow for flexible and efficient selections.
Turn off/on the representations pertaining to each ligand to examine the interaction and spatial arrangement of each ligand one at a time.
You should notice that both ligands share the same number of hydrogen bonding contacts, VAL94.

Figure 10. Interactions between TYK2 and Ligand L26.

Figure 11. Interactions between TYK2 and Ligand L00.
Once again, turn off the representation resname L00 so that resname L26 is only visible.
You will now look at the animation of the trajectory to see if you can determine which ligand is the “dummy atom” in this endstate1_.nc trajectory and which ligand is interacting. To do so:
Play the animation of the trajectory using the play button on the far right of the animation toolbar.
Set the animation speed to a slower pace, so that you can see the movement.
Hint: pay attention to the tail end of the ligand (where the L26 is different from L00).
Repeat this process with ligand L00.
After watching each ligand throughout the trajectory, can you determine which ligand is the “dummy atom”, i.e., which ligand is non-interacting in endstate1?
1.7 Calculating Root-Mean-Square Deviation (RMSD)
Now, you will learn how to use VMD to calculate an RMSD. This time instead of loading a PDB file, you will now load a trajectory file of the MTR1 system. The trajectory is from an AMBER MD simulation, and this system will be used in the additional tutorials. In the directory /expanse/projects/qstore/amber_ws/tutorials/VMD_CPPTRAJ_Basics/input_files/MTR1, you will see the files obtained from MD simulations of the RNA enzyme system, MTR1. The files are MTR1_prot-run.parm7 and centered.MTR1_prot-run.nc (or with .dcd extension).
Open this trajectory by either starting a new VMD session (quitting your current session and restarting VMD), or opening it in the same VMD session.
To open the trajectory of MTR1 in the current session, you can follow the steps we took before to loading a system:
Main Menu → File → New Molecule → Browse.
Find the parameter file (MTR1_prot-run.parm7) and select.
Once selected, the Determine file type: should read AMBER7 Parm.
Now, to load the trajectory file:
Browse again and find “centered.MTR1_prot-run.nc” or “centered.MTR1_prot-run.dcd” for Windows Users. Select it.
Press Load.
If you are using the terminal to load a new VMD session:
You can type:
[user@expanse] vmd MTR1_prot-run.parm7 centered.MTR1_prot-run.nc
*Larger trajectories will take longer to load into VMD.

Figure 12. Solvation box of MTR1.
If you decided to load both systems into one VMD session, you will now see in VMD Main that there are multiple molecules loaded.
Now you have the option to remove the display of one by clicking the D next to the molecule. It will turn red, indicating that it is off.
Additionally, the Graphical Representations window will have an option to toggle through systems to see their representations.
If you have multiple systems loaded in your VMD session, hide the acetic acid system so we can focus on the MTR1 trajectory.
With a trajectory now loaded, you can now make use of the animation toolbar at the bottom in VMD Main. The slider will transition through the frames, with the number to the left of the slider indicating which frame you are viewing. You can also play the trajectory as an animation, change the speed of the animation and change the animation type (ex: Loop).
To get started with our MTR1 trajectory analysis, create the following representations:
all not solvent
resid 9 44 62
water
resid 69
Change the Drawing Method to match with the representations below:

Figure 13. Residues in MTR1 that make up the catalytic center.
As mentioned before, we will use VMD to calculate its Root Mean Square Deviation (RMSD). RMSDs are helpful in understanding how much the structure deviates from the original starting structure over the time of the simulation. This is an important metric to support if you have a stable structure or not.
To perform this analysis:
Turn off all representations besides all not solvent. This will isolate the ribozyme:

Figure 14. MTR1.
Access the RMSD Trajectory Tool by going to:
Extensions→ Analysis→RMSD Trajectory Tool.
An interface will pop up. In the left white box, you can select the atoms (same way that you would make a representation) to select the region of the system you want to perform the RMSD calculation on. For example, the default is “protein”, which will perform the RMSD of the entire protein, if you were to have one.
For this system, replace “protein” with “nucleic” to select the entirety of the ribozyme.
You can be more specific with your selection for an RMSD calculation, such as, typing “resid 9 44 62 69”. The tick boxes you see allows for quicker selections to add on:
Backbone: adds on atoms within the backbone.
Trace: adds ‘and name CA’.
noh: which will exclude hydrogens from the atom selection.
noh should already be selected for you. Keep it selected.
Once you made your selection:
Press the Align button.
You might see a shift in the structure, that is VMD aligning the molecule to your selection (”nucleic”) from frame 1. If you have multiple structures loaded, you will see them in the table within the RMSD Trajectory Tool window. If this were the case, you decide which structure is the Reference mol and which structures to align to that. You do not need to worry too much about that now.
It is important to note aligning with Align should be a step that you do to set up a polished version of the trajectory for visualization. If you do not align your molecule throughout the frames in your trajectory, the structure will jump all around as it switches frames, making it impossible to get a grasp on things.
After you have hit the Align button:
Press the RMSD button.
The RMSD values for calculation will print in the table, including the average RMSD and the standard deviation.

Figure 15. RMSD Trajectory Tool table.
To gain further insight into the meaning of the RMSD:
Tick the box Plot, and click RMSD again.
The plot generated depicts the RMSD (in Å) with each frame of the trajectory. This plot provides valuable insights into the movement of your selection. High RMSD values should be noted, as that indicates that the molecule is undergoing significant structural changes. If the RMSD continues to climb, this is indicative of the structure either failing to reach equilibrium or that there is instability in the structure. If this were to be the case for you, it is suggested that you narrow down your selection to try and investigate which regions are responsible for the most change. In general, RMSDs tend to climb throughout the beginning of simulation, but there is a period in which it stabilizes. You must have a stable structure to depart from for further computation exploration.
Save the generated plot by ticking the Save box and click the RMSD button again.
A trajrmsd.dat file will be produced.

Figure 16. RMSD graph produced by RMSD Trajectory Tool.
As you can see, the RMSD is trending upwards, however, if you look at the value of Å, the RMSD is very low. This indicates the structure is quite stable.
1.8 Image Rendering
Another tool of VMD is to render high-quality images and animations of your system for posters, presentations or publications. We will quickly walk through the steps to obtain a high-quality image on this MTR1 system. First you must set up the scene that you want to display for your high-quality image.
Turn off all of the representations besides “all not solvent”.
Select “all not solvent”, and change the Drawing Method to NewRibbons.
Under Material, change to EdgyShiny.
Think of rendering the image as taking a screenshot or snapshot, therefore adjusting the view by rotating or zooming in or out to obtain a full view of the ribozyme. We also do not want to have the axis on in our image:
Turn off the axis by navigating to the VMD Main window and selecting Display →Axes→Off.
Next, you can change the projection mode:
From the Display menu, select Perspective.
VMD offers two projection modes including Perspective and Orthographic. The Perspective mode shows the structure with perspective, meaning objects further from the viewer appear smaller than those closer. This mode is useful for generating images. The Orthographic mode provides a uniform scale across the entire image, which is useful for trajectory analysis.
You can also turn the Depth Cueing on or off by:
Display→Depth Cueing.
This option provides a realistic 3D view with depth perception.
You can change the background color to white through:
Graphics→Colors.
Select Display→Background under the Categories.
Scroll up till you see white, and select it.
Now, once you have the display to your liking, render the image by going to:
File→Render.
In the pop-up window, the default program used to render the image is “Snapshot (VMD OpenGL window)”. This is low quality and not recommended for obtaining high-quality images. In the drop-down menu:
Select Tachyon (internal, in-memory rendering.
Change the filename and location for the image by clicking the Browse button.
Click the Start Rendering button.
Your high-quality image will pop up! If it is not to your liking, feel free to change the settings, adjust the view and render again.

Figure 17. High-quality rendered image of MTR1.