VMD
VMD
VMD
Version 1.9
March 9, 2011
NIH Resource for Macromolecular Modeling and Bioinformatics
Theoretical and Computational Biophysics Group
1
Beckman Institute for Advanced Science and Technology
University of Illinois at Urbana-Champaign
405 N. Mathews
Urbana, IL 61801
http://www.ks.uiuc.edu/Research/vmd/
Description
The VMD Users Guide describes how to run and use the molecular visualization and analysis
program VMD. This guide documents the user interfaces displaying and grapically manipulating
molecules, and describes how to use the scripting interfaces for analysis and to customize the
behavior of VMD.
VMD development is supported by the National Institutes of Health grant P41-RR005969.
1
http://www.ks.uiuc.edu/
Contents
1 Introduction 10
1.1 Contacting the authors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.2 Registering VMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.3 Citation Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.4 Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.5 Copyright and Disclaimer Notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.6 For information on our other software . . . . . . . . . . . . . . . . . . . . . . . . . . 14
2 Hardware and Software Requirements 16
2.1 Basic Hardware and Software Requirements . . . . . . . . . . . . . . . . . . . . . . . 16
2.2 Multi-core CPUs and GPU Acceleration . . . . . . . . . . . . . . . . . . . . . . . . . 16
3 Tutorials 17
3.1 Rapid Introduction to VMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 Viewing a molecule: Myoglobin . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.3 Rendering an Image . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.4 A Quick Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.5 An Introduction to Atom Selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.6 Comparing Two Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.7 Some Nice Represenations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.8 Saving your work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.9 Tracking Script Command Versions of the GUI Actions . . . . . . . . . . . . . . . . 22
4 Loading A Molecule 24
4.1 Notes on common molecular le formats . . . . . . . . . . . . . . . . . . . . . . . . . 24
4.2 What happens when a le is loaded? . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.3 Babel interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.4 Raster3D le format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
5 User Interface Components 27
5.1 Using the Mouse in the Graphics Window . . . . . . . . . . . . . . . . . . . . . . . . 27
5.1.1 Mouse Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
5.1.2 Pick Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
5.1.3 Hot Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
5.2 Using the Spaceball in the Graphics Window . . . . . . . . . . . . . . . . . . . . . . 31
5.2.1 Spaceball Driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.3 Using the Joystick in the Graphics Window . . . . . . . . . . . . . . . . . . . . . . . 33
2
5.4 Description of each VMD form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.4.1 Main Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.4.2 Main Form Molecule List browser . . . . . . . . . . . . . . . . . . . . . . . . 34
5.4.3 Main Form Animation Controls . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.4.4 Molecule File Browser Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.4.5 Mouse Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
5.4.6 Display Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4.7 Graphics Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.4.8 Labels Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.4.9 Color Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.4.10 Material Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.4.11 Render Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.4.12 Tool Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.4.13 Simulation Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
5.4.14 Sequence Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.4.15 RamaPlot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
6 Molecular Drawing Methods 60
6.1 Rendering methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
6.1.1 Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
6.1.2 Bonds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
6.1.3 DynamicBonds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.1.4 HBonds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.1.5 Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.1.6 VDW . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.1.7 CPK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.1.8 Licorice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.1.9 Polyhedra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.1.10 Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.1.11 Tube . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.1.12 Ribbons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.1.13 NewRibbons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.1.14 Cartoon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.1.15 NewCartoon . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.1.16 PaperChain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
6.1.17 Twister . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
6.1.18 Surf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
6.1.19 MSMS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
6.1.20 VolumeSlice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
6.1.21 Isosurface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
6.1.22 FieldLines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
6.1.23 Orbital . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.1.24 Beads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.1.25 Dotted . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.1.26 Solvent . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
6.2 Coloring Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.2.1 Color categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
3
6.2.2 Coloring Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.2.3 Coloring by color categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
6.2.4 Color scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.2.5 Materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6.3 Selection Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
6.3.1 Denition of Keywords and Functions . . . . . . . . . . . . . . . . . . . . . . 75
6.3.2 Boolean Keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.3.3 Short Circuiting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.3.4 Quoting with Single Quotes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
6.3.5 Double Quotes and Regular Expressions . . . . . . . . . . . . . . . . . . . . . 77
6.3.6 Comparison selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.3.7 Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
6.3.8 Other selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
7 Viewing Modes 85
7.1 Perspective/Orthographic views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.2 Monoscopic Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.3 Stereoscopic Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
7.3.1 Quad-buered Stereo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
7.3.2 Side-By-Side and Cross-Eyed Stereo . . . . . . . . . . . . . . . . . . . . . . . 86
7.3.3 DTI Side-by-side Stereo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.3.4 Checkerboard Stereo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.3.5 Column Interleaved Stereo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.3.6 Row Interleaved Stereo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.3.7 Anaglyph Stereo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
7.3.8 Stereo Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
8 Scene Export and Rendering 89
8.1 Screen Capture Using Snapshot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
8.2 Higher Quality Rendering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
8.3 Caveats . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
8.4 One Step Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.5 Making Stereo Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
8.6 Making a Movie . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
9 Tcl Text Interface 94
9.1 Using text commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
9.2 Tcl/Tk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.3 Tcl Text Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.3.1 animate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
9.3.2 atomselect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
9.3.3 axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9.3.4 color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
9.3.5 colorinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
9.3.6 display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
9.3.7 draw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
9.3.8 exit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
4
9.3.9 graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
9.3.10 gettimestep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
9.3.11 help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
9.3.12 imd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
9.3.13 label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
9.3.14 light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
9.3.15 logle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
9.3.16 material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.3.17 measure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110
9.3.18 menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
9.3.19 mol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118
9.3.20 molecule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
9.3.21 molinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
9.3.22 mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
9.3.23 play . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
9.3.24 quit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
9.3.25 render . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
9.3.26 rock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
9.3.27 rotate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
9.3.28 scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126
9.3.29 stage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
9.3.30 tool . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
9.3.31 translate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
9.3.32 user . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
9.3.33 vmdinfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
9.3.34 volmap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128
9.3.35 wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
9.3.36 sleep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
9.4 Tcl callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
10 Python Text Interface 137
10.1 Using the Python interpreter within VMD . . . . . . . . . . . . . . . . . . . . . . . . 137
10.2 Python modules within VMD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
10.3 Atom selections in Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
10.3.1 The built-in atomsel type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138
10.3.2 The AtomSel class (DEPRECATED) . . . . . . . . . . . . . . . . . . . . . . . 138
10.3.3 An atom selection example . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
10.3.4 Changing the selection and the frame . . . . . . . . . . . . . . . . . . . . . . 141
10.3.5 Combining atom selections . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
10.3.6 RMS example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
10.4 Python callbacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
10.4.1 Using Tkinter menus in VMD . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
10.5 Controlling VMD from Python . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
10.5.1 animate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
10.5.2 axes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
10.5.3 color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147
10.5.4 display . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
5
10.5.5 evaltcl . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
10.5.6 graphics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
10.5.7 imd . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
10.5.8 label . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150
10.5.9 material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
10.5.10 molecule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151
10.5.11 molrep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
10.5.12 render . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154
10.5.13 trans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
10.5.14 vmdnumpy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
10.6 High-level Python Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
10.6.1 Molecule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
10.6.2 MoleculeRep . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
10.6.3 Draw Style Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
10.6.4 Saving and Restoring Molecule State . . . . . . . . . . . . . . . . . . . . . . . 159
11 Vectors and Matrices 160
11.1 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
11.2 Matrix routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
11.3 Multiplying vectors and matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
11.4 Misc. functions and values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166
12 Molecular Analysis 168
12.1 Using the molinfo command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
12.2 Using the atomselect command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
12.3 Analysis scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
12.4 RMS Fit and Alignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
12.4.1 RMS Fit and Alignment Extension . . . . . . . . . . . . . . . . . . . . . . . . 178
12.4.2 RMS and scripting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
12.5 VMD Script Commands for Colors . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
12.5.1 Changing the color scale denitions . . . . . . . . . . . . . . . . . . . . . . . 181
12.5.2 Creating a set of black-and-white color denitions . . . . . . . . . . . . . . . 182
12.5.3 Revert all RGB values to defaults . . . . . . . . . . . . . . . . . . . . . . . . 182
12.5.4 Coloring Trick - Override a Coloring Category . . . . . . . . . . . . . . . . . 183
13 Customizing VMD Sessions 184
13.1 VMD Command-Line Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184
13.2 Environment Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
13.3 Startup Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
13.3.1 Core Script Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
13.3.2 User Script Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
13.3.3 .vmdrc and vmd.rc Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189
13.4 Using VMD as a WWW Client (for chemical/* documents) . . . . . . . . . . . . . . 190
13.4.1 MIME types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
13.4.2 Setting up your .mailcap . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
13.4.3 Example sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
6
Index 192
7
List of Figures
3.1 Sample VMD session displaying myoglobin. . . . . . . . . . . . . . . . . . . . . . . . 18
5.1 The Main form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.2 The Main form animation controls . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.3 The Molecule File Browser form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5.4 The Display menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.5 Relationship between screen height (SCRHEIGHT), screen distance to origin (SCRDIST),
and the viewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.6 The Graphics form (in Draw Style mode) . . . . . . . . . . . . . . . . . . . . . . . . 44
5.7 The Graphics form (in Selections mode) . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.8 The Labels form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
5.9 The Color form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5.10 The Material Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
5.11 The Render form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.12 The Tool form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
5.13 The Sequence form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
5.14 The RamaPlot Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
6.1 RGB color scale: the three plots shows the contributions of each color, and the
resulting colors are on the bottom. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.2 The shift to the red component of the RGB scale caused by the value of min. . . . 74
12.1 RMS calculation and alignment extension . . . . . . . . . . . . . . . . . . . . . . . . 178
8
List of Tables
5.1 Mouse control hot keys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.2 Rotation & scaling hot keys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.3 Menu control hot keys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5.4 Animation hot keys. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
5.5 Description of secondary structure codes in the Sequence form. . . . . . . . . . . . . 57
6.1 Molecular view representation styles. . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
6.2 Color categories used in VMD. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
6.3 Molecular coloring methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
6.4 Available Color Scale Gradations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
6.5 Atom selection keywords. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
6.6 Atom selection keywords (continued). . . . . . . . . . . . . . . . . . . . . . . . . . . 82
6.7 Atom selection functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.8 Read-only atom selection keywords which may be used to query the values of an
underlying volumetric map in the same molecule. The value of N, which can be 0 to
7 inclusively, refers to the volID of the underlying volumetric data (e.g., you could
type interpvol2). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.9 Regular expression methods. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
6.10 Regular expression conversions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
8.1 Miscellaneous Rendering Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
9.1 Summary of core text commands in VMD. . . . . . . . . . . . . . . . . . . . . . . . . 96
9.2 On-line Help Sources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
9.3 molinfo set/get keywords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
9.4 Description of Tcl callback variables in VMD. . . . . . . . . . . . . . . . . . . . . . . 135
10.1 Description of callbacks available to scripts running in the embedded Python inter-
preter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
9
Chapter 1
Introduction
VMD is a molecular graphics program designed for the interactive visualization and analysis of
biopolymers such as proteins, nucleic acids, lipids, and membranes. VMD runs on all major Unix
workstations, Apple MacOS X, and Microsoft Windows. Online information about VMD is available
from:
http://www.ks.uiuc.edu/Research/vmd/
List of key VMD features:
General molecular visualization
At its heart, VMD is a general application for displaying molecules containing any number
of atoms and is similar to other molecular visualization programs in its basic capabilities.
VMD reads data les using an extensible plugin system, and supports Babel for conversion of
other formats. User-dened atom selections can be displayed in any of the standard molecular
representations. Displayed graphics can be exported to an image le, to a scene le usable
by ray tracing programs, or to a geometry description le suitable for use with 3-D printers.
Visualization of dynamic molecular data
VMD can load atomic coordinate trajectories from AMBER, Charmm, DLPOLY, Gromacs,
MMTK, NAMD, X-PLOR, and many other simulation packages. The data can be used to
animate the molecule or to plot the change in molecular properties such as angles, dihedrals,
interatomic distances, or energies over time.
Visualization of volumetric data
VMD can load, generate, and display, volumetric maps. Supported map formats include
CryoEM maps, electrostatic potential maps, electron density maps, and many other map le
formats.
Interactive molecular dynamics simulations
VMD can be used as a graphical front-end to a live molecular dynamics program running on
a remote supercomputer or high-performance workstation. VMD can interactively apply and
visualize forces in an MD simulation as it runs.
Molecular analysis commands
Many commands are provided for molecular analysis. These include commands to extract
information on sets of atoms and molecules, vector and matrix routines for coordinate ma-
nipulation, and functions for computing values such as center of mass and radius of gyration.
10
Tcl and Python scripting languages
VMD uses the freely available Python and Tcl scripting languages for processing text com-
mands. These popular languages which contain variables, loops, subroutines, and much more.
VMD also uses the Tk Toolkit - a simple user interface toolkit that interfaces with Tcl.
Easy to extend
VMD is written in C and C++ and employs object-oriented design. VMD implements a
plugin interface for extending its le format support and for general purpose extensions in
functionality.
Support for multimodal input and various display systems
A number of dierent visual display and control systems are supported in addition to the usual
monitor, keyboard, and mouse. The VRPN library is used to get position and orientation
information from a wide variety of spatial input devices, including magnetic trackers, haptic
(force feedback) devices, Spaceballs, etc. VMD works with WireGL and Chromium on tiled
display walls, and immersive VR environments via compiled-in CAVE and FreeVR support.
1.1 Contacting the authors
The current developer of VMD is John E. Stone. The list of individuals that made signcant
contributions to this version of VMD in the form of patches, bug xes, and completely new plugins
includes Anton Arkhipov, Michael Bach, Robert Brunner, Jordi Cohen, Simon Cross, Markus
Dittrich, John Eargle, Peter Freddolino, Luis Gracia, Justin Gullingsrud, David Hardy, Konrad
Hinsen, James Gumbart, Robert Johnson, Axel Kohlmeyer, Michell Kuttel, John Mongan, Jim
Phillips, Elijah Roberts, Jan Saam, Alexander Spaar, Marcos Sotomayor, Leonardo Trabuco, Dan
Wright, and Kirby Vandivort.
We are very interested in and grateful for any user comments and reports of program bugs or
inaccuracies. If you have any suggestions, bug reports, or general comments about VMD, please
send them to us at [email protected].
1.2 Registering VMD
VMD is made available free of charge for all interested end-users of the software (but please see the
Copyright and Disclaimer notices). Please check the current VMD license agreement for details.
Registration is part of our software download procedure. Once youve lled out the forms on the
VMD download area and have read and agreed to the license, you are nished with the registration
process.
1.3 Citation Reference
The authors request that any published work or images created using VMD include the following
reference:
Humphrey, W., Dalke, A. and Schulten, K., VMD - Visual Molecular Dynamics J. Molec.
Graphics 1996, 14.1, 33-38.
11
VMD has been developed by the Theoretical and Computational Biophysics Group at the
Beckman Institute for Advanced Science and Technology of the University of Illinois at Urbana-
Champaign. This work is supported by the National Institutes of Health under grant number
P41-RR005969.
1.4 Acknowledgments
The authors would particularly like to thank those individuals who have contributed suggestions and
improvements, particularly those contributing new features. Special thanks go to Anton Arkhipov,
Andrew Dalke, Michael Bach, Alexander Balae, Ilya Balabin, Robert Brunner, Eamon Caddi-
gan, Jordi Cohen, Simon Cross, Markus Dittrich, John Eargle, Peter Freddolino, Todd Furlong,
Luis Gracia, Paul Grayson, Justin Gullingsrud, James Gumbart, David Hardy, Konrad Hinsen,
Barry Isralewitz, Sergei Izrailev, Robert Johnson, Axel Kohlmeyer, Michell Kuttel, John Mongan,
Jim Phillips, Jan Saam, Alexander Spaar, Charles Schwieters, Marcos Sotomayor, John E. Stone,
Leonardo Trabuco, Dan Wright, and Kirby Vandivort. The entire VMD user community now
benets from your contributions.
The authors would like to thank individuals who have indirectly helped with development by
making suggestions, pushing for new features, and trying out buggy code. Thanks go to Aleksei
Aksimentiev, Daniel Barsky, Axel Berg, Tom Bishop, Robert Brunner, Ivo Hofacker, Mu Gao,
James Gumbart, Xiche Hu, Tim Isgro, Dorina Kosztin, Ioan Kosztin, Joe Landman, Ilya Logunov,
Clare Macrae, Amy Shih, Lukasz Salwinski, Stephen Searle, Charles Schwieters, Ari Shinozaki,
Svilen Tzonev, Emad Tajkhorshid, Michael Tiemann, Elizabeth Villa, Raymond de Vries, Simon
Wareld Willy Wriggers, Dong Xu, and Feng Zhou.
Many external libraries and packages are used in VMD, and the program would not be as capable
without them. The authors of VMDwish to thank the authors of FLTK; the authors of Tcl and Tk;
the authors of Python; the authors of VRPN; Jon Leech for uniform point distributions; Amitabh
Varshney for SURF; Dmitrij Frishman for developing STRIDE; Jack Lund for the url get perl
script; Brad Grantham for the ACTC triangle consolidation library; John E. Stone for the Tachyon
ray tracer, WorkForce threading and timer routines, hash table code, and Spaceball drivers; and
Ethan Merrit for one of the ribbon drawing algorithms.
1.5 Copyright and Disclaimer Notices
VMD is Copyright c _ 1995-2009 Theoretical and Computational Biophysics Group and the
Board of Trustees of the University of Illinois
Portions of this code are copyright c _ 1997-1998 Andrew Dalke.
The terms for using, copying, modifying, and distributing VMD are specied by the VMD
License. The license agreement is distributed with VMD in the le LICENSE. If for any reason
you do not have this le in your distribution, it can be downloaded from:
http://www.ks.uiuc.edu/Research/vmd/current/LICENSE.html
Some of the code and executables used by VMD have their own usage restrictions:
ACTC
ACTC, the triangle consolidation library used in some versions of VMD, is Copyright (C)
2000, Brad Grantham and Applied Conjecture, all rights reserved.
12
Redistribution and use in source and binary forms, with or without modication, are permit-
ted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of condi-
tions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of con-
ditions and the following disclaimer in the documentation and/or other materials provided
with the distribution.
3. All advertising materials mentioning features or use of this software must display the fol-
lowing acknowledgment: This product includes software developed by Brad Grantham and
Applied Conjecture.
4. Neither the name Brad Grantham nor Applied Conjecture may be used to endorse or
promote products derived from this software without specic prior written permission.
5. Notication must be made to Brad Grantham about inclusion of this software in a product
including the author of the product and the name and purpose of the product. Notication
can be made using email to Brad Granthams current address ([email protected] as of
September 20th, 2000) or current U.S. mail address.
Python
Python is made available subject to the terms and conditions in CNRIs License Agreement.
This Agreement together with Python may be obtained from a proxy server on the Internet
using the following URL: http://hdl.handle.net/1895.22/1012
PCRE
The Perl Compatible Regular Expressions (PCRE) library used in VMD was written by
Philip Hazel and is Copyright (c) 1997-1999 University of Cambridge.
Permission is granted to anyone to use this software for any purpose on any computer system,
and to redistribute it freely, subject to the following restrictions:
1. This software is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
2. The origin of this software must not be misrepresented, either by explicit claim or by
omission.
3. Altered versions must be plainly marked as such, and must not be misrepresented as being
the original software.
4. If PCRE is embedded in any software that is released under the GNU General Purpose
License (GPL), then the terms of that license shall supersede any condition above with which
it is incompatible.
STRIDE
STRIDE, the program used for secondary structure calculation, is free to both academic and
commercial sites provided that STRIDE will not be a part of a package sold for money. The use
of STRIDE in commercial packages is not allowed without a prior written commercial license
agreement. See http://www.embl-heidelberg.de/argos/stride/stride info.html
SURF
The source code for SURF is copyrighted by the original author, Amitabh Varshney, and the
University of North Carolina at Chapel Hill. Permission to use, copy, modify, and distribute
this software and its documentation for educational, research, and non-prot purposes is
13
hereby granted, provided this notice, all the source les, and the name(s) of the original
author(s) appear in all such copies.
BECAUSE THE CODE IS PROVIDED FREE OF CHARGE, IT IS PROVIDED AS IS
AND WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED.
This software was developed and is made available for public use with the support of the
National Institutes of Health, National Center for Research Resources under grant RR02170.
Tachyon
The Tachyon multiprocessor ray tracing system and derivative code built into VMD is Copy-
right (c) 1994-2011 by John E. Stone. See the Tachyon distribution for redistribution and
licensing information.
Desmond and Maestro plugins by D. E. Shaw Research
Copyright 2009, D. E. Shaw Research, LLC All rights reserved.
Redistribution and use in source and binary forms, with or without modication, are permit-
ted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions,
and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of con-
ditions, and the following disclaimer in the documentation and/or other materials provided
with the distribution.
Neither the name of D. E. Shaw Research, LLC nor the names of its contributors may be
used to endorse or promote products derived from this software without specic prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBU-
TORS AS IS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
NESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, IN-
DIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CON-
TRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHER-
WISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.6 For information on our other software
VMD is part of a suite of tools developed by the Theoretical and Computational Biophysics group
at the University of Illinois.
BioCoRE
BioCoRE is a web-based collaborative environment for structural biology which provides
tools to allow collaboration between researchers down the hall or around the world. Anyone
with access to the internet and a standard web browser can join BioCoRE and create or be
14
added to research projects, and information about a particular project is shared among all
members of that project. More information is available at the BioCoRE home page
1
NAMD
A parallel, object-oriented molecular dynamics code designed for high-performance simula-
tion of large biomolecular systems. NAMD uses the CHARMM force eld and le formats
compatible with both CHARMM and X-PLOR. NAMD supports both periodic and non-
periodic boundaries with ecient full electrostatics, multiple timestepping, constant pressure
and temperature ensemble simulation methods. More information is available at the NAMD
home page
2
MDTools
MDTools is a collection of programs, scripts, and utilities provided for researchers to make
various modeling and simulation tasks easier. More information is available at the MDTools
home page
3
For more information on our software eorts, see the Theoretical and Computational Biophysics
Group home page
4
.
1
http://www.ks.uiuc.edu/Research/biocore
2
http://www.ks.uiuc.edu/Researach/namd
3
http://www.ks.uiuc.edu/Development/MDTools
4
http://www.ks.uiuc.edu/
15
Chapter 2
Hardware and Software Requirements
2.1 Basic Hardware and Software Requirements
The basic hardware requirements for running VMD vary depending on how it was compiled and how
it will be used. VMD has two primary modes of operation, the typical full-featured graphics-enabled
mode, and a purely text-based mode of operation suited for remote analysis on supercomputers,
embedded use in other packages, and similar batch-oriented analytical uses.
The full-featured graphics-enabled mode of VMD is the most demanding, and requires an
OpenGL-capable graphics accelerator with up-to-date drivers. Some graphics chipsets or GPUs
come with drivers that are below-spec and will not be able to run VMD with full graphics ca-
pability. These will either automatically, or as the result of user-dened environment variables
(e.g. VMDSIMPLEGRAPHICS), use a reduced functionality graphics mode within VMD. Since
the choice of the GPU chipset or card has the biggest impact on the visualization capabilities and
performance of VMD, this is the hardware component that is worth spending money on if ones
intended use of VMD is primarily focused on visualization related tasks. As an added bonus, recent
GPUs are now also capable of accelerating some of the computationally demanding tasks within
VMD, as will be discussed in more detail below.
Following the choice of graphics accelerator, the amount of available system memory tends
to have the next most signicant impact on the performance and capability of VMD. The more
memory a machine has, the more frames can be loaded at once from large molecular dynamics
trajectory les. For batch-mode analysis tasks that consist primarily of scripting, system memory
is frequently the resource that limits feasability of many analysis tasks.
2.2 Multi-core CPUs and GPU Acceleration
VMD makes full use of multi-core processors and multiple GPUs for acceleration of the most
computationally demanding visualization and analysis tasks. Multi-core CPUs accelerate features
including interactive MD, bond determination, within atom selections and derivatives, radial
distribution functions, and high quality renderings using the Tachyon and TachyonInternal ray
tracing features. VMD also supports GPU acceleration using CUDA, and takes advantage of both
multi-core CPUs and GPUs for acceleration of electrostatics (i.e. volmap coulomb, and volmap
coulombmsm), implicit ligand sampling (i.e. volmap ils), and computation and rendering of
molecular orbitals.
16
Chapter 3
Tutorials
3.1 Rapid Introduction to VMD
For those of you who dont like reading manuals, here is a quick introduction to VMD. The molecules
and data les used in this tutorial can be downloaded from the VMD home page from the doc-
umentation area associated with this version and is clearly labeled as Users Guide tutorial data.
The rest of this tutorial assumes that you have downloaded and unpacked this data set.
To start VMD type vmd on the command line of your shell (Unix), or start it by clicking the
VMD icon in your desktop or Start menu (Apple MacOS X and Microsoft Windows). VMD should
start up with a window titled vmd console, a display window entitled VMD OpenGL Display, and a
main menu entitled VMD. Text commands are typed in the console window, molecules are displayed
and manipulated in the graphics window, and other interfaces and extensions are available from
the menu interface. All of the forms can be closed or minimized, using your computers standard
windowing controls or the menu command [9.3.18] in text console. Most functions can be performed
with both the menu interface and the text console, though some of the more sophisticated scripting
features are only available as text commands.
3.2 Viewing a molecule: Myoglobin
In our quick tour of VMD, well start out by demonstrating a few of its visualization features. To
load a new molecule, select New Molecule. . . from the File menu in the main form, this will open
the Files form [5.4.4]. We will load a PDB (Protein Data Bank) le containing the coordinates
of the atoms in myoglobin (compliments of Joel Berendzen of Los Alamos National Laboratory).
Select the Browse. . . button in the les form to bring up a le browser. Go into the proteins/
directory of the tutorial data set that you have downloaded from the VMD web site. Once there,
select the le mbco.pdb in the le browser, and press the Load button in the molecule le browser.
button in the Files form. Figure 3.1 shows an example of VMD displaying this protein.
You can use the mouse to manipulate the structure in the display window. There are three
basic mouse modes [5.1.1]: rotation, translation, and scaling. The mode can be changed from the
Mouse menu in the main form, or by pressing r, t, or s on the keyboard while the mouse is in the
graphics window. While experimenting, note how the cursor changes to indicate the mouse mode.
In rotation mode, the left mouse button controls rotation about axes parallel to the screen, and the
middle button controls rotation about the axis perpendicular to the screen. In translation mode,
the left mouse button controls translation parallel to the screen, while the middle button controls
17
Figure 3.1: Sample VMD session displaying myoglobin.
translation in and out of the screen. Finally, in scaling mode, both the left and middle buttons
control global scaling when the mouse is moved left or right, but the middle button causes larger
changes.
By default molecules are displayed in a lines representation, colored by atom type. Suppose
you would like to view the myoglobin structure with its protein backbone represented as a tube, the
heme represented as licorice, the SO
4
ion and CO molecule represented as van der Waals spheres,
and histidines 64 and 93 represented as CPK models. First, open the Graphics form [5.4.7] by
selecting the Representations item in the the graphics menu of the VMD main form. Type backbone
in the Selected Atoms text entry area and press enter to select the myoglobin backbone. All of the
protein except for the backbone will disappear. Choose NewCartoon in the drawing method chooser
to display the backbone as a tube, and choose Structure in the coloring method chooser to color
the tube with the predened secondary structure color. Press the Create Rep button. This creates
a new representation in the browser, identical to the original one. The new representation can be
changed without aecting others, so clear the atom selection text area and enter resname HEM to
select the heme. At this point the heme isnt visible because it cannot be drawn as a cartoon, so
choose the Licorice drawing method to make it appear. Click on Create New again to make a
18
new view, and enter resname SO4 CO to select the SO
4
ion and the CO molecule, and choose the
drawing method VDW to render them as Van der Waal spheres. Once again, press the Create
Rep button and enter resid 93 64 to select the two histidines, and render them as CPK. If you
followed all that, then congratulations, you have made a nice image of myoglobin! With further
experimentation you should be well on your way to learning how to use VMD.
3.3 Rendering an Image
Find an interesting view of the molecule from the previous tutorial. Suppose you want to publish
this view in a journal and want a high quality image, or you want to make a large poster. Taking the
image from a screen capture often results in a rather grainy image as the size of the pixels becomes
apparent, so you want something with more resolution. There are several programs available which
can render a high-quality raster image, based on an input script. VMD has the option to create
input scripts for many of these image processing programs, which may then be processed to create
a higher quality image of the scene displayed by VMD at the time the script was created. See
Chapter 8 on rendering for a further description of how this works.
Open the Render form [ 5.4.11] and select Tachyon from the Render Using menu. Both of the
text boxes will be lled with default values which should not need to be changed for the purposes
of this tutorial. Press the Start Rendering button. After a few moments of processing, you sould
see the message
Info) Rendering complete.
in the VMD text console. If everything worked correctly, you will end up with an image le
named plot.dat.tga (on MacOS X or Unix) or plot.dat.bmp (on Windows) in your current working
directory. This image is in either Windows BMP or Targa graphics format, and can be read by
many programs (such as display, ipaste, xv, Gimp or Photoshop).
3.4 A Quick Animation
Another strength of VMD lies in its ability to playback trajectories resulting from molecular dynam-
ics simulations. A sample trajectory, alanin.dcd is provided in the proteins directory included
with VMD. To load it, open the molecule le browser as described previously. Next click on the
Browse button and select the alanin.psf le in the le browser. Once selected, press the Load
button to load the structure le. Next, select the alanin.dcd le and load it as well. This will
read the DCD trajectory frames into the same molecule with the previously loaded alanin.psf
le.
In the display window you should see a simulation of an alanin residue in vacuo. It isnt
particularly informative, but you can easily see that the structure is quite unstable in an isolated
environment. After the DCD le has loaded, animation will stop. To see it again or to ne- tune
playback, use the animation controls [5.4.3] found at the bottom of the main VMD form. Press
the button that looks like > to play the animation. Use the Speed slider at the bottom of the form
to change the speed of playback. By rotating the molecule around, etc. you should get an idea
about how the system destabilizes over the course of the simulation. The animation controls are
generally similar to what youd nd on a DVD or CD player.
19
3.5 An Introduction to Atom Selection
In this section it is assumed that you have the myoglobin structure mbco.pdb loaded and the views
discussed in section 3.2 created. If this is not true, go back and repeat the process described there.
VMD has a powerful atom selection method which is very helpful when generating attractive,
informative, and complex graphics. In the previous section you used a few of these atom selection
tools. This tutorial assumes that you have already loaded the myoglobin molecule, but it isnt
necessary to recreate all the graphical representations.
To change which atoms are used to display each representation of the molecule shown in the
display window, open the Graphics form [ 5.4.7] and select the representation you want to change.
You can then either edit the dierent elds (selection, coloring method, or drawing method) or use
the Delete button to delete the view entirely. Try changing or deleting some of the views. When
nished, delete all representations for the myoglobin structure. To get the basic line drawing view
back, clear the atom selection text entry area, enter all and press the Create Rep button.
Atoms may be selected on the basis of a property, i.e. protein or not protein, water, or
nucleic backbone. They may also be selected by atom name, such as atom C, by residue name,
such as resname HEM, or by many other identiers. Multiple atoms may be specied with one key-
word. For example, the selection name C CA N O will select the backbone atoms. (A similar eect
may be obtained with the command protein backbone.) VMD can handle regular expressions,
so that name "C.*" will select all atoms with names starting with C. VMD also understands the
boolean operators and, or, and not, so the selection resname HEM and not name "N.*" selects all
non-nitrogen atoms in the heme group of myoglobin.
Several more abstract selection criteria are available. For instance, the selection x > 5 nds
all atoms with an x coordinate greater than 5, while mass >12 and mass < 14 selects all atoms
with mass greater than 12 and less than 14 atomic mass units. Many math functions [ 6.7] are
also provided, so the selection sqrt( sqr(x) + sqr(y) + sqr(z) ) < 10 will select atoms in
a spherical region of radius 10
A centered about the origin of the coordinate space. You can pick
atoms nearby a selection with the phrase within <distance> of <selection> and all residues with
the same property as a given selection as same <property> as <selection>.
See section 6.3 for a full description of the selection command.
3.6 Comparing Two Structures
Lets start from scratch by deleting everything: use the text console and tye the command mol
delete all and press enter. This deletes all loaded molecules and is often more convenient then
selecting them and deleting them all one by one. Alternatively, you could highlight each molecule
in the molecule browser, and use the Delete Molecule item in the Molecule menu to remove them
one by one.
Begin by loading the mbco.pdb structure with the Files form. Turn on just the heme, CO, and
histidines by using the selection commands resname HEM CO or resid 64 93. The dot (probably
green) in the middle is the iron and you can verify that by picking it with the mouse. Do this by
changing the Object Mode pull-down to Pick, and selecting Atoms for the pick mode in the
Mouse menu. The label HEM154:FE should appear both on the display and in the text console.
Change the pick mode in the Mouse menu to Bonds. To get the distance between the iron
and the oxygen of the CO, click with the left mouse button rst on the iron and then on the
oxygen. The rst click turned the FE label on and the second turned the O label on and drew
20
a line between the two atoms with the distance drawn in the middle and a bit to the right. The
distance between the two atoms is 2.94
A, as compared to 2.93
A in the paper; not bad. However,
picking the distance between the FE and the C of the CO reveals a distance of 1.91
A as compared
to 1.85
A in the paper. The dierence is that the structures in the VMD distribution are actually
preliminary structures obtained before the nal coordinates were determined.
In order to experiment with more complex picking modes, consider the angle made by the O
of the CO with the FE of the heme and the NE2 of residue 93 (you can click on the atoms to nd
which ones are which). Using the Mouse menu, change the pick mode to Angles. This should
cause the cursor to become a red crosshair. Click on each of the three atoms using the left mouse
button. After the third pick, a shallow angle will appear indicating an 8.71 degree angle between
the three atoms.
Now load the intermediate star.pdb le which can also be found in the proteins directory of
your distribution. Again use the Files form to do this. Both of the molecules will be loaded side by
side. Go to the Graphics form and change the selection so it the same as the rst, i.e. resname HEM
CO or resid 64 93. The two molecules are almost atop each other, making it hard to distinguish
the two, so change the colors to simplify things.
First, in the Graphics form, change the Coloring method to Molecule. Use the Selected Molecule
chooser to change the mbco.pdb Coloring method to Molecule as well. Open the Color form [5.4.9]
and scroll the Category browser down until the line Molecule is visible. Click on it then click
on the line which says mbco.pdb. (There may be two mbco lines if the le had been loaded before
in this session.) Scroll the Colors browser up to click on blue. This should change one of the
molecules in the display to blue.
Next, click on the last line in the Names chooser, which says star.pdb. This time, choose red
from the Colors chooser. The display should be much easier to understand. The myoglobin with
the bound CO is in blue and the intermediate state is in red. At this point it is easy to measure
the change in position between the two dierent states by using the middle mouse button to pick
the same atom in the two conformations.
Once that is done, it is easy to point out one interesting aspect of the way VMD handles the
graphics. Go to the main form, select one of the two molecules, and press Toggle Fixed. Enter
translation mode and move the other molecule around. Notice that the number which lists the
distance between the two atoms never changes. Thats because the mouse only aects the way the
coordinates are translated to the screen image. It does not aect the real coordinates at all. It is
possible to change the coordinates in a molecule using the text command interface, or by using the
atom move pick modes [5.1.2]).
By the way, unx the molecules and do a Reset View from the Display menu to reset everything.
Load up the third structure, deoxy.pdb and give it the same selection as the other two molecules.
However, color this one green. Pull out Nature v. 371, Oct. 27, 1994 and turn to page 740. With
a bit of manipulation you should be able to recreate the image that appears there.
3.7 Some Nice Represenations
The following views are quite nice for displaying proteins and nucleic acids:
selection: all
drawing method: tube
coloring method: segname (or chain)
why? This show the backbone of the protein and nucleic acid strands
21
selection: protein and (name CA or not backbone)
drawing method: lines
coloring method: segname (or chain)
why? shows where the side chains are located, but they are thin so the
backbone is still visible and the scene is quickly drawn
selection: (numbonds = 0) and not waters
drawing method: vdw
coloring method: name
why? shows ions. The "not waters" omits cases where a waters oxygen is
known but not the hydrogen.
selection: not (waters or protein or nucleic)
drawing method: lines
coloring method: name
why? shows whatever is left; usually ligands and crystallizing agents
3.8 Saving your work
After creating a set of attractive and informative representations of your molecule, you may want
to save your work so that you can regenerate the scene later. There are two ways to do this in
VMD:
In the main menu, press the Save State button found in the File menu; this will bring up a
browser window where you can enter a le name in which to save your work.
In the text console, type save state lename, where lename is the name of the le in which
to save your work.
To restore your scene, you also have three choices:
Use the Load State item in the File manu to select and load a previously saved VMD session.
From the command line, start VMD with the options vmd -e lename, where lename was
the name of the le you saved before.
After starting VMD, from the text console, type play lename.
The most common source of problems is when VMD cant nd the les you used to load the
molecule. If this happens, try changing to the directory you were in when you rst loaded the
molecule, or edit the state le and use the full path names where you see mol new, mol addfile,
or mol load commands.
3.9 Tracking Script Command Versions of the GUI Actions
For most actions performed from the VMDGUI, there is an equivalent script command. VMDcan
print these commands to a log le or the console. This is a convenient way to automate le
22
processing by rst doing all steps interactively while logging to a le and then editing the logle to
turn it into a Tcl script operating on multiple les. There are two ways to do this in VMD:
In the main menu, press the Log TCL Commands to File button found in the File menu; this
will bring up a browser window where you can enter a le name in which you can save the
resulting script code.
In the text console, type logfile lename, where lename is the name of the log le.
The resulting le will contain Tcl script code that can be executed from the VMDcommand
prompt. The Log TCL Commands to Console button or the command logfile console will print
the Tcl commands to the console window instead. This is most useful, if you just want to nd out,
which VMDcommand is used to perform a specic action.
Finally, the logfile off command or clicking on the Turn O Logging button will stop the log
and close the log le, if needed.
23
Chapter 4
Loading A Molecule
The File menu is the primary means for loading molecules and other data into VMD. The built-in
le readers will load molecular structures from combinations of topology les, coordinate les, and
trajectory les. Readers are also included for data such as potential maps, electron density maps,
Grasp surface data, and arbitrary 3-D geometric data from Raster3D scene les. VMD can load
structures directly from Protein Data Bank over the internet, provided that a network connection
is present. Entering the four-character PDB accession code in the molecule le broswer form will
retrieve and load the structure over the network.
4.1 Notes on common molecular le formats
VMD natively understands several popular molecular data le formats: PDB coordinate les,
CHARMM, NAMD, and X-PLOR style PSF topology les, CHARMM, NAMD, and X-PLOR
style DCD trajectory les, NAMD binary restart (coordinate) les, AMBER structure (PARM)
and trajectory (CRD) les including both the old format and the new formats used by AMBER
7.0, and Gromacs (e.g. GRO, G96, XTC, TRR) structure and trajectory les. These les may
contain some redundant information and can be loaded in dierent combinations.
PDB les contains data about atoms, residues, segment names, occupancy and beta factor, and
one coordinate set. PSF and PARM les contain atoms, residues, segment names, residue types,
atomic mass and charge, and the bond connectivity. VMD supports four le formats used by
Gromacs: GRO, G96, TRR and XTC. GRO and G96 les contain structure information including
atoms, residue and segment data, and one coordinate set. CRD, DCD, TRR and XTC les contain
only coordinate data (frames ). It should be noted that while PDB, GRO and G96 les were
designed to contain only one coordinate set, multiple les can be concatenated into one larger le
to create a makeshift trajectory le which can be loaded by VMD.
When VMD loads a le it requires information about atom names and coordinates and tries to
ll in the rest. Since the PDB le contains all this information, it does not need to be loaded with
any other data les. However, the PDB le doesnt contain the atom types, masses, and charges,
so these are guessed or assigned default values. In particular, charges will be assigned a value of
0.0 if the le does not contain explicit charge information.
A PSF le does not contain coordinate information so it must be loaded along with a PDB or
DCD le. If a PDB and PSF are given there is no missing data and VMD makes no assumptions.
If a PSF and DCD are given then only the chain identier and occupancy and beta values are
missing so they are given a default value. A PARM le is similar to a PSF in that it too contains
24
no coordinate information. It must be loaded along with a CRD trajectory le. If a PARM and
CRD le are loaded together, then only the segname and chain ID for the atoms are left blank. A
CRD or DCD le can be specied along with the PDB, in which case the PDB le will be read
as normal, and then coordinate sets are read from the DCD or CRD until the end of the le is
reached. Gromacs GRO and G96 les can be loaded on their own since they contain the necessary
atom data and coordinates. They can also be loaded along with TRR and XTC les to obtain
trajectory data. Additional coordinates from a PDB, CRD, or DCD le can be appended to the
current coordinate set using the Molecule File Browser form.
4.2 What happens when a le is loaded?
When a coordinate le is loaded by itself (i.e. just a PDB, no PSF), VMD uses heuristics to replace
missing values that would normally be provided by a structure le. If necessary, VMD does a
distance-based bond search to determine connectivity. A bond is formed whenever two atoms are
within (R
1
+R
2
) 0.6 of each other, where R
1
and R
2
are the respective radii of candidate atoms.
If both structure and coordinate les are loaded, no approximations or guesses are made.
After the molecule is read in, new names are added to the coloring categories [6.2.3], and
assigned colors. Next, bond connectivity is established and the molecule is analyzed to identify its
components, i.e., to determine which residues are protein, nucleic acids, and waters, etc. A search
is then made to connect these into larger fragments of the same type, and summary information is
printed to the screen. An example output for BPTI is:
Info 1) Analyzing structure ...
Info 1) Atoms: 898 Bonds: 909
Info 1) Backbone bonds: Protein: 231 DNA: 0
Info 1) Residues: 58
Info 1) Waters: 0
Info 1) Segments: 1
Info 1) Fragments: 1 Protein: 1 Nucleic: 0
There are several types of fragments. Protein and nucleic fragments are homogeneous; either
all proteins, or all nucleic acids. However, it is possible for a protein to be connected to a nucleic
acid or some other non-protein. When this occurs, a warning message is printed, as in:
Warning 1) Unusual bond between residues 1 and 2
These warnings will occur with terminal amino acids, zinc ngers, myristolated residues, and poorly
dened structures.
4.3 Babel interface
VMD can use the program Babel, if installed, to translate a wide variety of dierent molecular
data les into the PDB format. Not all of these have been tested for use with VMD, so your results
may vary. VMD only uses Babel to read les and does not allow the use of Babel to save les to
other formats. The VMDBABELBIN environment variable [13.2] is used to specify the absolute path
to the the Babel executable (including the executable name). For more information about Babel,
see http://smog.com/chem/babel/. VMD currently supports version 1.6 of Babel.
25
4.4 Raster3D le format
In addition to the molecular le formats, VMD can read the input le for Raster3D. (Raster3D
converts an input le into a shaded raster image for use in making high quality pictures. It is often
used with MolScript.) The ability to read Raster3D allows users to view MolScript les in 3D and
incorporate special images into the display without having to edit the VMD code. The le format,
which is part of the Raster3D documentation, describes a simple collection of triangles, spheres,
and cylinders with either at or spherical ends. Each shape is colored by an RGB triplet.
Certain newer Raster3D objects are ignored, such as quadrics. Also, nearly all of the header
information is ignoredmost notably, the viewing matrix. Raster3D uses many cylinders with
spherical (rounded) ends. VMD deliberately omits these rounded ends since the resultant image
would be very slow to render interactively. VMD uses a xed size palette of colors, each triplet is
converted into its nearest indexed color. This may cause images to be colored slightly dierently
than expected.
26
Chapter 5
User Interface Components
VMD provides several methods for the user to control and interact with the molecular display. The
primary methods are by using the mouse, either in the graphics window or in the dierent graphical
user interface (GUI) forms provided by the program. In addition to the mouse, VMD also supports
a number of more advanced input devices such as the Spaceball, Magellan, and Phantom, which
provide the ability to manipulate molecules with six degrees of freedom. Some devices such as the
Phantom can also provide haptic (sense of touch) force feedback. VMD also provides a text console
interface for executing built-in commands or running scripts. This chapter describes how to use
the mouse-based user interfaces, and some of the advanced input devices supported in VMD. The
the text and scripting interface is described fully in chapter 9.
5.1 Using the Mouse in the Graphics Window
The graphics window is labeled VMD OpenGL Display and contains a view of the molecules and
other objects which make up the scene. When the mouse is in the graphics display window, it may
be used to perform the following actions such as:
Rotate, translate, or scale the displayed molecules
Select, or pick atoms or other objects in order to move them, or label them
Translate and rotate a set of atoms
Apply a force (acceleration) to a set of atoms
Move the lights
User-dened keyboard accelerators, or hot keys, are also available when the mouse is in the graphics
display window. These keys are bound to VMD text commands, which are executed when the key
is pressed. VMD has many built-in default hot key commands (see Tables 5.1, 5.2, 5.3 and 5.4).
Users can add new hot keys, overriding default settings if desired.
5.1.1 Mouse Modes
The mouse is in one of several modes at any time; the current mouse mode determines the eect of
pressing and releasing mouse buttons or the mouse wheel while the mouse is in the graphics window.
27
Each mouse mode, except the lights mode (see below), sets the mouse cursor to a characteristic
shape. The mouse mode is selected via the Mouse menu.
The available mouse modes are as follows:
Rotate Mode (hot key r)
When the mouse is in rotate mode, holding the left mouse button down and moving the mouse
rotates the molecules about axes parallel to the screen, in a virtual trackball behavior. To
get a rotation around the axes coming out of the screen (the z axis), hold the middle button
down and move the mouse left or right.
You can leave molecules rotating without continuously moving the mouse. Start the molecule
moving with the mouse, as above, then release the mouse button before you stop moving the
mouse. With some practice it becomes easy to impart a slight spin on the molecule, or whirl
it about madly. To stop the rotation, either press and hold the left mouse button down until
the molecule stops moving, or select Stop Rotation in the Mouse menu. Also, pressing the
rotation hot key r or any of the other mouse mode hot keys causes rotation to stop.
Translate Mode (hot key t)
When the mouse is in translate mode, holding the left button down allows you to move
the molecules parallel to the screen plane (left, right, up, and down). To move the molecule
towards or away from you, hold the middle button down and move the mouse right or left,
respectively.
Scale Mode (hot key s)
Pressing either the left or middle button down and moving to the right enlarges the molecules,
and moving the mouse left shrinks them. The dierence is that the middle button scales faster
than the left button. Scaling can also be accomplished with the mouse wheel (irrespective of
the current mode setting) on computers equipped with an appropriate mouse.
Move Light
VMD provides four directional lights to illuminate the molecular scene. The lights provide
diuse lighting and specular highlights and help the user perceive surface shape in rendered
objects. You can use the mouse to rotate each of the light source directions to a new position.
If the light isnt on, moving it will not aect the displayed image. To turn a light on or o,
use the Lights item within the Mouse menu.
Add/Remove Bonds
When the mouse is in add/remove bonds mode, clicking on atoms in a molecule will add a
bond between those atoms if one is not already present, or remove the bond between those
atoms if there is already a bond. The two atoms must belong to the same molecule.
5.1.2 Pick Modes
Mouse picking can be used to turn on or o various types of labels, to query for information about
an object, or to move items around on the screen. You can label an atom (and display the atom
name), or you can label geometric values such as the distance between two atoms (a bond label), an
angle between three atoms (an angle label), or the dihedral angle formed by four atoms (a dihedral
label). This is done by setting the mouse into the proper picking mode and then selecting the
relevant atoms with the mouse. Picking modes are selected from the Mouse menu.
The available pick mode actions are:
28
Center (hot key c)
This mode is used to change the point about which a molecule rotates when the molecule
is rotated. To cause a molecule to rotate about a specic atom, select this mode and then
click on that atom. The rotation point may be restored to its default position (the center of
volume of the molecule) by executing the Reset View option from the Mouse menu.
Query (hot key 0)
Clicking on an item will print out the name of the item (e.g. the atom name) to the text
console window.
Label Atom (hot key 1)
Clicking on an atom will toggle on/o a label for the atom.
Label Bond (hot key 2)
Clicking on two atoms in a row will toggle on/o a bond distance label between the two atoms
(a dotted line with the distance printed at the midpoint).
Label Angle (hot key 3)
Clicking on three atoms in a row will toggle on/o a label showing the angle formed by the
three atoms.
Label Dihedral (hot key 4)
Clicking on four atoms in a row toggles on/o a label showing the dihedral angle formed by
the four atoms.
Move Atom (hot key 5)
In this mode, the position of an atom can be changed by clicking on the desired atom,
and dragging with the mouse while the button is still pressed. This will change the atom
coordinates.
Move Residue (hot key 6)
This mode may be used to move all the atoms in a selected residue at the same time. Select
an atom in a residue, and move it to a new position while keeping the mouse button pressed.
All the atoms in the same residue as the selected one will be moved the same amount. Holding
down the shift key and the left mouse button while moving the mouse will rotate the atoms
in the residue about the selected atom. If the middle mouse button is held down instead, the
atoms in the residue will rotate about a line drawn through the picked atom and parallel to
a line coming directly out of the screen. This behavior is similar to the usual Rotate mode,
except that coordinates of atoms are changed.
Move Fragment (hot key 7)
A fragment is a set of atoms all connected by a series of covalent bonds. This mode acts just
like MoveResidue, except that the atoms which are moved are all in the selected fragment
rather than in the selected residue. This will change the atom coordinates. Holding down
the shift key and the left mouse button while moving the mouse will rotate the atoms in
the fragment about the selected atom. If the middle mouse button is held down instead, the
atoms in the fragment will rotate about a line drawn through the picked atom and parallel to
a line coming directly out of the screen. This behavior is similar to the usual Rotate mode,
except that coordinates of atoms are changed.
29
Move Molecule (hot key 8)
This mode may be used to move all the atoms in a selected molecule at the same time.
Select an atom in a molecule, and move it to a new position while keeping the mouse button
pressed. All the atoms in the same molecule as the selected one will be moved the same
amount. Holding down the shift key and the left mouse button while moving the mouse
will rotate the atoms in the molecule about the selected atom. If the middle mouse button
is held down instead, the atoms in the molecule will rotate about a line drawn through the
picked atom and parallel to a line coming directly out of the screen. This behavior is similar
to the usual Rotate mode, except that coordinates of atoms are changed.
Move Rep (hot key 9)
This mode may be used to move all the atoms in a selected representation at the same time.
You select a representation by clicking on one of the reps in the browser window of the
Graphics form. In order to move the atoms in this rep, the atom you pick with the mouse
must be selected by that rep.
When you have clicked on an atom in the rep, move the mouse to a new position while keeping
the mouse button pressed. All the atoms selected by the highlighted rep will be moved the
same amount. Holding down the shift key and the left mouse button while moving the
mouse will rotate the atoms in the rep about the selected atom. If the middle mouse button
is held down instead, the atoms in the rep will rotate about a line drawn through the picked
atom and parallel to a line coming directly out of the screen. This behavior is similar to the
usual Rotate mode, except that coordinates of atoms are changed.
5.1.3 Hot Keys
When the mouse is in the graphics window, many commands are accessible via programmable hot
keys. Hot keys allow you to do things like change mouse modes or advance the animation by a
frame by simply pressing a key. There are a number of predened hot keys, as listed in tables 5.1,
5.2, 5.3, and 5.4. They can be printed out with the command user print keys. The commands
listed are the text commands which are executed when the hot key is pressed; these text commands
are explained in section 9.3.
To add or modify a hot key, use the command user add key key command. The key parameter
must be a single character. If command contains more than one word, it must be enclosed in braces
so that the subsequent command words are not ignored. When that key is pressed while the mouse
cursor is in the graphics display window, the associated command will be executed. Once you
have a set of commands which are particularly useful and familiar for you, you will want these hot
key commands automatically available every time you run VMD. This can be done by placing the
commands to add these items in your .vmdrc le, which is a le containing VMD text commands
that is executed every time VMD starts up. The basic method for setting up this le is described
in section 13.3.3. Once you have such a le, put the user add commands in it.
30
Hot Key Command Purpose
r, R mouse mode 0 0 enter rotate mode; stop rotation
t, T mouse mode 1 0 enter translate mode
s, S mouse mode 2 0 enter scaling mode
0 mouse mode 4 0 query item
c mouse mode 4 1 assign rotation center
1 mouse mode 4 2 pick atom
2 mouse mode 4 3 pick bond (2 atoms)
3 mouse mode 4 4 pick angle (3 atoms)
4 mouse mode 4 5 pick dihedral (4 atoms)
5 mouse mode 4 6 move atom
6 mouse mode 4 7 move residue
7 mouse mode 4 8 move fragment
8 mouse mode 4 9 move molecule
9 mouse mode 4 13 move highlighted rep
% mouse mode 4 10 apply force on atom
about x
k, Cntl-p rotate x by -2 rotate 2
about x
l, Cntl-f rotate y by 2 rotate 2
about y
h, Cntl-b rotate y by -2 rotate 2
about y
g rotate z by 2 rotate 2
about z
G rotate z by -2 rotate 2
about z
Cntl-a scale by 1.1 enlarge 10 percent
Cntl-z scale by 0.9 shrink 10 percent
Table 5.2: Rotation & scaling hot keys.
Hot Key Command Purpose
Alt-M menu main off;menu main on Show main menu
Alt-f menu files off;menu files on Show les menu
Alt-g menu graphics off;menu graphics on Show graphics menu
Alt-l menu labels off;menu labels on Show labels menu
Alt-r menu render off;menu render on Show render menu
Alt-d menu display off;menu display on Show display menu
Alt-c menu color off;menu color on Show color menu
Cntl-r display resetview Reset display
Alt-q quit confirm Quit VMD with conrmation
Alt-Q quit Quit VMD
Alt-h hyperref invert Invert hyper text mode (NOT help)
Table 5.3: Menu control hot keys.
The Windows version of VMD uses the vendor-provided SpaceWare driver exclusively, and oper-
ates somewhat dierently from the serial interface software used on Unix. The SpaceWare software
runs as a separate process from VMD and must be started and fully operational before VMD is
run. At startup time VMD attempts to open the SpaceWare interface, displaying the success or
failure of initialization as it occurs, with applicable diagnostic information. The SpaceWare driver
provides detailed control over the sensitivity and conguration of the Spaceball. In order to use
the Spaceball function keys with VMD the SpaceWare driver must be set to send button events
as Function 1 and Function 2 at a minimum. Once set, it should be possible to cycle through the
various VMD Spaceball operational modes as described below.
32
Hot Key Command Purpose
+,f,F animate next move to next frame
-,b,B animate prev move to previous frame
.,> animate forward play animation forward
, animate reverse play animation reverse
< animate reverse play animation reverse
/, ? animate pause stop animation
Table 5.4: Animation hot keys.
5.3 Using the Joystick in the Graphics Window
The Windows version of VMD provides support for the Windows joystick driver, and will enumerate
all available joystick devices at startup time. The joystick interface employed in VMD is quite
simple, allowing the use of three control axes to translate, rotate, and scale the molecule. The
joystick interface assumes a device with at least two buttons. The rst joystick button resets the
view in the display window, and the second button cycles through each of the available joystick
modes. When VMD rst attaches to each of the joysticks, they are initially disabled so that
miscalibrated joysticks do not adversely aect the VMD session. Each joystick is initially enabled
by pressing its second button to switch modes. All joysticks are independently controlled such
that multiple joysticks can control dierent control axes, and multiple users could interact with the
program with separate controls.
33
5.4 Description of each VMD form
VMD uses several dierent GUI forms, each designed to control a specic aspect of the molecular
display (e.g., to control the appearance of the graphics display window, or to change the colors of
displayed objects). The following sections give a brief description of the forms available in VMD;
the remaining chapters in this manual describe the actions which these forms make available in
greater detail.
5.4.1 Main Form
Figure 5.1: The Main form
The Main form is the main way to access other forms, load and save les, control trajectory
playback, change various global program settings, access help, and to quit the program. Many of
these actions can also be performed with the menu shortcut keys described in Table 5.3.
The Quit menu item exits VMD. This will bring up another form which veries that you do
indeed wish to exit. Press Yes to quit, or No to return to VMD.
Help
The Help menu items each start a web browser to display on-line VMD help documents. The
browser is designated by the environment variable VMDHTMLVIEWER [ 13.2]. Selecting a help item
multiple times may start multiple browsers. The default web browser is Mozilla for Unix systems,
and the built-in Explorer shell for Windows systems. The menu contains items for the VMD Quick
Help page, as well as the current Users Guide, FAQ, and links to various helpful information and
programs.
5.4.2 Main Form Molecule List browser
The Main form shows the global status of the loaded molecules. Any number of molecules may
be displayed by VMD simultaneously. Each molecule can separately be hidden from view or xed
in place (e.g., prevented from being aected by mouse rotation commands). The form contains
controls to change the status of the molecules individually or in groups.
The browser displays information about each molecule. A unique integer ID is assigned to each
molecule by VMD when it is loaded. The Molecule is the le name which contained the topology
information. Atoms shows the number of atoms in the molecule, and Frames gives the number of
frames associated with the le.
34
Next to each molecule is a set of status ags, which indicate the current Status of each molecule.
Each molecule has the following characteristics, which can be on or o:
Top (T)
Top indicates the default molecule used in the text commands when nothing is specied for the
mol text command. It is also used in some forms (like Graphics and Animate) to determine
certain values. There can be only one top molecule at a time.
Active (A)
Several commands and actions in VMD operate on many molecules. These commands, unless
specically specied otherwise, will do their action for all the active molecules. The primary
use for this control is to prevent some molecules from being animated. Inactive molecules will
not animate when the play button is pressed.
Drawn (D)
If a molecule is Drawn then it is being displayed in the graphics display window. This is
useful for temporarily hiding a molecule from view without deleting it.
Fixed (F)
Fixed molecules do not undergo rotation, translation, or scaling. Note that while it may seem
that one molecule has been moved relative to another, the dierence is only apparent. The
internal coordinates do not change when a standard rotation is applied by using, for example,
the mouse. It is possible, however, to change the coordinates of atoms in a molecule, using
the text command interface, and by using the atom move picking modes.
Changing the Molecules Status
The status of a given molecule can be changed by selecting the molecule in the browser and double-
clicking the appropriate ag. Only one molecule can be top at any one time, so the previous top
molecule will change status when another is toggled.
Saving Trajectory Frames
Using the Save Coordinates. . . menu item, you can write trajectory frames to a le in one of several
le formats including PDB, DCD, Amber CRD, etc. This feature may be used to write out a new
trajectory in a single le after assembling many frames from dierent sources (such as PDB CRD,
DCD or Gromacs les, or even from a remote simulation). You can also use this, in combination
with the molecule le browser as a way to make PDB les from a DCD/CRD trajectory.
You can either save the entire stored trajectory, or a slice of the data by using the Amount
chooser [ 5.4.4]. Then select the appropriate output le type in the File Type chooser, and press
the Save button in the bottom right corner. This brings up the le browser, which you can use
to enter the new lename. Once you press the Save button in the browser, the le will be written
without further conrmation. See the section on the atomselect writexxx [ 9.3.2] command for
information on how to write atom coordinates for an atom selection in a PDB le.
Deleting Trajectory Frames
You can delete frames from memory through a dialog box. To bring it up, start by selecting a
molecule and choosing the Delete Frames. . . from the Molecule menu, or by double-clicking on the
35
Frames column for that molecule in the Molecule Browser. On this is done, choose the range of
frames you wish to delete with the First and Last controls, and then press the Delete button. There
is no conrmation of deletions.
The Stride control allows you to keep some frames in the range using the specied interval. For
example, if your range contains 10 frames labeled 0 through 9, and you use a stride of 4, the frames
numbered 0, 4 and 8 will be kept. A stride of 0 (zero) implies that all frames will be deleted.
Deleting a Molecule
The Delete Molecule menu item deletes all the selected molecules. There is no prompt verifying the
deletion, so take some care. If a deleted molecule was the top molecule, a new top molecule will be
set from the remaining structures.
GUI Shortcuts
There are a few useful mouse-based shortcuts that can be used in the Molecule List browser. Here
is a list:
Double-clicking on a molecules name brings up the Rename Molecule dialog box.
Double-clicking on a molecules number of frames brings up the Delete Frames dialog box.
Triple-clicking on the T (top) in front of a molecule focusses on that molecule by making it
the only molecule to be displayed (D) and active (A). Furthermore, the view is reset and the
molecule gets selected in the Representations form.
5.4.3 Main Form Animation Controls
Figure 5.2: The Main form animation controls
Each molecule in VMD can contain multiple sets of atomic coordinates, which may be animated
to show its motion over time. The coordinate sets can come from a molecular dynamics simulation,
or simply multiple versions of the same molecular structure. The main form contains controls for
animated playback of these trajectories. The controls contains several buttons which act like the
buttons on a VCR or DVD player. The buttons provide a way to play the trajectory, step forward,
stop, go to a specic frame, and go to the beginning or end. The status and frame counters
shown in the animation control reects the state of the top molecule. Commands entered via this
control, however, aect all active molecules [5.4.2], not just the top molecule, allowing concurrent
animation of multiple molecules.
Animation Speed
The rate of playback can be controlled in two ways. The Step control changes the animation step
size. By default, the frame step is 1, so each step of the playback increases (or decreases) the
36
animation frame number by one. If the frame step is 5 then the animation proceeds ve times
faster because only a fth of the frames are shown. The Speed slider at the bottom of the form also
aects the playback speed. Internally, this controls how many screen updates are needed between
each step. By default, the slider is at the far right indicating that one step is performed for each
screen redraw. Moving the slider to the left increases the minimum time required between updates.
Jumping to Specic Frames
The start and end buttons are used to simplify the comparison between the initial and nal struc-
tures. The start button resets the current animation to the rst frame, and end jumps to the last
frame. If you need to jump to a specic frame, enter the frame number in the frame counter text
area next to the start button and press enter. One thing to bear in mind is that the frame number
starts at 0, so to jump to the 5th frame, you must actually enter 4 here. The animation controls
are all relative to the top molecule [5.4.2].
Looping Styles
When the animation is playing forward and reaches the end of the data available for the top
molecule, one of three possible actions takes place, as specied in the style chooser. The default
is Loop, which will reset the active molecules to the rst frame and continue playing forward.
Once will stop the animation when it reaches the last frame, and Rock reverses the direction of
animation. The actions are symmetrical when the animation is playing in reverse.
5.4.4 Molecule File Browser Form
Figure 5.3: The Molecule File Browser form
The Files form is used to load a le from disk into a new or existing VMD molecule. It can be
brought up by choosing New Molecule. . . from the File menu, or by hilighting a molecule in the
Main form5.4.1 and choosing the Load Data Into Molecule. . . menu item. Once the form appears,
select the le you want by using the le browser or by typing the lename into the text entry
area. By default VMD will try to guess the type of le you are loading by matching the lename
extension with one of the le reader plugins in the le type list (the available le types are described
37
in Chapter 4). If VMD is unable to guess the appropriate le type or guesses incorrectly, you must
select it from the list manually.
You can control into which VMD molecule you want to load your data by selecting it from
the Load les for: popup menu at the top of the form. If the le being loaded is intended for a
new molecule, select New Molecule instead. If the le being loaded contains additional coordinate
frames, electron density map, or other ancillary data for an existing molecule, choose the appropriate
molecule from the selection list at the top of the form. If the le being loaded contains trajectory
frames , you have the option of loading a subset of the trajectory skipping ranges or strides of frames
rather than the whole thing. You can also select for VMD to load all frames before continuing on,
or to load them in the background so that you may continue to interact with the menus and forms
while it loads additional frames . If the le being loaded contains multiple volumetric data, you
may select which data sets you would like to load.
Once you have selected the le to be loaded, the appropriate le type, and the way it will be
loaded, press the Load button and VMD will being loading the selected le. Any informational
messages, errors or warnings which occur while loading the le will appear in the text window.
Reading Trajectory Frames
VMD can read in new coordinate sets from one of several le formats such as PDB, CRD, DCD,
or Gromacs les. The new coordinate sets are appended to the end of the stored frames for the
selected molecule. Loading coordinate data is like loading any other le, select it with the le
browser make sure the le type is set correctly for the le being loaded, and then press the Load
button.
By default, VMD will load all of the frames contained in a coordinate or trajectory le.
Sometimes you may not want to read in a whole coordinate or trajectory le. For example, you
may only want the last frame, or every tenth frame. You can do this by changing the options in the
Frames control of Files form. The Frames controls consist of three numeric input elds labeled
First, Last, and Stride. These make it possible to use a subset of the frames, starting at frame First
and selecting every Stride frames until the Last is reached. For instance, to select every fth frame
between frames 14 and 98, set:
First to 14
Last to 98
Stride to 5
(Remember that frame numbers in VMD start at 0, so frame 0 is the rst frame.) The value
-1 is a special number; setting First to -1 is the same as starting at the rst frame, Last = -1 is
the same as ending at the last frame, and Stride = -1 is the same as taking one step.
5.4.5 Mouse Menu
The Mouse menu indicates and controls the behavior of the mouse when the mouse moves and
clicks within the graphics window. Mouse clicks and drags can aect VMD in one of two ways. It
can change the view of the scene, either by rotating, translating, or scaling. It can also pick objects
in the scene, causing some further action to be taken. These behaviors are all reected in the state
of the Mouse menu.
Below, we describe the main parts of the Mouse menu.
38
Mouse modes
The top three menu items select whether the mouse will rotate, translate, or scale the scene when
the user clicks and drags with the left mouse button.
Pick modes
These modes, located right below the mouse modes in the Mouse menu, control how the mouse
aects objects in the scene (as opposed to how the mouse changes the view of these objects). Note
that any time you choose a new pick mode, the current mouse mode changes to Rotate.
Center changes how VMD rotates and scales the scene. To get a feel for how this works,
select Center from the Mouse menu, then click on an atom in the scene. If you now rotate
the scene by clicking and dragging with the left mouse button, the scene should rotate about
the picked atom. If you change the view mode to Scale using the View Mode pulldown
menu, the scene will expand while keeping the picked atom in view. The picked atom will
remain the center atom until a new atom is selected as Center, the Reset View button is
pressed, or a new molecule is loaded.
Query prints information about the item (e.g. the atom name) on the text console window.
Label adds labels to atoms in the scene. Labels include atoms, bonds, angles, and dihedrals.
These labels require, respectively, one, two, three, and four atoms to be picked. For the latter
three label types, the numerical value of the geometric label is displayed, along with a stippled
line connecting the picked atoms. The units for Bonds corresponds to whatever units the
coordinate le is written in. Angles and Dihedrals are measure in degrees.
Labels can then be manipulated through the Labels form.
Move changes the actual coordinates of atoms in the scene. Note that this is dierent from
simply changing the view. Clicking on one of the buttons in the Mode Mode menu selects
what group of atoms to move. Atom moves only the selected atom. Residue moves all
atoms in the same residue (e.g., amino acid or nucleotide) as the selected atom. Fragment
moves all atoms connected by a bond to the picked atom. Molecule moves every atom in
the molecular structure. Highlighted Rep is the most exible; it moves all atoms in the
highlighted representation in the browser window of the Graphics form.
Atoms are moved by clicking and dragging with the left mouse button. If the shift key is held
while the mouse is moved, the aected atoms are rotated about the selected atom. Rotating
atoms with the left button rotates about the x or y axis of the screen; rotating with the
middle or right button rotates about an axis perpendicular to the screen.
Note that there is currently no way to undo Move operations, so the atom coordinates should
rst be saved to a le.
Force applies a force to selected atoms in a running simualtion. These forces will be visible
only if an IMD connection has been established. Clicking and dragging with the left mouse
button will apply a force to the selected Atom, Residue, or Fragment, as in Move Mode.
Clicking with the middle or right button will cancel the force on the selected atoms.
Move Light allows the lights to be positioned around the scene. Individual lights are turned
on or o in the Display form. Selecting one of the lights in the Move Light menu rotates the
39
selected light about the origin. The Move Light Mode can also be cancelled by changing into
any other pick mode or mouse mode.
Add/Remove Bonds adds a bond between two clicked atoms if there is not one present,
and removes the bond otherwise. Both atoms must belong to the same molecule.
5.4.6 Display Menu
Figure 5.4: The Display menu
The Display menu controls many of the characteristics of the graphics display window. The
characteristics which may be modied include:
Reset View This menu item can be used to force VMD to reset the scene back to the
default viewing orientation and scale as is done when a molecule is rst loaded.
Stop Rotation This menu item stops autorotation of the scene. The scene can be au-
torotated by quickly dragging the mouse while briey depressing and releaseing the mouse
button, leaving the scene spinning until it is stopped either by this menu item or by further
mouse interactions.
Perspective The view of the scene can be Perspective or Orthographic. In the perspec-
tive view (the default), objects which are far away are smaller than those near by. In the
orthographic view, both objects appear at the same scale. Note that several of the sup-
ported external rendering programs do not support orthographic rendering. As such, it may
be necessary to fake it by translating the scene far away from the camera, and apply a
zoom factor. This has the eect of signicantly reducing the perspective, while not truly an
orthographic view.
40
Antialiasing Turns antialiasing on or o. Antialiasing helps smooth out the jagged ap-
pearance of displayed geometry resulting from the inherently discrete pixels on the display
device. The antialiasing feature is only available on platforms which support full-screen an-
tialiasing, sometimes known as multisample antialiasing. Several SGI and Sun graphics
systems fully support this feature. On platforms lacking the multisample capability, there
may be alternate ways to perform full-screen antialiasing by selecting an option in the display
driver setup. Windows machines most commonly place these controls in the display driver
conguration panel.
Depth Cueing Turns depth cueing on or o. Depth cueing causes distant objects to blend
into the background color, in order to aid in 3-D depth perception. The depth cueing settings
controlled in the Display Settings window. The Cue Mode parameter controls which type
of fog equation is used. The Linear depth cueing mode provides a simple depth gradient
with a dened starting point and endpoint. The Exp and Exp2 depth cueing modes take a
density parameter, and generally blend into the background color much more sharply than
the linear depth cueing mode. Scaling up the molecule will increase the amount of depth
cueing eect that is visible, since it will occupy a larger depth range. Scaling the molecule
size down decreases the depth cueing eect. Translating the molecule into and out of the
screen will cause it to blend into and out of the background color.
Culling Turns backface culling on or o. This feature is primarily used to accelerate ren-
dering performance on software based implementations of OpenGL, such as Mesa. Backface
culling actually reduces performance on some hardware renderers, so youll have to use your
own best judgement on whether or not it is helpful to use on your specic computer system.
FPS This option enables or disables on-the-y display of the achieved VMD rendering frame
rate. The frame rate is displayed in the upper right hand corner of the graphics window when
it is enabled.
Lights The graphics display window can use up to four separate light sources to add a
realistic eect to displayed graphical objects. The Lights On browser turns these light sources
on or o. If the number is highlighted, the light is on, and clicking on it turns the light o.
See section 5.1.1 for more discussion regarding lights.
Axes A set of XYZ axes may be displayed at any one of ve places on the screen (each of
the corners or the center) or turned o. This is controlled by the Axes chooser.
Stage The Stage browser controls the stage, which is a checkerboard plane that can be
located in any one of six places or turned o.
Stereo, Eye Sep, and Focal Length These controls are found in the Display Settings
form. These controls set the stereo mode and parameters; stereo is discussed fully in chapter
7. The Stereo chooser changes the stereo mode, while the Eye Sep and Focal Length controls
change the eye separation distance and the focal length, respectively.
Cachemode The Cachemode toggle controls whether or not VMD uses a display list caching
mechanism to accelerate rendering of static geometry. This feature can be extremely benecial
for achieving good interactive display performance on tiled display walls, and for remote
display over a network. Caching cannot be performed while animating trajectories, so the
41
performance benet is only possible interactive rotation and zooming of static molecular
structures.
Rendermode The Rendermode chooser controls which low-level rendering method VMD
uses. The Normal rendering mode is the default VMD rendering algorithm based on standard
xed-function OpenGL. The GLSL rendering mode uses OpenGL Programmable Shading
Language to implement real-time ray tracing of spheres, alpha-blended transparency, and
high-quality per-pixel lighting for all geometry. On machines with high performance graphics
boards supporting programmable shading, the GLSL rendering mode provides quality on par
with many of the external software renderers supported by VMD but at interactive display
rates.
Clipping Planes (Near Clip and Far Clip) These controls are found in the Display
Settings form. Only those parts of the scene between the near and far clipping planes are
drawn. The display clipping planes also set the depth cueing start and endpoints. Objects at
the near clipping plane are distinct and crisp, objects at the far clipping plane will be blended
into the background. Clipping planes positions are changed with the Near Clip and Far Clip
controls. It is not possible for the near clip to be farther away than the far clip. When using
stereo, it may be useful to set the near clip plane much lower than the default value. This
makes the geometry pop out of the screen a bit more, and can be used for greater dramatic
eect.
Screen Height (Hgt) and Distance (Dist) These controls are found in the Display
Settings form. The screen height, along with the screen distance, denes the geometry and
position of the display screen relative to the viewer. The screen height is the vertical size of
the display screen, in world coordinates. Each molecule is initially scaled and translated to
t within a 2 x 2 x 2 box centered at the origin; so the screen height helps determine how
large the molecule appears initially to the viewer.
The screen distance parameter determines the distance, in world coordinates, from the origin
to the display screen. If this is zero, the origin of the coordinate system in which molecules
(and all other graphical objects) are drawn coincides with the center of the display. If distance
is negative the origin is located between the viewer and the screen, if it is positive, the screen
is closer to the viewer than the origin. A negative value puts any stereo image in front of the
screen, aiding the three-dimensional eect; a positive value results in a stereo image that is
behind the screen, a less dramatic eect (but easier to see, for some people) stereo eect.
Figure 5.5 describes the relationship between the screen height, the screen distance, and the
world coordinate space.
5.4.7 Graphics Form
The Graphical Representations or Graphics form controls how molecules are drawn. Molecules are
represented by reps, which are dened by four main parameters: the selection [ 6.3], the drawing
method [ 6], the coloring method [ 6.2], and the material [ 6.2.5]. The selection determines
which part of the molecule is drawn, the drawing method denes which graphical representation is
used, the coloring method gives the the color of each part of the representation, and the material
determines the eects of lighting, shading, and transparency on the representation.
42
X
Y
Z
SCRDIST
i.e. -2.0
SCRHEIGHT
i.e. 6.0
Viewers
Eye Position
4/3 SCRHEIGHT
i.e. 8.0
Figure 5.5: Relationship between screen height (SCRHEIGHT), screen distance to origin
(SCRDIST), and the viewer
Draw Style Tab
Select a molecule for editing using the Selected Molecule chooser at the top of the form. The
browser below this chooser lists the reps available for the molecule. Each line of the browser
summarizes information about the drawing method, the coloring method, and the selection. Below
this browser, choosers and a text input led reect the current state of the rep, and provide controls
for changing the properties of the rep. Each drawing method has specic controls which will appear
when it is selected. When the ColorID coloring method is selected, a text entry box is shown
allowing you to specify the index of a color to use for the selection, which may be a number from
0 to 16.
Changing a rep. To change a representation, select it in the representation browser. The atom
selection for that rep will appear in the Selected Atoms text area and the controls will update to
reect the current settings. Changing the settings will immediately aect the displayed representa-
tion if the Apply Changes Automatically check box is selected. When it is disabled updates will only
occur when the Apply button is pressed. Changing the drawing method brings up method-specic
controls and defaults. If you go back to the previous draw style, VMD restores any changes that
you may have made to the settings. Pressing the Default button will restore the default settings.
The display will be updated after every change.
Adding a rep. To add a new representation of the molecule, enter the selection into the Atom
Selection text area (or keep what is there) and press Create Rep. This adds the representation to
the currently selected molecule.
43
Figure 5.6: The Graphics form (in Draw Style mode)
Deleting a rep. To delete a representation, select the representation in the browser and press
the Delete button. Bear in mind that this does not delete the molecule, it only deletes one of its
graphical representations.
Hiding a rep. To hide a rep, double-click its entry in the browser. The text will turn pink to
indicate that the rep is hidden. Turn the rep back on by double-clicking again on the same line.
Hidden reps will not recalculate their geometry if the animation frame changes until the rep is
turned back on.
Selections Tab
The Selections tab provides access to browsers which display the lists of atom names, residue names,
and so forth for the selected molecule. When the Selections tab is pressed, several browsers appear
in place of the drawing and coloring method controls. These are used to list the available keywords,
macros, and values for use in selecting atoms for the associated representation. The top browser lists
44
Figure 5.7: The Graphics form (in Selections mode)
singlewords and macros such as all, water, and hydrophobic. The botton left browser contains
a list of the keywords and functions understood by the selection command [6.3]. If a keyword is
selected which can take on a value (for instance, name and index), then the possible names will be
displayed in the bottom-rightmost browser. The functions can be identied by the ( to the right
of the name. After selecting a keyword, the right browser will display all the names associated
with the keyword. For example, selecting resname in the left browser will show all the three-letter
residue names known for the selected molecule.
Clicking on a eld in the value browser will add it to the selection text eld. Double clicking a
keyword eld adds the keyword to the text eld. Press Apply to actually change the atom selection
for the current rep. Press Reset to restore the atom selection to its original value.
The Selections tab also shows the atom selection macros that have been dened. These macros
let you dene a commonly used atom selection as a single word so that it can be inserted into a rep
more conveniently. Atom selection macros can currently be dened only through the Tcl [9.3.2]
or Python [10.3] text interfaces; see these sections for details.
45
Trajectory Tab
Selection and Color auto-update. When an atom selection such as water within 3 of
protein is made, the atoms in the selection are computed for the current animation frame. When
the animation frame changes, the selection is not normally recalculated; thus the displayed atoms
may not correspond to those that would be selected if the atom selection were performed for the
new animation frame. If the Update Selection Every Frame checkbox is highlighted by clicking on the
checkbox, then the atom selection for the current rep will be recalculated every time the animation
frame changes. Similarly, if the Update Color Every Frame checkbox is activated, the color will be
recalculated for every frame.
Color Scale Data Range. Several of the coloring methods available in Draw Style tab operate
over data elds that have no specically implied range of values. It is often useful to highlight a
very specic range of data values, in order to accomplish this the color scale range can be manually
set to a specic starting and ending values, overriding the default behavior which is to autoscale
from the minimum value to the maximum value. This feature is particularly useful when displaying
trajectories, since the range of values of interest may be quite dierent from the autoscaled range
for a single frame or all frames.
Draw Multiple Frames. Draw multiple trajectory frames or coordinate sets simultaneously.
This setting allows the user to select one or more ranges of frames to display simultaneously. The
frame specication takes one of the following forms now, frame number, start:end, or start:step:end.
Trajectory Smoothing. The Trajectory Smoothing Window Size is used to control the application
of a per-representation windowed-averaging smoothing function. This simple smoothing feature can
be used to eliminate much of the thermal noise inherent in a molecular dynamics trajectory so that
one can more easily see structural changes occuring over a wider time scale. The window size
parameter controls how many frames are averaged together to produce the coordinates which are
actually displayed. One important consideration when using the trajectory smoothing feature is
that VMD does not take periodic boundary conditions into consideration when smoothing trajectory
coordinates, so any atoms which wrap around within the span of the window will cause erratic
motions in the displayed representation. This can be avoided by unwrapping trajectory coordinates
prior to loading into VMD or by using atom selections to eliminate atoms which wrap around.
Periodic Tab
The Periodic tab controls the display of periodic images of a molecule. In order to display periodic
images, a molecule must have unit cell information set for a, b, c, alpha, beta, and gamma, which
are discussed in section 9.3.21. When the proper unit cell information is present, the periodic
display feature can show periodic images of the unit cell by transforming and rendering additional
copies of the structure. The current implementation of this feature doesnt provide for complex
crystallographic symmetry operations. Unit cells that can be replicated by translation along the
three unit cell axes are the only ones supported presently. The periodic images to be drawn are
selected by enabling images in one or more of the six faces of the unit cell. The Self image selects
the untranslated unit cell itself, so that one my render a representation consisting of only replica
images. This feature allows the unit cell and its periodic images to be displayed using dierent
materials, for cases where it is desirable to draw more attention to the original unit cell or to one
46
ore more of the replicas. The Number of Images counter controls how many replicas are made in
each of the six directions. Some le formats read by VMD may not include unit cell information, in
such cases you can use the scripting interface to set the unit cell information manually. PDB les
containing CRYST1 records are an example of a le format that provides unit cell information.
5.4.8 Labels Form
Figure 5.8: The Labels form
This form is used to manipulate the labels which may be placed on atoms, and the geometry
monitors which may be placed between atoms. Labels are selected with a mouse, as discussed in
section 5.1.2. Once selected, the Labels form can be used to turn dierent labels on or o or to delete
them entirely. Also, labels displaying geometrical data such as bond lengths may be graphically
displayed using this form.
Label categories
The Category chooser (in the upper left) is used to select which category of labels to manipulate.
The dierent label categories include:
Atoms, which are shown as a text string next to the atom listing the name and residue of the
atom;
Bonds, which are shown as dotted lines between the atoms with the bond length displayed
at the bond midpoint;
Angles, which are shown as dotted lines between the three atoms with the angle displayed at
the center of the dened triangle;
Dihedrals, which are shown as dotted lines between the four atoms with the dihedral angle
(the angle between the planes formed by the rst three atoms and the last three atoms) shown
at the midpoint of the torsional bond.
47
Springs, which are shown as dotted lines between the atoms with the bond length displayed
at the bond midpoint;
All the labels for the selected category which have been previously added are displayed in the
browser in the center of the form. The line itself contains from 1 to 4 atom names, depending
on the category; the atom names have the form <residue name><residue id>:<atom name>
followed by either (on) or (off). The last word indicates if the label is turned on or o.
Modifying or deleting a label
A label can be turned on or o without deleting it, by selecting the label in the central browser and
pressing the Hide button. To turn it back on, select it again then press the Show button. Press the
Delete button to delete it. This browser allows multiple selections, which, for example, allows you
to delete several labels at once. To select everything in the current category, press Select All; to
unselect them, press Unselect All. If nothing is selected, the action is applied to everything. Thus,
one way to turn everything o is to press Unselect All then press Hide. (It may seem counterintuitive,
but it was done this way so all the labels could be deleted by just pressing Delete.)
Pick information
The Picked Atom tab displays information about the last atom picked by the mouse. This informa-
tion is also echoed to the vmd console. The data in the will remain in until a new label is selected
by the mouse. Information about the following elds is identied:
Molecule - the name of the molecule referenced
XYZ - the position of the atom in 3D space
Resname - the type of the amino or nucleic acid to which this atom belongs
ResID - the internal VMD ID number of the entire residue to which the particular atom
belongs. E.g., ResId for an atom of a protein is the same as the residue number of that atom
as listed in its PDB le.
Name - the name of the atom as it appeared in the coordinate le
Type - the type of the atom, as determined by an internal VMD match-up of the given name
to a likely atom type associated with that name
Chain - if the coordinate le contained data in the Chain eld for this atom, then that data
is given here.
Segname - the name of the segment to which this atom belongs
Index - the internal VMD index used to identify the atom; this is useful for specifying selection
syntax to generate dierent representation styles for particular atoms. For PDB les Index
corresponds to the atom number listed in the le minus 1 (so that the index starts with 0).
Value - the calculated length of bonds, angles, or geometric measurements performed by the
selected label
48
Plotting a labels value
If the label has a numeric value (such as a bond length geometry monitor), it is easy to graph
the change of the value over time (for multiple frames in an animation). The Graph button calls a
Tcl script to plot the data for the selected labels. You can create your own script to handle label
plotting simply by creating a Tcl proc named vmd labelcb user. The proc should accept three
arguments. Have a look at the default scripts in the VMD scripts directory, found in the VMD
installation directory under scripts/vmd/graphlabels.tcl. If no supported graphing program is
available, a dialog box will be presented which will allow you to save the values of the labels to a
le.
5.4.9 Color Form
Figure 5.9: The Color form
VMD maintains a database of the colors used for the molecules and the other graphical objects in
the display window. The database consists of several color categories; each color category contains
a list of names, and each name is assigned a color. The assignment of colors to names can be
changed with this form. There are 16 colors, as well as black (the VMD color map), and this form
can also be used to modify the denitions of these 17 colors. For more about colors, see the chapter
on Coloring [6.2].
To see the names associated with a color category, click on the category in the Category browser
located on the left side of the form. Click on the name to see the color to which it is mapped. To
change the mapping, click on a new color in the browser to the right of the Category browser. For
instance, to change the background to white, pick Display in the left browser and Background
in the center one. The right browser will indicate the current color (which is initially black for the
background). Scroll through the right browser and select white to change the background.
Changing the RGB Value of a Color
The Color Denitions tab at the bottom of the Color menu lets you change the RGB denition
of the 17 palette colors. Select a color to edit using the browser at the bottom left corner of the
49
menu, then slide the three sliders to set the amount of each red, green and blue component. Default
restores the original color denition, and Grayscale toggles whether or not the three sliders will
move together as a unit. Color denitions are immediately updated in the graphics window, so you
can see the result of your editing right away.
Color Scale
Several of the coloring methods in the graphics form (e.g., Beta, Index, Position) are used to color
a range of values, as opposed to a list of names. The actual coloring is determined by the color
scale [6.2.4].
The color scale used to assign these colors is set in the Color Scale tab of the color menu. Choose
one of the ten color scales from the chooser, and adjust the Oset and Midpoint sliders until the
color scale shown at the bottom of the tab is as desired.
5.4.10 Material Form
Figure 5.10: The Material Form
This form is used to create and modify material denitions. The material denitions created
here will show up in the pulldown menu in the Graphics Form, allowing you to apply a material to
a given representation.
The upper left corner of the Materials Form contains a browser listing all the currently dened
materials. Below this browser is a set of ve sliders which indicate the current materials settings for
the material highlighted in the browser. Highlighting a dierent material in the browser by clicking
with the mouse will update the settings of the sliders. Conversely, moving the sliders will change
the denition of the the currently highlighted material in the browser. Pressing the Default
button will restore either of the rst two materials, Opaque and Transparent, to their original
settings.
50
To create a new material, press the Create New button in the upper right corner of the
Form. A new material with a default name will be created and displayed in the browser window.
This name can be changed at any time to something more descriptive by typing in the input box
to the right of the material browser and pressing enter (note that the names of Opaque and
Transparent cannot be changed). You can now edit the properties of this material using the
sliders at the bottom of the form. All materials in the materials browser, including those you
create, will appear in the Material pulldown menu in the Graphics form.
To experiment with the material settings, rst create a new material so that you can edit its
values. Next, load any molecule, change its drawing method to VDW representation, and using the
Material pulldown menu in the Graphics form, change the representations material to the material
you just created. Now, go back to the Materials form, highlight the new material in the browser,
and change some of the values in the sliders. The eect of changing shininess should be especially
dramatic.
5.4.11 Render Form
This form is used to export the currently displayed graphics scene to an image le or to a geometric
scene description le suitable for use by one of several external renderers, which can produce a
nal image. The supported rendering packages are listed in table 8.1. See Chapter 8 for detailed
information on how rendering is performed using external programs, as well as information on 3-D
printing and other uses of the exported scene description les.
Figure 5.11: The Render form
The rendering process works in two stages. The rst stage exports the displayed VMD scene
to a text or image le in the selected format. The second (optional) stage renders the exported
le, potentially displaying the results when complete. The exported le is named in the Filename
eld; a default name is given when a new format is selected, so it is best to hold o entering the
lename until after the le format is selected. Another way to select the lename is available by
pressing the Browse button, which opens up a le browser. Pressing the Start Rendering button
writes the data le. After that, the Render Command is executed. The default command should
start the appropriate rendering program if it is available.
Some of the rendering commands have been set to call a display program on the rendered image
when it is completed. VMD will wait for the display program to nish, which causes VMD to freeze
until the display program closes, so you may want to run the job in the background. This can be
51
done (on Unix) by enclosing the existing text with ()s and putting an & at the end. For example,
the way to make the Raster3D render command run in the background is:
(render < %s -sgi %s.rgb; ipaste %s.rgb)&
5.4.12 Tool Form
Figure 5.12: The Tool form
The Tool form is used to set up external 3D pointers, buttons, force-feedback devices, and the
VMD tools that they control. VMD communicates with input devices through CAVElib, FreeVR,
or via Virtual Reality Peripheral Network (VRPN), or with direct operating system interfaces.
Since VRPN provides networked device abstraction, VMD doesnt have to be running on the same
computer that VRPN devices are attached to. With VRPN, you may use buttons, trackers, and also
force-feedback (haptic) devices such as the PHANToM. In the CAVE or FreeVR, VMD recognizes
two types of devices: buttons and trackers. The built-in Spaceball driver can also be used to control
tools.
Conguring input devices
To use input devices with VMD tools, you need a sensor conguration le, in your home
directory called .vmdsensors (see the VMD Installer Guide). In this le, any number of devices
can be specied, using a universal sensor locator (USL). The format for a USL is as follows:
USL type://place/name:nums
type the type of sensor (vrpntracker, vrpnbuttons, vrpnfeedback, cavetracker, cavebuttons,
or sballtracker)
place the machine that controls it. Devices that cannot yet be used on arbitrary computers
over the network must have the keyword local here to be compatible with future versions.
52
name the name of the device within that machine. If multiple devices cant currently exist,
such as with the CAVE, then a standard name should be used, such as cave, so that the
same USL will make sense in the future, when multiple devices are allowed.
nums a comma-separated list of numbers of devices belonging to that names (optional,
defaults to zero). Some devices demand only one number or a specic number but button
devices should work correctly now.
The lines of a sensor conguration le come in four avors:
Comments begin with # and are ignored.
Empty lines are also ignored.
Device lines have the form device name USL, where name is the name that VMD will use
to refer to the device, and USL is the devices USL.
Options tell VMD how to use the most recently listed device. Currently, there are four
supported options:
scale x scales the position of a tracker by a factor x.
offset x y z adds a constant vector to the position of a tracker.
rot rightleft A
00
A
01
. . . A
33
multiplies the orientation matrix returned by a
tracker on either the right or the left by the matrix A.
forcescale x multiplies the force applied to a force-feedback device by the amount x.
Here is a simple example, showing some of the things you can do with a sensor conguration
le, for a more complete example, please refer to the .vmdsensors le that came with your VMD
distribution:
### Sensable PHANTOM via VRPN
### http://www.sensable.com/
### The Phantom haptic device connected to the computer "odessa"
device phantomtracker vrpntracker://odessa/Phantom0
scale 10
rot left 0 0 -1 0 1 0 1 0 0
device phantombuttons vrpnbuttons://odessa/Phantom0
device phantomfeedback vrpnfeedback://odessa/Phantom0
Using Tools
There are several dierent tools, each of which can be used with any of the input devices
1
:
The Grab Tool mimics a pair of tweezers, and can be used to move molecules around on
the screen without any keyboard or mouse commands. Pressing a button connects the 3d
cursor to the nearest molecule. Then, moving or rotating the tracker will cause the molecule
to move or rotate around on the screen.
1
The tools have been designed to allow VMD to use haptic devices. Most of the tools can give force-feedback to
the user, but none of them require haptic devices in order to operate.
53
The Rotate Tool is a tool for precisely rotating molecules with haptic devices. When a
button is pressed and released, the cursor is again connected to the molecule. With this tool,
however, the center of the molecule is xed, and the end of the haptic pointer is forced to
lie on the surface of a sphere about this center. Moving the device around the surface of
the sphere rotates the molecule, and another button click releases the molecule. There are
detentes like the clicks commonly felt in a 2d dial on the surface of the sphere, arranged
so that the user can rotate the molecule to precise 90-degree points. If the user holds down
the button for a while initially, he can feel the sphere and the detentes, but do not aect the
molecule. This preview mode allows the user to nd a good point from which to start the
rotation.
The Joystick Tool is the three-dimensional equivalent of a Joystick, for haptic devices.
Pressing the button creates a virtual spring, holding the device to its current location. If it
is pushed away from this point in some direction, the selected molecule starts sliding in that
direction, with a velocity that is proportional to the displacement of the device. The joystick
tool shows how a three dimensional input device can be used to supply relative (dierential)
coordinates instead of absolute coordinates.
The Tug Tool is a tool that allows interaction with running molecular dynamics simulations.
Pressing the button connects the device with a simulated spring to the nearest atom, and
pulling on it adds a force to the simulation. If a haptic device is being used, the user will feel
a force on his hand that is proportional to this force. In this way, the tug tool implements
something like the click-and-drag that is commonly used with windowing systems.
If an atom selection is assigned to the Tools, the the Tug Tool will apply a force to all the
atoms in the selection. The force applied will be proportional to the masses of the atoms in
the selection, so that all atoms experience the same acceleration. When a Tool Selection has
been assigned, the Tug Tool will always aect that selection, even if the button is pressed far
from any atoms in the selection; this is intended to make it easier for the user to apply forces
only on those atoms he/she intends to steer.
The Spring Tool also allows interaction with running molecular dynamics simulations. It
works like the Tug Tool except that when the button on the tracker is released near an atom,
the simulated spring is connected to it. See section 5.4.8 for information on viewing and
modifying the list of active springs.
The Pinch Tool is similar to the Tug Tool, except that force is applied only along the axis
dened by the orientation of the tracker.
The Print Tool is meant to be used as a debugging aid when one rst sets up VMD for
use with VRPN, the CAVE, or other 3-D input devices. When enabled, this tool prints text
messages to the VMD console indicating the current position of the tool in question. This
tool is useful when calibrating the various transformation matrices that operate on tracker
position and orientation data (whether in VMD or in VRPN, CAVElib, etc).
To add a new tool to a VMD session, open the Tool form and click the Create Tool button. The
tools number and type are displayed in the list to the left. Devices can be added to the tool by
selecting them from the Add Device menu, or removed with the Delete Device button. Some of
the options that can be specied in the sensor conguration le can be edited in using the controls
below, and the tools type can be changed with the Type menu.
54
5.4.13 Simulation Form
VMD has the ability to work with a molecular dynamics program running on another computer,
to interact with and display the results of a simulation as they are calculated. A major feature in
VMD is the ability to add perturbative steering forces to a running simulation, which are incor-
porated directly into the dynamics calculation; we refer to this capability as Interactive Molecular
Dynamics (IMD). In order to run and IMD simulation it is necessary to have a molecular dynam-
ics program that supports the IMD communication protocol. To date, two such programs exist;
NAMD, developed at University of Illinois, and Protomol, developed at Notre Dame. The rest
of the discussion in this chapter assumes you are using NAMD. See the NAMD home page
2
for
information on obtaining NAMD.
Interactive Molecular Dynamics
IMD works by establishing a TCP connection between VMD and the molecular dynamics simu-
lation program. NAMD, or whichever MD program is being used, acts as the server. In order to
prepare NAMDto accept VMDs IMD connection request, NAMDmust be congured to listen for
incoming connections on a network port. Once NAMD has started up, may wait for the user to
connect through that port. When VMDconnects to NAMDsuccesfully, the simulation commences.
Before connecting to the remote simulation, the VMDuser must rst load a molecule corresponding
to the system being simulated. The structure le should correspond to the same structure le
used by NAMD. Once the molecule is loaded and NAMD has been started and is listening for a
connection, you are ready to connect to the simulation and start receiving coordinates. To establish
a connection, open the Sim form, enter the hostname on which NAMD is running and the port
on which NAMD is listening for incoming connections, then press the Connect button to establish
the connection. If NAMD is running on several distributed nodes, VMD must connect to the root
node on which NAMD initially started out.
IMD Using the Sim form
The Sim form allows you to control the behavior of a molecular dynamics simulations which has been
previously connected to through use of the Remote form. This form contains controls to change
parameters for the simulation and to aect how VMD displays the results of the simulation. The
form also contains informative displays, which show the current status of the simulation connection,
and such things as the current energy, temperature, and timestep of the molecular system being
simulated.
At the top of the form are two entry elds and a button for establishing a connection to a running
MD simulation. Enter both the hostname on which the simulation is running, and the port on which
the simulation is listening, then press the Connect button to establish the connection. See the text
console for possible error messages and status updates. Below the connection display is a browser
used to set some connection parameters. These include:
Transfer Rate: How often a timestep is transferred from the remote simulation program
to VMD. By default, this is 1, which means every calculated timestep is sent. If this is set
to some value N, then only every Nth step will send from the remote computer, thereby
decreasing the amount of network processing and rendering that needs to be done.
2
http://www.ks.uiuc.edu/Research/namd/
55
Keep Rate: How often VMD saves the timestep in its animation list, instead of just dis-
carding it after displaying it. By default, this is 0, which means that VMD does not save
any timesteps. When this is 0, then when VMD receives a new timestep it replaces the last
timestep in the animation list with the new timestep, instead of appending it. When it is set
to some number N larger than 0, then every Nth timestep received from the remote simulation
will be appended to the molecule.
Parameters may be changed by entering text into the appropriate entry eld and pressing
<return>. When a new value is entered, a command is sent to the remote simulation to change
it. There may be some delay between when the simulation gets commands, acts on them, and the
results propagate back to VMD. Connection state is shown in the center of the form. The simulation
status text area displays energy values for the system being simulated (kinetic, electrostatic, etc.),
as well as the current timestep and the temperature. It is updated each time a new coordinate set
(timestep) is received by VMD. The Stop Sim button will terminate the remote simulation, but will
not delete the molecule in VMD. The Detach Sim button will sever the connection between VMD
and NAMD, but will allow the simulation to continue running.
5.4.14 Sequence Form
Figure 5.13: The Sequence form
This form is used to list the residue sequences of proteins and the base sequences of nucleic
acids, and to select residues/bases from the sequence list for highlighting in the 3-D structure in
the main VMD window. When residues are selected in the main VMD window, the corresponding
residue is highlighted in the sequence list in this form. Color-coded protein structure information
is displayed for amino-acid residues, and B-factor information is displayed for all residues. In this
section, residues refers both to amino acid residues in proteins, and to nucleotide bases with
associated backbone in DNA and RNA molecules.
Sequence information
The Sequence form contains a vertical listing of the residue sequence of a loaded molecule. The
Molecule pop-up menu control chooses which molecule to display the sequence of, the current top
molecule is displayed the rst time the Sequence form is opened. The name and molecule number
of the sequence displayed is shown in the title frame of the Sequence form.
56
For each residue displayed, the form lists: residue number, residue name/code, and chain letter.
If no chain is specied, chain letter is set to X. To the right of this are two color coded columns,
B value and struct. B-value shows the contents of the B-value (temperature factor) eld.
The struct eld shows protein secondary structure; select Help:Structure Codes from the form
menu, or see Table 5.5, for an explanation of the single letter codes in the color key.
Code Description
T Turn
E Extended conformation
B Isolated bridge
H Alpha helix
G 3-10 helix
I Pi-helix
C Coil
Table 5.5: Description of secondary structure codes in the Sequence form.
Selecting residues from the Sequence form listing
Click anywhere in the vertical listing with the left mouse button to highlight one residue. Click and
drag with the left mouse button to highlight multiple residues, shift-click to add a single residue
to the current selection, shift-click and drag to add multiple residues to your selection, right-click
to de-select a residue. Highlights appear as thick yellow Bonds representations, these can be
changed or turned o[ 5.4.14].
Selecting residues by clicking on the 3-D structure
Use the Mouse menu to enter Pick Atom mode (or press 1, the standard keyboard shortcut).
Click on any protein atom or nucleic acid atom, and its residue will highlight, and the sequence list
will scroll to display this residue. Shift-click works the same way, but adds to the current selection.
Note that if the zoom factor is smaller than 1.0, the single-residue sequence highlight will be shorter
in height than a full line of text. Once the Sequence window has been opened, any Pick will
create or add to selections, until highlighting is turned o[ 5.4.14].
Sequence Zooming
Larger molecules contain thousands of residues, too many to display in a linear text list all at once.
The sequence form can only list about 40 text lines; to work with a molecule of more than 40
residues use the scroll bars to scroll through the long list, or use the Zoom controls to t the data
from a long list into a small space.
The Zoom slider, and the Fit all, Every Residue buttons, zoom in and out of a long sequence list
to allow viewing and selecting from the entire list all at once. To represent more than 40 residues
on the form, the text list seems to skip residues, but selections, highlights and color-coded data
are still active for all residues.
By setting the Zoom slider to a value smaller than 1.0, or by pressing the Fit all button, more
or all of the sequence information for a large molecule can be seen at once. To show a text line for
every residue in the sequence (zoom factor = 1.0), click on the Every Residue button. The Zoom
57
slider can be dragged with the left mouse button (to re-scale sequence smoothly) or it can jump to
a given value by clicking along the slider track with the middle button (this is useful to work more
quickly with very long sequences).
For a multi-thousand residue protein with Fit all selected, hundreds of residues can be selected
at once, and trends in B-value and structure across the entire protein sequence can be detected.
In the screen-shot above, a section of 70 residues with lower B-values than surrounding sequence
is selected, by dragging a rectangle around the green stretch in the B-value column.
Other controls include:
Toggle display of 3-letter and 1-letter codes Click on 1-letter code to switch from
3-letter to 1-letter amino acid codes. The same button then reads 3-letter code, click it to
switch back from 1-letter to 3-letter codes.
Print contents of sequence window Select File:Print to File to create a postscript le
containing the current sequence listing and highlighting.
Turn o highlighting / Change highlight style
To clear all highlights, reselect the current molecule from the Molecule pop-up menu. To turn
the highlight representation o completely for a given molecule, nd the representation in the
Graphics form which the Sequence form has created (appears with Bonds ColorID 4) and set
the style to none. To change highlighting style, set this same representation to your preferred
style and coloring. The selection for this representation will still change whenever the sequence
form selection changes. Example application: specify Multiple Frames in the Trajectory tab of the
highlight representation. This will display the trajectory motions of the residues clicked on in the
main VMD window, or in the Sequence window.
Caveats
Pause on rst use: Since the sequence form displays secondary structure of loaded molecules,
there may be a pause for structure calculation the rst time the sequence for a protein is
displayed.
Selections by chain: When there are multiple segments in a chain, it is possible for several
residues to have the same residue number and chain name. These residues will be high-
lighted/selected/deselected together.
B-values can be user assigned: To use the B-value column to view arbitrary data, use the
selection set beta commands to change B-values. To refresh the displayed B-value data,
re-select the currently displayed molecule from the Molecule pop-up menu.
5.4.15 RamaPlot
The RamaPlot window displays a Ramachandran plot for a selected molecule. If you animate your
molecule over a range of frames , RamaPlot will update the Ramachandran plot automatically. You
can select a range of residues to be displayed in the plot. Clicking on a point in the Ramachandran
plot will show the trajectory of the selected residue in Ramachandran space over all frames . Fields
on the right of the window show the computed value of phi and psi for the most recently selected
residue. Finally, you can create a PostScript image of the current Ramachandran plot. RamaPlot
functionality is summarized in Fig. 5.14.
58
Figure 5.14: The RamaPlot Window
Using RamaPlot
Start RamaPlot by typing ramaplot in the VMD text console, or by selecting the ramaplot menu
item in the Extensions menu. The main window contains a Ramachandran graph, with phi and psi
running along the horizontal and vertical axis, respectively, from -180 to 180 degrees. The most
allowed region of Ramachandran space is colored blue; partially allowed regions are colored green.
After loading a molecule, using the pulldown menu in the upper right part of the window to
choose a molecule. Protein residues in the current molecule are mapped to the Ramachandran
diagram with yellow squares. Clicking on a square causes the square to turn red, displays residue
information in the elds on the right side of the window, and, if trajectory data is present, draws the
location of the selected residue in Ramachandran space for all frames in the trajectory as empty
black squares. Clicking one of the empty squares causes VMD to redraw the graphics display
window with coordinates from the timestep corresponding to that square. Clicking a second time
on a red highlighted residue switches o the trajectory information in the RamaPlot window.
When a protein contains many residues, it may be inconvenient to display all residues at once.
Enter an atom selection in the Selection input to choose which residues to display. Note that the
selection must contain the alpha carbons (name CA) of the residues you want to show. Note also
that, just like the Graphics form, the selection will not be recomputed if you change the animation
frame.
To print the contents of the white Ramachandran plot, select Print to le... from the RamaPlot
File pulldown menu. Enter a lename to save the contents of the window.
59
Chapter 6
Molecular Drawing Methods
Each molecule in VMD is drawn as a collection of several representations, of the molecule. A repre-
sentation is just one particular way of drawing the molecule, and consists of several characteristics:
An atom selection, which determines which of the atoms in the molecule will be included in
the view. This selection is entered in the text input eld at the bottom of the Graphics form.
Atom selections dont apply when drawing volumetric data such as an electron density map,
electrostatic potential map, etc. Section 6.3 describes the syntax used to select atoms.
A drawing method (representation style), which determines what shape to draw the atoms,
bonds, and other components of the molecule. Section 6.1 describes the rendering methods
available in VMD.
A coloring method, which determines how to color each of the atoms and bonds included in
the view. The Graphics form contains controls to set the coloring method at the right of the
form. Section 6.2 describes VMDs coloring methods.
A material, which determines the shininess, opacity, and other lighting and shading charac-
teristics used when rendering the molecule.
A molecule can contain any number of dierent representations, and complex pictures of the
molecule can be generated by creating views with dierent selections, coloring schemes, and ren-
dering methods. For example, the protein backbone can be drawn as a smooth tube in one view,
and important residues in the protein can be drawn as spheres or licorice bonds in other views.
When a molecule is rst loaded, it is given a default view, which will draw all the atoms as lines
and points, coloring each atom by what kind of element it is.
6.1 Rendering methods
All of the dierent rendering methods have various parameters which determine how they are
drawn. For each method, there are controls in the Graphics form which modify the associated
parameters, such as the line width and sphere resolution (the graphical controls are described in
section 5.4.7). Table 6.1 lists the available rendering methods, and the following sections describe
these methods and the parameters which modify their appearance.
60
Representation styles Description
Lines simple lines for bonds, points for atoms
Bonds lighted cylinders for bonds
DynamicBonds dynamically calculated distance-based bonds
HBonds display hydrogen bonds
Points just points for atoms, no bonds
VDW solid van der Waal spheres for atoms, no bonds
CPK scaled VDW spheres, with cylinders for bonds
Licorice spheres for atoms, cylinders for bonds, same radius
Polyhedra polyhedra connecting atoms within a cuto radius
Trace connected cylindrical segments through C
atoms
Tube smooth cylindrical tube through the C
atoms
Ribbons at ribbon through the C
atoms
NewRibbons smooth ribbon through the C
atoms
Cartoon cartoon diagram (cylinders and ribbons) based on secondary structure
NewCartoon smooth cartoon diagram (smooth ribbons) based on secondary structure
PaperChain display ring structures as polygons, colored by ring pucker
Twister at ribbon tracing glycosidic bonds, with twists oriented by sugar residues
MSMS molecular surface as determined by the program MSMS
Surf molecular surface as determined by SURF
VolumeSlice display a texture mapped slice from a volumetric data set
Isosurface display an isovalue surface from a volumetric data set
FieldLines eld lines generated by integrating particles by volume gradient vectors
Orbital molecular orbital selected by wavefunction type, spin, excitation, and orbital ID
Beads per-residue approximate bounding spheres
Dotted dotted van der Wall spheres for atoms, no bonds
Solvent dotted representation of the solvent accessible surface
Table 6.1: Molecular view representation styles.
6.1.1 Lines
The default representation is Lines, which is also known as wireframe. It draws a line between
each atom and the atoms to which it is bonded. Both atoms have to be selected before the bond
will be drawn. The rst half of each bond is colored appropriately for the rst atom, while the color
of the nal half corresponds to the second atom. The only parameter for the lines representation
is the line Thickness.
6.1.2 Bonds
Nearly everything about this option is the same as Lines [ 6.1.1] except that instead of drawing
a bond as a line between two atoms, a cylinder is drawn instead. To be more specic, it draws an
n-sided prism, where the number of sides is determined in the Graphics form [5.4.7] by the Bond
Resolution control and the radius is given by the value of Bond Radius, in Angstroms. If the radius
or number of sides gets too small, the bonds are drawn as lines.
In order to ne tune the bond representation, VMD does a small amount of trickery to the
prisms. That is, imagine two hollow cylinders coming together so that the center of the face of one
61
cylinder is in the same position as the center of the face of the other cylinder. Also suppose these
two cylinders come together at 90 degrees. Although most of these two cylinders will overlap, there
will appear to be a gap at their intersection.
To correct for this problem, VMD extends both cylinders somewhat so that the far ends touch.
If one looks closely, this produces more of an overlap, but it is much nicer looking than the gap.
When three or more bonds join at one atom, VMD chooses the lowest numbered bond and extends
all other bonds to meet with that one. It then extends that lowest numbered bond to meet with
the second lowest numbered one.
6.1.3 DynamicBonds
The DynamicBonds representation will automatically perform a distanced-based bond search for
the active atom selection and active trajectory frame. This representation does not perform the
endpoint xup procedure described above for the regular Bonds [ 6.1.2] representation. Instead,
it is intended to be used in concert with the VDW [ 6.1.6] representation to show bonds that are
being created and destroyed during the course of a trajectory. A bond is drawn if the atoms are
within Distance Cuto of eachother.
6.1.4 HBonds
The HBonds representation will draw a dotted line between two atoms if there is a possible
hydrogen bond between them. A possible hydrogen bond is dened by the following criteria:
Given an atom D with a hydrogen H bonded to it and an atom
A which is not bonded to D, a hydrogen bond exists between
A and H iff the distance ||D-A|| < dist and the angle D-H-A < ang,
where ang and dist are user defined.
Only the selected atoms are searched, so both the donor and acceptor must be selected for the
bond to be drawn. Also, youll note that the above doesnt check the atom type of the donor or
acceptor; the only criterion is if it already has or doesnt have a hydrogen.
One downfall of the current implementation is that it does an n
2
search of the selected atoms
so you probably dont want to show all the HBonds of a very large structure. Look for performance
improvements in future versions of VMD.
If you choose an HBonds representation but fail to see any hydrogen bonds, it may be because
the default Angle Cuto and Distance Cuto criterion in VMD are too small, so you might want to
try increasing the angle value from 20 to 30 degrees and the distance value from 3 to 4.
The HBonds are drawn as dotted lines of a given width. The default Line Thickness is 1 but
you should probably increase that to 2. On most SGIs you cant make it any wider than that,
as described in the man page for linewidth. The bond is colored by the color associated with the
acceptor.
6.1.5 Points
Points draws each atom as a point, and does not draw any of the bonds. This option is useful
when rendering very large molecules containing hundreds of thousands of atoms, particularly for
rendering water or other structures for which geometric detail may not be necessary. The Size of
the points can be changed.
62
6.1.6 VDW
VDW draws the atoms as spheres. The Sphere Scale used is the van der Waals radius multiplied
by a user-selectable scaling factor. The Sphere Resolution determines how nely to tessellate the
spheres that are drawn. Drawing spheres takes some time, since they are built from many polygons.
Note: Due to variations in atom naming conventions, in rare instances VMD may improperly
assign VDW radii to specic atoms, since VMD determines each atom type based on the rst letter
forming its name. For example, VMD would assume an atom named HG to be a hydrogen rather
than a mercury. If this happens, you are always free to redene the radii, using a syntax much like
that below:
set sel [atomselect top name HG]
$sel set radius 1.9
6.1.7 CPK
CPK is a combination of both Bonds [ 6.1.2] and VDW [ 6.1.6] in that it draws the atoms
as spheres and the bonds as cylinders. The resolution and radius can be modied independently.
The size of the sphere drawn in CPK mode is by default the scaled-down VDW radius, but this
scaling-factor can be changed by adjusting the Sphere Scale parameter. Since a sphere is drawn for
each atom, it will always be slower than the VDW option, but we will work on performance for
future versions. If the values for a sphere or bond attribute are too small, then those objects will
not be drawn.
6.1.8 Licorice
Licorice draws the atoms as spheres and the bonds as cylinders. The dierence between this and
CPK [ 6.1.7] is that the sphere radius is not controllable; instead, it is made the same size as the
bond. This makes for a nice, smooth transition and is one of the most often used representations.
It can be rather slow for large molecules.
6.1.9 Polyhedra
Polyhedra draws a collection of triangles that connect all triplets of groups of atoms within a user-
dened radius. This is commonly used in conjunction with specic atom selections for visualization
of amorphous silicon nanodevice structures and the like. At present, a single atom selection is used
for all candidate atoms, and only the radius parameter can be modied.
6.1.10 Trace
This representation applies much of the procedure used to construct the Tube [ 6.1.11]. In
the end, it connects the alpha-carbon atoms of successive residues by cylindrical segments with
adjustable width. In the case of nucleic acids, it is the P backbone atoms which are connected.
As always, the segment pieces are colored according to the atom they are associated with. If the
cylinder radius is made 0.00, then the cylinder segments are replaced with lines.
Note: the Trace option is useful for people doing threading or protein folding work who only
look at the C
coordinates and residue names, for then they dont have to build the sidechains
necessary to see their structure. Also, people working on polymers can fake their structure by
naming everything CA. in the PDB le and then using Trace.
63
6.1.11 Tube
There are two ways to draw a Tube representation, one for proteins and the other for nucleic
acids. The protein tube is a smooth curve through the selected C
. If the second C
for
each cylinder segment, but they are at the location of the C
atom is selected. Note that since this method assumes the protein is in a
beta conformation, it draws a much smoother ribbon than the standard Ribbons [ 6.1.12] option,
which draw the ribbon with an oscillation along the sheet.
The other conformations are drawn as a tube. Since the endpoints of the helix cylinder and
cartoon sheet are not at the C
or a calcium);
resname ALA PHE ASP
selects all atoms in either alanine, phenylalanine, or asparagine;
74
index 5
selects the 6th atom (in the internal VMD numbering scheme).
VMD can also do range selections, similar to X-PLORs : notation:
mass 5 to 11.5
selects atoms with mass between 5 and 11.5 inclusive,
resname ALA to CYS TYR
selects atoms in alanine, arginine, asparagine, aspartic acid, cystine, and also tyrosine.
The keyword selection works by checking each term on the list following the keyword. The term
is either a single word (eg, name CA) or a range (eg resid 35 to 90).
The method for determining the range checking is determined from the keyword data type;
numeric comparisons are dierent than string comparisons. The comparison should work as ex-
pected so that 8 is between 1 and 11 in a numeric context but not in a string one. This
may lead to some peculiar problems. Some keywords, such as segname, can take on string values
but can also be used by some people as a number eld. Suppose someone labeled the segname
eld with the numbers 1 through 12 on the assumption that they are numbers. That person would
be rather confused to nd that segname 1 to 11 only returns two segments. Also, strings will be
converted (via atof()) to a number so if the string isnt a number, it will be given the value of 0.
It is possible to force a search to be done in either a string or numeric context using the relational
operator discussed in 6.3.6
Selections can be combined with the boolean operators and and or, collected inside of paren-
thesis, and modied by not, as in
(name CA or name CB) and mass 12 to 17
which selects all atoms name CA or CB and have masses between 12 and 17 amu (this could be used
to distinguish a C-alpha from a calcium). VMD has operator precedence similar to C so leaving
the parentheis out of the previous expression, as in:
name CA or name CB and mass 12 to 17
actually selects all atoms named CA or those that are named CB and have the appropriate mass.
6.3.1 Denition of Keywords and Functions
The keywords available for selecting atoms in VMD are listed in tables 6.5 and 6.6 at the end of
this chapter. If a keyword denition is followed by bool, it is either on or o. If followed by str it
takes a value in the string context. If followed by num it takes a value in the number context.
75
Table 6.7 lists the built-in functions which may be used in atom selection expressions with
keywords which take on a numeric value.
Table 6.8 lists the built-in atom selection keywords which may be used in atom selection ex-
pressions to query the values of an underlying volumetric map in the same molecule. These are
read-only.
6.3.2 Boolean Keywords
Some selections take no values. For example, backbone selects the backbone atoms of the protein
and nucleic acids and protein selects protein atoms. Giving options to these selections is an error.
The selections can be used in the same way as other selections, as in:
protein and backbone
nucleic or protein
In addition, if neither and nor or are located after a boolean keyword, then an implicit and is
inserted, so that the following are valid:
protein name CA (same as: protein and name CA)
nucleic backbone
6.3.3 Short Circuiting
The boolean logic in VMD does short circuit evaluation on an element-wise basis. For instance,
given one atom, if X is true then X or Y will be true regradless of the value of Y, so there is no
need to evaluate it. Similarly, if X is false, then X and Y will also be false, so Y again need not be
evaluated.
Knowing how short circuit selections work can speed up several types of selections. Consider a
system with a large number of waters and a protein. The expression protein and segname < 10
is faster than segname < 10 and protein since in the rst selection only the atoms which are
proteins have the segname converted to a number, while in the second selection, all the segment
names are converted.
The within selection has its own form of short circuiting. The command can be interpreted as
nd the atoms of A which are withing a given distance from B, and if A isnt given, search all
the atoms. The search done in VMD takes a time roughly proportional to the number of atoms
in A multiplied by the number of atoms in B, so reducing the number of atoms in A (i.e., by not
testing every atoms) make the search faster.
Using the system with a lot of water and a protein, compare the selection
protein within 5 of resid 1
to (within 5 of resid 1) and protein.
The rst is very fast as it does a distance search between all the protein atoms and all the atoms
in resid 1. However, the second selection searches through all the atoms for those which are within
5
A of resid and then nds which of those are protein atoms.
6.3.4 Quoting with Single Quotes
VMD allows two types of quoting mechanisms, single and double quotes. Single quotes are used
to include spaces and other non-alphanumeric characters. Believe it or not, there are some residue
names with a space in them, so they can be referenced as, for example,
76
resname A 1
More importantly, ribose atoms can be given names like C5 or C5* (depending on the age of
the PDB record). The lexer in VMD has been modied so that C5, O", and N can be used
without quotes, but it cannot handle an unquoted asterisk (* conicts with multiplication and the
parser is not able to resolve the dierence). Some examples are:
name O5*
segname A *
name O5
Quotes may also be used to get around a reserved selection word, like x. The selection command
segname x will give an error because x is another keyword. Instead, use segname x. There is an
escape mechanism for including single quotes inside a single quoted string which uses a backslash
(\) before the single quote. This allows unusual names like C to be quoted as C \.
segname x <---- error; conflicts with the x keyword
segname x
name O5\
Also, double quotes (discussed in the next section) can be used, as in "C " or "C \*".
6.3.5 Double Quotes and Regular Expressions
Double quotes around a string are used to specify a regular expression search (compatible with Perl
5.005, using the Perl-compatible regular expressions library written by Philip Hazel). If you dont
know how to use them, try consulting the man pages for ed, egrep, vi, or regex. If not, read the
Perl docs, or get any one of a number of books including the OReilly and Associates Sed and Awk
book. The following examples show just a few ways that regular expressions can be used within
VMD.
Selection of all atoms with a name starting with C:
name "C.*"
Segment names containing a number:
segname ".*[0-9]+.*"
Multiple terms can be provided on the list of matching keywords. This example selects residues
starting with an A, the glycine residues, and residues ending with a T. As with a string, a regular
expression in a numeric context gets converted to an integer, which will always be zero:
resname "A.*" GLY ".*T"
Selections containing special characters such as +, , or , must be escaped with the \ character.
In order to select atoms named Na+, one would use the selection:
name "Na\+"
77
In brief, a regular selection allows matching to multiple possibilities, instead of just one char-
acter. Table 6.9 shows some of the methods that can be used.
There are many ways to do some selections. For example, choosing atoms with a name of either
CA or CB can be done in the following ways:
name CA CB
name "CA|CB"
name "C[AB]"
name "C(A|B)"
Several caveats for those who already understand regular expressions. VMD automatically
prepends ^( and appends )$ to the selection string. This makes the selection O match only
O and not OG or PRO. On the other hand, putting ^ and $ into the command wont really aect
anything, selections that match on a substring must be preceded and followed by .*, as in .*O.*,
and some illegal selections could be accepted as correct, but strange, as in C)|(O , which gets
converted to ^(C)|(O)$ and matches anything starting with a C or ending with an O.
A regular expression is similar to wildcard matching in X-PLOR. Table 6.10 is a list of conver-
sions from X-PLOR style wildcards to the matching regular expression.
6.3.6 Comparison selections
Comparisons can be used in VMD to do atom selections like mass < 5, which selects atoms with
mass less than 5 amu, and name eq CA, which is another way of choosing the CA atoms. The
underlying idea for the comparison selection is also based on the concept that every atom has a
property as specied by a keyword. When the keyword is given in the expression, the array (or
vector) of the corresponding values is constructed, and the size of the array is the same as the
number of atoms in the molecule. (If a single number or string is given instead of a keyword, the
array consists of copies of that given value.) The operations, like addition, multiplication, string
matching, and comparison, are then applied element-wise along the array. This type of selection is
similar to the vector statement in X-PLOR.
Take the example mass < 5 when applied on water, which has an oxygen of mass 15.9994 and
two hydrogens of mass 1.008. VMD sees the keyword mass and constructs the array [15.9994,
1.008, 1.008], then sees the 5 and makes the array [5, 5, 5]. It then compares each term of the
array and returns with the boolean array [False, True, True] (since 15.9994 is not less than 5, but
1.008 is). This nal boolean array is then used to determine which atoms are selected; in this case,
the hydrogens.
More complicated comparison selections can be constructed, either from arithmetic operations
or by using some of the standard math functions (the functions are listed in Table 6.7). Probably
the most often used function will be sqr, which squares each element of the array. Thus, the
command to select all atoms within 5
A of a point (x,y,z) = (3,4,-5) in space is:
sqr(x-3)+sqr(y-4)+sqr(z+5) <= sqr(5)
6.3.7 Comparison Operators
There are two types of comparison operators numeric and string which allow the user to
specify the appropriate comparison function. Suppose the segment name, which takes on a string
value, contains the names 11, and 8. VMD cannot gure out if 8 should be less than 11 (in
78
the numeric sense) or greater than 11 (in the lexographical sense). Instead of trying to resolve
this problem through some sort of internal heuristics, VMD leaves it up to the user so that 8 < 11
but 11 lt 8. (Perl users should recognize this solution.)
The numeric comparisons are the standard ones: <, <=, = or ==, >=, >, and !=. The corresponding
string comparisons are: lt, le, eq, ge, gt, and ne. As in perl there is a match operator, =~, so
that
CA =~ "C.*"
segname =~ "VP[1-4]" (matches VP1, VP2, VP3, and VP4, present in some
virus structures)
are valid. No distinction is made between single and double quotes.
6.3.8 Other selections
sequence
VMD supports selection based on the one-letter amino acid sequence with the sequence selection
keyword. This allows selections of the form
sequence APD
sequence "C..C" (might be used to pick out zinc fingers)
sequence AATCGGAT
Unlike the other string selection commands which take one of three types of strings, all the
strings for sequence are taken as regular expressions (though strings with non-alphanumerics must
still be quoted to get past the input parser). The method works by taking each of the protein
and nucleic acid fragments (pfrag and nfrag) in turn and constructing the one-letter amino acid
sequence. If a regular expression matches any of the sequence, the atoms in the matching residues
are selected. Multiple matches are allowed, though they cannot overlap. As is usual with regular
expressions, the largest possible match is made, so take care with expressions like C.*C.
within and same
Two useful types of selection mechanisms available in VMDare: within <number> of <selection>
and same <keyword> as <selection>. The rst selects all atoms within the specied distance (in
r
0
g(r)r
2
dr for all pairs of atoms in the two selections. Both
111
selections have to reference the same molecule and may be identical. In case one of the
selections resolves to an empty list for a given time step, and empty array is added to the
histograms. The command returns a list of ve lists containing r, g(r),
r
0
g(r)r
2
dr, the
unnormalized histogram, and a list of frame counters containing currently 3 elements: total
number of frames processed, the number of skipped frames and the number of frames handled
with the orthogonal cell algorithm (Further algorithm and corresponding list entris will be
added in the future). With the optional arguments delta (default 0.1) and rmax (default
10.0) one can set the resolution and the maximum r value. With the usepbc ag processing
of periodic boundary conditions can be turned on. With the selupdate ag enabled, both
atom selections are updated as each frame is processed, allowing productive use of within
selections. The size of the unitcell has to be stored in the trajectory le or has to be set
manually for all frames with the molinfo command. The command uses by default only the
current active frame for both selections. Using an explicite frame range via rst, last, and
step is recommended for most cases.
hbonds cuto angle selection1 [selection2]: Find all hydrogen bonds in the given selection(s),
using simple geometric criteria. Donor and acceptor must be within the cuto distance, and
the angle formed by the donor, hydrogen, and acceptor must be less than angle from 180
degrees. Only non-hydrogen atoms are considered in either selection. If both selection1 and
selection2 are given, the selection1 is considered the donor and selection2 is considered the
acceptor. If only one selection is given, all non-hydrogen atoms in the selection are considered
as both donors and acceptors. The two selections must be from the same molecule. The
function returns three lists; each element in each list corresponds to one hydrogen bond. The
rst list contains the indices of the donors, the second contains the indices of the acceptors,
and the third contains the index of the hydrogen atom in the hydrogen bond.
Known Issue: The output of hbonds cannot be considered 100% accurate if the donor and
acceptor selection share a common set of atoms.
inverse matrix: Returns the inverse of the given 4x4 matrix.
minmax selection: Returns two vectors, the rst containing the minimum x, y, and z coor-
dinates of all atoms in selection, and the second containing the corresponding maxima.
rgyr selection [weight weights]: Returns the radius of gyration of atoms in selection using
the given weight. The radius of gyration is computed as
r
2
gyr
=
i=1
w(i)(r(i) r)
2
i=1
w(i)
(9.1)
where r(i) is the position of the ith atom and r is the weighted center as computer by measure
center.
rmsd selection1 selection2 [weight weights]: Returns the root mean square distance between
corresponding atoms in the two selections, weighted by the given weight. selection1 and
selection2 must contain the same number of atoms (the selections may be from dierent
molecules that have dierent numbers of atoms).
rmsf selection [rst rst] [last last] [step step]: Returns the root mean square position
uctuation for each selected atom in the selected frames. If no rst, last, or step values are
provided the calculation will be done for all frames.
112
sasa srad selection [-points varname] [-restrict restrictedsel] [-samples numsamples]: Re-
turns the solvent-accessible surface area of atoms in the selection using the assigned radius
for each atom, extending each radius by srad to nd the points on a sphere that are exposed
to solvent. If the restrictedsel selection is used, only solvent-accessible points near that selec-
tion will be considered. The restrict option can be used to prevent internal protein voids or
pockets from aecting the surface area results. The points option can be used to see where
the area contributions are coming from, and then the restrict ag can be used to eliminate
any unwanted contributions after visualizing them. The varname parameter can be used to
collect the points which are determined to be solvent-accessible.
sumweights selection weight weights: Returns the sum of the list of weights (or data eld
to use for the weights) for all of the atoms in the selection.
bond atom list [options]: Returns the distance of the two specied atoms. The atoms are
specied in form of a list of atom indexes. Unless you specify a certain molecule through
molid molecule number these indices refer to the current top molecule. If the atoms are in
dierent molecules you can use the form atomid1 [molid1] atomid2 [molid2] ... where
you can set the molecule ID for the individual atoms. Note that measure bond does not care
about the bond that are specied in a psf le or that are drawn in VMD it just returns the
distance! Similar things are true for measure angle, dihed and imprp.
The following options can be specied:
molid <default molid>: The default molecule to which an atom belongs unless a
molecule number was explicitely specied for this atom in the atom list. Further, all
frame specications refer to this molecule. (Default is the current top molecule.)
frame <frame>: By default the value for the current frame will be returned but a
specic frame can be chosen through this option. One can also specify all or last instead
of a frame number in order to get a list of values for all frames or just the last frame
respectively.
first <frame>: Use this option to specify the rst frame of a frame range. (Default is
the current frame.)
last <frame>: Use this option to specify the last frame of a frame range. (Default is
the last frame of the molecule).
In case you specied the molecule IDs in the atom list then all frames specications will refer
to the current top molecule unless a default molecule was set using the molid option. Since
the top molecule can be dierent from the molecules involved in the selected atoms, it is
generally a good idea to specify a default molecule.
Here are a few examples of usage:
measure bond 3 5 Returns the bond energy between atoms 3 and 5 of the current frame
of the top molecule measure bond 3 5 molid 1 frame all Returns the bond energy
between atoms 3 and 5 of molecule 1 for all frames.
measure bond 3 5 1 molid 0 first 7 Returns the bond energy between atoms 3
of molecule 0 and atom 5 of molecule 1. The value is computed for all frames between the
seventh and the last frame of molecule 0.
angle atom list [options]: Returns the angle spanned by three atoms. Same input format as
the measure bond command.
113
dihed atom list [options]: Returns the dihedral angle dened by four atoms. Same input
format as the measure bond command.
imprp atom list [options]: Returns the improper dihedral angle dened by four atoms. Same
input format as the measure bond command.
energy energy term atom list [parameters] [options]: Returns the specied energy term for
a given set of atoms. The energy term must be one of bond, angle, dihed, imprp, vdw
or elect where vdw stands for van der Waals and elect for electrostatic energy. The energy
is computed based on the CHARMM force eld functions, the given parameters and the
current coordinates. All options for the measure bond command work for measure energy,
too. Thus, you can for instance request energies for a range of frames of a trajectory. Also
the format of the atom list is the same. The following parameters can be specied:
k <value>: force constant for bond, angle, dihed and imprp energies in kcal/mol/A
2
or
kcal/mol/rad
2
respectively.
x0 <value>: equilibrium value for bond length, angle, dihedral angles and improper
dihedrals in Angstrom or degree.
kub <value>: Urey-Bradley force constant for angles in kcal/mol/A
2
.
s0 <value>: Urey-Bradley equilibrium distance for angles in Angstrom.
n <value>: dihedral periodicity.
delta <value>: dihedral phase shift in degree (usually 0.0 or 180.0).
rmin1 <value>: VDW equilibrium distance for atom 1 in Angstrom.
rmin2 <value>: VDW equilibrium distance for atom 2 in Angstrom.
eps1 <value>: VDW energy well depth (epsilon) for atom 1 in kcal/mol.
eps2 <value>: VDW energy well depth (epsilon) for atom 2 in kcal/mol.
q1 <value>: charge for atom 1.
q2 <value>: charge for atom 2.
cutoff <value>: nonbonded cuto distance.
switchdist <value>: nonbonded switching distance.
For all omitted parameters a default value of 0.0 is assumed. For the electrostatic energy the
default charges are taken from the according atom based eld of the molecule. If the cuto
is not set or zero then no cuto function will be used.
surface selection gridsize radius depth: Returns a list of atom indices comprising the surface
of the selected atoms. The method for determining the surface is to construct a grid with a
spacing approximately equal to gridsize, where each grid point is either marked full or empty,
depending on whether any atoms from the selection are within radius distance of the grid
point. If the periodic cell parameters are dened in VMD, the molecule is considered periodic
and the grid reects the coordinates of periodic images of the selection. The grid size may be
modied from that passed to the routine so that an integer grid dimension ts the dimensions
of the box containing the molecule. Finally, each atom that falls within depth distance of an
empty grid point is considered a surface atom, and the command returns a list of atom indices
for all such atoms.
114
pbc2onc center [frame frame[last]: Computes the transformation matrix that transforms
coordinates from an arbitrary PBC cell into an orthonormal unitcell. Since the cell center is
not stored by VMD you have to specify it.
Here is a 2D example of a nonorthogonal PBC cell: A and B are the are the displacement
vectors which are needed to create the neighboring images. The parallelogram denotes the
PBC cell with the origin O at its center. The square to the right indicates the orthonormal
unit cell i.e. the area into which the atoms will be wrapped by transformation T.
+ B
/ + B
_________/________ |
/ / / +---|---+
/ / / T | | |
/ O--------/-------> A ====> | O---|--> A
/ / | |
/_________________/ +-------+
A = displacement vector along X-axis with length a
B = displacement vector in XY-plane with length b
A = displacement vector along X-axis with length 1
B = displacement vector along Y-axis with length 1
O = origin of the PBC cell
pbcneighbors center cuto [options]: Returns all image atoms that are within cuto
A of
the PBC unitcell in form of two lists. The rst list holds the atom coordinates while the
second one is an indexlist mapping the image atoms to the atoms in the unitcell. Since the
PBC cell center is not stored in DCDs and cannot be set in VMD it must be provided by the
user as the rst argument.
The second argument (cuto) is the maximum distance (in
A) from the PBC unit cell for
atoms to be considered. In other words the cuto vector denes the region surrounding the
pbc cell for which image atoms shall be constructed (i.e. 6 8 0 means 6
A for the direction
of A, 8
A for B and no images in the C-direction).
The following options can be specied:
molid <molecule number>: The default molecule to which an atom belongs unless a
molecule number was explicitely specied for this atom in the atom list. Further, all
frame specications refer to this molecule. (Default is the current top molecule.)
frame <frame>: By default the value for the current frame will be returned but a
specic frame can be chosen through this option. One can also specify all or last instead
of a frame number in order to get a list of values for all frames or just the last frame
respectively.
sel <selection>: If an atomselection is provided then only those image atoms are
returned that are within cuto of the selected atoms of the main cell. In case cuto is
a vector the largest value will be used.
align <matrix>: In case the molecule was aligned you can supply the alignment matrix
which is then used to correct for the rotation and shift of the pbc cell.
115
boundingbox PBC[<mincoord> <maxcoord>: With this option the atoms are wrapped
into a rectangular bounding box. If you provide PBC as an argument then the bound-
ing box encloses the PBC box but then the cuto is added to the bounding box. Negative
values for the cuto dimensions are allowed and lead to a smaller box. Instead you can
also provide a custom bounding box in form of the minmax coordinates (list contain-
ing two coordinate vectors such as returned by the measure minmax command). Here,
again, the cuto is added to the bounding box.
inertia selection [moments] [eigenvals]: Returns the center of mass and the principles axes
of inertia for the selected atoms. If moments is set then the moments of inertia tensor are
also returned. With option eigenvals the corresponding eigenvalues will be returned, too.
If both ags are set then the eigenvalues will be listed after the moments.
symmetry selection [plane[I[Cn[Sn [vector]] [tol value] [nobonds] [verbose level]: This
function evaluates the molecular symmetry of an atom selection. The underlying algorithm
nds the symmetry elements such as inversion center, mirror planes, rotary axes and rotary
reections. Based on the found symmetry elements it guesses the underlying point group. The
guess is fairly robust and can handle molecules whose coordinates deviate to a certain extent
from the ideal symmetry. The closest match with the highest symmetry will be returned.
Options:
tol <value>: Allows one to control tolerance of the algorithm when considering wether
something is symmetric or not. A smaller value signies a lower tolerance, the default
is 0.1.
nobonds: If this ag is set then the bond order and orientation are not considered when
comparing structures.
verbose <level>: Controls the amount of console output. A level of 0 means no output,
1 gives some statistics at the end of the search (default). Level 2 gives additional info
about each stage, and 2, 3, 4 yield even more info for each iteration.
idealsel <selection>: The symmetry search will be performed on the regular selection
but then the found symmetry elements will be imposed on the selection given with this
option an the search is repeated with this second selection. This method allows, for
example, to perform the symmetry guess on a selection without hydrogens (which might
point in random directions for rotable groups) but still get the ideal coordinates and
unique atoms for the entire structure. The selection specied here must be a superset
of the selection used for the symmetry search.
I: Instead of guessing the symmetry pointgroup of the selection determine if the se-
lections center o mass represents an inversion center. The returned value is a score
between 0 and 1 where 1 denotes a perfect match.
plane <vector>: Instead of guessing the symmetry pointgroup of the selection deter-
mine if the plane with the dened by its normal vector is a mirror plane of the selection.
The returned value is a score between 0 and 1 where 1 denotes a perfect match.
Cn[Sn <vector>: Instead of guessing the symmetry pointgroup of the selection deter-
mine if the rotation or rotary reection axis Cn/Sn with order n dened by vector exists
for the selection. E.g., if you want to query wether the Y-axis has a C3 rotational sym-
metry you specify C3 0 1 0. The returned value is a score between 0 and 1 where 1
denotes a perfect match.
116
imposeinversion: Impose an inversion center on the structure.
imposeplanes <vector> [<vector> ...]: Impose the planes given by a list of nor-
mal vectors on the structure.
imposeaxes|imposerotref <vector> order [<vector> order ...]:
Impose rotary axes or rotary reections on the structure specied by a list of pairs of a
vector and an integer. Each pair denes an axis and its order.
The scores for the individual symmetry elements depend on the specied tolerance. Imposing
symmetry elements on a structure will wrap the atoms around these elements and average the
coordinates of the atoms and its images. Atoms for which no image is found (with respect
to that transformation) will not be wrapped. I.e. if you, for instance, impose an axis on
a molecule that has no such rotary symmetry within the given tolerance then nothing will
happen.
Result:
The return value is a TCL list of pairs consisting of a label string and a value or list. For
each label the data following it are described below:
pointgroup The guessed point group. For point groups that have an order associated with
it, like C3v or D2, the order is replaced by n and we have Cnv or Dn. The order is
given separately (see below).
order Point group order, i.e. order of highest axis (0 if not applicable).
elements Summary of found symmetry elements, i.e. inversion center, rotary axes, rotary
reections, mirror planes. Example: (i) (C3) 3*(C2) (S6) 3*(sigma) for point group
D3d.
missing Elements missing with respect to ideal set of elements (same format as above). If
this is not an empty list then something has gone awfully wrong with the symmetry
nding algorithm.
additional Additional elements that would not be expected for this point group (same format
as above). If this is not an empty list then something has gone awfully wrong with the
symmetry nding algorithm.
com Center of mass of the selection based on the idealized coordinates (see ideal below).
inertia List of the three axes of inertia, the eigenvalues of the moments of inertia tensor and
a list of three 0/1 ags specifying for each axis wether it is unique or not.
inversion Flag 0/1 signifying if there is an inversion center.
axes Normalized vectors dening rotary axes
rotreect Normalized vectors dening rotary reections
planes Normalized vectors dening mirror planes.
ideal Idealized symmetric coordinates for all atoms of the selection. The coordinates are
listed in the order of increasing atom indices (same order asa returned by the atomselect
command get x y z). Thus you can use the list to set the atoms of your selection to
the ideal coordinates (see example below).
unique Index list dening a set of atoms with unique coordinates.
orient Matrix that aligns molecule with GAMESS standard orientation.
117
If a certain item is not present (e.g. no planes or no axes) then the corresponding value is an
empty list. The pair format allows to use the result as a TCL array for convenient access of
the dierent return items.
Example:
set sel [atomselect top all]
# Determine the symmetry
set result [measure symmetry $sel]
# Create array symm containing the results
array set symm $result
# Print selected elements of the array
puts $symm(pointgroup)
puts $symm(order)
puts $symm(elements)
puts $symm(axes)
# Set atoms of selection to ideally symmetric coordinates
$sel set {x y z} $symm(ideal)
9.3.18 menu
The menu forms of the GUI Control or query the on-screen GUI menu forms.
list: Return a list of the available menus
menu name on: Turn a menu on.
menu name o: Turn a menu o.
menu name status: Return on if on, off if o.
menu name loc: Return the x y location.
menu name move x y: Move a menu to the given (x, y) location
The parameter menu name is one of the following menu names: color, display, les, graphics, labels,
main, material, ramaplot. render, save, sequence, simulation, or tool.
9.3.19 mol
Load, modify, or delete a molecule in VMD. In the following, molecule number is a string describing
which molecules are to be aected by the command. It is one of the following: all, top, active,
inactive, displayed, on, off, fixed, free, or one of the unique integer ID codes assigned to
the molecules when they are loaded (starting with 0). The codes (molIDs) are not reused after a
molecule is deleted, so if you, for example, have three molecules loaded (numbered 0, 1, 2), delete
molecule with molID equal to 0, and then load another molecule, the new molecule will have molID
3. Thus, the list of available molecule IDs becomes (1 2 3). The index of the molecule on this
list is, among many other things, accessible through the molinfo command [9.3.21]. In the above
118
case, for example, molecule that was loaded the last has molID equal to 3, however, it is the third
on the list of molecules, so it has the index equal to 2 (since we start countin from 0).
The molecule representations (views) are assigned integer number (starting with 0 for each
molecule), which appear in the list on the Graphics form [5.4.7]. The representations can be added,
deleted or changed with the mol command. See also sections on molinfo command [ 9.3.21] for
more ways of retrieving information about the representations.
new [ lename ] [ options ]:
addle < lename > [ options ]:
mol new is used to create a new molecule from a le; if the optional lename parameter
is omitted, a plain, blank molecule is created with no atoms (this can be used to create
a canvas for drawing user-dened geometry). mol addfile is like mol new except that the
structure and coordinate data are loaded into the top molecule (whichever molecule was loaded
last) instead of creating a new one. Both mol new and mol addfile accept the following set
of options:
type <type>: Species the le type (psf, pdb, etc.) If this option is omitted, the lename
extension is used to guess the letype; otherwise, it overrides what would be guessed
from the lename.
first <frame>:
last <frame>:
step <frame>: For les containing coordinate frames , species which frames to load.
Frames are indexed starting at 0. A step of 1 means all frames in the range will be
loaded; a step of 2 means load every other frame.
waitfor <frames>: For les containing coordinate frames , species how many frames
to load before returning; the default is 1. If frames is less than the number of frames
in the le, the rest of the frames will be loaded in the background on subsequent VMD
display updates. If frames is -1 or all, then all frames in all les still in progress
will be loaded at once before the command returns. Frames loaded this way will load
faster than if they are loaded in the background. If les are still being loaded in the
background when the addle command is issued, frames from the les in progress will
be loaded rst.
volsets <set ids>: For les containing volumetric data, species which data sets to
load. <set ids> should be a list of zero-based indices.
autobonds <on|off>: Turn automatic bond calculation on/o. This can be useful for
loading unusual non-molecular coordinates for which VMDs bond-nding algorithm is
too slow (e.g., if the point density is very high). Default is on.
molid: For addle only. The molecule id of the molecule into which the le should be
loaded may be specied. It must be the last option specied. If omitted, the default is
the top molecule.
load structure le type structure le [coordinate le type coordinate le] : Load a new molecule
from lename(s) using the given format. If an additional coordinate le is specied, load this
le as well. New in VMD 1.8: All frames from the coordinate le will be loaded before
119
the command returns. If this is not desirable, use the animate read command for more ne-
grained control over how coordinate les are loaded. Previous version of VMD loaded only
one frame before returning. The function will return the id of the newly created molecule, or
return an error if unsuccessful.
urlload <le type> <URL>: Load a molecule of le type from a given URL address. Return
the id of the newly created molecule, or an error if unsuccessful.
pdbload <four letter accession id>: Retrieve the PDB le with the specied accession
code from the RCSB web site. Returns the id of the newly created molecule, or an error if
unsuccessful.
list: Print a one-line status summary for each molecule.
list molecule number: Print a one-line status summary for each molecule matching the
molecule number. If only one molecule matches the molecule number, also print the rep-
resentation status for this molecule, i.e., number of representations as well as the representa-
tion number, coloring method , representation style and the selection string for each of the
representations.
color coloring method: Change the default atom coloring method setting.
representation rep style: Change the default rendering method setting.
selection select method: Change the default atom selection setting.
clipplane center clipplane id rep number molecule number [ vector ]
clipplane color clipplane id rep number molecule number [ vector ]
clipplane normal clipplane id rep number molecule number [ vector ]
clipplane status clipplane id rep number molecule number [ boolean ]
modcolor rep number molecule number coloring method: Change the current coloring method
for the given representation in the specied molecule.
modmaterial rep number molecule number material name: Change the current material for
the given representation in the specied molecule.
modstyle rep number molecule number rep style: Change the current rendering method
(style) for the given representation in the specied molecule.
modselect rep number molecule number select method: Change the current selection for the
given representation in the specied molecule.
addrep molecule number: Using the current default settings for the atom selection, coloring,
and rendering methods, add a new representation to the specied molecule.
default category value: Set the default settings for color, style, selection, or material to the
supplied value.
120
delrep rep number molecule number: Deletes the given representation from the specied
molecule.
modrep rep number molecule number: Using the current default settings for the atom se-
lection, coloring, and rendering methods, changes the given representation to the current
defaults.
delete molecule number: Delete molecule(s).
active molecule number: Make molecule(s) active.
inactive molecule number: Make molecule(s) inactive.
on molecule number: Turn molecule(s) on (make drawn).
o molecule number : Turn molecule(s) o (hide).
x molecule number: Fix molecule(s).
free molecule number: Unx molecule(s).
top molecule number: Set the top molecule.
cancel molecule number: Cancel loading trajectories.
reanalyze molecule number: Re-analyze structure after bonding and atom name changes.
bondsrecalc molecule number: Recalculate bonds from distances for current timestep.
ssrecalc molecule number: Recalculate secondary structure.
rename molecule number newname: Rename the specied molecule.
repname molecule number rep number: Returns the name of the given rep. This name is
guaranteed to be unique for all reps in the molecule, and will stay with the rep even if the
rep number changes.
repindex molecule number name: Return the rep number for the rep with the given name,
or -1 if no rep with that name exists in that molecule.
selupdate rep number molecule number [ono]: Update the selection for the specied rep
each time the molecules timestep changes. If ono is not specied, returns the current update
state.
colupdate rep number molecule number [ono]: Update the calculated color for the specied
rep each time the molecules timestep changes. If ono is not specied, returns the current
update state.
drawframes molecule number rep number [frame specication]: Draw multiple trajectory
frames or coordinate sets simultaneously. This setting allows the user to select one or more
ranges of frames to display simultaneously. The frame specication takes one of the follow-
ing forms now, frame number, start:end, or start:step:end. If the frame specication is not
specied, the command returns the currently active frame selection text.
121
smoothrep molecule number rep number [n]: Get/set the window size for on-the-y smooth-
ing of trajectories. Instead of drawing the specied rep from the current coordinates, VMD
will calculate the average of the coordinates from the n previous and subsequent timesteps. If
n is zero then no smoothing is performed. Note that this smoothing does not aect any label
measurements, and does not change the values of the coordinates returned by atom selections
or written to les; it only aects how the rep is drawn. Smoothing can be especially useful
in visualizing rapidly uctuating molecules or making movies.
scaleminmax molecule number rep number [min max | auto]: Get/set the color scale range
for this rep. Normally the color scale is automatically scaled to the minimum and maximum
of the corresponding range of data. This command overrides the autoscaled values with the
values you specify. Omit the min and max arguments to get the current values. Use auto
instead of a min and max to rescale the color scale to the maximum range again.
showrep molecule number rep number [on | o]: Get/set whether the given rep is shown or
hidden. Hidden reps cannot be picked and do not show any graphics.
volume molecule number <volumeset name> <Origin> <a> <b> <c> #a #b #c <Data> Add
a volumetric data set to the current molecule. Origin, a, b, and c are vectors setting the origin
and the three cell vectors. #a, #b, and #c are the number of grid points in the respective cell
vector directions and nally the data has to be provided as one list with the data following
the grid points along the c-axis fastest, then the b-axis and nally the a-axis.
9.3.20 molecule
Same as mol.
9.3.21 molinfo
The molinfo command is used to get information about a molecule (or loaded le) including the
number of loaded atoms, the lename, the graphics selections, and the viewing matrices. It can
also be used to return information about the list of loaded molecules.
Each molecule has a unique id, which is assigned to it when it is rst loaded. These start at
zero and increase by 1 for each new molecule. When a molecule is deleted, the number is not used
again. There is one unique molecule, called the top molecule [5.4.2], which is used to determine
some parameters, such as the center of view, the data in the animation form, etc.
list: Returns a list of all current molecule ids.
num: Returns the number of loaded molecules.
top: Returns the id of the top molecule.
index n: Returns the id of the nth molecule.
molecule id get list of keywords
molecule id set list of keywords list of values Access and, in some cases, modify informa-
tion about a given molecule. The list of recognized keywords is given in Table 9.3.
122
Keyword Aliases Arg Set Description
id int N molecular id
index int N index on the molecule list
numatoms int N number of atoms
name str N the name of the molecule (usually the name of the le)
lename str N list of lenames for all les loaded for this molecule
letype str N list of le types for this molecule
database str N list of databases for this molecule
accession str N list of database accession codes for this molecule
remarks str N list of freeform remarks for this molecule
active bool Y is/make the molecule active
drawn displayed bool Y is/make the molecule drawn
xed bool Y is/make the molecule xed
top bool Y is/make the molecule top
center vector Y get/set the coordinate used as the center
center matrix matrix Y get/set the centering matrix
rotate matrix matrix Y get/set the rotation matrix
scale matrix matrix Y get/set the scaling matrix
global matrix matrix Y get/set the global (rotation/scaling) matrix
view matrix matrix N get/set the overall viewing matrix
numreps int N the number of representations
selection i string N the string for the ith selection
rep i string N the string for the ith representation
color i colour string N the string for the ith coloring method
numframes int N number of animation frames
numvolumedata int N number of volumetric data sets
frame int Y current frame number
timesteps int Y number of elapsed timesteps in an interactive simulation
angles list Y topology angle types and denitions type a1 a2 a3
dihedrals list Y topology dihedral types and denitions type a1 a2 a3 a4
impropers list Y topology improper types and denitions type a1 a2 a3 a4
bond oat N the bond energy (for the current frame)
angle oat N the angle energy
dihedral oat N the dihedral energy
improper oat N the improper energy
vdw oat N the van der Waal energy
electrostatic elec oat N the electrostatic energy
hbond oat N the hydrogen bond energy
kinetic oat N the total kinetic energy
potential oat N the total potential energy
energy oat N the total energy
temperature temp oat N the overall temperature
pressure oat Y the simulation pressure
volume oat Y the simulation volume
eeld oat Y eeld
alpha oat Y unit cell angle alpha in degrees (for the current frame)
beta oat Y unit cell angle beta in degrees (for the current frame)
gamma oat Y unit cell angle gamma in degrees (for the current frame)
a oat Y unit cell length a in Angstroms (for the current frame)
b oat Y unit cell length b in Angstroms (for the current frame)
c oat Y unit cell length c in Angstroms (for the current frame)
Table 9.3: molinfo set/get keywords
123
Examples:
vmd > molinfo top get numatoms
568
molinfo 0 get {filetype filename}
pdb /home/dalke/pdb/bpti.pdb
vmd > molinfo 0 get { {rep 0} {color 0} {rep 1} {color 1} }
{VDW 1.000000 8.000000} {ColorID 5} Lines 1.0000 SegName
9.3.22 mouse
Change the current state (mode) of the mouse, optionally active TCL callbacks.
mode 0: Set mouse mode to rotation.
mode 1: Set mouse mode to translation.
mode 2: Set mouse mode to scaling.
mode 3 N: Set mouse mode to rotate light N.
mode 4 N: Set mouse mode to picking mode N, where N is one of the following:
0: query item
1: pick center
2: pick atom
3: pick bond
4: pick angle
5: pick dihedral
6: move atom
7: move residue
8: move fragment
9: move molecule
10: force on atom
11: force on residue
12: force on fragment
callback on/o: Turn the callbacks on or o. To use the callbacks, trace the variable
vmd_pick_atom_silent. See below for information on tracing.
rocking on/o: Enable/disable persistent rotation of the scene with the mouse.
stoprotation: Stop any mouse-initiated scene rotation as well as any rocking initiated with
the rock command.
124
9.3.23 play
Start executing text commands from a specied le, instead of from the console. When the end of
the le is reached, VMD will resume reading commands from the previous source. This command
may be nested, so commands being read from one le can include commands to read other les.
lename: Execute commands from lename.
9.3.24 quit
Same as exit.
9.3.25 render
Output the currently displayed image (scene) to a le using the global VMD display settings and
any renderer-specic settings.
list: List the available rendering methods.
hasaa method: Query whether or not a renderer has controllable antialiasing feature.
aasamples method samples: Query or set the number of antialiasing samples to be used by
this renderer, if supported.
aosamples method samples: Query or set the number of ambient occlusion lighting samples
to be used by this renderer, if supported.
formats method: List a renderers available image output formats/modes.
format method format: Set a renderers active image output format/mode.
method lename: Render the global scene to lename using method and execute the default
command, where method can be one of the following:
ART
Gelato
POV3
PostScript
Radiance
Raster3D
Rayshade
Renderman
snapshot
STL
Tachyon
TachyonInternal
VRML-1
125
VRML-2
Wavefront
method lename command: Render the global scene to lename, then execute command.
Any %s in command are replaced by the lename (up to 5).
options method: Get the default command string.
options method command: Set new default command.
default method: Get the original default command.
9.3.26 rock
Rotate the current scene continually at a specied rate.
o: Stops rocking.
< x | y | z > by step: Rock around the given axis at a rate of step degrees per redraw.
< x | y | z > by step n: Rock around the given axis at a rate of step degrees per redraw for
n steps, reverse, and repeat.
9.3.27 rotate
Rotate the current scene around a given axis by a certain angle. This does not change atom
coordinates.
stop: Stop all rotation, similar to rock o, but it also stops mouse rotations as well.
< x | y | z > by angle: Rotate around the given axis angle degrees.
< x | y | z > to angle: Rotate the given axis to the absolute position angle.
< x | y | z > < by | to > angle step: Rotate at a rate of step degrees per redraw.
9.3.28 scale
Scale the current scene up or down. This does not change atom coordinates.
by f: Multiply scene scaling factor by f.
to f: Set scene scaling factor to f.
126
9.3.29 stage
Position a checkerboard stage on the screen.
location < o | origin | bottom | top | left | right | behind >: Set the location.
location: Get the current location.
locations: Get a list of possible locations.
panels n: Set number of panels in stage, up to 30.
panels: Get the number of panels in use
9.3.30 tool
Initialize and control the tools that are controlled by external tracking devices.
create: Create a new tool
change type [ toolid ]: Change the type of a tool.
scale scale [ toolid ]: Change the scale of the coordinates reported by a tool.
scaleforce scale [ toolid ]: Increase or decrease the force on a force-feedback device.
oset x y z [ toolid ]: Add a vector to a tools position.
delete [ toolid ]: Remove a tool.
rep molid repid: Choose only a single representation for tugging or SMD.
adddevice name [ toolid ] : Add a device to a tool, using a name found in the sensor
conguration le.
removedevice name [ toolid ] : Remove a device from a tool, using a name found in the
sensor conguration le.
callback on/off : Enable callbacks for the tools.
9.3.31 translate
Translate the objects in the current scene. This does not change the atom coordinates.
by x y z: Translate by vector (x, y, z) in screen units (note, that this does not change the
atom coordinates).
to x y z: Translate to the absolute position (x, y, z) in screen units.
127
9.3.32 user
Add user-customized commands.
add key key command: Assign the given text command to the hot key key. When key is
pressed while the mouse is in the display window, the specied command will be executed.
print keys : Print out the current denition of the hot keys.
See section 5.1.3 for examples of the use of the user command.
9.3.33 vmdinfo
(Tcl) Returns information about this version of VMD.
version: Returns the version number;
versionmsg: Full information about this version;
authors: List of authors;
arch: architecture type (in case you couldnt tell);
options: options used to compile VMD;
www: VMD home page;
wwwhelp: VMD help page.
This function is available without Tcl and the information is displayed to the screen.
9.3.34 volmap
The volmap command creates volumetric maps (3D grids containing a value at each grid point)
based on the molecular data, which can then be visualized in VMD using the Isosurface and
VolumeSlice representations or using the Volume coloring mode. Also note that the VolMap plugin,
accessible from the VMD Extension menu, provides a graphical front-end to many of the volmap
commands capabilities.
To create a volumetric map, the volmap command is run in the following way, where the atom
selection species the atoms and molecule to include in the calculation, and where the maptype
species the type of volumetric data to create:
volmap <maptype> <atom selection> [optional arguments]
For example, to create a mass density map with a cell side of 0.5
A, averaged over all frames of
the top molecule, and add the volumetric data to the top molecule, on would use:
volmap density [atomselect top "all"] -res 0.5 -weight mass -allframes \
-combine avg -mol top
The various volumetric data map types currently supported by volmap are listed as follows.
Please note that when a map type description refers to an atoms radius or beta eld, etc., that
these values will be read directly from VMDs associated elds for that atom. In certain cases, you
may want to adjust the atom selections elds (such as radius, beta, etc.) before performing the
volmap analysis.
128
density: creates a map of the weighted atomic density at each gridpoint. This is done
by replacing each atom in the selection with a normalized gaussian distribution of width
(standard deviation) equal to its atomic radius. The gaussian distribution for each atom is
then weighted using an optional weight (see the -weight argument), and defaults to a weight
of one (i.e, the number density). The various gaussians are then additively distributed on a
grid.
interp: creates a map with the atomic weights interpolated onto a grid. For each atom, its
weight is distributed to the 8 nearest voxels via a trilinear interpolation. The optional weight
(see the -weight argument) defaults to a weight of one.
distance: creates a map for which each gridpoint contains the distance between that point
and the edge of the nearest atom. In other words, each gridpoint species the maximum
radius of a sphere cnetered at that point which does not intersect with the spheres of any
other atoms. All atoms are treated as spheres using the atoms VMD radii.
coulomb: Creates a map of the electrostatic eld of the atom selection, made by comput-
ing the non-bonded Coulomb potential from each atom in the selection (in units of k
B
T/e).
The coulomb map generation is optimized to take advantage of multiple processors and pro-
grammable graphics board if they are available.
ils: Creates a free energy map of the distribution of a weakly-interacting monoatomic or di-
atomic gas ligand throughout the system using the Implicit Ligand Sampling (ILS) technique.
See additional information about ILS below.
mask: Creates a map which is set to 0 or 1 depending on whether they are within a specied
cuto distance (use the -cutoff argument) of any atoms in the selection. The mask map is
typically used in combination with other maps in order to hide/mask data that is far from a
region of interest.
occupancy: Each grid point is set to either 0 or 1, depending on whether it contains onbe
or more atoms or not. When averaged over many frames, this will provide the fractional
occupancy of that grid point. By default, atoms are treated as spheres using the atomic radii
and a gridpoint is considered to be occupied if it lies inside that sphere. Use the -points
argument to treat atoms as points (a grid point is occupied if its grid cube contains an
atoms center).
The following optional arguments are universally understood by every volmap map types:
-allframes: Use every frame in the molecule instead of just the current one to compute the
volumetric map. The method used to combine the various trajectory frame maps can be
specied using the -combine argument. By default, volmap only uses the current frame.
-combine < avg | max | min | stdev | pmf >: Species the rule to use to combine
frames when using the -allframes argument. These correspond to keeping the average,
maximum or minimum values from the range of calculated frames. stdev will return the
standard deviation for each point over the range of frames, and pmf uses a thermal average
ln
N
i
e
value
i
/N for each point. The default is avg except for ligand maps where the
default is pmf.
129
-res resolution: Sets the resolution of the map. This means that the volume will be subdivided
into many small cubes whose side have a length of resolution.
-minmax x
min
y
min
z
min
x
max
y
max
z
max
: Allows the user to specify the min-max
boundaries of the grid in which the volumetric map will be computed. The argument to
-minmax is a list of two 3-vectors specifying the minimum and maximum coordinates of the
desired volumetric data grid.
-checkpoint frequency: For the analysis of long trajectories, it can be desirable to have
intermediate outputs of the volmap computation. The checkpoint option forces the volmap
computation to output a map of what has been computed so far, at every frequency frames.
The default frequency is 500; setting the frequency to zero disables the checkpointing feature.
-mol < molid | top >: Exports the nal volumetric data into the VMD molecule specied
by molid. By default, all maps are exported to a le or name maptype out.dx; using the -mol
option overrides this.
-o lename: Exports the nal volumetric data into a DX le (.dx extension is added if
missing). By default, all maps are exported to a le or name maptype out.dx.
The following optional arguments are special arguments understood only by some volmap map
types. Some arguments may only apply to certain map types or may have dierent meaning for
dierent map types:
-cuto cuto: Species a cuto distance. For the distance maps, species the largest distance
that will be considered (large number is better but slower). For the mask maps, species the
distance from each atom which will be considered part of the mask.
-points: For the occupancy map type. Treat atoms as point particles instead of as spheres.
-radscale factor: For the density map type. Sets a multiplication factor that multiplies all
the VMD atomic radii for the purpose of the calculation.
-weight < eld name | value list >: For the density map type. Sets a per-atom weight to be
used when computing the density. This can be the name of any VMD numerical atomic eld
(such as mass, charge, beta, occupancy, user, radius, etc.) or else a Tcl list of numbers of the
same length as the number of atoms.
Implicit Ligand Sampling (volmap ils command)
This command computes a map of the estimated potential of mean force (in units of k
B
T at 300 K)
of placing a weakly-interacting gas monoatomic or multiatomic ligand at every gridpoint. These
results will only be valid when averaging over a large set of frames. Note that if you have a CUDA
enabled GPU then your ILS calculation will run about 20 times faster than on a CPU.
Please refer to and cite:
Cohen, J., A. Arkhipov, R. Braun and K. Schulten, Imaging the migration pathways for O
2
, CO,
NO, and Xe inside myoglobin, Biophysical Journal 91, 18441857, 2006.
The command syntax diers from the other volmap commands and it has its own set of options:
130
volmap ils molid < minmax | pbcbox > [options]
Here minmax denotes the boundaries of the grid in which the volumetric map will be computed.
It is given as a list of two 3-vectors specifying the minimum and maximum coordinates of the desired
volumetric data grid x
min
y
min
z
min
x
max
y
max
z
max
. If you provide the keyword pbcbox
instead of the minmax coordinates then the target grid will be set to the rectangular box that
encloses the PBC cell. A typical choice for the minmax parameters would be the minmax box of a
subset of your system (for instance the just protein) as returned by the measure minmax command.
Based on the grid dimensions a selection that includes all atoms within the interaction cuto
distance (specied by -cutoff) is automatically chosen for the computation of the interactions.
In case your minmax box exceeds the periodic bounday box the non-overlapping parts of your
map will be ill dened and a warning is printed. In this case you should consider wrapping the
coordinates so that the requested grid lies in the center of the box. You can use the pbc wrap
command from the PBCtool plugin for this.
In case the nonbonded interaction margin exceeds the periodic boundaries regions of your map
will be based on incomplete interactions and a warning is printed. If this happens you should use
the -pbc ag which automatically takes atoms of the neighboring cells into account.
Before starting the computation, the atomic radii of each atom in the molecule should be set to
the corresponding CHARMM Lennard-Jones R
min
/2 parameter (in
Angstr om), and the beta value
of each atom should be set to the CHARMM Lennard-Jones (energy well depth in kcal/mol)
parameter. This can be done using VMDs VolMap plugin. Simply call in succession the following
commands within the VMD console environment to use default CHARMM values for the various
atoms of a molecule:
package require ilstools
ILStools::readcharmmparams [list of CHARMM parameter files]
ILStools::assigncharmmparams <molid>
The following optional arguments are understood:
-rst frame: First frame to process. (default: frame 0)
-last frame: Last frame to process. (default: last frame of molecule)
-o lename: Exports the nal volumetric data into a DX le (.dx extension is added if
missing). By default, all maps are exported to a le or name maptype out.dx.
-res resolution: Sets the resolution of the nal map. This means that the volume will be
subdivided into many small cubes whose side have a length of resolution. The computa-
tion should be performed on a ner grid (see -subres option) but at the end the map is
downsampled to this resolution. A good choice for the grid resolution 1
A (argument -res).
Lower resolutions make it dicult to see features, higher ones will be very costly in terms of
computation time. Also, since the uctuation of the protein backbone is on the order of 1-2
Angstrom a higher grid resolution doesnt make much sense.
-subres num: Number of points in each dimension of the subsampling grid, e.g. 2 for a
2x2x2 subgrid or 3 for a 3x3x3 subgrid. A value of 1 means is no subsampling, the default is
(-subres 3). Without subsampling the probe is placed at each grid cell center (for diatomic
probes in numconf dierent random orientations, see argument -orient). This position is
131
assumed to be representative for the interaction of the probe in this voxel with the system.
However, for a typical voxel size of 1x1x1
A the energy value can dier signicantly within
the voxel and the value at the center might not be close to the average. Subsampling averages
over the interaction on a regular subgrid in each voxel thus producing a more accurate free
energy value for placing the probe into each voxel. Even though this severely increases the
computational cost it is highly recommended that you use subsampling! A 3x3x3 subgrid for
a 1
A resolution map is a good choice.
-T temperature: The temperature in Kelvin at which the MD simulation was performed.
(default: 300)
-probesel selection: Atom selection that denes the probe molecule. The radius and occu-
pancy elds should be populated with the VDW radii and VDW epsilon parameters from the
force eld (see option -probevdw). Alternatively, you can specify the probe coordinates and
VDW parameters probe atoms directly using the -probecoor and -probevdw options.
-probecoor atomcoords: Set the coordinates of the probe atoms in form of a list of triples
x
0
y
0
z
0
. . . x
N
y
N
z
N
.
-probevdw parameterlist: Set the tuple of van der Waals parameters for each probe atom
in the form
0
R
min,0
/2 . . .
N
R
min,N
/2. They dene the nonbonded interactions of
the probe evaluated by the Lennard-Jones potential
U
VDW
=
atoms i,j
ij
R
ij
r
ij
12
2
R
ij
r
ij
(9.2)
where R
ij
= (R
min,i
+ R
min,j
)/2 and
ij
=
i
j
. (Thats the same form as in CHARMM
and AMBER parameter les). Units of are kcal/mol, and of R
min
/2 are
Angstr om.
-orient n: Control the number of samples of dierent probe orientations for multiatom probes
at each grid point. The number n determines the angular spacing of probe orientation vectors
and of the rotations around each of these vectors.
n = 1: use 1 orientation only
n = 2: use 6 orientations (vertices of a octahedron)
n = 3: use 8 orientations (vertices of a hexahedron)
n = 4: use 12 orientations (faces of a dodecahedron)
n = 5: use 20 orientations (vertices of a dodecahedron)
n = 6: use 32 orientations (faces+vertices of a dodecahedron)
n > 6: geodesic subdivisions of icosahedral faces with frequency 1, 2, ... n 6
For each orientation a number of rotamers will be generated. The angular spacing of the
rotations around the orientation vectors is chosen to be about the same as the angular spacing
of the orientation vector itself. If the probe has at least one symmetry axis then the rotations
around the orientation vectors are reduced accordingly. If there is an innite oder axis (linear
molecule) the rotation will be omitted. In case there is an additional perpendicular C2 axis
the half of the orientations will be ignored so that there are no antiparallel pairs.
Probes with tetrahedral symmetry:
Here n denotes the number of rotamers for each of the 8 orientations dened by the vertices
of the tetrahedron and its dual tetrahedron.
132
-cuto cuto: Set the CHARMM van der Waals cuto beyond which the interaction between
the probe and protein atoms is set to zero.
-maxenergy energy: Cuto energy above which the occupancy of a grid cell is regarded zero.
For GPUs energies of more than 87 always correspond to oating point values of zero for the
occupancy. Hence there is no point going higher than that. For CPUs that number is higher,
however, the lower the occupancy the more severely these points will be undersampled and
the according error will be very high. Thus, in the nal map it probably does not make sense
to look at values higher than 10kT which not a big loss since the low energy regions are the
ones we are interested in. So you probably want to set this to a value between 10 and 87 (we
are in thye process of testing this but I suppose 20 kT would be a safe number).
-alignsel selection: Use the provided selection to align all trajectory frames to the rst frame.
If you dont use this option you should make sure that you aligned all frames yourself before
running volmap ils.
-transform matrix: Suppose you want to align your trajectory to a reference frame from
a dierent molecule. In this case you should align the rst frame of your trajectory to the
reference and provide the according alignment matrix as returned by measure fit) using
the -transform option. volmap ils will take care of the rest.
-pbc: This ag signals that you want a periodic boundary aware ILS calculation. Depending
on the desired target grid size image atoms from neighboring PBC cells are taken into account
for the computation. The atoms used for the calculation are chosen from a box that exceeds
the target grid size by the interaction cuto in each direction.
Note: If your molecule rotated or drifted from the PBC center during your MD simulation
then the structure alignment will rotate or shift the PBC cell so that your map might not lie
entirely inside the PBC cell anymore. This will lead to ill-dened fringes of the map and you
might want to consider rewrapping the coordinates. Rewrapping cannot undo the rotation
but unless you have a very oblonged PBC cell removing the shift by rewrapping will in most
cases yield a map without or with little boundary eects. See the pbc wrap command from
the PBCtool plugin.
Warning: If you use -pbc DO NOT ALIGN the frames of the structure yourself prior to the
calculation! It will totally mess up the denition of your PBC cells. Instead you should use
the -alignsel option and let volmap handle the alignment. However, you CAN align the
sturcture globally (i.e. align all frames using the SAME transformation matrix) to a reference
frame. In this case you have to provide the transformation matrix you used via -transform.
-pbccenter vector: Since the PBC cell origin is stored neither in DCD les nor in VMD you
have to specify it in case it is dierent than the default 0 0 0.
-maskonly: This ag requests to compute only a mask map telling for which gridpoints we
expect valid energies, i.e. the points for which the maps overlap for all frames will contain 1,
all other points will be 0. This is useful if you dont use periodic boundary conditions where
it can happen that due to the choice of the grid and/or the rotation of the protein the box
including your grid plus the interaction cuto will lie partially outside your system which
means you would miss some of the interactions. The map produced by the -maskonly mode
will tell where are these ill dened regions.
133
9.3.35 wait
Specify a number of seconds to wait before reading another command. Animation continues during
this time. The wait command will not behave as expected if called within a complex Tcl proc or
loop structures. The wait command doesnt actually run until the next complete Tcl code block
due to the way VMD processes its commands.
time: wait time seconds.
9.3.36 sleep
Specify a number of seconds to sleep before reading another command. Animation stops during
this time.
time: sleep time seconds.
9.4 Tcl callbacks
When certain events occur, VMD noties the Tcl interpreter by setting certain Tcl variables to
new values. You can use this feature to customize VMD, for instance, by causing new graphics to
appear when the user picks an atom, or recalculating secondary structure on the y.
To make these new feature happen at the right time, you need to write a script that takes a
certain set of arguments, and register this script with the variable you are interested. Registering
scripts is done with the built-in Tcl command trace; see http://www.tcl.tk/man/tcl8.4/TclCmd/trace.htm
for documentation on how to use this command. The idea is that after you register your callback,
when VMD changes the value of the variable, your script will immediately be called with the new
value of the variable as arguments. Table 9.4 summarizes the callback variables available in VMD.
In the VMD script library at http://www.ks.uiuc.edu/Research/vmd/script_library/, you
can nd a number of scripts that take advantage of Tcl variable tracing. Below, we give a simple
example. The following procedure takes the picked atom and nds the molecular weight of residue
it is on.
proc mol_weight {args} {
# use the picked atoms index and molecule id
global vmd_pick_atom vmd_pick_mol
set sel [atomselect $vmd_pick_mol "same residue as index $vmd_pick_atom"]
set mass 0
foreach m [$sel get mass] {
set mass [expr $mass + $m]
}
# get residue name and id
set atom [atomselect $vmd_pick_mol "index $vmd_pick_atom"]
lassign [$atom get {resname resid}] resname resid
# print the result
puts "Mass of $resname $resid = $mass"
}
134
Table 9.4: Description of Tcl callback variables in VMD.
When called Name Description
Molecule molid was deleted vmd molecule(molid) 0
Molecule molid was created
(data may not have been
loaded yet)
vmd molecule(molid) 1
Molecule molid was renamed vmd molecule(molid) 2
Structure le loaded vmd initialize structure(molid) 1
Coordinate le loaded vmd trajectory read(molid) name of coordinate le
Molecule molid changed ani-
mation frames
vmd frame(molid) new animation frame
Any VMD command executed vmd logfile Tcl text equivalent of com-
mand
An atom has been picked using
the Pick mouse mode
vmd pick event When receiving this event, the
following global variables are
also set: vmd pick atom (id
of picked atom), vmd pick mol
(id of picked molecule)
Pointer moved. vmd pick client name of pointer
Pointer moved. vmd pick mol silent id of nearby mol
Pointer moved. vmd pick atom silent id of nearby atom
Atom picked vmd pick shift state 1 if shift key down during pick,
0 otherwise
IMD coordinate set received vmd timestep(molid) frame containing new coordi-
nates
Set of labels to be graphed
vmd graph label labeltype labelid labeltype
labelid ...
Tcl interpreter is shutting
down
vmd quit 1
135
Once an atom has been picked, run the command mol weight to get output like:
Mass of ALA 7 : 67.047
Since VMD sets the vmd pick event, it can be traced. The trace function is registered as:
trace add variable ::vmd_pick_event write mol_weight
And now the residue masses will be printed automatically when an atom is picked. Make sure
to turn o the trace when you are done with it (e.g. your plugins window gets closed):
trace remove variable ::vmd_pick_event write mol_weight
136
Chapter 10
Python Text Interface
VMD 1.6 and later contain an embedded, fully-functional Python interpreter. The interpreter acts
just like the Python command line: you can import your own modules and run them from with the
text console of VMD. In addition, VMD provides a number of modules for loading molecules and
controlling their display.
Pre-compiled VMD binaries currently use Python version 2.5. The current VMD source code
has been tested to compile with Python versions 2.4 to 2.6 on a few platforms. User contributed
VMD rpm or deb packages can be thus be compiled against any of those versions.
10.1 Using the Python interpreter within VMD
When you start VMD, the VMD text console normally uses the Tcl command interpreter to process
what you type. In order to use the Python interpreter, you have to tell VMD to switch to Python
mode. There are three ways to do this: (1) Type gopython in the console window; (2) pass
-python as a command line option; or (3) put gopython on the last line of your .vmdrc le. If
VMD prints an error message reporting that the Python interpreter is not available, your version
of VMD was not compiled with Python support; contact the VMD developers for help. If all goes
well, you should see Python command prompt >>> in the console window. To switch back to
the Tcl interpreter, press Ctrl-D as though you were exiting Python. Switching back and forth
between Python and Tcl does not destroy any of your work; all variables and modules will still be
dened until you exit VMD.
Typing gopython <lename>, where <lename> is the name of a le containing Python code
will cause VMD to switch to Python mode, process the le, then switch back to Tcl. In this way,
you can embed Python functions inside your Tcl scripts!
You can also type gopython -command your code here to run an arbitrary line of python
code.
10.2 Python modules within VMD
Once you enter the VMD Python environment, you will nd a module called VMD already
loaded. This module contains all the other built-in modules for writing VMD Python scripts.
VMD is not distributed with an entire Python environment. In order to use the set of libraries
that normally come with a Python distribution, you must tell Python where to nd the libraries.
There are two primary means of doing this. The PYTHONHOME environment variable points to
137
the location where Python is installed; the version installed at this point must match VMDs
version (2.5). Thus if you have Python libraries in /usr/local/lib/python2.5, adding the line set
env(PYTHONHOME) /usr/local to your startup script or .vmdrc le will do the trick.
If you have additional modules that you want to use within VMD, use the PYTHONPATH environ-
ment variable to tell Python where to nd them. Please note that any of these modules have to be
compiled against matching versions of the Python package and its subpackages that are distributed
with the pre-compiled VMD binaries. If you want to use the native Python and its packages, you
will have to compile VMD from source code or install a user contributed package that matches
your OS. See any Python book and the instructions for compiling VMD from source code for more
information.
if the Tkinter module is found in the Python installation, VMD will load it at Python startup
in order to make Tkinter windows work in harmony with windows created from within Tk. In
addition, if you have Numeric Python installed in your system, a submodule called vmdnumpy will
become available within the VMD module; see below for details.
10.3 Atom selections in Python
10.3.1 The built-in atomsel type
NEW IN VMD 1.8.6: The AtomSel class has been deprecated, in favor of a new built-in type
called atomsel. The atomsel type functions much the same way as the old AtomSel class, but also
provides methods similar to the Tcl interface for returning RMS t matrices and applying those
transformations to coordinates.
The new atomsel type is found in a new built-in module, also called atomsel. Use help(atomsel)
to get the complete documentation.
10.3.2 The AtomSel class (DEPRECATED)
VMD provides an atom selection class for use in the Python interpreter. Instances of this class
correspond to a set of atom indices in a particular molecule for a particular coordinate set. Once
an atom selection is made, you can query the properties of the selected atoms, such as their names,
residue ids, or coordinates. In a similar fashion, you can set the values of these properties. You
can also perform logical operations on atom selections, including nding the intersection or union
of two atom selections or nding the inverse of the set. Finally, you can perform tuple operations
on the atom selection object to query the indices of the atoms in the selection.
Atom selection macros can be dened using the macro method of the AtomSel module. The syn-
tax is just as in the corresponding atomselect macro and atomselect delmacro Tcl commands;
see section 9.3.2 for details.
Below we summarize the methods available from the AtomSel class.
AtomSel(selection = all, molid = 0, frame = 0): Creates a new atom selection
object.
>>> sel = AtomSel(name CA, 1) # Selects the alpha carbons of molecule 1
select(selection): Change the selected atoms.
>>> sel.select(resid 5)
list(): Return a copy of the selected atom indices.
138
frame(value = -1): Set/get the coordinate frame for the selection. Nonpositive values will
return the current value of the frame without changing it.
>>> sel.frame(5)
>>> sel.frame()
5
get(attr1, attr2, ...): Takes any number of string arguments, which should correspond
to a valid atom property such as name, x, or water. Returns a list of the value of the
property for each atom in the selection. For boolean properties such as water, the returned
value will be 1 if true and 0 if false.
>>> x, y, z = sel.get(x, y, z)
set(attr, val): Set the atom property corresponding to attr using the values in val. The
number of elements in val should be either 1 or the number in the atom selection.
>>> len(sel)
12
>>> sel.set(beta,3)
>>> sel.set(beta,(1,2,3,4,5,6,7,8,9,10,11,12))
write(filename, filetype=None): Write the atoms in the selection to lename. Filetype
is guessed from the lename, or can be specied with letype.
sel1 & sel2: Create a new atom selection using the atoms found in both sel1 and sel2.
sel1 [ sel2: Create a new atom selection using the atoms found in either sel1 or sel2.
-sel: Create a new atom selection using the atoms not found in sel.
len(sel): Returns the number of atoms in the selection.
sel[0], sel[0:3]: Index and slice operations return the corresponding atoms in the selec-
tion.
center(weight=None): Return the center of the selected atoms, possibly weighted by
weight, which must be a sequence.
sasa(srad, samples=-1, points=None, restrict=None): Returns the solvent-accessible
surface area (SASA) of atoms in the selection using the assigned radius for each atom, ex-
tending each radius by srad to nd the points on a sphere that are exposed to solvent. If
a restrict selection is given, only solvent-accessible points near that selection bill be consid-
ered. The points parameter can be used to collect the points which are determined to be
solvent-accessible; this must be a list variable.
getbonds(): Returns a list of the atoms bonded to each atom in the selection.
setbonds(bonds): Set the bonds for the atoms in the selection. bonds must be a list of
the same length as the selection; each element in the list must be a sequence containing the
indices of the atoms to which the atom has a bond.
139
minmax(): Returns the minimum and maximum coordinates of the atoms in the selection
as a tuple of the form (xmin, ymin, zmin), (xmax, ymax, zmax).
rmsd(sel, frame=None, weight=None): Returns the root-mean-square distance of the
atoms in sel from the selection. If frame is given, the coordinates from the corresponding
frame will be used (see the example). If weight is given, the computed RMSD will be weighted
using the values in weight.
align(ref=None, move=None, frame=None, weight=None): Finds the transformation
that aligns the atoms in the selection with the atoms in ref, with optional weights weight,
and applies this transformation to the atoms in move. The following default values for all
arguments are provided:
ref: Same molecule and atoms as selection, but always using the
align(ref=None, move=None, frame=None, weight=None):
Finds the transformation that aligns the atoms in the selection with the atoms in ref,
with optional weights weight, and applies this transformation to the atoms in move.
The following default values for all arguments are provided:
ref: Same molecule and atoms as selection, but always using the rst timestep in
the molecule.
move: All atoms in the selection molecule.
frame: overrides both the selections frame and the move frame, but does not aect
the ref frame.
weight: Defaults to uniform weights on all atoms in selection.
rst timestep in the molecule.
move: All atoms in the selection molecule.
frame: overrides both the selections frame and the move frame, but does not aect the
ref frame.
weight: Defaults to uniform weights on all atoms in selection.
contacts(cutoff, sel=None): Returns pairs of of atoms within cutoff of each other.
If sel is None, atoms in the pairs must be in the selection; otherwise, the rst atom in each
pair will be from the selection, and the second will be from sel.
10.3.3 An atom selection example
In the rst example, we load the molecule alanin.pdb, and create an atom selection consisting
of the alpha carbons. Note that AtomSel is the name of the class which generates atom selection
instances. We show the string representation of the object by entering its name and pressing return;
this shows the text used in the selection.
Next we demenstrate how atom selections act like tuples: we can get their length using the built-
in len() command,and return a copy of the selected atoms in a tuple by using the slice operator
[:].
Finally, we demonstrate the get and set operations. The get() operation takes any number of
string arguments; for each argument, it returns a Python list of values corresponding to that string.
The set() operation allows only one property to be changed at a time. However, you can pass in
140
either a single value, which will be applied to all atoms in the selection, or a tuple or list of the same
size as the atom selection, in which case values in the list will be assigned to the corresponding
atom in the selection. We take advantage of this behavior in the following example by rst saving
the current value of beta for the selection, then setting the value of beta to 5 for all selected atoms,
and nally resetting the original values using the results of the get().
>>> from molecule import *
>>> from AtomSel import AtomSel
>>> load(alanin.pdb)
>>> CA = AtomSel(name CA)
>>> CA
name CA
>>> len(CA)
12
>>> CA[:]
(0, 5, 11, 17, 23, 29, 35, 41, 47, 53, 59, 65)
>>> resname, resid = CA.get(resname, resid)
>>> resname
[ACE, ALA, ALA, ALA, ALA, ALA, ALA, ALA, ALA, ALA, ALA, C
BX]
>>> resid
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
>>> x,y,z=CA.get(x,y,z)
>>> x
[-2.1840000152587891, 1.4500000476837158, 1.9809999465942383, 0.54100000858306885,
2.8090000152587891, 5.9079999923706055, 5.0440001487731934, 4.5659999847412109,
7.9340000152587891, 9.7329998016357422, 8.1689996719360352, 9.2229995727539062]
>>> y
[0.5910000205039978, 0.0, 3.6429998874664307, 4.8410000801086426, 2.5559999942779541,
3.7860000133514404, 7.4190001487731934, 6.7989997863769531, 5.0819997787475586,
7.9559998512268066, 10.515999794006348, 8.5710000991821289]
>>> z
[0.9100000262260437, 0.0, -0.9089999794960022, 2.3880000114440918, 4.3920001983642578,
2.5859999656677246, 3.244999885559082, 6.9559998512268066, 7.2639999389648438,
5.5669999122619629, 7.8870000839233398, 11.013999938964844]
>>> beta = CA.get(beta)
>>> CA.set(beta,5)
>>> CA.set(beta,beta)
>>>
10.3.4 Changing the selection and the frame
When molecule in VMD contains multiple coordinate sets (frames), atom selections must know
which frame they are referring to, especially when you make distance-based atom selections or
141
request time-varying properties like the x, y, or z coordinates. By default, atom selections in
Python use frame 0, i.e. the rst coordinate set. You can specify the frame either when you create
the atom selection, or by using the frame() method. Passing no arguments to frame() returns the
current value of the frame.
>>> load(psf,alanin.psf,dcd,alanin.dcd)
>>> resid5 = AtomSel(resid 5, frame=50)
>>> resid5.frame()
50
>>> resid5.frame(22)
>>> resid5.frame()
22
In a similar way, you can change the selected atoms of an atom selection object using the select()
operation. Continuing with the previous example:
>>> resid5
resid 5
>>> resid5.select(resid 7)
>>> resid5
resid 7
>>>
10.3.5 Combining atom selections
Once youve created one or more atom selections, you can combine them to create new ones.
>>> CA = AtomSel(name CA)
>>> resid5 = AtomSel(resid 5)
>>> CA
name CA
>>> resid5
resid 5
>>> ANDsel = CA & resid5
>>> ORsel = CA | resid5
>>> NOTsel = -CA
>>> ANDsel
(name CA) and (resid 5)
>>> ORsel
(name CA) or (resid 5)
>>> NOTsel
not (name CA)
>>>
When the combined atom selections are from dierent molecules or have dierent frame num-
bers, the molecule and frame from the rst atom selection are used.
142
10.3.6 RMS example
Example: nd the mass-weighted RMS distance from the initial frame. This assumes a molecule
and its timesteps have already been loaded (see the description of the Molecule class).
from AtomSel import AtomSel
from Molecule import *
# Get a reference to the first molecule.
m=moleculeList()[0]
# Select all atoms.
sel=AtomSel()
# We are comparing to the first frame.
sel.frame(0)
# Get the mass weights.
mass = sel.get(mass)
Heres another RMSD example that uses the {\tt align} method:
\begin{verbatim}
from AtomSel import AtomSel
from Molecule import Molecule
mol1=Molecule()
mol1.load(proteins/alanin.psf)
mol1.load(proteins/alanin.dcd)
n = mol1.numFrames()
sel=AtomSel(backbone)
# align all frames with the first frame, using the backbone atoms
for i in range(1,n):
sel.align(frame=i)
# align all frames with frame 10.
for i in range(1,n):
sel.align(ref=sel.frame(10), frame=i)
# Align residues 1-3 from frame 10 with frame 20, but use all backbone atoms
# to perform the fit.
resid123=AtomSel(resid 1 to 3)
sel.align(ref=sel.frame(20), frame=10, move=resid123)
# GOTCHA ALERT: sel.frame(10).align(ref=sel.frame(20)) does not work!!
# Thats because sel.frame(10) overrides frame 20 in this case since they
143
# are applied to the same AtomSel instance. Either use the frame argument,
# as illustrated here, or create a new AtomSel instance for the reference.
# Perform a mass-weighted RMSD alignment and compute the mass-weighted
# RMS distance from the first frame.
w=sel.get(mass)
rms=[]
ref=AtomSel(backbone,frame=0)
for i in range(n):
rms.append(sel.frame(i).align(ref=ref, weight=w).rmsd(ref, weight=w))
# Initialize result list.
rms=[]
# Go!
for i in range(m.numFrames()):
rms.append(sel.rmsd(sel, frame=i, weight=mass))
Heres another RMSD example that uses the align method:
from AtomSel import AtomSel
from Molecule import Molecule
mol1=Molecule()
mol1.load(proteins/alanin.psf)
mol1.load(proteins/alanin.dcd)
n = mol1.numFrames()
sel=AtomSel(backbone)
# align all frames with the first frame, using the backbone atoms
for i in range(1,n):
sel.align(frame=i)
# align all frames with frame 10.
for i in range(1,n):
sel.align(ref=sel.frame(10), frame=i)
# Align residues 1-3 from frame 10 with frame 20, but use all backbone atoms
# to perform the fit.
resid123=AtomSel(resid 1 to 3)
sel.align(ref=sel.frame(20), frame=10, move=resid123)
# GOTCHA ALERT: sel.frame(10).align(ref=sel.frame(20)) does not work!!
# Thats because sel.frame(10) overrides frame 20 in this case since they
# are applied to the same AtomSel instance. Either use the frame argument,
# as illustrated here, or create a new AtomSel instance for the reference.
144
# Perform a mass-weighted RMSD alignment and compute the mass-weighted
# RMS distance from the first frame.
w=sel.get(mass)
rms=[]
ref=AtomSel(backbone,frame=0)
for i in range(n):
rms.append(sel.frame(i).align(ref=ref, weight=w).rmsd(ref, weight=w))
10.4 Python callbacks
Some of your Python scripts may wish to be informed when various events in VMD occur. The
mechanism for expressing this interest is to register a callback function with a special module
supplied by VMD. When the event of interest occurs, all registered will functions will be called;
VMD will pass the functions information specic to the event. The set of callbacks events is listed
in Table 10.4.
Table 10.1: Description of callbacks available to scripts running in the embedded Python interpreter.
Name When called Function arguments
display update Screen redraw none
frame Molecule changes coordinate frame (molid, frame)
help User pushes help button on main form (name of topic)
initialize structure Molecule created or deleted (molid, 1 or 0)
pick atom Atom picked in graphics window (molid, atomid,
key shift state (1 if shift pressed, 0 otherwise) )
pick value Bond, angle, or dihedral label created (value)
timestep New IMD coordinate frame received (molid, frame)
trajectory Completion of coordinate le read/write (molid, lename)
All callback functions must take two arguments. The rst argument will be an object given
at the time the function is registered; VMD makes no use of this object, it simply saves it and
passes it to the callback when the callback function is called. The second argument to the callback
function will be a tuple containing 0 or more elements, depending on the type of callback. The
type of information for each callback is listed in the third column of Table 10.4.
Callbacks are registered/deregistered using the add callback/del callback methods of the VMD.vmdcallbacks
module. The syntax for these methods is:
def add_callback(name, func, userdata = None):
def del_callback(name, func, userdata = None):
name should be one of the callback names in Table 10.4. func is the function object. userdata
is any object; if no object is supplied, None will be passed as the rst argument to the callback
function. To unregister a callback, use the same name, func, and userdata as were used when the
callback was registered. The same function may be registered multiple times with dierent userdata
objects.
145
10.4.1 Using Tkinter menus in VMD
The object-oriented interface to Tk known as Tkinter is included with the embedded Python
interpreter. You can create Tkinter GUIs in the usual way, with one caveat: the Tkinter.mainloop()
method should never be called, as it will interfere with VMDs own event loop. VMD will take care
of updating your GUI windows for you.
10.5 Controlling VMD from Python
Commands for controlling VMD from Python are organized into modules which roughly correspond
to Tcl commands. Importing all the commands in a module is not recommended as some of the
functions (e.g., listall()) overlap. All commands are listed below, with the name of the module
given by the section heading.
10.5.1 animate
Python operations available from the animate module, used to control which coordinate frames are
displayed.
forward():
reverse(): forward() and reverse() causes VMD to start animating frames automatically
in order of increasing or decreasing frame number, respectively.
once():
rock():
loop(): once(), rock(), and loop() control how frames are cycled when VMD is animating
a series of frames. once() causes VMD to stop when it reaches the rst or last frame. rock()
causes VMD to reverse direction each time it gets to the beginning or end. loop() causes
VMD to continue from the beginning when reaches the last frame, or from the last frame if
it gets to the beginning.
style(): Returns either Once, Rock, or Loop, corresponding to the animation mode
VMD is currently in.
goto(frame): Set the animation to the given frame, and pause the animation.
prev(): Step to the next-lowest frame, then pause.
next(): Step to the next-highest frame, then pause.
pause(): Stop animating frames.
speed(value): Get/set the relative rate at which VMD animates frames. value should lie
between 0 and 1. If a value less than 0 is given, then the speed will not be changed. The new
value of the speed is always returned.
skip(value): Get/set the number of frames to skip when animating. A value of 1 means
every frame is shown; 2 means every other frame is shown; etc. If value is 0 or less, no change
is made. The new value of the speed is always returned.
146
is active(molid): Returns whether the molecule with the given id is active; that is;
whether it responds to animation or not.
activate(molid, trueorfalse): Make the molecule with the given id active or not. Active
molecules update their coordinate frames during animation; inactive molecules do not.
10.5.2 axes
Python operations available from the axes module, used to change where the axes are displayed in
the graphics window.
OFF, ORIGIN, LOWERLEFT, LOWERRIGHT, UPPERLEFT, UPPERRIGHT: String constants de-
ned in the axes module for setting the location of the axes.
get location(): Returns a string object corresonding the current location of the axes.
set location(location): Set the location of the axes, using one of constants dened in
the module.
10.5.3 color
Python operations available from the color module, used to change the color denitions, color maps,
or edit the color scale. All rgb and color scale values should be in the range 0 to 1.
categories(): Returns a list of available color categories.
get colormap(name): Returns a dictionary of name/color pairs for the given color cate-
gory.
set colormap(name, dict): Change the color denitions for the colors in the given color
category. The keys in dict must come from the keys listed by get colormap for that color
category, though not all keys need be listed. The values must be legal color names.
get colors(): Returns a dictionary whose keys are all the legal color names and whose
corresponding values are the RGB values of the color, represented as a 3-tuple.
set colors(dict): Changes RGB values for colors in VMD. Keys must be chosen from the
keys returned by get colors(). Values must be 3-tuples of oats.
scale method(): Returns the current color scale method.
scale methods(): Returns a list of all available color scale methods.
scale midpoint(): Returns the current color scale midpoint.
scale min(): Returns the current color scale minimum.
scale max(): Returns the current color scale maximum.
set scale(method, midpoint, min, max): Change the color scale method, midpoint, min-
imum, or maximum. All properties may be set using keyword arguments.
147
10.5.4 display
Python operations available from the display module, used to control the VMD camera as well as
screen updates.
update(): Force a display update, without checking the VMD FLTK menus
update ui(): Update the display as well as any other user interfaces.
update on(): Tell VMD to regularly update the display and the FLTK menus
update off(): Tell VMD not to regularly update the display. The display will be updated
only when display.update() is called.
stereomodes(): Returns a list of the available stereo modes.
PROJ PERSP, PROJ ORTHO: String constants dened in the display module for setting the
projection keyword in the set method.
set(**keywordlist):
get(key): set() and get() control various display properties. The following keywords ac-
cept/return oating-point values: eyesep, focallength, height, distance, nearclip,
farclip. The following keywords accept boolean values for on or o, respectively: antialias,
depthcue, culling. stereo should be one of the values returned by stereomodes().
projection should be one of the PROJ constants dened in this module. size should
be a list of two integers corresponding to the width and height of the display in pixels.
10.5.5 evaltcl
The evaltcl method provides access to the main VMD Tcl interpreter from Python. It takes a string
with Tcl commands as an argument and evaluates it. Its main purpose is to provide the Python
interpreter with access to functionality that is only available from Tcl and for which no equivalent
implementation yet exists in Python, for example the Tcl based plugins. Usage Examples:
from VMD import evaltcl
versionid=evaltcl(vmdinfo version)
evaltcl(play somescript.tcl)
10.5.6 graphics
Python operations available from the graphics module, used to create custom 3-D objects from
graphics primitives. The rst argument to all operations is the id of a Graphics molecule. Graphics
molecules are created using the load() command in the molecule module: load(graphics,
test) creates a Graphics molecule named test. For vertices and normals, a tuple with three
oat items is required.
triangle(id, v1, v2, v3): Draw a triangle with the given vertices.
trinorm(id, v1, v2, v3, n1, n2, n3): Draw a triangle with the given vertices and
vertex normals.
148
cylinder(id, v1, v2, radius=1.0, resolution=6, filled=0): Draw a cylinder with
endpoints specied by the given points. Radius, resolution, and lled (whether the ends
should be capped or not) may be optionally specied with keyword arguments.
point(id, v): Draw a point at the given coordinates.
line(id, v1, v2, style=solid, width=1): Draw a line between the given vertices.
Optionally, the line style may be specied as either solid or dashed, and width may be any
positive integer.
materials(id, onoff): Turns materials on/o for subsequent graphics primitives. Primi-
tives lying earlier in the stack are not aected. onoff should be either 0 (o) or 1 (on).
material(id, name): Sets the material for all graphics primitives in this molecule. name
should be one of the material names returned by material.listall().
color(id, color): Set the color for subsequent graphics primitives. color may be (1)
a tuple containing three oats specifying the RGB value, (2) an integer corresponding to a
color index, or (3) a string corresponding to a color name.
cone(id, v1, v2, radius=1.0, resolution=6): Draw a cone with base at v1 and point
at v2. radius and resolution may optionally be specied with keyword arguments.
sphere(id, center=(0.0, 0.0, 0.0), radius=1.0, resolution=6): Draw a sphere.
The sphere center, radius, and resolution may optionally be specied with keyword argu-
ments.
text(id, pos, text, size=1.0): Draw text at the given position (specied by a tuple
of three oats, using the string text. Size may optionally be specied using keyword argu-
ments.
delete(id, index): Deletes the graphics primitive with the given index. Alternatively, if
the string all is passed as the index, all graphics primitives will be deleted.
replace(id, index): Deletes the graphics primitive with the given index. The next graph-
ics primitive added will go in the newly vacated position. Subsequent graphics primitives will
resume at the end of the list.
info(ind, index): Returns a string describing the graphics primitive with the given index.
If the index is invalid, an IndexError exception is raised.
listall(ind): Returns the indices of the valid graphics primitives in a list.
10.5.7 imd
Python operations available from the imd module, used to display and interact with a molecule in
a molecular dynamics simulation.
connect(host, port): Connect to a simulation running on host host and listening for
incoming connections on port port.
pause(): If connected, cause the simulation to pause.
149
detach(): If connected, detach from the simulation. The simulation will continue to run,
but no more frames will be received until a connection is re-established.
kill(): If connected, terminate the simulation. The connection will also be abolished.
transfer(rate): Set/get how often the remote simulation sends coordinate frames to VMD.
If rate is omitted or is negative, no action is taken and the current value is returned. A value
of 1 corresponds to every frame being sent; a value of 2 corresponds to every other frame,
etc.
keep(rate): Set/get how often received coordinates frames are kept by VMD as part of
an animation. If rate is omitted or is negative, no action is taken and the current value is
returned. A value of 0 means no frames are saved. A value of 1 corresponds to every frame
being saved; a value of 2 corresponds to every other frame, etc.
copyunitcell(True/False): Control how unitcell information is passed to the new frame
that recieved via IMD. If set to False (the default) unit cell information would be taken from
the IMD connection. Since the IMD protocol currently has no provisions for communicating
the unit cell information, the unit cell dimensions are set to zero. If set to True the cell
information is copied from the previous frame.
WARNING: when using imd.copyunitcell(True) with simulations in the NPT ensemble,
the resulting unitcell information will be incorrect.
10.5.8 label
Python operations available from the label module, used to create, show/hide, and delete labels for
atoms, bonds, angles, or dihedrals.
ATOM, BOND, ANGLE, DIHEDRAL: Label types dened by the label module, for use as the rst
argument to the add, listall, show, hide, and delete methods.
add(type, molids, atomids): Create a label of the given type. molids and atomids must
be tuples containing 1, 2, 3, or 4 integers for ATOM, BOND, ANGLE, or DIHEDRAL labels,
respectively. If the label already exists, no action is performed. Returns a dict corresponding
to the referenced label that can be used in the show(), hide(), delete(), and getvalues()
methods.
listall(type): Returns a list of labels of the given type. The elements of the list are
python dictionary objects, with the following keys: molid, atomid, value, on. The values
for molid and atomid are tuples containing the molecule id and atom id for the label. value
is the numerical value of the geometry label, or zero for ATOM labels. on is 1 if the label is
shown, and 0 if the label is hidden.
show(type, label): Turn the given label on. label must be a dictionary containing molid
and atomid keys whose values are tuples. If the tuples match the molecule ids and atom ids
of the atoms in an existing label, the label will be turned on. Raises ValueError if the label
does not exist.
hide(type, label): Turn the given label o. label must be a dictionary containing molid
and atomid keys whose values are tuples. If the tuples match the molecule ids and atom ids
150
of the atoms in an existing label, the label will be turned o. Raises ValueError if the label
does not exist.
delete(type, label): Delete the given label. label must be a dictionary containing molid
and atomid keys whose values are tuples. If the tuples match the molecule ids and atom ids
of the atoms in an existing label, the label will be deleted. Raises ValueError if the label does
not exist.
getvalues(type, label): Returns a list of values of the given label for each coordinate
frame in the label. If the atoms in the label belong to dierent molecules, only the coordinates
of the rst molecule will be cycled. If the labels dont have values (like atom labels), None is
returned.
10.5.9 material
Python operations available from the material module, used to create and modify material prop-
erties of molecular representations.
listall(): Returns a Python list of the names of all available materials.
settings(name): Returns a Python dictionary of the material settings for material with
the given name.
add(name=None, copy=None): Create a new material with the given name. Optionally,
copy the properties from material copy into the new material. If no name is given, a new one
will be provided.
delete(name): Delete the material with the given name.
rename(oldname, newname): Rename the material with the given name. The new name
must not yet be used.
change(name, ambient, specular, diffuse, shininess, opacity): Change one or more
of the material settings for the material with the given name. Keyword arguments may be
used to specify each property.
10.5.10 molecule
Python operations available from the molecule module, used to load molecules and change their
representations.
num(): Returns the number of loaded molecules.
listall(): Returns the molids of the all the loaded molecules.
exists(molid): Returns true if the molid corresponds to an existing molecule.
new(name): Creates a new empty molecule with the given name and returns its id.
151
load(structure, sfname, coor, cfname): Load a molecule with structure type structure
and lename sfname. Additionally, a separate coordinate le may be provided, of type coor
and name cfname. New in VMD 1.8: All frames from cfname will be processed before the
function returns. If successful, the function will return the id of the new molecule.
>>> load(pdb,alanin.pdb)
>>> load(psf,alanin.psf,dcd,alanin.dcd)
cancel(molid): Cancel loading of coordinates le for the given molecule.
delete(molid): Delete the specied molecule.
read(molid, type, filename, beg = 0, end = -1, skip = 1, waitfor = 1, volsets
= [1]):
write(molid, type, filename, beg = 0, end = -1, skip = 1, waitfor = 1): Read
or write a le to/from the specied molecule. For reading, if molid is -1, a new molecule
will be created. Optional arguments beg, end, and skip may be specied with keywords;
the default is to load/save all coordinate frames. New in VMD 1.8: The waitfor option
will cause VMD to process the specied number of frames before returning. If waitfor is
negative, all frames from the le will be processed before the function returns. For reading
les containing volumetric datasets, set the volsets parameter to a list of set ids, starting
from 0, to specify which datasets to load.
add volumetric(molid, name, origin, xaxis, yaxis, zaxis, xsize, ysize, zsize, data):
Add a volumetric data set to the given molecule. origin, xaxis, yaxis, and zaxis must be
3-tuples specifying the center and scale of the data. xsize, ysize and zsize give the number
of elements along each dimension. data must be a Python list of the correct size as indicated
by the three sizes.
get filenames(molid): Returns a list of lenames that have been loaded into this molecule.
get filetypes(molid): Returns a list of letypes corresponding to get filenames.
get databases(molid): Returns a list of databases corresponding to get filenames.
get accessions(molid): Returns a list of accessiosn corresponding to get filenames.
get remarks(molid): Returns a list of remarks corresponding to get filenames.
delframe(molid, beg=0, end=-1, skip=1): Delete frames from the specied molecule.
Optional arguments beg, end, and skip may be specied with keywords; the default is to
delete all coordinate frames.
dupframe(molid, frame): Copy the coordinates from the given frame and append them as
a new frame.
numframes(molid): Return the number of coordinate frames in the specied molecule.
get frame(molid): Return the current coordinate frame for the specied molecule.
152
set frame(molid, frame): Set the current coordinate frames in the specied molecule.
numatoms(molid): Returns the number of atoms in the specied molecule.
ssrecalc(molid): Recalculate the secondary structure for the given molecule, using the
current set of coordinates.
name(molid): Returns the name of the given molecule.
rename(molid,newname): Rename the given molecule.
get top(molid):
set top(molid): Get/set the molid of the top molecule.
get periodic(molid, frame=-1):
set periodic(molid, frame=-1, a, b, c, alpha, beta, gamma): Get/set periodic im-
age settings for the given molecule and timestep (frame). get periodic returns a dictionary
whose keys are a, b, c, alpha, beta, gamma. set periodic sets the corresponding val-
ues; negative values will be ignored.
10.5.11 molrep
Python operations available from the molrep module, used to add and modify representation of
molecules.
num(molid): Returns the number of representations in the given molecule.
addrep(molid, style=None, color=None, selection=None, material=None): Add a
representation to the specied molecule. If any of the optional keywords are specied as well,
the new rep will have the specied properties. Note that these properties become the default
for future calls to addrep, so that addrep(0, style=VDW); addrep(0, color=Name)
will create two reps, each with a style of VDW.
delrep(molid, rep): Delete the specied rep from the given molecule.
modrep(molid, rep, style, sel, color, material): Modify the style, atom selection,
color, and/or material for the specied molecule and representation. Any combination of
the last four arguments may be specied, using positional or keyword arguments. Returns
success.
>>> modrep(0,0,color=name) # Color the rst rep of molecule 0 by name.
>>> modrep(0,2, selection=name CA, material=Transparent) # For the third represen-
tation of molecule 0, change the atom selection to name CA and the material to Trans-
parent
get style(molid, rep):
get selection(molid, rep):
get color(molid, rep):
153
get material(molid, rep): Returns the representation style, selection, color, or material,
respectively, for the given representation of the given molecule.
get repname(molid, rep):
repindex(molid, name): These two commands let you assign names to reps and access
them by that name. The name returned by get repname is guaranteed to be unique for all
reps in the molecule, and will stay with the rep it was assigned to even when the order of the
reps changes. Use repindex to nd the repid of the rep with the given name; -1 is returned
if no rep with that name exists.
get autoupdate(molid, rep):
set autoupdate(molid, rep, onoff): These two commands let you turn on/o automatic
updating of the atom selection for a given rep. Automatic updating means the atom selection
for the rep will be recalculated every time the coordinate frame of the molecule changes.
get colorupdate(molid, rep):
set colorupdate(molid, rep, onoff): These two commands let you turn on/o auto-
matic updating of the color for a given rep. Automatic updating means the color for the rep
will be recalculated every time the coordinate frame of the molecule changes; this is useful
for coloring by Position or User.
get smoothing(molid, rep):
set smoothing(molid, rep, n): These two commands let you get/set on-the-y smooth-
ing of molecular representations. Atom coordinates used to draw the given rep will be
smoothed with a moving average window size of 2n 1.
get scaleminmax(molid, rep):
set scaleminmax(molid, rep, min, max):
reset scaleminmax(molid, rep): Get/set the color scale range for this rep. Normally the
color scale is automatically scaled to the minimum and maximum of the corresponding range
of data. This command overrides the autoscaled values with the values you specify. Omit
the min and max arguments to get the current values. Use reset scaleminax to rescale the
color scale to the maximum range again.
get visible(molid, rep):
set visible(molid, rep, onoff): These two commands let you show or hide a selected
molecular representation, and retrieve the visibility status of a given rep.
10.5.12 render
Python operations available from the render module, used to export the scene to a le that can be
read by external rendering programs.
listall(): Return a Python list of the names of all supported rendering methods. One of
these should be the rst argument to the render() operation below.
154
render(method, filename): Using the the given rendering method, export the current
scene to the le filename. method should be one of the values returned by listall().
10.5.13 trans
Python operations available from the trans module, used to change the view of the rendered scene.
rotate(axis, angle): Rotate the scene about the specied axis by the given angle. axis
should be x, y, or z; angle is measured in degrees.
translate(x, y, z): Translate the scene by the given x, y, and z values.
scale(factor): Scale (zoom) the scene by the given factor.
resetview(molid): Sets the center, scale, rotation for all molecules so that the viewpoint
is centered on the molecule with the given id.
get center(molid):
set center(molid, vector): Get/set the coordinates of the center of the given molecule
as a Python list.
get scale(molid):
set scale(molid,scale): Get/set the scale factor used to display the given molecule.
get rotation(molid):
set rotation(molid, matrix): Get/set the rotation matrix for the given molecule as a
16-element Python list in row-major order.
get trans(molid):
set trans(molid, vector): Get/set the global translation applied to the given molecule
as a Python list.
is fixed(molid): Returns whether the molecule with the given id is xed; that is, whether
it is aected by translation, rotation, or scaling. Fixed molecules may still be animated (see
is active in the animate section).
fix(molid, trueorfalse): Make the molecule with the given id xed or not.
is shown(molid): Returns whether the molecule with the given id is shown or not.
show(molid, trueorfalse): Make the molecule with the given id shown or not.
10.5.14 vmdnumpy
This optional module is made available from within the toplevel VMD module if VMD detects a
Numeric Python installation in the Python search path. When present, the following methods are
provided:
155
timestep(molid, frame): Returns a single-precision Numeric array containing a direct
reference to the given set of atom coordinates. Atom coordinates are arranged xyzxyzxyz...
for each atom in the molecule. No copy of VMDs internal coordinates is made; therefore,
modications to this array will directly aect atom coordinates in VMD. Using the array after
the timestep has been deleted will likely cause VMD to crash. The advantage is maximum
eciency and the ability to easily modify atom coordinates without going through the atom
selection interface.
atomselect(molid, frame, selection): Returns an array of ints representing ags for
on/o atoms in the given atom selection. The syntax for the selection is the same as for
the AtomSel class. An array of this form can be used in conjunction with the Numeric take
function to get selected coordinates from a timestep. Creating the array in this way can be
50-100 times faster than converting from an AtomSel object.
10.6 High-level Python Interface
VMD provides three modules for accessing and manipulating VMD state with objects that represent
important entities. These objects can be thought of as references for the actual object within VMD:
you can create as many references as you want and delete them, but modifying the reference changes
the actual state of VMD. This is dierent from the AtomSel class, where each AtomSel instance
is independent of the molecules and reps in VMD. These proxy classes are written in pure Python
and use the lower level built-in interfaces to communicate with VMD.
10.6.1 Molecule
The Molecule class is a proxy for molecules loaded into VMD. Most operations raise ValueError if
the proxy no longer refers to a valid molecule (i.e. if the molecule has been deleted).
Molecule instances provide the following methods:
init (id=None): Creating a new Molecule instance with no arguments will create a new
empty molecule in VMD. Passing a valid molecule id will make the Molecule instance mirror
the state of the corresponding molecule in VMD.
int (): Casting a Molecule to an int returns the molecule ID.
rename(self, newname): Changes the name of the molecule.
name(): Returns the name of the molecule.
delete(): Deletes the molecule corresponding to this Molecule instance. The object can no
longer be used.
load(filename, filetype=None, first=0, last=-1, step=1, waitfor=-1, volsets=[0]):
Load molecule data from the given le. The letype will be guessed from the lename ex-
tension; this can be overrideen by setting the letype option. first, last, and step control
which coordinates frames to load, if any. volsets indicates which volumetric data sets to
load from the le. Raises IOError if the le cannot be loaded.
156
save(filename, filetype=None, first=0, last=-1, step=1, waitfor=-1, sel=None):
Save timesteps to the given le. The letype will be guessed from the lename extension; this
can be overridden by setting the letype option. rst, last, and step control which timesteps
to save. Returns the number of frames written before the command completes. Pass an
AtomSel instance as sel to write only a selection of atoms to the le. Note that this diers
from the AtomSel.write() method in that Molecule.save() writes a range of timesteps,
while AtomSel.write() writes only the coordinates corresponding to the selections currently
selected frame.
files():
types(): Returns a list of lenames and le types, respectively, for the les that have been
loaded into this molecule.
numAtoms(): Returns the number of atoms in the molecule.
numFrames(): Returns the number of coordinate frames in the molecule.
setFrame(frame): Set the coordinate frame to the given value. Must be in the range [0,
numFrames())
curFrame(): Returns the current coordinate frame for the molecule.
delFrame(first=0, last=-1, step=1): Deletes the given range of frames.
dupFrame(frame = None): Duplicate the given frame, apending it to the end. if frame is
None then the current frame is used.
numReps(): Returns the number of molecular representations (reps) in the given molecule.
reps(): Returns a list of MoleculeRep objects, one for each rep in the molecule.
addRep(rep): Add the given MoleculeRep instance to the Molecule. Modications to the
rep will aect all Molecules to which the rep has been added. Raises ValueError if the rep
has already been added to this molecule.
delRep(rep): Removes the given MoleculeRep from the Molecule. The rep is not aected
and can be added to other molecules, but changes to it will no longer aect this Molecule.
clearReps(): Removes all reps from this molecule.
autoUpdate(rep, onoff = None): If onoff is not None, sets the auto-update status for
this rep and molecule (note that a reps auto-update status may be dierent for dierent
molecules). Returns the reps auto-update status.
ssRecalc(): Recalculate the secondary structure for this molecule.
Examples:
>>> from VMD import *
>>> from Molecule import *
>>> bR=Molecule()
>>> bR.load(../proteins/brH.pdb)
157
<snip>
<Molecule.Molecule instance at 0x406d878c>
>>> bR.name()
molecule
>>> bR.rename(bR)
<Molecule.Molecule instance at 0x406d878c>
>>> bR.name()
bR
>>> bR.numAtoms()
3762
>>> bR.dupFrame()
<Molecule.Molecule instance at 0x406d878c>
>>> bR.numFrames()
2
10.6.2 MoleculeRep
The MoleculeRep class, dened in the Molecule module, is designed to make it easy to keep track
of the reps in a molecule and to update reps in many molecules simultaneously. The way it
works is to create a MoleculeRep instance, then add it to as many molecules as you want using
the Molecule.addRep() method. The only operations on MoleculeRep objects is to change their
properties; when this occurs, all molecules to which the rep has been added will be updated.
Deleting a MoleculeRep instance has no eect. A list of MoleculeRep instances for a given molecule
can be gotten from the Molecule.reps() method.
The MoleculeRep class provides the following methods:
init (style=defStyle, color=defColor, selection=defSelection, material=defMaterial):
Initialize the Rep object with optional style, color, selection and material properties. MoleculeRep
objects also have attributes with the same names as the above keywords; these can be used
to query the state of the rep. Dont set these attributes directly; use the change* methods
below instead.
changeStyle(style):
changeColor(color):
changeSelection(selection):
changeMaterial(material): Set the draw style, color, atom selection and material for this
rep. If the rep is assigned to any molecules, the molecule rep will be updated accordingly.
style must be a valid draw style; see the *Style functions below.
In the following example, we load a molecule, add a new transparent VDW rep to the molecule,
then change the atom selection for the rep to name CA:
>>> from VMD import *
>>> from Molecule import *
>>> bR=Molecule()
>>> bR.load(../proteins/brH.pdb)
158
<snip>
>>> reps=bR.reps()
>>> reps[0].style
Lines
>>> vdw=MoleculeRep(style=VDW, material=Transparent)
>>> bR.addRep(vdw)
>>> vdw.changeSelection(name CA)
10.6.3 Draw Style Methods
The syntax for changing the draw style in the MoleculeRep.changeStyle() method is fairly simple
and easy to remember as long as the default values for each style are used; however, remembering
that rep.changeStyle("CPK 0.5 0.5 8") is the way to set the bond radius, sphere scale, and
sphere resolution for CPK is a little more dicult. The Molecule class denes a function for each
draw style to make it easier to generate the required strings to pass to the changeStyle methods.
Each function accepts keyword arguments for specifying the draw style parameters and returns a
string suitable for changeStyle().
10.6.4 Saving and Restoring Molecule State
Molecule and MoleculeRep instances can be saved used the pickle module from the Python stan-
dard library. Molecules will be saved with information about their name, les, and reps. The les
themselves are not saved with the molecule; they will be reloaded when the molecule instance is
recreated using pickle.load(). MoleculeRep instances can also be pickled; when restored they
will be unassigned to any Molecules.
159
Chapter 11
Vectors and Matrices
Tcl does not handle mathematical expressions very well. It is slow at evaluating expressions, and
provides no facility for handling vectors or matrices. Since the latter two are needed for structure
analysis, we have added routines to manipulate them.
A vector in VMD is a list of numbers. All of the vector routines but one will work with vectors
of any length; veccross will only use vectors of three numbers. A matrix is a 4x4 collection of
numbers stored as a list of 4 vectors of 4 numbers, in row-major form.
Following are descriptions and examples of all the commands. For more examples of vectors,
though without much documentation, the script used to test the vectors implementation is located
at $env(VMDDIR)/scripts/vmd/test-vectors.tcl.
Since Tcl is slow at math, some of these commands have been reimplemented in C++. (The
original denition is in the vmd script distribution, but it is redened later on inside VMD). At
times, the speedup is a factor of 40 or more. These commands are noted by (C++).
11.1 Vectors
veczero Returns the zero vector, 0 0 0
Example:
vmd > veczero
0 0 0
(C++) vecadd v1 v2 [v3 ... vn] Returns the vector sum of all the terms.
Examples:
vmd > vecadd {1 2 3} {4 5 6} {7 8 9} {-11 -11 -11}
1 4 7
vmd > vecadd {0.1 0.2 0.4 0.8} {1 1 2 3} {3 1 4 1}
4.1 2.2 6.4 4.8
vmd > vecadd 4 5
9
vecmul v1 v2 Returns the vector of a term-by-term multiply.
160
Examples:
vmd > vecmul {1 2 3} {4 5 6}
4 10 18
vmd > vecmul {0.1 0.2 0.4 0.8} {1 1 2 3}
0.1 0.2 0.8 2.4
(C++) vecsub v1 v2 Returns the vector subtraction of the second term from the rst
Examples:
vmd > vecsub 6 3.2
2.8
vmd > vecsub {10 9.8 7} {0.1 0 -0.1}
9.9 9.8 7.1
vmd > vecsub {1 2 3 4 5} {6 7 8 9 10}
-5 -5 -5 -5 -5
(C++) vecsum v Returns the sum of the elements in v
Examples:
vmd > vecsum { 1 2 3 }
6.0
(C++) vecmean v Returns the mean of the elements in v
Examples:
vmd > vecmean { 1 2 3 }
2.0
(C++) vecstddev v Returns the standard deviation of the elements in v
Examples:
vmd > vecstddev { 1 2 3 4 5 6 7 8 9 10 }
2.87228131294
(C++) vecscale c v
(C++) vecscale v c Returns the vector of the scalar value c applied to each term of v
Examples:
vmd > vecscale .2 {1 2 3}
0.2 0.4 0.6
vmd > vecscale {-5 4 -3 2} -2
10 -8 6 -4
vmd > vecscale -2 3
-6
vecdot v1 v2 Returns the scalar dot product of the two vectors
161
Examples:
vmd > vecdot {1 -2 3} {4 5 6}
12
vmd > vecdot {3 4} {3 4}
25
vmd > vecdot {1 2 3 4 5} {5 4 3 2 1}
35
vmd > vecdot 3 -2
-6
veccross v1 v2 Returns the vector cross product of the two vectors.
Examples:
vmd > veccross {1 0 0} {0 1 0}
0 0 1
vmd > veccross {2 2 2} {-1 0 0}
0 -2 2
veclength v Returns the scalar length of v (|v|)
Examples:
vmd> veclength 5
5.0
vmd > veclength {5 12}
13.0
vmd > veclength {3 4 12}
13.0
vmd > veclength {1 -2 3 -4}
5.47723
veclength2 v Returns the square of the scalar length of v (|v|
2
)
Examples:
vmd > veclength2 5
25
vmd > veclength2 {5 12}
169
vmd > veclength2 {3 4 12}
169
vmd > veclength2 {1 -2 3 -4}
30
vecnorm v Returns the vector of length 1 directed along v
Examples:
vmd > vecnorm -10
-1.0
162
vmd > vecnorm {1 1 }
0.707109 0.707109
vmd > vecnorm {2 -3 1}
0.534522 -0.801783 0.267261
vmd > vecnorm {2 2 -2 2 -2 -2}
0.408248 0.408248 -0.408248 0.408248 -0.408248 -0.408248
vecdist v1 v2 Returns the distance between the two vectors (|v
2
v
1
|)
Examples:
vmd > vecdist -1.5 5.5
7.0
vmd > vecdist {0 0 0} {3 4 0}
5.0
vmd > vecdist {0 1 2 3 4 5 6} {-6 -5 -4 -3 -2 -1 0}
15.8745
vecinvert v Returns the additive inverse of v (v).
Examples:
vmd > vecinvert -11.1
11.1
vmd > vecinvert {3 -4 5}
-3 4 -5
vmd > vecinvert {0 -1 2 -3}
0 1 -2 3
11.2 Matrix routines
Because matrices are rather large when expressed in text form, the following denitions are used
for the examples.
transidentity Returns the identity matrix.
Example:
vmd > transidentity
{1.0 0.0 0.0 0.0} {0.0 1.0 0.0 0.0} {0.0 0.0 1.0 0.0} {0.0 0.0 0.0 1.0}
transtranspose m Returns the matrix transpose of the given matrix
Example:
vmd > transtranspose {{0 1 2 3 4} {5 6 7 8} {9 10 11 12} {13 14 15 16}}
{0 5 9 13} {1 6 10 14} {2 7 11 15} {3 8 12 16}
(C++) transmult m1 m2 [m3 ... mn] Returns the matrix multiplication of the given
matrices
163
Examples:
vmd > set mat1 {{1 2 3 4} {-2 3 -4 5} {3 -4 5 -6} {4 5 -6 -7}}
vmd > set mat2 {{1 0 0 0} {0 0.7071 -0.7071 0} {0 0.7071 0.7071 0} {0 0 0 1}}
vmd > set mat3 {{0.866025 0 0 0} {0 1 0 0} {-0.5 0 0.866025 0} {0 0 0 1}}
vmd > transmult $mat1 [transidentity]
{1.0 2.0 3.0 4.0} {-2.0 3.0 -4.0 5.0} {3.0 -4.0 5.0 -6.0}
{4.0 5.0 -6.0 -7.0}
vmd > transmult $mat1 $mat2 $mat3
{0.512475 3.5355 0.612366 4.0} {0.7428 -0.7071 -4.28656 5.0}
{-0.58387 0.7071 5.5113 -6.0} {7.35315 -0.7071 -6.73603 -7.0}
transaxis <x|y|z> amount [deg|rad|pi] Returns the transformation matrix needed to
rotate around the specied axis by a given amount. By default, the amount is specied in
degrees, though it can also be given in radians or factors of pi.
Examples:
vmd > transaxis x 90
{1.0 0.0 0.0 0.0} {0.0 -3.67321e-06 -1.0 0.0} {0.0 1.0 -3.67321e-06 0.0}
{0.0 0.0 0.0 1.0}
vmd > transaxis y 0.25 pi
{0.707107 0.0 0.707107 0.0} {0.0 1.0 0.0 0.0}
{-0.707107 0.0 0.707107 0.0} {0.0 0.0 0.0 1.0}
vmd > transaxis z 3.1415927 rad
{-1.0 -2.65359e-06 0.0 0.0} {2.65359e-06 -1.0 0.0 0.0} {0.0 0.0 1.0 0.0}
{0.0 0.0 0.0 1.0}
transvec v Returns the transformation matrix needed to bring the x axis along the v
vector. This matrix is not unique, since a nal rotation is allowed around the vector. The
matrix is made from a rotation around y, then one about z.
Examples:
vmd > transvec {0 1 0}
{-3.67321e-06 -1.0 0.0 0.0} {1.0 -3.67321e-06 0.0 0.0} {0.0 0.0 1.0 0.0}
{0.0 0.0 0.0 1.0}
vmd > vectrans [transvec {0 0 2}] {1 0 0}
0.0 0.0 1.0
transvecinv v Returns the transformation needed to bring the vector v to the x axis. This
produces the inverse matrix to transvec, and is composed of a rotation about z then one about
y.
Examples:
vmd > transvecinv {0 -1 0}
{-3.67321e-06 -1.0 0.0 0.0} {1.0 -3.67321e-06 0.0 0.0} {0.0 0.0 1.0 0.0}
{0.0 0.0 0.0 1.0}
vmd > vectrans [transvecinv {-3 4 -12}] {-3 4 -12}
13.0 -1.8e-05 5.8e-05
164
vmd > transmult [transvec {6 -5 7}] [transvecinv {6 -5 7}]
{0.999999 2.29254e-07 -6.262e-09 0.0} {2.29254e-07 0.999999
-4.52228e-07 0.0} {-6.262e-09 -4.52228e-07 1.0 0.0} {0.0 0.0 0.0 1.0}
(C++) transoset v Returns the transformation matrix needed to translate by the given
oset
Examples:
vmd > transoffset {1 0 0}
{1.0 0.0 0.0 1} {0.0 1.0 0.0 0} {0.0 0.0 1.0 0} {0.0 0.0 0.0 1.0}
vmd > transoffset {-6 5 -4.3}
{1.0 0.0 0.0 -6} {0.0 1.0 0.0 5} {0.0 0.0 1.0 -4.3} {0.0 0.0 0.0 1.0}
transabout v amount [deg|rad|pi] Generates the transformation matrix needed to rotate
by the given amount counter-clockwise around axis which goes through the origin and along
the given vector. As with transvec, the units of the amount of rotation can be degrees,
radians, or multiples of pi.
Examples:
# this is a rotation about x by 180 degrees
vmd > transabout {1 0 0} 180
{1.0 0.0 0.0 0.0} {0.0 -1.0 -2.65359e-06 0.0} {0.0 2.65359e-06
-1.0 0.0} {0.0 0.0 0.0 1.0}
# a rotation about z by 90 degrees
# (compare this to "transaxis z 90"
vmd > transabout {0 0 1} 1.5709 rad
{0.999624 -0.027414 0.0 0.0} {0.027414 0.999624 0.0 0.0}
{0.0 0.0 1.0 0.0} {0.0 0.0 0.0 1.0}
vmd > transabout {1 1 1} 1 pi
{-0.333335 0.666665 0.666669 0.0} {0.666668 -0.333334 0.666666
0.0} {0.666666 0.66667 -0.333332 0.0} {0.0 0.0 0.0 1.0}
trans [center {x y z}] [origin {x y z}] [oset {x y z}] [axis x amount [rad|deg|pi]]
[axis y amount [rad|deg|pi]] [axis z amount [rad|deg|pi]] [x amount [rad|deg|pi]]
[y amount [rad|deg|pi]] [z amount [rad|deg|pi]] [axis {x y z} amount [rad|deg|pi]]
[bond {x1 y1 z1} {x2 y2 z2} amount [rad|deg|pi]] [angle {x1 y1 z1} {x2 y2 z2} {x3 y3
z3} amount [rad|deg|pi]]
This command can do almost everything the other ones can do, and then some. It is designed
to be the main function used for generating transformation matrices.
Using it correctly calls for understanding how it works internally. There are three matrices:
centering, rotation, and oset. The centering matrix determines where the center of rotation is
located. By default, this is the origin, but it can be changed to pivot about any point. The
rotation matrix denes the rotation about that centering point, and the oset matrix denes the
nal translation after the rotation.
For example, to rotate around a given point, the transformations would be 1) the centering
matrix to bring that point to the origin, 2) the rotation about the center, and 3) the nal oset to
return the origin back to its original location.
The dierent options for the trans command modify the matrices in various ways.
165
center {x y z} Sets the centering matrix so that point x y z is brought to the origin
oset {x y z} Sets the oset matrix so that the origin is brought to x y z
origin {x y z} Sets both the centering and oset matrices to x y z
axis x amount [rad|deg|pi] Adds a rotation about the x axis by the given amount to the
rotation matrix
axis y amount [rad|deg|pi] Adds a rotation about the y axis by the given amount to the
rotation matrix
axis z amount [rad|deg|pi] Adds a rotation about the z axis by the given amount to the
rotation matrix
axis {x y z} amount [rad|deg|pi] Adds a rotation of the given amount about the given
vector to the rotation matrix
bond {x1 y1 z1} {x2 y2 z2} amount [rad|deg|pi] Sets the center and oset transforma-
tions to the rst point, and denes a rotation about the bond axis by the given amount.
angle {x1 y1 z1} {x2 y2 z2} {x3 y3 z3} amount [rad|deg|pi] Sets the center and oset
transformation to the second point, and denes a rotation about the axis perpendicular to
the plane made by the three points (the vector is computed from the cross product of the
vector connecting the rst two points with that connected the last two).
11.3 Multiplying vectors and matrices
There are two commands to multiply a matrix and a vector, vectrans and coordtrans. They
assume the vector is in column form and premultiply the matrix to the vector. If the vector
contains four numbers, the two commands are identical. If the vector has three elements, a fourth
is added; a 0 for vectrans and a 1 for coordtrans. The dierence is that vectors are not aected
by translations during transformations, while coordinates are.
(C++) vectrans m v Multiple the matrix m with the vector v (length 4); returns a vector
coordtrans m v Multiple the matrix m with the coordinate v (length 3); returns a vector
Examples:
vmd > vectrans [transaxis z 90] {1 0 0}
-3.67321e-06 1.0 0.0
vmd > vectrans [transvecinv {-3 4 -12}] {-3 4 -12}
13.0 -1.8e-05 5.8e-05
11.4 Misc. functions and values
Several other terms are added to the vectors package. The rst is the variable M PI, which contains
the value of pi.
166
Examples:
vmd > set M_PI
3.14159265358979323846
vmd > expr 90 * ($M_PI / 180)
1.5708
The functions trans from rot, trans to rot, trans from offset, and trans to offset are
used to get or set a transformation matrix from either a 3x3 rotation matrix or oset vector. As
currently designed, these assume there is no scaling in the matrix. The trans from offset is
identical to transoffset and is present for completeness.
The last is find rotation value varname, which takes a variable name and extracts from
the beginning of it those terms which describe an amount of rotation. The rest of the data in
the variable remains, and the amount of rotation, in radians, is returned. This is used by those
functions which need a rotation. The valid values are: a number, followed by one of rad, radian,
or radians for a value in radians, the word pi to give the rotation in factors of pi, or one of deg,
degree, or degrees for a value in degrees. If no units are given, the value is assumed to be in
degrees.
Examples:
vmd > set a "180 deg north"
180 deg north
vmd > find_rotation_value a
3.14159
vmd > set a
north
vmd > set a "1 pi to eat"
1 pi to eat
vmd > find_rotation_value a
3.14159
vmd > set a
to eat
vmd > set a 45
45
vmd > find_rotation_value a
0.785398
vmd > expr $M_PI * 3.0 / 2.0
4.71239
vmd > set a "4.71238 radians"
4.71238 radians
vmd > find_rotation_value a
4.71238
167
Chapter 12
Molecular Analysis
12.1 Using the molinfo command
This section covers how to extract information about molecules and atoms using the VMD text
command molinfo.
Examples:
Two functions, one to save the current view position, the other to restore it. The position of
the axis is not changed by these operations.
proc save_viewpoint {} {
global viewpoints
if [info exists viewpoints] {unset viewpoints}
# get the current matricies
foreach mol [molinfo list] {
set viewpoints($mol) [molinfo $mol get {
center_matrix rotate_matrix scale_matrix global_matrix}]
}
}
proc restore_viewpoint {} {
global viewpoints
foreach mol [molinfo list] {
puts "Trying $mol"
if [info exists viewpoints($mol)] {
molinfo $mol set {center_matrix rotate_matrix scale_matrix
global_matrix} $viewpoints($mol)
}
}
}
Cycle through the list of displayed molecules, turning each one on one at a time. At the end,
return the display ags to their original state.
# save the current display state
foreach mol [molinfo list] {
set disp($mol) [molinfo $mol get drawn]
168
}
# turn everything off
mol off all
# turn each molecule on then off again
foreach mol [molinfo list] {
if $disp($mol) {
mol on $mol
sleep 1
mol off $mol
}
}
# turn the original ones back on
foreach mol [molinfo list] {
if $disp($mol) {mol on $mol }
}
The last loop, which turns the originally drawn molecules back on, doesnt turn them on at
the same time. Thats because some commands (those which use the command queue) redraw the
graphics when they are used. This can be disabled with the display update (see section 9.3.6 for
more information). Using this, the nal loop becomes
#turn the original ones back on
display update off
foreach mol [molinfo list] {
if $disp($mol) {mol on $mol }
}
display update on
Alternatively, since the drawn option is settable, you could do:
foreach mol [molinfo list] {
if $disp($mol) {molinfo $mol set drawn 1}
}
However, that wont set the ag to redraw the scene so you need to force a redraw with display
redraw.
12.2 Using the atomselect command
Atom selection is the primary method to access information about the atoms in a molecule. It
works in two steps. The rst step is to create a selection given the selection text, molecule id, and
optional frame number. This is done by a function called atomselect, which returns the name of
the new atom selection. the second step is to use the created selection to access the information
about the atoms in the selections.
Atom selection is implemented as a Tcl function. The data returned from atomselect is the
name of the function to use. The name is of the form atomselect%d where %d is a non-negative
number (such as atomselect0, atomselect26, ...).
The way to use the function created by the atomselect command is to store the name into a
variable, then use the variable to get the name when needed.
169
vmd> set sel [atomselect top "water"]
atomselect3
vmd> $sel text
water
This is equivalent to saying
vmd> atomselect3 text
The easiest way of thinking about this is that the atomselect command creates an object.
To get information from the object you have to send it a command. Thus, in the example above
(atomselect1 num) the object atomselect1 was sent the command num, which asks the object
to return the number of atoms in the selection. These derived object functions (the ones with
names like atomselect3) take many options, as described in section 9.3.2,
For instance, given the selection
vmd> set sel [atomselect top "resid 4"]
atomselect4
you can get the atom names for each of the atoms in the selection with
vmd> $sel get name
N H CA CB C O
(which, remember, is the same as
vmd> atomselect4 get name
)
Multiple attributes can be requested by submitting a list, so if you want to see which atoms are
on the backbone,
vmd> $sel get {name backbone}
{N 1} {H 0} {CA 1} {CB 0} {C 1} {O 1}
and the atom coordinates with
vmd> $sel get {x y z}
{0.710000 4.211000 1.093000} {-0.026000 3.700000 0.697000} {0.541000
4.841000 2.388000} {-0.809000 4.462000 2.976000} {1.591000 4.371000
3.381000} {2.212000 5.167000 4.085000}
Note that the format of the data you get back from the get command depends on how many
attributes you requested. If you request only one attribute, as in the get name example above, you
will get back a simple list of elements. On the other hand, if you request two or more attributes,
you will get back a list of sublists. Specically, it is a list of size n where each element is itself
a list of size i, where n is the number of atoms in the selection and i is the number of attributes
requested.
Your scripts will run faster if you retrieve only one attribute at a time, because then VMD
does not have to construct the sublists for each attribute. Remember that in Tcl you can loop over
several lists at once using the foreach command:
170
foreach resid [$sel get resid] resname [$sel get resname] {
# process each resid and resname here
}
One quick function you can build with the coordinates is a method to calculate the geometrical
center (not quite the center of mass; thats a bit harder). This also uses some of the vector
commands discussed in the section about vectors and matrices [11], but you should be able to
gure them out from context.
proc geom_center {selection} {
# set the geometrical center to 0
set gc [veczero]
# [$selection get {x y z}] returns a list of {x y z}
# values (one per atoms) so get each term one by one
foreach coord [$selection get {x y z}] {
# sum up the coordinates
set gc [vecadd $gc $coord]
}
# and scale by the inverse of the number of atoms
return [vecscale [expr 1.0 /[$selection num]] $gc]
}
With that dened you can say (assuming $sel was created with the previous atomselection
example)
vmd> geom_center $sel
0.703168 4.45868 2.43667
Ill go through the example line by line. The function is named geom center and takes one param-
eter, the name of the selection. The rst line sets the variable gc to the zero vector, which is 0 0
0. On the second line of code, two things occur. First, the command
$selection get {x y z}
is executed, and the string is replaced with the result, which is
{0.710000 4.211000 1.093000} {-0.026000 3.700000 0.697000} {0.541000
4.841000 2.388000} {-0.809000 4.462000 2.976000} {1.591000 4.371000
3.381000} {2.212000 5.167000 4.085000}
This is a list of 6 terms (one for each atom in the selection), and each term is a list of three elements,
the x, y, and z coordinate, in that order.
The foreach command splits the list into its six terms and goes down the list term by term,
setting the variable coord to each successive term. Inside the loop, the value of $coord is added
to total sum.
The last line returns the geometrical center of the atoms in the selection. Since the geometrical
center is dened as the sum of the coordinate vectors divided by the number of elements, and so
far I have only calculated the sum of vectors, I need the inverse of the number of elements, which
is done with the expression
expr 1.0 / [$selection num]
171
The decimal in 1.0 is important since otherwise Tcl does integer division. Finally, this value is
used to scale the sum of the coordinate vectors (with vecscale), which returns the new value, which
is itself returned as the result of the procedure.
The center of mass function is slightly harder because you have to get the mass as well as
the x, y, z values, then break that up into to components. The formula for the center of mass is
m
i
x
i
/
mass
i
proc center_of_mass {selection} {
# some error checking
if {[$selection num] <= 0} {
error "center_of_mass: needs a selection with atoms"
}
# set the center of mass to 0
set com [veczero]
# set the total mass to 0
set mass 0
# [$selection get {x y z}] returns the coordinates {x y z}
# [$selection get {mass}] returns the masses
# so the following says "for each pair of {coordinates} and masses,
# do the computation ..."
foreach coord [$selection get {x y z}] m [$selection get mass] {
# sum of the masses
set mass [expr $mass + $m]
# sum up the product of mass and coordinate
set com [vecadd $com [vecscale $m $coord]]
}
# and scale by the inverse of the number of atoms
if {$mass == 0} {
error "center_of_mass: total mass is zero"
}
# The "1.0" cant be "1", since otherwise integer division is done
return [vecscale [expr 1.0/$mass] $com]
}
vmd> center_of_mass $sel
Info) 0.912778 4.61792 2.78021
The opposite of get is set. Many keywords (most notably, x, y, and z) can be set to
new values. This allows, for instance, atom coordinates to be changed, the occupancy values to be
updated, or user forces to be added. You can also change the resname, segid, and so forth, which
may be easier to do within VMD than, for example, editing a PDB le by hand.
set sel [atomselect top "index 5"]
$sel get {x y z}
{1.450000 0.000000 0.000000}
$set set {x y z} {{1.6 0 0}}
172
Note that just as the get option returned a list of lists, the set option needs a list of lists, which
is why the extra set of curly braces were need. Again, this must be a list of size n containing
elements which are a list of size i. The exeception is if n is 1, the list is duplicated enough times
so there is one element for each atom.
# get two atoms and set their coordinates
set sel [atomselect top "index 6 7"]
$sel set {x y z} { {5 0 0} {7.6 5.4 3.2} }
In this case, the atom with index 6 gets its (x, y, z) values set to 5 0 0 and the atom with index
7 has its coordinates changed to 7.6 5.4 3.2.
It is possible to move atoms this way by getting the coordinates, changing them (say by adding
some oset) and replacing it. Following is a function which will do just that:
proc moveby {sel offset} {
foreach coord [$sel get {x y z}] {
lappend newcoords [vecadd $coord $offset]
}
$sel set {x y z} $newcoords
}
And to use this function (in this case, to apply an oset of (x y z) = (0.1 -2.8 9) to the selection
$movesel):
moveby $movesel {0.1 -2.8 9}
However, to simplify matters some options have been added to the selection to deal with movements
(these commands are also implemented in C++ and are much faster than the Tcl versions). These
functions are moveby, moveto, and move. The rst two take a position vector and the last takes a
transformation matrix.
The rst command, moveby, moves each of the atoms in the selection over by the given vector
oset.
$sel moveby {1 -1 3.4}
The second, moveto, moves all the atoms in a selection to a given coordinate (it would be strange
to use this for a selection of more than one atom, but thats allowed). Example:
$sel moveto {-1 1 4.3}
The last of those, move, applies the given transformation matrix to each of the atom coordinates.
This is best used for rotating a set of atoms around a given axis, as in
$sel move [trans x 90]
which rotates the selection 90 degrees about the x axis. Of course, any transformation matrix may
be used.
A more useful example is the following, which rotates the side chain atoms around the CA-CB
bond by 10 degrees.
173
# get the sidechain atoms (CB and onwards)
set sidechain [atomselect top "sidechain residue 22"]
# get the CA coordinates -- could do next two on one line ...
set CA [atomselect top "name CA and residue 22"]
set CAcoord [lindex [$CA get {x y z}] 0]
# and get the CB coordinates
set CB [atomselect top "name CB and residue 22"]
set CBcoord [lindex [$CB get {x y z}] 0]
# apply a transform of 10 degrees about the given bond axis
$sidechain move [trans bond $CAcoord $CBcoord 10 deg]
12.3 Analysis scripts
Following are some more examples of routines that could be used for analysing molecules. These are
not the best routines to use since many of these can be implemented with the measure command,
which calls a much faster built-in function.
Finding waters near a protein This example nds the waters near the protein for each frame
of a trajectory and writes out a PDB le containing those waters:
set sel [atomselect top "water and same residue as (within 2 of protein)"]
set n [molinfo top get numframes]
for { set i 0 } { $i < $n } { incr i } {
$sel frame $i
$sel update
$sel writepdb water_$i.pdb
}
The frame option sets the frame of the selection, update tells the atom selection to recompute
which waters are near the protein, and writepdb writes the selected waters to a le.
Total mass of a selection
proc total_mass {selection} {
set sum 0
foreach mass [$selection get mass] {
set sum [expr {$sum + $mass}]
}
return $sum
}
Note the curly braces after the expr command in the above example. Omitting those braces causes
this script to run about three times slower! The moral of the story is: always put curly braces
around the expression that you pass to expr.
Heres another (slightly slower) way to do the same thing. This works because the mass returned
from the selection is a list of lists. Putting it inside the quotes of the eval makes it a sequence of
vectors, so the vecadd command will work on it.
174
proc total_mass1 {selection} {
set mass [$selection get mass]
eval "vecadd $mass"
}
Coordinate min and max Find the min and max coordinate values of a given molecule in the
x, y, and z directions (see also the measure command minmax). The function takes the molecule
id and returns two vectors; the rst contains the min values and the second contains the max.
proc minmax {molid} {
set sel [atomselect top all]
set sx [$sel get x]
set sy [$sel get y]
set sz [$sel get z]
set minx [lindex $sx 0]
set miny [lindex $sy 0]
set minz [lindex $sz 0]
set maxx $minx
set maxy $miny
set maxz $minz
foreach x $sx y $sy z $sz {
if {$x < $minx} {set minx $x} else {if {$x > $maxx} {set maxx $x}}
if {$y < $miny} {set miny $y} else {if {$y > $maxy} {set maxy $y}}
if {$z < $minz} {set minz $z} else {if {$z > $maxz} {set maxz $z}}
}
return [list [list $minx $miny $minz] [list $maxx $maxy $maxz]]
}
Radius of gyration Compute the radius of gyration for a selection (see also measure rgyr). The
square of the radius of gyration is dened as
i
m
i
(r
i
r
c
)
2
/
i
m
i
. This uses the center of mass
function dened earlier in this chapter; a faster version would replace that with measure center.
Note that the measure rgyr command does the same thing as this script, only much much faster.
proc gyr_radius {sel} {
# make sure this is a proper selection and has atoms
if {[$sel num] <= 0} {
error "gyr_radius: must have at least one atom in selection"
}
# gyration is sqrt( sum((r(i) - r(center_of_mass))^2) / N)
set com [center_of_mass $sel]
set sum 0
foreach coord [$sel get {x y z}] {
set sum [vecadd $sum [veclength2 [vecsub $coord $com]]]
}
return [expr sqrt($sum / ([$sel num] + 0.0))]
}
175
Applying this to the alanin.pdb coordinate le
vmd > mol new alanin.pdb
vmd > set sel [atomselect top all]
vmd > gyr_radius $sel
Info) 5.45443
Root mean square deviation Compute the rms dierence of a selection between two frames
of a trajectory. This takes a selection and the values of the two frames to compare.
proc frame_rmsd {selection frame1 frame2} {
set mol [$selection molindex]
# check the range
set num [molinfo $mol get numframes]
if {$frame1 < 0 || $frame1 >= $num || $frame2 < 0 || $frame2 >= $num} {
error "frame_rmsd: frame number out of range"
}
# get the first coordinate set
set sel1 [atomselect $mol [$selection text] frame $frame1]
set coords1 [$sel1 get {x y z}]
# get the second coordinate set
set sel2 [atomselect $mol [$selection text] frame $frame2]
set coords2 [$sel2 get {x y z}]
# and compute the rmsd values
set rmsd 0
foreach coord1 $coords1 coord2 $coords2 {
set rmsd [expr $rmsd + [veclength2 [vecsub $coord2 $coord1]]]
}
# divide by the number of atoms and return the result
return [expr $rmsd / ([$selection num] + 0.0)]
}
The following uses the frame rmsd function to list the rmsd of the molecule over the whole
trajectory, as compared to the rst frame.
vmd > mol new alanin.psf
vmd > mol addfile alanin.dcd
vmd > set sel [atomselect top all]
vmd > for {set i 0} {$i < [molinfo top get numframes]} {incr i} {
? puts [list $i [frame_rmsd $sel $i 0]]
? }
0 0.0
1 0.100078
2 0.291405
3 0.523673
....
97 20.0095
98 21.0495
99 21.5747
176
The last example shows how to set the beta eld. This is useful because one of the coloring
methods is Beta, which uses the beta values to color the molecule according to the current color
scale. (This can also be done with the occupancy eld.) Thus redening the beta values allows you
to color the molecules based on your own denition. One useful example is to color the molecule
based on the distance from a specic point (for this case, coloring a poliovirus protomer based on
its distance to the center of the virus (0, 0, 0) helps bring out the surface features).
proc betacolor_distance {sel point} {
# get the coordinates
foreach coord [$sel get {x y z}] {
# get the distance and put it in the "newbeta" list
set dist [veclength2 [vecsub $coord $point]]
lappend newbeta $dist
}
# set the beta term
$sel set beta $newbeta
}
And heres one way to use it:
# load pdb2plv.ent using anonymous ftp to the PDB
vmd > mol new 2plv
vmd > set sel [atomselect top all]
vmd > betacolor_distance $sel {0 0 0}
Then go to the graphics menu and set the Coloring Method to Beta.
12.4 RMS Fit and Alignment
When one has two similar structures, one often wants to compare them. Whats the dierence
between two X-ray structures? How much did the structure change during a simulation? To
answer these questions, you must rst gure out how to compare two structures, which usually
means that you must nd the root mean square deviation (RMSD).
Formally, given N atom positions from structure x and the corresponding N atoms from struc-
ture y with a weighting factor w(i), the RMSD is dened as:
RMSD(N; x, y) =
N
i=1
w
i
x
i
y
i
2
N
N
i=1
w
i
1
2
Using this equation by itself probably wont give you the answer you are looking for. Imagine
two identical structures oset by some distance. The RMSD should be 0, but the oset prevents
that from happening. What you really want is the minimum RMSD between two given structures;
the best t. There are many ways to do this, but for VMD we have implemented the method of
Kabsch (Acta Cryst. (1978) A34, 827-828 or see le Measure.C in the VMD source code). This
algorithm computes the transformation, needed to move one structure onto another in order to
minimize the RMSD.
With the mathematical prerequisites behind us, we still need to be able to specify how to choose
the atoms to compare. If you want to compare all the atoms in both structures, and they both
177
have the same number of atoms, then the problem is easy N is everything. This occurs most
often in MD simulations when the only thing dierent between two structures are the coordinates.
But what about homologous sequences? In this case, the number of atoms dier because
while the number of residues is the same, the sidechains have dierent numbers of atoms. The
usual solution is to determine the RMSD based solely on the backbone atoms or, in some X-ray
structures where only the C