71 #include <basic/Tracer.hh>
72 #include <utility/exit.hh>
73 #include <utility/stream_util.hh>
74 #include <utility/string_util.hh>
75 #include <basic/MetricValue.hh>
81 #include <utility/vector1.hh>
82 #include <numeric/constants.hh>
87 using namespace core::pose;
88 using namespace core::pose::metrics;
91 using utility::to_string;
92 using numeric::constants::f::pi;
93 using numeric::constants::f::pi_2;
95 static basic::Tracer
TR(
"protocols.toolbox.PoseMetricCalculators.SemiExplicitWaterUnsatisfiedPolarsCalculator");
99 namespace pose_metric_calculators {
101 SemiExplicitWaterUnsatisfiedPolarsCalculator::SemiExplicitWaterUnsatisfiedPolarsCalculator(
105 ) : hb_database_( core::scoring::hbonds::HBondDatabase::get_database(
"standard_params" ) ),
106 all_unsat_polars_( 0 ),
107 special_region_unsat_polars_(0),
108 semiexpl_water_cutoff_( semiexpl_water_cutoff ),
109 name_of_hbond_calc_( hbond_calc ),
110 scorefxn_( scorefxn )
124 std::set< core::Size >
const & special_region,
126 ) : hb_database_( core::scoring::hbonds::HBondDatabase::get_database(
"standard_params" ) ),
127 all_unsat_polars_(0),
128 special_region_unsat_polars_(0),
129 semiexpl_water_cutoff_( semiexpl_water_cutoff ),
130 name_of_hbond_calc_( hbond_calc ),
131 scorefxn_( scorefxn ),
132 special_region_( special_region )
158 basic::MetricValueBase * valptr
162 if ( key ==
"all_unsat_polars" ) {
163 basic::check_cast( valptr, &
all_unsat_polars_,
"all_unsat_polars expects to return a Size" );
166 }
else if ( key ==
"special_region_unsat_polars" ) {
170 }
else if ( key ==
"atom_unsat" ) {
171 basic::check_cast( valptr, &
atom_unsat_,
"atom_unsat expects to return a id::AtomID_Map< bool >" );
172 (
static_cast<basic::MetricValue<id::AtomID_Map< bool >
> *>(valptr))->set(
atom_unsat_ );
174 }
else if ( key ==
"atom_semiexpl_score" ) {
175 basic::check_cast( valptr, &
atom_semiexpl_score_,
"atom_semiexpl_score expects to return a id::AtomID_Map< Real >" );
176 (
static_cast<basic::MetricValue<id::AtomID_Map< Real >
> *>(valptr))->set(
atom_semiexpl_score_ );
178 }
else if ( key ==
"residue_unsat_polars" ) {
179 basic::check_cast( valptr, &
residue_unsat_polars_,
"residue_unsat_polars expects to return a utility::vector1< Size >" );
180 (
static_cast<basic::MetricValue<utility::vector1< Size >
> *>(valptr))->set(
residue_unsat_polars_ );
182 }
else if ( key ==
"residue_semiexpl_score" ) {
183 basic::check_cast( valptr, &
residue_semiexpl_score_,
"residue_semiexpl_score expects to return a utility::vector1< Real >" );
187 basic::Error() <<
"SemiExplicitWaterUnsatisfiedPolarsCalculator cannot compute the requested metric " << key << std::endl;
199 if ( key ==
"all_unsat_polars" ) {
201 }
else if ( key ==
"special_region_unsat_polars" ) {
203 }
else if ( key ==
"atom_Hbonds" ) {
204 basic::Error() <<
"id::AtomID_Map< bool > has no output operator, for metric " << key << std::endl;
206 }
else if ( key ==
"residue_unsat_polars" ) {
210 basic::Error() <<
"SemiExplicitWaterUnsatisfiedPolarsCalculator cannot compute metric " << key << std::endl;
223 Real const clash_dist_cut
226 Real const clash_dist2_cut( clash_dist_cut * clash_dist_cut );
227 for(
Size iatid = 1; iatid <= check_atids.size(); ++iatid ){
228 Vector const at1_xyz( pose.
xyz( check_atids[ iatid ] ) );
235 bool skip_at2(
false );
236 for(
Size jatid = 1; jatid <= check_atids.size(); ++jatid ){
237 if( atid2 == check_atids[ jatid ] ){ skip_at2 =
true;
break; }
239 if( skip_at2 )
continue;
240 Real const dist2( at1_xyz.distance_squared( pose.
xyz( atid2 ) ) );
241 if( dist2 < clash_dist2_cut ){
265 using namespace conformation;
266 using namespace scoring;
267 using namespace scoring::hbonds;
268 using namespace kinematics;
271 Pose ref_pose( pose );
283 Jump jump( pose.
jump( jump_number ) );
286 for(
Size iat = 1; iat <= new_rsd.
natoms(); ++iat ){
287 clash_check_atids.push_back(
id::AtomID( iat, new_seqpos ) );
291 Size aatm( 0 ), acc_pos( 0 ), hatm( 0 ), don_pos( 0 );
292 bool wat_is_acc(
false );
294 if( rsd.atom_type( atomno ).is_polar_hydrogen() &&
298 acc_pos = new_seqpos;
304 rsd.atom_type( atomno ).is_acceptor() ){
305 don_pos = new_seqpos;
310 else{ utility_exit_with_message(
"ERROR: res " + to_string( seqpos ) +
" atom " + to_string( atomno ) +
311 " res " + to_string( new_seqpos ) +
" atom " + to_string( new_atomno ) +
" is not HB don/acc pair!!\n" );
333 f_rot.new_chemical_bond( seqpos, new_seqpos, rsd.atom_name( atomno ), new_rsd.
atom_name( new_atomno ), pose.
total_residue() - 2 );
336 Size water_hb_states_tot( 0 );
337 Size water_hb_states_good( 0 );
347 Real BAHang_min( pi - std::acos(
MIN_xH ) ), BAHang_max( pi - std::acos(
MAX_xH ) );
Size BAHang_steps( 5 );
348 Real AHDang_min( pi - std::acos(
MIN_xD ) ), AHDang_max( pi - std::acos(
MAX_xD ) );
Size AHDang_steps( 5 );
350 Real B2BAHchi_min( 0 ), B2BAHchi_max( pi_2 );
Size B2BAHchi_steps( 10 );
351 Real BAHDchi_min( 0 ), BAHDchi_max( pi_2 );
Size BAHDchi_steps( 3 );
353 for(
Real AHdist = AHdist_min; AHdist <= AHdist_max;
354 AHdist += (AHdist_max - AHdist_min)/static_cast<Real>(AHdist_steps-1)){
359 for(
Real BAHang = BAHang_min - 0.0001; BAHang <= BAHang_max;
360 BAHang += (BAHang_max - BAHang_min)/static_cast<Real>(BAHang_steps-1)){
361 for(
Real AHDang = AHDang_min - .0001; AHDang <= AHDang_max;
362 AHDang += (AHDang_max - AHDang_min)/static_cast<Real>(AHDang_steps-1)){
364 for(
Real B2BAHchi = B2BAHchi_min; B2BAHchi <= B2BAHchi_max;
365 B2BAHchi += (B2BAHchi_max - B2BAHchi_min)/static_cast<Real>(B2BAHchi_steps-1)){
366 for(
Real BAHDchi = BAHDchi_min; BAHDchi <= BAHDchi_max;
367 BAHDchi += (BAHDchi_max - BAHDchi_min)/static_cast<Real>(BAHDchi_steps-1)){
371 Real cosBAH( std::cos( pi - BAHang ) );
372 Real cosAHD( std::cos( pi - AHDang ) );
377 Real hb_energy( 0.0 );
379 scorefxn->energy_method_options().hbond_options(),
380 hbe_type, AHdist, cosAHD, cosBAH, B2BAHchi, hb_energy );
382 if( hb_energy >= 0.0 )
continue;
384 ++water_hb_states_tot;
445 scorefxn->score( pose );
450 if( wat_score <= 0.0 ){
451 ++water_hb_states_good;
465 return ( static_cast< Real >( water_hb_states_good ) /
466 static_cast< Real >( water_hb_states_tot ) );
493 basic::MetricValue< id::AtomID_Map< Size > > atom_hbonds_dry;
506 bool this_atom_unsat(
false);
520 Size n_hbonds_needed( satisfac_cut - bonded_heavyatoms );
523 Size n_atom_hbonds( atom_hbonds_dry.value()[ atid ] );
524 if( n_atom_hbonds >= n_hbonds_needed ){
530 Real semiexpl_water_score( 0.0 );
535 pose, scorefxn, i,
at, *wat_rsd, wat_H1_at );
537 " semiexpl_wat_score: " << semiexpl_water_score << std::endl;
539 n_atom_hbonds += n_hbonds_needed;
551 pose, scorefxn, i, h_at, *wat_rsd, wat_O_at ) / n_bonded_H );
554 " semiexpl_wat_score: " << semiexpl_water_score << std::endl;
556 n_atom_hbonds += n_hbonds_needed;
567 if( n_atom_hbonds < n_hbonds_needed ){
571 this_atom_unsat =
true;
592 if( atom_type ==
"OH" )
return 2;
595 else if (atom_type ==
"OCbb")
return 2;
597 else if( atom_type ==
"S")
return 2;