4 * This source code is part of
8 * GROningen MAchine for Chemical Simulations
12 * Copyright (c) 1991-1999
13 * BIOSON Research Institute, Dept. of Biophysical Chemistry
14 * University of Groningen, The Netherlands
17 * GROMACS: A message-passing parallel molecular dynamics implementation
18 * H.J.C. Berendsen, D. van der Spoel and R. van Drunen
19 * Comp. Phys. Comm. 91, 43-56 (1995)
21 * Also check out our WWW page:
22 * http://md.chem.rug.nl/~gmx
27 * GRowing Old MAkes el Chrono Sweat
29 static char *SRCID_xlate_c
= "$Id$";
46 static t_xlate_atom
*get_xlatoms(int *nxlatom
)
48 static char *xlfile
="xlateat.dat";
50 t_xlate_atom
*xl
=NULL
;
51 char rbuf
[32],abuf
[32],repbuf
[32];
55 nlines
= get_lines(xlfile
,&lines
);
60 for(i
=0; (i
<nlines
); i
++) {
61 if (sscanf(lines
[i
],"%s%s%s",rbuf
,abuf
,repbuf
) != 3)
62 fprintf(stderr
,"Invalid line '%s' in %s\n",lines
[i
],xlfile
);
64 /* Use wildcards... */
65 if (strcmp(rbuf
,"*") != 0)
66 xl
[n
].res
= strdup(rbuf
);
70 /* Replace underscores in the string by spaces */
71 while ((_ptr
= strchr(abuf
,'_')) != 0)
74 xl
[n
].atom
= strdup(abuf
);
75 xl
[n
].replace
= strdup(repbuf
);
82 fprintf(stderr
,"%d out of %d lines of %s converted succesfully\n",
90 void rename_atoms(t_atoms
*atoms
)
98 xlatom
= get_xlatoms(&nxlate
);
100 open_symtab(&symtab
);
102 for(a
=0; (a
<atoms
->nr
); a
++) {
103 res
=*atoms
->resname
[atoms
->atom
[a
].resnr
];
104 atom
=atoms
->atomname
[a
];
105 if (isdigit(*atom
[0])) {
107 for (i
=0; (i
<strlen(*atom
)-1); i
++)
109 srenew(*atom
,strlen(*atom
)+2);
113 for(i
=0; (i
<nxlate
) && !bRenamed
; i
++) {
114 if ((xlatom
[i
].res
== NULL
) || (strcasecmp(res
,xlatom
[i
].res
) == 0) ||
115 ((strcasecmp("protein",xlatom
[i
].res
) == 0) && is_protein(res
)))
116 if (strcasecmp(*atom
,xlatom
[i
].atom
) == 0) {
117 /* don't free the old atomname, since it might be in the symtab */
118 atoms
->atomname
[a
]=put_symtab(&symtab
,xlatom
[i
].replace
);
123 close_symtab(&symtab
);
124 free_symtab(&symtab
);
125 for(i
=0; i
<nxlate
; i
++) {
126 sfree(xlatom
[i
].res
);
127 sfree(xlatom
[i
].atom
);
128 sfree(xlatom
[i
].replace
);