Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DockMCMProtocol.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 DockMCMProtocol
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 
22 // Unit Headers
24 
25 // Package Headers
29 
30 // Project Headers
35 
37 // Utility Headers
38 #include <basic/Tracer.hh>
39 // AUTO-REMOVED #include <utility/tag/Tag.hh> // REQUIRED FOR WINDOWS
40 
41 #include <protocols/jd2/util.hh>
42 
43 #include <core/pose/Pose.hh> //JQX: dumping out pdb for testing
44 
45 #include <protocols/moves/TrialMover.fwd.hh> //JQX: add this
50 #include <ObjexxFCL/format.hh>
52 
53 #include <basic/options/keys/OptionKeys.hh>
54 #include <basic/options/option.hh>
55 #include <basic/options/keys/docking.OptionKeys.gen.hh>
56 // AUTO-REMOVED #include <core/pack/task/operation/TaskOperation.hh>
57 
59 #include <utility/exit.hh>
60 #include <utility/vector0.hh>
61 #include <utility/vector1.hh>
62 
63 
64 using basic::T;
65 using basic::Error;
66 using basic::Warning;
67 
68 static basic::Tracer TR("protocols.docking.DockMCMProtocol",basic::t_info);
69 
70 // originally from dock_structure.cc Jeff Gray April 2001
71 
72 using namespace core;
73 
74 namespace protocols {
75 namespace docking {
76 
77 // default constructor
78 DockMCMProtocol::DockMCMProtocol() : DockingHighRes( 1 )
79 {
80  init();
81 }
82 
83 // constructor with arguments
84 // only one movable jump
86  core::Size const rb_jump
87 ) : DockingHighRes(rb_jump)
88 {
89  init();
90 }
91 
92 // constructor with arguments
93 // only one movable jump, scoring and packing defined
95  core::Size const rb_jump,
97  core::scoring::ScoreFunctionOP scorefxn_pack
98 ) : DockingHighRes(rb_jump, scorefxn, scorefxn_pack)
99 {
100  init();
101 }
102 
103 // constructor with arguments
104 // only one movable jump, scoring and packing defined
106  DockJumps const movable_jumps,
108 ) : DockingHighRes(movable_jumps[1], scorefxn)
109 {
110  init();
111 }
112 
113 // constructor with arguments
114 // only one movable jump, scoring and packing defined
116  DockJumps const movable_jumps,
118  core::scoring::ScoreFunctionOP scorefxn_pack
119 ) : DockingHighRes(movable_jumps, scorefxn, scorefxn_pack)
120 {
121  init();
122 }
123 
124 //destructor
126 
128 
129 
130 //clone
132  return new DockMCMProtocol(*this);
133 }
134 
135 void
137 {
138  moves::Mover::type( "DockMCMProtocol" );
140  movemap_reset_ = false;
143 
144  using namespace basic::options;
145  using namespace basic::options::OptionKeys;
146 
147  if ( option[ OptionKeys::docking::dock_mcm_first_cycles ].user() ) {
148  set_first_cycle(option[ OptionKeys::docking::dock_mcm_first_cycles ]() );
149  }
150  if ( option[ OptionKeys::docking::dock_mcm_second_cycles ].user() ) {
151  set_second_cycle(option[ OptionKeys::docking::dock_mcm_second_cycles ]() );
152  }
153 
154 
155 }
156 
157 // JQX: rewrite the apply function
158 
159 ////////////////////////////////////////////////////////////////////////////////
160 /// @begin docking high resolution apply function
161 /// @brief
162 /// @detailed
163 /// decides what to call according to options
165 {
166 
167  using namespace scoring;
168 
169  TR.Info << "in DockMCMProtocol.apply" << std::endl;
170  TR.Debug << "fold-tree in DockMCM: " << pose.fold_tree() << std::endl;
171  (*scorefxn())( pose );
172  jd2::write_score_tracer( pose, "DockMCM_start" );
173 
175  if(movemap_reset_){
176  dock_mcm_->set_move_map(movemap_);
177  }
178  //check if we are ignoring the default docking task
179  if( !ignore_default_task() ){
180  TR << "Using the DockingTaskFactory." << std::endl;
181  tf2()->create_and_attach_task_factory( this, pose );
182  }
183  else {
184  TR <<"The default DockingTaskFactory is being ignored." << std::endl;
185  }
186  //Need a check to make sure there is a task HERE!!!
187  if( task_factory() != 0 ){
188  dock_mcm_->set_task_factory( task_factory() );
189  }
190  //exit if you chose to ignore the default task but didn't provide one of your own.
191  if( ignore_default_task() && !task_factory() ){
192  utility_exit_with_message( "Exiting DockMCMProtocol you chose to ignore_default_task but no alternate task was given to docking, " );
193  }
194 
195  //JQX: define the initial_pack, and this initial_pack was defined as a trial mover
197  initial_pack->score_function( scorefxn_pack() );
198  initial_pack->task_factory( task_factory() );
199  if ( dock_mcm_->get_mc()->last_accepted_pose().empty() ) { dock_mcm_->init_mc(pose); } //JQX: use the dock_mcm_'s "mc_" object
200  moves::TrialMoverOP initial_pack_trial = new moves::TrialMover(initial_pack, dock_mcm_->get_mc() );
201 
202 
203 
204  //JQX: rt_min and sc_min options were ignored in the extreme coding week, put them back now
206  initial_repack_sequence->add_mover(initial_pack_trial);
207 
208  if ( rt_min() ){
210  moves::TrialMoverOP rtmin_trial = new moves::TrialMover( rtmin, dock_mcm_->get_mc() );
211  initial_repack_sequence->add_mover(rtmin_trial);
212  dock_mcm_->set_rtmin(true);
213  }
214  if ( sc_min() ){
216  moves::TrialMoverOP scmin_trial = new moves::TrialMover( scmin_mover, dock_mcm_->get_mc() );
217  initial_repack_sequence->add_mover(scmin_trial);
218  dock_mcm_->set_scmin(true);
219  }
220 
221 
222  initial_repack_sequence->apply( pose );
223 
224 
225 
226  jd2::write_score_tracer( pose, "DockMCM_pack_trialed" );
227 
228  /// minimize_trial defaults to a min_tolerance of 0.01 in DockMinMover
229  DockMinMoverOP minimize_trial = new DockMinMover( movable_jumps(), scorefxn(), dock_mcm_->get_mc() );
230  minimize_trial->apply( pose );
231  jd2::write_score_tracer( pose, "DockMCM_minimized" );
232 
233 // filter_->set_score_margin( 10.0 );
234 // if ( filter_->apply( pose ) )
235 // {
236  for ( Size i=1; i<=num_of_first_cycle_; ++i ) {
237  dock_mcm_->apply( pose );
238  jd2::write_score_tracer( pose, "DockMCM_cycle_"+ObjexxFCL::fmt::I(1, i ) );
239  }
240 
241 // filter_->set_score_margin( 5.0 );
242 
243  dock_mcm_->reset_cycle_index(); //JQX: reset the CycleMover index to 0
244 
245 
246 // if ( filter_->apply( pose ) )
247 // {
248  for ( Size i=1; i<=num_of_second_cycle_; ++i ) {
249  dock_mcm_->apply( pose );
250  jd2::write_score_tracer( pose, "DockMCM_cycle_"+ObjexxFCL::fmt::I(1, i+4 ) );
251  }
252 // }
253 // }
254 
255 // filter_->set_score_margin( 0.0 );
256 
257 
258  minimize_trial->set_min_tolerance( 0.01 );
259  minimize_trial->apply( pose );
260 
261 //JQX: get the smallest energy pose memorized in the "mc_" object
262  dock_mcm_-> get_mc()->recover_low( pose );
263 
264  jd2::write_score_tracer( pose, "DockMCM_final" );
265 
266 }
267 
268 
269 
270 
272  movemap_reset_ = true;
273  movemap_ = movemap;
274 }
275 
277  num_of_first_cycle_ = num;
278 }
280  num_of_second_cycle_ = num;
281 }
282 
284  return scorefxn();
285 }
286 
288  return scorefxn_pack();
289 }
290 
293  return "DockMCMProtocol";
294 }
295 
296 std::ostream & operator<<(std::ostream& out, const DockMCMProtocol & dmp )
297 {
298  // Display the state of the filters (on or off)
299  out << "High Resolution Filter: " << ( (dmp.filter_) ? "on" : "off" ) << std::endl;
300  out << "Docking Scorefunction: " << dmp.scorefxn_docking()->get_name() << std::endl;
301  out << "Packing Scorefunction: " << dmp.scorefxn_packing()->get_name() << std::endl;
302  out << "Movemap: ";
303  if (dmp.movemap_ != 0) { out << std::endl; dmp.movemap_->show(); }
304  else { out << "none"; }
305  return out;
306 }
307 
308 } // namespace docking
309 } // namespace protocols