OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
filter_clashes.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 #ifndef OST_MOL_ALG_FILTER_CLASHES_HH
20 #define OST_MOL_ALG_FILTER_CLASHES_HH
21 
22 #include <ost/mol/entity_view.hh>
25 namespace ost { namespace mol { namespace alg {
26 
28 {
29 public:
30  BondLengthInfo(): avg_length_(0),avg_zscore_(0),count_(0) {}
31  BondLengthInfo(Real avg_length,Real avg_zscore, int count):
32  avg_length_(avg_length),
33  avg_zscore_(avg_zscore),
34  count_(count){}
35  Real GetAvgLength() {return avg_length_;}
36  Real GetAvgZscore() {return avg_zscore_;}
37  int GetCount() {return count_;}
38 
39 private:
40  Real avg_length_;
41  Real avg_zscore_;
42  int count_;
43 };
44 
46 {
47 public:
48  ClashEvent(): atom1_(UniqueAtomIdentifier()),atom2_(UniqueAtomIdentifier()),mdl_dist_(0.0),adjusted_ref_dist_(0.0) {}
49  ClashEvent(const UniqueAtomIdentifier& atom1,const UniqueAtomIdentifier& atom2, Real mdl_dist, Real adjusted_ref_dist ):
50  atom1_(atom1),atom2_(atom2),mdl_dist_(mdl_dist),adjusted_ref_dist_(adjusted_ref_dist) {}
51  UniqueAtomIdentifier GetFirstAtom() const { return atom1_; }
52  UniqueAtomIdentifier GetSecondAtom() const { return atom2_; }
53  Real GetModelDistance() const { return mdl_dist_; }
54  Real GetAdjustedReferenceDistance() const { return adjusted_ref_dist_; }
55 private:
56  UniqueAtomIdentifier atom1_;
57  UniqueAtomIdentifier atom2_;
58  Real mdl_dist_;
59  Real adjusted_ref_dist_;
60 };
61 
63 {
64 
65 public:
66  ClashingInfo(): clash_count_(0), average_offset_ (0), clash_list_(std::vector<ClashEvent>()) {}
67  ClashingInfo (int clash_count, Real average_offset, const std::vector<ClashEvent>& clash_list):
68  clash_count_(clash_count), average_offset_ (average_offset),clash_list_(clash_list) {}
69  int GetClashCount() const {return clash_count_/2.0;}
70  Real GetAverageOffset() const {return average_offset_;}
71  std::vector<ClashEvent> GetClashList() const;
72 
73 private:
74  int clash_count_;
75  Real average_offset_;
76  std::vector<ClashEvent> clash_list_;
77 };
78 
80 {
81 public:
83  atom1_(UniqueAtomIdentifier()),atom2_(UniqueAtomIdentifier()),mdl_value_(0.0),allowed_range_(std::pair<Real,Real>(0.0,0.0)) {}
85  const UniqueAtomIdentifier& atom2,
86  Real mdl_value, std::pair<Real,Real> allowed_range ):
87  atom1_(atom1),atom2_(atom2),mdl_value_(mdl_value),allowed_range_(allowed_range) {}
88  UniqueAtomIdentifier GetFirstAtom() const { return atom1_; }
89  UniqueAtomIdentifier GetSecondAtom() const { return atom2_; }
90  Real GetBondLength() const { return mdl_value_; }
91  std::pair<Real,Real> GetAllowedRange() const { return allowed_range_; }
92 private:
93  UniqueAtomIdentifier atom1_;
94  UniqueAtomIdentifier atom2_;
95  Real mdl_value_;
96  std::pair<Real,Real> allowed_range_;
97 };
98 
100 {
101 public:
103  atom1_(UniqueAtomIdentifier()),atom2_(UniqueAtomIdentifier()),atom3_(UniqueAtomIdentifier()),mdl_value_(0.0),allowed_range_(std::pair<Real,Real>(0.0,0.0)) {}
105  const UniqueAtomIdentifier& atom2,
106  const UniqueAtomIdentifier& atom3,
107  Real mdl_value, std::pair<Real,Real> allowed_range ):
108  atom1_(atom1),atom2_(atom2),atom3_(atom3),mdl_value_(mdl_value),allowed_range_(allowed_range) {}
109  UniqueAtomIdentifier GetFirstAtom() const { return atom1_; }
110  UniqueAtomIdentifier GetSecondAtom() const { return atom2_; }
111  UniqueAtomIdentifier GetThirdAtom() const { return atom3_; }
112  Real GetAngleWidth() const { return mdl_value_; }
113  std::pair<Real,Real> GetAllowedRange() const { return allowed_range_; }
114 private:
115  UniqueAtomIdentifier atom1_;
116  UniqueAtomIdentifier atom2_;
117  UniqueAtomIdentifier atom3_;
118  Real mdl_value_;
119  std::pair<Real,Real> allowed_range_;
120 };
121 
123 {
124 public:
126  avg_zscore_bonds_(0),
127  bad_bond_count_(0),
128  bond_count_(0),
129  avg_zscore_angles_(0),
130  bad_angle_count_(0),
131  angle_count_(0),
132  avg_bond_length_info_(std::map<String,BondLengthInfo>()),
133  bond_violation_list_(std::vector<StereoChemicalBondViolation>()),
134  angle_violation_list_(std::vector<StereoChemicalAngleViolation>()) {}
135  StereoChemistryInfo(Real avg_zscore_bonds, int bad_bond_count, int bond_count,
136  Real avg_zscore_angles, int bad_angle_count, int angle_count,
137  const std::map<String,BondLengthInfo>& avg_bond_length_info,
138  const std::vector<StereoChemicalBondViolation>& bond_violation_list,
139  const std::vector<StereoChemicalAngleViolation>& angle_violation_list):
140  avg_zscore_bonds_(avg_zscore_bonds),
141  bad_bond_count_(bad_bond_count),
142  bond_count_(bond_count),
143  avg_zscore_angles_(avg_zscore_angles),
144  bad_angle_count_(bad_angle_count),
145  angle_count_(angle_count),
146  avg_bond_length_info_(avg_bond_length_info),
147  bond_violation_list_(bond_violation_list),
148  angle_violation_list_(angle_violation_list) {}
149  Real GetAvgZscoreBonds() const {return avg_zscore_bonds_;}
150  int GetBadBondCount() const {return bad_bond_count_;}
151  int GetBondCount() const {return bond_count_;}
152  Real GetAvgZscoreAngles() const {return avg_zscore_angles_;}
153  int GetBadAngleCount() const {return bad_angle_count_;}
154  int GetAngleCount() const {return angle_count_;}
155  std::map<String,BondLengthInfo> GetAvgBondLengthInfo() {return avg_bond_length_info_;}
156  std::vector<StereoChemicalBondViolation> GetBondViolationList() { return bond_violation_list_; }
157  std::vector<StereoChemicalAngleViolation> GetAngleViolationList() { return angle_violation_list_; }
158 
159 
160 private:
161  Real avg_zscore_bonds_;
162  int bad_bond_count_;
163  int bond_count_;
164  Real avg_zscore_angles_;
165  int bad_angle_count_;
166  int angle_count_;
167  std::map<String,BondLengthInfo> avg_bond_length_info_;
168  std::vector<StereoChemicalBondViolation> bond_violation_list_;
169  std::vector<StereoChemicalAngleViolation> angle_violation_list_;
170 };
171 
172 
175 {
176 
177 public:
179  ClashingDistances(): valid_flag_(true) {}
180 
184  void SetClashingDistance(const String& ele1,const String& ele2, Real min_distance, Real tolerance);
185 
187  std::pair<Real,Real> GetClashingDistance(const String& ele1,const String& ele2) const;
188 
190  Real GetAdjustedClashingDistance(const String& ele1,const String& ele2) const;
191 
193  Real GetMaxAdjustedDistance() const;
194 
196  bool IsEmpty() const;
197 
199  void PrintAllDistances() const;
200 
201 private:
202 
203  std::map <String,std::pair<Real,Real> > min_distance_;
204  Real default_min_distance_;
205  Real default_min_distance_tolerance_;
206  bool valid_flag_;
207 
208 };
209 
214 {
215 
216 public:
218  void SetParam(const String& param, const String& residue, Real value, Real st_dev);
219 
223  std::pair<Real,Real> GetParam(const String& element,const String& residue) const;
224 
228  bool ContainsParam(const String& param,const String& residue) const;
229 
233  bool IsEmpty() const;
234 
236  void PrintAllParameters() const;
237 
238 private:
239 
240  std::map<std::pair<String,String>,std::pair<Real,Real> > params_;
241 
242 };
243 
247 ClashingDistances DLLEXPORT_OST_MOL_ALG FillClashingDistances(std::vector<String>& stereo_chemical_props_file, bool check=false);
248 
253 StereoChemicalParams DLLEXPORT_OST_MOL_ALG FillStereoChemicalParams(const String& header, std::vector<String>& stereo_chemical_props_file, bool check=false);
254 
262 std::pair<EntityView,ClashingInfo> DLLEXPORT_OST_MOL_ALG FilterClashes(const EntityView& ent,
263  const ClashingDistances& min_distances, bool always_remove_bb=false);
264 
272 std::pair<EntityView,ClashingInfo> DLLEXPORT_OST_MOL_ALG FilterClashes(const EntityHandle& ent,
273  const ClashingDistances& min_distances, bool always_remove_bb=false);
274 
282 std::pair<EntityView,StereoChemistryInfo> DLLEXPORT_OST_MOL_ALG CheckStereoChemistry(const EntityView& ent,
283  const StereoChemicalParams& bond_table,
284  const StereoChemicalParams& angle_table,
285  Real bond_tolerance,
286  Real angle_tolerance,
287  bool always_remove_bb=false);
288 
296 std::pair<EntityView,StereoChemistryInfo> DLLEXPORT_OST_MOL_ALG CheckStereoChemistry(const EntityHandle& ent,
297  const StereoChemicalParams& bond_table,
298  const StereoChemicalParams& angle_table,
299  Real bond_tolerance,
300  Real angle_tolerance,
301  bool always_remove_bb=false);
302 
303 
304 }}}
305 
306 
307 #endif
std::vector< StereoChemicalAngleViolation > GetAngleViolationList()
UniqueAtomIdentifier GetThirdAtom() const
ClashingDistances DLLEXPORT_OST_MOL_ALG FillClashingDistances(std::vector< String > &stereo_chemical_props_file, bool check=false)
Fills a list of reference clashing distances from the content of a parameter file.
#define DLLEXPORT_OST_MOL_ALG
std::pair< EntityView, ClashingInfo > DLLEXPORT_OST_MOL_ALG FilterClashes(const EntityView &ent, const ClashingDistances &min_distances, bool always_remove_bb=false)
Filters a structure based on detected clashes between non bonded atoms. Entity version.
std::string String
Definition: base.hh:54
float Real
Definition: base.hh:44
StereoChemicalAngleViolation(const UniqueAtomIdentifier &atom1, const UniqueAtomIdentifier &atom2, const UniqueAtomIdentifier &atom3, Real mdl_value, std::pair< Real, Real > allowed_range)
ClashingInfo(int clash_count, Real average_offset, const std::vector< ClashEvent > &clash_list)
ClashEvent(const UniqueAtomIdentifier &atom1, const UniqueAtomIdentifier &atom2, Real mdl_dist, Real adjusted_ref_dist)
Protein or molecule.
std::pair< Real, Real > GetAllowedRange() const
ClashingDistances()
Default constructor (creates an empty list)
Contains the infomation needed to uniquely identify an atom in a structure.
StereoChemistryInfo(Real avg_zscore_bonds, int bad_bond_count, int bond_count, Real avg_zscore_angles, int bad_angle_count, int angle_count, const std::map< String, BondLengthInfo > &avg_bond_length_info, const std::vector< StereoChemicalBondViolation > &bond_violation_list, const std::vector< StereoChemicalAngleViolation > &angle_violation_list)
StereoChemicalParams DLLEXPORT_OST_MOL_ALG FillStereoChemicalParams(const String &header, std::vector< String > &stereo_chemical_props_file, bool check=false)
Fills a list of stereo-chemical statistics from the content of a parameter file.
UniqueAtomIdentifier GetSecondAtom() const
std::pair< EntityView, StereoChemistryInfo > DLLEXPORT_OST_MOL_ALG CheckStereoChemistry(const EntityView &ent, const StereoChemicalParams &bond_table, const StereoChemicalParams &angle_table, Real bond_tolerance, Real angle_tolerance, bool always_remove_bb=false)
Filters a structure based on detected stereo-chemical violations. Entity version. ...
UniqueAtomIdentifier GetFirstAtom() const
UniqueAtomIdentifier GetFirstAtom() const
Real GetAdjustedReferenceDistance() const
UniqueAtomIdentifier GetSecondAtom() const
List of stereo chemical parameters (Bonds and angles)
Real GetModelDistance() const
UniqueAtomIdentifier GetSecondAtom() const
BondLengthInfo(Real avg_length, Real avg_zscore, int count)
std::map< String, BondLengthInfo > GetAvgBondLengthInfo()
definition of EntityView
Definition: entity_view.hh:86
StereoChemicalBondViolation(const UniqueAtomIdentifier &atom1, const UniqueAtomIdentifier &atom2, Real mdl_value, std::pair< Real, Real > allowed_range)
std::pair< Real, Real > GetAllowedRange() const
UniqueAtomIdentifier GetFirstAtom() const
List of reference atom-atom distances to detect clashes between non-bonded atoms. ...
std::vector< StereoChemicalBondViolation > GetBondViolationList()