2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5 * Copyright (c) 2001-2004, The GROMACS development team.
6 * Copyright (c) 2013,2014,2015,2018,2019, by the GROMACS development team, led by
7 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8 * and including many others, as listed in the AUTHORS file in the
9 * top-level source directory and at http://www.gromacs.org.
11 * GROMACS is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public License
13 * as published by the Free Software Foundation; either version 2.1
14 * of the License, or (at your option) any later version.
16 * GROMACS is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with GROMACS; if not, see
23 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 * If you want to redistribute modifications to GROMACS, please
27 * consider that scientific software is very special. Version
28 * control is crucial - bugs must be traceable. We will be happy to
29 * consider code for inclusion in the official distribution, but
30 * derived work must not be called official GROMACS. Details are found
31 * in the README & COPYING files - if they are missing, get the
32 * official version at http://www.gromacs.org.
34 * To help us fund GROMACS development, we humbly ask that you cite
35 * the research papers on the package. Check out http://www.gromacs.org.
39 * Methods to modify atoms during preprocessing.
41 #ifndef GMX_GMXPREPROCESS_HACKBLOCK_H
42 #define GMX_GMXPREPROCESS_HACKBLOCK_H
49 #include "gromacs/gmxpreprocess/notset.h"
50 #include "gromacs/topology/ifunc.h"
51 #include "gromacs/utility/arrayref.h"
56 * Used for reading .rtp/.tdb
57 * ebtsBONDS must be the first, new types can be added to the end
58 * these *MUST* correspond to the arrays in hackblock.cpp
61 ebtsBONDS
, ebtsANGLES
, ebtsPDIHS
, ebtsIDIHS
, ebtsEXCLS
, ebtsCMAP
, ebtsNR
63 //! Names for interaction type entries
64 extern const char *btsNames
[ebtsNR
];
65 //! Numbers for atoms in the interactions.
66 extern const int btsNiatoms
[ebtsNR
];
68 /* if changing any of these structs, make sure that all of the
69 free/clear/copy/merge_t_* functions stay updated */
71 /*! \libinternal \brief
72 * Information about single bonded interaction.
74 struct BondedInteraction
76 //! Atom names in the bond.
77 std::array
<std::string
, MAXATOMLIST
> a
;
79 * Optional define string which gets copied from
80 * .rtp/.tdb to .top and will be parsed by cpp
84 //! Has the entry been found?
86 //! Get name of first atom in bonded interaction.
87 const std::string
&ai() const { return a
[0]; }
88 //! Get name of second atom in bonded interaction..
89 const std::string
&aj() const { return a
[1]; }
90 //! Get name of third atom in bonded interaction.
91 const std::string
&ak() const { return a
[2]; }
92 //! Get name of fourth atom in bonded interaction.
93 const std::string
&al() const { return a
[3]; }
94 //! Get name of fifth atom in bonded interaction.
95 const std::string
&am() const { return a
[4]; }
98 /*! \libinternal \brief
99 * Accumulation of different bonded types for preprocessing.
100 * \todo This should be merged with BondedInteraction.
102 struct BondedInteractionList
104 //! The type of bonded interaction.
106 //! The actual bonded interactions.
107 std::vector
<BondedInteraction
> b
;
110 /*! \libinternal \brief
111 * Information about preprocessing residues.
113 struct PreprocessResidue
115 //! Name of the residue.
117 //! The base file name this rtp entry was read from.
118 std::string filebase
;
120 std::vector
<t_atom
> atom
;
122 std::vector
<char **> atomname
;
123 //! Charge group numbers.
124 std::vector
<int> cgnr
;
125 //! Delete autogenerated dihedrals or not.
126 bool bKeepAllGeneratedDihedrals
= false;
127 //! Number of bonded exclusions.
129 //! If Hydrogen only 1-4 interactions should be generated.
130 bool bGenerateHH14Interactions
= false;
131 //! Delete dihedrals also defined by impropers.
132 bool bRemoveDihedralIfWithImproper
= false;
133 //! List of bonded interactions to potentially add.
134 std::array
<BondedInteractionList
, ebtsNR
> rb
;
135 //! Get number of atoms in residue.
136 int natom() const { return atom
.size(); }
139 //! Declare different types of hacks for later check.
140 enum class MoleculePatchType
142 //! Hack adds atom to structure/rtp.
144 //! Hack deletes atom.
146 //! Hack replaces atom.
150 /*! \libinternal \brief
151 * Block to modify individual residues
155 //! Number of new are deleted atoms. NOT always equal to atom.size()!
157 //! Old name for entry.
159 //! New name for entry.
162 std::vector
<t_atom
> atom
;
163 //! Chargegroup number.
165 //! Type of attachement.
167 //! Number of control atoms.
169 //! Name of control atoms.
170 std::array
<std::string
, 4> a
;
171 //! Is an atom to be hacked already present?
172 bool bAlreadyPresent
= false;
173 //! Are coordinates for a new atom already set?
175 //! New position for hacked atom.
176 rvec newx
= {NOTSET
};
177 //! New atom index number after additions.
183 * This depends on the setting of oname and nname
184 * for legacy reasons. If oname is empty, we are adding,
185 * if oname is set and nname is empty, an atom is deleted,
186 * if both are set replacement is going on. If both are unset,
187 * an error is thrown.
189 MoleculePatchType
type() const;
191 //! Control atom i name.
192 const std::string
&ai() const { return a
[0]; }
193 //! Control atom j name.
194 const std::string
&aj() const { return a
[1]; }
195 //! Control atom k name.
196 const std::string
&ak() const { return a
[2]; }
197 //! Control atom l name.
198 const std::string
&al() const { return a
[3]; }
200 /*! \libinternal \brief
201 * A set of modifications to apply to atoms.
203 struct MoleculePatchDatabase
207 //! File that entry was read from.
208 std::string filebase
;
209 //! List of changes to atoms.
210 std::vector
<MoleculePatch
> hack
;
211 //! List of bonded interactions to potentially add.
212 std::array
<BondedInteractionList
, ebtsNR
> rb
;
213 //! Number of atoms to modify
214 int nhack() const { return hack
.size(); }
218 * Reset modification block.
220 * \param[inout] globalPatches Block to reset.
221 * \todo Remove once constructor/destructor takes care of all of this.
223 void clearModificationBlock(MoleculePatchDatabase
*globalPatches
);
226 * Copy residue information.
228 * \param[in] s Source information.
229 * \param[in] d Destination to copy to.
230 * \param[inout] symtab Symbol table for names.
231 * \todo Remove once copy can be done directly.
233 void copyPreprocessResidues(const PreprocessResidue
&s
, PreprocessResidue
*d
, t_symtab
*symtab
);
236 * Add bond information in \p s to \p d.
238 * \param[in] s Source information to copy.
239 * \param[inout] d Destination to copy to.
240 * \param[in] bMin don't copy bondeds with atoms starting with '-'.
241 * \param[in] bPlus don't copy bondeds with atoms starting with '+'.
242 * \returns if bonds were removed at the termini.
244 bool mergeBondedInteractionList(gmx::ArrayRef
<const BondedInteractionList
> s
,
245 gmx::ArrayRef
<BondedInteractionList
> d
,
246 bool bMin
, bool bPlus
);
249 * Copy all information from datastructure.
251 * \param[in] s Source information.
252 * \param[inout] d Destination to copy to.
254 void copyModificationBlocks(const MoleculePatchDatabase
&s
, MoleculePatchDatabase
*d
);
257 * Add the individual modifications in \p s to \p d.
259 * \param[in] s Source information.
260 * \param[inout] d Destination to copy to.
262 void mergeAtomModifications(const MoleculePatchDatabase
&s
, MoleculePatchDatabase
*d
);
264 //! \copydoc mergeAtomModifications
265 void mergeAtomAndBondModifications(const MoleculePatchDatabase
&s
, MoleculePatchDatabase
*d
);