Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EtableEnergy.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/ScoreFunction.cc
11 /// @brief Atom pair energy functions
12 /// @author Stuart G. Mentzer (Stuart_Mentzer@objexx.com)
13 /// @author Kevin P. Hinshaw (KevinHinshaw@gmail.com)
14 
15 
16 // Unit headers
19 
20 // Package headers
25 
26 // Project headers
28 #include <core/pose/Pose.hh>
29 
30 #include <basic/options/option.hh>
31 #include <basic/options/keys/score.OptionKeys.gen.hh>
32 
33 #include <utility/vector1.hh>
34 
35 
36 
37 namespace core {
38 namespace scoring {
39 namespace etable {
40 
41 
42 /// @details This must return a fresh instance of the EtableEnergy class,
43 /// never an instance already in use
46  methods::EnergyMethodOptions const & options
47 ) const {
48  /// The command line option needs to override the EnergyMethodOptions because an Etable initialized with
49  /// the analytic_etable_evaluation flag on will not have allocated the large etables necessary for the
50  /// TableLookupEtableEnergy class.
51  if ( basic::options::option[ basic::options::OptionKeys::score::analytic_etable_evaluation ] || options.analytic_etable_evaluation() ) {
52  return new AnalyticEtableEnergy( *( ScoringManager::get_instance()->etable( options.etable_type() )), options );
53  } else {
54  return new TableLookupEtableEnergy( *( ScoringManager::get_instance()->etable( options.etable_type() )), options );
55  }
56 }
57 
60  ScoreTypes sts;
61  sts.push_back( fa_atr );
62  sts.push_back( fa_rep );
63  sts.push_back( fa_sol );
64  sts.push_back( fa_intra_atr );
65  sts.push_back( fa_intra_rep );
66  sts.push_back( fa_intra_sol );
67  return sts;
68 }
69 
70 
71 /// construction with an etable
73  Etable const & etable_in,
74  methods::EnergyMethodOptions const & options
75 )
76 :
77  BaseEtableEnergy< TableLookupEtableEnergy > ( new EtableEnergyCreator, etable_in, options ),
78  intrares_evaluator_( etable_in ),
79  interres_evaluator_( etable_in )
80 {
83 }
84 
86  TableLookupEtableEnergy const & src
87 ) :
89  intrares_evaluator_( src.intrares_evaluator_ ),
90  interres_evaluator_( src.interres_evaluator_ )
91 {
92 }
93 
96  return new TableLookupEtableEnergy( *this );
97 }
98 
99 void
101 {
102  if (pose.total_residue()) {
103  if ( pose.residue(1).type().atom_type_set_ptr() != etable().atom_set() ) {
104  utility_exit_with_message( "Illegal attempt to score with non-identical atom set between pose and etable " );
105  }
106  }
107 }
108 
109 bool
111  EnergyMap const & weights
112 ) const
113 {
114  return ( weights[ fa_intra_atr ] != 0 ||
115  weights[ fa_intra_rep ] != 0 ||
116  weights[ fa_intra_sol ] != 0 );
117 }
118 
119 /// @brief
120 void
122  conformation::Residue const & res,
123  pose::Pose const & pose,
124  ScoreFunction const & sfxn,
125  EnergyMap & emap
126 ) const
127 {
128  // ignore scoring residues which have been marked as "REPLONLY" residues (only the repulsive energy will be calculated)
130  return;
131  }
132 
133  EnergyMap tbemap;
134  if ( pose.energies().use_nblist() ) return; // intraresidue atom pairs present in neighborlist, evaluated during finalize
135 
136  count_pair::CountPairFunctionOP cpfxn = get_intrares_countpair( res, pose, sfxn );
137  //cpfxn->residue_atom_pair_energy( res, res, *this, tbemap );
138  intrares_evaluator_.residue_atom_pair_energy( res, res, *cpfxn, tbemap );
139  emap[ intrares_evaluator_.st_atr() ] = tbemap[ intrares_evaluator_.st_atr() ];
140  emap[ intrares_evaluator_.st_rep() ] = tbemap[ intrares_evaluator_.st_rep() ];
141  emap[ intrares_evaluator_.st_sol() ] = tbemap[ intrares_evaluator_.st_sol() ];
142 }
143 
144 
145 /// @details
146 /// Version 2: apl - 2012/06/14 -- Etable smoothing change for LK sol. Placing the
147 /// start point for the spline that ramps the LJatr term to zero at the minimum of
148 /// a) the VDW sum and b) (max_dis - 1.5), which, for famaxdis of 6 is 4.5 A. This
149 /// change effects the Br/Br and Br/I energies but no other atom-type pairs.
152 {
153  return 2;
154  //return 1; // Initial versioning
155 }
156 
157 
158 /////////////////////// Analytic Etable Energy Evaluation /////////////////////////////////
159 
160 
161 /// construction with an etable
163  Etable const & etable_in,
164  methods::EnergyMethodOptions const & options
165 ) :
166  BaseEtableEnergy< AnalyticEtableEnergy > ( new EtableEnergyCreator, etable_in, options ),
167  intrares_evaluator_( etable_in ),
168  interres_evaluator_( etable_in )
169 {
172 }
173 
175  AnalyticEtableEnergy const & src
176 ) :
178  intrares_evaluator_( src.intrares_evaluator_ ),
179  interres_evaluator_( src.interres_evaluator_ )
180 {
181 }
182 
185  return new AnalyticEtableEnergy( *this );
186 }
187 
188 void
190 {
191  if (pose.total_residue()) {
192  if ( pose.residue(1).type().atom_type_set_ptr() != etable().atom_set() ) {
193  utility_exit_with_message( "Illegal attempt to score with non-identical atom set between pose and etable " );
194  }
195  }
196 }
197 
198 bool
200  EnergyMap const & weights
201 ) const
202 {
203  return ( weights[ fa_intra_atr ] != 0 ||
204  weights[ fa_intra_rep ] != 0 ||
205  weights[ fa_intra_sol ] != 0 );
206 }
207 
208 /// @brief
209 void
211  conformation::Residue const & res,
212  pose::Pose const & pose,
213  ScoreFunction const & sfxn,
214  EnergyMap & emap
215 ) const
216 {
217  // ignore scoring residues which have been marked as "REPLONLY" residues (only the repulsive energy will be calculated)
219  return;
220  }
221 
222  EnergyMap tbemap;
223  if ( pose.energies().use_nblist() ) return; // intraresidue atom pairs present in neighborlist, evaluated during finalize
224 
225  count_pair::CountPairFunctionOP cpfxn = get_intrares_countpair( res, pose, sfxn );
226  //cpfxn->residue_atom_pair_energy( res, res, *this, tbemap );
227  intrares_evaluator_.residue_atom_pair_energy( res, res, *cpfxn, tbemap );
228  emap[ intrares_evaluator_.st_atr() ] = tbemap[ intrares_evaluator_.st_atr() ];
229  emap[ intrares_evaluator_.st_rep() ] = tbemap[ intrares_evaluator_.st_rep() ];
230  emap[ intrares_evaluator_.st_sol() ] = tbemap[ intrares_evaluator_.st_sol() ];
231 }
234 {
235  return 2; // apl - 2012/06/14 -- analytic version kept in sync with table-based version.
236  // return 1; // Initial versioning
237 }
238 
239 
241  atr_weight_( 1.0 ),
242  rep_weight_( 1.0 ),
243  sol_weight_( 1.0 ),
244  st_atr_( fa_atr ),
245  st_rep_( fa_rep ),
246  st_sol_( fa_sol ),
247  hydrogen_interaction_cutoff2_( etable.hydrogen_interaction_cutoff2() )
248 {}
249 
251 
253  Etable const & etable_in
254 ) :
255  EtableEvaluator( etable_in ),
256  ljatr_( etable_in.ljatr() ),
257  ljrep_( etable_in.ljrep() ),
258  solv1_( etable_in.solv1() ),
259  solv2_( etable_in.solv2() ),
260  dljatr_( etable_in.dljatr() ),
261  dljrep_( etable_in.dljrep() ),
262  dsolv_( etable_in.dsolv() ),
263  safe_max_dis2_( etable_in.get_safe_max_dis2() ),
264  etable_bins_per_A2_( etable_in.get_bins_per_A2() ),
265  dis2_step_( 1.0 / (Real) etable_bins_per_A2_ )
266 {}
267 
269 
270 
271 /// @details atom-pair-energy inline type resolution function
272 void
274  conformation::Residue const & rsd1,
275  conformation::Residue const & rsd2,
277  EnergyMap & emap
278 ) const
279 {
280  cp.residue_atom_pair_energy( rsd1, rsd2, *this, emap );
281 }
282 
283 /// @details atom-pair-energy inline type resolution function
284 void
286  conformation::Residue const & rsd1,
287  conformation::Residue const & rsd2,
289  EnergyMap & emap
290 ) const
291 {
292  cp.residue_atom_pair_energy_sidechain_backbone( rsd1, rsd2, *this, emap );
293 }
294 
295 /// @details atom-pair-energy inline type resolution function
296 void
298  conformation::Residue const & rsd1,
299  conformation::Residue const & rsd2,
301  EnergyMap & emap
302 ) const
303 {
304  cp.residue_atom_pair_energy_sidechain_whole( rsd1, rsd2, *this, emap );
305 }
306 
307 
308 /// @details atom-pair-energy inline type resolution function
309 void
311  conformation::Residue const & rsd1,
312  conformation::Residue const & rsd2,
314  EnergyMap & emap
315 ) const
316 {
317  cp.residue_atom_pair_energy_backbone_backbone( rsd1, rsd2, *this, emap );
318 }
319 
320 /// @details atom-pair-energy inline type resolution function
321 void
323  conformation::Residue const & rsd1,
324  conformation::Residue const & rsd2,
326  EnergyMap & emap
327 ) const
328 {
329  cp.residue_atom_pair_energy_sidechain_sidechain( rsd1, rsd2, *this, emap );
330 }
331 
332 
333 /// @details first level polymorphic type resolution function
334 void
336  trie::RotamerTrieBase const & trie1,
337  trie::RotamerTrieBase const & trie2,
339  ObjexxFCL::FArray2D< core::PackerEnergy > & pair_energy_table,
340  ObjexxFCL::FArray2D< core::PackerEnergy > & temp_table
341 ) const
342 {
343  trie1.trie_vs_trie( trie2, cp, *this, pair_energy_table, temp_table );
344 }
345 
346 /// @details first level polymorphic type resolution function
347 void
349  trie::RotamerTrieBase const & trie1,
350  trie::RotamerTrieBase const & trie2,
352  utility::vector1< core::PackerEnergy > & pair_energy_vector,
354 ) const
355 {
356  trie1.trie_vs_path( trie2, cp, *this, pair_energy_vector, temp_vector );
357 }
358 
359 
361  EtableEvaluator( etable ),
362  etable_( etable ),
363  safe_max_dis2_( etable.get_safe_max_dis2() )
364 {}
365 
367 
368 
369 /// @details atom-pair-energy inline type resolution function
370 void
372  conformation::Residue const & rsd1,
373  conformation::Residue const & rsd2,
375  EnergyMap & emap
376 ) const
377 {
378  cp.residue_atom_pair_energy( rsd1, rsd2, *this, emap );
379 }
380 
381 /// @details atom-pair-energy inline type resolution function
382 void
384  conformation::Residue const & rsd1,
385  conformation::Residue const & rsd2,
387  EnergyMap & emap
388 ) const
389 {
390  cp.residue_atom_pair_energy_sidechain_backbone( rsd1, rsd2, *this, emap );
391 }
392 
393 /// @details atom-pair-energy inline type resolution function
394 void
396  conformation::Residue const & rsd1,
397  conformation::Residue const & rsd2,
399  EnergyMap & emap
400 ) const
401 {
402  cp.residue_atom_pair_energy_sidechain_whole( rsd1, rsd2, *this, emap );
403 }
404 
405 
406 /// @details atom-pair-energy inline type resolution function
407 void
409  conformation::Residue const & rsd1,
410  conformation::Residue const & rsd2,
412  EnergyMap & emap
413 ) const
414 {
415  cp.residue_atom_pair_energy_backbone_backbone( rsd1, rsd2, *this, emap );
416 }
417 
418 /// @details atom-pair-energy inline type resolution function
419 void
421  conformation::Residue const & rsd1,
422  conformation::Residue const & rsd2,
424  EnergyMap & emap
425 ) const
426 {
427  cp.residue_atom_pair_energy_sidechain_sidechain( rsd1, rsd2, *this, emap );
428 }
429 
430 
431 
432 /// @details first level polymorphic type resolution function
433 void
435  trie::RotamerTrieBase const & trie1,
436  trie::RotamerTrieBase const & trie2,
438  ObjexxFCL::FArray2D< core::PackerEnergy > & pair_energy_table,
439  ObjexxFCL::FArray2D< core::PackerEnergy > & temp_table
440 ) const
441 {
442  trie1.trie_vs_trie( trie2, cp, *this, pair_energy_table, temp_table );
443 }
444 
445 /// @details first level polymorphic type resolution function
446 void
448  trie::RotamerTrieBase const & trie1,
449  trie::RotamerTrieBase const & trie2,
451  utility::vector1< core::PackerEnergy > & pair_energy_vector,
453 ) const
454 {
455  trie1.trie_vs_path( trie2, cp, *this, pair_energy_vector, temp_vector );
456 }
457 
458 
459 } // namespace etable
460 } // namespace scoring
461 } // namespace core