From: Joshua Adelman (
Date: Mon Nov 08 2010 - 15:26:02 CST

Hi Aneesh,

This involves a little Tcl scripting, but isn't too difficult. Start with an atomselect:
set sel [atomselect top "water within 5 of <whatever group of DNA atoms you're interested in>"]

Then the following is the core code in the loop over the trajectory frames:

$sel frame $frame
$sel update
set a [lsort -unique [$sel get resid]]
llength $a

This assumes that every water is assigned a unique resid. This should be pretty easy to modify if you want to do slightly different counting tasks as long as you understand a bit of Tcl and the atomselection command. You'll have to fill in the code necessary to loop over frames and then store/output the counts, but hopefully this will get you started. Everything else should be straightforward assuming you have a look at the VMD manual and various tutorials.

Best wishes,

On Nov 8, 2010, at 8:06 AM, aneesh cna wrote:

> Dear VMD users,
> My simulation system contains DNA in a box of water. I would like to count the number of water molecules within 5 angstrom around DNA ( or specific atoms of DNA) over the trajectories. Can anyone help me with a script to do this in VMD?
> Thanks in advance
> Sincerely
> Aneesh