00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef OST_MM_INTERACTION_HH
00021 #define OST_MM_INTERACTION_HH
00022
00023 #include <vector>
00024 #include <fstream>
00025
00026 #include <boost/shared_ptr.hpp>
00027 #include <boost/filesystem.hpp>
00028
00029 #include <ost/io/binary_data_source.hh>
00030 #include <ost/io/binary_data_sink.hh>
00031 #include <ost/io/io_exception.hh>
00032 #include <ost/message.hh>
00033 #include <ost/mol/atom_handle.hh>
00034 #include <ost/mol/residue_handle.hh>
00035
00036
00037 namespace ost { namespace mol{ namespace mm{
00038
00039 class Interaction;
00040 typedef boost::shared_ptr<Interaction> InteractionPtr;
00041
00042 enum FuncType{
00043 Invalid,
00044 HarmonicBond,
00045 HarmonicAngle,
00046 UreyBradleyAngle,
00047 PeriodicDihedral,
00048 PeriodicImproper,
00049 HarmonicImproper,
00050 CMap,
00051 LJ,
00052 LJPair,
00053 GBSA,
00054 DistanceConstraint,
00055 Exclusion,
00056 HarmonicPositionRestraint,
00057 HarmonicDistanceRestraint
00058 };
00059
00060 class Interaction{
00061
00062 public:
00063 Interaction(FuncType func_type);
00064
00065 void SetTypes(std::vector<String> types);
00066
00067 void SetNames(std::vector<String> names);
00068
00069 void SetParam(std::vector<Real>& parameters);
00070
00071 std::vector<String> GetTypes() const { return atom_types_; }
00072
00073 std::vector<String> GetNames() const { return atom_names_; }
00074
00075 std::vector<Real> GetParam() const { return parameters_; }
00076
00077 ost::mol::AtomHandleList GetAtoms(const ost::mol::ResidueHandle& res) const;
00078
00079 FuncType GetFuncType() const { return func_type_; }
00080
00081 bool ReplaceAtom(const String& name, const String& new_name, const String& new_type);
00082
00083 bool MatchTypes(const std::vector<String>& atom_types) const;
00084
00085 bool MatchNames(const std::vector<String>& atom_names) const;
00086
00087 bool HasName(const String& name) const;
00088
00089 bool HasType(const String& type) const;
00090
00091 bool IsParametrized() const { return set_parameters_; }
00092
00093 bool HasTypeWildcard() const { return has_type_wildcard_; }
00094
00095 bool HasNameWildcard() const { return has_name_wildcard_; }
00096
00097 template <typename DS>
00098 void Serialize(DS& ds){
00099 ds & set_parameters_;
00100 ds & has_type_wildcard_;
00101 ds & has_name_wildcard_;
00102
00103 if(ds.IsSource()){
00104 int num_types = 0;
00105 int num_names = 0;
00106 int num_param = 0;
00107 ds & num_types;
00108 ds & num_names;
00109 ds & num_param;
00110 for(int i = 0; i < num_types; ++i){
00111 String type;
00112 ds & type;
00113 atom_types_.push_back(type);
00114 }
00115 for(int i = 0; i < num_names; ++i){
00116 String name;
00117 ds & name;
00118 atom_names_.push_back(name);
00119 }
00120 for(int i = 0; i < num_param; ++i){
00121 Real param;
00122 ds & param;
00123 parameters_.push_back(param);
00124 }
00125 }
00126 else{
00127 int atom_types_size = atom_types_.size();
00128 int atom_names_size = atom_names_.size();
00129 int parameters_size = parameters_.size();
00130 ds & atom_types_size;
00131 ds & atom_names_size;
00132 ds & parameters_size;
00133
00134 for(std::vector<String>::iterator i = atom_types_.begin();
00135 i != atom_types_.end(); ++i){
00136 ds & *i;
00137 }
00138 for(std::vector<String>::iterator i = atom_names_.begin();
00139 i != atom_names_.end(); ++i){
00140 ds & *i;
00141 }
00142 for(std::vector<Real>::iterator i = parameters_.begin();
00143 i != parameters_.end(); ++i){
00144 ds & *i;
00145 }
00146 }
00147 }
00148
00149 private:
00150
00151 bool CheckSetNamesTypes(std::vector<String>& types);
00152 bool CheckSetParam(std::vector<Real>& param);
00153
00154 FuncType func_type_;
00155 bool set_parameters_;
00156 bool has_type_wildcard_;
00157 bool has_name_wildcard_;
00158 std::vector<Real> parameters_;
00159 std::vector<String> atom_types_;
00160 std::vector<String> atom_names_;
00161 };
00162
00163 }}}
00164
00165 #endif