OpenStructure
Loading...
Searching...
No Matches
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
25namespace ost { namespace mol { namespace alg {
26
28{
29public:
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
39private:
40 Real avg_length_;
41 Real avg_zscore_;
42 int count_;
43};
44
46{
47public:
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_; }
55private:
58 Real mdl_dist_;
59 Real adjusted_ref_dist_;
60};
61
63{
64
65public:
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
73private:
74 int clash_count_;
75 Real average_offset_;
76 std::vector<ClashEvent> clash_list_;
77};
78
80{
81public:
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_; }
92private:
95 Real mdl_value_;
96 std::pair<Real,Real> allowed_range_;
97};
98
100{
101public:
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_; }
114private:
118 Real mdl_value_;
119 std::pair<Real,Real> allowed_range_;
120};
121
123{
124public:
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
160private:
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
177public:
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
194
196 bool IsEmpty() const;
197
199 void PrintAllDistances() const;
200
201private:
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
216public:
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
238private:
239
240 std::map<std::pair<String,String>,std::pair<Real,Real> > params_;
241
242};
243
247ClashingDistances DLLEXPORT_OST_MOL_ALG FillClashingDistances(std::vector<String>& stereo_chemical_props_file, bool check=false);
248
253StereoChemicalParams DLLEXPORT_OST_MOL_ALG FillStereoChemicalParams(const String& header, std::vector<String>& stereo_chemical_props_file, bool check=false);
254
262std::pair<EntityView,ClashingInfo> DLLEXPORT_OST_MOL_ALG FilterClashes(const EntityView& ent,
263 const ClashingDistances& min_distances, bool always_remove_bb=false);
264
272std::pair<EntityView,ClashingInfo> DLLEXPORT_OST_MOL_ALG FilterClashes(const EntityHandle& ent,
273 const ClashingDistances& min_distances, bool always_remove_bb=false);
274
282std::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
296std::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
Protein or molecule.
definition of EntityView
BondLengthInfo(Real avg_length, Real avg_zscore, int count)
ClashEvent(const UniqueAtomIdentifier &atom1, const UniqueAtomIdentifier &atom2, Real mdl_dist, Real adjusted_ref_dist)
UniqueAtomIdentifier GetSecondAtom() const
Real GetAdjustedReferenceDistance() const
UniqueAtomIdentifier GetFirstAtom() const
List of reference atom-atom distances to detect clashes between non-bonded atoms.
void PrintAllDistances() const
Prints all distances in the list to standard output.
Real GetAdjustedClashingDistance(const String &ele1, const String &ele2) const
Recovers a reference distance already adjusted by the tolerance threshold from the list.
std::pair< Real, Real > GetClashingDistance(const String &ele1, const String &ele2) const
Recovers a reference distance and a tolerance threshold (respectively) from the list.
Real GetMaxAdjustedDistance() const
Recovers the longest distance in the list, corrected by tolerance.
bool IsEmpty() const
Returns true if the list is empty (i.e. in an invalid, useless state)
void SetClashingDistance(const String &ele1, const String &ele2, Real min_distance, Real tolerance)
Adds or replaces an entry.
ClashingDistances()
Default constructor (creates an empty list)
std::vector< ClashEvent > GetClashList() const
ClashingInfo(int clash_count, Real average_offset, const std::vector< ClashEvent > &clash_list)
StereoChemicalAngleViolation(const UniqueAtomIdentifier &atom1, const UniqueAtomIdentifier &atom2, const UniqueAtomIdentifier &atom3, Real mdl_value, std::pair< Real, Real > allowed_range)
std::pair< Real, Real > GetAllowedRange() const
UniqueAtomIdentifier GetSecondAtom() const
UniqueAtomIdentifier GetThirdAtom() const
UniqueAtomIdentifier GetFirstAtom() const
StereoChemicalBondViolation(const UniqueAtomIdentifier &atom1, const UniqueAtomIdentifier &atom2, Real mdl_value, std::pair< Real, Real > allowed_range)
std::pair< Real, Real > GetAllowedRange() const
UniqueAtomIdentifier GetSecondAtom() const
UniqueAtomIdentifier GetFirstAtom() const
List of stereo chemical parameters (Bonds and angles)
void SetParam(const String &param, const String &residue, Real value, Real st_dev)
Adds or replaces an entry.
bool ContainsParam(const String &param, const String &residue) const
Checks if the list contains an entry for a specific stereo-chemical item (a bond or atom in a specifi...
bool IsEmpty() const
Returns true if the list is empty (i.e. in an invalid, useless state)
std::pair< Real, Real > GetParam(const String &element, const String &residue) const
Recovers mean and standard deviation (respectively) of a stereo⁻chemical item (bond or angle) from th...
void PrintAllParameters() const
Prints all distances in the list to standard output.
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)
std::vector< StereoChemicalAngleViolation > GetAngleViolationList()
std::map< String, BondLengthInfo > GetAvgBondLengthInfo()
std::vector< StereoChemicalBondViolation > GetBondViolationList()
Contains the infomation needed to uniquely identify an atom in a structure.
float Real
Definition base.hh:44
std::string String
Definition base.hh:54
#define DLLEXPORT_OST_MOL_ALG
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.
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.
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.
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.
Definition base.dox:1