00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OST_MM_FORCE_FIELD_HH
00021 #define OST_MM_FORCE_FIELD_HH
00022
00023 #include <vector>
00024 #include <algorithm>
00025
00026
00027 #include <boost/shared_ptr.hpp>
00028 #include <boost/unordered_map.hpp>
00029
00030 #include <ost/message.hh>
00031 #include <ost/mol/mm/buildingblock.hh>
00032 #include <ost/mol/mm/interaction.hh>
00033 #include <ost/mol/mm/block_modifiers.hh>
00034 #include <ost/mol/mm/gromacs_block_modifiers.hh>
00035
00036 namespace ost { namespace mol{ namespace mm{
00037
00038 struct ResidueNames;
00039 class Forcefield;
00040
00041 typedef boost::shared_ptr<ResidueNames> ResidueNamesPtr;
00042 typedef boost::shared_ptr<ost::mol::mm::Forcefield> ForcefieldPtr;
00043
00044 struct ResidueNames{
00045
00046 ResidueNames() { };
00047
00048 ResidueNames(String a, String b, String c, String d):
00049 main(a),nter(b),cter(c),twoter(d) { }
00050
00051 String main;
00052 String nter;
00053 String cter;
00054 String twoter;
00055
00056 bool Contains(const String& name){
00057 return name == main || name == nter || name == cter || name == twoter;
00058 }
00059
00060 template <typename DS>
00061 void Serialize(DS& ds){
00062 ds & main;
00063 ds & nter;
00064 ds & cter;
00065 ds & twoter;
00066 }
00067 };
00068
00069
00070 class Forcefield {
00071 public:
00072
00073 Forcefield(): gen_pairs_(true), fudge_LJ_(1.0),fudge_QQ_(1.0) { }
00074
00075 static ForcefieldPtr Load(const String& filename);
00076
00077 void Save(const String& filename);
00078
00079
00080
00081 BuildingBlockPtr GetBuildingBlock(const String& name) const;
00082
00083 BlockModifierPtr GetBlockModifier(const String& modifier_name) const;
00084
00085 String GetAtomType(const String& res_name, const String& atom_name) const;
00086
00087 HydrogenConstructorPtr GetHydrogenConstructor(const String& name) const;
00088
00089 BlockModifierPtr GetNTerModifier(const String& res_name, const String& ter_name = "") const;
00090
00091 BlockModifierPtr GetCTerModifier(const String& res_name, const String& ter_name = "") const;
00092
00093 InteractionPtr GetBond(const String& type1,
00094 const String& type2) const;
00095
00096 InteractionPtr GetAngle(const String& type1,
00097 const String& type2,
00098 const String& type3) const;
00099
00100 std::vector<InteractionPtr> GetDihedrals(const String& type1,
00101 const String& type2,
00102 const String& type3,
00103 const String& type4) const;
00104
00105 std::vector<InteractionPtr> GetImpropers(const String& type1,
00106 const String& type2,
00107 const String& type3,
00108 const String& type4) const;
00109
00110 InteractionPtr GetCMap(const String& type1,
00111 const String& type2,
00112 const String& type3,
00113 const String& type4,
00114 const String& type5) const;
00115
00116 InteractionPtr GetImplicitGenborn(const String& type1) const;
00117
00118 InteractionPtr GetLJ(const String& type1,
00119 const String& type2,
00120 bool pair=false) const;
00121
00122 InteractionPtr GetLJ(const String& type) const;
00123
00124 InteractionPtr GetConstraint(const String& type1,
00125 const String& type2);
00126
00127 Real GetMass(const String& type) const;
00128
00129 Real GetFudgeLJ() const { return fudge_LJ_; }
00130
00131 Real GetFudgeQQ() const { return fudge_QQ_; }
00132
00133
00134
00135 void AddBuildingBlock(const String& name, BuildingBlockPtr p) { building_blocks_[name] = p; }
00136
00137 void AddBond(InteractionPtr p);
00138
00139 void AddAngle(InteractionPtr p);
00140
00141 void AddDihedral(InteractionPtr p);
00142
00143 void AddImproper(InteractionPtr p);
00144
00145 void AddCMap(InteractionPtr p);
00146
00147 void AddImplicitGenborn(InteractionPtr p);
00148
00149 void AddLJ(InteractionPtr p);
00150
00151 void AddLJPair(InteractionPtr p);
00152
00153 void AddConstraint(InteractionPtr p);
00154
00155 void AddMass(const String& type, Real mass) { atom_masses_[type] = mass; }
00156
00157 void SetFudgeLJ(Real f_lj) { fudge_LJ_ = f_lj; }
00158
00159 void SetFudgeQQ(Real f_qq) { fudge_QQ_ = f_qq; }
00160
00161 void SetGenPairs(bool gen_pairs) { gen_pairs_ = gen_pairs; }
00162
00163 void AddResidueRenamingRule(const String& name,
00164 const String& ff_main_name,
00165 const String& ff_n_ter_name,
00166 const String& ff_c_ter_name,
00167 const String& ff_two_ter_name);
00168
00169 void AddAtomRenamingRule(const String& res_name,
00170 const String& old_atom_name,
00171 const String& new_atom_name);
00172
00173 String GetResidueRenamingMain(const String& name) const;
00174
00175 String GetResidueRenamingNTer(const String& name) const;
00176
00177 String GetResidueRenamingCTer(const String& name) const;
00178
00179 String GetResidueRenamingTwoTer(const String& name) const;
00180
00181 String GetAtomRenaming(const String& res_name, const String& atom_name) const;
00182
00183 void AddHydrogenConstructor(const String& residue_name, HydrogenConstructorPtr p){
00184 hydrogen_constructors_[residue_name] = p;
00185 }
00186
00187 void AddBlockModifier(const String& modifier_name,
00188 BlockModifierPtr p) { block_modifiers_[modifier_name] = p; }
00189
00190 void SetStandardCTer(const String& res_name, const String& ter_name) { standard_c_termini_[res_name] = ter_name; }
00191
00192 void SetStandardNTer(const String& res_name, const String& ter_name) { standard_n_termini_[res_name] = ter_name; }
00193
00194
00195
00196 void AssignFFSpecificNames(ost::mol::EntityHandle& handle, bool reverse=false) const;
00197
00198
00199 bool HasAtomRenamingRules(const String& res_name) const {
00200 return (atom_renaming_ff_specific_.find(res_name)
00201 != atom_renaming_ff_specific_.end());
00202 }
00203 typedef std::vector<std::pair<String,String> > AtomRenamingType;
00204 const AtomRenamingType& GetAtomRenamingRules(const String& res_name) const;
00205
00206 private:
00207
00208 String AtomTypesToKeyword(std::vector<String>& types, bool allow_reordering = true) const;
00209 void CheckInteractionToAdd(InteractionPtr p, const String& interaction_type) const;
00210
00211
00212 bool gen_pairs_;
00213 Real fudge_LJ_;
00214 Real fudge_QQ_;
00215
00216 boost::unordered_map<String, Real> atom_masses_;
00217 boost::unordered_map<String, BuildingBlockPtr> building_blocks_;
00218 boost::unordered_map<String, BlockModifierPtr> block_modifiers_;
00219
00220
00221 boost::unordered_map<String,InteractionPtr> bonds_;
00222 boost::unordered_map<String,InteractionPtr> angles_;
00223 boost::unordered_map<String,InteractionPtr> lj_14_pairs_;
00224 boost::unordered_map<String,InteractionPtr> constraints_;
00225 boost::unordered_map<String,InteractionPtr> cmaps_;
00226 boost::unordered_map<String,InteractionPtr> implicit_genborn_;
00227 boost::unordered_map<String,InteractionPtr> ljs_;
00228 boost::unordered_map<String,std::vector<InteractionPtr> > dihedrals_;
00229 boost::unordered_map<String,std::vector<InteractionPtr> > improper_dihedrals_;
00230
00231 boost::unordered_map<String, AtomRenamingType> atom_renaming_ff_specific_;
00232 boost::unordered_map<String, ResidueNamesPtr> res_renaming_ff_specific_;
00233
00234 boost::unordered_map<String, HydrogenConstructorPtr> hydrogen_constructors_;
00235 boost::unordered_map<String, String> standard_n_termini_;
00236 boost::unordered_map<String, String> standard_c_termini_;
00237 };
00238
00239 }}}
00240
00241 #endif