44 #include <basic/Tracer.hh>
47 #include <utility/vector1.hh>
53 #include <ObjexxFCL/format.hh>
59 #include <utility/vector0.hh>
60 #include <boost/lexical_cast.hpp>
67 using ObjexxFCL::fmt::I;
68 using ObjexxFCL::fmt::F;
70 using namespace core::scoring;
72 static basic::Tracer
TR(
"protocols.protein_interface_design.design_utils" );
74 using namespace protocols::protein_interface_design;
85 using namespace core::scoring;
89 ScoreTypeVec score_types;
93 if( weights[ st ] != 0 ) score_types.push_back( st );
97 for(ScoreTypeVec::const_iterator it=score_types.begin(); it!=score_types.end(); ++it ) {
100 return( residue_total);
106 using namespace core::scoring;
128 if( restype1 != restype2 ) {
132 res_name1_.insert( std::make_pair( i, pose1.
residue(i).
name3() ));
133 res_name2_.insert( std::make_pair( i, pose2.
residue(i).
name3() ));
139 ReportSequenceDifferences::report( std::ostream & out )
const
141 std::map< Size, core::Real >::const_iterator it_energy1=res_energy1_.begin();
142 std::map< Size, core::Real >::const_iterator it_energy2=res_energy2_.begin();
143 std::map< Size, std::string >::const_iterator it_name1=res_name1_.begin();
144 std::map< Size, std::string >::const_iterator it_name2=res_name2_.begin();
146 if( it_energy1 == res_energy1_.end() ) {
150 else { out <<res_energy1_.size()<<
" changes:\n"; }
152 while( it_energy1!=res_energy1_.end() ) {
153 TR<<it_name1->second<<it_name1->first<<
" "<<it_energy1->second<<
'\t'<<
154 it_name2->second<<it_name2->first<<
" "<<it_energy2->second<<std::endl;
155 ++it_energy1; ++it_energy2; ++it_name1; ++it_name2;
170 ddG_val = ddG_val / cycles;
178 allowed_aas[ mutation ] =
true;
183 task->nonconst_residue_task(i).restrict_absent_canonical_aas( allowed_aas );
185 task->nonconst_residue_task(i).prevent_repacking();
193 using namespace core::scoring;
200 TR<<
"Averaging all ddg calculations over "<<ddg_cycles_<<
" iterations\n";
202 TR<<
"average ddG for design: "<<ddG_des_val<<
'\n';
204 (*scorefxn_wt)(pose_wt);
205 (*scorefxn_des)(pose_des);
208 seq_diff.calculate( pose_wt, pose_des );
209 typedef std::map< core::Size, core::Real> EnMap;
210 EnMap
const *energy_map2( seq_diff.get_res_energy( 2 ));
212 std::vector< int > revert_positions;
213 std::vector< int > ala_positions;
214 core::Size count_changes_orig( 0 ), count_changes_revert( 0 );
217 bool first_pass_ignored(
true ), first_pass_done(
true );
218 for( EnMap::const_iterator it2 = energy_map2->begin(); it2!=energy_map2->end(); ++it2 ) {
219 using boost::lexical_cast;
226 TR<<
"ddG change "<<ddG_revert_val-ddG_des_val<<
". ";
227 pose_des = saved_des;
228 if( ddG_revert_val <= ddG_des_val + ddg_tolerance_ ) {
230 if( first_pass_done )
231 first_pass_done =
false;
234 done_resids += lexical_cast<
string >( seqpos );
235 revert_positions.push_back( seqpos );
236 ++count_changes_orig;
240 ++count_changes_revert; ++count_changes_orig;
241 if( first_pass_ignored )
242 first_pass_ignored =
false;
244 ignored_resids +=
"+";
245 ignored_resids += lexical_cast<
string >( seqpos );
247 if( it2->second > 0 ) {
248 TR<<
"but the total energy for "<<pose_des.
residue(seqpos).
name3()<<seqpos<<
" is "<<it2->second<<
" testing an Ala substitution\n";
249 TR<<
"mutation "<<pose_des.
residue(seqpos).
name3()<<seqpos<<
"->ALA has ddG ";
252 TR << ddG_ala<<
" and will be ";
253 if( ddG_ala <= ddG_des_val ) {
255 ala_positions.push_back( seqpos );
257 else {
TR<<
"ignored\n"; }
261 pose_des = saved_des;
262 for( std::vector<int>::const_iterator it_rev=revert_positions.begin(); it_rev!=revert_positions.end(); ++it_rev ) {
265 for( std::vector<int>::const_iterator it_ala=ala_positions.begin(); it_ala!=ala_positions.end(); ++it_ala ) {
269 TR<<
"Starting ddG "<<ddG_des_val<<
" final ddG "<< ddG_all_changes<<
"\n";
270 TR<<
"Sequences changes in design: "<<count_changes_orig<<
". Sequence changes in reversion: "<<count_changes_revert<<
'\n';
271 TR<<
"Ignored residues: \n"<<ignored_resids<<
'\n';
272 TR<<
"Done residues: \n"<<done_resids<<
'\n';
282 native_residue_bonus_.push_back( native_residue_bonus );
284 add_residue_constraints( pose );
292 native_residue_bonus_.push_back( native_residue_bonus[i] );
294 add_residue_constraints( pose );
301 using namespace core::id;
302 using namespace core::conformation;
303 using namespace core::scoring::constraints;
313 FavorNonNativeResidue::FavorNonNativeResidue(
Pose & pose,
core::Real const non_native_residue_bonus )
317 non_native_residue_bonus_.push_back( non_native_residue_bonus );
319 add_residue_constraints( pose );
327 non_native_residue_bonus_.push_back( non_native_residue_bonus[i] );
329 add_residue_constraints( pose );
335 FavorNonNativeResidue::add_residue_constraints(
pose::Pose & pose )
const {
336 using namespace core::id;
337 using namespace core::conformation;
338 using namespace core::scoring::constraints;
359 bool const optimize_foldtree,
361 bool const simultaneous_minimization )
363 using namespace optimization;
365 runtime_assert( min_rb.size() == pose.
num_jump() );
368 runtime_assert( min_bb.size() == nres );
369 runtime_assert( min_sc.size() == nres );
370 runtime_assert( min_rb.size() == pose.
num_jump() );
375 if( optimize_foldtree && target_residues.size() > 0 ) {
377 core::Size central_residue( *target_residues.begin() );
386 mean_distance += res1.
xyz( res1.nbr_atom() ).
distance( res2.xyz( res2.nbr_atom() ) ) ;
388 if( mean_distance<=min_mean_dist ) {
389 central_residue = *res_it1;
390 min_mean_dist = mean_distance;
408 runtime_assert( nearest_res );
413 core::Size const jump_pos1( central_res_in_chain1 ? central_residue : nearest_res );
414 core::Size const jump_pos2( central_res_in_chain1 ? nearest_res : central_residue );
416 new_ft.
add_edge( jump_pos1, jump_pos2, rb_jump );
423 TR<<
"setting fold_tree for minimization between "<<jump_pos1<<
" and "<<jump_pos2<<
"\n";
427 TR<<
"Fold tree not optimized in minimize interface.\n"<<pose.
fold_tree()<<std::endl;
431 TR<<
"minimizing sc of residues: ";
434 mm.set_chi( i, min_sc[ i ] );
439 if( !simultaneous_minimization )
440 AtomTreeMinimizer().run( pose, mm, *scorefxn,
441 MinimizerOptions(
"dfpmin_armijo_nonmonotone", 0.01,
true,
false ) );
444 mm.set_jump( rb_jump, min_rb[ rb_jump ] );
445 if( !simultaneous_minimization && std::find( min_rb.begin(), min_rb.end(), true ) != min_rb.end() ){
446 TR<<
"minimizing rigid body orientation\n";
447 AtomTreeMinimizer().run( pose, mm, *scorefxn,
448 MinimizerOptions(
"dfpmin_armijo_nonmonotone", 0.01,
true,
false ) );
451 if( !simultaneous_minimization )
452 TR<<
"minimizing bb of residues (and sc of the previous subset): ";
455 mm.set_bb( i, min_bb[ i ] );
456 mm.set_chi( i, min_sc[ i ] );
460 TR<<
"\nAnd now minimizing all dofs together\n";
461 AtomTreeMinimizer().run( pose, mm, *scorefxn,
462 MinimizerOptions(
"dfpmin_armijo_nonmonotone", 0.01,
true,
false ) );
478 bool const simultaneous_minimization )
480 using namespace optimization;
481 using namespace conformation::symmetry;
488 TR<<
"minimizing sc of residues: ";
491 mm.set_chi( i, min_sc[ i ] );
498 if( !simultaneous_minimization )
500 MinimizerOptions(
"dfpmin_armijo_nonmonotone", 0.01,
true,
false ) );
505 if ( min_rb.size() > 0 ) {
506 TR<<
"minimizing rigid body orientation\n";
507 TR<<
"By default all dofs in the symmetry input are used!!!Should change?\n";
509 MinimizerOptions(
"dfpmin_armijo_nonmonotone", 0.01,
true,
false ) );
512 if( !simultaneous_minimization )
513 TR<<
"minimizing bb of residues (and sc of the previous subset): ";
516 mm.set_bb( i, min_bb[ i ] );
517 mm.set_chi( i, min_sc[ i ] );
521 TR<<
"\nAnd now minimizing all dofs together\n";
524 MinimizerOptions(
"dfpmin_armijo_nonmonotone", 0.01,
true,
false ) );
528 std::list< core::Size >
530 Pose const & in_pose,
core::Size const target_residue, std::set< core::Size >
const & binders,
531 bool const bb,
bool const sc,
core::Real const energy_thres,
bool const bb_bb )
534 using namespace core::scoring::hbonds;
536 std::list< core::Size > hbonded_list;
538 Pose pose( in_pose );
543 HBondDatabaseCOP hb_database( HBondDatabase::get_database( background_hbond_set.hbond_options().params_database_tag()));
546 TR <<
"decomposing bb hydrogen bond terms" << std::endl;
548 energy_options->hbond_options().decompose_bb_hb_into_pair_energies(
true);
549 scorefxn->set_energy_method_options(*energy_options);
555 for ( std::set< core::Size >::const_iterator binder_it=binders.begin(); binder_it!=binders.end(); ++binder_it ) {
559 if (
distance > distance_cutoff )
continue;
564 resi, resj, background_hbond_set.nbrs(resi.seqpos()), background_hbond_set.nbrs(resj.seqpos()),
566 !bb, !sc, !sc, !sc, pair_hbond_set);
569 resj, resi, background_hbond_set.nbrs(resj.seqpos()), background_hbond_set.nbrs(resi.seqpos()),
571 !bb, !sc, !sc, !sc, pair_hbond_set);
583 core::Real total_hbond_energy( hbond_emap.sum() );
590 if( total_hbond_energy <= energy_thres ) {
591 using namespace core::conformation;
593 using namespace core::scoring::hbonds;
594 HBond const & hb( pair_hbond_set.
hbond( i ) );
596 if( !bb && ( hb.don_hatm_is_protein_backbone() && hb.acc_atm_is_protein_backbone() ) )
continue;
597 if( !sc && ( !hb.don_hatm_is_protein_backbone() || !hb.acc_atm_is_protein_backbone() ) )
continue;
599 core::Size const don_res_i( hb.don_res() ), acc_res_i( hb.acc_res() );
601 acc_rsd( pose.
residue( acc_res_i ) );
602 if( (don_rsd.seqpos() == *binder_it && acc_rsd.seqpos() == target_residue) ||
603 ( don_rsd.seqpos() == target_residue && acc_rsd.seqpos() == *binder_it ) ){
604 hbonded_list.push_back( *binder_it );
606 TR << I( width, target_residue )
607 << I( width, *binder_it )
608 <<
A( width, resi.name1() )
609 <<
A( width, resj.name1() )
612 << F( width, 3, hbond_emap[
hbond_sc ] )
620 return( hbonded_list );