OpenStructure
Loading...
Searching...
No Matches
forcefield.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19
20#ifndef OST_MM_FORCE_FIELD_HH
21#define OST_MM_FORCE_FIELD_HH
22
23#include <vector>
24#include <algorithm>
25
26
27#include <boost/shared_ptr.hpp>
28#include <boost/unordered_map.hpp>
29
30#include <ost/message.hh>
35
36namespace ost { namespace mol{ namespace mm{
37
38struct ResidueNames;
39class Forcefield;
40
41typedef boost::shared_ptr<ResidueNames> ResidueNamesPtr;
42typedef boost::shared_ptr<ost::mol::mm::Forcefield> ForcefieldPtr;
43
45
47
49 main(a),nter(b),cter(c),twoter(d) { }
50
55
56 bool Contains(const String& name){
57 return name == main || name == nter || name == cter || name == twoter;
58 }
59
60 template <typename DS>
61 void Serialize(DS& ds){
62 ds & main;
63 ds & nter;
64 ds & cter;
65 ds & twoter;
66 }
67};
68
69
71public:
72
73 Forcefield(): gen_pairs_(true), fudge_LJ_(1.0),fudge_QQ_(1.0) { }
74
75 static ForcefieldPtr Load(const String& filename);
76
77 void Save(const String& filename);
78
79 //Getter functions
80
82
83 BlockModifierPtr GetBlockModifier(const String& modifier_name) const;
84
85 std::vector<String> GetBuildingBlockNames() const;
86
87 String GetAtomType(const String& res_name, const String& atom_name) const;
88
90
91 BlockModifierPtr GetNTerModifier(const String& res_name, const String& ter_name = "") const;
92
93 BlockModifierPtr GetCTerModifier(const String& res_name, const String& ter_name = "") const;
94
96 const String& type2) const;
97
99 const String& type2,
100 const String& type3) const;
101
102 std::vector<InteractionPtr> GetDihedrals(const String& type1,
103 const String& type2,
104 const String& type3,
105 const String& type4) const;
106
107 std::vector<InteractionPtr> GetImpropers(const String& type1,
108 const String& type2,
109 const String& type3,
110 const String& type4) const;
111
113 const String& type2,
114 const String& type3,
115 const String& type4,
116 const String& type5) const;
117
119
121 const String& type2,
122 bool pair=false) const;
123
124 InteractionPtr GetLJ(const String& type) const;
125
127 const String& type2);
128
129 Real GetMass(const String& type) const;
130
131 Real GetFudgeLJ() const { return fudge_LJ_; }
132
133 Real GetFudgeQQ() const { return fudge_QQ_; }
134
135 //functions to add interactions and settings
136
137 void AddBuildingBlock(const String& name, BuildingBlockPtr p) { building_blocks_[name] = p; }
138
140
142
144
146
148
150
152
154
156
157 void AddMass(const String& type, Real mass) { atom_masses_[type] = mass; }
158
159 void SetFudgeLJ(Real f_lj) { fudge_LJ_ = f_lj; }
160
161 void SetFudgeQQ(Real f_qq) { fudge_QQ_ = f_qq; }
162
163 void SetGenPairs(bool gen_pairs) { gen_pairs_ = gen_pairs; }
164
166 const String& ff_main_name,
167 const String& ff_n_ter_name,
168 const String& ff_c_ter_name,
169 const String& ff_two_ter_name);
170
171 void AddAtomRenamingRule(const String& res_name,
172 const String& old_atom_name,
173 const String& new_atom_name);
174
176
178
180
182
183 String GetAtomRenaming(const String& res_name, const String& atom_name) const;
184
186 hydrogen_constructors_[residue_name] = p;
187 }
188
189 void AddBlockModifier(const String& modifier_name,
190 BlockModifierPtr p) { block_modifiers_[modifier_name] = p; }
191
192 void SetStandardCTer(const String& res_name, const String& ter_name) { standard_c_termini_[res_name] = ter_name; }
193
194 void SetStandardNTer(const String& res_name, const String& ter_name) { standard_n_termini_[res_name] = ter_name; }
195
196
197 //Renaming to the forcefield specific names (residues/atoms)
198 void AssignFFSpecificNames(ost::mol::EntityHandle& handle, bool reverse=false) const;
199
200 // get renaming rules (for data extraction)
201 bool HasAtomRenamingRules(const String& res_name) const {
202 return (atom_renaming_ff_specific_.find(res_name)
203 != atom_renaming_ff_specific_.end());
204 }
205 typedef std::vector<std::pair<String,String> > AtomRenamingType;
206 const AtomRenamingType& GetAtomRenamingRules(const String& res_name) const;
207
208private:
209
210 String AtomTypesToKeyword(std::vector<String>& types, bool allow_reordering = true) const;
211 void CheckInteractionToAdd(InteractionPtr p, const String& interaction_type) const;
212
213 //this is all nonbonded stuff
214 bool gen_pairs_;
215 Real fudge_LJ_;
216 Real fudge_QQ_;
217
218 boost::unordered_map<String, Real> atom_masses_;
219 boost::unordered_map<String, BuildingBlockPtr> building_blocks_;
220 boost::unordered_map<String, BlockModifierPtr> block_modifiers_;
221
222 //the standard interactions
223 boost::unordered_map<String,InteractionPtr> bonds_;
224 boost::unordered_map<String,InteractionPtr> angles_;
225 boost::unordered_map<String,InteractionPtr> lj_14_pairs_;
226 boost::unordered_map<String,InteractionPtr> constraints_;
227 boost::unordered_map<String,InteractionPtr> cmaps_;
228 boost::unordered_map<String,InteractionPtr> implicit_genborn_;
229 boost::unordered_map<String,InteractionPtr> ljs_;
230 boost::unordered_map<String,std::vector<InteractionPtr> > dihedrals_;
231 boost::unordered_map<String,std::vector<InteractionPtr> > improper_dihedrals_;
232
233 boost::unordered_map<String, AtomRenamingType> atom_renaming_ff_specific_;
234 boost::unordered_map<String, ResidueNamesPtr> res_renaming_ff_specific_;
235
236 boost::unordered_map<String, HydrogenConstructorPtr> hydrogen_constructors_;
237 boost::unordered_map<String, String> standard_n_termini_;
238 boost::unordered_map<String, String> standard_c_termini_;
239};
240
241}}}//ns
242
243#endif
Protein or molecule.
void AddResidueRenamingRule(const String &name, const String &ff_main_name, const String &ff_n_ter_name, const String &ff_c_ter_name, const String &ff_two_ter_name)
InteractionPtr GetImplicitGenborn(const String &type1) const
String GetResidueRenamingTwoTer(const String &name) const
std::vector< String > GetBuildingBlockNames() const
BlockModifierPtr GetBlockModifier(const String &modifier_name) const
void AddBlockModifier(const String &modifier_name, BlockModifierPtr p)
InteractionPtr GetBond(const String &type1, const String &type2) const
BuildingBlockPtr GetBuildingBlock(const String &name) const
bool HasAtomRenamingRules(const String &res_name) const
String GetAtomType(const String &res_name, const String &atom_name) const
void AddImproper(InteractionPtr p)
void AddCMap(InteractionPtr p)
void SetFudgeLJ(Real f_lj)
BlockModifierPtr GetCTerModifier(const String &res_name, const String &ter_name="") const
void SetFudgeQQ(Real f_qq)
std::vector< InteractionPtr > GetDihedrals(const String &type1, const String &type2, const String &type3, const String &type4) const
String GetResidueRenamingCTer(const String &name) const
String GetResidueRenamingNTer(const String &name) const
String GetResidueRenamingMain(const String &name) const
void AddImplicitGenborn(InteractionPtr p)
void SetStandardNTer(const String &res_name, const String &ter_name)
static ForcefieldPtr Load(const String &filename)
BlockModifierPtr GetNTerModifier(const String &res_name, const String &ter_name="") const
HydrogenConstructorPtr GetHydrogenConstructor(const String &name) const
const AtomRenamingType & GetAtomRenamingRules(const String &res_name) const
InteractionPtr GetLJ(const String &type) const
void AddAngle(InteractionPtr p)
void AddDihedral(InteractionPtr p)
Real GetMass(const String &type) const
void SetStandardCTer(const String &res_name, const String &ter_name)
void AddLJ(InteractionPtr p)
void Save(const String &filename)
void AddConstraint(InteractionPtr p)
InteractionPtr GetLJ(const String &type1, const String &type2, bool pair=false) const
void AssignFFSpecificNames(ost::mol::EntityHandle &handle, bool reverse=false) const
String GetAtomRenaming(const String &res_name, const String &atom_name) const
void AddBond(InteractionPtr p)
void AddMass(const String &type, Real mass)
InteractionPtr GetCMap(const String &type1, const String &type2, const String &type3, const String &type4, const String &type5) const
void AddBuildingBlock(const String &name, BuildingBlockPtr p)
void SetGenPairs(bool gen_pairs)
void AddAtomRenamingRule(const String &res_name, const String &old_atom_name, const String &new_atom_name)
void AddLJPair(InteractionPtr p)
std::vector< InteractionPtr > GetImpropers(const String &type1, const String &type2, const String &type3, const String &type4) const
InteractionPtr GetAngle(const String &type1, const String &type2, const String &type3) const
void AddHydrogenConstructor(const String &residue_name, HydrogenConstructorPtr p)
InteractionPtr GetConstraint(const String &type1, const String &type2)
std::vector< std::pair< String, String > > AtomRenamingType
float Real
Definition base.hh:44
std::string String
Definition base.hh:54
boost::shared_ptr< BuildingBlock > BuildingBlockPtr
boost::shared_ptr< BlockModifier > BlockModifierPtr
boost::shared_ptr< ost::mol::mm::Forcefield > ForcefieldPtr
Definition forcefield.hh:42
boost::shared_ptr< HydrogenConstructor > HydrogenConstructorPtr
boost::shared_ptr< Interaction > InteractionPtr
boost::shared_ptr< ResidueNames > ResidueNamesPtr
Definition forcefield.hh:41
Definition base.dox:1
bool Contains(const String &name)
Definition forcefield.hh:56
ResidueNames(String a, String b, String c, String d)
Definition forcefield.hh:48
structure