37 #include <basic/Tracer.hh>
49 #include <numeric/xyzVector.hh>
50 #include <numeric/xyzMatrix.hh>
56 #include <basic/options/keys/score.OptionKeys.gen.hh>
59 #include <utility/vector1.hh>
70 #include <platform/types.hh>
78 #include <utility/Bound.hh>
79 #include <utility/string_util.hh>
80 #include <utility/vector0_bool.hh>
81 #include <utility/file/FileName.hh>
82 #include <utility/keys/SmallKeyVector.hh>
83 #include <utility/options/BooleanOption.hh>
84 #include <utility/options/OptionCollection.hh>
85 #include <numeric/xyz.functions.hh>
86 #include <ObjexxFCL/FArray3D.hh>
87 #include <basic/options/option.hh>
91 static basic::Tracer
TR(
"core.scoring.geometric_solvation.ExactOccludedHbondSolEnergy" );
95 namespace geometric_solvation {
105 basic::options::option[ basic::options::OptionKeys::score::exact_occ_skip_Hbonders ],
106 basic::options::option[ basic::options::OptionKeys::score::exact_occ_include_Hbond_contribution ],
107 basic::options::option[ basic::options::OptionKeys::score::exact_occ_pairwise ],
108 basic::options::option[ basic::options::OptionKeys::score::exact_occ_pairwise_by_res ],
109 basic::options::option[ basic::options::OptionKeys::score::exact_occ_split_between_res ],
110 ! basic::options::option[ basic::options::OptionKeys::score::exact_occ_self_res_no_occ ],
111 basic::options::option[basic::options::OptionKeys::score::exact_occ_radius_scaling]
124 using namespace core;
125 using namespace core::scoring;
126 using namespace core::scoring::hbonds;
142 if ( instance_ == 0 )
165 xstep_ = water_grid_width / ( xnum_points_ - 1 );
166 ystep_ = water_grid_width / ( ynum_points_ - 1 );
167 zstep_ = water_grid_depth / ( znum_points_ - 1 );
169 xorigin_ = -xstep_ * ( xnum_points_ + 1) / 2.;
170 yorigin_ = -ystep_ * ( ynum_points_ + 1) / 2.;
179 if ( instance_ == 0 )
191 using namespace hbonds;
198 TR <<
"computing and storing water weight grids for acceptor types." << std::endl;
204 TR <<
"computing and storing water weight grids for donor types." << std::endl;
214 std::vector < std::vector < std::vector <core::Real> > > & water_weights,
216 GridInfo const & grid_info,
bool const water_is_donor)
219 static Vector const base_to_outer(0,0,1);
224 water_weights.clear();
229 water_weights[tx][ty].resize(grid_info.
znum_points(), 0.);
238 water_position.x() += grid_info.
xstep();
239 water_position.y() = grid_info.
yorigin();
241 water_position.y() += grid_info.
ystep();
242 water_position.z() = grid_info.
zorigin();
244 water_position.z() += grid_info.
zstep();
248 if ( water_is_donor ) {
257 AHdis = water_position.length();
258 AHdis -= water_O_H_distance;
263 xH = dot( base_to_outer, water_position.normalized() );
271 AHdis = water_position.length();
275 xD = dot( base_to_outer, water_position.normalized() );
279 if ( xH <
MIN_xH )
continue;
280 if ( xH >
MAX_xH )
continue;
281 if ( xD <
MIN_xD )
continue;
282 if ( xD >
MAX_xD )
continue;
283 if ( AHdis <
MIN_R )
continue;
284 if ( AHdis >
MAX_R )
continue;
291 AHdis, xD, xH, dummy_chi, curr_water_hbond );
294 curr_water_hbond *= entropy_scaling;
295 if ( curr_water_hbond < 0 ) {
297 water_weights[tx][ty][tz] = curr_water_weight;
298 sum_grid_water_weight += curr_water_weight;
304 return sum_grid_water_weight;
308 std::vector < std::vector < std::vector <core::Real> > >
const &
313 TR <<
"Could not look up map element" << std::endl;
314 TR <<
"get_water_weight_grid hbond_eval_type " << hbond_eval_type << std::endl;
318 return curr_water_weights_iter->second;
327 TR <<
"Could not look up map element" << std::endl;
328 TR <<
"get_sum_water_weight_grid hbond_eval_type " << hbond_eval_type << std::endl;
332 return curr_sum_water_weights_iter->second;
339 bool const exact_occ_skip_Hbonders,
340 bool const exact_occ_include_Hbond_contribution,
341 bool const exact_occ_pairwise,
342 bool const exact_occ_pairwise_by_res,
343 bool const exact_occ_split_between_res,
344 bool const exact_occ_self_res_occ,
349 exact_occ_skip_Hbonders_( exact_occ_skip_Hbonders ),
350 exact_occ_include_Hbond_contribution_( exact_occ_include_Hbond_contribution ),
351 exact_occ_pairwise_( exact_occ_pairwise ),
352 exact_occ_pairwise_by_res_( exact_occ_pairwise_by_res ),
353 exact_occ_split_between_res_( exact_occ_split_between_res ),
354 exact_occ_self_res_occ_( exact_occ_self_res_occ ),
355 occ_radius_scaling_( occ_radius_scaling ),
362 if (
verbose_ )
TR <<
"ExactOccludedHbondSolEnergy constructor" << std::endl;
364 TR <<
"Error - cannot split occ energy between residues unless pairwise calculations are used!" << std::endl;
387 exact_occ_skip_Hbonders_( src.exact_occ_skip_Hbonders_ ),
388 exact_occ_include_Hbond_contribution_( src.exact_occ_include_Hbond_contribution_ ),
389 exact_occ_pairwise_( src.exact_occ_pairwise_ ),
390 exact_occ_pairwise_by_res_( src.exact_occ_pairwise_by_res_ ),
391 exact_occ_split_between_res_( src.exact_occ_split_between_res_ ),
392 exact_occ_self_res_occ_( src.exact_occ_self_res_occ_ ),
393 occ_radius_scaling_( src.occ_radius_scaling_ ),
395 verbose_( src.verbose_ ),
396 atom_type_set_ptr_( src.atom_type_set_ptr_ )
398 if (
verbose_ )
TR <<
"ExactOccludedHbondSolEnergy constructor" << std::endl;
400 TR <<
"Error - cannot split occ energy between residues unless pairwise calculations are used!" << std::endl;
441 TR <<
"Error - cannot compute derivatives for ExactOccludedHbondSolEnergy (occ_sol_exact)" << std::endl;
449 TR <<
"Error - cannot compute derivatives for ExactOccludedHbondSolEnergy (occ_sol_exact)" << std::endl;
466 for ( chemical::AtomIndices::const_iterator
468 hnume = polar_rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
469 Size const polar_atom( *hnum );
476 if ( ( base_atom_name ==
" N " ) && polar_rsd.
is_lower_terminus() ) max_possible_LK /= 3;
477 if ( base_atom_name ==
" NZ " ) max_possible_LK /= 3;
478 if ( base_atom_name ==
" ND2" ) max_possible_LK /= 2;
479 if ( base_atom_name ==
" NE2" ) max_possible_LK /= 2;
480 if ( base_atom_name ==
" NH1" ) max_possible_LK /= 2;
481 if ( base_atom_name ==
" NH2" ) max_possible_LK /= 2;
487 max_possible_LK = -5.;
492 core::Real const Ebulk_weight = ( sum_water_weights * Emax_weight ) / ( 1. - Emax_weight);
496 core::Real const grid_constant = sum_water_weights + Ebulk_weight;
506 neighborlist.push_back( polar_resnum);
510 neighbor_iter != neighbor_iter_end; ++neighbor_iter ) {
511 neighborlist.push_back( (*neighbor_iter)->get_other_ind( polar_resnum ) );
513 for (
Size occ_inx = 1; occ_inx <= neighborlist.size(); ++occ_inx ) {
514 core::Size const occ_resnum( neighborlist[occ_inx] );
521 for (
Size occ_atomno = 1; occ_atomno <= occ_rsd.
natoms(); ++occ_atomno ) {
524 true, occ_resnum,
true, occ_atomno );
529 residue_geosol += polar_group_energy;
537 for ( chemical::AtomIndices::const_iterator
539 anume = polar_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
540 Size const polar_atom( *anum );
550 max_possible_LK = -5.;
555 core::Real const Ebulk_weight = ( sum_water_weights * Emax_weight ) / ( 1. - Emax_weight);
558 core::Real const grid_constant = sum_water_weights + Ebulk_weight;
568 neighborlist.push_back( polar_resnum);
572 neighbor_iter != neighbor_iter_end; ++neighbor_iter ) {
573 neighborlist.push_back( (*neighbor_iter)->get_other_ind( polar_resnum ) );
575 for (
Size occ_inx = 1; occ_inx <= neighborlist.size(); ++occ_inx ) {
576 core::Size const occ_resnum( neighborlist[occ_inx] );
583 for (
Size occ_atomno = 1; occ_atomno <= occ_rsd.
natoms(); ++occ_atomno ) {
586 true, occ_resnum,
true, occ_atomno );
591 residue_geosol += polar_group_energy;
599 TR <<
"PAIRWISE OUTPUT FORMAT IS NOT YET SUPPORTED" << std::endl;
613 Size const polar_atom,
614 bool const restrict_to_single_occluding_residue,
615 Size const single_occluding_resinx,
616 bool const restrict_to_single_occluding_atom,
617 Size const single_occluding_atominx
634 restrict_to_single_occluding_residue,
635 single_occluding_resinx,
636 restrict_to_single_occluding_atom,
637 single_occluding_atominx);
647 std::vector < std::vector < std::vector <core::Real> > >
const & water_weights,
648 bool const restrict_to_single_occluding_residue,
650 bool const restrict_to_single_occluding_atom,
658 if ( restrict_to_single_occluding_residue && !
exact_occ_self_res_occ_ && ( polar_resnum == single_occluding_resinx ) ) {
670 bool const hydrogens_can_occlude =
false;
687 core::Vector const translation_vector = -1.0 * orig_polar_atom_xyz;
688 core::Vector const translated_base_atom = orig_base_atom_xyz + translation_vector;
696 core::Vector desired_z = -1. * translated_base_atom.normalized();
699 core::Real arbitrary_x, arbitrary_y, arbitrary_z;
701 if ( std::abs( desired_z.z() ) > 0.01 ) {
704 arbitrary_z = -1. * ((arbitrary_x * desired_z.x()) + (arbitrary_y * desired_z.y())) / desired_z.z();
706 if ( std::abs( desired_z.y() ) > 0.01 ) {
709 arbitrary_y = -1. * ((arbitrary_x * desired_z.x()) + (arbitrary_z * desired_z.z())) / desired_z.y();
714 arbitrary_x = -1. * ((arbitrary_y * desired_z.y()) + (arbitrary_z * desired_z.z())) / desired_z.x();
717 core::Vector desired_x(arbitrary_x,arbitrary_y,arbitrary_z);
718 desired_x.normalize();
719 core::Vector desired_y = cross_product( desired_x, desired_z );
725 transformation_matrix.xx( desired_x.dot(cartesian_x) );
726 transformation_matrix.xy( desired_x.dot(cartesian_y) );
727 transformation_matrix.xz( desired_x.dot(cartesian_z) );
728 transformation_matrix.yx( desired_y.dot(cartesian_x) );
729 transformation_matrix.yy( desired_y.dot(cartesian_y) );
730 transformation_matrix.yz( desired_y.dot(cartesian_z) );
731 transformation_matrix.zx( desired_z.dot(cartesian_x) );
732 transformation_matrix.zy( desired_z.dot(cartesian_y) );
733 transformation_matrix.zz( desired_z.dot(cartesian_z) );
736 core::Vector new_base_atom_location = transformation_matrix * translated_base_atom;
737 assert( std::abs(new_base_atom_location.normalized().x()) < 0.001 );
738 assert( std::abs(new_base_atom_location.normalized().y()) < 0.001 );
739 assert( std::abs(new_base_atom_location.normalized().z() + 1.) < 0.001 );
742 if ( restrict_to_single_occluding_residue ) {
744 assert ( single_occluding_resinx > 0 );
745 neighborlist.push_back( single_occluding_resinx );
749 neighborlist.push_back( polar_resnum);
753 neighbor_iter != neighbor_iter_end; ++neighbor_iter ) {
754 neighborlist.push_back( (*neighbor_iter)->get_other_ind( polar_resnum ) );
758 for (
Size occ_inx = 1; occ_inx <= neighborlist.size(); ++occ_inx ) {
759 core::Size const occ_resnum( neighborlist[occ_inx] );
766 Size atom_startinx = 1;
768 if ( restrict_to_single_occluding_atom ) {
770 assert ( single_occluding_atominx > 0 );
771 atom_startinx = single_occluding_atominx;
772 atom_lastinx = single_occluding_atominx;
777 for (
Size occ_atomno = atom_startinx; occ_atomno <= atom_lastinx; ++occ_atomno ) {
780 if ( occ_atom_is_hydrogen && ! hydrogens_can_occlude )
continue;
783 if ( polar_resnum == occ_resnum ) {
784 if ( polar_atomno == occ_atomno )
continue;
785 if ( base_atomno == occ_atomno )
continue;
790 if ( occ_radius < 0.1 )
continue;
792 core::Real const sq_dist_cut = ( occ_radius + water_radius ) * ( occ_radius + water_radius );
800 bool occ_atom_is_Hbonded(
false);
803 for ( chemical::AtomIndices::const_iterator hnum = occ_rsd.
Hpos_polar().begin(), hnume = occ_rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
804 Size const don_h_atom( *hnum );
806 if ( occ_atomno == base_atom ) {
808 for ( chemical::AtomIndices::const_iterator anum = polar_rsd.
accpt_pos().begin(), anume = polar_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
809 Size const acc_atom( *anum );
810 if ( polar_atomno == acc_atom ) {
816 HBEvalTuple const hbe_type( don_chem_type, acc_chem_type, seq_sep);
819 occ_rsd.
atom( occ_atomno ).
xyz(), occ_rsd.
atom( don_h_atom ).
xyz(),
821 polar_rsd.
atom( polar_rsd.
abase2( polar_atomno ) ).
xyz(), hb_ener);
823 if ( hb_ener < 0. ) {
835 polar_group_hb_energy += hb_ener;
838 occ_atom_is_Hbonded =
true;
847 for ( chemical::AtomIndices::const_iterator anum = occ_rsd.
accpt_pos().begin(), anume = occ_rsd.
accpt_pos().end(); anum != anume; ++anum ) {
848 Size const acc_atom( *anum );
849 if ( occ_atomno == acc_atom ) {
851 for ( chemical::AtomIndices::const_iterator hnum = polar_rsd.
Hpos_polar().begin(), hnume = polar_rsd.
Hpos_polar().end(); hnum != hnume; ++hnum ) {
852 Size const don_h_atom( *hnum );
853 if ( polar_atomno == don_h_atom ) {
860 HBEvalTuple const hbe_type( don_chem_type, acc_chem_type, seq_sep );
864 occ_rsd.
atom( occ_rsd.
abase2( occ_atomno ) ).
xyz(), hb_ener);
866 if ( hb_ener < 0. ) {
878 polar_group_hb_energy += hb_ener;
881 occ_atom_is_Hbonded =
true;
893 core::Vector const translated_occ_atom_xyz = orig_occ_atom_xyz + translation_vector;
894 core::Vector const transformed_occ_atom_xyz = transformation_matrix * ( orig_occ_atom_xyz + translation_vector );
897 assert( std::abs(orig_polar_atom_xyz.distance( orig_occ_atom_xyz ) - transformed_occ_atom_xyz.magnitude()) < 0.001 );
898 assert( std::abs(orig_base_atom_xyz.distance( orig_occ_atom_xyz ) - new_base_atom_location.distance( transformed_occ_atom_xyz )) < 0.001 );
903 water_position.x() += grid_info.
xstep();
904 core::Real sq_xdist = ( water_position.x() - transformed_occ_atom_xyz.x() ) * ( water_position.x() - transformed_occ_atom_xyz.x() );
905 if ( sq_xdist > sq_dist_cut )
continue;
906 water_position.y() = grid_info.
yorigin();
908 water_position.y() += grid_info.
ystep();
909 core::Real sq_ydist = ( water_position.y() - transformed_occ_atom_xyz.y() ) * ( water_position.y() - transformed_occ_atom_xyz.y() );
910 if ( sq_ydist > sq_dist_cut )
continue;
911 water_position.z() = grid_info.
zorigin();
913 water_position.z() += grid_info.
zstep();
914 core::Real sq_zdist = ( water_position.z() - transformed_occ_atom_xyz.z() ) * ( water_position.z() - transformed_occ_atom_xyz.z() );
915 if ( sq_zdist > sq_dist_cut )
continue;
916 core::Real sq_curr_dist = sq_xdist + sq_ydist + sq_zdist;
917 if ( sq_curr_dist < sq_dist_cut ) {
935 core::Real const curr_water_weight = water_weights[tx][ty][tz];
936 sum_occluded_weights += curr_water_weight;
943 core::Real geometric_solvation_energy = -
geosol_kT * log( 1 - ( sum_occluded_weights / grid_constant ) );
950 if ( polar_group_is_acceptor ) {
954 switch( acc_chem_type) {
956 geometric_solvation_energy -= 0.775088;
957 desired_hb_weight = geometric_solvation_energy *0.72908;
960 geometric_solvation_energy -= 0.775088;
961 desired_hb_weight = geometric_solvation_energy *0.94358;
964 geometric_solvation_energy -=0.32359;
965 desired_hb_weight = geometric_solvation_energy *0.83315;
968 geometric_solvation_energy -= 1.07342;
969 desired_hb_weight = geometric_solvation_energy *0.64448;
972 geometric_solvation_energy -= 1.67093;
973 desired_hb_weight = geometric_solvation_energy *1.0758;
976 geometric_solvation_energy -= 0.681323;
977 desired_hb_weight = geometric_solvation_energy *0.97637;
980 geometric_solvation_energy -= 0.752036;
981 desired_hb_weight = geometric_solvation_energy *1.2094;
984 std::cout <<
"Chemical acceptor type not found: " << acc_chem_type << std::endl;
989 if (polar_group_is_donor ) {
993 switch (don_chem_type ) {
995 geometric_solvation_energy -= 1.56141;
996 desired_hb_weight = geometric_solvation_energy *0.59343;
999 geometric_solvation_energy -= 0.4999125;
1000 desired_hb_weight = geometric_solvation_energy*.8906;
1003 geometric_solvation_energy -=0.957797;
1004 desired_hb_weight = geometric_solvation_energy *0.90386;
1007 geometric_solvation_energy -= 0.591156;
1008 desired_hb_weight = geometric_solvation_energy *0.9971;
1011 geometric_solvation_energy -=0.854121;
1012 desired_hb_weight = geometric_solvation_energy *0.97701;
1015 geometric_solvation_energy -= 0.33501;
1016 desired_hb_weight = geometric_solvation_energy*1.5641;
1019 geometric_solvation_energy -= 0.981806;
1020 desired_hb_weight = geometric_solvation_energy *0.8612;
1023 geometric_solvation_energy -=0.538248;
1024 desired_hb_weight = geometric_solvation_energy *1.142;
1027 geometric_solvation_energy -= 0.681433;
1028 desired_hb_weight = geometric_solvation_energy *1.1076;
1031 geometric_solvation_energy -= 0.785331;
1032 desired_hb_weight = geometric_solvation_energy *1.1066;
1035 std::cout <<
"Chemical donor type not found: " << don_chem_type << std::endl;
1044 if ( geometric_solvation_energy > 0 ) {
1045 if ( polar_group_is_acceptor ) {
1049 switch( acc_chem_type) {
1051 geometric_solvation_energy -= 0.624376;
1052 desired_hb_weight = geometric_solvation_energy *0.72832;
1055 geometric_solvation_energy -= 0.427747;
1056 desired_hb_weight = geometric_solvation_energy *0.89874;
1059 geometric_solvation_energy -= 0.286873;
1060 desired_hb_weight = geometric_solvation_energy *0.82413;
1063 geometric_solvation_energy -= 0.725837;
1064 desired_hb_weight = geometric_solvation_energy *0.85228;
1067 geometric_solvation_energy -= 0.690253;
1068 desired_hb_weight = geometric_solvation_energy *0.91419;
1071 geometric_solvation_energy -= 0.64312;
1072 desired_hb_weight = geometric_solvation_energy *1.0239;
1075 geometric_solvation_energy -= 0.713553;
1076 desired_hb_weight = geometric_solvation_energy *1.0076;
1079 std::cout <<
"Chemical acceptor type not found: " << acc_chem_type << std::endl;
1084 if (polar_group_is_donor ) {
1088 switch (don_chem_type ) {
1090 geometric_solvation_energy -= 0.794341;
1091 desired_hb_weight = geometric_solvation_energy *0.606;
1094 geometric_solvation_energy -= 0.294998;
1095 desired_hb_weight = geometric_solvation_energy*1.0568;
1098 geometric_solvation_energy -= 0.426234;
1099 desired_hb_weight = geometric_solvation_energy *0.82543;
1102 geometric_solvation_energy -= 0.297841;
1103 desired_hb_weight = geometric_solvation_energy *1.1028;
1106 geometric_solvation_energy -= 0.5463725;
1107 desired_hb_weight = geometric_solvation_energy *0.98083;
1110 geometric_solvation_energy -= 0.1029515;
1111 desired_hb_weight = geometric_solvation_energy*1.727;
1114 geometric_solvation_energy -= 0.2953195;
1115 desired_hb_weight = geometric_solvation_energy *0.83017;
1118 geometric_solvation_energy -= 0.22389;
1119 desired_hb_weight = geometric_solvation_energy *1.5544;
1122 geometric_solvation_energy -= 0.494319;
1123 desired_hb_weight = geometric_solvation_energy *0.98647;
1126 geometric_solvation_energy -= 0.451273;
1127 desired_hb_weight = geometric_solvation_energy *1.1331;
1130 std::cout <<
"Chemical donor type not found: " << don_chem_type << std::endl;
1141 geometric_solvation_energy = geometric_solvation_energy + (desired_hb_weight*polar_group_hb_energy );
1142 return geometric_solvation_energy;
1192 core::Real const Ebulk_weight = ( sum_water_weights * Emax_weight ) / ( 1. - Emax_weight);
1195 core::Real const grid_constant = sum_water_weights + Ebulk_weight;
1197 return grid_constant;