25 #include <utility/tag/Tag.hh>
29 #include <numeric/xyzVector.hh>
58 #include <utility/exit.hh>
67 #include <basic/options/option.hh>
68 #include <basic/options/keys/packing.OptionKeys.gen.hh>
69 #include <basic/options/keys/hotspot.OptionKeys.gen.hh>
70 #include <basic/Tracer.hh>
76 #include <boost/foreach.hpp>
79 #include <utility/vector0.hh>
80 #include <utility/vector1.hh>
88 #define foreach BOOST_FOREACH
90 using namespace core::scoring;
91 using namespace protocols::protein_interface_design;
93 static basic::Tracer
TR(
"protocols.protein_interface_design.movers.PlaceSimultaneouslyMover" );
96 namespace protein_interface_design {
99 using namespace protocols::moves;
100 using namespace core;
103 PlaceSimultaneouslyMoverCreator::keyname()
const
105 return PlaceSimultaneouslyMoverCreator::mover_name();
109 PlaceSimultaneouslyMoverCreator::create_mover()
const {
114 PlaceSimultaneouslyMoverCreator::mover_name()
116 return "PlaceSimultaneously";
119 PlaceSimultaneouslyMover::~PlaceSimultaneouslyMover() {
136 if( before_min >= -0.0001 ){
137 TR<<
"bb_cst evalutes to 0. Failing";
143 MinimizeInterface( pose, stub_scorefxn, no_min, no_min, min_rb(), optimize_foldtree(), no_targets,
true);
151 using namespace protocols::hotspot_hashing;
152 using namespace core::scoring::constraints;
156 core::Size const num_csts_before_min( csts_before_min.size() );
164 for(
core::Size repeat( 1 ); repeat<=minimization_steps; ++repeat ){
166 using namespace core::scoring;
169 core::Real const bb_cst_weight( curr.second );
170 TR<<
"applying mover: "<<curr_mover->get_name()<<
'\n';
172 curr_mover->prevent_repacking( prevent_repacking() );
173 curr_mover->optimize_foldtree(
false );
174 curr_mover->design(
false );
175 TR<<
" design and repacking during stub minimization is prevented\n";
176 TR<<
"using weight: "<<bb_cst_weight<<
" for the stub bb constraints\n";
177 TR<<
"and 1.0 for coordinate constraints"<<std::endl;
178 ScoreFunctionOP minimize_mover_scorefxn_repack( curr_mover->scorefxn_repack() );
179 if( minimize_mover_scorefxn_repack )
181 ScoreFunctionOP minimize_mover_scorefxn_minimize( curr_mover->scorefxn_minimize() );
182 if( minimize_mover_scorefxn_minimize )
184 curr_mover->apply( pose );
189 core::Size const pos( stubset_pos_pair.second.second );
191 targets.push_back( pos );
192 sc_min[ pos ] =
true;
195 using namespace core::scoring;
200 MinimizeInterface( pose, stub_scorefxn, no_min, sc_min, min_rb(), optimize_foldtree(), targets,
true );
204 for(
core::Size i( host_chain_begin ); i<=host_chain_end; ++i ) min_host[ i ] =
true;
206 MinimizeInterface( pose, score12_mod, min_host, sc_min, no_min_rb, optimize_foldtree(), targets,
true );
207 TR<<
"Doing rb minimization towards the stub and sc minimization of placed stubs" <<std::endl;
208 MinimizeInterface( pose, stub_scorefxn, no_min, sc_min, min_rb(), optimize_foldtree(), targets,
true );
213 core::Size const num_csts_after_min( csts_after_min.size() );
214 TR<<
"Csts before min "<<num_csts_before_min<<
" after min "<<num_csts_after_min<<std::endl;
215 runtime_assert( num_csts_after_min == num_csts_before_min );
225 using namespace protocols::hotspot_hashing;
226 using namespace core::pack::task;
228 residue_level_tasks_for_placed_hotspots_->clear();
230 *residue_level_tasks_for_placed_hotspots_ = *(task_factory());
232 core::Size const pos( stubset_pos.second.second );
233 runtime_assert( pos );
235 using namespace core::pack::task::operation;
240 if( hs_set_curr != hs_set )
continue;
243 allowed_aas[ hs_stub_curr->residue()->type().aa() ] =
true;
247 residue_level_tasks_for_placed_hotspots_->push_back( rac_op );
248 residue_level_tasks_for_placed_hotspots_->push_back( re_op );
250 PackerTaskOP task = residue_level_tasks_for_placed_hotspots_->create_task_and_apply_taskoperations( pose );
266 using namespace protocols::hotspot_hashing;
268 TR<<
"Calling auction"<<std::endl;
269 auction_->stub_sets( stub_sets_ );
270 auction_->apply( pose );
273 TR<<
"Auction failed => PlaceSimultaneously failing.\n";
276 stub_sets_ = auction_->stub_sets();
280 foreach(
StubSetStubPos const stubset_pos_pair, auction_->stub_sets() ){
281 core::Size const pos( stubset_pos_pair.second.second );
282 targets.push_back( pos );
283 sc_min[ pos ] =
true;
288 prev_pack.insert( prev_pack.begin(), targets.begin(), targets.end() );
289 std::sort( prev_pack.begin(), prev_pack.end() );
290 std::unique( prev_pack.begin(), prev_pack.end() );
291 prevent_repacking( prev_pack );
293 using namespace core::pack;
294 using namespace core::pack::task;
295 PackerTaskOP task = create_task_for_hotspot_packing( pose );
299 if( std::find( targets.begin(), targets.end(), i ) == targets.end() )
300 task->nonconst_residue_task(i).prevent_repacking();
302 using namespace core::scoring;
305 using namespace core::scoring;
307 MinimizeInterface( pose, stub_scorefxn, no_min, sc_min, min_rb(), optimize_foldtree(), targets,
true );
310 using namespace core::scoring;
311 core::Size const pos( stubset_pos_pair.second.second );
314 using namespace protocols::filters;
316 bool const pass_tot_energy( total_energy_filter.
apply( pose ) );
319 bool const pass_stub_set_filter( modified_filter->apply( pose ) );
321 if( distance >= max_cb_cb_dist_ || !pass_tot_energy || !pass_stub_set_filter ){
322 TR<<
"Failed stub filters and/or distance cutoff\n";
326 bool const after_placement_pass( after_placement_filter_->apply( pose ) );
327 if( !after_placement_pass ){
328 TR<<
"Failed after_placement_filter\n";
333 core::Size const position( hs_set.second.second );
334 TR<<
"Paired position "<<position<<
'\n';
344 using namespace protocols::hotspot_hashing;
350 core::Size const res_num( hs_set.second.second );
353 using namespace core::chemical;
355 if( res_num < chain_end )
357 if( res_num > chain_begin )
360 if( res_num > chain_begin )
365 bool const pass( after_placement_filter_->apply( pose ) );
374 saved_coord_constraints_ = pose.
add_constraints( saved_coord_constraints_ );
375 if( coord_sdev < 0.0001 ){
376 TR<<
"no coordinate constraints applied\n";
380 using namespace protocols::hotspot_hashing;
383 core::Size const position( hs_set.second.second );
387 TR<<
"applied coordinate constraints\n";
395 using namespace protocols::hotspot_hashing;
396 TR<<
"redesigning remainder of interface with user defined design movers\n";
398 BuildAlaPose toAla( host_chain_ == 1, host_chain_ == 2 );
400 if( !prevent_repacking().empty() ) no_repack = prevent_repacking();
401 if( !no_repack.empty() ){
402 std::sort( no_repack.begin(), no_repack.end() );
403 std::unique( no_repack.begin(), no_repack.end() );
406 toAla.
task_factory( residue_level_tasks_for_placed_hotspots_ );
407 TR<<
"switching interface to alanine\n";
411 foreach(
MoverRealPair const mover_coord_cst, design_movers_ ){
412 core::Real const sdev( mover_coord_cst.second );
414 TR<<
"applying design mover "<<mover->get_name()<<
'\n';
417 refresh_coordinate_constraints( pose, sdev );
419 TR.Debug<<
"before refreshing coord cst "<<before_refresh<<
" constraints. after: "<<after_refresh<<std::endl;
422 TR<<
"no constraints applied\n";
425 mover->prevent_repacking( prevent_repacking() );
426 using namespace core::pack::task;
427 mover->task_factory( residue_level_tasks_for_placed_hotspots_ );
428 mover->optimize_foldtree(
false );
429 TR<<
"setting coordinate constraint weights to 1.0 in design movers\n";
434 mover->apply( pose );
436 TR.Debug<<
"before applying design mover "<<before_apply_design_mover<<
" constraints. After: "<<after_apply_design_mover<<std::endl;
437 if( before_apply_design_mover != after_apply_design_mover ){
438 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;
439 runtime_assert( before_apply_design_mover != after_apply_design_mover );
441 TR<<
"removing coordinate constraints\n";
451 using namespace protocols::hotspot_hashing;
453 bool const stub_score_filter_pass( stub_score_filter_->apply( pose ) );
454 if( !stub_score_filter_pass ){
455 TR<<
"Stub score filter reported failure at the beginning of PlaceSimultaneously. Failing"<<std::endl;
461 saved_stub_sets_ = stub_sets_;
464 bbcst_scorefxn->reset();
466 (*bbcst_scorefxn)( pose );
468 rbstub_minimization_->apply( pose );
469 minimize_all( pose, minimization_repeats_before_placement_ );
470 bool const pairing( pair_sets_with_positions( pose ) );
472 TR<<
"Failed to pair sets with individual scaffold positions"<<std::endl;
473 final_cleanup( pose );
478 minimize_all( pose, minimization_repeats_after_placement_ );
487 PlaceSimultaneouslyMover::get_name()
const {
488 return PlaceSimultaneouslyMoverCreator::mover_name();
497 prevent_repacking_.
clear();
498 restrict_to_repacking_.clear();
499 saved_bb_constraints_.clear();
500 stub_sets_ = saved_stub_sets_;
509 PlaceSimultaneouslyMover::parse_my_tag(
TagPtr const tag,
515 using namespace protocols::hotspot_hashing;
516 using namespace protocols::filters;
517 using namespace core::pack::task;
519 TR<<
"Parsing PlaceSimultaneouslyMover----"<<std::endl;
522 auction_->parse_my_tag( tag, data, filters, movers, pose );
523 rbstub_minimization_->parse_my_tag( tag, data, filters, movers, pose );
524 stub_score_filter_->parse_my_tag( tag, data, filters, movers, pose );
526 if( tag->hasOption(
"task_operations" ) ){
528 TR<<
"*****WARNING: ERASING existing task_factory, b/c of specifications for new task operations in\n"<<tag<<std::endl;
532 host_chain_ = tag->getOption<
core::Size>(
"chain_to_design", 2 );
533 optimize_foldtree( tag->getOption<
bool >(
"optimize_fold_tree", 1 ) );
534 TR<<
"optimize_foldtree set to: "<<optimize_foldtree()<<std::endl;
536 repack_non_ala_ = tag->getOption<
bool>(
"repack_non_ala", 1 );
539 std::string const after_placement_filter_name( tag->getOption<
std::string>(
"after_placement_filter",
"true_filter" ) );
540 Filters_map::const_iterator ap_filter( filters.find( after_placement_filter_name ) );
541 if( after_placement_filter_name ==
"true_filter" )
544 after_placement_filter_ = ap_filter->second->
clone();
548 foreach(
TagPtr const btag, branch_tags ){
549 if( btag->getName() ==
"StubMinimize" ){
550 minimization_repeats_before_placement_ = btag->getOption<
core::Size >(
"min_repeats_before_placement", 0 );
551 minimization_repeats_after_placement_ = btag->getOption<
core::Size >(
"min_repeats_after_placement", 1 );
553 foreach(
TagPtr stub_m_tag, stub_min_tags ){
555 core::Real const bb_stub_constraint_weight( stub_m_tag->getOption<
core::Real > (
"bb_cst_weight", 10.0 ) );
556 std::map< std::string const, MoverOP >::const_iterator find_mover( movers.find( stub_mover_name ));
557 bool const stub_mover_found( find_mover != movers.end() );
558 if( stub_mover_found ){
561 TR<<
"dynamic cast failed in tag "<<tag<<
". Make sure that the mover is derived from DesignRepackMover"<<std::endl;
562 runtime_assert( drSOP );
564 minimization_movers_.push_back( std::make_pair( drSOP, bb_stub_constraint_weight) );
565 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';
569 else if( btag->getName() ==
"DesignMovers" ){
571 foreach(
TagPtr const m_tag_ptr, design_tags ){
573 bool const apply_coord_constraints( m_tag_ptr->getOption<
bool >(
"use_constraints", 1 ) );
576 std::map< std::string const, MoverOP >::const_iterator find_mover( movers.find( mover_name ));
577 bool const mover_found( find_mover != movers.end() );
581 TR<<
"dynamic cast failed in tag "<<tag<<
". Make sure that the mover is derived from DesignRepackMover"<<std::endl;
582 runtime_assert( drOP );
584 design_movers_.push_back( std::make_pair( drOP, ( apply_coord_constraints ? coord_cst_std : -1 ) ) );
585 TR<<
"added design mover "<<mover_name<<
" to place simultaneously ";
586 if( apply_coord_constraints )
587 TR<<
"with with std "<< coord_cst_std<<
'\n';
589 TR<<
"with no coord cst\n";
592 TR<<
"***WARNING WARNING! Mover defined for PlaceSimultaneouslyMoverMover not found in mover_list. EXITING ***"<<std::endl;
593 runtime_assert( mover_found );
597 else if( btag->getName() ==
"StubSets" ){
599 explosion_ = btag->getOption<
core::Size >(
"explosion", 0 );
600 stub_energy_threshold_ = btag->getOption<
core::Real>(
"stub_energy_threshold", 1.0 );
601 max_cb_cb_dist_ = btag->getOption<
core::Real >(
"max_cb_dist", 3.0 );
604 foreach(
TagPtr const stubset_tag, stubset_tags ){
607 if( data.
has(
"hotspot_library", stub_fname ) ){
609 TR<<
"Associated mover with an already read stubset named "<<stub_fname<<std::endl;
612 stubset->read_data( stub_fname );
614 stub_sets_.push_back(std::make_pair(stubset, std::make_pair(
new HotspotStub(), 0)));
618 task->initialize_from_command_line().or_include_current(
true );
623 core::Size const chain_begin( ala_pose->conformation().chain_begin( host_chain_ ) );
624 core::Size const chain_end( ala_pose->conformation().chain_end( host_chain_ ) );
628 if( i >= chain_begin && i <=chain_end ) {
629 core::Size const restype( ala_pose->residue(i).aa() );
631 task->nonconst_residue_task(i).prevent_repacking();
633 task->nonconst_residue_task(i).restrict_absent_canonical_aas( allowed_aas );
636 task->nonconst_residue_task( i ).prevent_repacking();
639 if( basic::options::option[basic::options::OptionKeys::packing::resfile].user() )
644 (*scorefxn)( *ala_pose );
646 std::string const stub_set_filter_name( stubset_tag->getOption<
std::string >(
"filter_name",
"true_filter" ) );
647 Filters_map::const_iterator stub_set_filter( filters.find( stub_set_filter_name ) );
648 runtime_assert( stub_set_filter != filters.end() );
649 stub_set_filters_[ stubset ] = stub_set_filter->second->clone();
652 else if( btag->getName() !=
"NotifyMovers" )
653 utility_exit_with_message(
"ERROR: tag in PlaceSimultaneouslyMover not defined\n" );
656 if( minimization_movers_.size() == 0 )
657 TR<<
"No StubMinimize movers defined by user, defaulting to minimize_rb and _sc of stubs only\n";
659 auction_->task_factory( data.
get<
TaskFactory * >(
"TaskFactory",
"placement" ) );
660 rbstub_minimization_->task_factory( data.
get<
TaskFactory * >(
"TaskFactory",
"placement" ) );
663 TR<<
"Using "<<minimization_repeats_before_placement_<<
" minimization steps before placement (bbcst constraints on)\n";
664 TR<<
"Using "<<minimization_repeats_after_placement_<<
" minimization steps after placement (no constraints on)\n";
665 TR<<
"max cb cb distance set to "<<max_cb_cb_dist_<<
'\n';
666 TR<<
"place simultaneously mover on chain "<<host_chain_<<
" with repack_non_ala set to "<<repack_non_ala_<<std::endl;
669 PlaceSimultaneouslyMover::PlaceSimultaneouslyMover() :