31 #include <ObjexxFCL/format.hh>
35 #include <basic/options/option.hh>
36 #include <basic/options/keys/score.OptionKeys.gen.hh>
41 #include <basic/Tracer.hh>
44 #include <numeric/xyzVector.hh>
45 #include <numeric/conversions.hh>
46 #include <numeric/xyz.functions.hh>
49 #include <utility/vector1.hh>
50 #include <boost/bind.hpp>
56 static basic::Tracer
tr(
"core.scoring.carbon_hbonds.CarbonHBondEnergy" );
61 namespace carbon_hbonds {
63 using namespace ObjexxFCL::fmt;
88 carbon_hbond_potential_(
ScoringManager::get_instance()->get_CarbonHBondPotential() ),
89 max_dis_( carbon_hbond_potential_.max_dis() ),
90 max_dis2_( max_dis_*max_dis_ ),
91 path_dist_cutoff_( 4 ),
92 orientation_dep_rna_ch_o_bonds_( ! basic::options::option[ basic::options::OptionKeys::score::disable_orientation_dependent_rna_ch_o_bonds ]),
99 carbon_hbond_potential_(
ScoringManager::get_instance()->get_CarbonHBondPotential() ),
100 max_dis_( carbon_hbond_potential_.max_dis() ),
101 max_dis2_( max_dis_*max_dis_ ),
102 path_dist_cutoff_( src.path_dist_cutoff_ ),
103 orientation_dep_rna_ch_o_bonds_( src.orientation_dep_rna_ch_o_bonds_ ),
104 verbose_( src.verbose_ )
230 Size const path_size =
250 Real res_res_energy( 0.0 ), energy( 0.0 );
254 for ( chemical::AtomIndices::const_iterator
256 hnume = don_rsd.
Hpos_apolar().end(); hnum != hnume; ++hnum ) {
257 Size const don_h_atm( *hnum );
261 for ( chemical::AtomIndices::const_iterator
263 anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
266 Size const acc_atm( *anum );
269 if ( don_rsd.
xyz( don_h_atm ).distance_squared( acc_rsd.
xyz( acc_atm ) ) >
max_dis2_ )
continue;
272 acc_atm, acc_rsd, energy ) ) {
283 res_res_energy += energy;
288 return res_res_energy;
298 Real res_res_energy( 0.0 ), energy( 0.0 );
301 for ( chemical::AtomIndices::const_iterator
303 hnume = don_rsd.
Hpos_apolar().end(); hnum != hnume; ++hnum ) {
304 Size const don_h_atm( *hnum );
308 for ( chemical::AtomIndices::const_iterator
310 anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
312 Size const acc_atm( *anum );
316 if ( don_rsd.
xyz( don_h_atm ).distance_squared( acc_rsd.
xyz( acc_atm ) ) >
max_dis2_ )
continue;
321 res_res_energy += energy;
325 return res_res_energy;
335 Real res_res_energy( 0.0 ), energy( 0.0 );
338 for ( chemical::AtomIndices::const_iterator
340 hnume = don_rsd.
Hpos_apolar().end(); hnum != hnume; ++hnum ) {
341 Size const don_h_atm( *hnum );
345 for ( chemical::AtomIndices::const_iterator
347 anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
349 Size const acc_atm( *anum );
353 if ( don_rsd.
xyz( don_h_atm ).distance_squared( acc_rsd.
xyz( acc_atm ) ) >
max_dis2_ )
continue;
358 res_res_energy += energy;
362 return res_res_energy;
372 Real res_res_energy( 0.0 ), energy( 0.0 );
375 for ( chemical::AtomIndices::const_iterator
377 hnume = don_rsd.
Hpos_apolar().end(); hnum != hnume; ++hnum ) {
378 Size const don_h_atm( *hnum );
382 for ( chemical::AtomIndices::const_iterator
384 anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
386 Size const acc_atm( *anum );
390 if ( don_rsd.
xyz( don_h_atm ).distance_squared( acc_rsd.
xyz( acc_atm ) ) >
max_dis2_ )
continue;
395 res_res_energy += energy;
399 return res_res_energy;
409 Real res_res_energy( 0.0 ), energy( 0.0 );
412 for ( chemical::AtomIndices::const_iterator
414 hnume = don_rsd.
Hpos_apolar().end(); hnum != hnume; ++hnum ) {
415 Size const don_h_atm( *hnum );
419 for ( chemical::AtomIndices::const_iterator
421 anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
423 Size const acc_atm( *anum );
427 if ( don_rsd.
xyz( don_h_atm ).distance_squared( acc_rsd.
xyz( acc_atm ) ) >
max_dis2_ )
continue;
430 res_res_energy += energy;
434 return res_res_energy;
450 bool const eval_bb( eval_bbsc || eval_bbbb );
451 bool const eval_sc( eval_bbsc || eval_scsc );
454 for ( chemical::AtomIndices::const_iterator
456 hnume = don_rsd.
Hpos_apolar().end(); hnum != hnume; ++hnum ) {
457 Size const don_h_atm( *hnum );
460 if ( ! eval_bb )
continue;
462 if ( ! eval_sc )
continue;
467 for ( chemical::AtomIndices::const_iterator
469 anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
471 Size const acc_atm( *anum );
476 if ( ! eval_bb )
continue;
478 if ( ! eval_bbbb )
continue;
480 if ( ! eval_bbsc )
continue;
483 if ( ! eval_sc )
continue;
485 if ( ! eval_bbsc )
continue;
487 if ( ! eval_scsc )
continue;
492 if ( don_rsd.
xyz( don_h_atm ).distance_squared( acc_rsd.
xyz( acc_atm ) ) >
max_dis2_ )
continue;
496 acc_atm, acc_rsd, energy,
true, f2 ) ) {
498 if ( don_h_bb && acc_bb ) {
500 }
else if ( ! don_h_bb && ! acc_bb ) {
510 Vector const f1 = cross( f2, acc_rsd.
xyz( acc_atm ) );
512 don_atom_derivs[ don_h_atm ].f2() += f2;
513 don_atom_derivs[ don_h_atm ].f1() += f1 ;
515 acc_atom_derivs[ acc_atm ].f2() -= f2;
516 acc_atom_derivs[ acc_atm ].f1() -= f1;
522 don_atom_derivs[ don_h_atm ].f2() += f2;
523 Vector f1_H = cross( f2, acc_rsd.
xyz( acc_atm ) );
524 don_atom_derivs[ don_h_atm ].f1() += f1_H;
530 acc_atom_derivs[ acc_atm ].f2() += f2;
531 Vector f1_Acc = cross( f2, don_rsd.
xyz( don_h_atm ) );
532 acc_atom_derivs[ acc_atm ].f1() += f1_Acc;
550 Size const don_h_atm,
555 bool const update_deriv ,
566 if ( !
path_distance_OK( don_rsd, acc_rsd, don_atm, acc_atm ) )
return false;
572 if( acc_rsd.
is_virtual( acc_atm ) )
return false;
574 if( don_rsd.
is_virtual( don_atm ) )
return false;
576 if( don_rsd.
is_virtual( don_h_atm) )
return false;
582 Vector const & don_h_atm_xyz( don_rsd.
atom( don_h_atm ).
xyz() );
585 Vector const & base_atm_xyz( acc_rsd.
atom( base_atm ).
xyz() );
588 Vector H_A_vector = acc_atm_xyz - don_h_atm_xyz;
589 Vector D_H_vector = don_h_atm_xyz - don_atm_xyz;
590 Vector B_A_vector = acc_atm_xyz - base_atm_xyz;
595 Vector const r_H_A( acc_atm_xyz - don_h_atm_xyz );
596 Vector const z_D_H( ( don_h_atm_xyz - don_atm_xyz ).normalize() );
605 Real const angle_DH_A = numeric::conversions::degrees( angle_radians( don_atm_xyz, don_h_atm_xyz, acc_atm_xyz ) );
606 tr <<
"CHbond [RNA]: "<< don_rsd.
name1() << I(3,don_rsd.
seqpos())<<
607 " atom "<< don_rsd.
atom_name( don_h_atm )<<
" [ " <<
609 " ] bonded to acc_res " <<
611 " atom "<< acc_rsd.
atom_name( acc_atm ) <<
612 " with energy "<< F(8,3,energy) <<
" [" << F(8,3,H_A_vector.length()) <<
" Angstroms; "
613 << angle_DH_A <<
" degrees ]" << std::endl;
620 don_rsd.
atom_type_index( don_atm ), H_A_vector, D_H_vector, B_A_vector, update_deriv, f2);
624 " atom "<< don_rsd.
atom_name( don_h_atm )<<
" [ " <<
626 " ] bonded to acc_res " <<
628 " atom "<< acc_rsd.
atom_name( acc_atm ) <<
629 " with energy "<< F(8,3,energy) <<
" [" << F(8,3,H_A_vector.length()) <<
"]" << std::endl;
645 for ( chemical::AtomIndices::const_iterator
647 hnume = rsd.
Hpos_apolar().end(); hnum != hnume; ++hnum ) {
648 Size const don_h_atm( *hnum );
649 if ( don_h_atm == atm )
return true;
659 for ( chemical::AtomIndices::const_iterator
661 anume = rsd.
accpt_pos().end(); anum != anume; ++anum ) {
662 Size const acc_atm( *anum );
663 if ( acc_atm == atm )
return true;