From de0f363c30484eed6837b569cf6d29287bcf8a4d Mon Sep 17 00:00:00 2001 From: Teemu Murtola Date: Sat, 31 May 2014 22:11:47 +0300 Subject: [PATCH] Move atomprop.* to topology/ - Remove some unnecessary includes. - Convert the source file to C++ and fix some issues. - Some header cleanup in touched files. This introduces a fileio<->topology cyclic dependency, but that needs to wait for later resolution. Change-Id: I88e70cd9024d86c56c4d4435fa91c42af9af7c29 --- src/contrib/hexamer.c | 1 - src/contrib/mkice.c | 1 - src/gromacs/fileio/pdbio.c | 3 ++- src/gromacs/fileio/pdbio.h | 5 +++-- src/gromacs/fileio/tpxio.c | 4 ++-- src/gromacs/gmxana/gmx_dyecoupl.c | 1 + src/gromacs/gmxana/gmx_editconf.c | 12 ++++++------ src/gromacs/gmxpreprocess/insert-molecules.cpp | 2 +- src/gromacs/gmxpreprocess/pdb2gmx.c | 2 +- src/gromacs/gmxpreprocess/read-conformation.cpp | 2 +- src/gromacs/gmxpreprocess/read-conformation.h | 4 ++-- src/gromacs/gmxpreprocess/solvate.cpp | 13 +++++++------ src/gromacs/gmxpreprocess/x2top.c | 1 - src/gromacs/tools/check.c | 13 +++++++------ src/gromacs/topology/CMakeLists.txt | 1 + .../{gmxlib/atomprop.c => topology/atomprop.cpp} | 14 ++++++-------- src/gromacs/{legacyheaders => topology}/atomprop.h | 11 +++++------ .../trajectoryanalysis/modules/freevolume.cpp | 2 +- src/gromacs/trajectoryanalysis/modules/sasa.cpp | 2 +- src/programs/view/manager.cpp | 6 +++--- 20 files changed, 50 insertions(+), 50 deletions(-) rename src/gromacs/{gmxlib/atomprop.c => topology/atomprop.cpp} (97%) rename src/gromacs/{legacyheaders => topology}/atomprop.h (93%) diff --git a/src/contrib/hexamer.c b/src/contrib/hexamer.c index 6e55de9c3a..22117c73a9 100644 --- a/src/contrib/hexamer.c +++ b/src/contrib/hexamer.c @@ -51,7 +51,6 @@ #include "typedefs.h" #include "gbutil.h" #include "gromacs/math/units.h" -#include "atomprop.h" void copy_atom(t_symtab *tab,t_atoms *a1,int i1,t_atoms *a2,int i2, rvec xin[],rvec xout[],rvec vin[],rvec vout[]) diff --git a/src/contrib/mkice.c b/src/contrib/mkice.c index 2cd3b2afbc..a60b847cdd 100644 --- a/src/contrib/mkice.c +++ b/src/contrib/mkice.c @@ -53,7 +53,6 @@ #include "gromacs/fileio/trnio.h" #include "gromacs/topology/symtab.h" #include "gromacs/fileio/strdb.h" -#include "atomprop.h" #include "gromacs/fileio/confio.h" #define TET 109.47 diff --git a/src/gromacs/fileio/pdbio.c b/src/gromacs/fileio/pdbio.c index 58de0aaf67..a4c1487d68 100644 --- a/src/gromacs/fileio/pdbio.c +++ b/src/gromacs/fileio/pdbio.c @@ -44,8 +44,8 @@ #include #include -#include "gromacs/legacyheaders/atomprop.h" #include "gromacs/legacyheaders/copyrite.h" +#include "gromacs/legacyheaders/index.h" #include "gromacs/legacyheaders/types/ifunc.h" #include "gromacs/legacyheaders/typedefs.h" #include "gromacs/utility/futil.h" @@ -54,6 +54,7 @@ #include "gromacs/math/units.h" #include "gromacs/math/vec.h" #include "gromacs/pbcutil/pbc.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/topology/symtab.h" #include "gromacs/topology/topology.h" #include "gromacs/utility/cstringutil.h" diff --git a/src/gromacs/fileio/pdbio.h b/src/gromacs/fileio/pdbio.h index e3a69b4486..a8f41a62b3 100644 --- a/src/gromacs/fileio/pdbio.h +++ b/src/gromacs/fileio/pdbio.h @@ -40,12 +40,13 @@ #include -#include "../legacyheaders/atomprop.h" +#include "../legacyheaders/types/simple.h" #ifdef __cplusplus extern "C" { #endif +struct gmx_atomprop; struct t_atoms; struct t_topology; @@ -104,7 +105,7 @@ void write_pdbfile(FILE *out, const char *title, struct t_atoms *atoms, * which may be useful for visualization purposes. */ -void get_pdb_atomnumber(struct t_atoms *atoms, gmx_atomprop_t aps); +void get_pdb_atomnumber(struct t_atoms *atoms, struct gmx_atomprop *aps); /* Routine to extract atomic numbers from the atom names */ int read_pdbfile(FILE *in, char *title, int *model_nr, diff --git a/src/gromacs/fileio/tpxio.c b/src/gromacs/fileio/tpxio.c index 7dc48935a6..55f5f6a085 100644 --- a/src/gromacs/fileio/tpxio.c +++ b/src/gromacs/fileio/tpxio.c @@ -51,12 +51,12 @@ #include "tpxio.h" #include "txtdump.h" #include "confio.h" -#include "atomprop.h" #include "copyrite.h" -#include "gromacs/topology/mtop_util.h" #include "gromacs/math/vec.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/topology/block.h" +#include "gromacs/topology/mtop_util.h" #include "gromacs/topology/symtab.h" #include "gromacs/topology/topology.h" #include "gromacs/utility/cstringutil.h" diff --git a/src/gromacs/gmxana/gmx_dyecoupl.c b/src/gromacs/gmxana/gmx_dyecoupl.c index 7e8934f6c6..cc492abd05 100644 --- a/src/gromacs/gmxana/gmx_dyecoupl.c +++ b/src/gromacs/gmxana/gmx_dyecoupl.c @@ -42,6 +42,7 @@ #include "gromacs/fileio/trxio.h" #include "gromacs/fileio/xvgr.h" #include "gromacs/pbcutil/pbc.h" +#include "index.h" #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/smalloc.h" diff --git a/src/gromacs/gmxana/gmx_editconf.c b/src/gromacs/gmxana/gmx_editconf.c index 6b87cf828c..3bf14dbf76 100644 --- a/src/gromacs/gmxana/gmx_editconf.c +++ b/src/gromacs/gmxana/gmx_editconf.c @@ -43,26 +43,26 @@ #include "gromacs/fileio/pdbio.h" #include "gromacs/fileio/confio.h" -#include "gromacs/utility/smalloc.h" #include "macros.h" -#include "gromacs/commandline/pargs.h" #include "gromacs/fileio/strdb.h" #include "index.h" -#include "gromacs/math/vec.h" #include "typedefs.h" #include "gromacs/gmxlib/conformation-utilities.h" #include "gromacs/math/units.h" -#include "atomprop.h" #include "gromacs/fileio/tpxio.h" #include "gromacs/fileio/trxio.h" -#include "gromacs/pbcutil/pbc.h" #include "princ.h" #include "txtdump.h" #include "viewit.h" -#include "gromacs/pbcutil/rmpbc.h" #include "gmx_ana.h" +#include "gromacs/commandline/pargs.h" +#include "gromacs/math/vec.h" +#include "gromacs/pbcutil/pbc.h" +#include "gromacs/pbcutil/rmpbc.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/utility/fatalerror.h" +#include "gromacs/utility/smalloc.h" typedef struct { diff --git a/src/gromacs/gmxpreprocess/insert-molecules.cpp b/src/gromacs/gmxpreprocess/insert-molecules.cpp index a69ad76497..7d583bd855 100644 --- a/src/gromacs/gmxpreprocess/insert-molecules.cpp +++ b/src/gromacs/gmxpreprocess/insert-molecules.cpp @@ -44,7 +44,6 @@ #include "gromacs/math/utilities.h" #include "gromacs/fileio/confio.h" #include "macros.h" -#include "atomprop.h" #include "names.h" #include "gromacs/math/vec.h" #include "gromacs/gmxlib/conformation-utilities.h" @@ -56,6 +55,7 @@ #include "gromacs/pbcutil/ishift.h" #include "gromacs/pbcutil/pbc.h" #include "gromacs/random/random.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/utility/cstringutil.h" #include "gromacs/utility/fatalerror.h" #include "gromacs/utility/futil.h" diff --git a/src/gromacs/gmxpreprocess/pdb2gmx.c b/src/gromacs/gmxpreprocess/pdb2gmx.c index 4dd0bf2894..db0a541256 100644 --- a/src/gromacs/gmxpreprocess/pdb2gmx.c +++ b/src/gromacs/gmxpreprocess/pdb2gmx.c @@ -62,13 +62,13 @@ #include "gromacs/gmxlib/conformation-utilities.h" #include "genhydro.h" #include "readinp.h" -#include "atomprop.h" #include "index.h" #include "fflibutil.h" #include "macros.h" #include "gromacs/commandline/pargs.h" #include "gromacs/fileio/strdb.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/topology/block.h" #include "gromacs/topology/symtab.h" #include "gromacs/utility/smalloc.h" diff --git a/src/gromacs/gmxpreprocess/read-conformation.cpp b/src/gromacs/gmxpreprocess/read-conformation.cpp index e282233aa2..fa4d8c5b78 100644 --- a/src/gromacs/gmxpreprocess/read-conformation.cpp +++ b/src/gromacs/gmxpreprocess/read-conformation.cpp @@ -35,9 +35,9 @@ #include "read-conformation.h" #include "gromacs/fileio/confio.h" -#include "gromacs/legacyheaders/atomprop.h" #include "gromacs/legacyheaders/types/simple.h" #include "gromacs/legacyheaders/typedefs.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/topology/atoms.h" #include "gromacs/utility/cstringutil.h" #include "gromacs/utility/smalloc.h" diff --git a/src/gromacs/gmxpreprocess/read-conformation.h b/src/gromacs/gmxpreprocess/read-conformation.h index be15b1d4fb..4a1704d5ce 100644 --- a/src/gromacs/gmxpreprocess/read-conformation.h +++ b/src/gromacs/gmxpreprocess/read-conformation.h @@ -36,12 +36,12 @@ #define GMX_GMXPREPROCESS_READ_CONFORMATION_H #include "types/simple.h" -#include "atomprop.h" #ifdef __cplusplus extern "C" { #endif +struct gmx_atomprop; struct t_atoms; /*! \brief Allocate and fill an array of inter-atomic half distances @@ -50,7 +50,7 @@ struct t_atoms; * default value. Used directly and indirectly by solvate and * insert-molecules for deciding whether molecules clash. The return * pointer should be freed by the caller. */ -real *makeExclusionDistances(const struct t_atoms *a, gmx_atomprop_t aps, +real *makeExclusionDistances(const struct t_atoms *a, struct gmx_atomprop *aps, real defaultDistance, real scaleFactor); /*! \brief Read a conformation from a file, allocate and fill data structures. diff --git a/src/gromacs/gmxpreprocess/solvate.cpp b/src/gromacs/gmxpreprocess/solvate.cpp index 90ade75747..a639c08a43 100644 --- a/src/gromacs/gmxpreprocess/solvate.cpp +++ b/src/gromacs/gmxpreprocess/solvate.cpp @@ -43,21 +43,22 @@ #include #include "typedefs.h" -#include "gromacs/utility/smalloc.h" -#include "gromacs/utility/cstringutil.h" #include "gromacs/fileio/confio.h" #include "macros.h" #include "gromacs/utility/futil.h" -#include "atomprop.h" #include "names.h" -#include "gromacs/math/vec.h" -#include "gromacs/utility/fatalerror.h" -#include "gromacs/commandline/pargs.h" #include "gromacs/gmxlib/conformation-utilities.h" #include "addconf.h" #include "read-conformation.h" #include "gromacs/fileio/pdbio.h" +#include "gromacs/commandline/pargs.h" +#include "gromacs/math/vec.h" +#include "gromacs/topology/atomprop.h" +#include "gromacs/utility/cstringutil.h" +#include "gromacs/utility/fatalerror.h" +#include "gromacs/utility/smalloc.h" + #ifdef DEBUG static void print_stat(rvec *x, int natoms, matrix box) { diff --git a/src/gromacs/gmxpreprocess/x2top.c b/src/gromacs/gmxpreprocess/x2top.c index 686b300e28..06962af891 100644 --- a/src/gromacs/gmxpreprocess/x2top.c +++ b/src/gromacs/gmxpreprocess/x2top.c @@ -56,7 +56,6 @@ #include "pdb2top.h" #include "gen_ad.h" #include "gpp_nextnb.h" -#include "atomprop.h" #include "hackblock.h" #include "nm2type.h" diff --git a/src/gromacs/tools/check.c b/src/gromacs/tools/check.c index 91ecdded11..47c703efa5 100644 --- a/src/gromacs/tools/check.c +++ b/src/gromacs/tools/check.c @@ -43,17 +43,11 @@ #include #include "macros.h" -#include "gromacs/commandline/pargs.h" #include "txtdump.h" -#include "gromacs/utility/fatalerror.h" -#include "atomprop.h" #include "gromacs/math/vec.h" -#include "gromacs/pbcutil/pbc.h" #include "gromacs/math/units.h" #include "index.h" -#include "gromacs/utility/smalloc.h" #include "names.h" -#include "gromacs/topology/mtop_util.h" #include "gromacs/utility/futil.h" #include "gromacs/fileio/gmxfio.h" #include "gromacs/fileio/trnio.h" @@ -62,7 +56,14 @@ #include "gromacs/fileio/enxio.h" #include "gromacs/fileio/tpxio.h" #include "gromacs/fileio/trxio.h" + +#include "gromacs/commandline/pargs.h" +#include "gromacs/pbcutil/pbc.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/topology/block.h" +#include "gromacs/topology/mtop_util.h" +#include "gromacs/utility/fatalerror.h" +#include "gromacs/utility/smalloc.h" #include "compare.h" diff --git a/src/gromacs/topology/CMakeLists.txt b/src/gromacs/topology/CMakeLists.txt index a6ffdfb009..fb900cfca0 100644 --- a/src/gromacs/topology/CMakeLists.txt +++ b/src/gromacs/topology/CMakeLists.txt @@ -36,6 +36,7 @@ file(GLOB TOPOLOGY_SOURCES *.cpp *.c) set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${TOPOLOGY_SOURCES} PARENT_SCOPE) set(TOPOLOGY_PUBLIC_HEADERS + atomprop.h atoms.h block.h idef.h diff --git a/src/gromacs/gmxlib/atomprop.c b/src/gromacs/topology/atomprop.cpp similarity index 97% rename from src/gromacs/gmxlib/atomprop.c rename to src/gromacs/topology/atomprop.cpp index 0b359886e5..519a5bb897 100644 --- a/src/gromacs/gmxlib/atomprop.c +++ b/src/gromacs/topology/atomprop.cpp @@ -34,6 +34,8 @@ * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org. */ +#include "gromacs/topology/atomprop.h" + #ifdef HAVE_CONFIG_H #include #endif @@ -42,11 +44,8 @@ #include #include "gromacs/fileio/strdb.h" -#include "gromacs/legacyheaders/atomprop.h" #include "gromacs/legacyheaders/copyrite.h" #include "gromacs/legacyheaders/index.h" -#include "gromacs/legacyheaders/macros.h" -#include "gromacs/legacyheaders/typedefs.h" #include "gromacs/math/utilities.h" #include "gromacs/utility/cstringutil.h" #include "gromacs/utility/fatalerror.h" @@ -226,7 +225,7 @@ static void read_prop(gmx_atomprop_t aps, int eprop, double factor) while (get_a_line(fp, line, STRLEN)) { line_no++; - if (sscanf(line, "%s %s %lf", resnm, atomnm, &pp) == 3) + if (sscanf(line, "%31s %31s %20lf", resnm, atomnm, &pp) == 3) { pp *= factor; add_prop(ap, aps->restype, resnm, atomnm, pp, line_no); @@ -281,7 +280,6 @@ static void set_prop(gmx_atomprop_t aps, int eprop) gmx_atomprop_t gmx_atomprop_init(void) { gmx_atomprop *aps; - int p; snew(aps, 1); @@ -350,7 +348,6 @@ gmx_bool gmx_atomprop_query(gmx_atomprop_t aps, real *value) { gmx_atomprop *ap = (gmx_atomprop*) aps; - size_t i; int j; #define MAXQ 32 char atomname[MAXQ], resname[MAXQ]; @@ -367,8 +364,9 @@ gmx_bool gmx_atomprop_query(gmx_atomprop_t aps, } if (isdigit(atomnm[0])) { + int i; /* put digit after atomname */ - for (i = 1; (i < min(MAXQ-1, strlen(atomnm))); i++) + for (i = 1; i < MAXQ-1 && atomnm[i] != '\0'; i++) { atomname[i-1] = atomnm[i]; } @@ -430,5 +428,5 @@ int gmx_atomprop_atomnumber(gmx_atomprop_t aps, const char *elem) return gmx_nint(ap->prop[epropElement].value[i]); } } - return NOTSET; + return -1; } diff --git a/src/gromacs/legacyheaders/atomprop.h b/src/gromacs/topology/atomprop.h similarity index 93% rename from src/gromacs/legacyheaders/atomprop.h rename to src/gromacs/topology/atomprop.h index c70f760ec5..33b0c60da8 100644 --- a/src/gromacs/legacyheaders/atomprop.h +++ b/src/gromacs/topology/atomprop.h @@ -3,7 +3,7 @@ * * Copyright (c) 1991-2000, University of Groningen, The Netherlands. * Copyright (c) 2001-2004, The GROMACS development team. - * Copyright (c) 2010, by the GROMACS development team, led by + * Copyright (c) 2010,2014, by the GROMACS development team, led by * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl, * and including many others, as listed in the AUTHORS file in the * top-level source directory and at http://www.gromacs.org. @@ -34,16 +34,16 @@ * To help us fund GROMACS development, we humbly ask that you cite * the research papers on the package. Check out http://www.gromacs.org. */ +#ifndef GMX_TOPOLOGY_ATOMPROP_H +#define GMX_TOPOLOGY_ATOMPROP_H -#ifndef _atomprop_h -#define _atomprop_h +#include "../utility/basedefinitions.h" +#include "../utility/real.h" #ifdef __cplusplus extern "C" { #endif -#include "index.h" - /* Abstract type for the atom property database */ typedef struct gmx_atomprop *gmx_atomprop_t; @@ -75,5 +75,4 @@ gmx_bool gmx_atomprop_query(gmx_atomprop_t aps, } #endif - #endif diff --git a/src/gromacs/trajectoryanalysis/modules/freevolume.cpp b/src/gromacs/trajectoryanalysis/modules/freevolume.cpp index 5add615390..b8084b433a 100644 --- a/src/gromacs/trajectoryanalysis/modules/freevolume.cpp +++ b/src/gromacs/trajectoryanalysis/modules/freevolume.cpp @@ -43,7 +43,6 @@ #include -#include "gromacs/legacyheaders/atomprop.h" #include "gromacs/legacyheaders/copyrite.h" #include "gromacs/analysisdata/analysisdata.h" @@ -59,6 +58,7 @@ #include "gromacs/selection/nbsearch.h" #include "gromacs/selection/selection.h" #include "gromacs/selection/selectionoption.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/topology/topology.h" #include "gromacs/trajectoryanalysis/analysissettings.h" #include "gromacs/utility/arrayref.h" diff --git a/src/gromacs/trajectoryanalysis/modules/sasa.cpp b/src/gromacs/trajectoryanalysis/modules/sasa.cpp index 087a8eea33..2128e3f245 100644 --- a/src/gromacs/trajectoryanalysis/modules/sasa.cpp +++ b/src/gromacs/trajectoryanalysis/modules/sasa.cpp @@ -47,7 +47,6 @@ #include #include -#include "gromacs/legacyheaders/atomprop.h" #include "gromacs/legacyheaders/copyrite.h" #include "gromacs/analysisdata/analysisdata.h" @@ -64,6 +63,7 @@ #include "gromacs/pbcutil/pbc.h" #include "gromacs/selection/selection.h" #include "gromacs/selection/selectionoption.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/topology/symtab.h" #include "gromacs/topology/topology.h" #include "gromacs/trajectoryanalysis/analysismodule.h" diff --git a/src/programs/view/manager.cpp b/src/programs/view/manager.cpp index a4ddb6541a..4541de232a 100644 --- a/src/programs/view/manager.cpp +++ b/src/programs/view/manager.cpp @@ -48,14 +48,14 @@ #include "typedefs.h" #include "macros.h" -#include "atomprop.h" #include "names.h" -#include "gromacs/pbcutil/pbc.h" #include "copyrite.h" +#include "gromacs/fileio/tpxio.h" #include "gromacs/math/utilities.h" #include "gromacs/math/vec.h" -#include "gromacs/fileio/tpxio.h" +#include "gromacs/pbcutil/pbc.h" +#include "gromacs/topology/atomprop.h" #include "gromacs/utility/cstringutil.h" #include "gromacs/utility/futil.h" #include "gromacs/utility/smalloc.h" -- 2.22.0