17 #include <boost/foreach.hpp>
18 #define foreach BOOST_FOREACH
21 #include <utility/tag/Tag.hh>
27 #include <numeric/xyzVector.hh>
57 #include <utility/exit.hh>
68 #include <numeric/random/random.hh>
69 #include <numeric/random/random_permutation.hh>
71 #include <basic/options/option.hh>
72 #include <basic/options/keys/packing.OptionKeys.gen.hh>
73 #include <basic/options/keys/hotspot.OptionKeys.gen.hh>
82 #include <utility/vector0.hh>
83 #include <utility/vector1.hh>
84 #include <numeric/NumericTraits.hh>
85 #include <basic/Tracer.hh>
92 using namespace core::scoring;
94 static basic::Tracer
TR(
"protocols.protein_interface_design.movers.PlaceStubMover" );
95 static basic::Tracer
stats_TR(
"STATS.PlaceStubMover" );
96 static basic::Tracer
TR_debug(
"DEBUG.PlaceStubMover" );
98 static numeric::random::RandomGenerator
RG( 10101979 );
100 namespace protocols {
101 namespace protein_interface_design {
104 using namespace protocols::moves;
105 using namespace core;
108 PlaceStubMoverCreator::keyname()
const
110 return PlaceStubMoverCreator::mover_name();
114 PlaceStubMoverCreator::create_mover()
const {
119 PlaceStubMoverCreator::mover_name()
124 PlaceStubMover::PlaceStubMover() :
126 score_threshold_( 0.0 ),
129 add_constraints_( false ),
130 after_placement_filter_( NULL ),
131 final_filter_( NULL ),
132 coord_cst_func_( NULL ),
133 default_fold_tree_( NULL ),
134 leave_coord_csts_after_placement_( false ),
135 place_scaffold_( false ),
136 max_cb_cb_dist_( 4.0 ),
138 triage_positions_( true ),
139 stub_energy_threshold_( 1.0 ),
140 residue_level_tasks_for_placed_hotspots_( NULL ),
141 residue_numbers_( NULL )
160 bool const triage_positions,
164 score_threshold_( score_threshold ),
165 host_chain_( host_chain ),
167 triage_positions_(triage_positions),
168 stub_energy_threshold_(stub_energy_threshold)
193 std::pair< core::Size, bool >
const res_cst( std::make_pair( res_num,
add_constraints_ ) );
196 using namespace core::chemical;
198 if( res_num < chain_end )
200 if( res_num > chain_begin )
203 if( res_num > chain_begin )
213 TR_debug<<
"foldtree before append: "<<partner_chain.fold_tree()<<std::endl;
214 partner_chain.append_residue_by_jump( res_stub, 1 );
215 TR_debug<<
"foldtree after append: "<<partner_chain.fold_tree()<<std::endl;
221 pose_stub_tree.
clear();
222 using namespace core::kinematics;
223 pose_stub_tree.
add_edge( 1, partner_chain.total_residue()-1, Edge::PEPTIDE );
224 pose_stub_tree.
add_edge( 1, partner_chain.total_residue(), rb_jump );
225 pose_stub_tree.
set_jump_atoms( rb_jump, partner_chain.residue( 1 ).atom_type( partner_chain.residue( 1 ).nbr_atom()).element(),
"CB" );
226 partner_chain.fold_tree( pose_stub_tree );
227 TR_debug<<
"pose stub tree: "<<partner_chain.fold_tree()<<std::endl;
238 new_ft.add_edge( jump_pos1, jump_pos2, rb_jump );
240 if( jump_pos2 > host_chain_begin )
242 if( jump_pos2 < host_chain_end )
243 new_ft.add_edge( jump_pos2, pose.
total_residue(), kinematics::Edge::PEPTIDE );
246 new_ft.delete_self_edges();
247 TR_debug<<
"pose fold tree before imposing new jump "<<pose.
fold_tree()<<std::endl;
249 TR_debug<<
"pose fold tree after imposing new jump "<<pose.
fold_tree()<<std::endl;
271 using namespace core::scoring::constraints;
273 core::Size const num_csts_before_min( csts_before_min.size() );
275 using namespace core::scoring;
279 TR <<
"Speeding up StubMinimize..." << std::endl;
280 stub_scorefxn->reset();
282 stub_scorefxn->set_weight(
fa_rep, 0.44 );
283 stub_scorefxn->set_weight(
fa_dun, 0.56 );
287 else {stub_scorefxn->set_weight(
fa_atr, 0.01 );
289 stub_scorefxn->set_weight(
fa_sol, 0.01 );
290 stub_scorefxn->set_weight(
fa_pair, 0.01 );
294 stub_scorefxn->set_weight(
hbond_sc, 0.01 );
297 using namespace protocols::hotspot_hashing;
299 if( stub() != NULL ){
300 runtime_assert( host_residue );
304 TR_debug<<
"Not minimizing towards this stub, b/c of large orientational discrepancy\n";
311 TR<<
"making single-stub based constraint\n";
313 core::Real const bonus( stub->bonus_value() );
315 core::Real const cb_force( std::max( std::min( 10.0, -bonus / (distance * distance) - 0.05 ), 0.05 ) );
316 TR <<
"Cb force: "<<cb_force<<std::endl;
320 stub_constraints.push_back(
new BackboneStubConstraint( pose, host_residue, fixed_atom_id, host_res, bonus, cb_force ) );
326 using namespace core::scoring::constraints;
328 for(
core::Size resi=host_chain_begin; resi<=host_chain_end; ++resi )
330 stub_task->nonconst_residue_task( resi ).prevent_repacking();
331 TR<<
"adding multiple stub constraints to pose\n";
332 stub_set_->add_hotspot_constraints_to_pose( pose, fixed_atom_id, stub_task,
stub_set_, 0.7, 0,
false, 10.0,
true );
333 (*stub_scorefxn)(pose);
338 core::Size const constraint_num( constraints.size() );
339 TR<<
"adding "<<constraint_num<<
" stub constraints to pose"<<std::endl;
340 (*stub_scorefxn)(pose);
343 for( ConstraintCOPs::const_iterator it = constraints.begin(); it != constraints.end(); ++it ){
345 runtime_assert( cst );
347 using namespace core::scoring::constraints;
350 if( active_constraint->type() ==
"BackboneStub" ){
352 runtime_assert( bb_cst );
354 to_be_removed.push_back( *it );
357 if( !to_be_removed.empty() ){
359 TR<<
"removed "<<to_be_removed.size()<<
" constraints\n";
365 using namespace core::scoring;
368 if( !it->second ) num_rigid_jumps++;
369 if( num_rigid_jumps > 1 ){
370 TR<<
"****WARNING WARNING**** Activating chainbreak weight, implying two rigid jumps.\n";
371 TR<<
"Not fully supported by PlaceStub\n";
380 if( before_min >= -0.0001 ){
381 if( stub() != NULL ){
382 TR<<
"no bb stub constraint score even though I computed it analytically! Ask Sarel what's wrong here."<<std::endl;;
383 runtime_assert( stub() != NULL );
386 TR<<
"removing stub constraints from pose\n";
396 using namespace protocols::hotspot_hashing;
398 core::Real CB_CA_angle_before_minmize_mover(0);
401 core::Size before_apply_stub_minimize_mover(0);
404 if( stub() != NULL ){
405 before_min_distance = pose.
residue( host_residue ).
xyz(
"CB" ).distance( stub->residue()->xyz(
"CB" ) );
406 curr_bonus = stub->bonus_value();
407 before_apply_stub_minimize_mover = pose.
constraint_set()->get_all_constraints().size();
408 before_min_cb_force = -curr_bonus / (before_min_distance *before_min_distance );
411 test_res_res_aln( pose.
residue( host_residue ), *stub->residue(), C_N_angle_before_minmize_mover, CB_CA_angle_before_minmize_mover );
412 (*stub_scorefxn )( pose );
417 TR<<
"entering movers for stub minimization....\n";
419 TR<<
"performing an initial rb minimization as well as sc minimization of previously placed stubs (if present) \n";
425 TR<<
"applying mover: "<<curr_mover->get_name()<<
'\n';
428 curr_mover->optimize_foldtree(
false );
429 curr_mover->design(
false );
430 TR<<
" design and repacking during stub minimization is prevented" << std::endl;
431 TR<<
"using weight: "<<bb_cst_weight<<
" for the stub bb constraints "<<std::endl;
432 ScoreFunctionOP minimize_mover_scorefxn_repack( curr_mover->scorefxn_repack() );
433 if( minimize_mover_scorefxn_repack )
435 ScoreFunctionOP minimize_mover_scorefxn_minimize( curr_mover->scorefxn_minimize() );
436 if( minimize_mover_scorefxn_minimize )
438 curr_mover->apply( pose );
442 for(
core::Size i=host_chain_begin; i<=host_chain_end; ++i ) min_host[ i ] =
true;
444 MinimizeInterface( pose, score12, min_host, sc_min, no_min_rb,
false , no_targets,
true );
447 TR<<
"Doing rb minimization towards the stub and sc minimization of placed stubs" <<std::endl;
454 test_res_res_aln( pose.
residue( host_residue ), *(stub->residue()), C_N_angle_after_minmize_mover, CB_CA_angle_after_minmize_mover );
456 core::Real const after_min_distance( pose.
residue( host_residue ).
xyz(
"CB" ).distance( stub->residue()->xyz(
"CB" ) ) );
457 Real const pi(numeric::NumericTraits<Real>::pi());
458 core::Real const curr_bonus( stub->bonus_value() );
459 core::Real const after_min_cb_force( -curr_bonus / (after_min_distance * after_min_distance) );
460 stats_TR<<
"CB distances, before minimize movers: "<<before_min_distance<<
" and after: "<<after_min_distance<<
'\n';
461 stats_TR<<
"C_N angle alignment, before minimization: "<<( C_N_angle_before_minmize_mover *180 )/pi<<
" and after: "<<( C_N_angle_after_minmize_mover *180 )/pi<<
'\n';
462 stats_TR<<
"CB_CA angle alignment, before minimization: "<<( CB_CA_angle_before_minmize_mover *180 )/pi<<
" and after: "<<( CB_CA_angle_after_minmize_mover *180 )/pi<<
'\n';
463 stats_TR<<
"cb force, before minimization: "<<
"before entering minimize movers: "<<before_min_cb_force <<
" and after minimization: "<<after_min_cb_force<<
'\n';
466 TR_debug<<
"before applying stub minimization mover "<<before_apply_stub_minimize_mover<<
" constraints. After: "<<after_apply_stub_minimize_mover<<std::endl;
467 if( before_apply_stub_minimize_mover != after_apply_stub_minimize_mover ){
468 TR<<
" ***ERROR: stub minimization has changed the number of constraints on the pose. Before: "<< before_apply_stub_minimize_mover<<
" after: "<<after_apply_stub_minimize_mover<<
". This behaviour is unsupported."<<std::endl;
469 runtime_assert( before_apply_stub_minimize_mover != after_apply_stub_minimize_mover );
473 TR<<
"Doing rb minimization towards the stub and sc minimization of placed stubs" <<std::endl;
479 TR<<
"backbone_stub_constraint score changed from "<<before_min<<
" to "<<after_min<<
" during minimization\n";
480 TR<<
"removing hotspot constraints from pose" <<std::endl;
484 core::Size const num_csts_after_min( csts_after_min.size() );
485 TR_debug<<
"Csts before min "<<num_csts_before_min<<
" after min "<<num_csts_after_min<<std::endl;
486 runtime_assert( num_csts_after_min == num_csts_before_min );
488 TR<<
"removed all hotspot constraints\n";
490 if( after_min >= -0.0001 ){
491 TR<<
"bb stub constraint score too high. Skipping this stub\n";
501 using namespace protocols::hotspot_hashing;
508 core::Real const bonus( stub->bonus_value() );
509 TR<<
"trying stub of bonus "<<bonus<<
'\n';
512 TR<<
"failed this stub\n";
515 }
while( !accepted );
555 using namespace protocols::hotspot_hashing;
561 bbcst_scorefxn->reset();
563 (*bbcst_scorefxn)( pose );
572 if( bb_constraints_size > 0 ){
573 TR_debug<<
"removed "<<bb_constraints_size<<
" bb constraints from pose\n";
574 TR_debug<<
"before removal "<<before_removal<<
" after removal "<<after_removal<<
'\n';
592 no_repack.push_back( it->first );
594 if( !no_repack.empty() ){
595 std::sort( no_repack.begin(), no_repack.end() );
596 std::unique( no_repack.begin(), no_repack.end() );
600 TR<<
"switching interface to alanine\n";
606 if( !minimization_status ){
607 TR<<
"constraint score evaluates to 0 in this pose. Failing\n";
624 HotspotStubSet::Hs_vec::iterator stub_it(
stub_set_->begin() );
625 std::vector< core::Size > host_positions;
629 host_positions.push_back( d );
632 for(
core::Size i=host_chain_begin+1; i<=host_chain_end-1; ++i )
633 host_positions.push_back( i );
639 TR<<
"Stub selection failed" <<std::endl;
649 numeric::random::random_permutation( host_positions.begin(), host_positions.end(),
RG );
650 for( std::vector< core::Size >::const_iterator host_pos_it = host_positions.begin(); host_pos_it!=host_positions.end(); ++host_pos_it) {
651 using namespace core::conformation;
654 Residue const res_stub( *stub->residue() );
659 || ( res_host.aa() ==
chemical::aa_pro && !basic::options::option[basic::options::OptionKeys::hotspot::allow_proline] )
660 || res_host.type().name() ==
"CYD" )
677 TR_debug<<
"stub failed placement due to alignment"<<std::endl;
683 TR <<
"Trying host position " << res << std::endl;
688 stub->set_filter( rep_filter );
689 bool const self_energy_pass( stub->get_scaffold_status( res ) );
690 if( self_energy_pass ){
710 no_repack.push_back( it->first );
713 assert( std::find(no_repack.begin(), no_repack.end(), res) != no_repack.end() );
715 std::sort( no_repack.begin(), no_repack.end() );
716 std::unique( no_repack.begin(), no_repack.end() );
719 TR<<
"switching interface to alanine\n";
723 stats_TR <<
"Stub of energy "<<stub->bonus_value()
725 <<
" placed on residue "<<res
726 <<
". The distance between stub's Cb and the residue's is "
727 <<distance<<
"A. Passing rep filter"<<std::endl;
734 TR_debug <<
"DEBUG: before minimize around hs we had "<<before_min<<
" constraints. after: "<<after_min<<std::endl;
736 core::Real const dist_after_min_threshold( 2.0 );
737 core::Real const distance_after_min( res_host_after_min.xyz(
"CB" ).distance( res_stub.xyz(
"CB" ) ) );
738 stats_TR<<
"stub - host residue Cb distance after stub-based minimization is "<<distance_after_min<<std::endl;
739 if( distance_after_min >= dist_after_min_threshold ){
740 stats_TR<<
"Distance too large. failing stub\n";
748 bool const pass_after_placement( modified_after_placement_filter->apply( pose ) );
749 if( pass_after_placement )
750 stats_TR<<
"Passed after placement filter"<<std::endl;
752 stats_TR<<
"failed after placement filter"<<std::endl;
762 TR_debug <<
"DEBUG: before remove coord constraints we had "<<before_remove<<
" constraints. after: "<<after_remove<<std::endl;
766 bool const interface_energy_pass( total_energy_filter->apply( pose ) );
767 if( interface_energy_pass ){
770 bool subsequent_stub_placement_failure(
false );
771 TR<<
"redesigning remainder of interface with user defined design movers\n";
774 TR<<
"Pushing residue number "<<res<<
" to residue_numbers_ object"<<std::endl;
782 TR<<
"applying design mover "<<it->first->get_name()<<
'\n';
783 bool const use_constraints( it->second );
784 if( use_constraints ){
785 TR<<
"using coordinate constraints with sdev "<<*it_sdev<<
'\n';
789 TR_debug<<
"before refreshing coord cst "<<before_refresh<<
" constraints. after: "<<after_refresh<<std::endl;
792 TR<<
"no constraints applied\n";
795 it->first->optimize_foldtree(
false );
796 if( it->first->get_name() ==
"PlaceStub" ){
803 runtime_assert( modified_place_stub );
807 new_prev_repack.push_back( it->first );
809 modified_place_stub->prevent_repacking( new_prev_repack );
813 modified_place_stub->apply( pose );
815 stats_TR<<
"Subsequent stub placement failed. Trying another stub placement"<<std::endl;
816 subsequent_stub_placement_failure =
true;
821 TR_debug<<
"setting coordinate constraint weights to 1.0 in design movers"<<std::endl;
824 core::Real const coord_cst_weight( use_constraints ? 1 : 0 );
827 it->first->apply( pose );
831 TR_debug<<
"before applying design mover "<<before_apply_design_mover<<
" constraints. After: "<<after_apply_design_mover<<std::endl;
832 if( before_apply_design_mover != after_apply_design_mover ){
833 TR<<
"ERROR: This design mover changed the number of constraints on the pose. Before: "<< before_apply_design_mover<<
" after: "<<after_apply_design_mover<<
". This behaviour is unsupported."<<std::endl;
834 runtime_assert( before_apply_design_mover != after_apply_design_mover );
839 if( subsequent_stub_placement_failure ){
844 TR_debug<<
"before final filter "<<before_final_filter<<
" constraints"<<std::endl;
848 bool const final_filter_pass( modified_final_filter->apply( pose ) );
849 if( final_filter_pass ) {
850 stats_TR<<
"SUCCESS: Stub passed final filter and placed at position "<<res<<
". after "<<count_two_sided<<
" two sided evaluations."<< std::endl;
852 TR_debug<<
"Adding taskawareness to taskaware design movers\n";
855 using namespace core::pack::task::operation;
861 TR_debug<<
"Before adding we had "<<size_before_adding<<
" task operations. Now we have "<<size_after_adding<<std::endl;
866 TR_debug<<
"after success "<<after_success<<
" constraints"<<std::endl;
874 std::ostringstream convert;
882 job->add_string_string_pair(column_header, convert.str());
889 stats_TR<<
"Stub at position "<<res<<
" failed final filter"<<std::endl;
893 stats_TR<<
"Stub at position "<<res<<
" failed interface energy filter"<<std::endl;
896 stats_TR<<
"Stub failed self-energy filter"<<std::endl;
901 }
while( count_two_sided <= stub_set_->
size() );
902 stats_TR<<
"Stub placement failed after "<<count_two_sided<<
" two-sided_trials."<<std::endl;
920 if( crd_cst_size > 0 ){
921 TR<<
"removed "<<crd_cst_size<<
" coordinate constraints"<<std::endl;
939 TR<<
"Cleaning up after successful stubplacement, but NOT removing coordinate constraints\n";
946 if( bb_constraints_size > 0 ){
948 TR<<
"reapplied "<<bb_constraints_size<<
" bb constraints to pose"<<std::endl;
983 if( add_constraints )
989 TR<<
"Stub based atom tree: "<<pose.
fold_tree()<<std::endl;
999 using namespace protocols::hotspot_hashing;
1001 TR<<
"Parsing PlaceStubMover----"<<std::endl;
1003 if( tag->hasOption(
"name" ) ){
1008 if( tag->hasOption(
"residue_numbers_setter" ) ){
1009 std::string const residue_numbers_name( tag->getOption(
"residue_numbers", tag->getOption<
std::string >(
"residue_numbers_setter" ) ) );
1010 residue_numbers_ = protocols::moves::get_set_from_datamap< protocols::moves::DataMapObj< utility::vector1< core::Size > > >(
"residue_numbers", residue_numbers_name, data );
1013 if( tag->hasOption(
"task_operations" ) ){
1015 TR<<
"*****WARNING: ERASING existing task_factory, b/c of specifications for new task operations in\n"<<tag<<std::endl;
1020 hurry_ = tag->getOption<
bool>(
"hurry", 0 );
1024 if( tag->hasOption(
"stubfile" ) ) {
1027 if( data.
has(
"hotspot_library", stub_fname ) ){
1029 TR<<
"Associated mover with an already read stubset named "<<stub_fname<<std::endl;
1032 stub_set_->read_data( stub_fname );
1039 bool const minimize_rb( tag->getOption<
bool >(
"minimize_rb", 0 ) );
1042 std::string const after_placement_filter_name( tag->getOption<
std::string>(
"after_placement_filter",
"true_filter" ) );
1043 protocols::filters::Filters_map::const_iterator find_ap_filter( filters.find( after_placement_filter_name ));
1045 bool const ap_filter_found( find_ap_filter != filters.end() );
1046 if( ap_filter_found )
1049 if( after_placement_filter_name !=
"true_filter" ){
1050 TR<<
"***WARNING WARNING! Filter defined for PlaceStubMover not found in filter_list!!!! Defaulting to truefilter***"<<std::endl;
1051 runtime_assert( ap_filter_found );
1058 protocols::filters::Filters_map::const_iterator find_filter( filters.find( final_filter_name ));
1060 bool const filter_found( find_filter != filters.end() );
1064 if( final_filter_name !=
"true_filter" ){
1065 TR<<
"***WARNING WARNING! Filter defined for PlaceStubMover not found in filter_list!!!! Defaulting to truefilter***"<<std::endl;
1066 runtime_assert( filter_found );
1074 if( tag->hasOption(
"allowed_host_res") ) {
1077 tag,
"allowed_host_res", pose ));
1083 for(
Size host_pos( host_chain_begin); host_pos <= host_chain_end; ++host_pos )
1085 if( std::find( allowed_host_pos.begin(), allowed_host_pos.end(), host_pos)
1086 == allowed_host_pos.end() )
1093 <<
" of "<<host_chain_end - host_chain_begin + 1
1094 <<
" host positions."<<std::endl;
1100 if( (*btag)->getName() ==
"StubMinimize" ){
1104 core::Real const bb_stub_constraint_weight( (*stub_m_tag)->getOption<
core::Real > (
"bb_cst_weight", 10.0 ) );
1105 std::map< std::string const, MoverOP >::const_iterator find_mover( movers.find( stub_mover_name ));
1106 bool const stub_mover_found( find_mover != movers.end() );
1107 if( stub_mover_found ){
1110 TR<<
"dynamic cast failed in tag "<<tag<<
". Make sure that the mover is derived from DesignRepackMover"<<std::endl;
1111 runtime_assert( drSOP );
1114 TR<<
"added stub minimize mover "<<stub_mover_name<<
" to minimize towards the stub. Using this weight for the bb stub constraints: "<< bb_stub_constraint_weight<<
'\n';
1118 else if( (*btag)->getName() ==
"DesignMovers" ){
1121 TagPtr const m_tag_ptr = *m_it;
1123 bool const apply_coord_constraints( m_tag_ptr->getOption<
bool >(
"use_constraints", 1 ) );
1126 std::map< std::string const, MoverOP >::const_iterator find_mover( movers.find( mover_name ));
1127 bool const mover_found( find_mover != movers.end() );
1131 TR<<
"dynamic cast failed in tag "<<tag<<
". Make sure that the mover is derived from DesignRepackMover"<<std::endl;
1132 runtime_assert( drOP );
1134 design_movers_.push_back( std::make_pair( drOP, apply_coord_constraints ) );
1136 TR<<
"added design mover "<<mover_name<<
" to place stub with apply_coord_constraints switched to "<< apply_coord_constraints<<
" with std "<< coord_cst_std<<
" and hurry=" <<
hurry_ <<
'\n';
1139 TR<<
"***WARNING WARNING! Mover defined for PlaceStubMover not found in mover_list. EXITING ***"<<std::endl;
1140 runtime_assert( mover_found );
1144 else if( (*btag)->getName() !=
"NotifyMovers" )
1145 utility_exit_with_message(
"ERROR: tag in PlaceStub not defined\n" );
1149 TR<<
"No StubMinimize movers defined by user, defaulting to minimize_rb and _sc of stubs only\n";
1163 task->initialize_from_command_line().or_include_current(
true );
1173 if( i >= chain_begin && i <=chain_end ) {
1174 core::Size const restype( ala_pose->residue(i).aa() );
1176 task->nonconst_residue_task(i).prevent_repacking();
1178 task->nonconst_residue_task(i).restrict_absent_canonical_aas( allowed_aas );
1181 task->nonconst_residue_task( i ).prevent_repacking();
1184 if( basic::options::option[basic::options::OptionKeys::packing::resfile].user() )
1189 (*scorefxn)( *ala_pose );
1197 TR<<
"leaving constraints on after successful placement\n";
1203 TR<<
"place stub mover on chain "<<
host_chain_<<
" with score threshold of "<<
score_threshold_<<
" minimize_rb to "<<minimize_rb<<
" final filter "<<final_filter_name<<
" and place scaffold="<<
place_scaffold_<<std::endl;