Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DockingLowRes.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 DockingLowRes
11 /// @brief protocols that are specific to docking low resolution
12 /// @detailed
13 /// @author Monica Berrondo
14 /// @author Modified by Sergey Lyskov
15 /// @author Modified by Jacob Corn
16 /// @author Modified by Daisuke Kuroda
17 
19 
20 // Rosetta Headers
22 
23 // AUTO-REMOVED #include <basic/options/option.hh>
24 // AUTO-REMOVED #include <basic/options/keys/OptionKeys.hh>
25 
26 // AUTO-REMOVED #include <core/kinematics/FoldTree.hh>
27 
28 #include <core/pose/Pose.hh>
29 
31 
33 #include <protocols/moves/Mover.hh>
34 // AUTO-REMOVED #include <protocols/moves/OutputMovers.hh>
39 
40 // Utility Headers
41 #include <utility/tools/make_vector1.hh>
42 
43 // ObjexxFCL Headers
44 #include <ObjexxFCL/string.functions.hh>
45 #include <ObjexxFCL/format.hh>
46 
47 // C++ Headers
48 #include <string>
49 
50 //Utility Headers
51 // AUTO-REMOVED #include <numeric/conversions.hh>
52 
53 #include <numeric/trig.functions.hh>
54 #include <numeric/xyzMatrix.fwd.hh>
55 
56 #include <basic/Tracer.hh>
57 
59 #include <utility/vector0.hh>
60 #include <utility/vector1.hh>
61 
62 using basic::T;
63 using basic::Error;
64 using basic::Warning;
65 
66 static basic::Tracer TR("protocols.docking.DockingLowRes");
67 
68 // originally from dock_structure.cc Jeff Gray April 2001
69 //
70 //
71 
72 using namespace core;
73 
74 namespace protocols {
75 namespace docking {
76 
77 // default constructor
78 DockingLowRes::DockingLowRes() :
79  Mover()
80 {
81  init(utility::tools::make_vector1<core::SSize>(1), NULL);
82 }
83 
84 
85 // constructor with arguments
88  core::Size const rb_jump
89 ) : Mover(), scorefxn_(scorefxn)
90 {
91  init(utility::tools::make_vector1<core::SSize>(rb_jump), scorefxn);
92 }
93 
96  DockJumps const movable_jumps
97 ) : Mover(), scorefxn_(scorefxn)
98 {
99  init(movable_jumps, scorefxn);
100 }
101 
103  DockJumps const movable_jumps,
105 )
106 {
107  moves::Mover::type( "DockingLowRes" );
108  movable_jumps_ = movable_jumps;
109 
110  // setup all the booleans with default values
111  // they will get overwritten by the options and/or passed values
112  set_default();
113 
114  if ( scorefxn() == NULL ) {
116  } else scorefxn_ = scorefxn;
117 
118  // set up objects based on the boolean values defined above
120 }
121 
122 
123 //destructor
125 
128  return new DockingLowRes(*this);
129 }
130 
131 
133  trans_magnitude_ = 0.7;
134  rot_magnitude_ = 5.0;
135  chi_ = false;
136  bb_ = false;
137 
138  temperature_ = 0.8;
139  nb_list_ = true; /// not sure if this should be true or not
140  accept_rate_ = 0.0;
141 
142  inner_cycles_ = 50;
143  outer_cycles_ = 10;
144 }
145 
147 {
148  rb_mover_ = NULL;
150 
151  // the movable dof's -- jumps only in this case
153  movemap_->set_chi( chi_ ); // is this right?
154  movemap_->set_bb( bb_ ); // is this right?
155  for( DockJumps::const_iterator it = movable_jumps_.begin(); it != movable_jumps_.end(); ++it ) {
156  movemap_->set_jump( *it, true );
157  }
158 
159  // setup the mc object
161 
164 }
165 
167 {
168  scorefxn_ = scorefxn;
169  // mc object score function is out of sync and needs to be recreated
171 }
172 
174  using namespace moves;
175 
177 
179  docking_lowres_protocol_->add_mover( rb_mover_ );
180 }
181 
182 ////////////////////////////////////////////////////////////////////////////////
183 /// @begin DockingLowRes.apply
184 ///
185 /// @brief Perform several cycles of rigid-body Monte Carlo moves
186 /// and adapt the step size.
187 /// @detailed
188 ///
189 /// @remarks
190 /// currently used only in the low-resolution step (centroid mode)
191 ///
192 /// @references pose_docking_centroid_rigid_body_adaptive from pose_docking.cc and
193 /// rigid_body_MC_cycle_adaptive from dock_structure.cc
194 ///
195 /// @authors Monica Berrondo October 22 2007
196 ///
197 /// @last_modified October 22 2007
198 /////////////////////////////////////////////////////////////////////////////////
200 {
201  using namespace scoring;
202 
203  //TR << "in " << name << "apply" << std::endl;
204  TR << "in DockingLowRes.apply" << std::endl;
205 
208  }
209 
211  finalize_setup( pose );
213  }
214 
215  /// since the mc object is created on construction, the pose must be passed to it
216  /// every time the mover is applied to ensure that the mc object is in sync with the pose
217  (*scorefxn_)( pose );
218  mc_->reset( pose );
219 
220  show( TR );
221 
222  TR << "::::::::::::::::::Centroid Rigid Body Adaptive:::::::::::::::::::" << std::endl;
223 
224  for ( core::Size i=1; i<=outer_cycles_; ++i) {
225  rigid_body_trial( pose );
226  if ( accept_rate_ < 0.5 ) {
227  trans_magnitude_ *= 0.9;
228  rot_magnitude_ *= 0.9;
229  } else {
230  trans_magnitude_ *= 1.1;
231  rot_magnitude_ *= 1.1;
232  }
233 // pose.energies().show( std::cout );
234  }
235  mc_->recover_low( pose );
236  TR.flush();
237 // pose.energies().show( std::cout );
238 }
239 
242  return type();
243 }
244 
245 ////////////////////////////////////////////////////////////////////////////////
246 /// @begin rigid_body_trial
247 ///
248 /// @brief Perform a cycle of rigid-body Monte Carlo moves
249 ///
250 /// @detailed Performs a number (nattempts) of MC rigid-body moves
251 /// (of size trans_magnitude, rot_magnitude). The number of successful
252 /// attempts is stored in accept_rate_ and used in adaptive trials.
253 ///
254 /// @remarks the success_rate defines
255 /// whether the translation/rotation size is increased or decreased for
256 /// the next cycle.
257 /// currently used only in the low-resolution step (centroid mode)
258 ///
259 /// @references pose_docking_rigid_body_trial from pose_docking.cc and
260 /// rigid_body_MC_cycle from dock_structure.cc
261 ///
262 /// @authors Monica Berrondo October 22 2007
263 ///
264 /// @last_modified October 22 2007
265 /////////////////////////////////////////////////////////////////////////////////
267 {
268  using namespace moves;
269 
270  // PDBDumpMoverOP dump = new PDBDumpMover("lowres_cycle_");
271  // dump->apply( pose );
272  // MCShowMoverOP mc_show = new MCShowMover( mc_ );
273  // mc_show->apply( pose );
274 
275  rb_mover_->rot_magnitude( rot_magnitude_ );
276  rb_mover_->trans_magnitude( trans_magnitude_ );
277 
279 // rb_trial->keep_stats_type( moves::all_stats );
280  rb_trial->keep_stats_type( accept_reject );
281 
282  RepeatMoverOP rb_cycle = new RepeatMover( rb_trial, inner_cycles_ );
283  rb_cycle->apply( pose );
284 
285  pose = mc_->lowest_score_pose();
286  mc_->reset( pose );
287 
288  accept_rate_ = rb_trial->acceptance_rate();
289 }
290 
292 
293 
294 /// @details Show the complete setup of the docking protocol
295 void
296 DockingLowRes::show( std::ostream & out ) const {
297  using namespace ObjexxFCL::fmt;
298 
299  // All output will be 80 characters - 80 is a nice number, don't you think?
300  std::string line_marker = "///";
301  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
302  out << line_marker << A( 47, " Docking Low Res Protocol" ) << space( 27 ) << line_marker << std::endl;
303  out << line_marker << space( 74 ) << line_marker << std::endl;
304 
305  // Display the number of inner cycles during low res docking
306  out << line_marker << " Centroid Inner Cycles: " << inner_cycles_ ;
307  out << space( 48 ) << line_marker << std::endl;
308 
309  // Display the number of outer cycles during low res docking
310  out << line_marker << " Centroid Outer Cycles: " << outer_cycles_;
311  out << space( 48 ) << line_marker << std::endl;
312 
313  // Display the state of the filters (on or off)
314  out << line_marker << " Scorefunction: " << space( 58 ) << line_marker << std::endl;
315  scorefxn_->show(out);
316  out <<std::endl;
317 
318  // Close the box I have drawn
319  out << "////////////////////////////////////////////////////////////////////////////////" << std::endl;
320 }
321 
322 std::ostream & operator<<(std::ostream& out, const DockingLowRes & dp)
323 {
324  dp.show( out );
325  return out;
326 }
327 
328 } // namespace docking
329 } // namespace protocols