Most VMD functions can be accessed through text commands implemented in Tcl and Python. This allows scripts to be written which can load molecules, make movies, or run entire demos automatically. These scripts can include control loops, variable substitution, if-then-else constructs, function and procedure definitions, and many other features.

The scripts provided here are relatively simple examples of what can be done using the scripting interfaces in VMD. As such, most of these scripts perform a very specific task, and would need to be modified for more general-purpose use, though some of them may serve your needs as-is.

If you would like to learn more about these scripts, you can read the Tcl and Python scripting sections in the VMD User's Guide and consult Tcl and Python references.

Python VMD scripts

  • fit_angle — finds the angle between the best-fit line through two selections or a given vector
  • reswin — sequence selection and coloring script
  • selpath — draws a trace through the average position of an atom selection over a trajectory

Tcl VMD scripts

Structure building scripts

  • mergemultiframepdb — Merge large multi-frame virus capsid structures into a single structure using the psfgen plugin
  • mutate_res — Mutate a residue
  • splitmultiframepdb — Split multi-frame NMR structures into separate molecules and load them into VMD.
  • mergepdbs — Merge several PDB files together into a single structure using the psfgen plugin
  • mono2poly — Build complete biological unit from PDB BIOMT records

Analysis scripts

  • bigdcd — Analyze large Charmm/X-PLOR/NAMD "DCD" trajectories
  • ca-dist — Given a selection, plot the CA-CA distance
  • ColorCoord — set residue user field according to number of hbonds formed with neighbors
  • HOLE — a script for running the HOLE program written by Oliver Smart
  • metal_environment — Finds the propensity of residues near given ions
  • stride_workaround — Works around a limitation in STRIDE, allowing determination of secondary structure of proteins in very large structures
  • trajectory_path — Draws the path of the center of mass of a selection through an animation
  • frame_rmsd — computes rmsd between two frames of a trajectory
  • geometry — measure various molecular geometry
  • difference_matrix — makes a matrix of center of mass distances between residues of two proteins
  • total_mass — returns the total mass of a selected molecule
  • get_total_charge — returns the total charge of a selected molecule
  • residmap — converts resids between different numbering schemes
  • orient — align molecules to their principal axes

Trajectory processing scripts

  • animatepdbs — Load a consecutively numbered sequence of PDB files as a trajectory animation
  • bridging_waters — Example of how to display a selection that changes over an animation
  • fitframes — fits a selection to all frames in a trajectory
  • morph — generates an interpolated animation between two given frames
  • parallel-analysis — examples of parallel Timeline analysis scripts, using the MPI features of VMD
  • PBCTools — Set up and display periodic boundary conditions.
  • PBCWrap — Wrap atoms of selection $sel around PBC unit cell boundaries, requires pbctools script.
  • pdbbfactor — Load a multi-frame PDB file's B-Factor values into the User data attribute as a trajectory
  • rmsd_matrix — calculates a matrix of rmsds between the frames in a trajectory
  • sscache — Automatically stores secondary structure information for animations
  • trajectory_analyze — An example of an efficient way to analyze large trajectories within VMD while they load.
  • trajectory_path — Draws the path of the center of mass of a selection through an animation
  • trajectory_smooth — Computes average position for the atoms in a sliding window of N frames, so one can see net movements of residues and eliminate thermal noise.

File conversion scripts

  • top2psf — Convert Gromacs topology files to CHARMM PSF format

Collaboration and BioCoRE related scripts

  • vmdcollab — Connect two or more VMD sessions together in an interactive collaborative session.

User-customization scripts

  • vmd_use_pdb_ss — Build secondary structure from information in a PDB record, rather than from STRIDE
  • save_restore_viewpoint — Allows you to save or load particularly good viewing points

Demo and presentation scripts

  • dnademos — VMD DNA demos, lac repressor, sophisticated Tk controls over VMD processes
  • vmd_kiosk — VMD kiosk demo script

User-defined graphics scripts

  • blink — blink a selected representation
  • box_molecule — Frames a molecule with a box
  • colordisplacement — Color structures by displacement
  • Swing — Animation using the "draw" commands
  • 2dgraph — A good example of how to graph a quantity in VMD, in this case a one variable function
  • 3dgraph — Uses VMD graphics features to plot the surface of a two variable function
  • 3dparplot — An example of how to plot parametric surfaces of two variables in VMD
  • color_scale_bar — draws a color bar on the screen to show all of the current colors
  • eye_line — Draws a cylinder from the picked atom through the eye
  • delaunay_triangulate — calculate various types of molecular surfaces using delaunay triangulation
  • graphicspick — Example use of user-defined graphics picking callback
  • pbcbox — Draws the periodic simulation box
  • spring — Draws a spring from a picked atom outward toward the eye
  • dials — Draws dials which indicate the amount of time which has passed when playing back a simulation or the amount of force being applied to a certain part of the system
  • highlight_bases — Draws small slabs at the locations of DNA bases for emphasis
  • mk3drama — Creates a nice color coded 3d-ramachandran histogram graph
  • rotate_display — Rotates the display around the molecule, rather than altering the coordinates as is usually done.

Interactive scripts based on picking, mouse clicks, etc

  • eye_line — Draws a cylinder from the picked atom through the eye
  • pickbond — Allows the user to interactively add or delete bonds using the mouse

Movie making scripts

  • animated_gif — A good example of how to directly make animated gifs for WWW pages. Uses rotation of a molecule as an example
  • roll - Rolls the display in a lemniscape pattern on two axes, a very nice alternative to rotations and single-axis rocking.
  • rotation_movie — Writes out a series of screen shots corresponding to stages in a rotation
  • trajectory_movie_short — Writes out screen shots corresponding to frames of an animation
  • trajectory_movie — Again writes out screen shots corresponding to frames of an animation, but provides more options than trajectory_movie_short
  • take_picture — A flexible procedure to capture, render, and manage multiple screen shots.
  • view_change_render — Five procedures to save, restore, and smoothly animate VMD's camera/eye position by interpolating between them, optionally rendering to image files to create movies.

Sequence display scripts

  • reswin — Browse sequence, highlight and color structure by sequence selections

Scripts for displaying volumetric data, Electron density maps, etc

  • potsel — gets electrostatic grid via Delphi for VMD
  • potsurf — uses Delphi to show electrostatic potential on a molecular surface
  • readedm — read X-PLOR ASCII Electron Density Map files
  • readcube — read Gaussian ASCII "cube" files

Web-based VMD scripts

  • webvmd — Example scripts for controlling VMD from within a web browser
  • sandbox — A safe VMD "sandbox" for execution of untrusted VMD scripts

Submitting a script

If you have a useful or interesting script to contribute, please contact <>, which will be answered by one of the VMD maintainers. When you submit a script, fill in all the information given above (if appropritate). If you want, you may add more headers. We will go over the script and make sure it works properly. We have final say on adding a script. Unless otherwise agreed, any submitted script must follow the standard VMD script library redistribution policy.

VMD script library redistribution policy

Scripts in the library are freely available for anyone to use and modify but may not be sold. They are distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Should the software prove defective YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.