gmx select -f *.xtc -s *.tpr -os size.xvg -oi index.dat -select 'group X and within 0.5 of group Y'
It dynamically selects atoms in group X within 0.5 nm of group Y. In your case, group X = water molecules or water oxygen atoms more specifically, group Y = two residues (for example residue 1 2). Then the following command will work.
gmx select -f *.xtc -s *.tpr -os size.xvg -oi index.dat -select 'name OW and within 0.5 of (residue 1 2)'
The number of OW atoms is saved in size.xvg. The list of the selected OW atoms is saved in index.dat.
Cong Guo ..Madam thanks a lot for your quick and prompt reply. I have tried with the following command its shows following error..How can I do selection..?
With the selection ‘residue 263 & chain B && residue 366 & chain C’, NO atoms are selected.
First, '&&' should be 'or'.
Second, the keyword 'residue' is different from 'resid’. If there are N residues in your system , residue ranges from 0 to N-1. I guess you want to select the 263rd residue in chain B and the 366th residue in chain C. Assume their correct residue indexes are i and j. The right selection sentence should be 'name OW and within 0.5 of (residue i j)'.
@Cong Guo Hello, I tried your method for my system but i am not getting the correct numbers. I am currently trying to count the number of ions between two groups. Each group has 16 atoms which i grouped under one name. I used the following command but the numbers i am getting is way above what i visualized in VMD gmx select -f md.xtc -s md.tpr -os Ca.xvg -oi index.dat -select 'name Ca and within 1 of (resname 1 2)'
where 1 and 2 are the two groups and Ca is the ion between these two.