From: Axel Kohlmeyer (
Date: Mon Oct 19 2015 - 15:51:23 CDT

On Mon, Oct 19, 2015 at 4:05 PM, Daniela Rivas <>

> Hi,
> I have a trajectory file and I would like to plot the number of water
> molecules within a distance from a residue in time. I've been trying to
> figure out how to do it but I couldn't find anything.

​you may not find a tool that is ready to do exactly that, but all the
pieces should be available and it is just a matter of connecting them.
this definitely will require some Tcl scripting, so you should familiarize
yourself with Tcl script programming in general and how to use it in VMD.
then go over the corresponding section in the VMD user's guide and study
some of the provided examples.

what you basically need to do is:

- define a selection for your case with the atom select command and assign
the resulting identifier to a variable
- open a file for your plot or an empty list
- program a loop over all frams of your simulation​
- inside the loop update the selection and then output the frame number and
the number of atoms in the selection. you want to restrict your selection
to only include the water oxygens and use "exwithin" instead of "within" to
not count the atoms of the residue in question.
- add the frame number and the relevant number of atoms from the selection
to the file (or the list)
- close the file and plot it with a suitable program, or use the multiplot
plugin of VMD to plot the graph.


> I hope you can help me.
> Thanks,
> Daniela.

Dr. Axel Kohlmeyer
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.