Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DockMCMCycle.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 DockMCMCycle
11 /// @brief protocols that are specific to high resolution docking
12 /// @detailed
13 /// This contains the functions that create initial positions for docking
14 /// You can either randomize partner 1 or partner 2, spin partner 2, or
15 /// perform a simple perturbation.
16 /// Also contains docking mcm protocol
17 /// @author Monica Berrondo
18 /// @author Modified by Sergey Lyskov
19 /// @author Modified by Sid Chaudhury
20 /// @author Modified by Jacob Corn
21 
23 
24 // Rosetta Headers
26 
29 
30 #include <core/pose/Pose.hh>
31 
34 
38 #include <protocols/moves/Mover.hh>
46 
47 //for resfile reading
48 
49 // ObjexxFCL Headers
50 #include <ObjexxFCL/string.functions.hh>
51 #include <ObjexxFCL/format.hh>
52 
53 // C++ Headers
54 #include <string>
55 
56 #include <basic/Tracer.hh>
57 using basic::T;
58 
60 #include <utility/vector0.hh>
61 #include <utility/vector1.hh>
62 #include <utility/options/IntegerVectorOption.hh>
63 #include <basic/options/keys/OptionKeys.hh>
64 
65 #include <basic/options/option.hh>
66 #include <basic/options/keys/docking.OptionKeys.gen.hh>
67 
68 
69 using basic::Error;
70 using basic::Warning;
71 
72 static basic::Tracer TR("protocols.docking.DockMCMCycle");
73 
74 // originally from dock_structure.cc Jeff Gray April 2001
75 
76 using namespace core;
77 
78 namespace protocols {
79 namespace docking {
80 
81 // default constructor
82 DockMCMCycle::DockMCMCycle() : Mover()
83 {
84  movable_jumps_.push_back(1); // operate on the first jump
85  moves::Mover::type( "DockMCMCycle" );
86  set_default();
87 }
88 
89 // constructor with arguments
90 // only one movable jump
92  core::Size const rb_jump,
94 ) : Mover(), scorefxn_(scorefxn), scorefxn_pack_(scorefxn)
95 {
96  movable_jumps_.push_back( rb_jump );
97  moves::Mover::type( "DockMCMCycle" );
98  set_default();
99 }
100 
101 // constructor with arguments
102 // only one movable jump, scoring and packing defined
104  core::Size const rb_jump,
106  core::scoring::ScoreFunctionOP scorefxn_pack
107 ) : Mover(), scorefxn_(scorefxn), scorefxn_pack_(scorefxn_pack)
108 {
109  movable_jumps_.push_back( rb_jump );
110  moves::Mover::type( "DockMCMCycle" );
111  set_default();
112 }
113 
114 // constructor with arguments
115 // only one movable jump, scoring and packing defined
117  DockJumps const movable_jumps,
119  core::scoring::ScoreFunctionOP scorefxn_pack
120 ) : Mover(), scorefxn_(scorefxn), scorefxn_pack_(scorefxn_pack)
121 {
123  moves::Mover::type( "DockMCMCycle" );
124  set_default();
125 }
126 
127 //destructor
129 
130 //clone
132  return new DockMCMCycle(*this);
133 }
134 
135 void
137 {
138  tf_ = new core::pack::task::TaskFactory( *tf );
139 }
140 
142 {
143 
144  using namespace basic::options; //quick hack by rhiju
145  using namespace basic::options::OptionKeys::docking; // quick hack by rhiju -- later feed this in through dockingprotocol
146 
147  trans_magnitude_ = 0.1;
148  rot_magnitude_ = 5.0;
149 
150  rtmin_ = false;
151  scmin_ = false;
152 
153  // setup scoring with defaults
154  if ( scorefxn_() == NULL ) {
157  }
158 
159  // setup the movemap
161  movemap_->set_chi( false );
162  movemap_->set_bb( false );
163  for ( DockJumps::const_iterator it = movable_jumps_.begin(); it != movable_jumps_.end(); ++it ) {
164  movemap_->set_jump( *it, true );
165  }
166 
167  // perhaps call this dock_minimize_bb_res or something.
168  if ( option[ bb_min_res ].user() ){
169  utility::vector1< Size > const & min_res = option[ bb_min_res ]();
170  for ( Size n = 1; n <= min_res.size(); n++ ) movemap_->set_bb( min_res[n], true );
171  }
172  if ( option[ sc_min_res ].user() ){
173  utility::vector1< Size > const & min_res = option[ sc_min_res ]();
174  for ( Size n = 1; n <= min_res.size(); n++ ) movemap_->set_chi( min_res[n], true );
175  }
176 
177 
178 
179  // setup values for minimization
180  min_tolerance_ = 0.01;
181  min_type_ = std::string( "dfpmin_armijo_nonmonotone" );
182  nb_list_ = true;
183 
184  // setup the mc object
185  mc_ = new moves::MonteCarlo( *scorefxn_, 0.8 );
187 
188  // packing information
189  repack_period_ = 8;
190 }
191 
193 ////////////////////////////////////////////////////////////////////////////////
194 /// @begin docking high resolution apply function
195 /// @brief
196 /// @detailed
197 /// decides what to call according to options
199 {
200  TR.Debug << "in DockMCMCycle.apply" << std::endl;
201 // protocols::moves::PyMolMover pymol; //JQX: comment out, pymolmover will use the random number, not good for debug
202 
203  // only set up on first call to the mover
204  if ( ! dock_mcm_cycle_ )
205  {
206  init_mc(pose);
207  }
208 
209  dock_mcm_cycle_->apply( pose );
210 // pymol.apply( pose ); //JQX: comment out
211 // pymol.send_energy( pose ); //JQX: comment out
212 }
213 
216  return "DockMCMCycle";
217 }
218 
219 //JQX: reset the pack_cycle_ index
221 {
222  dock_mcm_cycle_->reset_cycle_index();
223 }
224 
226 {
227  /// It is possible for the MonteCarlo instance to be shared among several movers
228  /// in other protocols and we do not want to overwrite the history of that instance,
229  /// but we must ensure the MonteCarlo instance is ready for use.
230  if ( mc_->last_accepted_pose().empty() )
231  {
232  (*scorefxn_)(pose);
233  mc_->reset( pose );
234  }
235  setup_protocol( pose );
236  TR << "Setting up defaults for DockMCMCycle: " << std::endl;
237  show(TR);
238 }
239 
240 ///////////////////////////////////////////////////////////////////////////////////
241 /// @begin dock_mcm_protocol
242 ///
243 /// @brief main entrance to do monte carlo minimization
244 /// @detailed
245 /// single cycle of mcm minimization. Then it is rigid-body minimized
246 /// to a stringent tolerance.
247 ///
248 /// @remarks
249 ///
250 /// @references docking_mcm_protocol from docking_minimize.cc
251 /// pose_docking_monte_carlo_minimize from pose_docking.cc
252 ///
253 /// @authors Monica Berrondo
254 ///
255 /// @last_modified August 19 2010
256 /////////////////////////////////////////////////////////////////////////////////
258  using namespace moves;
259  using namespace basic::options;
260  using namespace core::pack::task;
261  using namespace core::pack::task::operation;
262  using namespace protocols::toolbox::task_operations;
263 
264  //JQX: set up rigid body movers
266 
267 
268  //set up sidechain movers for each movable jump
269  // tf_->push_back( new RestrictToInterface( movable_jumps_ ) );
270  // JQX commented this out, there is one more RestrictToInterface function in the DockTaskFactory.cc file
271 
272 
274  SequenceMoverOP rb_pack_min = new SequenceMover;
275 
276  rb_pack_min->add_mover( rb_mover );
277  rb_pack_min->add_mover( rottrial );
278 
279 
280  //JQX: use (SequenceMover) rb_pack_min and (MinMover) min_mover
281  //JQX: to define the JumpOutMover
282  core::Real minimization_threshold = 15.0;
284  JumpOutMoverOP rb_mover_min = new JumpOutMover( rb_pack_min, min_mover, scorefxn_, minimization_threshold );
285 
286 
287  //JQX: (JumpOutMover) rb_mover_min should be a TrialMover
288  TrialMoverOP rb_mover_min_trail = new TrialMover( rb_mover_min, mc_);
289 
290 
291  //JQX: define the SequenceMover repack_step
292  //JQX: repack_step is almost the same as rb_mover_min_trail
293  //JQX: the only difference is you have one more step: (TrialMover) the pack_interface_and_loops_trial
294  //JQX: the TrialMover is actually ... (PackRotamersMover) pack_rotamers
295  SequenceMoverOP repack_step = new SequenceMover;
296  repack_step->add_mover(rb_mover_min_trail);
298  pack_rotamers->task_factory(tf_);
299  TrialMoverOP pack_interface_and_move_loops_trial = new TrialMover( pack_rotamers, mc_);
300  repack_step->add_mover(pack_interface_and_move_loops_trial);
301 
302 
303 
304 
305  // these are not being used at all in the extreme code week, JQX incorporated into the sequence
306  if(rtmin_){
308  TrialMoverOP rtmin_trial = new TrialMover( rtmin, mc_ );
309  repack_step->add_mover(rtmin_trial);
310  }
311  if(scmin_){
313  //@TODO JQX: this is so weird, I cannot directly put tf_ to construct the SideChainMinMover
315  TrialMoverOP scmin_trial = new TrialMover( scmin_mover, mc_ );
316  repack_step->add_mover(scmin_trial);
317  }
318 
319  //JQX: define the cycle mover
320  //JQX: 1. rb_mover_min_trail (7 times)
321  //JQX: 2. repack_tep (1 time)
323  for (Size i=1; i<repack_period_; ++i) dock_mcm_cycle_->add_mover( rb_mover_min_trail );
324  dock_mcm_cycle_->add_mover( repack_step );
325 
326 
327 }
328 
329 /// @details Show the complete setup of the docking protocol
330 void
331 DockMCMCycle::show( std::ostream & out ) const {
332  out << *this;
333 }
334 
335 std::ostream & operator<<(std::ostream& out, const DockMCMCycle & dp )
336 {
337  using namespace ObjexxFCL::fmt;
338 
339  // All output will be 80 characters - 80 is a nice number, don't you think?
340  std::string line_marker = "///";
341  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
342  // Display the movable jumps that will be used in docking
343  out << line_marker << " Dockable Jumps: ";
344 
345  core::Size spaces_so_far = 23;
346  bool first = true;
347  for ( DockJumps::const_iterator it = dp.movable_jumps_.begin() ; it != dp.movable_jumps_.end() ; ++it ){
348  if (!first) {
349  out << ", ";
350  spaces_so_far += 2;
351  }
352  else first = false;
353 
354  out << I( 1, *it );
355  spaces_so_far += 1;
356  }
357  core::Size remaining_spaces = 80 - spaces_so_far;
358  if ( remaining_spaces > 0 ) out << space( 80 - spaces_so_far );
359  out << line_marker << std::endl;
360 
361  // Display the translation, and rotation of the cycle
362  out << line_marker << " Translation: " << dp.trans_magnitude_<< space( 57 ) << line_marker << std::endl;
363  out << line_marker << " Rotation: " << dp.rot_magnitude_ << space( 62 ) << line_marker << std::endl;
364  out << line_marker << " Scorefunction: " << space( 58 ) << line_marker << std::endl;
365  dp.scorefxn_->show(out);
366  out <<std::endl;
367  out << line_marker << " Packing scorefunction: " << space( 50 ) << line_marker << std::endl;
368  dp.scorefxn_pack_->show(out);
369  out << std::endl;
370 
371  // Close the box I have drawn
372  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
373  return out;
374 }
375 
377 {
378  return movable_jumps_;
379 }
380 
381 } // namespace docking
382 } // namespace protocols