Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ClassicRelax.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 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 relax_protocols
11 /// @brief protocols that are specific to relax
12 /// @detailed
13 /// @author Mike Tyka, Monica Berrondo
14 
15 
17 
18 // AUTO-REMOVED #include <core/chemical/ResidueTypeSet.hh>
19 #include <core/scoring/rms_util.hh>
25 // AUTO-REMOVED #include <core/conformation/ResidueFactory.hh>
26 
27 #include <core/io/pdb/pose_io.hh>
28 
29 #include <core/pose/Pose.hh>
30 #include <core/pose/util.hh>
32 #include <basic/datacache/BasicDataCache.hh>
33 #include <basic/Tracer.hh>
34 
45 
46 // Symmetry
48 // AUTO-REMOVED #include <core/conformation/symmetry/util.hh>
49 
55 #include <basic/options/keys/symmetry.OptionKeys.gen.hh>
56 
58 // AUTO-REMOVED #include <protocols/loops/Loops.hh>
60 #include <basic/options/option.hh>
61 #include <basic/options/keys/relax.OptionKeys.gen.hh>
62 #include <basic/options/keys/in.OptionKeys.gen.hh>
63 #include <basic/options/keys/run.OptionKeys.gen.hh>
64 #include <basic/datacache/DiagnosticData.hh>
67 
68 
69 // ObjexxFCL Headers
70 #include <ObjexxFCL/string.functions.hh>
71 
72 #include <utility/vector0.hh>
73 #include <utility/vector1.hh>
74 
75 
76 #ifdef BOINC_GRAPHICS
77 #include <protocols/boinc/boinc.hh>
78 #endif
79 
80 
81 //#include <utility/io/mpistream.hh>
82 
83 using basic::T;
84 using basic::Error;
85 using basic::Warning;
86 
87 static basic::Tracer TR("protocols.relax.ClassicRelax");
88 
89 using namespace core;
90 using io::pdb::dump_pdb;
91 ////////////////////////////////////////////////////////////////////////////////////////////////////
92 
93 namespace protocols {
94 namespace relax {
95 
97 ClassicRelaxCreator::keyname() const
98 {
99  return ClassicRelaxCreator::mover_name();
100 }
101 
103 ClassicRelaxCreator::create_mover() const {
104  return new ClassicRelax;
105 }
106 
108 ClassicRelaxCreator::mover_name()
109 {
110  return "ClassicRelax";
111 }
112 
113 ////////////////////////////////////////////////////////////////////////////////////////////////////
114 ClassicRelax::ClassicRelax(
116 ) :
117  parent("ClassicRelax", scorefxn_in ),
118  checkpoints_("ClassicRelax")
119 {
120  set_default();
121  // set these to true - by deafult we're using the default
122  // types for these objects. if the user chooses to set their own
123  // these will be set to false to indicate that the user has done so
126  use_default_mc_ = true;
127 }
128 ////////////////////////////////////////////////////////////////////////////////////////////////////
129 /// @brief constructor taking both ScoreFunction and MoveMap
131  parent( "ClassicRelax",scorefxn_in ),
132  checkpoints_("ClassicRelax")
133 {
136  use_default_mc_ = true;
137  set_movemap( movemap );
138  set_default( false /* use_default_movemap */ );
139 }
140 ////////////////////////////////////////////////////////////////////////////////////////////////////
141 
143  parent("ClassicRelax"),
144  checkpoints_("ClassicRelax")
145 {
146  set_default();
147 
150  use_default_mc_ = true;
151 }
152 
154  //utility::pointer::ReferenceCount(),
155  parent( other ),
156  min_mover_( other.min_mover_ ),
157  checkpoints_( other.checkpoints_ ),
158  mc_( other.mc_ ),
159  use_default_mc_( other.use_default_mc_ ),
160  pack_full_repack_( other.pack_full_repack_ ),
161  use_default_pack_full_repack_( other.use_default_pack_full_repack_ ),
162  pack_rottrial_( other.pack_rottrial_ ),
163  use_default_pack_rottrial_( other.use_default_pack_rottrial_ ),
164  m_Temperature( other.m_Temperature ),
165  nmoves_( other.nmoves_ ),
166  energycut( other.energycut ),
167  min_type( other.min_type ),
168  nb_list( other.nb_list ),
169  min_tolerance( other.min_tolerance ),
170  moveset_phase1_( other.moveset_phase1_ ),
171  moveset_phase2_( other.moveset_phase2_ ),
172  moveset_phase3_( other.moveset_phase3_ ),
173  lj_ramp_cycles( other.lj_ramp_cycles ),
174  lj_ramp_inner_cycles( other.lj_ramp_inner_cycles ),
175  start_rep_weight( other.start_rep_weight ),
176  end_rep_weight( other.end_rep_weight ),
177  st_rep_( other.st_rep_ ),
178  st_atr_( other.st_atr_ ),
179  st_sol_( other.st_sol_ ),
180  stage2_repack_period( other.stage2_repack_period ),
181  stage2_cycles( other.stage2_cycles ),
182  stage3_cycles( other.stage3_cycles ),
183  score_stage2_beginning( other.score_stage2_beginning ),
184  score_stage2_quarter( other.score_stage2_quarter ),
185  score_stage2_half( other.score_stage2_half ),
186  score_stage2_end( other.score_stage2_end ),
187  filter_stage2_beginning( other.filter_stage2_beginning ),
188  filter_stage2_quarter( other.filter_stage2_quarter ),
189  filter_stage2_half( other.filter_stage2_half ),
190  filter_stage2_end( other.filter_stage2_end )
191 {
192 }
193 
194 ////////////////////////////////////////////////////////////////////////////////////////////////////
196  return new ClassicRelax(*this);
197 }
198 
199 ////////////////////////////////////////////////////////////////////////////////////////////////////
201 ////////////////////////////////////////////////////////////////////////////////////////////////////
202 
203 
204 ////////////////////////////////////////////////////////////////////////////////////////////////////
205 ///@details registering of options that are relevant for AbrelaxApplication
207  using namespace basic::options;
208  using namespace basic::options::OptionKeys;
209 
211 
212  option.add_relevant( OptionKeys::relax::wobblemoves );
213  option.add_relevant( OptionKeys::relax::constrain_relax_to_native_coords );
214  option.add_relevant( OptionKeys::relax::constrain_relax_to_start_coords );
215  option.add_relevant( OptionKeys::relax::constrain_relax_segments );
216  option.add_relevant( OptionKeys::relax::ramp_constraints );
217  option.add_relevant( OptionKeys::relax::energycut );
218  option.add_relevant( OptionKeys::relax::stage1_ramp_cycles );
219  option.add_relevant( OptionKeys::relax::stage1_ramp_inner_cycles );
220  option.add_relevant( OptionKeys::relax::stage2_repack_period );
221  option.add_relevant( OptionKeys::relax::stage2_cycles );
222  option.add_relevant( OptionKeys::relax::min_tolerance );
223  option.add_relevant( OptionKeys::relax::stage3_cycles );
224  option.add_relevant( OptionKeys::relax::cycle_ratio );
225  option.add_relevant( OptionKeys::relax::filter_stage2_beginning );
226  option.add_relevant( OptionKeys::relax::filter_stage2_quarter );
227  option.add_relevant( OptionKeys::relax::filter_stage2_half );
228  option.add_relevant( OptionKeys::relax::filter_stage2_end );
229 }
230 
231 
233  set_scorefxn( scorefxn_in );
234  set_default();
235 }
236 
237 
238 
239 
240 ////////////////////////////////////////////////////////////////////////////////////////////////////
241 void ClassicRelax::set_default( bool const use_default_movemap ){
242  TR << "Setting up default relax setting" << std::endl;
243  // minimization
244  //min_type = std::string("dfpmin_armijo_nonmonotone");
246  nb_list = true;
247 
248 
252 
253  m_Temperature = 0.8;
254 
255  nmoves_ = 5;
256  energycut = basic::options::option[ basic::options::OptionKeys::relax::energycut ];
257 
258  lj_ramp_cycles = basic::options::option[ basic::options::OptionKeys::relax::stage1_ramp_cycles];
259  lj_ramp_inner_cycles = basic::options::option[ basic::options::OptionKeys::relax::stage1_ramp_inner_cycles];
260  start_rep_weight = 0.02;
261  end_rep_weight = 1.0;
262 
263  // PHASE2 stuff
264  stage2_repack_period = basic::options::option[ basic::options::OptionKeys::relax::stage2_repack_period];
265  stage2_cycles = basic::options::option[ basic::options::OptionKeys::relax::stage2_cycles ];
266  min_tolerance = basic::options::option[ basic::options::OptionKeys::relax::min_tolerance ]; //0.00025; //as in stage2 in rosetta++
267 
268  if ( basic::options::option[ basic::options::OptionKeys::run::test_cycles ] ) {
269  stage2_cycles = 1;
270  stage3_cycles = 1;
271  lj_ramp_cycles = 1;
272  min_tolerance = 0.2;
273  }
274 
275  // PHASE3 stuff
276  stage3_cycles = basic::options::option[ basic::options::OptionKeys::relax::stage3_cycles ];
277 
278  filter_stage2_beginning = basic::options::option[ basic::options::OptionKeys::relax::filter_stage2_beginning ];
279  filter_stage2_quarter = basic::options::option[ basic::options::OptionKeys::relax::filter_stage2_quarter ];
280  filter_stage2_half = basic::options::option[ basic::options::OptionKeys::relax::filter_stage2_half ];
281  filter_stage2_end = basic::options::option[ basic::options::OptionKeys::relax::filter_stage2_end ];
282 
285  score_stage2_half = 0;
286  score_stage2_end = 0;
287 
288  //chu move these two calls after values are set, otherwise it causes bad bug with uninitialized variables.
289 
290  if ( use_default_movemap ) {
292  }
294 
298 }
299 
301  TR.Info << "Setting min tolerance: " << new_tolerance << std::endl;
302  min_tolerance = new_tolerance;
304 }
305 
306 
307 // sets up the default minimizer object with all the options
309  // options for minimizer
310  if ( basic::options::option[ basic::options::OptionKeys::symmetry::symmetry_definition ].user() ) {
312  } else {
314  }
315 }
316 ////////////////////////////////////////////////////////////////////////////////////////////////////
317 ///@details At stage 1 we're only doing small and shear moves
319 {
320  // setup the move objects
322  small_mover->angle_max( 'H', 2.0 );
323  small_mover->angle_max( 'E', 2.0 );
324  small_mover->angle_max( 'L', 3.0 );
325 
326  // setup the move objects
328  shear_mover->angle_max( 'H', 2.0 );
329  shear_mover->angle_max( 'E', 2.0 );
330  shear_mover->angle_max( 'L', 3.0 );
331 
332  // create a Random Mover, fill it with individual moves
333  moves::RandomMoverOP moveset_phase1_temp = new moves::RandomMover();
334  //moveset_phase1_temp ->add_mover( small_mover );
335  //moveset_phase1_temp ->add_mover( shear_mover );
336 
337  // then set our internal moveset
338  moveset_phase1_ = moveset_phase1_temp;
339 }
340 ////////////////////////////////////////////////////////////////////////////////////////////////////
341 ///@details At stage 2 we're doing small, shear, wobble and crank moves (the latter two are works in progress)
343 {
344  // setup the move objects
346  small_mover->angle_max( 'H', 2.0 );
347  small_mover->angle_max( 'E', 2.0 );
348  small_mover->angle_max( 'L', 3.0 );
349 
350  // setup the move objects
352  shear_mover->angle_max( 'H', 2.0 );
353  shear_mover->angle_max( 'E', 2.0 );
354  shear_mover->angle_max( 'L', 3.0 );
355 
356  // create a Random Mover, fill it with individual moves
357  moves::RandomMoverOP moveset_phase2_temp = new moves::RandomMover();
358  moveset_phase2_temp ->add_mover( small_mover );
359  moveset_phase2_temp ->add_mover( shear_mover );
360 
361  // setup the move object
362  if( basic::options::option[ basic::options::OptionKeys::relax::wobblemoves ].user() &&
363  basic::options::option[ basic::options::OptionKeys::in::file::frag3 ].user() ){
364  std::string frag3_file = basic::options::option[ basic::options::OptionKeys::in::file::frag3 ]();
366  fragset3mer->read_fragment_file( frag3_file );
368 
369  moveset_phase2_temp ->add_mover( wobble_mover );
370  moveset_phase2_temp ->add_mover( wobble_mover );
371  }
372 
373  // then set our internal moveset
374  moveset_phase2_ = moveset_phase2_temp;
375 
376 }
377 ////////////////////////////////////////////////////////////////////////////////////////////////////
378 ///@details At stage 3 we're only doing small and shear moves
380 {
381  // setup the move objects
383  small_mover->angle_max( 'H', 2.0 );
384  small_mover->angle_max( 'E', 2.0 );
385  small_mover->angle_max( 'L', 3.0 );
386 
387  // setup the move objects
389  shear_mover->angle_max( 'H', 2.0 );
390  shear_mover->angle_max( 'E', 2.0 );
391  shear_mover->angle_max( 'L', 3.0 );
392 
393  // create a Random Mover, fill it with individual moves
394  moves::RandomMoverOP moveset_phase3_temp = new moves::RandomMover();
395  moveset_phase3_temp ->add_mover( small_mover );
396  moveset_phase3_temp ->add_mover( shear_mover );
397 
398  // then set our internal moveset
399  moveset_phase3_ = moveset_phase3_temp;
400 
401 }
402 ////////////////////////////////////////////////////////////////////////////////////////////////////
404  if( use_default_mc_ ){
405  mc_ = new moves::MonteCarlo( pose , *get_scorefxn() , 0.8 );
406  }
407 }
408 ////////////////////////////////////////////////////////////////////////////////////////////////////
410  check_default_mc( pose );
411  return mc_;
412 }
413 
414 
415 
416 ////////////////////////////////////////////////////////////////////////////////////////////////////
418  mc_ = new_mc_;
419  use_default_mc_ = false; // user has set his own
420 }
421 
422 ////////////////////////////////////////////////////////////////////////////////////////////////////
426  task_ = pack::task::TaskFactory::create_packer_task( pose ); //!!!!!!!!!!!
427 
428  utility::vector1<bool> allow_repack(pose.total_residue(), false);
429 
430  for ( Size i = 1; i<= pose.total_residue() ; ++i ) {
431 
432  allow_repack[i] = movemap.get_chi(i);
433  }
434 
435 
436  if (basic::options::option[ basic::options::OptionKeys::relax::chi_move].user() ){
437  bool const repack = basic::options::option[ basic::options::OptionKeys::relax::chi_move]();
438  allow_repack.assign( pose.total_residue(), repack);
439  }
440 
441  task_->initialize_from_command_line().restrict_to_repacking().restrict_to_residues(allow_repack);
442  task_->or_include_current( true );
443  if ( basic::options::option[ basic::options::OptionKeys::symmetry::symmetry_definition ].user() ) {
445  } else {
447  }
448  /* TODO set packer_task_factory */
449 
450  (*get_scorefxn())( pose );
451  }
452 
453 
454 }
455 ////////////////////////////////////////////////////////////////////////////////////////////////////
457  pack_full_repack_ = new_pack_full_repack;
459 }
460 ////////////////////////////////////////////////////////////////////////////////////////////////////
462 
465  task_ = pack::task::TaskFactory::create_packer_task( pose ); //!!!!!!!!!!!
466 
467 
468  utility::vector1<bool> allow_repack( pose.total_residue(), false);
469 
470  for ( Size i = 1; i<= pose.total_residue() ; ++i ) {
471 
472 
473  allow_repack[i] = movemap.get_chi(i);
474 
475  }
476 
477 
478  if (basic::options::option[ basic::options::OptionKeys::relax::chi_move].user() ){
479  bool const repack = basic::options::option[ basic::options::OptionKeys::relax::chi_move]();
480  allow_repack.assign( pose.total_residue(), repack);
481  }
482 
483 
484  task_->initialize_from_command_line().restrict_to_repacking().restrict_to_residues(allow_repack);
485  task_->or_include_current( true );
486  (*get_scorefxn())( pose );
487  /// Now handled automatically. scorefxn_->accumulate_residue_total_energies( pose ); // fix this
488  if ( basic::options::option[ basic::options::OptionKeys::symmetry::symmetry_definition ].user() ) {
490  } else {
492  }
493  }
494 
495 }
496 ////////////////////////////////////////////////////////////////////////////////////////////////////
498  pack_rottrial_ = new_pack_rottrial;
500 }
501 ////////////////////////////////////////////////////////////////////////////////////////////////////
502 
504  core::pose::setPoseExtraScores( pose, "Filter_Stage2_dEnd", score_stage2_end);
505  core::pose::setPoseExtraScores( pose, "Filter_Stage2_cHalf", score_stage2_half);
506  core::pose::setPoseExtraScores( pose, "Filter_Stage2_bQuarter",score_stage2_quarter);
507  core::pose::setPoseExtraScores( pose, "Filter_Stage2_aBefore", score_stage2_beginning);
508 }
509 
510 
511 ////////////////////////////////////////////////////////////////////////////////////////////////////
513  using namespace moves;
514  using namespace scoring;
515  using namespace basic::options;
516  using namespace basic::options::OptionKeys;
517  using namespace core::pose::datacache;
518 
519  runtime_assert( get_scorefxn() );
520  (*get_scorefxn())(pose);
521 
522  /// Invoke parent local_movemap initialization routines
523  core::kinematics::MoveMapOP local_movemap = get_movemap()->clone();
524  initialize_movemap( pose, *local_movemap );
525 
526  // Make sure we only allow symmetrical degrees of freedom to move
527 // if ( basic::options::option[ basic::options::OptionKeys::symmetry::symmetry_definition ].user() ) {
528 // core::pose::symmetry::make_symmetric_movemap( pose, *local_movemap );
529 // }
530 
531  // remember the original pose before refinement kicks in, we'll need it later
532  core::pose::Pose prerefine_pose = pose;
533 
534  // Set up any internal constraints that need to be set
535  set_up_constraints( pose, *local_movemap );
536 
537  check_default_mc( pose );
538  check_default_full_repacker( pose, *local_movemap);
539  check_default_rottrial( pose, *local_movemap);
540 
541  // Make sure we only allow symmetrical degrees of freedom to move
542  if ( basic::options::option[ basic::options::OptionKeys::symmetry::symmetry_definition ].user() ) {
543  core::pose::symmetry::make_symmetric_movemap( pose, *local_movemap );
544  }
545 
546  min_mover_->movemap(local_movemap);
547 
548  get_scorefxn()->show(TR.Debug , pose);
549 
550  apply_disulfides(pose);
551 
552  if( ( lj_ramp_cycles > 0 ) && (!checkpoints_.recover_checkpoint( pose, "stage_1", get_current_tag(), true, true )) ) {
553 
554  // part 1 ----------------------------------------
555  TR.Info << std::endl << std::endl << "===================================================================" << std::endl;
556  TR.Info << " Stage 1 " << std::endl;
557  TR.Info << " Ramping repulsives with " << lj_ramp_cycles << " outer cycles and "
558  << lj_ramp_inner_cycles << " inner cycles" << std::endl;
559 
560  // setup the repack cycle
561  moves::CycleMoverOP repack_cycle( new moves::CycleMover() );
562  repack_cycle->add_mover( pack_full_repack_ );
563  for ( int i=1; i<lj_ramp_inner_cycles; ++i )
564  repack_cycle->add_mover( pack_rottrial_ );
565 
566  moves::SequenceMoverOP phase1_cycle( new moves::SequenceMover() );
567  //phase1_cycle->add_mover( moveset_phase1_ );
568  phase1_cycle->add_mover( repack_cycle );
569 
570  moves::JumpOutMoverOP phase1_min(
571  new moves::JumpOutMover( phase1_cycle, min_mover_, get_scorefxn(), 1E6 )
572  );
573 
574  moves::TrialMoverOP phase1_trial( new moves::TrialMover( phase1_min, mc_ ) );
575 
576  moves::RampingMoverOP full_cycle_phase1_;
577  if ( ramp_down_constraints_ ) {
578  core::scoring::EnergyMap starting_weights, final_weights;
579  starting_weights = final_weights = get_scorefxn()->weights();
580  starting_weights[ fa_rep ] = start_rep_weight * starting_weights[ fa_rep ]; // ramp up repulsion
581  final_weights[ coordinate_constraint ] = 0;
582  final_weights[ atom_pair_constraint ] = 0;
583  final_weights[ angle_constraint ] = 0;
584  final_weights[ dihedral_constraint ] = 0;
585 
586  full_cycle_phase1_ = new moves::RampingMover(
587  phase1_trial, get_scorefxn(),
588  starting_weights, final_weights,
589  lj_ramp_cycles, lj_ramp_inner_cycles, mc_ );
590  full_cycle_phase1_->set_func_for_weight( coordinate_constraint, new moves::FastLinearFunc( 0, 0.6 ) );
591  full_cycle_phase1_->set_func_for_weight( atom_pair_constraint, new moves::FastLinearFunc( 0, 0.6 ) );
592  } else {
593  full_cycle_phase1_ = new moves::RampingMover(
594  phase1_trial, get_scorefxn(), scoring::fa_rep,
595  lj_ramp_cycles, lj_ramp_inner_cycles, mc_ );
596  full_cycle_phase1_->start_weight( start_rep_weight * get_scorefxn()->weights()[ scoring::fa_rep ] );
597  full_cycle_phase1_->end_weight( end_rep_weight * get_scorefxn()->weights()[ scoring::fa_rep ] );
598  }
599 
600  full_cycle_phase1_->apply( pose );
601 
602  checkpoints_.checkpoint( pose, "stage_1", get_current_tag(), true );
603 
604  }
605 
606  mc_->reset_scorefxn( pose, *get_scorefxn() );
607  (*get_scorefxn())(pose);
608  get_scorefxn()->show(TR.Debug , pose);
610  // save time if the pose is symmetric
612  dynamic_cast<core::conformation::symmetry::SymmetricConformation &> ( pose.conformation()) );
614  // need to copy virtuals first
615  for ( Size ii = prerefine_pose.total_residue(); ii>=1; --ii ) {
616  if ( symm_info->fa_is_independent(ii) )
617  prerefine_pose.replace_residue( ii, pose.residue( ii ), false);
618  }
619  } else {
620  for ( Size ii = 1; ii <= prerefine_pose.total_residue(); ++ii ) {
621  prerefine_pose.replace_residue( ii, pose.residue( ii ), false);
622  }
623  }
624  pose = prerefine_pose;
625  (*get_scorefxn())(pose);
626 
627  check_default_mc( pose );
628  check_default_full_repacker( pose, *local_movemap );
629  check_default_rottrial( pose, *local_movemap );
630 
631 
632  /// Stage 2 is
633  /// Stage 2 is mysterious, just like the comment above.
634  /// Stage 2 is <useless> ! Use fastrelax instead.
635  if( stage2_cycles < 0 ) {
636  stage2_cycles = pose.total_residue() * 4;
637  }
638 
639 
640  if( stage2_cycles > 0 )
641  if (!checkpoints_.recover_checkpoint( pose, "stage_2", get_current_tag(), true, true)) {
642 
643  core::Real temp_score = (*get_scorefxn())(pose);
644  get_scorefxn()->show( TR.Debug , pose );
645  score_stage2_beginning = temp_score;
646  score_stage2_quarter = temp_score;
647  score_stage2_half = temp_score;
648  score_stage2_end = temp_score;
649  setPoseExtraScores( pose );
650  mc_->reset(pose);
651 
652  if ( filter_stage2_beginning < temp_score ) {
653  TR.Info << "Structure failed filter_stage2_beginning: " << temp_score << " > " << filter_stage2_beginning << std::endl;
654  return;
655  }
656 
657  // part 2 ----------------------------------------
658  TR.Info << std::endl << "===================================================================" << std::endl;
659  TR.Info << " Stage 2 " << std::endl;
660  TR.Info << " Mainmintrial for " << stage2_cycles << " with a full repack every "
661  << stage2_repack_period << " cycles" << std::endl;
662 
663  // setup the repack cycle
664  moves::CycleMoverOP repack_cycle( new moves::CycleMover() );
665  for ( int i=1; i<stage2_repack_period; ++i ){
666  repack_cycle->add_mover( pack_rottrial_ );
667  }
668  repack_cycle->add_mover( pack_full_repack_ );
669 
670  moves::SequenceMoverOP phase2_cycle( new moves::SequenceMover() );
671  phase2_cycle->add_mover( moveset_phase2_ );
672  phase2_cycle->add_mover( repack_cycle );
673 
674  moves::JumpOutMoverOP phase2_min( new moves::JumpOutMover( phase2_cycle, min_mover_, get_scorefxn(), 25.0 ) );
675 
676  moves::TrialMoverOP phase2_trial( new moves::TrialMover( phase2_min, mc_ ) );
677 
678  moves::RepeatMoverOP full_cycle_phase2_;
679  full_cycle_phase2_ = new moves::RepeatMover( phase2_trial, int( core::Real(stage2_cycles) * basic::options::option[ basic::options::OptionKeys::relax::cycle_ratio] / 4.0 ) );
680 
681  full_cycle_phase2_->apply( pose );
682 
683  score_stage2_quarter = mc_->lowest_score();
684  score_stage2_half = mc_->lowest_score();
685  score_stage2_end = mc_->lowest_score();
686  if ( filter_stage2_quarter < mc_->lowest_score() ) {
687  TR.Info << "Structure failed filter_stage2_quarter: " << mc_->lowest_score() << " > " << filter_stage2_quarter << std::endl;
688  mc_->recover_low( pose );
689  setPoseExtraScores( pose );
690  return;
691  }
692 
693  full_cycle_phase2_->apply( pose );
694 
695  score_stage2_half = mc_->lowest_score();
696  score_stage2_end = mc_->lowest_score();
697  if ( filter_stage2_half < mc_->lowest_score() ) {
698  TR.Info << "Structure failed filter_stage2_half: " << mc_->lowest_score() << " > " << filter_stage2_quarter << std::endl;
699  mc_->recover_low( pose );
700  setPoseExtraScores( pose );
701  return;
702  }
703 
704  full_cycle_phase2_->apply( pose );
705  full_cycle_phase2_->apply( pose );
706 
707  score_stage2_end = mc_->lowest_score();
708  if ( filter_stage2_end< mc_->lowest_score() ) {
709  TR.Info << "Structure failed score_stage2_end: " << mc_->lowest_score() << " > " << filter_stage2_quarter << std::endl;
710  mc_->recover_low( pose );
711  setPoseExtraScores( pose );
712  return;
713  }
714 
715  checkpoints_.checkpoint( pose, "stage_2", get_current_tag(), true);
716  }
717 
718  mc_->recover_low( pose );
719  (*get_scorefxn())(pose);
720  get_scorefxn()->show(TR.Debug, pose);
721  setPoseExtraScores( pose );
722  mc_->reset(pose);
723 
724  // output_debug_structure( pose, "rl_stage2" );
725 
726  if( stage3_cycles < 0 ){
727  stage3_cycles = pose.total_residue();
728  }
729  if( stage3_cycles > 0 )
730  if (!checkpoints_.recover_checkpoint( pose, "stage_3", get_current_tag(), true, true )) {
731 
732  // part 3 ----------------------------------------
733  TR.Info << std::endl << "===================================================================" << std::endl;
734  TR.Info << " Stage 3 " << std::endl;
735  TR.Info << " Mainmintrial for " << stage3_cycles << std::endl;
736  moves::SequenceMoverOP phase3_cycle( new moves::SequenceMover() );
737  phase3_cycle->add_mover( moveset_phase3_ );
738  phase3_cycle->add_mover( pack_rottrial_ );
739 
740  moves::JumpOutMoverOP phase3_min( new moves::JumpOutMover( phase3_cycle, min_mover_, get_scorefxn(), 15.0 ) );
741 
742  moves::TrialMoverOP phase3_trial( new moves::TrialMover( phase3_min, mc_ ) );
743 
744  moves::RepeatMoverOP full_cycle_phase3_;
745  full_cycle_phase3_ = new moves::RepeatMover( phase3_trial, int( core::Real(stage3_cycles) * basic::options::option[ basic::options::OptionKeys::relax::cycle_ratio]) );
746 
747  full_cycle_phase3_->apply( pose );
748 
749  checkpoints_.checkpoint( pose, "stage_3", get_current_tag(), true );
750 
751  }
752 
753  // output_debug_structure( pose, "rl_stage3" );
754  mc_->recover_low( pose );
755 
756  // add scores to map for output
757  std::map < std::string, core::Real > score_map;
759  if ( get_native_pose()!=0 ) {
760  score_map["rms"] = CA_rmsd( *get_native_pose(), pose );
761  }
762 
763  get_scorefxn()->show( TR.Debug , pose );
764  TR << std::endl;
765 
766  // cache the score map to the pose
767  // why does this obliterate any scores that were already there?
768  pose.data().set(CacheableDataType::SCORE_MAP, new basic::datacache::DiagnosticData(score_map));
769 
770 
771  (*get_scorefxn())(pose);
772 }
773 
776  return "ClassicRelax";
777 }
778 
779 }
780 } // namespace protocols
781 
782