Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HBondEnergy.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/HBondEnergy.fwd.hh
11 /// @brief Hydrogen bond energy method forward declaration
12 /// @author Phil Bradley
13 /// @author Andrew Leaver-Fay
14 
15 
16 
17 // Unit Headers
20 
21 // Package headers
22 #include <core/scoring/Energies.hh>
29 
34 
42 
44 
45 //pba membrane specific initialization
47 // AUTO-REMOVED #include <core/scoring/MembraneTopology.hh>
48 // AUTO-REMOVED #include <core/pose/datacache/CacheableDataType.hh>
49 #include <basic/datacache/BasicDataCache.hh>
50 
51 //#include <core/scoring/ScoringManager.hh>
52 
53 // Project headers
55 ///#include <core/pack/rotamer_set/RotamerSetFactory.hh>
57 
58 #include <core/pose/Pose.hh>
59 #include <basic/Tracer.hh>
60 #include <basic/datacache/CacheableData.hh>
61 
62 // Option Keys Headers
63 // AUTO-REMOVED #include <basic/options/option.hh>
64 // AUTO-REMOVED #include <basic/options/keys/in.OptionKeys.gen.hh>
65 // AUTO-REMOVED #include <basic/options/keys/corrections.OptionKeys.gen.hh>
66 
67 // Numeric Headers
68 #include <numeric/numeric.functions.hh>
69 
70 // ObjexxFCL Headers
71 // AUTO-REMOVED #include <ObjexxFCL/format.hh>
72 
75 #include <core/id/types.hh>
78 #include <utility/vector1.hh>
79 
80 namespace core {
81 namespace scoring {
82 namespace hbonds {
83 
84 class HBondResidueMinData;
86 
89 
92 
93 /// @brief A class to hold data for the HBondEnergy class used in
94 /// score and derivative evaluation.
95 class HBondResidueMinData : public basic::datacache::CacheableData
96 {
97 public:
99  virtual ~HBondResidueMinData() {}
100 
101  virtual basic::datacache::CacheableDataOP clone() const
102  { return new HBondResidueMinData( *this ); }
103 
104  void set_bb_don_avail( bool setting ) { bb_don_avail_ = setting; }
105  void set_bb_acc_avail( bool setting ) { bb_acc_avail_ = setting; }
106 
107  bool bb_don_avail() const { return bb_don_avail_; }
108  bool bb_acc_avail() const { return bb_acc_avail_; }
109 
110  void set_natoms( Size setting ) { natoms_ = setting; }
111  Size natoms() const { return natoms_; }
112 
113  void set_nneighbors( Size setting ) { nneighbors_ = setting; }
114  Size nneighbors() const { return nneighbors_; }
115 
116 private:
119 
122 };
123 
124 class HBondResPairMinData : public basic::datacache::CacheableData
125 {
126 public:
128  virtual ~HBondResPairMinData() {}
129  virtual basic::datacache::CacheableDataOP clone() const
130  { return new HBondResPairMinData( *this ); }
131 
134 
135  HBondResidueMinData const & res1_data() const { return *res1_dat_; }
136  HBondResidueMinData const & res2_data() const { return *res2_dat_; }
137 
138  //void update_natoms();
139 
140  void clear_hbonds();
141  void add_hbond( HBond const & );
142 
143  /// @brief res should be 1 or 2
144  //utility::vector1< HBond > const &
145  //hbonds_for_atom( Size res, Size atom ) const {
146  // assert( res == 1 || res == 2 );
147  // return ( res == 1 ? res1_hbonds_[ atom ] : res2_hbonds_[ atom ] );
148  //}
149 private:
150  //void add_hbond_for_resatom( HBond const &, Size rsd, Size atno );
151 
152 private:
153 
156 
157  // The hydrogen bonds that atoms in residue 1 form with atoms in residue 2
158  // These must be updated during the setup_for_derivatives
159  //utility::vector1< utility::vector1< HBond > > res1_hbonds_;
160  //utility::vector1< utility::vector1< HBond > > res2_hbonds_;
161 
162 };
163 
167 
168 /// @details Don't resize to a smaller size for hbonds
169 //void HBondResPairMinData::update_natoms()
170 //{
171 // assert( res1_dat_ && res2_dat_ );
172 // //clear_hbonds();
173 // if ( res1_hbonds_.size() < res1_dat_->natoms() ) res1_hbonds_.resize( res1_dat_->natoms() );
174 // if ( res2_hbonds_.size() < res2_dat_->natoms() ) res2_hbonds_.resize( res2_dat_->natoms() );
175 //}
176 
177 /// @details Don't deallocate the vectors of hbonds; just resize those vectors to 0 length.
178 /// This saves new() and delete() expenses for future add_hbond() calls.
179 //void HBondResPairMinData::clear_hbonds() {
180 // for ( Size ii = 1, iiend = res1_dat_->natoms(); ii <= iiend; ++ii ) {
181 // res1_hbonds_[ ii ].clear();
182 // }
183 // for ( Size ii = 1, iiend = res2_dat_->natoms(); ii <= iiend; ++ii ) {
184 // res2_hbonds_[ ii ].clear();
185 // }
186 //
187 //}
188 
189 //void HBondResPairMinData::add_hbond( HBond const & hb )
190 //{
191 // /// find lower res and upper res
192 // Size don_id( hb.don_res() < hb.acc_res() ? 1 : 2 );
193 // add_hbond_for_resatom( hb, don_id, hb.don_hatm() );
194 // Size acc_id( hb.don_res() < hb.acc_res() ? 2 : 1 );
195 // add_hbond_for_resatom( hb, acc_id, hb.acc_atm() );
196 //}
197 
198 //void HBondResPairMinData::add_hbond_for_resatom( HBond const & hb, Size res, Size atno )
199 //{
200 // assert( res == 1 || res == 2 );
201 //
202 // if ( res == 1 ) {
203 // res1_hbonds_[ atno ].push_back( hb );
204 // } else {
205 // res2_hbonds_[ atno ].push_back( hb );
206 // }
207 //}
208 
209 static basic::Tracer tr("core.scoring.hbonds.HbondEnergy");
210 
211 /// @details This must return a fresh instance of the HBondEnergy class,
212 /// never an instance already in use
215  methods::EnergyMethodOptions const & options
216 ) const {
217  return new HBondEnergy( options.hbond_options() );
218 }
219 
222  ScoreTypes sts;
223  sts.push_back( hbond_lr_bb );
224  sts.push_back( hbond_sr_bb );
225  sts.push_back( hbond_bb_sc );
226  sts.push_back( hbond_sr_bb_sc );
227  sts.push_back( hbond_lr_bb_sc );
228  sts.push_back( hbond_sc );
229  sts.push_back( hbond_intra ); //Currently affects only RNA.
230  return sts;
231 }
232 
233 
234 /// ctor
236  parent( new HBondEnergyCreator ),
237  options_( new HBondOptions( opts )),
238  database_( HBondDatabase::get_database(opts.params_database_tag()) ),
239  memb_potential_( ScoringManager::get_instance()->get_Membrane_FAPotential() ) //pba
240 {}
241 
242 /// copy ctor
244  parent( src ),
245  options_( new HBondOptions( *src.options_)) ,
246  database_( src.database_),
247  memb_potential_( src.memb_potential_) //pba
248 {}
249 
251 
252 /// clone
255 {
256  return new HBondEnergy( *this );
257 }
258 
259 ///
260 void
262  pose::Pose & pose,
263  utility::vector1< bool > const &,
265 ) const
266 {
269 
271  hbonds::HBondSetOP hbond_set( new hbonds::HBondSet( options_ ) );
272 
273  //pba membrane object initialization
274  if (options_->Mbhbond()) {
280  }
281 
282  hbond_set->setup_for_residue_pair_energies( pose );
283  pose.energies().data().set( HBOND_SET, hbond_set );
284 
285  using namespace trie;
286  using namespace hbtrie;
287 
288  TrieCollectionOP tries = new TrieCollection;
289  tries->total_residue( pose.total_residue() );
290  for ( Size ii = 1; ii <= pose.total_residue(); ++ii ) {
291  // Do not compute energy for virtual residues.
292  if ( pose.residue(ii).aa() == core::chemical::aa_vrt) continue;
293 
294  HBondRotamerTrieOP one_rotamer_trie = create_rotamer_trie( pose.residue( ii ), pose );
295  tries->trie( ii, one_rotamer_trie );
296  }
297  pose.energies().data().set( HBOND_TRIE_COLLECTION, tries );
298 }
299 
300 void
302  pose::Pose const & pose,
304 ) const
305 {
306  using namespace hbtrie;
307 
308  HBondRotamerTrieOP rottrie = create_rotamer_trie( set, pose );
309  //std::cout << "--------------------------------------------------" << std::endl << " HBROTAMER TRIE: " << set.resid() << std::endl;
310  //rottrie->print();
311  set.store_trie( methods::hbond_method, rottrie );
312 }
313 
314 // Updates the cached rotamer trie for a residue if it has changed during the course of
315 // a repacking
316 void
318 {
319  using namespace trie;
320  using namespace hbtrie;
322 
323  HBondRotamerTrieOP one_rotamer_trie = create_rotamer_trie( pose.residue( resid ), pose );
324 
325  // grab non-const & of the cached tries and replace resid's trie with a new one.
326  TrieCollection & trie_collection( static_cast< TrieCollection & > (pose.energies().data().get( HBOND_TRIE_COLLECTION )));
327  trie_collection.trie( resid, one_rotamer_trie );
328 }
329 
330 
331 
332 ///
333 void
335 {
337 
339  HBondSetOP hbond_set( new hbonds::HBondSet( *options_, pose.total_residue() ) );
340 
341  //pba membrane object initialization
342  if (options_->Mbhbond()) {
348  }
349 
350  hbond_set->setup_for_residue_pair_energies( pose );
351 
352  /// During minimization, keep the set of bb/bb hbonds "fixed" by using the old boolean values.
353  if ( pose.energies().use_nblist() && pose.energies().data().has( HBOND_SET ) ) {
354  HBondSet const & existing_set = static_cast< HBondSet const & > (pose.energies().data().get( HBOND_SET ));
355  hbond_set->copy_bb_donor_acceptor_arrays( existing_set );
356  }
357  pose.energies().data().set( HBOND_SET, hbond_set );
358 }
359 
360 ///
361 /*void
362 HBondEnergy::setup_for_derivatives( pose::Pose & pose, ScoreFunction const & ) const
363 {
364  using EnergiesCacheableDataType::HBOND_SET;
365 
366  pose.update_residue_neighbors();
367  HBondSetOP hbond_set( new hbonds::HBondSet( options_, pose.total_residue() ) );
368  hbond_set->setup_for_residue_pair_energies( pose, true, false );
369  if ( pose.energies().use_nblist() && pose.energies().data().has( HBOND_SET ) ) {
370  HBondSet const & existing_set = static_cast< HBondSet const & > (pose.energies().data().get( HBOND_SET ));
371  hbond_set->copy_bb_donor_acceptor_arrays( existing_set );
372  }
373  pose.energies().data().set( HBOND_SET, hbond_set );
374 }*/
375 
376 
377 
378 /////////////////////////////////////////////////////////////////////////////
379 // scoring
380 /////////////////////////////////////////////////////////////////////////////
381 
382 /// @details Note that this only evaluates sc-sc and sc-bb energies unless options_->decompose_bb_hb_into_pair_energies
383 /// is set to true, in which case, this function also evaluates bb-bb energies.
384 /// Note also that this function enforces the bb/sc hbond exclusion rule.
385 void
387  conformation::Residue const & rsd1,
388  conformation::Residue const & rsd2,
389  pose::Pose const & pose,
390  ScoreFunction const &,
391  EnergyMap & emap
392 ) const
393 {
395 
396  if ( rsd1.seqpos() == rsd2.seqpos() ) return;
397  if ( options_->exclude_DNA_DNA() && rsd1.is_DNA() && rsd2.is_DNA() ) return;
398 
399  hbonds::HBondSet const & hbond_set
400  ( static_cast< hbonds::HBondSet const & >
401  ( pose.energies().data().get( HBOND_SET )));
402 
403  // this only works because we have already called
404  // hbond_set->setup_for_residue_pair_energies( pose )
405 
406  // Non-pairwise additive exclusion rules:
407  // exclude backbone-backbone hbond if set in options_ (if, say, they were pre-computed)
408  // exclude backbone-sidechain hbond if backbone-backbone hbond already in hbond_set*
409  // exclude sidechain-backbone hbond if backbone-backbone hbond already in hbond_set*
410  // * these two rules are only enforced as long as bb_donor_acceptor_check is "true"
411 
412  // mjo Historically, if this exclusion rule is not
413  // enforced--accoring to Brian Kuhlman--"Serines are put up and down
414  // helices". According to John Karanicolas, amide acceptors have a
415  // local energy minima where one lone pair moves in line with the
416  // base-acceptor, and the other lone pair is delocalized in between
417  // the base and acceptor atoms. In this configuration it is
418  // energetically disfavorable to make multiple hbonds with the
419  // acceptor.
420 
421  // NOTE: "bsc" -> acc=bb don=sc
422  // "scb" -> don=sc don=bb
423 
424  bool exclude_bsc = false, exclude_scb = false;
425  if (rsd1.is_protein()) exclude_scb = options_->bb_donor_acceptor_check() && hbond_set.don_bbg_in_bb_bb_hbond(rsd1.seqpos());
426  if (rsd2.is_protein()) exclude_bsc = options_->bb_donor_acceptor_check() && hbond_set.acc_bbg_in_bb_bb_hbond(rsd2.seqpos());
427 
428  //pba membrane dependent hbond potential hack
429  if (options_->Mbhbond()) {
430 
432  *database_,
433  rsd1, rsd2, hbond_set.nbrs(rsd1.seqpos()), hbond_set.nbrs(rsd2.seqpos()),
434  false /*calculate_derivative*/,
435  !options_->decompose_bb_hb_into_pair_energies(), exclude_bsc, exclude_scb, false,
436  *options_,
437  emap,
438  pose);
439 
440  exclude_bsc = exclude_scb = false;
441  if (rsd2.is_protein()) exclude_scb = options_->bb_donor_acceptor_check() && hbond_set.don_bbg_in_bb_bb_hbond(rsd2.seqpos());
442  if (rsd1.is_protein()) exclude_bsc = options_->bb_donor_acceptor_check() && hbond_set.acc_bbg_in_bb_bb_hbond(rsd1.seqpos());
443 
445  *database_,
446  rsd2, rsd1, hbond_set.nbrs(rsd2.seqpos()), hbond_set.nbrs(rsd1.seqpos()),
447  false /*calculate_derivative*/,
448  !options_->decompose_bb_hb_into_pair_energies(), exclude_bsc, exclude_scb, false,
449  *options_,
450  emap,
451  pose);
452 
453  } else {
454 
456  *database_,
457  rsd1, rsd2, hbond_set.nbrs(rsd1.seqpos()), hbond_set.nbrs(rsd2.seqpos()),
458  false /*calculate_derivative*/,
459  !options_->decompose_bb_hb_into_pair_energies(), exclude_bsc, exclude_scb, false,
460  *options_,
461  emap);
462 
463  exclude_bsc = exclude_scb = false;
464  if (rsd2.is_protein()) exclude_scb = options_->bb_donor_acceptor_check() && hbond_set.don_bbg_in_bb_bb_hbond(rsd2.seqpos());
465  if (rsd1.is_protein()) exclude_bsc = options_->bb_donor_acceptor_check() && hbond_set.acc_bbg_in_bb_bb_hbond(rsd1.seqpos());
466 
468  *database_,
469  rsd2, rsd1, hbond_set.nbrs(rsd2.seqpos()), hbond_set.nbrs(rsd1.seqpos()),
470  false /*calculate_derivative*/,
471  !options_->decompose_bb_hb_into_pair_energies(), exclude_bsc, exclude_scb, false,
472  *options_,
473  emap);
474  }
475 }
476 
477 bool
479  conformation::Residue const &,
480  conformation::Residue const &,
481  bool res_moving_wrt_eachother
482 ) const
483 {
484  return res_moving_wrt_eachother;
485 }
486 
487 bool
489 
490 bool
492 {
493  return true;
494 }
495 
496 /// @details computes the residue pair energy during minimization; this includes bb/bb energies
497 /// as opposed to the standard residue_pair_energy interface, which does not include bb/bb energies.
498 /// On the other hand, this interface presumes that no new bb/bb hydrogen bonds are formed during
499 /// the course of minimization, and no existing bb/bb hydrogen bonds are lost.
500 /// Note: this function does not directly enforce the bb/sc exclusion rule logic, but rather,
501 /// takes the boolean "bb_don_avail" and "bb_acc_avail" data stored in the pairdata object
502 void
504  conformation::Residue const & rsd1,
505  conformation::Residue const & rsd2,
506  ResPairMinimizationData const & pairdata,
507  pose::Pose const & pose, //pba
508  ScoreFunction const &,
509  EnergyMap & emap
510 ) const
511 {
512  if ( rsd1.xyz( rsd1.nbr_atom() ).distance_squared( rsd2.xyz( rsd2.nbr_atom() ) )
513  > std::pow( rsd1.nbr_radius() + rsd2.nbr_radius() + atomic_interaction_cutoff(), 2 ) ) return;
514 
515  assert( dynamic_cast< HBondResPairMinData const * > ( pairdata.get_data( hbond_respair_data )() ));
516  HBondResPairMinData const & hb_pair_dat( static_cast< HBondResPairMinData const & > ( pairdata.get_data_ref( hbond_respair_data ) ));
517 
518  //pba membrane dependent hbond potential hack
519  if (options_->Mbhbond()) {
520 
521  { // scope /// 1st == evaluate hbonds with donor atoms on rsd1
522  /// case A: sc is acceptor, bb is donor && res2 is the acceptor residue -> look at the donor availability of residue 1
523  bool exclude_scb( ! hb_pair_dat.res1_data().bb_don_avail() );
524  /// case B: bb is acceptor, sc is donor && res2 is the acceptor residue -> look at the acceptor availability of residue 2
525  bool exclude_bsc( ! hb_pair_dat.res2_data().bb_acc_avail() );
526 
528  *database_,
529  rsd1, rsd2,
530  hb_pair_dat.res1_data().nneighbors(), hb_pair_dat.res2_data().nneighbors(),
531  false /*calculate_derivative*/,
532  false, exclude_bsc, exclude_scb, false,
533  *options_,
534  emap, pose);
535  }
536 
537  { // scope
538  /// 2nd == evaluate hbonds with donor atoms on rsd2
539  /// case A: sc is acceptor, bb is donor && res1 is the acceptor residue -> look at the donor availability of residue 2
540  bool exclude_scb( ! hb_pair_dat.res2_data().bb_don_avail() );
541  /// case B: bb is acceptor, sc is donor && res1 is the acceptor residue -> look at the acceptor availability of residue 1
542  bool exclude_bsc( ! hb_pair_dat.res1_data().bb_acc_avail() );
543 
545  *database_,
546  rsd2, rsd1,
547  hb_pair_dat.res2_data().nneighbors(), hb_pair_dat.res1_data().nneighbors(),
548  false /*calculate_derivative*/,
549  false, exclude_bsc, exclude_scb, false,
550  *options_,
551  emap, pose);
552  }
553 
554  } else {
555 
556  { // scope
557  /// 1st == evaluate hbonds with donor atoms on rsd1
558  /// case A: sc is acceptor, bb is donor && res2 is the acceptor residue -> look at the donor availability of residue 1
559  bool exclude_scb( ! hb_pair_dat.res1_data().bb_don_avail() );
560  /// case B: bb is acceptor, sc is donor && res2 is the acceptor residue -> look at the acceptor availability of residue 2
561  bool exclude_bsc( ! hb_pair_dat.res2_data().bb_acc_avail() );
562 
564  *database_,
565  rsd1, rsd2,
566  hb_pair_dat.res1_data().nneighbors(), hb_pair_dat.res2_data().nneighbors(),
567  false /*calculate_derivative*/,
568  false, exclude_bsc, exclude_scb, false,
569  *options_,
570  emap);
571  }
572 
573  { // scope
574  /// 2nd == evaluate hbonds with donor atoms on rsd2
575  /// case A: sc is acceptor, bb is donor && res1 is the acceptor residue -> look at the donor availability of residue 2
576  bool exclude_scb( ! hb_pair_dat.res2_data().bb_don_avail() );
577  /// case B: bb is acceptor, sc is donor && res1 is the acceptor residue -> look at the acceptor availability of residue 1
578  bool exclude_bsc( ! hb_pair_dat.res1_data().bb_acc_avail() );
579 
581  *database_,
582  rsd2, rsd1,
583  hb_pair_dat.res2_data().nneighbors(), hb_pair_dat.res1_data().nneighbors(),
584  false /*calculate_derivative*/,
585  false, exclude_bsc, exclude_scb, false,
586  *options_,
587  emap);
588  }
589 
590  }
591 
592 }
593 
594 /// @details Note that this function helps enforce the bb/sc exclusion rule by setting the donor and acceptor availability
595 /// for backbone donors and acceptors. If the backbone-sidechain-exclusion rule is not being enforced, then this function
596 /// marks all donors and acceptors as being available. If it is being enforced, then is uses the hbondset functions
597 /// don_bbg_in_bb_bb_hbond and acc_bbg_in_bb_bb_hbond. The decisions made in this function impact the evaluation
598 /// of energies in the above residue_pair_energy_ext method.
599 void
601  conformation::Residue const & rsd,
602  pose::Pose const & pose,
603  ScoreFunction const &,
605  ResSingleMinimizationData & res_data_cache
606 ) const
607 {
609 
610  HBondSet const & hbondset = static_cast< HBondSet const & > (pose.energies().data().get( HBOND_SET ));
611  HBondResidueMinDataOP hbresdata( 0 );
612  if ( res_data_cache.get_data( hbond_res_data ) ) {
613  hbresdata = static_cast< HBondResidueMinData * > ( res_data_cache.get_data( hbond_res_data )() );
614  // assume that bb-don-avail and bb-acc-avail are already initialized
615  } else {
616  hbresdata = new HBondResidueMinData;
617  hbresdata->set_nneighbors( hbondset.nbrs( rsd.seqpos() ) );
618  if ( rsd.is_protein() ) {
619  hbresdata->set_bb_don_avail( options_->bb_donor_acceptor_check() ? ! hbondset.don_bbg_in_bb_bb_hbond( rsd.seqpos() ) : true );
620  hbresdata->set_bb_acc_avail( options_->bb_donor_acceptor_check() ? ! hbondset.acc_bbg_in_bb_bb_hbond( rsd.seqpos() ) : true );
621  }
622  res_data_cache.set_data( hbond_res_data, hbresdata );
623  }
624  hbresdata->set_natoms( rsd.natoms() );
625 }
626 
627 
628 void
630  conformation::Residue const &,
631  conformation::Residue const &,
632  pose::Pose const &,
633  ScoreFunction const &,
635  ResSingleMinimizationData const & res1_data_cache,
636  ResSingleMinimizationData const & res2_data_cache,
637  ResPairMinimizationData & data_cache
638 ) const
639 {
640  HBondResPairMinDataOP hbpairdat;
641  if ( data_cache.get_data( hbond_respair_data ) ) {
642  // assume that hbpairdat has already been pointed at its two residues, and that it may need to update
643  // its size based on a change to the number of atoms from a previous initialization.
644  assert( dynamic_cast< HBondResPairMinData * > ( data_cache.get_data( hbond_respair_data )() ));
645  hbpairdat = static_cast< HBondResPairMinData * > ( data_cache.get_data( hbond_respair_data )() );
646  } else {
647  assert( dynamic_cast< HBondResidueMinData const * > ( res1_data_cache.get_data( hbond_res_data )() ));
648  assert( dynamic_cast< HBondResidueMinData const * > ( res2_data_cache.get_data( hbond_res_data )() ));
649 
650  hbpairdat = new HBondResPairMinData;
651  hbpairdat->set_res1_data( static_cast< HBondResidueMinData const * > ( res1_data_cache.get_data( hbond_res_data )() ));
652  hbpairdat->set_res2_data( static_cast< HBondResidueMinData const * > ( res2_data_cache.get_data( hbond_res_data )() ));
653  data_cache.set_data( hbond_respair_data, hbpairdat );
654  }
655  //hbpairdat->update_natoms();
656 
657 }
658 
659 bool
661 {
662  return false;
663 }
664 
665 
666 /// @details Triplication of the loops that iterate across hbond donors and acceptors
667 /// Find all hbonds for a pair of residues and add those found hbonds to the
668 /// hb_pair_dat object; these hbonds will be used for derivative evaluation, so evaluate
669 /// the F1/F2 derivative vectors now. This function respects the exclude bsc and scb variables
670 /// to avoid hbonds. Called by setup_for_derivatives_for_residue_pair
671 /// pba modified
672 void
674  EnergyMap const & weights,
675  HBondSet const & hbond_set,
676  HBondDatabaseCOP database,
677  conformation::Residue const & don_rsd,
678  conformation::Residue const & acc_rsd,
679  Size const don_nb,
680  Size const acc_nb,
681  bool const exclude_bsc, /* exclude if acc=bb and don=sc */
682  bool const exclude_scb, /* exclude if acc=sc and don=bb */
683  // output
684  utility::vector1< DerivVectorPair > & don_atom_derivs,
685  utility::vector1< DerivVectorPair > & acc_atom_derivs
686 ) const
687 {
688  EnergyMap emap;
689 
690  //assert( don_rsd.seqpos() != acc_rsd.seqpos() ); Commented out by Parin Sripakdeevong (sripakpa@stanford.edu) on 12/26/2011
691 
692  bool is_intra_res=(don_rsd.seqpos()==acc_rsd.seqpos());
693 
694  if(is_intra_res){
695  if(don_rsd.is_RNA()==false) return;
696  if(don_rsd.is_RNA()!=acc_rsd.is_RNA()) utility_exit_with_message("don_rsd.is_RNA()!=acc_rsd.is_RNA()");
697  if(hbond_set.hbond_options().include_intra_res_RNA()==false) return;
698  }
699 
700  // <f1,f2> -- derivative vectors
701  HBondDerivs deriv;
702 
703  for ( chemical::AtomIndices::const_iterator
704  hnum = don_rsd.Hpos_polar().begin(), hnume = don_rsd.Hpos_polar().end();
705  hnum != hnume; ++hnum ) {
706  Size const hatm( *hnum );
707  Size const datm(don_rsd.atom_base(hatm));
708  bool datm_is_bb = don_rsd.atom_is_backbone(datm);
709 
710  Vector const & hatm_xyz( don_rsd.atom(hatm).xyz() );
711  Vector const & datm_xyz( don_rsd.atom(datm).xyz() );
712 
713  if(is_intra_res){ //Must be RNA (see above early return condition)
714  if( don_rsd.RNA_type().is_RNA_base_atom( datm )==false ) continue;
715  if( don_rsd.is_virtual(hatm) ) continue; //Is this necessary?
716  if( don_rsd.is_virtual(datm) ) continue; //Is this necessary?
717  }
718 
719  for ( chemical::AtomIndices::const_iterator
720  anum = acc_rsd.accpt_pos().begin(), anume = acc_rsd.accpt_pos().end();
721  anum != anume; ++anum ) {
722 
723  Size const aatm( *anum );
724 
725  if(is_intra_res){ //Must be RNA (see above early return condition)
726  if( acc_rsd.RNA_type().atom_is_phosphate(aatm)==false) continue;
727  if( acc_rsd.path_distance( aatm, datm ) < 4) utility_exit_with_message("rsd.path_distance(aatm, datm) < 4"); //consistency check
728  if( acc_rsd.is_virtual(aatm) ) continue; //Is this necessary?
729  }
730 
731  if ( acc_rsd.atom_is_backbone(aatm)){
732  if ( ! datm_is_bb && exclude_bsc ) continue; // if the donor is sc, the acceptor bb, and exclude_b(a)sc(d)
733  } else {
734  if (datm_is_bb && exclude_scb) continue; // if the donor is bb, the acceptor sc, and exclude_sc(a)b(d)
735  }
736 
737  // rough filter for existance of hydrogen bond
738  if ( hatm_xyz.distance_squared( acc_rsd.xyz( aatm ) ) > MAX_R2 ) continue;
739 
740  Real unweighted_energy( 0.0 );
741 
742  HBEvalTuple hbe_type( datm, don_rsd, aatm, acc_rsd);
743 
744  int const base ( acc_rsd.atom_base( aatm ) );
745  int const base2( acc_rsd.abase2( aatm ) );
746  assert( base2 > 0 && base != base2 );
747 
748  hb_energy_deriv( *database, *options_, hbe_type, datm_xyz, hatm_xyz,
749  acc_rsd.atom(aatm ).xyz(),
750  acc_rsd.atom(base ).xyz(),
751  acc_rsd.atom(base2).xyz(),
752  unweighted_energy, true /*eval deriv*/, deriv);
753 
754  if (unweighted_energy >= MAX_HB_ENERGY) continue;
755 
756  //pba buggy?
757  Real weighted_energy = // evn weight * weight-set[ hbtype ] weight
758  (! hbond_set.hbond_options().use_hb_env_dep() ? 1 :
759  get_environment_dependent_weight(hbe_type, don_nb, acc_nb, hbond_set.hbond_options() )) *
760  hb_eval_type_weight( hbe_type.eval_type(), weights, is_intra_res);
761 
762  //pba membrane specific correction
763  if ( options_->Mbhbond()) {
765  steepness_, don_nb, acc_nb, hatm_xyz, acc_rsd.atom(aatm ).xyz()) *
766  hb_eval_type_weight( hbe_type.eval_type(), weights, is_intra_res);
767  }
768 
769  /// Only accumulate h and acc derivs for now; soon, don, h, acc, a-base and abase2 derivs
770  don_atom_derivs[ datm ].f1() += weighted_energy * deriv.don_deriv.f1();
771  don_atom_derivs[ datm ].f2() += weighted_energy * deriv.don_deriv.f2();
772  don_atom_derivs[ hatm ].f1() += weighted_energy * deriv.h_deriv.f1();
773  don_atom_derivs[ hatm ].f2() += weighted_energy * deriv.h_deriv.f2();
774  acc_atom_derivs[ aatm ].f1() += weighted_energy * deriv.acc_deriv.f1();
775  acc_atom_derivs[ aatm ].f2() += weighted_energy * deriv.acc_deriv.f2();
776 
777  // ring-acceptor derivative assignment logic is tricky
778  assign_abase_derivs( *options_, acc_rsd, aatm, hbe_type, deriv.abase_deriv, weighted_energy, acc_atom_derivs );
779 
780 
781  acc_atom_derivs[ base2 ].f1() += weighted_energy * deriv.abase2_deriv.f1();
782  acc_atom_derivs[ base2 ].f2() += weighted_energy * deriv.abase2_deriv.f2();
783 
784  /*
785  // now we have identified a hbond -> append it into the hbond_set
786  //hbond_set.append_hbond( hatm, don_rsd, aatm, acc_rsd,
787  // hbe_type, unweighted_energy, environmental_weight, deriv );
788 
789  bool const dhatm_is_protein_backbone
790  ( don_rsd.is_protein() && don_rsd.atom_is_backbone( hatm ) );
791  bool const aatm_is_protein_backbone
792  ( acc_rsd.is_protein() && acc_rsd.atom_is_backbone( aatm ) );
793 
794  bool const dhatm_is_backbone( don_rsd.atom_is_backbone( hatm ) );
795  bool const aatm_is_backbone( acc_rsd.atom_is_backbone( aatm ) );
796 
797  Size const don_pos( don_rsd.seqpos() );
798  Size const acc_pos( acc_rsd.seqpos() );
799 
800  HBond hbond( hatm, dhatm_is_protein_backbone, don_rsd.is_protein(), don_rsd.is_DNA(),
801  dhatm_is_backbone, don_pos,
802  aatm, aatm_is_protein_backbone, acc_rsd.is_protein(), acc_rsd.is_DNA(),
803  aatm_is_backbone, acc_pos,
804  hbe_type, unweighted_energy, environmental_weight, deriv );
805 
806  hb_pair_data.add_hbond( hbond );
807  //////
808  */
809 
810  } // loop over acceptors
811  } // loop over donors
812 
813 }
814 
815 
816 /// @details Store all the hbonds formed between these two residues in the data_cache object
817 /// so that they are available for derivative evaluation.
818 /*void
819 HBondEnergy::setup_for_derivatives_for_residue_pair(
820  conformation::Residue const & rsd1,
821  conformation::Residue const & rsd2,
822  ResSingleMinimizationData const &,
823  ResSingleMinimizationData const &,
824  pose::Pose const & pose,
825  ResPairMinimizationData & data_cache
826 ) const
827 {
828  /// Iterate across all acceptor and donor atom pairs for these two residues, and write down the hydrogen bonds
829  /// that are formed.
830 
831  using EnergiesCacheableDataType::HBOND_SET;
832 
833  HBondSet const & hbondset = static_cast< HBondSet const & > (pose.energies().data().get( HBOND_SET ));
834 
835  assert( dynamic_cast< HBondResPairMinData * > ( data_cache.get_data( hbond_respair_data )() ));
836  HBondResPairMinData & hb_pair_dat = static_cast< HBondResPairMinData & > ( data_cache.get_data_ref( hbond_respair_data ) );
837  hb_pair_dat.clear_hbonds();
838 
839  Size const rsd1nneighbs( hb_pair_dat.res1_data().nneighbors() );
840  Size const rsd2nneighbs( hb_pair_dat.res2_data().nneighbors() );
841 
842  { // scope
843  /// 1st == find hbonds with donor atoms on rsd1
844  /// case A: sc is acceptor, bb is donor && res2 is the acceptor residue -> look at the donor availability of residue 1
845  bool exclude_scb( ! hb_pair_dat.res1_data().bb_don_avail() );
846  /// case B: bb is acceptor, sc is donor && res2 is the acceptor residue -> look at the acceptor availability of residue 2
847  bool exclude_bsc( ! hb_pair_dat.res2_data().bb_acc_avail() );
848 
849  identify_hbonds_1way( hbondset, database_, rsd1, rsd2, rsd1nneighbs, rsd2nneighbs, exclude_bsc, exclude_scb, hb_pair_dat );
850  }
851 
852  { // scope
853  /// 2nd == evaluate hbonds with donor atoms on rsd2
854  /// case A: sc is acceptor, bb is donor && res1 is the acceptor residue -> look at the donor availability of residue 2
855  bool exclude_scb( ! hb_pair_dat.res2_data().bb_don_avail() );
856  /// case B: bb is acceptor, sc is donor && res1 is the acceptor residue -> look at the acceptor availability of residue 1
857  bool exclude_bsc( ! hb_pair_dat.res1_data().bb_acc_avail() );
858 
859 
860  identify_hbonds_1way( hbondset, database_, rsd2, rsd1, rsd2nneighbs, rsd1nneighbs, exclude_bsc, exclude_scb, hb_pair_dat );
861  }
862 
863 }*/
864 
865 ///WORKING| MODELED AFTER THE VERSION IN OccludedHbondSolEnergy...Need to make sure that this is correct!: Parin Sripakdeevong/////
866 void
868  conformation::Residue const & rsd,
870  pose::Pose const & pose,
871  EnergyMap const & weights,
873 ) const
874 {
875 
876  if(options_->include_intra_res_RNA() && rsd.is_RNA()){
877 
879 
880  HBondSet const & hbondset = static_cast< HBondSet const & > (pose.energies().data().get( HBOND_SET ));
881 
882  bool exclude_scb=false;
883 
884  hbond_derivs_1way( weights, hbondset, database_, rsd, rsd, 1, 1, exclude_scb, exclude_scb, atom_derivs, atom_derivs );
885 
886  }
887 }
888 ///WORKING| MODELED AFTER THE VERSION IN OccludedHbondSolEnergy...Need to make sure that this is correct!: Parin Sripakdeevong/////
889 
890 
891 void
893  conformation::Residue const & rsd1,
894  conformation::Residue const & rsd2,
897  ResPairMinimizationData const & min_data,
898  pose::Pose const & pose, // stores the hbond database in the cached hbond set
899  EnergyMap const & weights,
900  utility::vector1< DerivVectorPair > & r1_atom_derivs,
901  utility::vector1< DerivVectorPair > & r2_atom_derivs
902 ) const
903 {
904  if ( rsd1.xyz( rsd1.nbr_atom() ).distance_squared( rsd2.xyz( rsd2.nbr_atom() ) )
905  > std::pow( rsd1.nbr_radius() + rsd2.nbr_radius() + atomic_interaction_cutoff(), 2 ) ) return;
906 
907  /// Iterate across all acceptor and donor atom pairs for these two residues, and write down the hydrogen bonds
908  /// that are formed.
909 
911 
912  HBondSet const & hbondset = static_cast< HBondSet const & > (pose.energies().data().get( HBOND_SET ));
913 
914  assert( dynamic_cast< HBondResPairMinData const * > ( min_data.get_data( hbond_respair_data )() ));
915  HBondResPairMinData const & hb_pair_dat = static_cast< HBondResPairMinData const & > ( min_data.get_data_ref( hbond_respair_data ) );
916 
917  Size const rsd1nneighbs( hb_pair_dat.res1_data().nneighbors() );
918  Size const rsd2nneighbs( hb_pair_dat.res2_data().nneighbors() );
919 
920  { // scope
921  /// 1st == find hbonds with donor atoms on rsd1
922  /// case A: sc is acceptor, bb is donor && res2 is the acceptor residue -> look at the donor availability of residue 1
923  bool exclude_scb( ! hb_pair_dat.res1_data().bb_don_avail() );
924  /// case B: bb is acceptor, sc is donor && res2 is the acceptor residue -> look at the acceptor availability of residue 2
925  bool exclude_bsc( ! hb_pair_dat.res2_data().bb_acc_avail() );
926 
927  hbond_derivs_1way( weights, hbondset, database_, rsd1, rsd2, rsd1nneighbs, rsd2nneighbs, exclude_bsc, exclude_scb, r1_atom_derivs, r2_atom_derivs );
928  }
929 
930  { // scope
931  /// 2nd == evaluate hbonds with donor atoms on rsd2
932  /// case A: sc is acceptor, bb is donor && res1 is the acceptor residue -> look at the donor availability of residue 2
933  bool exclude_scb( ! hb_pair_dat.res2_data().bb_don_avail() );
934  /// case B: bb is acceptor, sc is donor && res1 is the acceptor residue -> look at the acceptor availability of residue 1
935  bool exclude_bsc( ! hb_pair_dat.res1_data().bb_acc_avail() );
936 
937 
938  hbond_derivs_1way( weights, hbondset, database_, rsd2, rsd1, rsd2nneighbs, rsd1nneighbs, exclude_bsc, exclude_scb, r2_atom_derivs, r1_atom_derivs );
939  }
940 
941 }
942 
943 /// @details The hydrogen bonds must have already been found and added to the minpair_data
944 /// container in a call to setup_for_derivatives_for_residue_pair() where the input
945 /// residues are guaranteed to not have changed since that call.
946 /*void
947 HBondEnergy::eval_atom_derivative_for_residue_pair(
948  Size const atom_index,
949  conformation::Residue const & rsd1,
950  conformation::Residue const & rsd2,
951  ResSingleMinimizationData const & ,
952  ResSingleMinimizationData const & ,
953  ResPairMinimizationData const & minpair_data,
954  pose::Pose const &, // provides context
955  kinematics::DomainMap const &,
956  ScoreFunction const &,
957  EnergyMap const & weights,
958  Vector & F1,
959  Vector & F2
960 ) const
961 {
962 
963  assert( dynamic_cast< HBondResPairMinData const * > ( minpair_data.get_data( hbond_respair_data )() ));
964  HBondResPairMinData const & hb_pair_dat = static_cast< HBondResPairMinData const & > ( minpair_data.get_data_ref( hbond_respair_data ) );
965 
966  utility::vector1< HBond > const & hbonds( hb_pair_dat.hbonds_for_atom( rsd1.seqpos() < rsd2.seqpos() ? 1 : 2, atom_index ));
967 
968  /// This loop extracted from the old hbonds.cc::get_atom_hbond_derivative() method
969  id::AtomID atom( atom_index, rsd1.seqpos() );
970 
971  for ( Size ii = 1; ii <= hbonds.size(); ++ii ) {
972  HBond const & hbond( hbonds[ ii ] );
973  Real sign_factor( 0.0 );
974  if ( hbond.atom_is_donorH( atom ) ) sign_factor = 1.0;
975  else {
976  assert( hbond.atom_is_acceptor( atom ) );
977  sign_factor = -1;
978  }
979  // get the appropriate type of hbond weight
980  Real const weight(sign_factor * hbond.weight() * hb_eval_type_weight(hbond.eval_type(), weights));
981  F1 += weight * hbond.deriv().first;
982  F2 += weight * hbond.deriv().second;
983 
984  }
985 }*/
986 
987 void
989  conformation::Residue const & rsd1,
990  conformation::Residue const & rsd2,
991  pose::Pose const & pose,
992  ScoreFunction const &,// sfxn,
993  EnergyMap & emap
994 ) const
995 {
996  /// if we're including bb/bb energies in the energy maps, then they need to be calculated
997  /// in the backbone_backbone_energy so that:
998  /// residue_pair_energy = backbone_backbone_energy(r1,r2) + backbone_sidechain_energy(r1,r2) +
999  /// backbone_sidechain_energy(r2,r1) + sidechain_sidechain_energy(r1,r2)
1000 
1001  if ( ! options_->decompose_bb_hb_into_pair_energies() ) return;
1002 
1004 
1005  if ( rsd1.seqpos() == rsd2.seqpos() ) return;
1006  if ( options_->exclude_DNA_DNA() && rsd1.is_DNA() && rsd2.is_DNA() ) return;
1007 
1008  hbonds::HBondSet const & hbond_set
1009  ( static_cast< hbonds::HBondSet const & >( pose.energies().data().get( HBOND_SET )));
1010 
1011  //pba membrane dependent hbond potential hack
1012  if (options_->Mbhbond()) {
1013 
1015  *database_,
1016  rsd1, rsd2, hbond_set.nbrs(rsd1.seqpos()), hbond_set.nbrs(rsd1.seqpos()),
1017  false /*calculate_derivative*/,
1018  false, true, true, true, /* calc bb_bb, don't calc bb_sc, sc_bb, or sc_sc */
1019  *options_,
1020  emap, pose);
1021 
1023  *database_,
1024  rsd2, rsd1, hbond_set.nbrs(rsd2.seqpos()), hbond_set.nbrs(rsd1.seqpos()),
1025  false /*calculate_derivative*/,
1026  false, true, true, true, /* calc bb_bb, don't calc bb_sc, sc_bb, or sc_sc */
1027  *options_,
1028  emap, pose);
1029 
1030  } else {
1031 
1033  *database_,
1034  rsd1, rsd2, hbond_set.nbrs(rsd1.seqpos()), hbond_set.nbrs(rsd1.seqpos()),
1035  false /*calculate_derivative*/,
1036  false, true, true, true, /* calc bb_bb, don't calc bb_sc, sc_bb, or sc_sc */
1037  *options_,
1038  emap);
1039 
1041  *database_,
1042  rsd2, rsd1, hbond_set.nbrs(rsd2.seqpos()), hbond_set.nbrs(rsd1.seqpos()),
1043  false /*calculate_derivative*/,
1044  false, true, true, true, /* calc bb_bb, don't calc bb_sc, sc_bb, or sc_sc */
1045  *options_,
1046  emap);
1047 
1048  }
1049 }
1050 
1051 /// @details Note: this function enforces the bb/sc hbond exclusion rule
1052 void
1054  conformation::Residue const & rsd1,
1055  conformation::Residue const & rsd2,
1056  pose::Pose const & pose,
1057  ScoreFunction const &,// sfxn,
1058  EnergyMap & emap
1059 ) const
1060 {
1062 
1063  if ( rsd1.seqpos() == rsd2.seqpos() ) return;
1064  if ( options_->exclude_DNA_DNA() && rsd1.is_DNA() && rsd2.is_DNA() ) return;
1065 
1066  hbonds::HBondSet const & hbond_set
1067  ( static_cast< hbonds::HBondSet const & > ( pose.energies().data().get( HBOND_SET )));
1068 
1069  // this only works because we have already called
1070  // hbond_set->setup_for_residue_pair_energies( pose )
1071 
1072  //pba membrane dependent hbond potential hack
1073  if (options_->Mbhbond()) {
1074 
1075  /// If we're enforcing the bb/sc exclusion rule, and residue1 is a protein residue, and if residue 1's backbone-donor group
1076  /// is already participating in a bb/bb hbond, then do not evaluate the identify_hbonds_1way_membrane function
1077  if ( !options_->bb_donor_acceptor_check() || ! rsd1.is_protein() || ! hbond_set.don_bbg_in_bb_bb_hbond(rsd1.seqpos())) {
1079  *database_,
1080  rsd1, rsd2, hbond_set.nbrs(rsd1.seqpos()), hbond_set.nbrs(rsd2.seqpos()),
1081  false /*calculate_derivative*/,
1082  true, true, false, true,
1083  *options_,
1084  emap, pose);
1085  }
1086 
1087  /// If we're enforcing the bb/sc exclusion rule, and residue1 is a protein residue, and if residue 1's backbone-acceptor group
1088  /// is already participating in a bb/bb hbond, then do not evaluate the identify_hbonds_1way_membrane function
1089  if ( !options_->bb_donor_acceptor_check() || ! rsd1.is_protein() || ! hbond_set.acc_bbg_in_bb_bb_hbond(rsd1.seqpos())) {
1091  *database_,
1092  rsd2, rsd1, hbond_set.nbrs(rsd2.seqpos()), hbond_set.nbrs(rsd1.seqpos()),
1093  false /*calculate_derivative*/,
1094  true, false, true, true,
1095  *options_,
1096  emap, pose);
1097  }
1098 
1099  } else {
1100  /// If we're enforcing the bb/sc exclusion rule, and residue1 is a protein residue, and if residue 1's backbone-donor group
1101  /// is already participating in a bb/bb hbond, then do not evaluate the identify_hbonds_1way function
1102  if ( !options_->bb_donor_acceptor_check() || !rsd1.is_protein() || !hbond_set.don_bbg_in_bb_bb_hbond(rsd1.seqpos())) {
1104  *database_,
1105  rsd1, rsd2, hbond_set.nbrs(rsd1.seqpos()), hbond_set.nbrs(rsd2.seqpos()),
1106  false /*calculate_derivative*/,
1107  true, true, false, true,
1108  *options_,
1109  emap);
1110  }
1111 
1112  /// If we're enforcing the bb/sc exclusion rule, and residue1 is a protein residue, and if residue 1's backbone-acceptor group
1113  /// is already participating in a bb/bb hbond, then do not evaluate the identify_hbonds_1way function
1114  if ( !options_->bb_donor_acceptor_check() || !rsd1.is_protein() || !hbond_set.acc_bbg_in_bb_bb_hbond(rsd1.seqpos())) {
1116  *database_,
1117  rsd2, rsd1, hbond_set.nbrs(rsd2.seqpos()), hbond_set.nbrs(rsd1.seqpos()),
1118  false /*calculate_derivative*/,
1119  true, false, true, true,
1120  *options_,
1121  emap);
1122  }
1123  }
1124 }
1125 
1126 void
1128  conformation::Residue const & rsd1,
1129  conformation::Residue const & rsd2,
1130  pose::Pose const & pose,
1131  ScoreFunction const &,// sfxn,
1132  EnergyMap & emap
1133 ) const
1134 {
1135  Size nbrs1 = pose.energies().tenA_neighbor_graph().get_node( rsd1.seqpos() )->num_neighbors_counting_self_static();
1136  Size nbrs2 = pose.energies().tenA_neighbor_graph().get_node( rsd2.seqpos() )->num_neighbors_counting_self_static();
1137 
1138  //pba membrane dependent hbond potential hack
1139  if (options_->Mbhbond()) {
1140 
1142  *database_,
1143  rsd1, rsd2, nbrs1, nbrs2,
1144  false /*calculate_derivative*/,
1145  true, true, true, false, *options_, emap,
1146  pose);
1148  *database_,
1149  rsd2, rsd1, nbrs2, nbrs1,
1150  false /*calculate_derivative*/,
1151  true, true, true, false, *options_, emap,
1152  pose);
1153 
1154  } else {
1155 
1157  *database_,
1158  rsd1, rsd2, nbrs1, nbrs2,
1159  false /*calculate_derivative*/,
1160  true, true, true, false, *options_, emap);
1162  *database_,
1163  rsd2, rsd1, nbrs2, nbrs1,
1164  false /*calculate_derivative*/,
1165  true, true, true, false, *options_, emap);
1166  }
1167 
1168 }
1169 
1170 
1171 void
1173  conformation::RotamerSetBase const & set1,
1174  conformation::RotamerSetBase const & set2,
1175  pose::Pose const & pose,
1176  ScoreFunction const &,
1177  EnergyMap const & weights,
1178  ObjexxFCL::FArray2D< core::PackerEnergy > & energy_table
1179 ) const
1180 {
1181  assert( set1.resid() != set2.resid() );
1182 
1183  if ( options_->exclude_DNA_DNA() && pose.residue( set1.resid() ).is_DNA() && pose.residue( set2.resid() ).is_DNA() ) return;
1184 
1185  using namespace methods;
1186  using namespace hbtrie;
1187  using namespace trie;
1189 
1190  ObjexxFCL::FArray2D< core::PackerEnergy > temp_table1( energy_table );
1191  ObjexxFCL::FArray2D< core::PackerEnergy > temp_table2( energy_table );
1192 
1193  temp_table1 = 0; temp_table2 = 0;
1194 
1195  // save weight information so that its available during tvt execution
1196  // and also the neighbor counts for the two residues.
1197  weights_ = weights;
1198  res1_ = set1.resid();
1199  res2_ = set2.resid();
1200 
1201  rotamer_seq_sep_ = pose.residue( set2.resid() ).polymeric_oriented_sequence_distance( pose.residue( set1.resid() ) );
1202 
1203  if ( true ) { // super_hacky
1204  hbonds::HBondSet const & hbond_set
1205  ( static_cast< hbonds::HBondSet const & >
1206  ( pose.energies().data().get( HBOND_SET )));
1207  res1_nb_ = hbond_set.nbrs( set1.resid() );
1208  res2_nb_ = hbond_set.nbrs( set2.resid() );
1209  } else {
1210  res1_nb_ = pose.energies().tenA_neighbor_graph().get_node( set1.resid() )->num_neighbors_counting_self();
1211  res2_nb_ = pose.energies().tenA_neighbor_graph().get_node( set2.resid() )->num_neighbors_counting_self();
1212  }
1213  HBondRotamerTrieCOP trie1( static_cast< trie::RotamerTrieBase const * > ( set1.get_trie( hbond_method )() ));
1214  HBondRotamerTrieCOP trie2( static_cast< trie::RotamerTrieBase const * > ( set2.get_trie( hbond_method )() ));
1215 
1216  //prepare_for_residue_pair( set1.resid(), set2.resid(), pose );
1217  //assert( rep_scoretype() == fa_rep || rep_scoretype() == coarse_fa_rep );
1218 
1219  // figure out which trie countPairFunction needs to be used for this set
1220  TrieCountPairBaseOP cp = new HBCountPairFunction;
1221 
1222  /// now execute the trie vs trie algorithm.
1223  /// this steps through three rounds of type resolution before finally arriving at the
1224  /// actual trie_vs_trie method. The type resolution calls allow the trie-vs-trie algorithm
1225  /// to be templated with full type knowledge and therefore be optimized by the compiler for
1226  /// each variation on the count pair data used and the count pair funtions invoked.
1227  //std::cout << "BEGIN TVT " << set1.resid() << " and " << set2.resid() << std::endl;
1228  trie1->trie_vs_trie( *trie2, *cp, *this, temp_table1, temp_table2 );
1229  //std::cout << "END TVT " << set1.resid() << " and " << set2.resid() << std::endl;
1230 
1231  /// add in the energies calculated by the tvt alg.
1232  energy_table += temp_table1;
1233  //std::cout << "FINISHED evaluate_rotamer_pair_energies" << std::endl;
1234 
1235  /*
1236  // debug
1237  //using namespace pack;
1238 
1239  ObjexxFCL::FArray2D< core::PackerEnergy > temp_table3( energy_table );
1240  temp_table3 = 0;
1241  EnergyMap emap;
1242  for ( Size ii = 1, ii_end = set1.num_rotamers(); ii <= ii_end; ++ii ) {
1243  for ( Size jj = 1, jj_end = set2.num_rotamers(); jj <= jj_end; ++jj ) {
1244  emap.zero();
1245  residue_pair_energy( *set1.rotamer( ii ), *set2.rotamer( jj ), pose, sfxn, emap );
1246  temp_table3( jj, ii ) += weights.dot( emap );
1247  if ( std::abs( temp_table1( jj, ii ) - temp_table3( jj, ii )) > 0.001 ) {
1248  std::cout << "Residues " << set1.resid() << " & " << set2.resid() << " rotamers: " << ii << " & " << jj;
1249  std::cout << " tvt/reg discrepancy: tvt= " << temp_table1( jj, ii ) << " reg= " << temp_table3( jj, ii );
1250  std::cout << " delta: " << temp_table1( jj, ii ) - temp_table3( jj, ii ) << std::endl;
1251  }
1252  }
1253  }
1254  std::cout << "Finished RPE calcs for residues " << set1.resid() << " & " << set2.resid() << std::endl;
1255  */
1256 }
1257 
1258 
1259 
1260 //@brief overrides default rotamer/background energy calculation and uses
1261 // the trie-vs-trie algorithm instead
1262 void
1264  conformation::RotamerSetBase const & set,
1265  conformation::Residue const & residue,
1266  pose::Pose const & pose,
1267  ScoreFunction const & ,
1268  EnergyMap const & weights,
1270 ) const
1271 {
1272  using namespace methods;
1273  using namespace hbtrie;
1274  using namespace trie;
1277 
1278  if ( options_->exclude_DNA_DNA() && residue.is_DNA() && pose.residue( set.resid() ).is_DNA() ) return;
1279 
1280  // allocate space for the trie-vs-trie algorithm
1281  utility::vector1< core::PackerEnergy > temp_vector1( set.num_rotamers(), 0.0 );
1282  utility::vector1< core::PackerEnergy > temp_vector2( set.num_rotamers(), 0.0 );
1283 
1284  // save weight information so that its available during tvt execution
1285  weights_ = weights;
1286  res1_ = set.resid(); //Added by Parin Sripakdeevong (sripakpa@stanford.edu)
1287  res2_ = residue.seqpos(); //Added by Parin Sripakdeevong (sripakpa@stanford.edu)
1288  rotamer_seq_sep_ = pose.residue( residue.seqpos() ).polymeric_oriented_sequence_distance( pose.residue( set.resid() ) );
1289 
1290  if ( true ) { // super_hacky
1291  hbonds::HBondSet const & hbond_set
1292  ( static_cast< hbonds::HBondSet const & >
1293  ( pose.energies().data().get( HBOND_SET )));
1294  res1_nb_ = hbond_set.nbrs( set.resid() );
1295  res2_nb_ = hbond_set.nbrs( residue.seqpos() );
1296  } else {
1297  res1_nb_ = pose.energies().tenA_neighbor_graph().get_node( set.resid() )->num_neighbors_counting_self();
1298  res2_nb_ = pose.energies().tenA_neighbor_graph().get_node( residue.seqpos() )->num_neighbors_counting_self();
1299  }
1300 
1301  HBondRotamerTrieCOP trie1( static_cast< trie::RotamerTrieBase const * > ( set.get_trie( hbond_method )() ) );
1302  HBondRotamerTrieCOP trie2 = ( static_cast< TrieCollection const & >
1303  ( pose.energies().data().get( HBOND_TRIE_COLLECTION )) ).trie( residue.seqpos() );
1304 
1305  TrieCountPairBaseOP cp = new HBCountPairFunction;
1306 
1307  /// now execute the trie vs trie algorithm.
1308  /// this steps through three rounds of type resolution before finally arriving at the
1309  /// actual trie_vs_trie method. The type resolution calls allow the trie-vs-trie algorithm
1310  /// to be templated with full type knowledge (and therefore be optimized by the compiler for
1311  /// each variation on the count pair data used and the count pair funtions invoked.
1312  trie1->trie_vs_path( *trie2, *cp, *this, temp_vector1, temp_vector2 );
1313 
1314  /// add in the energies calculated by the tvt alg.
1315  for ( Size ii = 1; ii <= set.num_rotamers(); ++ii ) {
1316  energy_vector[ ii ] += temp_vector1[ ii ];
1317  }
1318  //std::cout << "FINISHED evaluate_rotamer_background_energies" << std::endl;
1319 
1320  /*
1321  //debug
1322  utility::vector1< Energy > temp_vector3( energy_vector.size(), 0.0f );
1323  EnergyMap emap;
1324  for ( Size ii = 1, ii_end = set.num_rotamers(); ii <= ii_end; ++ii ) {
1325  emap.zero();
1326  residue_pair_energy( *set.rotamer( ii ), residue, pose, sfxn, emap );
1327  temp_vector3[ ii ] += weights.dot( emap );
1328  if ( std::abs( temp_vector1[ ii ] - temp_vector3[ ii ]) > 0.001 ) {
1329  std::cout << "Residues " << set.resid() << " & " << residue.seqpos() << " rotamers: " << ii << " & bg";
1330  std::cout << " tvt/reg discrepancy: tvt= " << temp_vector1[ ii ] << " reg= " << temp_vector3[ ii ];
1331  std::cout << " delta: " << temp_vector1[ ii ] - temp_vector3[ ii ] << std::endl;
1332  }
1333  }
1334  std::cout << "Finished Rotamer BG calcs for residues " << set.resid() << " & " << residue.seqpos() << std::endl;
1335  */
1336 
1337 }
1338 
1339 
1340 ///
1341 void
1343  pose::Pose & pose,
1344  ScoreFunction const &,
1345  EnergyMap & totals
1346 ) const
1347 {
1349 
1350  /// Don't add in bb/bb hbond energies during minimization
1351  if ( pose.energies().use_nblist() ) return;
1352 
1353  if (options_->decompose_bb_hb_into_pair_energies()) return;
1354 
1355  hbonds::HBondSet const & hbond_set
1356  ( static_cast< hbonds::HBondSet const & >( pose.energies().data().get( HBOND_SET )));
1357 
1358  EnergyMap hbond_emap(totals);
1359 
1360 
1361  // the current logic is that we fill the hbond set with backbone
1362  // hbonds only at the beginning of scoring. this is done to setup
1363  // the bb-bb hbond exclusion logic. so the hbondset should only
1364  // include bb-bb hbonds.
1365  // but see get_hb_don_chem_type in hbonds_geom.cc -- that only
1366  // classifies protein backbone donors as backbone, and the energy
1367  // accumulation by type is influenced by that via HBeval_lookup
1368  //
1369  // the important thing is that there's no double counting, which
1370  // is I think true since both fill_hbond_set and get_rsd-rsd-energy
1371  // use atom_is_backbone to check...
1372  //assert( std::abs( bb_scE ) < 1e-3 && std::abs( scE ) < 1e-3 );
1373 
1374 
1375  // this is to replicate buggy behavior regarding protein-backbone -- dna-backbone hbonds
1376  Real original_bb_sc = totals[ hbond_bb_sc ];
1377  Real original_sr_bb_sc = totals[ hbond_sr_bb_sc ];
1378  Real original_lr_bb_sc = totals[ hbond_lr_bb_sc ];
1379  Real original_sc = totals[ hbond_sc ];
1380  Real original_intra = totals[hbond_intra];
1381  // end replicate
1382 
1383  get_hbond_energies( hbond_set, totals );
1384 
1385  // begin replicate
1386  totals[ hbond_bb_sc ] = original_bb_sc;
1387  totals[ hbond_sr_bb_sc ] = original_sr_bb_sc;
1388  totals[ hbond_lr_bb_sc ] = original_lr_bb_sc;
1389  totals[ hbond_sc ] = original_sc;
1390  totals[ hbond_intra ] = original_intra;
1391  // end replicate
1392 
1393 }
1394 
1395 /* DEPRECATED
1396 /// f1 and f2 are zeroed
1397 void
1398 HBondEnergy::eval_atom_derivative(
1399  id::AtomID const & atom_id,
1400  pose::Pose const & pose,
1401  kinematics::DomainMap const &,
1402  ScoreFunction const &,
1403  EnergyMap const & weights,
1404  Vector & F1,
1405  Vector & F2
1406 ) const
1407 {
1408  using EnergiesCacheableDataType::HBOND_SET;
1409 
1410  hbonds::HBondSet const & hbond_set
1411  ( static_cast< hbonds::HBondSet const & >
1412  ( pose.energies().data().get( HBOND_SET ) ) );
1413  Vector f1,f2;
1414  hbonds::get_atom_hbond_derivative( atom_id, hbond_set, weights, f1, f2 );
1415  F1 += f1;
1416  F2 += f2;
1417 }*/
1418 
1419 ///@brief HACK! MAX_R defines the maximum donorH to acceptor distance.
1420 // The atomic_interaction_cutoff method is meant to return the maximum distance
1421 // between two *heavy atoms* for them to have a zero interaction energy.
1422 // I am currently assuming a 1.35 A maximum distance between a hydrogen and the
1423 // heavy atom it is bound to, stealing this number from the CYS.params file since
1424 // the HG in CYS is much further from it's SG than aliphatic hydrogens are from their carbons.
1425 // This is a bad idea. Someone come up with a way to fix this!
1426 //
1427 // At 4.35 A interaction cutoff, the hbond energy function is incredibly short ranged!
1428 Distance
1430 {
1431  return MAX_R + 1.35; // MAGIC NUMBER
1432 }
1433 
1434 /// @brief the atomic interaction cutoff and the hydrogen interaction cutoff are the same.
1435 Real
1437 {
1438  return (MAX_R + 1.35) * ( MAX_R + 1.35 );
1439 }
1440 
1441 
1442 ///@brief HBondEnergy is context sensitive
1443 void
1445  utility::vector1< bool > & context_graphs_required
1446 ) const
1447 {
1448  context_graphs_required[ ten_A_neighbor_graph ] = true;
1449 }
1450 
1451 bool
1453 {
1454 
1455  bool condition_1= (weights[hbond_intra]>0.0001) ? true : false;
1456 
1457  bool condition_2= (options_->include_intra_res_RNA()) ? true: false;
1458 
1459  return (condition_1 && condition_2);
1460 
1461 }
1462 
1463 
1464 void
1466  conformation::Residue const & rsd,
1467  pose::Pose const &,
1468  ScoreFunction const & ,
1469  EnergyMap & emap
1470 ) const
1471 {
1472 
1473  if(options_->include_intra_res_RNA() && rsd.is_RNA()){
1474  identify_intra_res_hbonds( *database_, rsd, false /*calculate_derivative*/, *options_, emap);
1475  }
1476 
1477 }
1478 
1479 void
1481  conformation::Residue const & res,
1482  hbonds::HBondOptions const & options,
1483  hbonds::HBondSet const & hbond_set,
1485 )
1486 {
1487  using namespace trie;
1488  using namespace hbtrie;
1489 
1490  Size const resid( res.seqpos() );
1491 
1492  Size n_to_add(0);
1493  utility::vector1< int > add_to_trie( res.natoms(), 0 );
1494  for ( Size jj = 1; jj <= res.natoms(); ++jj ) {
1495  if ( res.atom_type_set()[ res.atom( jj ).type() ].is_acceptor() ) {
1496  //std::cout << "acc=" << jj << " ";
1497  add_to_trie[ jj ] = 1;
1498  } //else if ( res.atom_type_set()[ res.atom( jj ).type() ].is_hydrogen() &&
1499  else if ( res.atom_is_hydrogen( jj ) &&
1500  res.atom_type_set()[ res.atom( res.type().atom_base( jj ) ).type() ].is_donor()) {
1501  add_to_trie[ jj ] = 1;
1502  add_to_trie[ res.type().atom_base( jj ) ] = 1;
1503  //std::cout << "don=" << jj << " donb= " << res.type().atom_base( jj ) << " ";
1504  }
1505  }
1506  //std::cout << "rotamer trie for residue: " << res.type().name() << std::endl;
1507  for ( Size jj = 1; jj <= res.natoms(); ++jj ) {
1508  if ( add_to_trie[ jj ] == 1 ){
1509  ++n_to_add;
1510  //std::cout << jj << " ";
1511  }
1512  }
1513  //std::cout << std::endl;
1514 
1515  if ( n_to_add == 0 ) {
1516  // What happens if there are NO hydrogen bonding atoms? It would be nice if we didn't have to create
1517  // a trie at all, but I'm pretty sure the indexing logic requires that we have a place-holder rotamer.
1518  add_to_trie[ 1 ] = 1; ++n_to_add;
1519  }
1520  rotamer_descriptor.natoms( n_to_add );
1521 
1522  Size count_added_atoms = 0;
1523  for ( Size jj = 1; jj <= res.nheavyatoms(); ++jj ) {
1524  if ( add_to_trie[ jj ] == 0 ) continue;
1525 
1526  HBAtom newatom;
1527  HBCPData cpdata;
1528 
1529  newatom.xyz( res.atom(jj).xyz() );
1530  newatom.base_xyz( res.xyz( res.atom_base( jj )) );
1531  newatom.is_hydrogen( false );
1532  newatom.is_backbone( res.atom_is_backbone( jj ) ) ;
1533 
1534  //Following preserves hbond_sc, hbond_bb_sc, as preferred by other developers for protein/DNA.
1535  newatom.is_protein( res.is_protein() );
1536  newatom.is_dna( res.is_DNA() );
1537 
1538  if ( res.atom_type_set()[ res.atom( jj ).type() ].is_acceptor() ) {
1539 
1540  newatom.hb_chem_type( get_hb_acc_chem_type( jj, res ));
1541  //newatom.orientation_vector( create_acc_orientation_vector( res, jj ));
1542  //newatom.base_xyz( res.xyz( res.atom_base( jj )) );
1543  newatom.base2_xyz( res.xyz( res.abase2( jj )) );
1544 
1545  cpdata.is_sc( ! res.type().atom_is_backbone( jj ) );
1546 
1547  /// Count-pair data is responsible for enforcing the sc/bb hbond exclusion rule.
1548  /// If we're not using the rule, set "avoid_sc_hbonds" to false.
1549  cpdata.avoid_sc_hbonds( options.bb_donor_acceptor_check() &&
1550  ! cpdata.is_sc() &&
1551  res.type().is_protein() &&
1552  hbond_set.acc_bbg_in_bb_bb_hbond( resid ) );
1553  }
1554 
1555 
1556  RotamerDescriptorAtom< HBAtom, HBCPData > rdatom( newatom, cpdata );
1557  rotamer_descriptor.atom( ++count_added_atoms, rdatom );
1558 
1559  for ( Size kk = res.attached_H_begin( jj ),
1560  kk_end = res.attached_H_end( jj );
1561  kk <= kk_end; ++kk ) {
1562  if ( add_to_trie[ kk ] == 0 ) continue;
1563 
1564  HBAtom newhatom;
1565  newhatom.xyz( res.atom(kk).xyz() );
1566  newhatom.base_xyz( res.xyz( res.atom_base( kk )) );
1567  newhatom.base2_xyz( Vector( 0.0, 0.0, 0.0 ) );
1568  //newhatom.orientation_vector( create_don_orientation_vector( res, kk ));
1569  newhatom.hb_chem_type( get_hb_don_chem_type( res.atom_base(kk), res ));
1570  newhatom.is_hydrogen( true );
1571  newhatom.is_backbone( res.atom_is_backbone( kk ) ) ;
1572 
1573  //Following preserves hbond_sc, hbond_bb_sc, as preferred by other developers for protein/DNA.
1574  newhatom.is_protein( res.is_protein() );
1575  newhatom.is_dna( res.is_DNA() );
1576 
1577  HBCPData hcpdata;
1578  hcpdata.is_sc( ! res.type().atom_is_backbone( kk ) );
1579 
1580  /// Count-pair data is responsible for enforcing the sc/bb hbond exclusion rule.
1581  /// If we're not using the rule, set "avoid_sc_hbonds" to false.
1582  hcpdata.avoid_sc_hbonds( options.bb_donor_acceptor_check() &&
1583  ! hcpdata.is_sc() &&
1584  res.type().is_protein() &&
1585  hbond_set.don_bbg_in_bb_bb_hbond( resid ) );
1586 
1587  RotamerDescriptorAtom< HBAtom, HBCPData > hrdatom( newhatom, hcpdata );
1588  rotamer_descriptor.atom( ++count_added_atoms, hrdatom );
1589 
1590  }
1591  }
1592 }
1593 
1596  conformation::RotamerSetBase const & rotset,
1597  pose::Pose const & pose
1598 ) const
1599 {
1600  using namespace trie;
1601  using namespace hbtrie;
1603 
1604  hbonds::HBondSet const & hbond_set
1605  ( static_cast< hbonds::HBondSet const & >
1606  ( pose.energies().data().get( HBOND_SET ) ) );
1607 
1608  //Size const resid( rotset.resid() );
1609 
1611 
1612  for ( Size ii = 1; ii <= rotset.num_rotamers(); ++ii ) {
1613  conformation::ResidueCOP ii_rotamer( rotset.rotamer( ii ) );
1614  create_rotamer_descriptor( *ii_rotamer, *options_, hbond_set, rotamer_descriptors[ ii ] );
1615  rotamer_descriptors[ ii ].rotamer_id( ii );
1616  }
1617 
1618  sort( rotamer_descriptors.begin(), rotamer_descriptors.end() );
1619 
1620  return new RotamerTrie< HBAtom, HBCPData >( rotamer_descriptors, atomic_interaction_cutoff());
1621 
1622 }
1623 
1626  conformation::Residue const & res,
1627  pose::Pose const & pose
1628 ) const
1629 {
1630  using namespace trie;
1631  using namespace hbtrie;
1633 
1634  hbonds::HBondSet const & hbond_set
1635  ( static_cast< hbonds::HBondSet const & >
1636  ( pose.energies().data().get( HBOND_SET ) ) );
1637 
1639 
1640  create_rotamer_descriptor( res, *options_, hbond_set, rotamer_descriptors[ 1 ] );
1641  rotamer_descriptors[ 1 ].rotamer_id( 1 );
1642 
1643  return new RotamerTrie< HBAtom, HBCPData >( rotamer_descriptors, atomic_interaction_cutoff());
1644 
1645 }
1646 
1647 ///@brief code to evaluate a hydrogen bond energy for the trie that
1648 /// didn't belong in the header itself -- it certainly does enough work
1649 /// such that inlining it would not likely produce a speedup.
1650 Energy
1652  hbtrie::HBAtom const & at1, // atom 1 is the heavy atom, the acceptor
1653  hbtrie::HBAtom const & at2, // atom 2 is the hydrogen atom, the donor
1654  bool flipped // is at1 from residue 1?
1655 ) const
1656 {
1657 
1658  // When acc and don are both polymers and on the same chain:
1659  // ss = acc.seqpos - don.seqpos
1660  int ss = (flipped ? -rotamer_seq_sep_ : rotamer_seq_sep_);
1661  HBEvalTuple hbe_type = hbond_evaluation_type( at2, 0, // donor atom
1662  at1, ss); // acceptor atom
1663  Energy hbenergy;
1664  //hb_energy_deriv_u( database_, hbe_type, at2.xyz(), at2.xyz() /*apl -- donor atom coordinate goes here, but is only used for derivatives */,
1665  // at2.orientation_vector(),
1666  // at1.xyz(), at1.xyz() /* apl -- acceptor-base coordinate goes here, but is only used for derivatives */,
1667  // at1.orientation_vector(),
1668  // Vector(-1.0,-1.0,-1.0), // abase2 xyz -- this is now wrong
1669  // hbenergy,
1670  // false /*evaluate_derivative*/, DUMMY_DERIVS );
1671 
1672  hb_energy_deriv( *database_, *options_, hbe_type,
1673  at2.base_xyz(), at2.xyz(), // donor heavy atom, donor hydrogen,
1674  at1.xyz(), at1.base_xyz(), at1.base2_xyz(), // acceptor, acceptor base, acceptor base2
1675  hbenergy, false, DUMMY_DERIVS );
1676  //std::cout << "drawn_out_heavyatom_hydrogenatom_energy " << hbenergy << " " << at1 << " " << at2 << std::endl;
1677 
1678  if ( hbenergy >= MAX_HB_ENERGY ) return 0.0; // no hbond
1679 
1680  //std::cout << "drawn_out_heavyatom_hydrogenatom_energy " << hbenergy << " " << at1 << " " << at2 << std::endl;
1681 
1682  Real envweight( 1.0 );
1683  if ( options_->use_hb_env_dep() ){
1684  envweight = ( flipped ? get_environment_dependent_weight( hbe_type, res2_nb_, res1_nb_, *options_ ) :
1686  }
1687  //pba membrane specific correction
1688  if ( options_->Mbhbond()) {
1689 
1690  Real membrane_depth_dependent_weight( 1.0 );
1691  membrane_depth_dependent_weight = ( flipped ? get_membrane_depth_dependent_weight(normal_, center_, thickness_,
1693  center_, thickness_, steepness_, res2_nb_, res1_nb_, at2.xyz(), at1.xyz()) );
1694 
1695  // std::cout << "flipped " << flipped << " acc " << res1_nb_ << " don " << res2_nb_ << " wat " << envweight
1696  // << " memb " << membrane_depth_dependent_weight << std::endl;
1697 
1698  envweight = membrane_depth_dependent_weight;
1699  }
1700 
1701  Real weighted_energy(hb_eval_type_weight(hbe_type.eval_type(), weights_, res1_==res2_) * hbenergy * envweight);
1702 
1703  //std::cout << "weighted energy: " << weighted_energy << " " << hbenergy << " " << envweight << std::endl;
1704  return weighted_energy;
1705 }
1706 
1707 
1708 /// @details
1709 /// Version 2: 2011-06-27 Fixing chi2 SER/THR and chi3 TYR derivatives when they act as acceptors.
1710 core::Size
1712 {
1713  //return 1; // Initial versioning
1714  return 2;
1715 }
1716 
1717 } // hbonds
1718 } // scoring
1719 } // core
1720