#include <stdio.h>
-#include "../legacyheaders/types/atoms.h"
#include "../legacyheaders/types/simple.h"
#include "../legacyheaders/types/topology.h"
extern "C" {
#endif
+struct t_atoms;
+
int read_g96_conf(FILE *fp, const char *infile, t_trxframe *fr, char *line);
/* read a Gromos96 coordinate or trajectory file, *
* returns the number of atoms *
int gro_first_x_or_v(FILE *status, t_trxframe *fr);
/* read first/next x and/or v frame from gro file */
-void write_hconf_indexed_p(FILE *out, const char *title, t_atoms *atoms,
+void write_hconf_indexed_p(FILE *out, const char *title, struct t_atoms *atoms,
int nx, const atom_id index[], int ndec,
rvec *x, rvec *v, matrix box);
-void write_hconf_p(FILE *out, const char *title, t_atoms *atoms, int ndec,
+void write_hconf_p(FILE *out, const char *title, struct t_atoms *atoms, int ndec,
rvec *x, rvec *v, matrix box);
/* Write a Gromos file with precision ndec: number of decimal places in x,
* v has one place more. */
void write_sto_conf_indexed(const char *outfile, const char *title,
- t_atoms *atoms,
+ struct t_atoms *atoms,
rvec x[], rvec *v, int ePBC, matrix box,
atom_id nindex, atom_id index[]);
/* like write_sto_conf, but indexed */
void write_sto_conf(const char *outfile, const char *title,
- t_atoms *atoms,
+ struct t_atoms *atoms,
rvec x[], rvec *v, int ePBC, matrix box);
/* write atoms, x, v (if .gro and not NULL) and box (if not NULL)
* to an STO (.gro or .pdb) file */
/* read the number of atoms from an STX file */
void read_stx_conf(const char *infile, char *title,
- t_atoms *atoms,
+ struct t_atoms *atoms,
rvec x[], rvec *v, int *ePBC, matrix box);
/* Read atoms, x, v and box from an STX file.
* If ePBC!=NULL return the type of pbc in *ePBC or -1 if unknown.
extern "C" {
#endif
+struct t_atoms;
+
typedef struct gmx_conect_t *gmx_conect;
/* THE pdb format (for ATOM/HETATOM lines) */
gmx_conect conect, gmx_bool bTerSepChains);
/* REALLY low level */
-void write_pdbfile(FILE *out, const char *title, t_atoms *atoms,
+void write_pdbfile(FILE *out, const char *title, struct t_atoms *atoms,
rvec x[], int ePBC, matrix box, char chain,
int model_nr, gmx_conect conect, gmx_bool bTerSepChains);
/* Low level pdb file writing routine.
* which may be useful for visualization purposes.
*/
-void get_pdb_atomnumber(t_atoms *atoms, gmx_atomprop_t aps);
+void get_pdb_atomnumber(struct t_atoms *atoms, gmx_atomprop_t aps);
/* Routine to extract atomic numbers from the atom names */
int read_pdbfile(FILE *in, char *title, int *model_nr,
- t_atoms *atoms, rvec x[], int *ePBC, matrix box,
+ struct t_atoms *atoms, rvec x[], int *ePBC, matrix box,
gmx_bool bChange, gmx_conect conect);
/* Function returns number of atoms found.
* ePBC and gmx_conect structure may be NULL.
*/
void read_pdb_conf(const char *infile, char *title,
- t_atoms *atoms, rvec x[], int *ePBC, matrix box,
+ struct t_atoms *atoms, rvec x[], int *ePBC, matrix box,
gmx_bool bChange, gmx_conect conect);
/* Read a pdb file and extract ATOM and HETATM fields.
* Read a box from the CRYST1 line, return 0 box when no CRYST1 is found.
#include "../../external/tng_io/include/tng_io.h"
#endif
-#include "gromacs/legacyheaders/types/atoms.h"
-
#include "gromacs/math/units.h"
#include "gromacs/utility/common.h"
#include "gromacs/utility/fatalerror.h"
extern "C" {
#endif
+struct t_atoms;
+struct t_block;
+
typedef struct
{
int bIr; /* Non zero if input_rec is present */
* else if bMass=TRUE, read the masses into top.atoms from the mass database.
*/
-void tpx_make_chain_identifiers(t_atoms *atoms, t_block *mols);
+void tpx_make_chain_identifiers(struct t_atoms *atoms, struct t_block *mols);
#ifdef __cplusplus
}
* This file is part of the GROMACS molecular simulation package.
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
- * Copyright (c) 2013, by the GROMACS development team, led by
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,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.
#ifndef GMX_FILEIO_TRX_H
#define GMX_FILEIO_TRX_H
-#include "../legacyheaders/types/atoms.h"
+#include "gromacs/math/vectypes.h"
+#include "gromacs/utility/basedefinitions.h"
+#include "gromacs/utility/real.h"
#ifdef __cplusplus
extern "C" {
#endif
+struct t_atoms;
+
typedef struct gmxvmdplugin t_gmxvmdplugin;
typedef struct trxframe
real lambda; /* free energy perturbation lambda */
int fep_state; /* which fep state are we in? */
gmx_bool bAtoms;
- t_atoms *atoms; /* atoms struct (natoms) */
+ struct t_atoms *atoms; /* atoms struct (natoms) */
gmx_bool bPrec;
real prec; /* precision of x, fraction of 1 nm */
gmx_bool bX;
}
#endif
+struct t_atoms;
+
/* a dedicated status type contains fp, etc. */
typedef struct t_trxstatus t_trxstatus;
* gc is important for pdb file writing only and may be NULL.
*/
-int write_trx(t_trxstatus *status, int nind, const atom_id *ind, t_atoms *atoms,
+int write_trx(t_trxstatus *status, int nind, const atom_id *ind, struct t_atoms *atoms,
int step, real time, matrix box, rvec x[], rvec *v,
gmx_conect gc);
/* Write an indexed frame to a TRX file.
#include "gromacs/math/vec.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/random/random.h"
+#include "gromacs/topology/atoms.h"
#include "gromacs/topology/block.h"
#include "gromacs/topology/symtab.h"
#include "gromacs/utility/smalloc.h"
return buf;
}
-void init_atom(t_atoms *at)
-{
- int i;
-
- at->nr = 0;
- at->nres = 0;
- at->atom = NULL;
- at->resinfo = NULL;
- at->atomname = NULL;
- at->atomtype = NULL;
- at->atomtypeB = NULL;
- at->pdbinfo = NULL;
-}
-
-void init_atomtypes(t_atomtypes *at)
-{
- at->nr = 0;
- at->radius = NULL;
- at->vol = NULL;
- at->atomnumber = NULL;
- at->gb_radius = NULL;
- at->S_hct = NULL;
-}
-
void init_groups(gmx_groups_t *groups)
{
int g;
snew(ir->simtempvals, 1);
}
-void done_atom (t_atoms *at)
-{
- at->nr = 0;
- at->nres = 0;
- sfree(at->atom);
- sfree(at->resinfo);
- sfree(at->atomname);
- sfree(at->atomtype);
- sfree(at->atomtypeB);
- if (at->pdbinfo)
- {
- sfree(at->pdbinfo);
- }
-}
-
-void done_atomtypes(t_atomtypes *atype)
-{
- atype->nr = 0;
- sfree(atype->radius);
- sfree(atype->vol);
- sfree(atype->surftens);
- sfree(atype->atomnumber);
- sfree(atype->gb_radius);
- sfree(atype->S_hct);
-}
-
void done_moltype(gmx_moltype_t *molt)
{
int f;
}
}
-void add_t_atoms(t_atoms *atoms, int natom_extra, int nres_extra)
-{
- int i;
-
- if (natom_extra > 0)
- {
- srenew(atoms->atomname, atoms->nr+natom_extra);
- srenew(atoms->atom, atoms->nr+natom_extra);
- if (NULL != atoms->pdbinfo)
- {
- srenew(atoms->pdbinfo, atoms->nr+natom_extra);
- }
- if (NULL != atoms->atomtype)
- {
- srenew(atoms->atomtype, atoms->nr+natom_extra);
- }
- if (NULL != atoms->atomtypeB)
- {
- srenew(atoms->atomtypeB, atoms->nr+natom_extra);
- }
- for (i = atoms->nr; (i < atoms->nr+natom_extra); i++)
- {
- atoms->atomname[i] = NULL;
- memset(&atoms->atom[i], 0, sizeof(atoms->atom[i]));
- if (NULL != atoms->pdbinfo)
- {
- memset(&atoms->pdbinfo[i], 0, sizeof(atoms->pdbinfo[i]));
- }
- if (NULL != atoms->atomtype)
- {
- atoms->atomtype[i] = NULL;
- }
- if (NULL != atoms->atomtypeB)
- {
- atoms->atomtypeB[i] = NULL;
- }
- }
- atoms->nr += natom_extra;
- }
- if (nres_extra > 0)
- {
- srenew(atoms->resinfo, atoms->nres+nres_extra);
- for (i = atoms->nres; (i < atoms->nres+nres_extra); i++)
- {
- memset(&atoms->resinfo[i], 0, sizeof(atoms->resinfo[i]));
- }
- atoms->nres += nres_extra;
- }
-}
-
-void init_t_atoms(t_atoms *atoms, int natoms, gmx_bool bPdbinfo)
-{
- atoms->nr = natoms;
- atoms->nres = 0;
- snew(atoms->atomname, natoms);
- atoms->atomtype = NULL;
- atoms->atomtypeB = NULL;
- snew(atoms->resinfo, natoms);
- snew(atoms->atom, natoms);
- if (bPdbinfo)
- {
- snew(atoms->pdbinfo, natoms);
- }
- else
- {
- atoms->pdbinfo = NULL;
- }
-}
-
-t_atoms *copy_t_atoms(t_atoms *src)
-{
- t_atoms *dst;
- int i;
-
- snew(dst, 1);
- init_t_atoms(dst, src->nr, (NULL != src->pdbinfo));
- dst->nr = src->nr;
- if (NULL != src->atomname)
- {
- snew(dst->atomname, src->nr);
- }
- if (NULL != src->atomtype)
- {
- snew(dst->atomtype, src->nr);
- }
- if (NULL != src->atomtypeB)
- {
- snew(dst->atomtypeB, src->nr);
- }
- for (i = 0; (i < src->nr); i++)
- {
- dst->atom[i] = src->atom[i];
- if (NULL != src->pdbinfo)
- {
- dst->pdbinfo[i] = src->pdbinfo[i];
- }
- if (NULL != src->atomname)
- {
- dst->atomname[i] = src->atomname[i];
- }
- if (NULL != src->atomtype)
- {
- dst->atomtype[i] = src->atomtype[i];
- }
- if (NULL != src->atomtypeB)
- {
- dst->atomtypeB[i] = src->atomtypeB[i];
- }
- }
- dst->nres = src->nres;
- for (i = 0; (i < src->nres); i++)
- {
- dst->resinfo[i] = src->resinfo[i];
- }
- return dst;
-}
-
-void t_atoms_set_resinfo(t_atoms *atoms, int atom_ind, t_symtab *symtab,
- const char *resname, int resnr, unsigned char ic,
- int chainnum, char chainid)
-{
- t_resinfo *ri;
-
- ri = &atoms->resinfo[atoms->atom[atom_ind].resind];
- ri->name = put_symtab(symtab, resname);
- ri->rtp = NULL;
- ri->nr = resnr;
- ri->ic = ic;
- ri->chainnum = chainnum;
- ri->chainid = chainid;
-}
-
-void free_t_atoms(t_atoms *atoms, gmx_bool bFreeNames)
-{
- int i;
-
- if (bFreeNames && atoms->atomname != NULL)
- {
- for (i = 0; i < atoms->nr; i++)
- {
- if (atoms->atomname[i] != NULL)
- {
- sfree(*atoms->atomname[i]);
- *atoms->atomname[i] = NULL;
- }
- }
- }
- if (bFreeNames && atoms->resinfo != NULL)
- {
- for (i = 0; i < atoms->nres; i++)
- {
- if (atoms->resinfo[i].name != NULL)
- {
- sfree(*atoms->resinfo[i].name);
- *atoms->resinfo[i].name = NULL;
- }
- }
- }
- if (bFreeNames && atoms->atomtype != NULL)
- {
- for (i = 0; i < atoms->nr; i++)
- {
- if (atoms->atomtype[i] != NULL)
- {
- sfree(*atoms->atomtype[i]);
- *atoms->atomtype[i] = NULL;
- }
- }
- }
- if (bFreeNames && atoms->atomtypeB != NULL)
- {
- for (i = 0; i < atoms->nr; i++)
- {
- if (atoms->atomtypeB[i] != NULL)
- {
- sfree(*atoms->atomtypeB[i]);
- *atoms->atomtypeB[i] = NULL;
- }
- }
- }
- sfree(atoms->atomname);
- sfree(atoms->atomtype);
- sfree(atoms->atomtypeB);
- sfree(atoms->resinfo);
- sfree(atoms->atom);
- sfree(atoms->pdbinfo);
- atoms->nr = 0;
- atoms->nres = 0;
- atoms->atomname = NULL;
- atoms->atomtype = NULL;
- atoms->atomtypeB = NULL;
- atoms->resinfo = NULL;
- atoms->atom = NULL;
- atoms->pdbinfo = NULL;
-}
-
real max_cutoff(real cutoff1, real cutoff2)
{
if (cutoff1 == 0 || cutoff2 == 0)
#include "gromacs/fileio/confio.h"
#include "gromacs/legacyheaders/atomprop.h"
#include "gromacs/legacyheaders/types/simple.h"
-#include "gromacs/legacyheaders/types/atoms.h"
#include "gromacs/legacyheaders/typedefs.h"
+#include "gromacs/topology/atoms.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/smalloc.h"
#define GMX_GMXPREPROCESS_READ_CONFORMATION_H
#include "types/simple.h"
-#include "types/atoms.h"
#include "atomprop.h"
#ifdef __cplusplus
extern "C" {
#endif
+struct t_atoms;
+
/*! \brief Allocate and fill an array of inter-atomic half distances
*
* These are either scaled VDW radii taken from vdwradii.dat, or the
* 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 t_atoms *a, gmx_atomprop_t aps,
+real *makeExclusionDistances(const struct t_atoms *a, gmx_atomprop_t aps,
real defaultDistance, real scaleFactor);
/*! \brief Read a conformation from a file, allocate and fill data structures.
* Used by solvate and insert-molecules. The returned pointers *x and
* *v should be freed by the caller. atoms should have its destructor
* called. */
-char *readConformation(const char *confin, t_atoms *atoms, rvec **x, rvec **v,
+char *readConformation(const char *confin, struct t_atoms *atoms, rvec **x, rvec **v,
int *ePBC, matrix box);
#ifdef __cplusplus
#include <stdio.h>
-#include "types/atoms.h"
+#include "types/simple.h"
#ifdef __cplusplus
extern "C" {
#endif
+struct t_atoms;
struct t_blocka;
void check_index(char *gname, int n, atom_id index[],
atom_id *index[], char *grpnames[], int grpnr[]);
/* the same but also reads the number of the selected group*/
-void get_index(t_atoms *atoms, const char *fnm, int ngrps,
+void get_index(struct t_atoms *atoms, const char *fnm, int ngrps,
int isize[], atom_id *index[], char *grpnames[]);
/* Does the same as rd_index, but if the fnm pointer is NULL it
* will not read from fnm, but it will make default index groups
void add_grp(struct t_blocka *b, char ***gnames, int nra, atom_id a[], const char *name);
/* Ads group a with name name to block b and namelist gnames */
-void analyse(t_atoms *atoms, struct t_blocka *gb, char ***gn,
+void analyse(struct t_atoms *atoms, struct t_blocka *gb, char ***gn,
gmx_bool bASK, gmx_bool bVerb);
/* Makes index groups gb with names gn for atoms in atoms.
* bASK=FALSE gives default groups.
#include "types/simple.h"
#include "types/enums.h"
#include "types/idef.h"
-#include "types/atoms.h"
#include "../fileio/trx.h"
#include "types/topology.h"
#include "types/energy.h"
/* Functions to initiate and delete structures *
* These functions are defined in gmxlib/typedefs.c
*/
-void init_atom (t_atoms *at);
void init_mtop(gmx_mtop_t *mtop);
void init_top(t_topology *top);
void init_inputrec(t_inputrec *ir);
void init_df_history(df_history_t *dfhist, int nlambda);
void done_df_history(df_history_t *dfhist);
void copy_df_history(df_history_t * df_dest, df_history_t *df_source);
-void done_atom (t_atoms *at);
void done_moltype(gmx_moltype_t *molt);
void done_molblock(gmx_molblock_t *molb);
void done_mtop(gmx_mtop_t *mtop, gmx_bool bDoneSymtab);
void preserve_box_shape(t_inputrec *ir, matrix box_rel, matrix b);
/* Preserve the box shape, b can be box or boxv */
-void init_t_atoms(t_atoms *atoms, int natoms, gmx_bool bPdbinfo);
-/* allocate memory for the arrays, set nr to natoms and nres to 0
- * set pdbinfo to NULL or allocate memory for it */
-
-t_atoms *copy_t_atoms(t_atoms *src);
-/* copy an atoms struct from src to a new one */
-
-void add_t_atoms(t_atoms *atoms, int natom_extra, int nres_extra);
-/* allocate extra space for more atoms and or residues */
-
-void t_atoms_set_resinfo(t_atoms *atoms, int atom_ind, struct t_symtab *symtab,
- const char *resname, int resnr, unsigned char ic,
- int chainnum, char chainid);
-/* Set the residue name, number, insertion code and chain identifier
- * of atom index atom_ind.
- */
-
-void free_t_atoms(t_atoms *atoms, gmx_bool bFreeNames);
-/* Free all the arrays and set the nr and nres to 0.
- * bFreeNames tells if to free the atom and residue name strings,
- * don't free them if they still need to be used in e.g. the topology struct.
- */
-
t_atoms *mtop2atoms(gmx_mtop_t *mtop);
/* generate a t_atoms struct for the system from gmx_mtop_t */
#ifndef GMX_LEGACYHEADERS_TOPOLOGY_H
#define GMX_LEGACYHEADERS_TOPOLOGY_H
-#include "atoms.h"
#include "idef.h"
#include "simple.h"
+#include "../../topology/atoms.h"
#include "../../topology/block.h"
#include "../../topology/symtab.h"
#ifndef GMX_PBCUTIL_RMPBC_H
#define GMX_PBCUTIL_RMPBC_H
-#include "../legacyheaders/types/atoms.h"
#include "../legacyheaders/types/idef.h"
#include "../fileio/trx.h"
#include "../math/vectypes.h"
extern "C" {
#endif
+struct t_atoms;
+
typedef struct gmx_rmpbc *gmx_rmpbc_t;
gmx_rmpbc_t gmx_rmpbc_init(t_idef *idef, int ePBC, int natoms);
void gmx_rmpbc_trxfr(gmx_rmpbc_t gpbc, t_trxframe *fr);
/* As gmx_rmpbc but operates on a t_trxframe data structure. */
-void rm_gropbc(t_atoms *atoms, rvec x[], matrix box);
+void rm_gropbc(struct t_atoms *atoms, rvec x[], matrix box);
/* Simple routine for use in analysis tools that just have a pdb or
* similar file.
*/
set(LIBGROMACS_SOURCES ${LIBGROMACS_SOURCES} ${TOPOLOGY_SOURCES} PARENT_SCOPE)
set(TOPOLOGY_PUBLIC_HEADERS
+ atoms.h
block.h
symtab.h)
--- /dev/null
+/*
+ * This file is part of the GROMACS molecular simulation package.
+ *
+ * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
+ * Copyright (c) 2001-2004, The GROMACS development team.
+ * Copyright (c) 2013,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.
+ *
+ * GROMACS is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1
+ * of the License, or (at your option) any later version.
+ *
+ * GROMACS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GROMACS; if not, see
+ * http://www.gnu.org/licenses, or write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * If you want to redistribute modifications to GROMACS, please
+ * consider that scientific software is very special. Version
+ * control is crucial - bugs must be traceable. We will be happy to
+ * consider code for inclusion in the official distribution, but
+ * derived work must not be called official GROMACS. Details are found
+ * in the README & COPYING files - if they are missing, get the
+ * official version at http://www.gromacs.org.
+ *
+ * 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/atoms.h"
+
+#include <cstring>
+
+#include "gromacs/topology/symtab.h"
+#include "gromacs/utility/smalloc.h"
+
+void init_atom(t_atoms *at)
+{
+ at->nr = 0;
+ at->nres = 0;
+ at->atom = NULL;
+ at->resinfo = NULL;
+ at->atomname = NULL;
+ at->atomtype = NULL;
+ at->atomtypeB = NULL;
+ at->pdbinfo = NULL;
+}
+
+void init_atomtypes(t_atomtypes *at)
+{
+ at->nr = 0;
+ at->radius = NULL;
+ at->vol = NULL;
+ at->atomnumber = NULL;
+ at->gb_radius = NULL;
+ at->S_hct = NULL;
+}
+
+void done_atom(t_atoms *at)
+{
+ at->nr = 0;
+ at->nres = 0;
+ sfree(at->atom);
+ sfree(at->resinfo);
+ sfree(at->atomname);
+ sfree(at->atomtype);
+ sfree(at->atomtypeB);
+ if (at->pdbinfo)
+ {
+ sfree(at->pdbinfo);
+ }
+}
+
+void done_atomtypes(t_atomtypes *atype)
+{
+ atype->nr = 0;
+ sfree(atype->radius);
+ sfree(atype->vol);
+ sfree(atype->surftens);
+ sfree(atype->atomnumber);
+ sfree(atype->gb_radius);
+ sfree(atype->S_hct);
+}
+
+void add_t_atoms(t_atoms *atoms, int natom_extra, int nres_extra)
+{
+ int i;
+
+ if (natom_extra > 0)
+ {
+ srenew(atoms->atomname, atoms->nr+natom_extra);
+ srenew(atoms->atom, atoms->nr+natom_extra);
+ if (NULL != atoms->pdbinfo)
+ {
+ srenew(atoms->pdbinfo, atoms->nr+natom_extra);
+ }
+ if (NULL != atoms->atomtype)
+ {
+ srenew(atoms->atomtype, atoms->nr+natom_extra);
+ }
+ if (NULL != atoms->atomtypeB)
+ {
+ srenew(atoms->atomtypeB, atoms->nr+natom_extra);
+ }
+ for (i = atoms->nr; (i < atoms->nr+natom_extra); i++)
+ {
+ atoms->atomname[i] = NULL;
+ memset(&atoms->atom[i], 0, sizeof(atoms->atom[i]));
+ if (NULL != atoms->pdbinfo)
+ {
+ std::memset(&atoms->pdbinfo[i], 0, sizeof(atoms->pdbinfo[i]));
+ }
+ if (NULL != atoms->atomtype)
+ {
+ atoms->atomtype[i] = NULL;
+ }
+ if (NULL != atoms->atomtypeB)
+ {
+ atoms->atomtypeB[i] = NULL;
+ }
+ }
+ atoms->nr += natom_extra;
+ }
+ if (nres_extra > 0)
+ {
+ srenew(atoms->resinfo, atoms->nres+nres_extra);
+ for (i = atoms->nres; (i < atoms->nres+nres_extra); i++)
+ {
+ std::memset(&atoms->resinfo[i], 0, sizeof(atoms->resinfo[i]));
+ }
+ atoms->nres += nres_extra;
+ }
+}
+
+void init_t_atoms(t_atoms *atoms, int natoms, gmx_bool bPdbinfo)
+{
+ atoms->nr = natoms;
+ atoms->nres = 0;
+ snew(atoms->atomname, natoms);
+ atoms->atomtype = NULL;
+ atoms->atomtypeB = NULL;
+ snew(atoms->resinfo, natoms);
+ snew(atoms->atom, natoms);
+ if (bPdbinfo)
+ {
+ snew(atoms->pdbinfo, natoms);
+ }
+ else
+ {
+ atoms->pdbinfo = NULL;
+ }
+}
+
+t_atoms *copy_t_atoms(t_atoms *src)
+{
+ t_atoms *dst;
+ int i;
+
+ snew(dst, 1);
+ init_t_atoms(dst, src->nr, (NULL != src->pdbinfo));
+ dst->nr = src->nr;
+ if (NULL != src->atomname)
+ {
+ snew(dst->atomname, src->nr);
+ }
+ if (NULL != src->atomtype)
+ {
+ snew(dst->atomtype, src->nr);
+ }
+ if (NULL != src->atomtypeB)
+ {
+ snew(dst->atomtypeB, src->nr);
+ }
+ for (i = 0; (i < src->nr); i++)
+ {
+ dst->atom[i] = src->atom[i];
+ if (NULL != src->pdbinfo)
+ {
+ dst->pdbinfo[i] = src->pdbinfo[i];
+ }
+ if (NULL != src->atomname)
+ {
+ dst->atomname[i] = src->atomname[i];
+ }
+ if (NULL != src->atomtype)
+ {
+ dst->atomtype[i] = src->atomtype[i];
+ }
+ if (NULL != src->atomtypeB)
+ {
+ dst->atomtypeB[i] = src->atomtypeB[i];
+ }
+ }
+ dst->nres = src->nres;
+ for (i = 0; (i < src->nres); i++)
+ {
+ dst->resinfo[i] = src->resinfo[i];
+ }
+ return dst;
+}
+
+void t_atoms_set_resinfo(t_atoms *atoms, int atom_ind, t_symtab *symtab,
+ const char *resname, int resnr, unsigned char ic,
+ int chainnum, char chainid)
+{
+ t_resinfo *ri;
+
+ ri = &atoms->resinfo[atoms->atom[atom_ind].resind];
+ ri->name = put_symtab(symtab, resname);
+ ri->rtp = NULL;
+ ri->nr = resnr;
+ ri->ic = ic;
+ ri->chainnum = chainnum;
+ ri->chainid = chainid;
+}
+
+void free_t_atoms(t_atoms *atoms, gmx_bool bFreeNames)
+{
+ int i;
+
+ if (bFreeNames && atoms->atomname != NULL)
+ {
+ for (i = 0; i < atoms->nr; i++)
+ {
+ if (atoms->atomname[i] != NULL)
+ {
+ sfree(*atoms->atomname[i]);
+ *atoms->atomname[i] = NULL;
+ }
+ }
+ }
+ if (bFreeNames && atoms->resinfo != NULL)
+ {
+ for (i = 0; i < atoms->nres; i++)
+ {
+ if (atoms->resinfo[i].name != NULL)
+ {
+ sfree(*atoms->resinfo[i].name);
+ *atoms->resinfo[i].name = NULL;
+ }
+ }
+ }
+ if (bFreeNames && atoms->atomtype != NULL)
+ {
+ for (i = 0; i < atoms->nr; i++)
+ {
+ if (atoms->atomtype[i] != NULL)
+ {
+ sfree(*atoms->atomtype[i]);
+ *atoms->atomtype[i] = NULL;
+ }
+ }
+ }
+ if (bFreeNames && atoms->atomtypeB != NULL)
+ {
+ for (i = 0; i < atoms->nr; i++)
+ {
+ if (atoms->atomtypeB[i] != NULL)
+ {
+ sfree(*atoms->atomtypeB[i]);
+ *atoms->atomtypeB[i] = NULL;
+ }
+ }
+ }
+ sfree(atoms->atomname);
+ sfree(atoms->atomtype);
+ sfree(atoms->atomtypeB);
+ sfree(atoms->resinfo);
+ sfree(atoms->atom);
+ sfree(atoms->pdbinfo);
+ atoms->nr = 0;
+ atoms->nres = 0;
+ atoms->atomname = NULL;
+ atoms->atomtype = NULL;
+ atoms->atomtypeB = NULL;
+ atoms->resinfo = NULL;
+ atoms->atom = NULL;
+ atoms->pdbinfo = NULL;
+}
*
* Copyright (c) 1991-2000, University of Groningen, The Netherlands.
* Copyright (c) 2001-2004, The GROMACS development team.
- * Copyright (c) 2012, by the GROMACS development team, led by
+ * Copyright (c) 2012,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.
* 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 _atoms_h
-#define _atoms_h
+#ifndef GMX_TOPOLOGY_ATOMS_H
+#define GMX_TOPOLOGY_ATOMS_H
-
-#include "simple.h"
+#include "../utility/basedefinitions.h"
+#include "../utility/real.h"
#ifdef __cplusplus
extern "C" {
#endif
+struct t_symtab;
+
enum {
eptAtom, eptNucleus, eptShell, eptBond, eptVSite, eptNR
};
/* The particle type */
-typedef struct {
+typedef struct t_atom
+{
real m, q; /* Mass and charge */
real mB, qB; /* Mass and charge for Free Energy calc */
unsigned short type; /* Atom type */
char elem[4]; /* Element name */
} t_atom;
-typedef struct {
+typedef struct t_resinfo
+{
char **name; /* Pointer to the residue name */
int nr; /* Residue number */
unsigned char ic; /* Code for insertion of residues */
char **rtp; /* rtp building block name (optional) */
} t_resinfo;
-typedef struct {
+typedef struct t_pdbinfo
+{
int type; /* PDB record name */
int atomnr; /* PDB atom number */
char altloc; /* Alternate location indicator */
int uij[6]; /* Anisotropic B-factor */
} t_pdbinfo;
-typedef struct {
+typedef struct t_grps
+{
int nr; /* Number of different groups */
int *nm_ind; /* Index in the group names */
} t_grps;
-typedef struct {
+typedef struct t_atoms
+{
int nr; /* Nr of atoms */
t_atom *atom; /* Array of atoms (dim: nr) */
/* The following entries will not */
t_pdbinfo *pdbinfo; /* PDB Information, such as aniso. Bfac */
} t_atoms;
-typedef struct {
+typedef struct t_atomtypes
+{
int nr; /* number of atomtypes */
real *radius; /* GBSA radius for each atomtype */
real *vol; /* GBSA efective volume for each atomtype */
int *atomnumber; /* Atomic number, used for QM/MM */
} t_atomtypes;
-
#define PERTURBED(a) (((a).mB != (a).m) || ((a).qB != (a).q) || ((a).typeB != (a).type))
+void init_atom(t_atoms *at);
+void init_atomtypes(t_atomtypes *at);
+void done_atom(t_atoms *at);
+void done_atomtypes(t_atomtypes *at);
+
+void init_t_atoms(t_atoms *atoms, int natoms, gmx_bool bPdbinfo);
+/* allocate memory for the arrays, set nr to natoms and nres to 0
+ * set pdbinfo to NULL or allocate memory for it */
+
+t_atoms *copy_t_atoms(t_atoms *src);
+/* copy an atoms struct from src to a new one */
+
+void add_t_atoms(t_atoms *atoms, int natom_extra, int nres_extra);
+/* allocate extra space for more atoms and or residues */
+
+void t_atoms_set_resinfo(t_atoms *atoms, int atom_ind, struct t_symtab *symtab,
+ const char *resname, int resnr, unsigned char ic,
+ int chainnum, char chainid);
+/* Set the residue name, number, insertion code and chain identifier
+ * of atom index atom_ind.
+ */
+
+void free_t_atoms(t_atoms *atoms, gmx_bool bFreeNames);
+/* Free all the arrays and set the nr and nres to 0.
+ * bFreeNames tells if to free the atom and residue name strings,
+ * don't free them if they still need to be used in e.g. the topology struct.
+ */
+
#ifdef __cplusplus
}
#endif