[gmx-users] make_ndx: atomname selection
Javier Cerezo
jcb1 at um.es
Tue Apr 24 20:52:36 CEST 2012
Hi all
I'd like to do a selection of atom names such as:
a C1 C3 C2 C4
to get an index file with 4 atoms (no other matches in the file) and
then use it with g_angle to calculate the dihedral. The problem is that
make_ndx does not keep the order of atoms in the resulting index file as
they are added interactively to make_ndx, thus leading to a wrong
dihedral calculation if the order of the atoms selected in not the same
as that in the structure.
I don't know if this can be a trouble for someone else or if there is
any workaround. Actually, make_ndx does not say anything whether it keep
the order or not, so I would not call it a bug. Anyway, if there is not
such a workarouund, that might be changed in the code if anything else
is affected. The required change is in make_ndx.c at select_atomnames
function (l. 497). Here you have a working modification:
static int select_atomnames(t_atoms *atoms,int n_names,char **names,
atom_id *nr,atom_id *index,gmx_bool bType)
{
char *name;
int j, counter;
atom_id i;
counter=0;
for(i=0; i<atoms->nr; i++) {
if (bType)
name=*(atoms->atomtype[i]);
else
name=*(atoms->atomname[i]);
j=0;
while (j<n_names && !comp_name(name,names[j]))
j++;
if (j<n_names) {
*nr=j;
index[*nr]=i;
counter++;
}
}
*nr=counter;
printf("Found %u atoms with %s%s",
*nr,bType ? "type" : "name",(n_names==1)?"":"s");
for(j=0; (j<n_names); j++)
printf(" %s",names[j]);
printf("\n");
return *nr;
}
--
Javier CEREZO BASTIDA
PhD Student
Physical Chemistry
Universidad de Murcia
Murcia (Spain)
Tel: (+34)868887434
More information about the gromacs.org_gmx-users
mailing list