Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FACTSEnergy.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/facts/FACTSEnergy.cc
11 // @brief
12 // @author Massih Khorvash
13 // @author: Hahnbeom Park
14 
15 // Unit headers
19 
20 // Project headers
24 #include <core/scoring/Energies.hh>
28 
29 #include <core/pose/Pose.hh>
30 #include <core/id/AtomID.fwd.hh>
31 #include <core/id/AtomID.hh>
35 
36 #include <basic/datacache/CacheableData.hh>
37 #include <basic/prof.hh>
38 
39 // Utility headers
40 #include <utility/vector1.hh>
41 
42 
43 namespace core {
44 namespace scoring {
45 namespace methods {
46 
47 /// @details This must return a fresh instance of the GenBornEnergy class,
48 /// never an instance already in use
49 methods::EnergyMethodOP FACTSEnergyCreator::create_energy_method(
50  methods::EnergyMethodOptions const & options
51 ) const {
52  return new FACTSEnergy( options );
53 }
54 
55 ScoreTypes FACTSEnergyCreator::score_types_for_method() const {
56  ScoreTypes sts;
57  sts.push_back( facts_elec );
58  sts.push_back( facts_sasa );
59  return sts;
60 }
61 
63  parent( src ),
64  potential_( src.potential_ ),
65  exclude_DNA_DNA_( src.exclude_DNA_DNA_ )
66 {}
67 
69  parent( new FACTSEnergyCreator ),
70  potential_( ScoringManager::get_instance()->get_FACTSPotential() ),
71  exclude_DNA_DNA_( options.exclude_DNA_DNA() )
72 {}
73 
74 /// clone
76 {
77  return new FACTSEnergy( *this );
78 }
79 
81  pose::Pose const &,
82  Size,
83  Size
84 ) const
85 {
86  return true;
87 }
88 
89 ///
90 void
92  pose::Pose & pose,
93  utility::vector1< bool > const & residues_repacking,
95 ) const
96 {
98 
99  /// build placeholders, compute template born radii, stash in Pose
100  potential_.setup_for_packing( pose, residues_repacking );
101 
102 }
103 
105  pose::Pose const & pose,
106  //pack::rotamer_set::RotamerSet & rotamer_set
107  conformation::RotamerSetBase & rotamer_set
108 ) const
109 {
110  /// this will stash rotamer born radii in rotamer set
111  potential_.get_rotamers_born_radii( pose, rotamer_set );
112 }
113 
115  pose::Pose & pose,
116  Size resid
117 ) const
118 {
119  /// update born radii for residue that has changed during packing, eg in rotamer trials
120  /// need to double-check the current logic on this...
121  potential_.update_residue_for_packing( pose, resid );
122 }
123 
124 //
126 {
127  methods::LongRangeEnergyType const & lr_type( long_range_type() );
128 
130 
131  // create a container
132  Energies & energies( pose.energies() );
133  bool create_new_lre_container( false );
134 
135  if ( energies.long_range_container( lr_type ) == 0 ) {
136  create_new_lre_container = true;
137  } else {
138  LREnergyContainerOP lrc = energies.nonconst_long_range_container( lr_type );
139  DenseEnergyContainerOP dec( static_cast< DenseEnergyContainer * > ( lrc.get() ) );
140  if ( dec->size() != pose.total_residue() ) {
141  create_new_lre_container = true;
142  }
143  }
144 
145  if ( create_new_lre_container ) {
146  LREnergyContainerOP new_dec_elec = new DenseEnergyContainer( pose.total_residue(), facts_elec );
147  energies.set_long_range_container( lr_type, new_dec_elec );
148  LREnergyContainerOP new_dec_sasa = new DenseEnergyContainer( pose.total_residue(), facts_sasa );
149  energies.set_long_range_container( lr_type, new_dec_sasa );
150  }
151 }
152 
154 {
156 }
157 
158 /////////////////////////////////////////////////////////////////////////////
159 // scoring
160 /////////////////////////////////////////////////////////////////////////////
161 
163  conformation::Residue const & rsd1,
164  conformation::Residue const & rsd2,
165  pose::Pose const & pose,
166  ScoreFunction const &,
167  EnergyMap & emap
168 ) const
169 {
170  if ( exclude_DNA_DNA_ && rsd1.is_DNA() && rsd2.is_DNA() ) return;
171 
172  FACTSPoseInfo const & facts_info
173  ( static_cast< FACTSPoseInfo const & >( pose.data().get( pose::datacache::CacheableDataType::FACTS_POSE_INFO ) ) ); // SHOULD BE FAST!
174 
175  emap[ facts_elec ] += potential_.evaluate_polar_energy( rsd1, facts_info.residue_info( rsd1.seqpos() ),
176  rsd2 );
177  if ( rsd1.seqpos() == rsd2.seqpos() ){
178  emap[ facts_sasa ] += potential_.evaluate_nonpolar_energy( rsd1, facts_info.residue_info( rsd1.seqpos() ),
179  rsd2 );
180  }
181 }
182 
184  conformation::RotamerSetBase const & set,
185  pose::Pose const & pose,
186  ScoreFunction const & sfxn,
188 ) const
189 {
190 
191  using namespace conformation;
192  using namespace numeric;
193  using core::conformation::RotamerSetCacheableDataType::FACTS_ROTAMER_SET_INFO;
194 
195  if ( exclude_DNA_DNA_ && pose.residue( set.resid() ).is_DNA() ) return;
196 
197  FACTSRotamerSetInfo const & facts_info
198  ( set.data().get< FACTSRotamerSetInfo >( FACTS_ROTAMER_SET_INFO ) );
199 
200  FACTSPoseInfo const & facts_pose_info
201  ( static_cast< FACTSPoseInfo const & >( pose.data().get( pose::datacache::CacheableDataType::FACTS_POSE_INFO ) ) );
202 
203  utility::vector1< Real > dBRi1( pose.residue(set.resid()).natoms(), 0.0 );
204  utility::vector1< Real > dBRi2( pose.residue(set.resid()).natoms(), 0.0 );
205  utility::vector1< Real > dSAi1( pose.residue(set.resid()).natoms(), 0.0 );
206  utility::vector1< Real > dSAi2( pose.residue(set.resid()).natoms(), 0.0 );
207 
208  for ( Size ii = 1, ii_end = set.num_rotamers(); ii <= ii_end; ++ii ) {
209 
210  Real const polarE_noncorrect =
211  potential_.evaluate_polar_otf_energy( *set.rotamer( ii ), facts_info.residue_info( ii ),
212  *set.rotamer( ii ), facts_info.residue_info( ii ),
213  dBRi1, dBRi2, false );
214 
215  Real const polarE_correct = 0.0;
216  //Real const polarE_correct =
217  // potential_.polar_energy_pack_corrector( pose.residue( set.resid()),
218  // *set.rotamer( ii ),
219  // facts_pose_info.residue_info( set.resid() ) );
220 
221  Real const polarE = polarE_noncorrect + polarE_correct;
222 
223  Real const nonpolarE
224  ( potential_.evaluate_nonpolar_energy( *set.rotamer( ii ), facts_info.residue_info( ii ),
225  *set.rotamer( ii ) ));
226 
227  energies[ ii ] += static_cast< core::PackerEnergy > ( sfxn[ facts_elec ] * polarE
228  + sfxn[ facts_sasa ] * nonpolarE);
229 
230  }
231 }
232 
234  conformation::RotamerSetBase const & set,
235  pose::Pose const & pose,
236  ScoreFunction const & ,
238 ) const
239 {
240  using namespace conformation;
241  using namespace numeric;
242  using core::conformation::RotamerSetCacheableDataType::FACTS_ROTAMER_SET_INFO;
243 
244  if ( exclude_DNA_DNA_ && pose.residue( set.resid() ).is_DNA() ) return;
245 
246  FACTSRotamerSetInfo const & facts_info
247  ( set.data().get< FACTSRotamerSetInfo >( FACTS_ROTAMER_SET_INFO ) );
248 
249  utility::vector1< Real > dBRi1( pose.residue(set.resid()).natoms(), 0.0 );
250  utility::vector1< Real > dBRi2( pose.residue(set.resid()).natoms(), 0.0 );
251  utility::vector1< Real > dSAi1( pose.residue(set.resid()).natoms(), 0.0 );
252  utility::vector1< Real > dSAi2( pose.residue(set.resid()).natoms(), 0.0 );
253 
254  for ( Size ii = 1, ii_end = set.num_rotamers(); ii <= ii_end; ++ii ) {
255 
256  Real const polarE
257  ( potential_.evaluate_polar_otf_energy( *set.rotamer( ii ), facts_info.residue_info( ii ),
258  *set.rotamer( ii ), facts_info.residue_info( ii ),
259  dBRi1, dBRi2,
260  false ) );
261  Real const nonpolarE
262  ( potential_.evaluate_nonpolar_energy( *set.rotamer( ii ), facts_info.residue_info( ii ),
263  *set.rotamer( ii ) ));
264 
265  (emaps[ ii ])[ facts_elec ] += polarE ;
266  (emaps[ ii ])[ facts_sasa ] += nonpolarE ;
267  }
268 }
269 
271  conformation::RotamerSetBase const & set1,
272  conformation::RotamerSetBase const & set2,
273  pose::Pose const & pose,
274  ScoreFunction const &, // sfxn,
275  EnergyMap const & weights,
276  ObjexxFCL::FArray2D< core::PackerEnergy > & energy_table
277 ) const
278 {
279  using namespace conformation;
280  using namespace numeric;
281  using core::conformation::RotamerSetCacheableDataType::FACTS_ROTAMER_SET_INFO;
282 
283  //cout << "eval_pairres" << endl;
284  if ( exclude_DNA_DNA_ && pose.residue( set1.resid() ).is_DNA() && pose.residue( set2.resid() ).is_DNA() ) return;
285 
286  PROF_START( basic::FACTS_ROTAMER_PAIR_ENERGIES );
287 
288  FACTSRotamerSetInfo const & facts_info1
289  ( set1.data().get< FACTSRotamerSetInfo >( FACTS_ROTAMER_SET_INFO ) );
290 
291  FACTSRotamerSetInfo const & facts_info2
292  ( set2.data().get< FACTSRotamerSetInfo >( FACTS_ROTAMER_SET_INFO ) );
293 
294  utility::vector1< Real > dBRi1( pose.residue(set1.resid()).natoms(), 0.0 );
295  utility::vector1< Real > dBRi2( pose.residue(set2.resid()).natoms(), 0.0 );
296  utility::vector1< Real > dSAi1( pose.residue(set1.resid()).natoms(), 0.0 );
297  utility::vector1< Real > dSAi2( pose.residue(set2.resid()).natoms(), 0.0 );
298 
299  for ( Size ii = 1; ii <= set1.get_n_residue_types(); ++ii ) {
300  Size const ii_offset = set1.get_residue_type_begin( ii );
301  Residue const & ii_example_rotamer( *set1.rotamer( ii_offset ));
302 
303  Vector const & ii_coord( ii_example_rotamer.nbr_atom_xyz() );
304  Real const ii_radius( ii_example_rotamer.nbr_radius() );
305 
306  for ( Size jj = 1; jj <= set2.get_n_residue_types(); ++jj ) {
307  Size const jj_offset = set2.get_residue_type_begin( jj );
308  Residue const & jj_example_rotamer( *set2.rotamer( jj_offset ));
309 
310  if ( exclude_DNA_DNA_ && ii_example_rotamer.is_DNA() && jj_example_rotamer.is_DNA() ) continue;
311 
312  Vector const & jj_coord( jj_example_rotamer.nbr_atom_xyz() );
313  Real const jj_radius( jj_example_rotamer.nbr_radius() );
314 
315  if ( ii_coord.distance_squared( jj_coord ) < std::pow(ii_radius+jj_radius+packing_interaction_cutoff(), 2 )) {
316  for ( Size kk = 1, kke = set1.get_n_rotamers_for_residue_type( ii ); kk <= kke; ++kk ) {
317  Size const kk_rot_id = ii_offset + kk - 1;
318  for ( Size ll = 1, lle = set2.get_n_rotamers_for_residue_type( jj ); ll <= lle; ++ll ) {
319  Size const ll_rot_id = jj_offset + ll - 1;
320 
321  /*
322  potential_.evaluate_context_change_for_packing(
323  pose.residue( set1.resid() ),
324  *set1.rotamer( kk_rot_id ), facts_info1.residue_info( kk_rot_id ),
325  pose.residue( set2.resid() ),
326  *set2.rotamer( ll_rot_id ), facts_info2.residue_info( ll_rot_id ),
327  dBRi1, dBRi2, dSAi1, dSAi2 );
328  */
329 
330  Real const polarE
331  ( potential_.evaluate_polar_otf_energy( *set1.rotamer( kk_rot_id ), facts_info1.residue_info( kk_rot_id ),
332  *set2.rotamer( ll_rot_id ), facts_info2.residue_info( ll_rot_id ),
333  dBRi1, dBRi2,
334  false ));
335  Real const nonpolarE
336  ( potential_.evaluate_nonpolar_energy( *set1.rotamer( kk_rot_id ), facts_info1.residue_info( kk_rot_id ),
337  *set2.rotamer( ll_rot_id ) ) );
338 
339  energy_table( ll_rot_id, kk_rot_id ) += static_cast< core::PackerEnergy >( weights[ facts_elec ] * polarE
340  + weights[ facts_sasa ] * nonpolarE );
341  //std::cout << "Pair: " << set1.resid() << " " << set2.resid() << " " << kk_rot_id << " ";
342  //std::cout << ll_rot_id << " " << polarE << " " << nonpolarE << std::endl;
343  }
344  }
345  }
346  }
347  }
348  PROF_START( basic::FACTS_ROTAMER_PAIR_ENERGIES );
349 }
350 
351 /*
352 // Below is a lazy version for checking pair term score
353 // Note that this is also "not exact", since during packing context should be changed, which couldn't be updated on the fly
354 void FACTSEnergy::evaluate_rotamer_pair_energies(
355  conformation::RotamerSetBase const & set1,
356  conformation::RotamerSetBase const & set2,
357  pose::Pose const & pose,
358  ScoreFunction const &, // sfxn,
359  EnergyMap const & weights,
360  ObjexxFCL::FArray2D< core::PackerEnergy > & energy_table
361 ) const
362 {
363  using namespace conformation;
364  using namespace numeric;
365  using core::conformation::RotamerSetCacheableDataType::FACTS_ROTAMER_SET_INFO;
366 
367  //cout << "eval_pairres" << endl;
368  if ( exclude_DNA_DNA_ && pose.residue( set1.resid() ).is_DNA() && pose.residue( set2.resid() ).is_DNA() ) return;
369 
370  PROF_START( basic::FACTS_ROTAMER_PAIR_ENERGIES );
371 
372  FACTSRotamerSetInfo const & facts_info1
373  ( set1.data().get< FACTSRotamerSetInfo >( FACTS_ROTAMER_SET_INFO ) );
374 
375  FACTSRotamerSetInfo const & facts_info2
376  ( set2.data().get< FACTSRotamerSetInfo >( FACTS_ROTAMER_SET_INFO ) );
377 
378  FACTSPoseInfo const & facts_info_pose( static_cast< FACTSPoseInfo const & >
379  (pose.data().get( core::pose::datacache::CacheableDataType::FACTS_POSE_INFO )));
380 
381  core::pose::Pose pose_tmp( pose );
382 
383  for ( Size ii = 1; ii <= set1.get_n_residue_types(); ++ii ) {
384  Size const ii_offset = set1.get_residue_type_begin( ii );
385  Residue const & ii_example_rotamer( *set1.rotamer( ii_offset ));
386 
387  Vector const & ii_coord( ii_example_rotamer.nbr_atom_xyz() );
388  Real const ii_radius( ii_example_rotamer.nbr_radius() );
389 
390  for ( Size jj = 1; jj <= set2.get_n_residue_types(); ++jj ) {
391  Size const jj_offset = set2.get_residue_type_begin( jj );
392  Residue const & jj_example_rotamer( *set2.rotamer( jj_offset ));
393 
394  if ( exclude_DNA_DNA_ && ii_example_rotamer.is_DNA() && jj_example_rotamer.is_DNA() ) continue;
395 
396  Vector const & jj_coord( jj_example_rotamer.nbr_atom_xyz() );
397  Real const jj_radius( jj_example_rotamer.nbr_radius() );
398 
399  if ( ii_coord.distance_squared( jj_coord ) < std::pow(ii_radius+jj_radius+packing_interaction_cutoff(), 2 )) {
400  for ( Size kk = 1, kke = set1.get_n_rotamers_for_residue_type( ii ); kk <= kke; ++kk ) {
401  Size const kk_rot_id = ii_offset + kk - 1;
402 
403  pose_tmp.replace_residue( set1.resid(), *set1.rotamer( kk_rot_id), false );
404 
405  for ( Size ll = 1, lle = set2.get_n_rotamers_for_residue_type( jj ); ll <= lle; ++ll ) {
406  Size const ll_rot_id = jj_offset + ll - 1;
407 
408  pose_tmp.replace_residue( set2.resid(), *set2.rotamer( ll_rot_id), false );
409 
410  potential_.setup_for_scoring( pose_tmp );
411  FACTSResidueInfo const & facts1
412  ( pose_tmp.data().get< FACTSPoseInfo >( core::pose::datacache::CacheableDataType::FACTS_POSE_INFO ).residue_info(set1.resid()) );
413  FACTSResidueInfo const & facts2
414  ( pose_tmp.data().get< FACTSPoseInfo >( core::pose::datacache::CacheableDataType::FACTS_POSE_INFO ).residue_info(set2.resid()) );
415 
416  //FACTSResidueInfo facts1 = facts_info1.residue_info( kk_rot_id );
417  //facts1.initialize( pose_tmp.residue(set1.resid()) );
418  //potential_.get_single_rotamer_born_radii( pose_tmp.residue(set1.resid()), pose_tmp, facts_info_pose, facts1 );
419 
420  //FACTSResidueInfo facts2 = facts_info2.residue_info( ll_rot_id );
421  //facts2.initialize( pose_tmp.residue(set2.resid()) );
422  //potential_.get_single_rotamer_born_radii( pose_tmp.residue(set2.resid()), pose_tmp, facts_info_pose, facts2 );
423 
424  Real const polarE
425  ( potential_.evaluate_polar_otf_energy( pose.residue( set1.resid() ), *set1.rotamer( kk_rot_id ), facts1,
426  pose.residue( set2.resid() ), *set2.rotamer( ll_rot_id ), facts2, false ));
427  Real const nonpolarE
428  ( potential_.evaluate_nonpolar_energy( *set1.rotamer( kk_rot_id ), facts1,
429  *set2.rotamer( ll_rot_id ) ) );
430 
431  energy_table( ll_rot_id, kk_rot_id ) += static_cast< core::PackerEnergy >( weights[ facts_elec ] * polarE
432  + weights[ facts_sasa ] * nonpolarE );
433  std::cout << "Pair: " << set1.resid() << " " << set2.resid() << " " << kk_rot_id << " ";
434  std::cout << ll_rot_id << " " << polarE << " " << nonpolarE << std::endl;
435  }
436  }
437  }
438  }
439  }
440  PROF_START( basic::FACTS_ROTAMER_PAIR_ENERGIES );
441 }
442 */
443 
445  conformation::RotamerSetBase const & set,
446  conformation::Residue const & rsd,
447  pose::Pose const & pose,
448  ScoreFunction const &, // sfxn,
449  EnergyMap const & weights,
451 ) const
452 {
453  //cout << "eval_background" << endl;
454 
455  PROF_START( basic::FACTS_ROTAMER_BACKGROUND_ENERGIES );
456 
457  using conformation::Residue;
458  using core::conformation::RotamerSetCacheableDataType::FACTS_ROTAMER_SET_INFO;
459 
460  FACTSResidueInfo const & facts_rsd_info
461  ( pose.data().get< FACTSPoseInfo >( core::pose::datacache::CacheableDataType::FACTS_POSE_INFO ).residue_info(rsd.seqpos()));
462 
463  FACTSRotamerSetInfo const & facts_set_info
464  ( set.data().get< FACTSRotamerSetInfo >( FACTS_ROTAMER_SET_INFO ) );
465 
466  utility::vector1< Real > dBRi1( pose.residue(set.resid()).natoms(), 0.0 );
467  utility::vector1< Real > dBRi2( rsd.natoms(), 0.0 );
468  utility::vector1< Real > dSAi1( pose.residue(set.resid()).natoms(), 0.0 );
469  utility::vector1< Real > dSAi2( rsd.natoms(), 0.0 );
470 
471  for ( Size ii = 1; ii <= set.get_n_residue_types(); ++ii ) {
472  Size const ii_offset = set.get_residue_type_begin( ii );
473  Residue const & ii_example_rotamer( *set.rotamer( ii_offset ));
474 
475  Vector const & ii_coord( ii_example_rotamer.nbr_atom_xyz() );
476  Real const ii_radius( ii_example_rotamer.nbr_radius() );
477 
478  if ( exclude_DNA_DNA_ && ii_example_rotamer.is_DNA() && rsd.is_DNA() ) continue;
479 
480  Vector const & jj_coord( rsd.nbr_atom_xyz() );
481  Real const jj_radius( rsd.nbr_radius() );
482 
483  if ( ii_coord.distance_squared( jj_coord ) < std::pow(ii_radius+jj_radius+packing_interaction_cutoff(), 2 )) {
484  for ( Size kk = 1, kke = set.get_n_rotamers_for_residue_type( ii ); kk <= kke; ++kk ) {
485  Size const kk_rot_id = ii_offset + kk - 1;
486 
487  /*
488  potential_.evaluate_context_change_for_packing(
489  pose.residue( set.resid() ),
490  *set.rotamer( kk_rot_id ), facts_set_info.residue_info( kk_rot_id ),
491  rsd,
492  rsd, facts_rsd_info,
493  dBRi1, dBRi2, dSAi1, dSAi2 );
494  */
495 
496  Real const polarE
497  ( potential_.evaluate_polar_otf_energy( *set.rotamer( kk_rot_id ), facts_set_info.residue_info( kk_rot_id ),
498  rsd, facts_rsd_info,
499  dBRi1, dBRi2, false ) );
500  Real const nonpolarE
501  ( potential_.evaluate_nonpolar_energy( *set.rotamer( kk_rot_id ), facts_set_info.residue_info( kk_rot_id ),
502  rsd) );
503  energy_vector[ kk_rot_id ] += static_cast< core::PackerEnergy > (weights[ facts_elec ] * polarE
504  + weights[ facts_sasa ] * nonpolarE );
505  //std::cout << "Background: " << ii << " " << kk << " " << kk_rot_id << " " << polarE << " " << nonpolarE << std::endl;
506  } // kk - rotamers for residue types
507  } // nbrs
508  } // ii - residue types for rotamer set
509  PROF_STOP( basic::FACTS_ROTAMER_BACKGROUND_ENERGIES );
510 }
511 
513  conformation::RotamerSetBase const & set,
514  conformation::Residue const & rsd,
515  pose::Pose const & pose,
516  ScoreFunction const &, // sfxn,
517  EnergyMap const & ,
519 ) const
520 {
521  using conformation::Residue;
522  using core::conformation::RotamerSetCacheableDataType::FACTS_ROTAMER_SET_INFO;
523 
524  FACTSResidueInfo const & facts_rsd_info
525  ( pose.data().get< FACTSPoseInfo >( core::pose::datacache::CacheableDataType::FACTS_POSE_INFO ).residue_info(rsd.seqpos()));
526 
527  FACTSRotamerSetInfo const & facts_set_info
528  ( set.data().get< FACTSRotamerSetInfo >( FACTS_ROTAMER_SET_INFO ) );
529 
530  utility::vector1< Real > dBRi1( pose.residue(set.resid()).natoms(), 0.0 );
531  utility::vector1< Real > dBRi2( rsd.natoms(), 0.0 );
532  utility::vector1< Real > dSAi1( pose.residue(set.resid()).natoms(), 0.0 );
533  utility::vector1< Real > dSAi2( rsd.natoms(), 0.0 );
534 
535  for ( Size ii = 1; ii <= set.get_n_residue_types(); ++ii ) {
536  Size const ii_offset = set.get_residue_type_begin( ii );
537  Residue const & ii_example_rotamer( *set.rotamer( ii_offset ));
538 
539  Vector const & ii_coord( ii_example_rotamer.nbr_atom_xyz() );
540  Real const ii_radius( ii_example_rotamer.nbr_radius() );
541 
542  if ( exclude_DNA_DNA_ && ii_example_rotamer.is_DNA() && rsd.is_DNA() ) continue;
543 
544  Vector const & jj_coord( rsd.nbr_atom_xyz() );
545  Real const jj_radius( rsd.nbr_radius() );
546 
547  if ( ii_coord.distance_squared( jj_coord ) < std::pow(ii_radius+jj_radius+packing_interaction_cutoff(), 2 )) {
548  for ( Size kk = 1, kke = set.get_n_rotamers_for_residue_type( ii ); kk <= kke; ++kk ) {
549  Size const kk_rot_id = ii_offset + kk - 1;
550 
551  Real const polarE
552  ( potential_.evaluate_polar_otf_energy( *set.rotamer( kk_rot_id ), facts_set_info.residue_info( kk_rot_id ),
553  rsd, facts_rsd_info,
554  dBRi1, dBRi2, false) );
555  Real const nonpolarE
556  ( potential_.evaluate_nonpolar_energy( *set.rotamer( kk_rot_id ), facts_set_info.residue_info( kk_rot_id ),
557  rsd ) );
558  (emaps[ kk_rot_id ])[ facts_elec ] += polarE;
559  (emaps[ kk_rot_id ])[ facts_sasa ] += nonpolarE;
560  } // kk - rotamers for residue types
561  } // nbrs
562  } // ii - residue types for rotamer set
563 }
564 
565 
566 /////////////////////////////////////////////////////////////////////////////
567 ///
569  id::AtomID const & atom_id,
570  pose::Pose const & pose,
571  kinematics::DomainMap const & domain_map,
572  ScoreFunction const &,
573  EnergyMap const & weights,
574  Vector & F1,
575  Vector & F2
576 ) const
577 {
578  potential_.eval_atom_polar_derivative( atom_id, weights[ facts_elec ], pose, domain_map, exclude_DNA_DNA_, F1, F2 );
579  potential_.eval_atom_nonpolar_derivative( atom_id, weights[ facts_sasa ], pose, domain_map, exclude_DNA_DNA_, F1, F2 );
580 }
581 
582 /// @brief FACTSEnergy requires no context graphs
584 {
585 }
586 
587 /// @brief FACTSEnergy does define intraresidue interactions
588 bool FACTSEnergy::defines_intrares_energy( EnergyMap const & /*weights*/ ) const
589 {
590  return true;
591 }
592 
594  conformation::Residue const & rsd,
595  pose::Pose const & pose,
596  ScoreFunction const &,
597  EnergyMap & emap
598 ) const
599 {
600  if ( exclude_DNA_DNA_ && rsd.is_DNA() ) return;
601 
602  FACTSResidueInfo const & facts
603  ( pose.data().get< FACTSPoseInfo >( core::pose::datacache::CacheableDataType::FACTS_POSE_INFO ).residue_info( rsd.seqpos()));
604 
605  emap[ facts_elec ] += potential_.evaluate_polar_energy( rsd, facts, rsd );
606  emap[ facts_sasa ] += potential_.evaluate_nonpolar_energy( rsd, facts, rsd );
607 
608 }
609 
611 {
612  return 1;
613 }
614 
615 }
616 }
617 }