Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PlaceSimultaneouslyMover.cc
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 sw=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/protein_interface_design/movers/PlaceSimultaneouslyMover.cc
11 /// @brief
12 /// @author Sarel Fleishman (sarelf@u.washington.edu)
13 
14 // Unit headers
17 
18 // Package headers
21 
22 // Project Headers
23 #include <core/types.hh>
24 #include <core/pose/Pose.hh>
25 #include <utility/tag/Tag.hh>
27 #include <core/id/AtomID.hh>
28 #include <core/chemical/AA.hh>
29 #include <numeric/xyzVector.hh>
31 
33 
38 //#include <core/pack/rotamer_trials.hh>
40 
44 
45 //#include <protocols/docking/DockingProtocol.hh>
46 #include <protocols/moves/Mover.hh>
48 //#include <protocols/moves/ResidueMover.hh>
53 #include <protocols/moves/ResId.hh>
55 
56 
57 // Utility Headers
58 #include <utility/exit.hh>
59 
60 // Unit Headers
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>
71 
72 // C++ headers
73 #include <map>
74 #include <algorithm>
75 #include <utility>
76 #include <boost/foreach.hpp>
77 
78 #include <core/pose/util.hh>
79 #include <utility/vector0.hh>
80 #include <utility/vector1.hh>
81 
82 //Auto Headers
86 
87 
88 #define foreach BOOST_FOREACH
89 
90 using namespace core::scoring;
91 using namespace protocols::protein_interface_design;
92 
93 static basic::Tracer TR( "protocols.protein_interface_design.movers.PlaceSimultaneouslyMover" );
94 
95 namespace protocols {
96 namespace protein_interface_design {
97 namespace movers {
98 
99 using namespace protocols::moves;
100 using namespace core;
101 
103 PlaceSimultaneouslyMoverCreator::keyname() const
104 {
105  return PlaceSimultaneouslyMoverCreator::mover_name();
106 }
107 
109 PlaceSimultaneouslyMoverCreator::create_mover() const {
110  return new PlaceSimultaneouslyMover;
111 }
112 
114 PlaceSimultaneouslyMoverCreator::mover_name()
115 {
116  return "PlaceSimultaneously";
117 }
118 
119 PlaceSimultaneouslyMover::~PlaceSimultaneouslyMover() {
120 }
121 
124  return( protocols::moves::MoverOP( new PlaceSimultaneouslyMover( *this ) ) );
125 }
126 
127 
128 /// @details preliminary rb minimization step in the presence of strong hotspot constraints. Reports failure
129 /// if pre-minimization bb_cst score is 0. Note that setting up constraints should be done outside
130 bool
131 PlaceSimultaneouslyMover::minimize_no_bb( core::pose::Pose & pose ) const {
132 
134  simple_filters::ScoreTypeFilter const stf( stub_scorefxn, backbone_stub_constraint, 1.0 );
135  core::Real const before_min( stf.compute( pose ) );
136  if( before_min >= -0.0001 ){
137  TR<<"bb_cst evalutes to 0. Failing";
138  return false;
139  }
140  //for minimization (rb and sc of previous placed stubs)
141  utility::vector1< bool > const no_min( pose.total_residue(), false );
143  MinimizeInterface( pose, stub_scorefxn, no_min/*bb*/, no_min/*sc_min*/, min_rb()/*rb*/, optimize_foldtree(), no_targets, true/*simultaneous optimization*/);
144  return( true );
145 }
146 
147 /// @details wraps around user-defined minimization movers. Note that setting up constraints should be done
148 /// outside this method.
149 void
150 PlaceSimultaneouslyMover::minimize_all( core::pose::Pose & pose, core::Size const minimization_steps ) const{
151  using namespace protocols::hotspot_hashing;
152  using namespace core::scoring::constraints;
153 
155  ConstraintCOPs const csts_before_min = pose.constraint_set()->get_all_constraints();
156  core::Size const num_csts_before_min( csts_before_min.size() );
157 
158  //core::Size fixed_res(1);
159  //if( host_chain_ == 1 ) fixed_res = pose.total_residue(); // set but never used ~Labonte
160  // core::id::AtomID const fixed_atom_id = core::id::AtomID( pose.residue(fixed_res).atom_index("CA"), fixed_res ); // Unused variable causes a warning.
161 
163 
164  for( core::Size repeat( 1 ); repeat<=minimization_steps; ++repeat ){
165  foreach( MoverRealPair const curr, minimization_movers_ ){
166  using namespace core::scoring;
167 
168  simple_moves::DesignRepackMoverOP const curr_mover( curr.first );
169  core::Real const bb_cst_weight( curr.second );
170  TR<<"applying mover: "<<curr_mover->get_name()<<'\n';
171  //restricting movers for stub minimization
172  curr_mover->prevent_repacking( prevent_repacking() );
173  curr_mover->optimize_foldtree( false );
174  curr_mover->design( false ); //we dont want any design to take place within any mover for stub minimization
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 )
180  minimize_mover_scorefxn_repack->set_weight( backbone_stub_constraint, bb_cst_weight );
181  ScoreFunctionOP minimize_mover_scorefxn_minimize( curr_mover->scorefxn_minimize() );
182  if( minimize_mover_scorefxn_minimize )
183  minimize_mover_scorefxn_minimize->set_weight( backbone_stub_constraint, bb_cst_weight );
184  curr_mover->apply( pose );
185  utility::vector1< bool > sc_min( pose.total_residue(), false );
186  utility::vector1< bool > const no_min( pose.total_residue(), false );
188  foreach( StubSetStubPos const stubset_pos_pair, stub_sets_ ){
189  core::Size const pos( stubset_pos_pair.second.second );
190  if( pos!=0 ){
191  targets.push_back( pos );
192  sc_min[ pos ] = true;
193  }
194  }//foreach stubset_pos_pair
195  using namespace core::scoring;
196  ScoreFunctionCOP stub_scorefxn( make_stub_scorefxn() );
198  score12_mod->set_weight( backbone_stub_constraint, 10.0 ); //This will not have any effect if the bbcsts are off
199  score12_mod->set_weight( coordinate_constraint, 1.0 );//similarly
200  MinimizeInterface( pose, stub_scorefxn, no_min/*bb*/, sc_min, min_rb()/*rb*/, optimize_foldtree(), targets, true/*simultaneous optimization*/ );
201  utility::vector1< bool > min_host( pose.total_residue(), false );
202  core::Size const host_chain_begin( pose.conformation().chain_begin( host_chain_ ) );
203  core::Size const host_chain_end ( pose.conformation().chain_end( host_chain_ ) );
204  for( core::Size i( host_chain_begin ); i<=host_chain_end; ++i ) min_host[ i ] = true;
205  utility::vector1< bool > const no_min_rb( pose.num_jump(), false );
206  MinimizeInterface( pose, score12_mod, min_host/*bb*/, sc_min, no_min_rb/*rb*/, optimize_foldtree(), targets, true/*simultaneous optimization*/ );
207  TR<<"Doing rb minimization towards the stub and sc minimization of placed stubs" <<std::endl;
208  MinimizeInterface( pose, stub_scorefxn, no_min/*bb*/, sc_min, min_rb()/*rb*/, optimize_foldtree(), targets, true/*simultaneous optimization*/ );
209  }//foreach minimization mover
210  }//repeat
211 
212  ConstraintCOPs const csts_after_min = pose.constraint_set()->get_all_constraints();
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 );//constraints shouldnt have changed
216 }
217 
218 /// @details setup the residue level tasks for each of the paired positions in stub_sets_. This sets the explosion
219 /// level as well as the allowed identities at each position
220 /// Note that two things happen in this function: 1) the task is modified to reflect the rotamer explosion operations.
221 /// 2) residue_level_tasks_for_placed_hotspots_ is updated with these operations
223 PlaceSimultaneouslyMover::create_task_for_hotspot_packing( core::pose::Pose const & pose )
224 {
225  using namespace protocols::hotspot_hashing;
226  using namespace core::pack::task;
227 
228  residue_level_tasks_for_placed_hotspots_->clear();
229  if( task_factory() )
230  *residue_level_tasks_for_placed_hotspots_ = *(task_factory()); // this will allow PlaceStub's TaskAware paragraph to affect what is happening here, including trickling down to design movers
231  foreach( StubSetStubPos const stubset_pos, stub_sets_ ){
232  core::Size const pos( stubset_pos.second.second );
233  runtime_assert( pos );
234  HotspotStubSetCOP hs_set = stubset_pos.first;
235  using namespace core::pack::task::operation;
236  RotamerExplosionOP re_op = new RotamerExplosion( pos, EX_THREE_THIRD_STEP_STDDEVS, explosion_ );
238  foreach( ResidueAuctionItem const item, auction_->auction_results() ){
239  HotspotStubSetCOP hs_set_curr( item.second.second.first );
240  if( hs_set_curr != hs_set ) continue;
241  HotspotStubCOP hs_stub_curr( item.second.second.second );
242  chemical::ResidueType const type( hs_stub_curr->residue()->type() );
243  allowed_aas[ hs_stub_curr->residue()->type().aa() ] = true;
244  }//foreach item in auction_->auction_results()
245  RestrictAbsentCanonicalAASOP rac_op = new RestrictAbsentCanonicalAAS( pos, allowed_aas );
246 
247  residue_level_tasks_for_placed_hotspots_->push_back( rac_op );
248  residue_level_tasks_for_placed_hotspots_->push_back( re_op );
249  }//foreach stubset_pos
250  PackerTaskOP task = residue_level_tasks_for_placed_hotspots_->create_task_and_apply_taskoperations( pose );
251  return( task );
252 }
253 
254 /// @details positions on the scaffold are auctioned to hotspot stub sets. The stubset that has a stub with the
255 /// lowest constraint energy with respect to that position wins the auction. If the number of positions that are
256 /// paired is less than the number of hotspot families, then failure is reported.
257 /// If pairing succeeds, each of the paired positions is allowed to adopt an identity from its parent stubset
258 /// that has below 0 constraint energy. Following which pack_rotamers is called with ex1, ex2, and rotamer explosion
259 /// if directed by the user.
260 /// Finally, each placed hotspot is tested for its total energy and for a user-defined filter. If one of these
261 /// filters fails, failure is reported.
262 /// Note that residues other than the lowest constraint energy identities might emerge from this process.
263 bool
264 PlaceSimultaneouslyMover::pair_sets_with_positions( core::pose::Pose & pose )
265 {
266  using namespace protocols::hotspot_hashing;
267 
268  TR<<"Calling auction"<<std::endl;
269  auction_->stub_sets( stub_sets_ );
270  auction_->apply( pose );
271  protocols::moves::MoverStatus const auction_stat( auction_->get_last_move_status() );
272  if( auction_stat != protocols::moves::MS_SUCCESS ){
273  TR<<"Auction failed => PlaceSimultaneously failing.\n";
274  return( false );
275  }
276  stub_sets_ = auction_->stub_sets();//copying the pairings information
277  utility::vector1< bool > sc_min( pose.total_residue(), false );
278  utility::vector1< bool > const no_min( pose.total_residue(), false );
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;
284  }//foreach stubset_pos_pair
285 
286  {//add to the prevent repacking
287  utility::vector1< core::Size > prev_pack( prevent_repacking() );
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 );
292  }//end add to prevent repacking
293  using namespace core::pack;
294  using namespace core::pack::task;
295  PackerTaskOP task = create_task_for_hotspot_packing( pose );
296 // task->/*initialize_from_command_line().*/or_include_current( true ); // we don't want rotamer explosion with ex1 ex2
297  for( core::Size i=1; i<=pose.total_residue(); ++i ){
298  if( !pose.residue(i).is_protein() ) continue;
299  if( std::find( targets.begin(), targets.end(), i ) == targets.end() )
300  task->nonconst_residue_task(i).prevent_repacking();
301  }//for residue i in pose
302  using namespace core::scoring;
304  pack_rotamers( pose, *score12, task );
305  using namespace core::scoring;
306  ScoreFunctionCOP stub_scorefxn( make_stub_scorefxn() );
307  MinimizeInterface( pose, stub_scorefxn, no_min/*bb*/, sc_min, min_rb()/*rb*/, optimize_foldtree()/*optimize foldtree*/, targets, true/*simultaneous optimization*/ );
308  foreach( StubSetStubPos & stubset_pos_pair, stub_sets_ ){
309  //filter each placed hotspot
310  using namespace core::scoring;
311  core::Size const pos( stubset_pos_pair.second.second );
312  HotspotStubSetOP stubset( stubset_pos_pair.first );
313  HotspotStubCOP stub( stubset_pos_pair.second.first );
314  using namespace protocols::filters;
315  simple_filters::EnergyPerResidueFilter total_energy_filter( pos, score12, total_score, stub_energy_threshold_ );
316  bool const pass_tot_energy( total_energy_filter.apply( pose ) );
317  protocols::filters::FilterOP modified_filter( stub_set_filters_[ stubset ]->clone() );
318  protocols::moves::modify_ResId_based_object( modified_filter, pos );
319  bool const pass_stub_set_filter( modified_filter->apply( pose ) );
320  core::Real const distance( pose.residue( pos ).xyz( "CB" ).distance( stub->residue()->xyz( "CB" ) ) );
321  if( distance >= max_cb_cb_dist_ || !pass_tot_energy || !pass_stub_set_filter ){
322  TR<<"Failed stub filters and/or distance cutoff\n";
323  return( false );
324  }
325  }
326  bool const after_placement_pass( after_placement_filter_->apply( pose ) );
327  if( !after_placement_pass ){
328  TR<<"Failed after_placement_filter\n";
329  return( false );
330  }
331 
332  foreach( StubSetStubPos const hs_set, stub_sets_ ){
333  core::Size const position( hs_set.second.second );
334  TR<<"Paired position "<<position<<'\n';
335  }
336  TR.flush();
337  return( true );
338 }
339 
340 /// @details this will be removed in the future
341 bool
342 PlaceSimultaneouslyMover::place_stubs( core::pose::Pose & pose ) const
343 {
344  using namespace protocols::hotspot_hashing;
345  core::Size const chain_begin( pose.conformation().chain_begin( host_chain_ ) );
346  core::Size const chain_end( pose.conformation().chain_end( host_chain_ ) );
347 
348  foreach( StubSetStubPos hs_set, stub_sets_ ){
349  HotspotStubCOP stub( hs_set.second.first );
350  core::Size const res_num( hs_set.second.second );
351  pose.replace_residue( res_num, *(stub->residue()), true );
352 
353  using namespace core::chemical;
354 //removing variant types can only be done if the residue would still be connected to the chain
355  if( res_num < chain_end )
357  if( res_num > chain_begin )
359  pose.conformation().update_polymeric_connection( res_num ); // o/w residues connections mess up
360  if( res_num > chain_begin )
361  pose.conformation().update_polymeric_connection( res_num - 1 );
362  }
363 
365  bool const pass( after_placement_filter_->apply( pose ) );
366  return( pass );
367 }
368 
369 /// @details removes the coordinate constraints from the pose and reapplies them individually.
370 void
371 PlaceSimultaneouslyMover::refresh_coordinate_constraints( core::pose::Pose & pose, core::Real const coord_sdev )
372 {
374  saved_coord_constraints_ = pose.add_constraints( saved_coord_constraints_ );
375  if( coord_sdev < 0.0001 ){
376  TR<<"no coordinate constraints applied\n";
377  return;
378  }
379  foreach( StubSetStubPos hs_set, stub_sets_ ){
380  using namespace protocols::hotspot_hashing;
381 
382  HotspotStubCOP stub( hs_set.second.first );
383  core::Size const position( hs_set.second.second );
385  add_coordinate_constraints( pose, *stub->residue(), host_chain_, position, coord_sdev, dummy_cst );
386  }
387  TR<<"applied coordinate constraints\n";
388 }
389 
390 /// @details wraps around the user-defined design movers. Applies coordinate constraints as specified by the user.
391 /// Prevents repacking of placed hotspots
392 void
393 PlaceSimultaneouslyMover::design( core::pose::Pose & pose )
394 {
395  using namespace protocols::hotspot_hashing;
396  TR<<"redesigning remainder of interface with user defined design movers\n";
397 
398  BuildAlaPose toAla( host_chain_ == 1/*partner1*/, host_chain_ == 2 /*partner2*/ );
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() );
404  toAla.prevent_repacking( no_repack );
405  }
406  toAla.task_factory( residue_level_tasks_for_placed_hotspots_ );
407  TR<<"switching interface to alanine\n";
408  toAla.apply( pose );
409 
410  saved_coord_constraints_ = remove_coordinate_constraints_from_pose( pose );
411  foreach( MoverRealPair const mover_coord_cst, design_movers_ ){//design movers
412  core::Real const sdev( mover_coord_cst.second );
413  simple_moves::DesignRepackMoverOP mover( mover_coord_cst.first );
414  TR<<"applying design mover "<<mover->get_name()<<'\n';
415  if( sdev >= 0 ){//use constraints
416  core::Size const before_refresh( pose.constraint_set()->get_all_constraints().size() );
417  refresh_coordinate_constraints( pose, sdev );
418  core::Size const after_refresh( pose.constraint_set()->get_all_constraints().size() );
419  TR.Debug<<"before refreshing coord cst "<<before_refresh<<" constraints. after: "<<after_refresh<<std::endl;
420  }//use constraints
421  else
422  TR<<"no constraints applied\n";
423 
424  core::Size const before_apply_design_mover( pose.constraint_set()->get_all_constraints().size() );
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";
430  core::scoring::ScoreFunctionOP scorefxn_rep( mover->scorefxn_repack() );
431  core::scoring::ScoreFunctionOP scorefxn_min( mover->scorefxn_minimize() );
432  if( scorefxn_rep ) scorefxn_rep->set_weight( coordinate_constraint, 1.0 );
433  if( scorefxn_min ) scorefxn_min->set_weight( coordinate_constraint, 1.0 );
434  mover->apply( pose );
435  core::Size const after_apply_design_mover( pose.constraint_set()->get_all_constraints().size() );
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 );
440  }
441  TR<<"removing coordinate constraints\n";
443  }//foreach Design movers
444  remove_coordinate_constraints_from_pose( pose ); // just in case
445  pose.add_constraints( saved_coord_constraints_ );
446 }
447 
448 void
449 PlaceSimultaneouslyMover::apply( core::pose::Pose & pose )
450 {
451  using namespace protocols::hotspot_hashing;
452 
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;
456  set_last_move_status( protocols::moves::FAIL_RETRY );
457  return;
458  }
459 
460  saved_pose_ = pose;
461  saved_stub_sets_ = stub_sets_;
462  // rescore the pose to ensure that backbone stub cst's are populated
464  bbcst_scorefxn->reset();
465  bbcst_scorefxn->set_weight( core::scoring::backbone_stub_constraint, 1.0 );
466  (*bbcst_scorefxn)( pose );
467 
468  rbstub_minimization_->apply( pose );
469  minimize_all( pose, minimization_repeats_before_placement_ );
470  bool const pairing( pair_sets_with_positions( pose ) );
471  if( !pairing ){
472  TR<<"Failed to pair sets with individual scaffold positions"<<std::endl;
473  final_cleanup( pose );
474  set_last_move_status( protocols::moves::FAIL_RETRY );
475  return;
476  }
478  minimize_all( pose, minimization_repeats_after_placement_ );
479  TR.flush();
480  design( pose );
481  TR<<"Design done\n";
482  TR.flush();
483  set_last_move_status( protocols::moves::MS_SUCCESS );
484 }
485 
487 PlaceSimultaneouslyMover::get_name() const {
488  return PlaceSimultaneouslyMoverCreator::mover_name();
489 }
490 
491 /// @details This should be called before failing placesimultaneously.
492 void
493 PlaceSimultaneouslyMover::final_cleanup( core::pose::Pose & pose )
494 {
495  pose = saved_pose_;
496  //don't accumulate state between ntrials
497  prevent_repacking_.clear();
498  restrict_to_repacking_.clear();
499  saved_bb_constraints_.clear();
500  stub_sets_ = saved_stub_sets_;
501  auction_->clear();
502 /// The statement below would clear task_factories of child design movers
503 // if( residue_level_tasks_for_placed_hotspots_ )
504 // residue_level_tasks_for_placed_hotspots_->clear();
505  TR.flush();
506 }
507 
508 void
509 PlaceSimultaneouslyMover::parse_my_tag( TagPtr const tag,
510  DataMap &data,
511  protocols::filters::Filters_map const &filters,
512  Movers_map const &movers,
513  core::pose::Pose const & pose )
514 {
515  using namespace protocols::hotspot_hashing;
516  using namespace protocols::filters;
517  using namespace core::pack::task;
518 
519  TR<<"Parsing PlaceSimultaneouslyMover----"<<std::endl;
520 /// auction, rbstub_minimization, and stub_score_filter are different, private
521 /// instantiations and should parse the stubset, chain, etc. information
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 );
525 
526  if( tag->hasOption( "task_operations" ) ){
527  if( task_factory() )
528  TR<<"*****WARNING: ERASING existing task_factory, b/c of specifications for new task operations in\n"<<tag<<std::endl;
529  task_factory( protocols::rosetta_scripts::parse_task_operations( tag, data ) );
530  }
531 
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;
535 
536  repack_non_ala_ = tag->getOption<bool>( "repack_non_ala", 1 );
537  min_rb( true );
538 
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" )
542  after_placement_filter_ = new protocols::filters::TrueFilter;
543  else
544  after_placement_filter_ = ap_filter->second->clone();
545  //parsing stub minimize movers and design movers for place stub
546  utility::vector0< TagPtr > const branch_tags( tag->getTags() );
547 
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 );
552  utility::vector0< TagPtr > const stub_min_tags( btag->getTags() );
553  foreach( TagPtr stub_m_tag, stub_min_tags ){
554  std::string const stub_mover_name( stub_m_tag->getOption<std::string>( "mover_name" ) );
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 ){
559  simple_moves::DesignRepackMoverOP drSOP = dynamic_cast< simple_moves::DesignRepackMover * >( find_mover->second->clone().get() );
560  if( !drSOP ){
561  TR<<"dynamic cast failed in tag "<<tag<<". Make sure that the mover is derived from DesignRepackMover"<<std::endl;
562  runtime_assert( drSOP );
563  }//done cast check
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';
566  }
567  }
568  }
569  else if( btag->getName() == "DesignMovers" ){
570  utility::vector0< TagPtr > const design_tags( btag->getTags() );
571  foreach( TagPtr const m_tag_ptr, design_tags ){
572  std::string const mover_name( m_tag_ptr->getOption< std::string >( "mover_name" ) );
573  bool const apply_coord_constraints( m_tag_ptr->getOption< bool >( "use_constraints", 1 ) );
574  core::Real const coord_cst_std( m_tag_ptr->getOption< core::Real >( "coord_cst_std", 0.5 ) );
575 
576  std::map< std::string const, MoverOP >::const_iterator find_mover( movers.find( mover_name ));
577  bool const mover_found( find_mover != movers.end() );
578  if( mover_found ){
579  simple_moves::DesignRepackMoverOP drOP = dynamic_cast< simple_moves::DesignRepackMover * >( find_mover->second.get() );
580  if( !drOP ){
581  TR<<"dynamic cast failed in tag "<<tag<<". Make sure that the mover is derived from DesignRepackMover"<<std::endl;
582  runtime_assert( drOP );
583  }
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';
588  else
589  TR<<"with no coord cst\n";
590  }
591  else{
592  TR<<"***WARNING WARNING! Mover defined for PlaceSimultaneouslyMoverMover not found in mover_list. EXITING ***"<<std::endl;
593  runtime_assert( mover_found );
594  }
595  }
596  }
597  else if( btag->getName() == "StubSets" ){
598  //PlaceSimultaneously doesn't use the utility function parse_stub_sets b/c it needs to connect filters with 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 );
602 
603  utility::vector0< TagPtr > const stubset_tags( btag->getTags() );
604  foreach( TagPtr const stubset_tag, stubset_tags ){
605  std::string const stub_fname = stubset_tag->getOption< std::string >( "stubfile" );
606  HotspotStubSetOP stubset = new HotspotStubSet;
607  if( data.has( "hotspot_library", stub_fname ) ){
608  stubset = data.get< protocols::hotspot_hashing::HotspotStubSet * >( "hotspot_library", stub_fname );
609  TR<<"Associated mover with an already read stubset named "<<stub_fname<<std::endl;
610  }
611  else
612  stubset->read_data( stub_fname );
613 
614  stub_sets_.push_back(std::make_pair(stubset, std::make_pair(new HotspotStub(), 0))); // REQUIRED FOR WINDOWS
615  //stub_sets_.push_back( StubSetStubPos( stubset, std::pair< HotspotStubOP, core::Size >( 0, 0 ) ) );
616  core::pose::PoseOP ala_pose = new core::pose::Pose( pose );
618  task->initialize_from_command_line().or_include_current( true );
619 
621  allowed_aas[ chemical::aa_ala ] = true;
622 
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_ ) );
625 
626  for ( core::Size i = 1; i <= pose.total_residue(); i++) {
627  if ( !pose.residue(i).is_protein() ) continue;
628  if( i >= chain_begin && i <=chain_end ) {
629  core::Size const restype( ala_pose->residue(i).aa() );
630  if( ( restype == chemical::aa_pro && !basic::options::option[basic::options::OptionKeys::hotspot::allow_proline] ) || restype == chemical::aa_gly )
631  task->nonconst_residue_task(i).prevent_repacking();
632  else
633  task->nonconst_residue_task(i).restrict_absent_canonical_aas( allowed_aas );
634  }
635  else {
636  task->nonconst_residue_task( i ).prevent_repacking();
637  }
638  }
639  if( basic::options::option[basic::options::OptionKeys::packing::resfile].user() )
640  core::pack::task::parse_resfile(pose, *task);
641 
643  pack::pack_rotamers( *ala_pose, *scorefxn, task);
644  (*scorefxn)( *ala_pose );
645  stubset->pair_with_scaffold( *ala_pose, host_chain_, new protocols::filters::TrueFilter );
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();
650  }//foreach stubset_tag
651  }// fi stubsets
652  else if( btag->getName() != "NotifyMovers" )
653  utility_exit_with_message( "ERROR: tag in PlaceSimultaneouslyMover not defined\n" );
654  generate_taskfactory_and_add_task_awareness( btag, movers, data, task_factory() );//residue_level_tasks_for_placed_hotspots_ );
655  }
656  if( minimization_movers_.size() == 0 )
657  TR<<"No StubMinimize movers defined by user, defaulting to minimize_rb and _sc of stubs only\n";
658 
659  auction_->task_factory( data.get< TaskFactory * >( "TaskFactory", "placement" ) );
660  rbstub_minimization_->task_factory( data.get< TaskFactory * >( "TaskFactory", "placement" ) );
661 // stub_score_filter_->parse_my_tag( tag, data, filters, movers, pose );
662 // stub_score_filter_->stub_sets( stub_sets_ );
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;
667 }
668 
669 PlaceSimultaneouslyMover::PlaceSimultaneouslyMover() :
670  simple_moves::DesignRepackMover( PlaceSimultaneouslyMoverCreator::mover_name() )
671 {
672  residue_level_tasks_for_placed_hotspots_ = new core::pack::task::TaskFactory;//watch out! Never allocate a new task factory for this guy after parsing has been done, b/c in parsing all task aware movers will be watching it through their task_factory_
673 // user_defined_auction_ = false;
674 // user_defined_stub_score_filter_ = false;
675 // user_defined_bbstub_minimization_ = false;
679  stub_sets_.clear();
680  stub_set_filters_.clear();
681  host_chain_=2;
682  saved_stub_sets_.clear();
683  stub_set_filters_.clear();
684  max_cb_cb_dist_ = 3.0;
686  minimization_movers_.clear();
689  saved_bb_constraints_.clear();
690  design_movers_.clear();
691  explosion_ = 0;
692  saved_coord_constraints_.clear();
693 }
694 
695 } //movers
696 } //protein_interface_design
697 } //protocols
698