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 std::vector<String> GetBuildingBlockNames() const;
00086
00087 String GetAtomType(const String& res_name, const String& atom_name) const;
00088
00089 HydrogenConstructorPtr GetHydrogenConstructor(const String& name) const;
00090
00091 BlockModifierPtr GetNTerModifier(const String& res_name, const String& ter_name = "") const;
00092
00093 BlockModifierPtr GetCTerModifier(const String& res_name, const String& ter_name = "") const;
00094
00095 InteractionPtr GetBond(const String& type1,
00096 const String& type2) const;
00097
00098 InteractionPtr GetAngle(const String& type1,
00099 const String& type2,
00100 const String& type3) const;
00101
00102 std::vector<InteractionPtr> GetDihedrals(const String& type1,
00103 const String& type2,
00104 const String& type3,
00105 const String& type4) const;
00106
00107 std::vector<InteractionPtr> GetImpropers(const String& type1,
00108 const String& type2,
00109 const String& type3,
00110 const String& type4) const;
00111
00112 InteractionPtr GetCMap(const String& type1,
00113 const String& type2,
00114 const String& type3,
00115 const String& type4,
00116 const String& type5) const;
00117
00118 InteractionPtr GetImplicitGenborn(const String& type1) const;
00119
00120 InteractionPtr GetLJ(const String& type1,
00121 const String& type2,
00122 bool pair=false) const;
00123
00124 InteractionPtr GetLJ(const String& type) const;
00125
00126 InteractionPtr GetConstraint(const String& type1,
00127 const String& type2);
00128
00129 Real GetMass(const String& type) const;
00130
00131 Real GetFudgeLJ() const { return fudge_LJ_; }
00132
00133 Real GetFudgeQQ() const { return fudge_QQ_; }
00134
00135
00136
00137 void AddBuildingBlock(const String& name, BuildingBlockPtr p) { building_blocks_[name] = p; }
00138
00139 void AddBond(InteractionPtr p);
00140
00141 void AddAngle(InteractionPtr p);
00142
00143 void AddDihedral(InteractionPtr p);
00144
00145 void AddImproper(InteractionPtr p);
00146
00147 void AddCMap(InteractionPtr p);
00148
00149 void AddImplicitGenborn(InteractionPtr p);
00150
00151 void AddLJ(InteractionPtr p);
00152
00153 void AddLJPair(InteractionPtr p);
00154
00155 void AddConstraint(InteractionPtr p);
00156
00157 void AddMass(const String& type, Real mass) { atom_masses_[type] = mass; }
00158
00159 void SetFudgeLJ(Real f_lj) { fudge_LJ_ = f_lj; }
00160
00161 void SetFudgeQQ(Real f_qq) { fudge_QQ_ = f_qq; }
00162
00163 void SetGenPairs(bool gen_pairs) { gen_pairs_ = gen_pairs; }
00164
00165 void AddResidueRenamingRule(const String& name,
00166 const String& ff_main_name,
00167 const String& ff_n_ter_name,
00168 const String& ff_c_ter_name,
00169 const String& ff_two_ter_name);
00170
00171 void AddAtomRenamingRule(const String& res_name,
00172 const String& old_atom_name,
00173 const String& new_atom_name);
00174
00175 String GetResidueRenamingMain(const String& name) const;
00176
00177 String GetResidueRenamingNTer(const String& name) const;
00178
00179 String GetResidueRenamingCTer(const String& name) const;
00180
00181 String GetResidueRenamingTwoTer(const String& name) const;
00182
00183 String GetAtomRenaming(const String& res_name, const String& atom_name) const;
00184
00185 void AddHydrogenConstructor(const String& residue_name, HydrogenConstructorPtr p){
00186 hydrogen_constructors_[residue_name] = p;
00187 }
00188
00189 void AddBlockModifier(const String& modifier_name,
00190 BlockModifierPtr p) { block_modifiers_[modifier_name] = p; }
00191
00192 void SetStandardCTer(const String& res_name, const String& ter_name) { standard_c_termini_[res_name] = ter_name; }
00193
00194 void SetStandardNTer(const String& res_name, const String& ter_name) { standard_n_termini_[res_name] = ter_name; }
00195
00196
00197
00198 void AssignFFSpecificNames(ost::mol::EntityHandle& handle, bool reverse=false) const;
00199
00200
00201 bool HasAtomRenamingRules(const String& res_name) const {
00202 return (atom_renaming_ff_specific_.find(res_name)
00203 != atom_renaming_ff_specific_.end());
00204 }
00205 typedef std::vector<std::pair<String,String> > AtomRenamingType;
00206 const AtomRenamingType& GetAtomRenamingRules(const String& res_name) const;
00207
00208 private:
00209
00210 String AtomTypesToKeyword(std::vector<String>& types, bool allow_reordering = true) const;
00211 void CheckInteractionToAdd(InteractionPtr p, const String& interaction_type) const;
00212
00213
00214 bool gen_pairs_;
00215 Real fudge_LJ_;
00216 Real fudge_QQ_;
00217
00218 boost::unordered_map<String, Real> atom_masses_;
00219 boost::unordered_map<String, BuildingBlockPtr> building_blocks_;
00220 boost::unordered_map<String, BlockModifierPtr> block_modifiers_;
00221
00222
00223 boost::unordered_map<String,InteractionPtr> bonds_;
00224 boost::unordered_map<String,InteractionPtr> angles_;
00225 boost::unordered_map<String,InteractionPtr> lj_14_pairs_;
00226 boost::unordered_map<String,InteractionPtr> constraints_;
00227 boost::unordered_map<String,InteractionPtr> cmaps_;
00228 boost::unordered_map<String,InteractionPtr> implicit_genborn_;
00229 boost::unordered_map<String,InteractionPtr> ljs_;
00230 boost::unordered_map<String,std::vector<InteractionPtr> > dihedrals_;
00231 boost::unordered_map<String,std::vector<InteractionPtr> > improper_dihedrals_;
00232
00233 boost::unordered_map<String, AtomRenamingType> atom_renaming_ff_specific_;
00234 boost::unordered_map<String, ResidueNamesPtr> res_renaming_ff_specific_;
00235
00236 boost::unordered_map<String, HydrogenConstructorPtr> hydrogen_constructors_;
00237 boost::unordered_map<String, String> standard_n_termini_;
00238 boost::unordered_map<String, String> standard_c_termini_;
00239 };
00240
00241 }}}
00242
00243 #endif