#include "resall.h"
/* use bonded types definitions in hackblock.h */
-#define ekwRepl (ebtsNR+1)
-#define ekwAdd (ebtsNR+2)
-#define ekwDel (ebtsNR+3)
-#define ekwNR 3
-static const char *kw_names[ekwNR] = {
- "replace", "add", "delete"
-};
-
-static int find_kw(char *keyw)
+#define ekwRepl (ebtsNR + 1)
+#define ekwAdd (ebtsNR + 2)
+#define ekwDel (ebtsNR + 3)
+#define ekwNR 3
+static const char* kw_names[ekwNR] = { "replace", "add", "delete" };
+
+static int find_kw(char* keyw)
{
int i;
#define FATAL() gmx_fatal(FARGS, "Reading Termini Database: not enough items on line\n%s", line)
-static void read_atom(char *line, bool bAdd,
- std::string *nname, t_atom *a, PreprocessingAtomTypes *atype, int *cgnr)
+static void read_atom(char* line, bool bAdd, std::string* nname, t_atom* a, PreprocessingAtomTypes* atype, int* cgnr)
{
int nr, i;
char buf[5][30];
if (nr < 3 || nr > 4)
{
- gmx_fatal(FARGS, "Reading Termini Database: expected %d or %d items of atom data in stead of %d on line\n%s", 3, 4, nr, line);
+ gmx_fatal(FARGS,
+ "Reading Termini Database: expected %d or %d items of atom data in stead of %d "
+ "on line\n%s",
+ 3, 4, nr, line);
}
i = 0;
if (!bAdd)
}
}
-static void print_atom(FILE *out, const t_atom &a, PreprocessingAtomTypes *atype)
+static void print_atom(FILE* out, const t_atom& a, PreprocessingAtomTypes* atype)
{
- fprintf(out, "\t%s\t%g\t%g\n",
- atype->atomNameFromAtomType(a.type), a.m, a.q);
+ fprintf(out, "\t%s\t%g\t%g\n", atype->atomNameFromAtomType(a.type), a.m, a.q);
}
-static void print_ter_db(const char *ff, char C, gmx::ArrayRef<const MoleculePatchDatabase> tb,
- PreprocessingAtomTypes *atype)
+static void print_ter_db(const char* ff,
+ char C,
+ gmx::ArrayRef<const MoleculePatchDatabase> tb,
+ PreprocessingAtomTypes* atype)
{
std::string buf = gmx::formatString("%s-%c.tdb", ff, C);
- FILE *out = gmx_fio_fopen(buf.c_str(), "w");
+ FILE* out = gmx_fio_fopen(buf.c_str(), "w");
- for (const auto &modification : tb)
+ for (const auto& modification : tb)
{
fprintf(out, "[ %s ]\n", modification.name.c_str());
if (std::any_of(modification.hack.begin(), modification.hack.end(),
- [](const auto &mod)
- { return mod.type() == MoleculePatchType::Replace; }))
+ [](const auto& mod) { return mod.type() == MoleculePatchType::Replace; }))
{
- fprintf(out, "[ %s ]\n", kw_names[ekwRepl-ebtsNR-1]);
- for (const auto &hack : modification.hack)
+ fprintf(out, "[ %s ]\n", kw_names[ekwRepl - ebtsNR - 1]);
+ for (const auto& hack : modification.hack)
{
if (hack.type() == MoleculePatchType::Replace)
{
}
}
if (std::any_of(modification.hack.begin(), modification.hack.end(),
- [](const auto &mod)
- { return mod.type() == MoleculePatchType::Add; }))
+ [](const auto& mod) { return mod.type() == MoleculePatchType::Add; }))
{
- fprintf(out, "[ %s ]\n", kw_names[ekwAdd-ebtsNR-1]);
- for (const auto &hack : modification.hack)
+ fprintf(out, "[ %s ]\n", kw_names[ekwAdd - ebtsNR - 1]);
+ for (const auto& hack : modification.hack)
{
if (hack.type() == MoleculePatchType::Add)
{
}
}
if (std::any_of(modification.hack.begin(), modification.hack.end(),
- [](const auto &mod)
- { return mod.type() == MoleculePatchType::Delete; }))
+ [](const auto& mod) { return mod.type() == MoleculePatchType::Delete; }))
{
- fprintf(out, "[ %s ]\n", kw_names[ekwDel-ebtsNR-1]);
- for (const auto &hack : modification.hack)
+ fprintf(out, "[ %s ]\n", kw_names[ekwDel - ebtsNR - 1]);
+ for (const auto& hack : modification.hack)
{
if (hack.type() == MoleculePatchType::Delete)
{
if (!modification.rb[bt].b.empty())
{
fprintf(out, "[ %s ]\n", btsNames[bt]);
- for (const auto &b : modification.rb[bt].b)
+ for (const auto& b : modification.rb[bt].b)
{
for (int k = 0; k < btsNiatoms[bt]; k++)
{
gmx_fio_fclose(out);
}
-static void read_ter_db_file(const char *fn,
- std::vector<MoleculePatchDatabase> *tbptr,
- PreprocessingAtomTypes *atype)
+static void read_ter_db_file(const char* fn,
+ std::vector<MoleculePatchDatabase>* tbptr,
+ PreprocessingAtomTypes* atype)
{
- char filebase[STRLEN];
- char header[STRLEN], buf[STRLEN], line[STRLEN];
+ char filebase[STRLEN];
+ char header[STRLEN], buf[STRLEN], line[STRLEN];
fflib_filename_base(fn, filebase, STRLEN);
/* Remove the C/N termini extension */
- char *ptr = strrchr(filebase, '.');
+ char* ptr = strrchr(filebase, '.');
if (ptr != nullptr)
{
ptr[0] = '\0';
}
- FILE *in = fflib_open(fn);
+ FILE* in = fflib_open(fn);
- int kwnr = NOTSET;
+ int kwnr = NOTSET;
get_a_line(in, line, STRLEN);
- MoleculePatchDatabase *block = nullptr;
+ MoleculePatchDatabase* block = nullptr;
while (!feof(in))
{
if (get_header(line, header))
{
if (block == nullptr)
{
- gmx_fatal(FARGS, "reading termini database: "
+ gmx_fatal(FARGS,
+ "reading termini database: "
"directive expected before line:\n%s\n"
- "This might be a file in an old format.", line);
+ "This might be a file in an old format.",
+ line);
}
/* this is not a header, so it must be data */
if (kwnr >= ebtsNR)
/* this is a hack: add/rename/delete atoms */
/* make space for hacks */
block->hack.emplace_back(MoleculePatch());
- MoleculePatch *hack = &block->hack.back();
+ MoleculePatch* hack = &block->hack.back();
/* get data */
int n = 0;
{
if (sscanf(line, "%s%n", buf, &n) != 1)
{
- gmx_fatal(FARGS, "Reading Termini Database '%s': "
- "expected atom name on line\n%s", fn, line);
+ gmx_fatal(FARGS,
+ "Reading Termini Database '%s': "
+ "expected atom name on line\n%s",
+ fn, line);
}
hack->oname = buf;
/* we only replace or delete one atom at a time */
}
else
{
- gmx_fatal(FARGS, "unimplemented keyword number %d (%s:%d)",
- kwnr, __FILE__, __LINE__);
+ gmx_fatal(FARGS, "unimplemented keyword number %d (%s:%d)", kwnr, __FILE__, __LINE__);
}
if (kwnr == ekwRepl || kwnr == ekwAdd)
{
hack->atom.emplace_back();
- read_atom(line+n, kwnr == ekwAdd,
- &hack->nname, &hack->atom.back(), atype,
+ read_atom(line + n, kwnr == ekwAdd, &hack->nname, &hack->atom.back(), atype,
&hack->cgnr);
if (hack->nname.empty())
{
}
else
{
- gmx_fatal(FARGS, "Reading Termini Database '%s': don't know which name the new atom should have on line\n%s", fn, line);
+ gmx_fatal(FARGS,
+ "Reading Termini Database '%s': don't know which name the "
+ "new atom should have on line\n%s",
+ fn, line);
}
}
}
else if (kwnr >= 0 && kwnr < ebtsNR)
{
/* this is bonded data: bonds, angles, dihedrals or impropers */
- int n = 0;
+ int n = 0;
block->rb[kwnr].b.emplace_back();
- BondedInteraction *newBond = &block->rb[kwnr].b.back();
+ BondedInteraction* newBond = &block->rb[kwnr].b.back();
for (int j = 0; j < btsNiatoms[kwnr]; j++)
{
int ni;
- if (sscanf(line+n, "%s%n", buf, &ni) == 1)
+ if (sscanf(line + n, "%s%n", buf, &ni) == 1)
{
newBond->a[j] = buf;
}
else
{
- gmx_fatal(FARGS, "Reading Termini Database '%s': expected %d atom names (found %d) on line\n%s", fn, btsNiatoms[kwnr], j-1, line);
+ gmx_fatal(FARGS,
+ "Reading Termini Database '%s': expected %d atom names (found "
+ "%d) on line\n%s",
+ fn, btsNiatoms[kwnr], j - 1, line);
}
n += ni;
}
strcpy(buf, "");
- sscanf(line+n, "%s", buf);
+ sscanf(line + n, "%s", buf);
newBond->s = buf;
}
else
{
- gmx_fatal(FARGS, "Reading Termini Database: Expecting a header at line\n"
- "%s", line);
+ gmx_fatal(FARGS,
+ "Reading Termini Database: Expecting a header at line\n"
+ "%s",
+ line);
}
}
get_a_line(in, line, STRLEN);
gmx_ffclose(in);
}
-int read_ter_db(const char *ffdir, char ter,
- std::vector<MoleculePatchDatabase> *tbptr, PreprocessingAtomTypes *atype)
+int read_ter_db(const char* ffdir, char ter, std::vector<MoleculePatchDatabase>* tbptr, PreprocessingAtomTypes* atype)
{
std::string ext = gmx::formatString(".%c.tdb", ter);
/* Search for termini database files.
* Do not generate an error when none are found.
*/
- std::vector<std::string> tdbf = fflib_search_file_end(ffdir, ext.c_str(), FALSE);
+ std::vector<std::string> tdbf = fflib_search_file_end(ffdir, ext.c_str(), FALSE);
tbptr->clear();
- for (const auto &filename : tdbf)
+ for (const auto& filename : tdbf)
{
read_ter_db_file(filename.c_str(), tbptr, atype);
}
return tbptr->size();
}
-std::vector<MoleculePatchDatabase *>
-filter_ter(gmx::ArrayRef<MoleculePatchDatabase> tb,
- const char *resname)
+std::vector<MoleculePatchDatabase*> filter_ter(gmx::ArrayRef<MoleculePatchDatabase> tb, const char* resname)
{
// TODO Four years later, no force fields have ever used this, so decide status of this feature
/* Since some force fields (e.g. OPLS) needs different
* Remember to free the list when you are done with it...
*/
- auto none_idx = tb.end();
- std::vector<MoleculePatchDatabase *> list;
+ auto none_idx = tb.end();
+ std::vector<MoleculePatchDatabase*> list;
for (auto it = tb.begin(); it != tb.end(); it++)
{
- const char *s = it->name.c_str();
+ const char* s = it->name.c_str();
bool found = false;
do
{
s++;
}
}
- }
- while (!found && s != nullptr);
+ } while (!found && s != nullptr);
}
/* All residue-specific termini have been added. We might have to fall
*/
for (auto it = tb.begin(); it != tb.end(); it++)
{
- const char *s = it->name.c_str();
+ const char* s = it->name.c_str();
if (gmx::equalCaseInsensitive("None", it->name))
{
none_idx = it;
{
/* Time to see if there's a generic terminus that matches.
Is there a hyphen? */
- const char *c = strchr(s, '-');
+ const char* c = strchr(s, '-');
/* A conjunction hyphen normally indicates a residue-specific
terminus, which is named like "GLY-COOH". A generic terminus
/* '-' as the last character indicates charge, so if that's
the only one found e.g. "COO-", then it was not a conjunction
hyphen, so this is a generic terminus */
- bool bOnlyFoundChargeHyphen = (bFoundAnyHyphen &&
- *(c+1) == '\0');
+ bool bOnlyFoundChargeHyphen = (bFoundAnyHyphen && *(c + 1) == '\0');
/* Thus, "GLY-COO-" is not recognized as a generic terminus. */
bool bFoundGenericTerminus = !bFoundAnyHyphen || bOnlyFoundChargeHyphen;
if (bFoundGenericTerminus)
/* Check that we haven't already added a residue-specific version
* of this terminus.
*/
- auto found = std::find_if(list.begin(), list.end(),
- [&s](const MoleculePatchDatabase *b)
- { return strstr(b->name.c_str(), s) != nullptr; });
+ auto found = std::find_if(list.begin(), list.end(), [&s](const MoleculePatchDatabase* b) {
+ return strstr(b->name.c_str(), s) != nullptr;
+ });
if (found == list.end())
{
list.push_back(it);
}
-MoleculePatchDatabase *choose_ter(gmx::ArrayRef<MoleculePatchDatabase *> tb, const char *title)
+MoleculePatchDatabase* choose_ter(gmx::ArrayRef<MoleculePatchDatabase*> tb, const char* title)
{
int sel, ret;
printf("%s\n", title);
int i = 0;
- for (const auto &modification : tb)
+ for (const auto& modification : tb)
{
bool bIsZwitterion = (0 == gmx_wcmatch("*ZWITTERION*", modification->name.c_str()));
printf("%2d: %s%s\n", i, modification->name.c_str(),
do
{
ret = fscanf(stdin, "%d", &sel);
- }
- while ((ret != 1) || (sel < 0) || (sel >= tb.ssize()));
+ } while ((ret != 1) || (sel < 0) || (sel >= tb.ssize()));
return tb[sel];
}