Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SmallMinCCDTrial.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
6 // (c) under license. The Rosetta software is developed by the contributing
7 // (c) members of the Rosetta Commons. For more information, see
8 // (c) http://www.rosettacommons.org. Questions about this can be addressed to
9 // (c) University of Washington UW TechTransfer,email:license@u.washington.edu.
10 
11 /// @file protocols/loops/loop_mover/refine/LoopRefineInnerCycle.cc
12 /// @brief Perform a small move followed CCD closure, packing and minimization
13 /// @detailed
14 ///
15 /// @author Brian D. Weitzner ( brian.weitzner@gmail.com )
16 
17 // Unit headers
20 
21 // Package headers
25 #include <protocols/loops/Loop.hh>
26 #include <protocols/loops/Loops.hh>
27 
28 // Project headers
36 #include <core/pose/Pose.hh>
38 #include <core/scoring/Energies.hh>
42 
43 // Basic headers
44 #include <basic/Tracer.hh>
45 
46 // Utility headers
47 #include <utility/excn/Exceptions.hh>
48 
49 // ObjexxFCL headers
50 #include <ObjexxFCL/format.hh>
51 
52 // C++ headers
53 #include <fstream>
54 
55 static basic::Tracer TR("protocols.loops.loop_mover.refine.SmallMinCCDTrial");
56 
57 namespace protocols {
58 namespace loops {
59 namespace loop_mover {
60 namespace refine {
61 
62 ///////////////////////////////////////////////////////////////////////////////////////////////////////
63 ////////////////////////////////////////////// BOILER PLATE CODE //////////////////////////////////////
64 ///////////////////////////////////////////////////////////////////////////////////////////////////////
65 
66 ///@brief default constructor
68 {
69  init();
70 }
71 
72 ///@brief copy constructor
74 {
76 }
77 
78 ///@brief assignment operator
80  //abort self-assignment
81  if ( this == &rhs ) return *this;
84  return *this;
85 }
86 
87 //destructor
89 
90 /// @brief Each derived class must specify its name.
92 {
93  return type();
94 }
95 
96 //@brief clone operator, calls the copy constructor
99 {
100  return new SmallMinCCDTrial( *this );
101 }
102 
103 ///@brief fresh_instance returns a default-constructed object for JD2
106 {
107  return new SmallMinCCDTrial();
108 }
109 
110 ///@brief This mover retains state such that a fresh version is needed if the input Pose is about to change
112 {
113  return true;
114 }
115 
117 {
118  /// PUT THE LIST OF OPTIONS THAT ARE USED HERE ///
119 
120  /// RECURSIVELY CALL REGISTER OPTIONS ON ALL MOVERS THAT THIS CLASS HAS AN OWNING_PTR TO ///
121 }
122 ///////////////////////////////////////////////////////////////////////////////////////////////////////
123 /////////////////////////////////////// END OF BOILER PLATE CODE //////////////////////////////////////
124 ///////////////////////////////////////////////////////////////////////////////////////////////////////
125 
126 // constructor with arguments
128  LoopMover_Refine_CCDAP loop_mover,
132 ) : LoopRefineInnerCycle( loop_mover, mc, scorefxn, tf )
133 {
134  init();
135 }
136 
138 {
142 
143  // TR << "Beginning apply function of " + get_name() + "." << std::endl;
144 
145  setup_objects( pose );
146 
147  // show( TR );
148 
149  // TODO: Determine if set_bumb_check can be done at the TaskFactory level and do it there if possible.
150  // TODO: If not, make these two lines a function so I can't mess this up.
151  PackerTaskOP task_before_bb_perturbation = task_factory()->create_task_and_apply_taskoperations( pose );
152  task_before_bb_perturbation->set_bump_check( true );
153 
154  LoopsOP all_loops = loop_mover()->loops();
155  Loops one_loop = get_one_random_loop();
156 
157  // set up movemap for one loop
158  MoveMapOP one_loop_movemap = movemap();
159  loop_mover()->setup_movemap( pose, one_loop, task_before_bb_perturbation->repacking_residues(), one_loop_movemap );
160 
161  debug_zero( pose );
162 
163  simple_moves::SmallMover small_moves( one_loop_movemap, mc()->temperature(), nmoves_ );
164  small_moves.apply( pose );
165 
166  debug_one( pose );
167 
168 
169  if (! one_loop[ one_loop.size() ].is_terminal( pose ) ) ccd_close_loops( pose, one_loop, *one_loop_movemap);
170 
171  debug_two( pose );
172 
173  // TODO: Determine if set_bumb_check can be done at the TaskFactory level and do it there if possible.
174  // TODO: If not, make these two lines a function so I can't mess this up.
175  PackerTaskOP task_after_bb_perturbation = task_factory()->create_task_and_apply_taskoperations( pose );
176  task_after_bb_perturbation->set_bump_check( true );
177  rotamer_trials( pose, *scorefxn(), task_after_bb_perturbation );
178  debug_three( pose );
179 
180 
181  MoveMapOP all_loops_movemap = movemap();
182  loop_mover()->setup_movemap( pose, *all_loops, task_after_bb_perturbation->repacking_residues(), all_loops_movemap );
183 
184  if ( loop_mover()->flank_residue_min() )
185  {
186  add_loop_flank_residues_bb_to_movemap(*all_loops, *all_loops_movemap);
187  }
188 
189  minimizer( pose )->run( pose, *all_loops_movemap, *scorefxn(), *minimizer_options_ );
190 
191  debug_four( pose );
192 
193  std::string move_type = "small_ccd_min";
194  mc()->boltzmann( pose, move_type );
195 
196  debug_five( pose );
197 
198  mc()->show_scores();
199 }
200 
201 
203 {
204  // TR << "Setting up data for " + get_name() + "." << std::endl;
205 
207 }
208 
210 {
212  type( "SmallMinCCDTrial" );
213 
214  nmoves_ = 1;
215  minimizer_options_ = new MinimizerOptions( "dfpmin", 0.001, true /*use_nblist*/, false /*deriv_check*/ );
216  init_options();
217 }
218 
220  SmallMinCCDTrial & lhs,
221  SmallMinCCDTrial const & rhs
222 )
223 {
224  // copy all data members from rhs to lhs
225  lhs.minimizer_ = rhs.minimizer_;
226 }
227 
229 {
230  /* UNCOMMENT WHEN THERE ARE ACTUALLY OPTIONS TO PROCESS
231  using basic::options::option;
232  using namespace basic::options::OptionKeys;
233  */
234  // Set options here.
235 }
236 
238 {
239  // minimizer
240  if (! minimizer_){
241  if ( core::pose::symmetry::is_symmetric( pose ) ) {
243  } else {
245  }
246  }
247  return minimizer_;
248 }
249 
251 {
252  return nmoves_;
253 }
254 
256 {
257  nmoves_ = nmoves;
258 }
259 
261 {
262  return minimizer_options_;
263 }
264 
266 {
267  if ( minimizer_options ) minimizer_options_ = minimizer_options;
268 }
269 
270 void
271 SmallMinCCDTrial::show( std::ostream & out )
272 {
273  out << *this;
274 }
275 
276 std::ostream & operator<<(std::ostream& out, SmallMinCCDTrial const & small_min_ccd_trial )
277 {
278  out << small_min_ccd_trial.get_name() << " is an awesome class." << std::endl;
279  return out;
280 }
281 
282 ///////////////////////////////////////////////////////////////////////////////////////////////////////
283 /////////////////////////////////////// EXCESSIVE DEBUGGING OUTPUT ////////////////////////////////////
284 ///////////////////////////////////////////////////////////////////////////////////////////////////////
286 {
287  if ( debug() ) {
288  TR << "chutmp-debug small_move-0: " << " " << (*scorefxn())(pose) << std::endl;
289  TR << "small_move-0: " << pose.energies().total_energies().weighted_string_of( scorefxn()->weights() )
290  << " rmsd: " << ObjexxFCL::fmt::F(9,3,loop_rmsd( pose, *get_native_pose(), *loop_mover()->loops() )) << std::endl;
291  pose.dump_pdb("small_move-0.pdb");
292  }
293 
294 }
295 
297 {
298  if ( debug() ) {
299  TR << "chutmp-debug small_move-1: " << " " << (*scorefxn())(pose) << std::endl;
300  TR << "small_move-1: " << pose.energies().total_energies().weighted_string_of( scorefxn()->weights() )
301  << " rmsd: " << ObjexxFCL::fmt::F(9,3,loop_rmsd( pose, *get_native_pose(), *loop_mover()->loops() )) << std::endl;
302  pose.dump_pdb("small_move-1.pdb");
303  std::ofstream out("score.small_move_1");
304  out << "scoring of input_pose " << (*scorefxn())(pose) << std::endl;
305  scorefxn()->show( out );
306  out << pose.energies();
307  }
308 }
309 
311 {
312  if ( debug() ) {
313  TR << "chutmp-debug small_move-2: " << " " << (*scorefxn())(pose) << std::endl;
314  TR << "small_move-2: " << pose.energies().total_energies().weighted_string_of( scorefxn()->weights() )
315  << " rmsd: " << ObjexxFCL::fmt::F(9,3,loop_rmsd( pose, *get_native_pose(), *loop_mover()->loops() )) << std::endl;
316  pose.dump_pdb("small_move-2.pdb");
317  std::ofstream out("score.small_move_2");
318  out << "scoring of input_pose " << (*scorefxn())(pose) << std::endl;
319  scorefxn()->show( out );
320  out << pose.energies();
321  }
322 }
323 
325 {
326  if ( debug() ) {
327  TR << "chutmp-debug small_move-3: " << " " << (*scorefxn())(pose) << std::endl;
328  TR << "small_move-3: " << pose.energies().total_energies().weighted_string_of( scorefxn()->weights() )
329  << " rmsd: " << ObjexxFCL::fmt::F(9,3,loop_rmsd( pose, *get_native_pose(), *loop_mover()->loops() )) << std::endl;
330  pose.dump_pdb("small_move-3.pdb");
331  }
332 }
333 
335 {
336  if ( debug() ) {
337  TR << "chutmp-debug small_move-4: " << " " << (*scorefxn())(pose) << std::endl;
338  TR << "small_move-4: " << pose.energies().total_energies().weighted_string_of( scorefxn()->weights() )
339  << " rmsd: " << ObjexxFCL::fmt::F(9,3,loop_rmsd( pose, *get_native_pose(), *loop_mover()->loops() )) << std::endl;
340  pose.dump_pdb("small_move-4.pdb");
341  }
342 }
343 
345 {
346  if ( debug() ) {
347  TR << "chutmp-debug small_move-5: " << " " << (*scorefxn())(pose) << std::endl;
348  TR << "small_move-5: " << pose.energies().total_energies().weighted_string_of( scorefxn()->weights() )
349  << " rmsd: " << ObjexxFCL::fmt::F(9,3,loop_rmsd( pose, *get_native_pose(), *loop_mover()->loops() )) << std::endl;
350  pose.dump_pdb("small_move-5.pdb");
351  }
352 }
353 
354 ///////////////////////////////////////////////////////////////////////////////////////////////////////
355 ////////////////////////////////////// END OF EXCESSIVE DEBUG OUTPUT //////////////////////////////////
356 ///////////////////////////////////////////////////////////////////////////////////////////////////////
357 
359 
361  return new SmallMinCCDTrial();
362 }
363 
365  return "SmallMinCCDTrial";
366 }
367 
368 } // namespace refine
369 } // namespace loop_mover
370 } // namespace loops
371 } // namespace protocols