Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CenHBEnergy.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file core/scoring/methods/CenHBEnergy.cc
11 /// @brief Smooth, differentiable version of centroid hbond term
12 /// @author Frank DiMaio
13 
14 
18 
19 // AUTO-REMOVED #include <core/scoring/AtomVDW.hh>
21 // AUTO-REMOVED #include <core/scoring/Energies.hh>
22 // AUTO-REMOVED #include <core/scoring/EnergyGraph.hh>
23 // AUTO-REMOVED #include <core/scoring/methods/EnergyMethodOptions.hh>
24 // AUTO-REMOVED #include <core/scoring/etable/count_pair/CountPairFunction.hh>
25 // AUTO-REMOVED #include <core/scoring/etable/count_pair/CountPairFactory.hh>
26 // AUTO-REMOVED #include <core/scoring/etable/count_pair/types.hh>
28 #include <core/pose/Pose.hh>
30 // AUTO-REMOVED #include <core/id/AtomID.hh>
31 
32 
33 #include <numeric/xyz.functions.hh>
34 #include <numeric/constants.hh>
35 #include <numeric/conversions.hh>
36 #include <numeric/deriv/distance_deriv.hh>
37 #include <numeric/deriv/angle_deriv.hh>
38 // AUTO-REMOVED #include <numeric/deriv/dihedral_deriv.hh>
39 #include <numeric/numeric.functions.hh>
40 
41 #include <utility/vector1.hh>
42 
43 //Auto Headers
45 
46 namespace core {
47 namespace scoring {
48 namespace methods {
49 
50 
51 /// @details This must return a fresh instance of the CenHBEnergy class,
52 /// never an instance already in use
56 ) const {
57  return new CenHBEnergy( );
58 }
59 
62  ScoreTypes sts;
63  sts.push_back( cen_hb );
64  return sts;
65 }
66 
67 
68 /// @details C-TOR with method options object
71  potential_( ScoringManager::get_instance()->get_CenHBPotential( ) ) { }
72 
73 
74 /// clone
77  return new CenHBEnergy( *this );
78 }
79 
80 /// @details copy c-tor
82  parent( src ),
83  potential_( src.potential_ ) { }
84 
85 
86 /////////////////////////////////////////////////////////////////////////////
87 // scoring
88 /////////////////////////////////////////////////////////////////////////////
89 
90 ///
91 void
94 }
95 
96 
97 ///
98 void
101 }
102 
103 
104 ///
105 void
107  conformation::Residue const & rsd1,
108  conformation::Residue const & rsd2,
109  pose::Pose const &,
110  ScoreFunction const &,
111  EnergyMap & emap
112 ) const {
113  Real score(0.0);
114 
115  Size seqsep = rsd1.polymeric_sequence_distance( rsd2 );
116 
117  // is there a way to get these coords without string comparisons?
118  Vector bbH, bbO, bbC, bbN;
119  Real r, xd, xh;
120 
121  if (rsd1.aa() != core::chemical::aa_pro) {
122  bbH = rsd1.atom( rsd1.atom_index("H") ).xyz();
123  bbO = rsd2.atom( rsd2.atom_index("O") ).xyz();
124 
125  r = bbH.distance( bbO );
126  if ( r <= potential_.cutoff( seqsep ) ) {
127  bbN = rsd1.atom( rsd1.atom_index("N") ).xyz();
128  bbC = rsd2.atom( rsd2.atom_index("C") ).xyz();
129  xd = numeric::angle_degrees( bbN,bbH,bbO );
130  xh = numeric::angle_degrees( bbH,bbO,bbC );
131 
132  //std::cerr << " r,xd,xh = " << r << "," << 180-xd << "," << 180-xh << " -- " << potential_.func( seqsep, r,180-xd,180-xh ) << std::endl;
133  score += potential_.func( seqsep, r,180-xd,180-xh );
134  }
135  }
136 
137  if (rsd2.aa() != core::chemical::aa_pro) {
138  bbH = rsd2.atom( rsd2.atom_index("H") ).xyz();
139  bbO = rsd1.atom( rsd1.atom_index("O") ).xyz();
140 
141  r = bbH.distance( bbO );//, xd, xh;
142  if ( r <= potential_.cutoff( seqsep ) ) {
143  bbN = rsd2.atom( rsd2.atom_index("N") ).xyz();
144  bbC = rsd1.atom( rsd1.atom_index("C") ).xyz();
145  xd = numeric::angle_degrees( bbN,bbH,bbO );
146  xh = numeric::angle_degrees( bbH,bbO,bbC );
147 
148  score += potential_.func( seqsep, r,180-xd,180-xh );
149  //std::cerr << " r,xd,xh = " << r << "," << 180-xd << "," << 180-xh << " -- " << potential_.func( seqsep, r,180-xd,180-xh ) << std::endl;
150  }
151  }
152 
153  emap[ cen_hb ] += score;
154 }
155 
156 
157 void
159  conformation::Residue const & rsd1,
160  conformation::Residue const & rsd2,
163  ResPairMinimizationData const &,
164  pose::Pose const &,
165  EnergyMap const & weights,
166  utility::vector1< DerivVectorPair > & r1_atom_derivs,
167  utility::vector1< DerivVectorPair > & r2_atom_derivs
168 ) const {
169  // is there a way to get these coords without string comparisons?
170  using numeric::constants::f::pi;
171  using namespace numeric::deriv;
172  Size idxH, idxO, idxC, idxN;
173  Vector bbH, bbO, bbC, bbN;
174  Real r, xd, xh;
175  Size seqsep = rsd1.polymeric_sequence_distance( rsd2 );
176  Real weight = weights[ cen_hb ];
177 
178  if (rsd1.aa() != core::chemical::aa_pro) {
179  idxH = rsd1.atom_index("H"); bbH = rsd1.atom( idxH ).xyz();
180  idxO = rsd2.atom_index("O"); bbO = rsd2.atom( idxO ).xyz();
181  r = bbH.distance( bbO );
182  if ( r <= potential_.cutoff( seqsep ) ) {
183  idxN = rsd1.atom_index("N"); bbN = rsd1.atom( idxN ).xyz();
184  idxC = rsd2.atom_index("C"); bbC = rsd2.atom( idxC ).xyz();
185  xd = numeric::angle_degrees( bbN,bbH,bbO );
186  xh = numeric::angle_degrees( bbH,bbO,bbC );
187 
188  Vector dfunc = potential_.dfunc( seqsep, r,180-xd,180-xh );
189 
190  // convert deg->radians + invert angular terms, scale by weight
191  dfunc[0] *= weight;
192  dfunc[1] *= -weight * 180/pi;
193  dfunc[2] *= -weight * 180/pi;
194 
195  // compute gradients
196  // distance
197  Vector f1,f2;
198  Real temp_dist, temp_ang;
199  distance_f1_f2_deriv(bbH, bbO, temp_dist, f1, f2);
200  r1_atom_derivs[ idxH ].f1() += dfunc[0] * f1;
201  r1_atom_derivs[ idxH ].f2() += dfunc[0] * f2;
202  r2_atom_derivs[ idxO ].f1() += -dfunc[0] * f1;
203  r2_atom_derivs[ idxO ].f2() += -dfunc[0] * f2;
204 
205  /// N-H-O angle
206  angle_p1_deriv( bbO, bbH, bbN, temp_ang, f1, f2);
207  r2_atom_derivs[ idxO ].f1() += dfunc[1] * f1;
208  r2_atom_derivs[ idxO ].f2() += dfunc[1] * f2;
209  angle_p1_deriv( bbN, bbH, bbO, temp_ang, f1, f2);
210  r1_atom_derivs[ idxN ].f1() += dfunc[1] * f1;
211  r1_atom_derivs[ idxN ].f2() += dfunc[1] * f2;
212  angle_p2_deriv( bbN, bbH, bbO, temp_ang, f1, f2);
213  r1_atom_derivs[ idxH ].f1() += dfunc[1] * f1;
214  r1_atom_derivs[ idxH ].f2() += dfunc[1] * f2;
215 
216  /// H-O-C angle
217  angle_p1_deriv( bbH, bbO, bbC, temp_ang, f1, f2);
218  r1_atom_derivs[ idxH ].f1() += dfunc[2] * f1;
219  r1_atom_derivs[ idxH ].f2() += dfunc[2] * f2;
220  angle_p1_deriv( bbC, bbO, bbH, temp_ang, f1, f2);
221  r2_atom_derivs[ idxC ].f1() += dfunc[2] * f1;
222  r2_atom_derivs[ idxC ].f2() += dfunc[2] * f2;
223  angle_p2_deriv( bbC, bbO, bbH, temp_ang, f1, f2);
224  r2_atom_derivs[ idxO ].f1() += dfunc[2] * f1;
225  r2_atom_derivs[ idxO ].f2() += dfunc[2] * f2;
226  }
227  }
228 
229  if (rsd2.aa() != core::chemical::aa_pro) {
230  idxH = rsd2.atom_index("H"); bbH = rsd2.atom( idxH ).xyz();
231  idxO = rsd1.atom_index("O"); bbO = rsd1.atom( idxO ).xyz();
232  r = bbH.distance( bbO );
233  if ( r <= potential_.cutoff( seqsep ) ) {
234  idxN = rsd2.atom_index("N"); bbN = rsd2.atom( idxN ).xyz();
235  idxC = rsd1.atom_index("C"); bbC = rsd1.atom( idxC ).xyz();
236  xd = numeric::angle_degrees( bbN,bbH,bbO );
237  xh = numeric::angle_degrees( bbH,bbO,bbC );
238 
239  Vector dfunc = potential_.dfunc( seqsep, r,180-xd,180-xh );
240  // convert deg->radians + invert angular terms, scale by weight
241  dfunc[0] *= weight;
242  dfunc[1] *= -weight * 180/pi;
243  dfunc[2] *= -weight * 180/pi;
244 
245 
246  // compute gradients
247  // distance
248  Vector f1,f2;
249  Real temp_dist, temp_ang;
250  distance_f1_f2_deriv(bbH, bbO, temp_dist, f1, f2);
251  r2_atom_derivs[ idxH ].f1() += dfunc[0] * f1;
252  r2_atom_derivs[ idxH ].f2() += dfunc[0] * f2;
253  r1_atom_derivs[ idxO ].f1() -= dfunc[0] * f1;
254  r1_atom_derivs[ idxO ].f2() -= dfunc[0] * f2;
255 
256  /// N-H-O angle
257  angle_p1_deriv( bbO, bbH, bbN, temp_ang, f1, f2);
258  r1_atom_derivs[ idxO ].f1() += dfunc[1] * f1;
259  r1_atom_derivs[ idxO ].f2() += dfunc[1] * f2;
260  angle_p1_deriv( bbN, bbH, bbO, temp_ang, f1, f2);
261  r2_atom_derivs[ idxN ].f1() += dfunc[1] * f1;
262  r2_atom_derivs[ idxN ].f2() += dfunc[1] * f2;
263  angle_p2_deriv( bbN, bbH, bbO, temp_ang, f1, f2);
264  r2_atom_derivs[ idxH ].f1() += dfunc[1] * f1;
265  r2_atom_derivs[ idxH ].f2() += dfunc[1] * f2;
266 
267  /// H-O-C angle
268  angle_p1_deriv( bbH, bbO, bbC, temp_ang, f1, f2);
269  r2_atom_derivs[ idxH ].f1() += dfunc[2] * f1;
270  r2_atom_derivs[ idxH ].f2() += dfunc[2] * f2;
271  angle_p1_deriv( bbC, bbO, bbH, temp_ang, f1, f2);
272  r1_atom_derivs[ idxC ].f1() += dfunc[2] * f1;
273  r1_atom_derivs[ idxC ].f2() += dfunc[2] * f2;
274  angle_p2_deriv( bbC, bbO, bbH, temp_ang, f1, f2);
275  r1_atom_derivs[ idxO ].f1() += dfunc[2] * f1;
276  r1_atom_derivs[ idxO ].f2() += dfunc[2] * f2;
277 
278  }
279  }
280 }
281 
282 
283 /// @brief CenHBEnergy distance cutoff
284 Distance
286  return 6.0;
287 }
288 
289 /// @brief CenHBEnergy
290 void
292 
295  return 1; // Initial versioning
296 }
297 
298 
299 
300 }
301 }
302 }