41 #include <basic/options/option.hh>
42 #include <basic/options/keys/score.OptionKeys.gen.hh>
45 #include <ObjexxFCL/format.hh>
49 #include <basic/Tracer.hh>
52 #include <utility/vector1.hh>
53 #include <utility/options/IntegerVectorOption.hh>
54 #include <utility/options/StringVectorOption.hh>
55 #include <ObjexxFCL/FArray3D.hh>
60 static basic::Tracer
tr(
"core.scoring.geometric_solvation.GeometricSolEnergy" );
76 namespace geometric_solvation {
78 using namespace ObjexxFCL::fmt;
98 using namespace core::scoring::hbonds;
105 hb_database_(
HBondDatabase::get_database( opts.hbond_options().params_database_tag() )),
107 geometric_sol_scale_( 0.4 * 1.17 / 0.65 ),
108 correct_geom_sol_acceptor_base_( basic::options::option[ basic::options::OptionKeys::score::geom_sol_correct_acceptor_base ]() ),
112 options_->hbond_options().use_incorrect_deriv(
true );
113 options_->hbond_options().use_sp2_chi_penalty(
false );
120 hb_database_( src.hb_database_ ),
121 dist_cut2_( src.dist_cut2_ ),
122 geometric_sol_scale_( src.geometric_sol_scale_ ),
123 correct_geom_sol_acceptor_base_( src.correct_geom_sol_acceptor_base_ ),
124 verbose_( src.verbose_ )
148 hbond_set->setup_for_residue_pair_energies( pose );
166 hbond_set->resize_bb_donor_acceptor_arrays( pose.
total_residue() );
243 Real res_solE( 0.0 ), energy( 0.0 );
246 for ( chemical::AtomIndices::const_iterator
248 hnume = don_rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
249 Size const don_h_atm( *hnum );
250 for (
Size occ_atm = 1; occ_atm <= occ_rsd.
nheavyatoms(); occ_atm++ ) {
260 occ_atm, occ_rsd, pose, energy );
276 Real res_solE( 0.0 ), energy( 0.0 );
278 for ( chemical::AtomIndices::const_iterator
280 anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
281 Size const acc_atm( *anum );
282 for (
Size occ_atm = 1; occ_atm <= occ_rsd.
nheavyatoms(); occ_atm++ ) {
292 occ_atm, occ_rsd, pose, energy);
321 z = cross( (water_v - atom_v), (atom_v - base_v) );
323 y = water_v - atom_v;
328 direction = xH * y +
Real( std::sqrt( 1 - (xH * xH) ) ) * x;
329 water_base_v = water_v + bond_length * direction;
338 bool const & is_donor,
340 Vector const & polar_atm_xyz,
341 Vector const & base_atm_xyz,
342 Vector const & occluding_atm_xyz,
343 Size const & polar_nb,
345 bool const update_deriv ,
349 static bool const always_do_full_calculation(
true );
354 Real AHdis( 0.0 ), xD( 0.0 ), xH( 0.0 ), energy( 0.0 );
358 static Distance const water_O_H_distance( 0.958 );
359 Real environment_weight( 1.0 );
368 Real const AHdis2 = (polar_atm_xyz - occluding_atm_xyz).length_squared();
369 if ( AHdis2 >
MAX_R2 )
return 0.0;
370 if ( AHdis2 <
MIN_R2 )
return 0.0;
371 AHdis = std::sqrt(AHdis2);
374 xD =
get_water_cos( base_atm_xyz, polar_atm_xyz, occluding_atm_xyz );
375 if ( xD <
MIN_xD )
return 0.0;
376 if ( xD >
MAX_xD )
return 0.0;
379 Vector occluding_base_atm_xyz( 0.0 );
380 if ( update_deriv || always_do_full_calculation ) {
381 set_water_base_atm( base_atm_xyz, polar_atm_xyz, occluding_atm_xyz, occluding_base_atm_xyz,
382 xH, water_O_H_distance );
384 hbond_eval_type, base_atm_xyz, polar_atm_xyz,
386 occluding_base_atm_xyz,
387 occluding_base_atm_xyz,
389 if (
verbose_)
tr <<
"DERIV ENERGY DONOR: " << energy;
392 if (
options_->hbond_options().use_hb_env_dep() ) {
405 AHdis = ( polar_atm_xyz - occluding_atm_xyz ).length();
406 AHdis -= water_O_H_distance;
407 Real const AHdis2 = AHdis * AHdis;
408 if ( AHdis2 >
MAX_R2 )
return 0.;
409 if ( AHdis2 <
MIN_R2 )
return 0.;
413 xH =
get_water_cos( base_atm_xyz, polar_atm_xyz, occluding_atm_xyz );
414 if ( xH <
MIN_xH )
return 0.;
415 if ( xH >
MAX_xH )
return 0.;
418 if ( update_deriv || always_do_full_calculation ) {
419 Vector occluding_base_atm_xyz( 0.0 );
420 set_water_base_atm( base_atm_xyz, polar_atm_xyz, occluding_atm_xyz, occluding_base_atm_xyz,
421 -xD, water_O_H_distance );
423 occluding_atm_xyz, occluding_base_atm_xyz,
424 polar_atm_xyz, base_atm_xyz, base_atm_xyz,
426 if (
verbose_)
tr <<
"DERIV ENERGY ACCPT: " << energy;
428 if (
options_->hbond_options().use_hb_env_dep() ) {
440 if ( !always_do_full_calculation ) {
441 Real dummy_chi( 0.0 );
442 assert( !
options_->hbond_options().use_sp2_chi_penalty() );
445 AHdis, xD, xH, dummy_chi, energy );
448 if (
verbose_ )
tr <<
" jk ENERGY: " << energy << std::endl;
459 sol_penalty *= reweight;
486 if (sol_penalty < 0.) {
505 Size const & don_h_atm,
507 Size const & occ_atm,
511 bool const update_deriv ,
528 ( static_cast< hbonds::HBondSet const & >
537 Vector const & don_h_atm_xyz( don_rsd.
atom( don_h_atm ).
xyz() );
538 Vector const & don_base_atm_xyz( don_rsd.
atom( don_base_atm ).
xyz() );
542 if ( ( don_rsd.
seqpos() == occ_rsd.
seqpos() ) && ( occ_atm == don_base_atm ) )
return;
551 bool const don_h_atm_is_protein_backbone
553 bool const occ_atm_is_protein_backbone_acceptor
556 !occ_atm_is_protein_backbone_acceptor ) {
562 Real const base_dis2 = ( occ_atm_xyz - don_base_atm_xyz).length_squared();
566 Real const hdis2 = ( occ_atm_xyz - don_h_atm_xyz ).length_squared();
567 if ( hdis2 > base_dis2 )
return;
572 bool const potential_backbone_backbone_hbond =
573 ( don_h_atm_is_protein_backbone && occ_atm_is_protein_backbone_acceptor );
576 Size const don_nbrs = tenA_neighbor_graph.get_node( don_rsd.
seqpos() )->num_neighbors_counting_self();
577 Size const occ_nbrs = tenA_neighbor_graph.get_node( occ_rsd.
seqpos() )->num_neighbors_counting_self();
586 don_h_atm_xyz, don_base_atm_xyz, occ_atm_xyz,
588 update_deriv, deriv);
590 if (
verbose_ && ( energy > 0.0 ) ) {
591 tr <<
"jk DON res "<< don_rsd.
name1() << I(3,don_rsd.
seqpos())<<
592 " atom "<< don_rsd.
atom_name( don_h_atm )<<
" is occluded by occ_res " <<
594 " atom "<< occ_rsd.
atom_name( occ_atm ) <<
595 " (HBEvalType " << I(2,hbe.
eval_type()) <<
") " <<
596 " with energy "<< F(8,3,energy)<< std::endl;
621 acc_rsd.
xyz( acc_rsd.
abase2( acc_atm ) ),
622 base_atm_xyz, dummy );
634 Size const & acc_atm,
636 Size const & occ_atm,
640 bool const update_deriv ,
656 ( static_cast< hbonds::HBondSet const & >
669 bool const acc_atm_is_protein_backbone
682 if ( ( acc_rsd.
seqpos() == occ_rsd.
seqpos() ) && ( occ_atm == base_atm ) )
return;
686 bool const occ_atm_is_protein_backbone_donor
689 !occ_atm_is_protein_backbone_donor )
return;
697 Real const acc_dis2 = ( occ_atm_xyz - acc_atm_xyz ).length_squared();
701 Real const base_dis2 = ( occ_atm_xyz - base_atm_xyz ).length_squared();
702 if ( acc_dis2 > base_dis2 )
return;
706 bool const potential_backbone_backbone_hbond =
707 ( acc_atm_is_protein_backbone && occ_atm_is_protein_backbone_donor );
711 HBEvalTuple hbe = potential_backbone_backbone_hbond ? (
HBEvalTuple( occ_atm, occ_rsd, acc_atm, acc_rsd ) ) :
714 Size const acc_nbrs = tenA_neighbor_graph.get_node( acc_rsd.
seqpos() )->num_neighbors_counting_self();
715 Size const occ_nbrs = tenA_neighbor_graph.get_node( occ_rsd.
seqpos() )->num_neighbors_counting_self();
721 acc_atm_xyz, base_atm_xyz, occ_atm_xyz,
723 update_deriv, deriv);
725 if (
verbose_ && ( energy > 0.0 ) ) {
726 tr<<
"jk ACC res "<< acc_rsd.
name1() << I(3, acc_rsd.
seqpos())<<
727 " atom "<< acc_rsd.
atom_name( acc_atm )<<
" is occluded by occ_res "<<
729 " atom "<< occ_rsd.
atom_name( occ_atm ) <<
730 " (HBEvalType " << I(2,hbe.
eval_type()) <<
") " <<
731 " with energy "<< F(8,3,energy)<<std::endl;
743 Vector const & polar_atm_xyz,
744 Vector const & occluding_atm_xyz )
const
746 return dot( (polar_atm_xyz - base_atm_xyz).normalize(), (occluding_atm_xyz - polar_atm_xyz).normalize() );
757 for ( chemical::AtomIndices::const_iterator
759 hnume = rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
760 Size const don_h_atm( *hnum );
762 if ( don_base_atm == atm )
return true;
773 for ( chemical::AtomIndices::const_iterator
775 hnume = rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
776 Size const don_h_atm( *hnum );
777 if ( don_h_atm == atm )
return true;
787 for ( chemical::AtomIndices::const_iterator
789 anume = rsd.
accpt_pos().end(); anum != anume; ++anum ) {
790 Size const acc_atm( *anum );
791 if ( acc_atm == atm )
return true;
824 if(current_rsd.is_RNA()==
false)
return;
825 if(other_rsd.is_RNA()==
false)
return;
827 static bool const update_deriv(
true );
834 if(
verbose_) std::cout <<
"Start eval_atom_derivative, intra_res case, res= " << i <<
" atomno= " << current_atm <<
"[" << current_rsd.atom_name(current_atm) <<
"]" << std::endl;
838 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
851 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
865 for ( chemical::AtomIndices::const_iterator hnum = other_rsd.Hpos_polar().begin(), hnume = other_rsd.Hpos_polar().end(); hnum != hnume; ++hnum ) {
866 Size const don_h_atm( *hnum );
877 for ( chemical::AtomIndices::const_iterator anum = other_rsd.accpt_pos().begin(), anume = other_rsd.accpt_pos().end(); anum != anume; ++anum ) {
878 Size const acc_atm ( *anum );
890 std::cout <<
"eval_atom_derivative, intra_res :";
891 std::cout <<
" F1= " << F1[0] <<
" " << F1[1] <<
" " << F1[2];
892 std::cout <<
" F2= " << F2[0] <<
" " << F2[1] <<
" " << F2[2] << std::endl;
893 std::cout <<
"Finish eval_atom_derivative, intra_res case, res= " << i <<
" atomno= " << current_atm <<
"[" << current_rsd.atom_name(current_atm) <<
"]" << std::endl;
926 static bool const update_deriv(
true );
931 iter = energy_graph.get_node( i )->const_edge_list_begin();
935 Size j( (*iter)->get_other_ind( i ) );
937 if ( i == j )
continue;
943 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
946 pose, energy, update_deriv, deriv );
955 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
958 pose, energy, update_deriv, deriv );
968 for ( chemical::AtomIndices::const_iterator
969 hnum = other_rsd.Hpos_polar().begin(),
970 hnume = other_rsd.Hpos_polar().end(); hnum != hnume; ++hnum ) {
971 Size const don_h_atm( *hnum );
973 atom_id.
atomno(), current_rsd,
974 pose, energy, update_deriv, deriv );
981 for ( chemical::AtomIndices::const_iterator
982 anum = other_rsd.accpt_pos().begin(),
983 anume = other_rsd.accpt_pos().end(); anum != anume; ++anum ) {
984 Size const acc_atm ( *anum );
986 atom_id.
atomno(), current_rsd,
987 pose, energy, update_deriv, deriv );
1008 Real total_energy( 0.0 );
1012 Size const i( atom_id.
rsd() );
1018 iter = energy_graph.get_node( i )->const_edge_list_begin();
1022 Size j( (*iter)->get_other_ind( i ) );
1026 if ( i == j )
continue;
1032 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
1035 m, other_rsd, pose, energy );
1036 total_energy += energy;
1042 for (
Size m = 1; m <= other_rsd.nheavyatoms(); m++ ){
1045 m, other_rsd, pose, energy );
1046 total_energy += energy;
1052 return total_energy;
1110 return MAX_R + 1.35;
1133 if(rsd.
is_RNA()==
false)
return;
1135 Real geo_solE_intra_RNA =
1152 Real res_solE( 0.0 ), energy( 0.0 );
1158 for ( chemical::AtomIndices::const_iterator hnum = don_rsd.
Hpos_polar().begin(), hnume = don_rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
1159 Size const don_h_atm( *hnum );
1160 for (
Size occ_atm = 1; occ_atm <= occ_rsd.
nheavyatoms(); occ_atm++ ) {
1183 Real res_solE( 0.0 ), energy( 0.0 );
1185 for ( chemical::AtomIndices::const_iterator anum = acc_rsd.
accpt_pos().begin(), anume = acc_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
1186 Size const acc_atm( *anum );
1187 for (
Size occ_atm = 1; occ_atm <= occ_rsd.
nheavyatoms(); occ_atm++ ) {