Fixed bug 553 by checking whether an atom name is longer than 2 characters
authorDavid van der Spoel <spoel@xray.bmc.uu.se>
Tue, 14 Sep 2010 07:04:25 +0000 (09:04 +0200)
committerDavid van der Spoel <spoel@xray.bmc.uu.se>
Tue, 14 Sep 2010 07:04:25 +0000 (09:04 +0200)
and has a digit in the third character. In that case the name is expected
to be protein. However, in this case e.g. Si12 will be designated as Sulphur.
The alternative would be to check whether the present residue is an amino acid
but that may be problematic as well.

src/gmxlib/pdbio.c

index 40ce78420c3edd2085c52da62acb2553935fc932..33342dd1b5c1328dce2a30b56714d45b5f4f2777 100644 (file)
@@ -436,7 +436,7 @@ static void read_anisou(char line[],int natom,t_atoms *atoms)
 
 void get_pdb_atomnumber(t_atoms *atoms,gmx_atomprop_t aps)
 {
-  int  i,atomnumber;
+  int  i,atomnumber,len;
   size_t k;
   char anm[6],anm_copy[6];
   char nc='\0';
@@ -448,8 +448,9 @@ void get_pdb_atomnumber(t_atoms *atoms,gmx_atomprop_t aps)
   for(i=0; (i<atoms->nr); i++) {
     strcpy(anm,atoms->pdbinfo[i].atomnm);
     strcpy(anm_copy,atoms->pdbinfo[i].atomnm);
+    len = strlen(anm);
     atomnumber = NOTSET;
-    if (anm[0] != ' ') {
+    if ((anm[0] != ' ') && ((len <=2) || ((len > 2) && !isdigit(anm[2])))) {
       anm_copy[2] = nc;
       if (gmx_atomprop_query(aps,epropElement,"???",anm_copy,&eval))
        atomnumber = gmx_nint(eval);