RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
SATypes.h
1/***********************************************************************
2 * The rDock program was developed from 1998 - 2006 by the software team
3 * at RiboTargets (subsequently Vernalis (R&D) Ltd).
4 * In 2006, the software was licensed to the University of York for
5 * maintenance and distribution.
6 * In 2012, Vernalis and the University of York agreed to release the
7 * program as Open Source software.
8 * This version is licensed under GNU-LGPL version 3.0 with support from
9 * the University of Barcelona.
10 * http://rdock.sourceforge.net/
11 ***********************************************************************/
12
13#ifndef _RBTSATYPES_H_
14#define _RBTSATYPES_H_
15
16#include "rxdock/Config.h"
17
18#include <functional>
19
20namespace rxdock {
21
22class Atom;
23
24// Atom typing class for the solvation atom types
25// HHS = Hasel, Hendrickson and Still, Tetrahedron Computer Methodology, 1
26// (1988) 103-116 This paper describes the fast approximation to
27// solvent-accessible surface area used here Solvation atom types are inspired
28// by Wang, Wang, Huo, Lee and Kollman, J. Phys. Chem. B 105 (2001) 5055-5067
29class HHSType {
30public:
31 enum eType {
32 UNDEFINED = 0,
33 C_sp3,
34 CH_sp3,
35 CH2_sp3,
36 CH3_sp3,
37 C_sp2,
38 CH_sp2,
39 CH2_sp2,
40 C_sp2p,
41 C_ar,
42 CH_ar,
43 C_sp,
44 C_sp3_P,
45 CH_sp3_P,
46 CH2_sp3_P,
47 CH3_sp3_P,
48 C_sp2_P,
49 CH_sp2_P,
50 CH2_sp2_P,
51 C_ar_P,
52 CH_ar_P,
53 H,
54 HO,
55 HN,
56 HNp,
57 HS,
58 O_sp3,
59 OH_sp3,
60 OW,
61 O_tri,
62 OH_tri,
63 O_sp2,
64 ON,
65 Om,
66 N_sp3,
67 NH_sp3,
68 NH2_sp3,
69 N_sp3p,
70 N_tri,
71 NH_tri,
72 NH2_tri,
73 N_sp2,
74 N_sp2p,
75 N_ar,
76 N_sp,
77 S_sp3,
78 S_sp2,
79 P,
80 F,
81 Cl,
82 Br,
83 I,
84 Metal,
85 MAXTYPES // KEEP AS LAST TYPE: used to size the atom name string list
86 };
87
88 HHSType();
89 virtual ~HHSType();
90
91 eType operator()(Atom *anAtom) const;
92 std::string Type2Str(eType) const;
93 eType Str2Type(const std::string &) const;
94
95private:
96 void SetupTypeNames();
97 std::vector<std::string> m_typeNames;
98};
99
100typedef SmartPtr<HHSType *> HHSTypePtr; // Smart pointer
101typedef std::vector<HHSType::eType> HHSTypeList;
102typedef HHSTypeList::iterator HHSTypeListIter;
103typedef HHSTypeList::const_iterator HHSTypeListConstIter;
104
105// Interaction center class for solvation calculations
106// A "decorated" Atom in effect
107// Designed as a "create-once, read-many" object
108// Attributes (radius, ASP etc) cannot be changed once constructed
109// The Overlap method accumulates the surface areas for each atom
110// based on pair-wise distances to surrounding atoms
112public:
113 // Constants from the HHS paper
114 static const double r_s; // solvent probe radius
115 static const double d_s; // solvent probe diameter
116 static const double Pij_12; // correction factor for 1-2 connections
117 static const double Pij_13; // ditto for 1-3
118 static const double Pij_14; // and for 1-4+
119
120 // Default p_i, r_i, and sigma values
121 HHS_Solvation(HHSType::eType t, Atom *a, double p = 1.0, double r = 1.0,
122 double s = 0.0);
123
124 // Get properties
125 double GetA_i(void) const { return A_i; }
126 double GetS_i(void) const { return S_i; }
127 double GetP_i(void) const { return p_i; }
128 double GetR_i(void) const { return r_i; }
129 double GetSigma(void) const { return sigma; }
130 HHSType::eType GetHHSType() const { return hhsType; }
131 Atom *GetAtom() const { return atom; }
132 inline double GetArea() const { return S_i * A_i; } // Exposed area
133 inline double GetEnergy() const { return E_i * A_i; } // Surface energy
134
135 // Actions
136 // Initialise all calculated parameters to an isolated atom (no overlap)
137 void Init();
138 // Saves current value of A_i to A_inv
139 // Use to memorise the partially calculated area due to invariant interaction
140 // distances
141 inline void Save() { A_inv = A_i; };
142 // Restores A_inv to A_i
143 // Use prior to continuing the calculation due to variable interaction
144 // distances
145 inline void Restore() { A_i = A_inv; };
146 // Calculate overlap between this center and another (h)
147 // Updates the exposed fractions (A_i) for both centers
148 // p_ij is the correction factor for 1-2, 1-3, and 1-4+ connected atoms
149 void Overlap(HHS_Solvation *h, double p_ij);
150 // Get a list of all the current (partitioned) variable-distance interactions
151 // to this center
152 const std::vector<HHS_Solvation *> &GetVariable() const { return m_prt; }
153 int GetNumVariable() const { return m_prt.size(); }
154 // Add a variable-distance interaction
155 void AddVariable(HHS_Solvation *anAtom);
156 // Helper function to calculate the overlap for all the variable interactions
157 // to this center All are 1-4+ by definition
158 void OverlapVariable();
159 // As above, but ignores disabled interaction centers
160 void OverlapVariableEnabledOnly();
161 // Partition the list of variable interactions
162 // Copy those that are closer than distance d to the partitioned list
163 // d=0 => clear the partition
164 void Partition(double d = 0.0);
165
166private:
167 double p_i; // atom-type dependent correction
168 double r_i; // quasi vdW radius
169 double S_i; // Surface area of isolated atom (constant)
170 double A_i; // Fraction of atom surface currently exposed
171 double A_inv; // invariant part of atom surface (memory, used by Save/Restore)
172 double sigma; // atomic solvation parameter
173 double E_i; // energy of isolated atom (S_i * sigma)
174 double PI_r_i_plus_r_s; // PI*(r_i+r_s)
175 double p_i_over_S_i; // p_i / S_i
176
177 HHSType::eType hhsType; // solvation atom type
178 Atom *atom; // the Atom itself
179 std::vector<HHS_Solvation *> m_var; // Vector of all variable distances
180 std::vector<HHS_Solvation *>
181 m_prt; // Vector of current partioned variable distances
182};
183
184typedef std::vector<HHS_Solvation *> HHS_SolvationRList;
185typedef HHS_SolvationRList::iterator HHS_SolvationRListIter;
186typedef HHS_SolvationRList::const_iterator HHS_SolvationRListConstIter;
187
188typedef std::vector<HHS_SolvationRList>
189 HHS_SolvationListMap; // vector of regular pointers
190typedef HHS_SolvationListMap::iterator HHS_SolvationListMapIter;
191typedef HHS_SolvationListMap::const_iterator HHS_SolvationListMapConstIter;
192
193typedef SmartPtr<HHS_Solvation> HHS_SolvationPtr; // Smart pointer
194typedef std::vector<HHS_SolvationPtr>
195 HHS_SolvationList; // Vector of smart pointers
196typedef HHS_SolvationList::iterator HHS_SolvationListIter;
197typedef HHS_SolvationList::const_iterator HHS_SolvationListConstIter;
198
199// Useful STL predicates and function objects
200class InitHHS {
201public:
202 explicit InitHHS() {}
203 void operator()(HHS_Solvation *pHHS) { pHHS->Init(); }
204};
205class SaveHHS {
206public:
207 explicit SaveHHS() {}
208 void operator()(HHS_Solvation *pHHS) { pHHS->Save(); }
209};
211public:
212 explicit RestoreHHS() {}
213 void operator()(HHS_Solvation *pHHS) { pHHS->Restore(); }
214};
216 double d;
217
218public:
219 explicit PartitionHHS(double dd) : d(dd) {}
220 void operator()(HHS_Solvation *pHHS) { pHHS->Partition(d); }
221};
223public:
224 explicit OverlapVariableHHS() {}
225 void operator()(HHS_Solvation *pHHS) { pHHS->OverlapVariable(); }
226};
228 HHS_Solvation *pHHSi;
229 double p_ij;
230
231public:
232 explicit OverlapHHS(HHS_Solvation *pHHS, double p) : pHHSi(pHHS), p_ij(p) {}
233 void operator()(HHS_Solvation *pHHSj) { pHHSi->Overlap(pHHSj, p_ij); }
234};
235
236// Is HHS type equal to t ?
237class isHHSType_eq : public std::function<bool(HHS_Solvation *)> {
238 HHSType::eType t;
239
240public:
241 explicit isHHSType_eq(HHSType::eType tt) : t(tt) {}
242 bool operator()(const HHS_Solvation *pHHS) const {
243 return pHHS->GetHHSType() == t;
244 }
245};
246
247// Is HHS_Solvation selected ?
248class isHHSSelected : public std::function<bool(HHS_Solvation *)> {
249public:
250 explicit isHHSSelected() {}
251 bool operator()(const HHS_Solvation *pHHS) const;
252};
253
254inline double AccumHHSEnergy(double val, const HHS_Solvation *pHHS) {
255 return val + pHHS->GetEnergy();
256}
257
258} // namespace rxdock
259
260#endif //_RBTSATYPES_H_
Definition Atom.h:49
Definition SATypes.h:29
Definition SATypes.h:111
Definition SATypes.h:200
Definition SATypes.h:227
Definition SATypes.h:222
Definition SATypes.h:215
Definition SATypes.h:210
Definition SATypes.h:205
Definition SmartPointer.h:48
Definition SATypes.h:248
Definition SATypes.h:237