Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FlexPepDockingLowRes.cc
Go to the documentation of this file.
1 // (c) Copyright Rosetta Commons Member Institutions.
2 // (c) This file is part of the Rosetta software suite and is made available under license.
3 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
4 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
5 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
6 
7 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
8 // vi: set ts=2 noet;
9 //
10 // (C) 199x-2008 Hebrew University, Jerusalem
11 //
12 /// @file FlexPepDockingLowRes.hh
13 ///
14 /// @brief low-resolution part of docking protocol
15 /// @date August 5, 2008
16 /// @author Barak Raveh
17 
18 
21 
22 #include <core/types.hh>
23 // AUTO-REMOVED #include <core/chemical/ChemicalManager.hh>
24 #include <core/fragment/FragSet.hh>
26 #include <basic/options/option.hh>
27 #include <basic/options/keys/OptionKeys.hh>
28 #include <basic/options/keys/loops.OptionKeys.gen.hh>
30 #include <basic/Tracer.hh>
36 #include <protocols/moves/Mover.hh>
42 #include <utility/exit.hh>
43 #include <string>
44 // AUTO-REMOVED #include <cstdio>
45 
46 #include <utility/vector0.hh>
47 #include <utility/vector1.hh>
48 
49 //Auto Headers
51 
52 using namespace protocols::flexpep_docking;
53 
54 static basic::Tracer TR("protocols.flexPepDockingLowRes");
55 
56 
57 //////////////////////////////////////////////
58 /// @brief
59 /// constructor for low resolution flexpible peptide docking
60 //
61 // @param[in] scorefxn_in
62 // The scoring function used for optimization
63 // @param[in] rb_jump
64 // The FoldTree rigid body jump over
65 // which rigid-body pertrubations are made
69  core::kinematics::MoveMapOP movemap_in,
70  Size const rb_jump_in )
71  : flags_(flags_in),
72  movemap_(movemap_in),
73  rb_jump_(rb_jump_in)
74 {
75  using namespace basic::options;
76 
77  // TODO: create a set_defaults() function
78  scorefxn_ = new core::scoring::ScoreFunction( *scorefxn_in );
79 
80  // Loop modeling options
81  // NOTE: most LoopRelax options are initiated automatically from cmd-line
82  // TODO: LoopRelaxMover is a wrapper, perhaps user the LoopModel class explicitly
83  loop_relax_mover_ = new protocols::comparative_modeling::LoopRelaxMover();
84  // loop_relax_mover_->centroid_scorefxn(scorefxn_); // TODO: we need a chain brteak score here, so let's leave it for modeller default?
85  loop_relax_mover_->refine("no"); // centroid modeling only
86  loop_relax_mover_->relax("no"); // centroid modeling only
87  if( option[ OptionKeys::loops::frag_files ].user() )
88  {
89  // these protocols optionally take a fragment set .. only load if
90  // specified
93  loop_relax_mover_->frag_libs( frag_libs );
94  }
95 }
96 
97 
98 // empty destructor - for good inclusion of OP clasesses
100 {}
101 
102 
103 ///////////////////////////////////////////////
104 /// @brief initial setup for apply
105 void
107 {
108  double temperature = 0.8;
109  mc_ = new moves::MonteCarlo( pose, *scorefxn_, temperature );
110  // setup minimizer
111  std::string min_type = "dfpmin_atol"; // armijo_nonmonotone? different tolerance?
112  double min_func_tol = 0.1;
114  movemap_, scorefxn_, min_type, min_func_tol, true /*nb_list accel.*/ );
115 }
116 
117 
118 ///////////////////////////////////////////////
119 // switch pose to centroid mode, if not already there
120 void
122 ( core::pose::Pose & pose ) const
123 {
124  if(!pose.is_fullatom())
125  return;
126  TR.Debug << "Switching to centroid" << std::endl;
128  to_centroid_mover( core::chemical::CENTROID );
129  to_centroid_mover.apply(pose);
130 }
131 
132 
133 //////////////////////////////////////////////
134 // switch pose to full-atom mode, if not already
135 // using side-chains of referencePose
136 void
138 ( core::pose::Pose & pose, core::pose::Pose& referencePose ) const
139 {
140  runtime_assert(referencePose.is_fullatom());
142  to_all_atom_mover( core::chemical::FA_STANDARD );
144  recover_sidechains( referencePose );
145  recover_sidechains.apply( pose );
146 }
147 
148 
149 ////////////////////////////////////////////
150 void
153  const int cycles,
154  double& acceptance_rate )
155 {
156  using namespace protocols::moves;
157  // setup sub-moves
158  simple_moves::SmallMoverOP small_mover =
159  new protocols::simple_moves::SmallMover( movemap_, 0.8 /*temp*/, 100 /*nmoves ???*/ );
160  small_mover->angle_max('L',flags_.smove_angle_range);
162  new protocols::simple_moves::ShearMover( movemap_, 0.8 /*temp*/, 100 /*nmoves ???*/ );
163  shear_mover->angle_max('L',flags_.smove_angle_range);
164 
165  // setup cycle of sub-moves
166  CycleMoverOP cyclic_tor_moves =
167  new CycleMover;
168  cyclic_tor_moves->add_mover(small_mover);
169  cyclic_tor_moves->add_mover(shear_mover);
170 
171  // wrap with monte-carlo trial mover
172  TrialMoverOP mc_trial = new TrialMover( cyclic_tor_moves, mc_ );
173  mc_trial->keep_stats_type( accept_reject ); // track stats (for acceptance rate)
174 
175  // Do initial forced perturbation // TODO: do we want to keep this part?
176  small_mover->apply(pose);
177  shear_mover->apply(pose);
178  // run Monte-Carlo
179  for( int i=1; i<=cycles; ++i ) {
180  mc_trial->apply( pose );
181  }
182  // extract best pose and return statistics
183  pose = mc_->lowest_score_pose();
184  mc_->reset( pose );
185  acceptance_rate = mc_trial->acceptance_rate();
186 }
187 
188 
189 ///////////////////////////////////////////
190 void
193 {
194  using namespace protocols::moves;
195 
196  if(flags_.peptide_nres() < 5) // TODO: 3 is minimum for KIC loop closure, and flanks should be excluded
197  return;
198  // set up and model a random loop
199  Size first_res = flags_.peptide_first_res() + 1;
200  Size last_res = flags_.peptide_last_res() - 1;
202  loops->add_loop(first_res, last_res); // TODO: cut defaults to zero, is this a random cut?
203  for(Size i = first_res; i <= last_res ; i++)
204  runtime_assert( movemap_->get_bb(i) ); // verify loop is movable, this should have been always true for the peptide
205  loop_relax_mover_->loops( loops );
206  loop_relax_mover_->apply( pose );
207 
208 }
209 
210 
211 
212 ///////////////////////////////////////////
213 // returns the acceptance rate from the RB monte-carlo
214 void
217  const int cycles,
218  const float trans_magnitude,
219  const float rot_magnitude,
220  double& acceptance_rate
221 )
222 {
223  using namespace protocols::moves;
224 
225  // set up monte-carlo trial moves
228  rb_jump_, rot_magnitude, trans_magnitude );
229  TrialMoverOP mc_trial = new TrialMover( rb_mover, mc_ );
230  mc_trial->keep_stats_type( accept_reject ); // track stats (for acceptance rate)
231 
232  // run monte-carlo
233  for(int i = 1; i <= cycles ; i++)
234  {
235  mc_trial->apply(pose);
236  }
237 
238  // extract best pose and return statistics
239  pose = mc_->lowest_score_pose();
240  mc_->reset( pose );
241  acceptance_rate = mc_trial->acceptance_rate();
242 }
243 
244 
245 ///////////////////////////////////////////////
246 void
248 {
249  using namespace core;
250  // variable declarations: //
251  pose::Pose startPose = pose;
252  int outer_cycles=10; // TODO: runtime param?
253  int inner_cycles_rb = 50; // TODO: runtime param?
254  int inner_cycles_torsions = 50; // TODO: runtime param?
255  double trans_mag = 0.5; // Angstrom // TODO: runtime param?
256  double rot_mag = 5; // Degrees // TODO: runtime param?
257  double rb_acceptance, torsions_acceptance; // MC acceptance rates
258  // real stuff: //
259  to_centroid(pose);
260  setup_for_apply(pose);
261  TR.flush();
262  TR.flush();
263  for ( int i=1; i<=outer_cycles; ++i) {
264  if(flags_.rbMCM) {
266  ( pose , inner_cycles_rb, trans_mag, rot_mag, rb_acceptance);
267  minimizer_->apply(pose);
268  }
269  if(flags_.torsionsMCM) {
271  ( pose , inner_cycles_torsions, torsions_acceptance);
272  minimizer_->apply(pose);
273  }
275  loopclosure_monte_carlo( pose );
276  minimizer_->apply(pose);
277  }
278  }
279  TR.flush();
280  to_allatom(pose, startPose /*reference pose*/);
281 }
282 
285  return "FlexPepDockingLowRes";
286 }
287