40 #include <ObjexxFCL/format.hh>
44 #include <basic/Tracer.hh>
45 #include <basic/options/option.hh>
46 #include <basic/options/keys/score.OptionKeys.gen.hh>
51 #include <ObjexxFCL/FArray3D.hh>
54 static basic::Tracer
tr(
"core.scoring.geometric_solvation.ContextIndependentGeometricSolEnergy" );
68 namespace geometric_solvation {
70 using namespace ObjexxFCL::fmt;
90 using namespace core::scoring::hbonds;
96 hb_database_(
HBondDatabase::get_database( opts.hbond_options().params_database_tag() )),
98 geometric_sol_scale_( 0.4 * 1.17 / 0.65 ),
99 correct_geom_sol_acceptor_base_( basic::options::option[ basic::options::OptionKeys::score::geom_sol_correct_acceptor_base ]() ),
105 options_->hbond_options().use_incorrect_deriv(
true );
106 options_->hbond_options().use_sp2_chi_penalty(
false );
115 hb_database_( src.hb_database_ ),
116 dist_cut2_( src.dist_cut2_ ),
117 geometric_sol_scale_( src.geometric_sol_scale_ ),
118 correct_geom_sol_acceptor_base_( src.correct_geom_sol_acceptor_base_ ),
119 verbose_( src.verbose_ )
141 hbond_set->setup_for_residue_pair_energies( pose );
161 hbond_set->resize_bb_donor_acceptor_arrays( pose.
total_residue() );
187 if ( rsd1.
seqpos() == rsd2.
seqpos() ) utility_exit_with_message(
"rsd1.seqpos() == rsd2.seqpos()");
225 Real res_solE( 0.0 ), energy( 0.0 );
228 for ( chemical::AtomIndices::const_iterator hnum = don_rsd.
Hpos_polar().begin(), hnume = don_rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
229 Size const don_h_atm( *hnum );
230 for (
Size occ_atm = 1; occ_atm <= occ_rsd.
nheavyatoms(); occ_atm++ ) {
249 Real res_solE( 0.0 ), energy( 0.0 );
251 for ( chemical::AtomIndices::const_iterator anum = acc_rsd.
accpt_pos().begin(), anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
252 Size const acc_atm( *anum );
253 for (
Size occ_atm = 1; occ_atm <= occ_rsd.
nheavyatoms(); occ_atm++ ) {
279 Distance const & bond_length )
const
284 z = cross( (water_v - atom_v), (atom_v - base_v) );
286 y = water_v - atom_v;
291 direction = xH * y +
Real( std::sqrt( 1 - (xH * xH) ) ) * x;
292 water_base_v = water_v + bond_length * direction;
301 bool const & is_donor,
303 Vector const & polar_atm_xyz,
304 Vector const & base_atm_xyz,
305 Vector const & occluding_atm_xyz,
306 bool const update_deriv ,
310 static bool const always_do_full_calculation(
true );
315 Real AHdis( 0.0 ), xD( 0.0 ), xH( 0.0 ), energy( 0.0 );
319 static Distance const water_O_H_distance( 0.958 );
320 Real const environment_weight= 1.0;
329 Real const AHdis2 = (polar_atm_xyz - occluding_atm_xyz).length_squared();
330 if ( AHdis2 >
MAX_R2 )
return 0.0;
331 if ( AHdis2 <
MIN_R2 )
return 0.0;
332 AHdis = std::sqrt(AHdis2);
335 xD =
get_water_cos( base_atm_xyz, polar_atm_xyz, occluding_atm_xyz );
336 if ( xD <
MIN_xD )
return 0.0;
337 if ( xD >
MAX_xD )
return 0.0;
340 Vector occluding_base_atm_xyz( 0.0 );
341 if ( update_deriv || always_do_full_calculation ) {
342 set_water_base_atm( base_atm_xyz, polar_atm_xyz, occluding_atm_xyz, occluding_base_atm_xyz,
343 xH, water_O_H_distance );
345 hbond_eval_type, base_atm_xyz, polar_atm_xyz,
347 occluding_base_atm_xyz,
348 occluding_base_atm_xyz,
351 if (
verbose_)
tr <<
"DONOR ENERGY: " << energy << std::endl;
363 AHdis = ( polar_atm_xyz - occluding_atm_xyz ).length();
364 AHdis -= water_O_H_distance;
365 Real const AHdis2 = AHdis * AHdis;
366 if ( AHdis2 >
MAX_R2 )
return 0.;
367 if ( AHdis2 <
MIN_R2 )
return 0.;
371 xH =
get_water_cos( base_atm_xyz, polar_atm_xyz, occluding_atm_xyz );
372 if ( xH <
MIN_xH )
return 0.;
373 if ( xH >
MAX_xH )
return 0.;
376 if ( update_deriv || always_do_full_calculation ) {
377 Vector occluding_base_atm_xyz( 0.0 );
378 set_water_base_atm( base_atm_xyz, polar_atm_xyz, occluding_atm_xyz, occluding_base_atm_xyz,
379 -xD, water_O_H_distance );
381 occluding_atm_xyz, occluding_base_atm_xyz,
382 polar_atm_xyz, base_atm_xyz, base_atm_xyz,
386 if (
verbose_)
tr <<
"ACCPT ENERGY: " << energy << std::endl;
397 if ( !always_do_full_calculation ) {
398 Real dummy_chi( 0.0 );
399 assert( !
options_->hbond_options().use_sp2_chi_penalty() );
403 if (
verbose_ )
tr <<
" jk ENERGY: " << energy << std::endl;
414 sol_penalty *= reweight;
433 if (sol_penalty < 0.) {
452 Size const & don_h_atm,
454 Size const & occ_atm,
458 bool const update_deriv ,
475 Vector const & don_h_atm_xyz( don_rsd.
atom( don_h_atm ).
xyz() );
476 Vector const & don_base_atm_xyz( don_rsd.
atom( don_base_atm ).
xyz() );
480 if ( ( don_rsd.
seqpos() == occ_rsd.
seqpos() ) && ( occ_atm == don_base_atm ) )
return;
490 Real const base_dis2 = ( occ_atm_xyz - don_base_atm_xyz).length_squared();
494 Real const hdis2 = ( occ_atm_xyz - don_h_atm_xyz ).length_squared();
495 if ( hdis2 > base_dis2 )
return;
506 bool const potential_backbone_backbone_hbond = ( don_h_atm_is_protein_backbone && occ_atm_is_protein_backbone_acceptor );
516 if (
verbose_ && ( energy > 0.0 ) ) {
517 tr <<
"jk DON res "<< don_rsd.
name1() << I(3,don_rsd.
seqpos())<<
518 " atom "<< don_rsd.
atom_name( don_h_atm )<<
" is occluded by occ_res " <<
520 " atom "<< occ_rsd.
atom_name( occ_atm ) <<
521 " (HBEvalType " << I(2,hbe.
eval_type()) <<
") " <<
522 " with energy "<< F(8,3,energy)<< std::endl;
547 acc_rsd.
xyz( acc_rsd.
abase2( acc_atm ) ),
548 base_atm_xyz, dummy );
560 Size const & acc_atm,
562 Size const & occ_atm,
566 bool const update_deriv ,
595 if ( ( acc_rsd.
seqpos() == occ_rsd.
seqpos() ) && ( occ_atm == base_atm ) )
return;
603 Real const acc_dis2 = ( occ_atm_xyz - acc_atm_xyz ).length_squared();
607 Real const base_dis2 = ( occ_atm_xyz - base_atm_xyz ).length_squared();
608 if ( acc_dis2 > base_dis2 )
return;
620 bool const potential_backbone_backbone_hbond = ( acc_atm_is_protein_backbone && occ_atm_is_protein_backbone_donor );
622 if(potential_backbone_backbone_hbond) hbe = (
hbond_evaluation_type( occ_atm, occ_rsd, acc_atm, acc_rsd ) );
630 if (
verbose_ && ( energy > 0.0 ) ) {
631 tr<<
"jk ACC res "<< acc_rsd.
name1() << I(3, acc_rsd.
seqpos())<<
632 " atom "<< acc_rsd.
atom_name( acc_atm )<<
" is occluded by occ_res "<<
634 " atom "<< occ_rsd.
atom_name( occ_atm ) <<
635 " (HBEvalType " << I(2,hbe.
eval_type()) <<
") " <<
636 " with energy "<< F(8,3,energy)<<std::endl;
647 Vector const & polar_atm_xyz,
648 Vector const & occluding_atm_xyz )
const
650 return dot( (polar_atm_xyz - base_atm_xyz).normalize(), (occluding_atm_xyz - polar_atm_xyz).normalize() );
661 for ( chemical::AtomIndices::const_iterator
663 hnume = rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
664 Size const don_h_atm( *hnum );
666 if ( don_base_atm == atm )
return true;
677 for ( chemical::AtomIndices::const_iterator
679 hnume = rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
680 Size const don_h_atm( *hnum );
681 if ( don_h_atm == atm )
return true;
691 for ( chemical::AtomIndices::const_iterator
693 anume = rsd.
accpt_pos().end(); anum != anume; ++anum ) {
694 Size const acc_atm( *anum );
695 if ( acc_atm == atm )
return true;
737 static bool const update_deriv(
true );
744 if(
verbose_) std::cout <<
"Start eval_atom_derivative, intra_res case, res= " << i <<
" atomno= " << current_atm <<
"[" << current_rsd.atom_name(current_atm) <<
"]" << std::endl;
748 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
761 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
775 for ( chemical::AtomIndices::const_iterator hnum = other_rsd.Hpos_polar().begin(), hnume = other_rsd.Hpos_polar().end(); hnum != hnume; ++hnum ) {
776 Size const don_h_atm( *hnum );
787 for ( chemical::AtomIndices::const_iterator anum = other_rsd.accpt_pos().begin(), anume = other_rsd.accpt_pos().end(); anum != anume; ++anum ) {
788 Size const acc_atm ( *anum );
800 std::cout <<
"eval_atom_derivative, intra_res :";
801 std::cout <<
" F1= " << F1[0] <<
" " << F1[1] <<
" " << F1[2];
802 std::cout <<
" F2= " << F2[0] <<
" " << F2[1] <<
" " << F2[2] << std::endl;
803 std::cout <<
"Finish eval_atom_derivative, intra_res case, res= " << i <<
" atomno= " << current_atm <<
"[" << current_rsd.atom_name(current_atm) <<
"]" << std::endl;
831 static bool const update_deriv(
true );
836 iter = energy_graph.get_node( i )->const_edge_list_begin();
840 Size j( (*iter)->get_other_ind( i ) );
844 if ( i == j )
continue;
848 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
851 pose, energy, update_deriv, deriv );
859 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
862 pose, energy, update_deriv, deriv );
871 for ( chemical::AtomIndices::const_iterator
872 hnum = other_rsd.Hpos_polar().begin(),
873 hnume = other_rsd.Hpos_polar().end(); hnum != hnume; ++hnum ) {
874 Size const don_h_atm( *hnum );
876 atom_id.
atomno(), current_rsd,
877 pose, energy, update_deriv, deriv );
883 for ( chemical::AtomIndices::const_iterator
884 anum = other_rsd.accpt_pos().begin(),
885 anume = other_rsd.accpt_pos().end(); anum != anume; ++anum ) {
886 Size const acc_atm ( *anum );
888 atom_id.
atomno(), current_rsd,
889 pose, energy, update_deriv, deriv );
908 Real total_energy( 0.0 );
918 iter = energy_graph.get_node( i )->const_edge_list_begin();
922 Size j( (*iter)->get_other_ind( i ) );
926 if ( i == j )
continue;
932 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
937 total_energy += energy;
943 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
948 total_energy += energy;
997 Real geo_solE_intra_RNA =
1015 Real res_solE( 0.0 ), energy( 0.0 );
1021 for ( chemical::AtomIndices::const_iterator hnum = don_rsd.
Hpos_polar().begin(), hnume = don_rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
1022 Size const don_h_atm( *hnum );
1023 for (
Size occ_atm = 1; occ_atm <= occ_rsd.
nheavyatoms(); occ_atm++ ) {
1046 Real res_solE( 0.0 ), energy( 0.0 );
1048 for ( chemical::AtomIndices::const_iterator anum = acc_rsd.
accpt_pos().begin(), anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
1049 Size const acc_atm( *anum );
1050 for (
Size occ_atm = 1; occ_atm <= occ_rsd.
nheavyatoms(); occ_atm++ ) {