Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
atom_pair_energy_inline.hh
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 /// @begin atom_pair_energy_inline.hh
11 ///
12 /// @brief
13 /// A class for scoring fa_atr, fa_rep, fa_sol
14 ///
15 /// @detailed
16 /// This class is invoked when scoring. The terms that it is responsible for are fa_atr,
17 /// fa_rep, fa_sol. The class is highly optimized for speed and will break if you are not
18 /// careful. It calls functions within BaseEtableEnergy, which actually does the scoring.
19 /// It passes an energy map, which contains the energy for that residue for the atr, rep, and sol
20 /// terms. This is modified once the scores are tallied in BaseEtableEnergy.
21 ///
22 ///
23 /// @authors
24 /// Stuart G. Mentzer (Stuart_Mentzer@objexx.com)
25 /// Kevin P. Hinshaw (KevinHinshaw@gmail.com)
26 /// Andrew Leaver-Fay (leaverfa@email.unc.edu)
27 /// Steven Combs - comments and skipping of virtual atoms
28 ///
29 /// @last_modified December 6 2010
30 /////////////////////////////////////////////////////////////////////////
31 #ifndef INCLUDED_core_scoring_etable_atom_pair_energy_inline_hh
32 #define INCLUDED_core_scoring_etable_atom_pair_energy_inline_hh
33 
34 #include <core/scoring/types.hh>
35 // AUTO-REMOVED #include <core/scoring/etable/EtableEnergy.hh>
36 // AUTO-REMOVED #include <core/scoring/etable/CoarseEtableEnergy.hh>
37 
41 
42 // AUTO-REMOVED #include <utility/vector1.hh>
43 
44 #include <numeric/xyzVector.hh>
45 
47 #include <utility/vector1.hh>
48 
49 
50 namespace core {
51 namespace scoring {
52 
53 
54 ///////////////////////////////////////////////////////////////////////////////
55 
56 /// class T must define
57 // operator() ( int, int, Real & ) const;
58 // class T_Etable must define
59 // pair_energy_H( Atom const &, Atom const &, Real, EnergyMap & )
60 template< class T, class T_Etable >
61 inline
62 void
64  conformation::Residue const & res1,
65  int const atomno1,
66  conformation::Residue const & res2,
67  Size const atomno2,
68  Size const at1hbegin, //at1hbegin and at1hend define a range of hydrogen atom indices -- those h's bound to at1
69  Size const at1hend,
70  Size const at2hbegin,
71  Size const at2hend,
72  T const & count_pair,
73  T_Etable const & etable_energy,
74  EnergyMap &emap
75 )
76 {
77  using conformation::Atom;
78 
79  Weight weight( 1.0 );
80  Size path_dist( 0 );
81  Atom const & atom1( res1.atom( atomno1 ) );
82  Atom const & atom2( res2.atom( atomno2 ) );
83 
84 
85  // Heavy Atom in res1 to Hs in res2
86  for ( Size i = at2hbegin; i<= at2hend; ++i )
87  {
88  Atom const & H2( res2.atom( i ) );
89  weight = 1.0;
90  path_dist = 0;
91  if ( count_pair( atomno1, i, weight, path_dist ) ) {
92  etable_energy.pair_energy_H( atom1, H2, weight, emap );
93  }
94  }
95 
96 
97  // Hs in res1 to heavy Atom and Hs in res2
98  for ( Size i = at1hbegin; i<= at1hend; ++i )
99  {
100  Atom const & H1( res1.atom(i) );
101  weight = 1.0;
102  path_dist = 0;
103  // H in res1 to heavy Atom in res2
104  if ( count_pair( i, atomno2, weight, path_dist ) ) {
105  etable_energy.pair_energy_H( H1, atom2, weight, emap );
106  }
107 
108  // H in res1 to Hs in res2
109  for ( Size j = at2hbegin; j<= at2hend; ++j ) {
110  Atom const & H2( res2.atom(j) );
111  weight = 1.0f;
112  path_dist = 0;
113  if ( count_pair( i, j, weight, path_dist ) ) {
114  etable_energy.pair_energy_H( H1, H2, weight, emap );
115  }
116  }
117  }
118 }
119 
120 
121 
122 
123 ///////////////////////////////////////////////////////////////////////////////
124 
125 
126 /// @brief templated atom pair energy calculations
127 ///
128 /// loops over the heavy atoms of residue1 and the heavy atoms of residue2,
129 /// evaluates their energies, and if a pair of heavy atoms is close enough,
130 /// descendes into the attached hydrogen atoms for each.
131 ///
132 /// Templates are for count_pair type resolution and etable type resolution: there are
133 /// no polymorphic lookups within these functions
134 ///
135 /// class T must define
136 // operator() ( int, int, Real & ) const;
137 ///
138 /// class T_Etable must define
139 /// atom_pair_energy( Atom const &, Atom const &, Real, EnergyMap &, Distance ) and
140 //. pair_energy_H( Atom const &, Atom const &, Real, EnergyMap & )
141 template < class T, class T_Etable >
142 inline
143 void
145  conformation::Residue const & res1,
146  conformation::Residue const & res2,
147  T_Etable const & etable_energy,
148  T const & count_pair,
149  EnergyMap & emap,
150  int res1_start,
151  int res1_end,
152  int res2_start,
153  int res2_end
154 )
155 {
156  using conformation::Atom;
157 
158  //std::cout << "inline_residue_atom_pair_energy( res" << res1.seqpos() << ", res";
159  //std::cout << res2.seqpos() << ");" << std::endl;
160  //assert ( !( res1.is_DNA() && res2.is_DNA() ) ); // pb for testing, will remove
161 
162  DistanceSquared dsq;
163  Weight weight;
164  Size path_dist;
165  // get hydrogen interaction cutoff
166  Real const Hydrogen_interaction_cutoff2
167  ( etable_energy.hydrogen_interaction_cutoff2() );
168 
169  typedef utility::vector1< Size > const & vect;
170 
171  vect r1hbegin( res1.attached_H_begin() );
172  vect r1hend( res1.attached_H_end() );
173  vect r2hbegin( res2.attached_H_begin() );
174  vect r2hend( res2.attached_H_end() );
175 
176  // Atom pairs
177  for ( int i = res1_start, i_end = res1_end; i <= i_end; ++i ) {
178  Atom const & atom1( res1.atom(i) );
179  //get virtual information
180  bool atom1_virtual(res1.atom_type(i).is_virtual());
181  for ( int j=res2_start, j_end = res2_end; j <= j_end; ++j ) {
182  //check if virtual
183  bool atom2_virtual(res2.atom_type(j).is_virtual());
184  Atom const & atom2( res2.atom(j) );
185  weight = 1.0;
186  path_dist = 0;
187  if(atom1_virtual || atom2_virtual){
188  // NOOP! etable_energy.virtual_atom_pair_energy(emap);
189  }else{
190  if ( count_pair( i, j, weight, path_dist ) ) {
191  // std::cout << "Atom Pair Energy: " << i << " with " << j << " ";
192  etable_energy.atom_pair_energy( atom1, atom2, weight, emap, dsq );
193  // std::cout << "atr: " << emap[ coarse_fa_atr ] << " ";
194  // std::cout << "rep: " << emap[ coarse_fa_rep ] << " ";
195  // std::cout << "sol: " << emap[ coarse_fa_sol ] << " ";
196  // std::cout << std::endl;
197 
198  } else {
199  dsq = atom1.xyz().distance_squared( atom2.xyz() );
200  }
201  if ( dsq < Hydrogen_interaction_cutoff2 ) {
203  res1, i, res2, j,
204  r1hbegin[ i ], r1hend[ i ],
205  r2hbegin[ j ], r2hend[ j ],
206  count_pair, etable_energy , emap);
207  // std::cout << "atr: " << emap[ fa_atr ] << " ";
208  // std::cout << "rep: " << emap[ fa_rep ] << " ";
209  // std::cout << std::endl;
210 
211  }
212  }
213  }
214  }
215 
216 }
217 
218 /// @brief intraresidue atom pair energy evaluations
219 template < class T, class T_Etable >
220 inline
221 void
223  conformation::Residue const & res,
224  T_Etable const & etable_energy,
225  T const & count_pair,
226  EnergyMap & emap
227 )
228 {
229  using conformation::Atom;
230 
231  //std::cout << "inline_residue_atom_pair_energy( res" << res1.seqpos() << ", res";
232  //std::cout << res2.seqpos() << ");" << std::endl;
233 
234  DistanceSquared dsq;
235  Weight weight;
236  Size path_dist;
237 
238  // get hydrogen interaction cutoff
239  Real const Hydrogen_interaction_cutoff2
240  ( etable_energy.hydrogen_interaction_cutoff2() );
241 
242  typedef utility::vector1< Size > const & vect;
243 
244  vect rhbegin( res.attached_H_begin() );
245  vect rhend( res.attached_H_end() );
246 
247  int const resnheavyatoms = res.nheavyatoms();
248 
249  // Atom pairs
250  for ( int i=1; i <= resnheavyatoms; ++i ) {
251  Atom const & atom1( res.atom(i) );
252  bool atom1_virtual(res.atom_type(i).is_virtual());
253  for ( int j=i+1; j <= resnheavyatoms; ++j ) {
254  bool atom2_virtual(res.atom_type(j).is_virtual());
255  Atom const & atom2( res.atom(j) );
256  weight = 1.0;
257  path_dist = 0;
258  if(atom1_virtual || atom2_virtual){
259  //etable_energy.virtual_atom_pair_energy(emap);
260  }else{
261 
262  if ( count_pair( i, j, weight, path_dist ) ) {
263  // std::cout << "Intra Res Atom Pair Energy: atom " << i << " with atom " << j << " ";
264  etable_energy.atom_pair_energy( atom1, atom2, weight, emap, dsq );
265  //std::cout << "atr: " << emap[ coarse_fa_atr ] << " ";
266  //std::cout << "rep: " << emap[ coarse_fa_rep ] << " ";
267  //std::cout << "sol: " << emap[ coarse_fa_sol ] << " ";
268  //std::cout << std::endl;
269  } else {
270  dsq = atom1.xyz().distance_squared( atom2.xyz() );
271  }
272 
273  if ( dsq < Hydrogen_interaction_cutoff2 ) {
275  res, i, res, j,
276  rhbegin[ i ], rhend[ i ],
277  rhbegin[ j ], rhend[ j ],
278  count_pair, etable_energy, emap);
279  //std::cout << "atr: " << emap[ fa_atr ] << " ";
280  //std::cout << "rep: " << emap[ fa_rep ] << " ";
281  //std::cout << std::endl;
282 
283  }
284  }
285  }
286  }
287 }
288 
289 
290 template < class T, class T_Etable >
291 inline
292 void
294  conformation::Residue const & res1,
295  conformation::Residue const & res2,
296  T_Etable const & etable_energy,
297  T const & count_pair,
298  EnergyMap & emap
299 )
300 {
302  res1, res2, etable_energy, count_pair, emap,
303  1, res1.nheavyatoms(), 1, res2.nheavyatoms() );
304 }
305 
306 template < class T, class T_Etable>
307 inline
308 void
310  conformation::Residue const & res1,
311  conformation::Residue const & res2,
312  T_Etable const & etable_energy,
313  T const & count_pair,
314  EnergyMap & emap
315 )
316 {
318  res1, res2, etable_energy, count_pair, emap,
319  res1.first_sidechain_atom(), res1.nheavyatoms(), 1, res2.last_backbone_atom() );
320 }
321 
322 template < class T, class T_Etable >
323 inline
324 void
326  conformation::Residue const & res1,
327  conformation::Residue const & res2,
328  T_Etable const & etable_energy,
329  T const & count_pair,
330  EnergyMap & emap
331 )
332 {
334  res1, res2, etable_energy, count_pair, emap,
335  res1.first_sidechain_atom(), res1.nheavyatoms(), 1, res2.nheavyatoms() );
336 }
337 
338 template < class T, class T_Etable>
339 inline
340 void
342  conformation::Residue const & res1,
343  conformation::Residue const & res2,
344  T_Etable const & etable_energy,
345  T const & count_pair,
346  EnergyMap & emap
347 )
348 {
350  res1, res2, etable_energy, count_pair, emap,
351  1, res1.last_backbone_atom(), 1, res2.last_backbone_atom() );
352 }
353 
354 template < class T, class T_Etable>
355 inline
356 void
358  conformation::Residue const & res1,
359  conformation::Residue const & res2,
360  T_Etable const & etable_energy,
361  T const & count_pair,
362  EnergyMap & emap
363 )
364 {
366  res1, res2, etable_energy, count_pair, emap,
367  res1.first_sidechain_atom(), res1.nheavyatoms(), res2.first_sidechain_atom(), res2.nheavyatoms() );
368 }
369 
370 
371 } // namespace scoring
372 } // namespace core
373 
374 #endif