Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LoopMover_QuickCCD_Moves.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 protocols/loops/loop_mover/independent_loop_mover/LoopMover_Perturb_QuickCCD_Moves.cc
11 /// @brief kinematic loop closure main protocols
12 /// @author Mike Tyka
13 
14 //// Unit Headers
16 //#include <protocols/loops/LoopMover.hh>
19 #include <protocols/loops/Loop.hh>
20 #include <protocols/loops/Loops.hh>
21 // AUTO-REMOVED #include <protocols/loops/kinematic_closure/KinematicMover.hh>
24 //
25 //
26 //// Rosetta Headers
27 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
29 
31 // AUTO-REMOVED #include <core/conformation/util.hh>
33 #include <core/id/TorsionID.hh>
38 #include <basic/options/option.hh>
39 #include <core/pose/Pose.hh>
40 // AUTO-REMOVED #include <core/pose/util.hh>
41 #include <core/scoring/Energies.hh>
42 // AUTO-REMOVED #include <core/scoring/rms_util.hh>
44 // AUTO-REMOVED #include <core/scoring/ScoreFunctionFactory.hh>
45 #include <core/fragment/FragSet.hh>
47 
49 // AUTO-REMOVED #include <core/conformation/symmetry/util.hh>
50 
52 
53 //#include <core/pack/task/TaskFactory.hh>
54 //#include <core/pack/task/PackerTask.hh>
55 //#include <core/pack/task/operation/TaskOperations.hh>
56 // AUTO-REMOVED #include <core/pack/rotamer_trials.hh>
57 // AUTO-REMOVED #include <core/pack/pack_rotamers.hh>
58 //#include <protocols/simple_moves/BackboneMover.hh>
61 
62 // AUTO-REMOVED #include <basic/prof.hh> // profiling
63 #include <basic/Tracer.hh> // tracer output
65 
66 //Utility Headers
67 #include <numeric/random/random.hh>
68 // AUTO-REMOVED #include <utility/io/izstream.hh>
69 
70 // C++ Headers
71 #include <iostream>
72 #include <map>
73 #include <string>
74 
75 // option key includes
76 
77 #include <basic/options/keys/loops.OptionKeys.gen.hh>
78 #include <basic/options/keys/constraints.OptionKeys.gen.hh>
79 
80 #include <core/pose/util.hh>
81 #include <utility/vector1.hh>
82 
83 //Auto Headers
84 
85 
86 
87 
88 
89 
90 namespace protocols {
91 namespace loops {
92 namespace loop_mover {
93 namespace perturb {
94 
95 ///////////////////////////////////////////////////////////////////////////////
96 using namespace core;
97 static basic::Tracer TR("protocols.loops.loop_mover.perturb.LoopMover_Perturb_QuickCCD_Moves");
98 
99 
100 static numeric::random::RandomGenerator RG(42862);
101 
102 
105 {}
106 
107 
110 ) :
111  LoopMover_Perturb_QuickCCD( loops_in )
112 {
113 }
114 
115 
117  protocols::loops::LoopsOP loops_in,
119 ) :
120  LoopMover_Perturb_QuickCCD( loops_in, scorefxn )
121 {
122 }
123 
126  return "LoopMover_Perturb_QuickCCD_Moves";
127 }
128 
130  core::pose::Pose & pose,
131  protocols::loops::Loop const & loop
132 ){
133  using namespace kinematics;
134  using namespace scoring;
135  using namespace optimization;
136  using namespace protocols::simple_moves;
137  using namespace basic::options;
138  using namespace basic::options::OptionKeys;
139  using namespace numeric::random;
140 
141  tr() << "***** DOING CCD MOVES *****" << std::endl;
142 
143  core::Size const nres = pose.total_residue();
144 
145  // store starting fold tree and cut pose
146  kinematics::FoldTree f_orig=pose.fold_tree();
147  set_single_loop_fold_tree( pose, loop );
148 
149  // generate movemap after fold_tree is set
150  kinematics::MoveMapOP mm_one_loop = new kinematics::MoveMap(), mm_one_loop_symm = new kinematics::MoveMap();
151  set_move_map_for_centroid_loop( loop, *mm_one_loop );
152  set_move_map_for_centroid_loop( loop, *mm_one_loop_symm );
153  if ( core::pose::symmetry::is_symmetric( pose ) ) {
154  core::pose::symmetry::make_symmetric_movemap( pose, *mm_one_loop_symm );
155  }
156 
157  int const loop_size( loop.stop() - loop.start() + 1 );
158  core::Size cycles2 = 10;
159  core::Size cycles3 = std::max( 30, int( 10*loop_size));
160  tr().Info << "Number of cycles: cycles2 and cycles3 " << cycles2 << " " << cycles3 << std::endl;
161 
162  // special case ... vrt res at last position
163  //chainbreak_present &= ( loop.stop() != nres-1 || pose.residue( nres ).aa() != core::chemical::aa_vrt );
164  bool chainbreak_present = ( loop.start() != 1 && loop.stop() != nres &&
165  !pose.residue( loop.start() ).is_lower_terminus() &&
166  !pose.residue( loop.stop() ).is_upper_terminus() );
167 
168  // set loop.cut() variant residue for chainbreak score if chanbreak is present
169  if( chainbreak_present ){
172  }
173 
174  ( *scorefxn() )(pose);
175  /// Now handled automatically. scorefxn_->accumulate_residue_total_energies( pose );
176  core::pose::Pose start_pose = pose;
177 
178 
179 
180  // either extend or at least idealize the loop (just in case).
181  if( loop.is_extended() ) set_extended_torsions( pose, loop );
182  else idealize_loop( pose, loop );
183 
184  // omega needs to be moveable for FragmentMovers, so use a separate movemap
185  kinematics::MoveMapOP frag_mover_movemap = new kinematics::MoveMap();
186  frag_mover_movemap->set_bb_true_range( loop.start(), loop.stop() );
187 
190  it = frag_libs().begin(), it_end = frag_libs().end();
191  it != it_end; it++ ) {
192  ClassicFragmentMoverOP cfm = new ClassicFragmentMover( *it, frag_mover_movemap );
193  cfm->set_check_ss( false );
194  cfm->enable_end_bias_check( false );
195  fragmover.push_back( cfm );
196  }
197 
198  core::Real m_Temperature_ = 2.0;
199  moves::MonteCarloOP mc_ = new moves::MonteCarlo( pose, *scorefxn(), m_Temperature_ );
200 
201  if( randomize_loop_ ){
202  // insert random fragment as many times as the loop is long (not quite the exact same as the old code)
203  for ( Size i = loop.start(); i <= loop.stop(); ++i ) {
204  for ( std::vector< FragmentMoverOP >::const_iterator
205  it = fragmover.begin(),it_end = fragmover.end(); it != it_end; it++ ) {
206  (*it)->apply( pose );
207  }
208  }
209  }
210 
211  // Set up Minimizer object
213  float const dummy_tol( 0.001 ); // linmin sets tol internally
214  bool const use_nblist( true ), deriv_check( false ); // true ); // false );
215  MinimizerOptions options( "linmin", dummy_tol, use_nblist, deriv_check);
216  if ( core::pose::symmetry::is_symmetric( pose ) ) {
218  } else {
220  }
221 
222 
223 
224  // Set up MonteCarlo Object
225  core::Real const init_temp = 2.0;
226  core::Real temperature = init_temp;
227  mc_->reset( pose );
228  mc_->set_temperature( temperature );
229 
230  int frag_count = 0;
231  scorefxn()->show_line_headers( tr().Info );
232 
233  float final_chain_break_weight = 5.0;
234  if ( core::pose::symmetry::is_symmetric( pose ) ) {
236  dynamic_cast<core::conformation::symmetry::SymmetricConformation const & > ( pose.conformation()) );
238  final_chain_break_weight = 5.0*symm_info->subunits();
239  }
240 
241 
242 
243  float const delta_weight( final_chain_break_weight/cycles2 );
244  scorefxn()->set_weight( chainbreak, 0.0 ); //not evaluating quadratic chainbreak
245  mc_->score_function( *scorefxn() );
246 
247  bool has_constraints = pose.constraint_set()->has_constraints();
248  float final_constraint_weight = option[ basic::options::OptionKeys::constraints::cst_weight ]();
249  for ( core::Size c2 = 1; c2 <= cycles2; ++c2 ) {
250  mc_->recover_low( pose );
251 
252  // ramp up constraints
253  if( has_constraints ) {
254  if( c2 != cycles2 ) {
255  scorefxn()->set_weight( core::scoring::atom_pair_constraint, final_constraint_weight*float(c2)/float( cycles2 ) );
256  } else {
257  scorefxn()->set_weight( core::scoring::atom_pair_constraint, final_constraint_weight * 0.2 );
258  }
259  }
260  if ( chainbreak_present ) {
261  scorefxn()->set_weight( linear_chainbreak, c2*delta_weight );
262  }
263  mc_->score_function( *scorefxn() );
264 
265  // score and print an info line
266  ( *scorefxn() )(pose);
267  scorefxn()->show_line( tr() , pose );
268  tr() << std::endl;
269 
270  for ( core::Size c3 = 1; c3 <= cycles3; ++c3 ) {
271  if(( !chainbreak_present || uniform()*cycles2 > c2 ))
272  {
273  //do fragment moves here
274  for ( std::vector< FragmentMoverOP >::const_iterator
275  it = fragmover.begin(),it_end = fragmover.end(); it != it_end; it++ ) {
276 
277 
278  if( ((*it)->fragments()->max_frag_length() == 1 ) && (uniform() < option[OptionKeys::loops::skip_1mers ]() ) ) continue;
279  if( ((*it)->fragments()->max_frag_length() == 3 ) && (uniform() < option[OptionKeys::loops::skip_3mers ]() ) ) continue;
280  if( ((*it)->fragments()->max_frag_length() == 9 ) && (uniform() < option[OptionKeys::loops::skip_9mers ]() ) ) continue;
281 
282  (*it)->apply( pose );
283  frag_count++;
284  }
285  } else {
286  //do ccd_moves here
287  if( ! option[OptionKeys::loops::skip_ccd_moves ]() ){
288  loop_closure::ccd::ccd_moves(5, pose, *mm_one_loop, loop.start(), loop.stop(), loop.cut() );
289  }
290  }
291  mc_->boltzmann( pose, "QuickCCD_Moves" );
292  } // cycles3
293  mzr->run( pose, *mm_one_loop_symm, *scorefxn(), options );
294  } //cycles2
295 
296  // now ensure the loop is properly closed!
297  float chain_break_score = std::max( (float)pose.energies().total_energies()[ scoring::chainbreak ],
299 
300  if( ( chain_break_score > 0.1 ) && chainbreak_present )
301  {
302  mc_->recover_low( pose );
303  tr() << "--" << std::endl;
304  ( *scorefxn() )(pose);
305  scorefxn()->show_line( tr() , pose );
306  tr() << std::endl;
307  Loop closeloop(std::max(loop.cut()-3,loop.start()), std::min(loop.cut()+3,loop.stop()), loop.cut() );
308  fast_ccd_close_loops( pose, closeloop, *mm_one_loop );
309  ( *scorefxn() )(pose);
310  scorefxn()->show_line( tr() , pose );
311  tr() << std::endl;
312  mc_->reset( pose );
313  }
314 
315  pose = mc_->lowest_score_pose();
316  //scorefxn_->show( tr.Info , pose );
317  tr().Info << "-------------------------" << std::endl;
318  mc_->show_counters();
319 
320  // CHeck chain break !
321  if( chainbreak_present ){
322  ( *scorefxn() )( pose );
323  core::Real chain_break_score = std::max( (float)pose.energies().total_energies()[ scoring::chainbreak ],
325 
326  core::Real chain_break_tol = option[ basic::options::OptionKeys::loops::chain_break_tol ]();
327  tr().Info << "Chainbreak: " << chain_break_score << " Max: " << chain_break_tol << std::endl;
328  if( chain_break_score > chain_break_tol ) return Failure;
329  }
330 
331  // return to original fold tree
332  pose.fold_tree( f_orig );
333 
334  return Success;
335 }
336 
338 {
339  return TR;
340 }
341 
343 
344 
347 }
348 
350  return "LoopMover_Perturb_QuickCCD_Moves";
351 }
352 
353 } // namespace perturb
354 } // namespace loop_mover
355 } // namespace loops
356 } // namespace protocols