37 #include <numeric/random/random.hh>
56 #include <basic/Tracer.hh>
57 #include <utility/exit.hh>
58 #include <utility/stream_util.hh>
59 #include <utility/string_util.hh>
60 #include <basic/MetricValue.hh>
64 namespace pose_metric_calculators {
69 using namespace basic;
72 using namespace conformation;
73 using namespace chemical;
74 using namespace kinematics;
75 using namespace scoring;
76 using namespace options;
77 using namespace basic::options::OptionKeys;
78 using namespace optimization;
81 static basic::Tracer
TR(
"protocols.toolbox.PoseMetricCalculators.ExplicitWaterUnsatisfiedPolarsCalculator");
82 static numeric::random::RandomGenerator
RG(2718);
86 scorefxn_( scorefxn ),
88 all_unsat_polars_( 0 )
95 ExplicitWaterUnsatisfiedPolarsCalculator::ExplicitWaterUnsatisfiedPolarsCalculator(
ScoreFunctionOP scorefxn,
Real shell_cutoff ):
96 scorefxn_( scorefxn ),
97 shell_cutoff_( shell_cutoff ),
98 all_unsat_polars_( 0 )
107 void ExplicitWaterUnsatisfiedPolarsCalculator::lookup(
std::string const & key, basic::MetricValueBase * valptr )
const{
108 if ( key ==
"all_unsat_polars" ) {
109 basic::check_cast( valptr, &all_unsat_polars_,
"all_unsat_polars expects to return a Size" );
110 (
static_cast<basic::MetricValue<Size> *
>(valptr))->set( all_unsat_polars_ );
112 basic::Error() <<
"ExplicitWaterUnsatisfiedPolarsCalculator cannot compute the requested metric " << key << std::endl;
119 if ( key ==
"all_unsat_polars" ) {
120 return utility::to_string( all_unsat_polars_ );
122 basic::Error() <<
"ExplicitWaterUnsatisfiedPolarsCalculator cannot compute metric " << key << std::endl;
146 Jump jump( pose.
jump( jump_number ) );
149 Real jump_dist( dist_min +
RG.uniform() * ( dist_max - dist_min ) );
150 jump.random_trans( jump_dist );
174 Size const max_attempt_per_atom( 20 );
175 Size const max_wat_per_atom( 5 );
179 for(
Size i = 1; i <= max_attempt_per_atom; ++i ){
180 if( n_wat >= max_wat_per_atom )
break;
188 for(
Size i = 1; i <= 10; ++i ){
189 Jump jump( pose.
jump( jump_number ) );
190 jump.gaussian_move( 1, 0.05, 90.0 );
192 mc_dock->boltzmann( pose );
194 mc_dock->recover_low( pose );
196 if( mc_create->boltzmann( pose ) ){
200 min_mover->apply( pose );
204 mc_create->recover_low( pose );
215 using namespace core::scoring::hbonds;
221 for(
Size i = 1; i <= hbset.nhbonds(); ++i ){
222 HBond hb( hbset.hbond( i ) );
223 if( hb.don_res() == seqpos ){
224 Size don_atm( rsd.atom_base( hb.don_hatm() ) );
225 n_atom_hbonds[ don_atm ] += 1;
227 else if( hb.acc_res() == seqpos ){
228 n_atom_hbonds[ hb.acc_atm() ] += 1;
232 for(
Size atm = 1; atm <= rsd.nheavyatoms(); ++atm ){
233 if( !( rsd.atom_type( atm ).is_acceptor() || rsd.atom_type( atm ).is_donor() ) )
continue;
235 if( n_atom_hbonds[ atm ] == 0 ){
236 atm_is_unsat[ atm ] =
true;
continue;
240 std::string atom_type( rsd.type().atom_type( atm ).name() );
241 Size satisfac_cut = 3;
242 if( atom_type ==
"OH" || atom_type ==
"OCbb" || atom_type ==
"S" ){
245 Size bonded_heavyatoms = rsd.n_bonded_neighbor_all_res( atm )
246 - rsd.type().number_bonded_hydrogens( atm );
247 if( bonded_heavyatoms + n_atom_hbonds[ atm ] < satisfac_cut ){
248 atm_is_unsat[ atm ] =
true;
254 void ExplicitWaterUnsatisfiedPolarsCalculator::recompute(
core::pose::Pose const & pose_in ){
256 all_unsat_polars_ = 0;
262 Pose pose( pose_in );
270 Real min_dist( 1.5 );
274 Real fa_sol_wt( scorefxn->get_weight(
fa_sol ) );
275 scorefxn->set_weight(
fa_sol, 0.0 );
278 for ( chemical::AtomIndices::const_iterator hnum = rsd.Hpos_polar().begin(),
279 hnume = rsd.Hpos_polar().end(); hnum != hnume; ++hnum ) {
280 Size const iatom( *hnum );
281 if( !atm_is_unsat[ iatom ] )
continue;
283 dock_waters_to_atom( pose, scorefxn, seqpos, iatom, *wat_rsd, 1, min_dist, shell_cutoff_ );
286 for ( chemical::AtomIndices::const_iterator anum = rsd.accpt_pos().begin(),
287 anume = rsd.accpt_pos().end(); anum != anume; ++anum ){
288 Size const iatom( *anum );
289 if( !atm_is_unsat[ iatom ] )
continue;
291 dock_waters_to_atom( pose, scorefxn, seqpos, iatom, *wat_rsd, 1, min_dist, shell_cutoff_ );
296 for(
Size iatom = 1; iatom <= atm_is_unsat.size(); ++iatom ){
297 if( atm_is_unsat[ iatom ] ) ++all_unsat_polars_;