OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
interaction.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_INTERACTION_HH
21 #define OST_MM_INTERACTION_HH
22 
23 #include <vector>
24 #include <fstream>
25 
26 #include <boost/shared_ptr.hpp>
27 #include <boost/filesystem.hpp>
28 
31 #include <ost/io/io_exception.hh>
32 #include <ost/message.hh>
33 #include <ost/mol/atom_handle.hh>
35 
36 
37 namespace ost { namespace mol{ namespace mm{
38 
40 typedef boost::shared_ptr<Interaction> InteractionPtr;
41 
42 enum FuncType{
51  LJ,
58 };
59 
61 
62 public:
63  Interaction(FuncType func_type);
64 
65  void SetTypes(std::vector<String> types);
66 
67  void SetNames(std::vector<String> names);
68 
69  void SetParam(std::vector<Real>& parameters);
70 
71  std::vector<String> GetTypes() const { return atom_types_; }
72 
73  std::vector<String> GetNames() const { return atom_names_; }
74 
75  std::vector<Real> GetParam() const { return parameters_; }
76 
78 
79  FuncType GetFuncType() const { return func_type_; }
80 
81  bool ReplaceAtom(const String& name, const String& new_name, const String& new_type);
82 
83  bool MatchTypes(const std::vector<String>& atom_types) const;
84 
85  bool MatchNames(const std::vector<String>& atom_names) const;
86 
87  bool HasName(const String& name) const;
88 
89  bool HasType(const String& type) const;
90 
91  bool IsParametrized() const { return set_parameters_; }
92 
93  bool HasTypeWildcard() const { return has_type_wildcard_; }
94 
95  bool HasNameWildcard() const { return has_name_wildcard_; }
96 
97  template <typename DS>
98  void Serialize(DS& ds){
99  ds & set_parameters_;
100  ds & has_type_wildcard_;
101  ds & has_name_wildcard_;
102 
103  if(ds.IsSource()){
104  int num_types = 0;
105  int num_names = 0;
106  int num_param = 0;
107  ds & num_types;
108  ds & num_names;
109  ds & num_param;
110  for(int i = 0; i < num_types; ++i){
111  String type;
112  ds & type;
113  atom_types_.push_back(type);
114  }
115  for(int i = 0; i < num_names; ++i){
116  String name;
117  ds & name;
118  atom_names_.push_back(name);
119  }
120  for(int i = 0; i < num_param; ++i){
121  Real param;
122  ds & param;
123  parameters_.push_back(param);
124  }
125  }
126  else{
127  int atom_types_size = atom_types_.size();
128  int atom_names_size = atom_names_.size();
129  int parameters_size = parameters_.size();
130  ds & atom_types_size;
131  ds & atom_names_size;
132  ds & parameters_size;
133 
134  for(std::vector<String>::iterator i = atom_types_.begin();
135  i != atom_types_.end(); ++i){
136  ds & *i;
137  }
138  for(std::vector<String>::iterator i = atom_names_.begin();
139  i != atom_names_.end(); ++i){
140  ds & *i;
141  }
142  for(std::vector<Real>::iterator i = parameters_.begin();
143  i != parameters_.end(); ++i){
144  ds & *i;
145  }
146  }
147  }
148 
149 private:
150 
151  bool CheckSetNamesTypes(std::vector<String>& types);
152  bool CheckSetParam(std::vector<Real>& param);
153 
154  FuncType func_type_;
155  bool set_parameters_;
156  bool has_type_wildcard_;
157  bool has_name_wildcard_;
158  std::vector<Real> parameters_;
159  std::vector<String> atom_types_;
160  std::vector<String> atom_names_;
161 };
162 
163 }}} //ns
164 
165 #endif
std::vector< String > GetNames() const
Definition: interaction.hh:73
void SetNames(std::vector< String > names)
boost::shared_ptr< Interaction > InteractionPtr
Definition: interaction.hh:39
std::string String
Definition: base.hh:54
float Real
Definition: base.hh:44
bool MatchNames(const std::vector< String > &atom_names) const
bool MatchTypes(const std::vector< String > &atom_types) const
std::vector< Real > GetParam() const
Definition: interaction.hh:75
bool IsParametrized() const
Definition: interaction.hh:91
void SetParam(std::vector< Real > &parameters)
ost::mol::AtomHandleList GetAtoms(const ost::mol::ResidueHandle &res) const
std::vector< String > GetTypes() const
Definition: interaction.hh:71
Interaction(FuncType func_type)
structure
FuncType GetFuncType() const
Definition: interaction.hh:79
bool HasName(const String &name) const
bool ReplaceAtom(const String &name, const String &new_name, const String &new_type)
std::vector< AtomHandle > AtomHandleList
bool HasType(const String &type) const
void SetTypes(std::vector< String > types)
bool HasNameWildcard() const
Definition: interaction.hh:95
bool HasTypeWildcard() const
Definition: interaction.hh:93