From: Josh Vermaas (
Date: Mon Oct 13 2014 - 09:15:38 CDT

Hi James,

Its certainly possible, but you are going to need to make some choices
and write the scripts yourself. Doing something automatically at startup
means you'd put a set of commands into your vmdrc file or the script you
load your trajectories with (see this section of the user guide: It also
sounds like you want to have labels pop up as the simulation progresses.
This is possible with Tcl callbacks
(, but I
think its simpler to start working on part B first, and get the data
first before trying to make it pretty for visualization purposes.

The basic structure of any analysis script is to loop over the frames
loaded into VMD and compute something. Here is roughly how I'd do it:
set sel1 [atomselect top "protein"]
set sel2 [atomselect top "some atomselection text that gets the surface"]
#Go over the trajectory.
for { set i 0 } { $i < [molinfo top getframes] } { incr i } {
     $sel1 frame $i
     $sel2 frame $i
     set idxs [measure contacts 3.0 $sel1 $sel2] ;# See for the
measure contacts routine
     set sel [atomselect top "index $idxs"]
     set residuelist [lsort -unique $sel get residue]
     $sel delete
     set sel [atomselect top "name CA and residue $residuelist"]
     foreach resname [$sel get resname] resid [$sel get resid] {
         puts "$resname $resid contacts the surface at frame $i"
     $sel delete

I'll leave it up to you how you want to handle checking for the "first"
contact. I generally keep a dictionary around
(, where the keys are the
residue and the value is the frame, and only add to the dictionary if
the key doesn't exist.

-Josh Vermaas

On 10/12/2014 10:04 PM, James Lord wrote:
> Dear VMD users,
> I am looking at protein adsorption onto a surface and I want VMD to
> display the residues name that come into contact with surface
> automatically when I load the trajectory file and as the simulation
> movie plays. My questions are
> A) Is it possible?? If yes how? Can anyone tell me step by step
> procedure?
> B) Is there any script available so that in VMD while movie is playing
> and the protein is coming into contact with surface it saves residues
> name, number and the time (frame number) that they come into contact
> with surface on a text file?
> Any comment is appreciated
> Cheers
> James