#include "hackblock.h"
-typedef struct {
- char *filebase;
- char *res;
- char *atom;
- char *replace;
+typedef struct
+{
+ char* filebase;
+ char* res;
+ char* atom;
+ char* replace;
} t_xlate_atom;
-static void get_xlatoms(const std::string &filename, FILE *fp,
- int *nptr, t_xlate_atom **xlptr)
+static void get_xlatoms(const std::string& filename, FILE* fp, int* nptr, t_xlate_atom** xlptr)
{
char filebase[STRLEN];
char line[STRLEN];
char abuf[1024], rbuf[1024], repbuf[1024], dumbuf[1024];
- char *_ptr;
+ char* _ptr;
int n, na, idum;
- t_xlate_atom *xl;
+ t_xlate_atom* xl;
fflib_filename_base(filename.c_str(), filebase, STRLEN);
}
if (na != 3)
{
- gmx_fatal(FARGS, "Expected a residue name and two atom names in file '%s', not '%s'", filename.c_str(), line);
+ gmx_fatal(FARGS, "Expected a residue name and two atom names in file '%s', not '%s'",
+ filename.c_str(), line);
}
- srenew(xl, n+1);
+ srenew(xl, n + 1);
xl[n].filebase = gmx_strdup(filebase);
/* Use wildcards... */
*xlptr = xl;
}
-static void done_xlatom(int nxlate, t_xlate_atom *xlatom)
+static void done_xlatom(int nxlate, t_xlate_atom* xlatom)
{
int i;
sfree(xlatom);
}
-void rename_atoms(const char* xlfile, const char *ffdir,
- t_atoms *atoms, t_symtab *symtab, gmx::ArrayRef<const PreprocessResidue> localPpResidue,
- bool bResname, ResidueType *rt, bool bReorderNum,
- bool bVerbose)
+void rename_atoms(const char* xlfile,
+ const char* ffdir,
+ t_atoms* atoms,
+ t_symtab* symtab,
+ gmx::ArrayRef<const PreprocessResidue> localPpResidue,
+ bool bResname,
+ ResidueType* rt,
+ bool bReorderNum,
+ bool bVerbose)
{
int nxlate, a, i, resind;
- t_xlate_atom *xlatom;
+ t_xlate_atom* xlatom;
char c, *rnm, atombuf[32];
bool bReorderedNum, bRenamed, bMatch;
bool bStartTerm, bEndTerm;
else
{
std::vector<std::string> fns = fflib_search_file_end(ffdir, ".arn", FALSE);
- for (const auto &filename : fns)
+ for (const auto& filename : fns)
{
- FILE * fp = fflib_open(filename);
+ FILE* fp = fflib_open(filename);
get_xlatoms(filename, fp, &nxlate, &xlatom);
gmx_ffclose(fp);
}
{
resind = atoms->atom[a].resind;
- bStartTerm = (resind == 0) || atoms->resinfo[resind].chainnum != atoms->resinfo[resind-1].chainnum;
- bEndTerm = (resind >= atoms->nres-1) || atoms->resinfo[resind].chainnum != atoms->resinfo[resind+1].chainnum;
+ bStartTerm = (resind == 0) || atoms->resinfo[resind].chainnum != atoms->resinfo[resind - 1].chainnum;
+ bEndTerm = (resind >= atoms->nres - 1)
+ || atoms->resinfo[resind].chainnum != atoms->resinfo[resind + 1].chainnum;
if (bResname)
{
if (isdigit(atombuf[0]))
{
c = atombuf[0];
- for (i = 0; (static_cast<size_t>(i) < strlen(atombuf)-1); i++)
+ for (i = 0; (static_cast<size_t>(i) < strlen(atombuf) - 1); i++)
{
- atombuf[i] = atombuf[i+1];
+ atombuf[i] = atombuf[i + 1];
}
atombuf[i] = c;
bReorderedNum = TRUE;
for (i = 0; (i < nxlate) && !bRenamed; i++)
{
/* Check if the base file name of the rtp and arn entry match */
- if (localPpResidue.empty() ||
- gmx::equalCaseInsensitive(localPpResidue[resind].filebase, xlatom[i].filebase))
+ if (localPpResidue.empty()
+ || gmx::equalCaseInsensitive(localPpResidue[resind].filebase, xlatom[i].filebase))
{
/* Match the residue name */
- bMatch = (xlatom[i].res == nullptr ||
- (gmx_strcasecmp("protein-nterm", xlatom[i].res) == 0 &&
- rt->namedResidueHasType(rnm, "Protein") && bStartTerm) ||
- (gmx_strcasecmp("protein-cterm", xlatom[i].res) == 0 &&
- rt->namedResidueHasType(rnm, "Protein") && bEndTerm) ||
- (gmx_strcasecmp("protein", xlatom[i].res) == 0 &&
- rt->namedResidueHasType(rnm, "Protein")) ||
- (gmx_strcasecmp("DNA", xlatom[i].res) == 0 &&
- rt->namedResidueHasType(rnm, "DNA")) ||
- (gmx_strcasecmp("RNA", xlatom[i].res) == 0 &&
- rt->namedResidueHasType(rnm, "RNA")));
+ bMatch = (xlatom[i].res == nullptr
+ || (gmx_strcasecmp("protein-nterm", xlatom[i].res) == 0
+ && rt->namedResidueHasType(rnm, "Protein") && bStartTerm)
+ || (gmx_strcasecmp("protein-cterm", xlatom[i].res) == 0
+ && rt->namedResidueHasType(rnm, "Protein") && bEndTerm)
+ || (gmx_strcasecmp("protein", xlatom[i].res) == 0
+ && rt->namedResidueHasType(rnm, "Protein"))
+ || (gmx_strcasecmp("DNA", xlatom[i].res) == 0
+ && rt->namedResidueHasType(rnm, "DNA"))
+ || (gmx_strcasecmp("RNA", xlatom[i].res) == 0
+ && rt->namedResidueHasType(rnm, "RNA")));
if (!bMatch)
{
- const char *ptr0 = rnm;
- const char *ptr1 = xlatom[i].res;
- while (ptr0[0] != '\0' && ptr1[0] != '\0' &&
- (ptr0[0] == ptr1[0] || ptr1[0] == '?'))
+ const char* ptr0 = rnm;
+ const char* ptr1 = xlatom[i].res;
+ while (ptr0[0] != '\0' && ptr1[0] != '\0' && (ptr0[0] == ptr1[0] || ptr1[0] == '?'))
{
ptr0++;
ptr1++;
/* Don't free the old atomname,
* since it might be in the symtab.
*/
- const char *ptr0 = xlatom[i].replace;
+ const char* ptr0 = xlatom[i].replace;
if (bVerbose)
{
- printf("Renaming atom '%s' in residue %d %s to '%s'\n",
- *atoms->atomname[a],
- atoms->resinfo[resind].nr,
- *atoms->resinfo[resind].name,
- ptr0);
+ printf("Renaming atom '%s' in residue %d %s to '%s'\n", *atoms->atomname[a],
+ atoms->resinfo[resind].nr, *atoms->resinfo[resind].name, ptr0);
}
atoms->atomname[a] = put_symtab(symtab, ptr0);
bRenamed = TRUE;