Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FragmentSampler.hh
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 src/protocols/abinitio/FragmentSampler.hh
11 /// @brief header file for FragmentSampler protocol
12 /// @detailed
13 /// Contains currently: Classic Abinitio
14 ///
15 ///
16 /// @author Oliver Lange
17 /// @author James Thompson
18 /// @author Mike Tyka
19 
20 
21 #ifndef INCLUDED_protocols_abinitio_FragmentSampler_hh
22 #define INCLUDED_protocols_abinitio_FragmentSampler_hh
23 
25 
26 
27 // Unit Headers
28 
29 //#include <core/io/silent/SilentFileData.hh>
30 //#include <core/io/silent/SilentFileData.fwd.hh>
31 //#include <core/io/silent/SilentStructFactory.hh>
32 
33 // AUTO-REMOVED #include <protocols/simple_moves/FragmentMover.fwd.hh>
35 #include <protocols/moves/Mover.hh>
37 
38 #include <core/pose/Pose.fwd.hh>
39 // AUTO-REMOVED #include <core/kinematics/MoveMap.fwd.hh>
40 #include <core/types.hh>
43 //#include <core/pack/task/PackerTask.fwd.hh>
44 
45 // AUTO-REMOVED #include <protocols/abinitio/Protocol.hh>
46 // AUTO-REMOVED #include <protocols/moves/TrialMover.hh>
47 
48 // ObjexxFCL Headers
49 
50 // Utility headers
51 #include <utility/pointer/ReferenceCount.hh>
52 #include <basic/prof.hh>
53 #include <utility/exit.hh>
54 
55 //// C++ headers
56 // AUTO-REMOVED #include <cstdlib>
57 #include <string>
58 #include <vector>
59 
61 #include <utility/vector1.hh>
62 
63 
64 namespace protocols {
65 namespace abinitio {
66 
67 /// Move these forward declarations to FragmentSampler.fwd.hh
68 class FragmentSampler;
70 
71 //@ brief The Classic Abinitio protocol from rosetta++
72 /*!
73 @ detail
74 general usage:
75 FragmentSampler abinitio;
76 abinitio.init( pose );
77 ...
78 while(nstruct) {
79  abinitio.apply( pose );
80 }
81 
82 call FragmentSampler::register_options() before core::init to add relevant options to the applications help
83 
84 , with the following
85 stages, all of which uses a different ScoreFunction based on the cen_std.wts in minirosetta_database:
86 
87 - Stage 1: large (usually 9mer) randomly selected fragment insertions, only VDW term turned on.
88 Uses score0.wts_patch and runs for either a maximum of 2000 cycles or until all moveable phi/psi values
89 have been changed.
90 
91 - Stage 2: large randomly selected fragment insertions, more score terms turned on. Uses score1.wts_patch
92 and runs for 2000 cycles.
93 
94 - Stage 3: uses large randomly selected fragment insertions, although the size of the fragment insertions
95 is tunable via the set_apply_large_frags( bool ) method. Alternates between score2.wts_patch and score5.wts_patch,
96 running tunable numbers of 2000-cycle iterations between the two scoring functions.
97 
98 - Stage 4: uses small (usually 3mer) fragment insertions with the fragment selection based on the Gunn cost for
99 finding local fragment moves. Runs for 4000-cycles and uses score3.wts_patch.
100 
101 The class implements the basic abinito approach as known from rosetta++. We tried to set this up, such that
102 behaviour of the protocol can be changed in many different ways ( see, e.g., FoldConstraints ). To be able to change the
103 behaviour of the protocol easily the class-apply function and methods called therein (e.g., prepare_XXX() / do_XXX_cycles() ) should
104 not directly change moves or trials. A reference to the currently used score-function should be obtained by
105 mc().score_function() ...
106 
107 Behaviour can be changed in the following ways:
108 
109 use non-classic FragmentMover --> eg. not uniformly sampled fragments, but using some weighting
110  --> large and small moves doesn't have to be 3mers and 9mers... use other movers...
111  ---> or other fragets for the "convenience constructor"
112 use custom trial classes --> overload update_moves()
113 
114 change sampling behaviour:
115  overload prepare_XXX() methods: these are called before the cycling for a certain stage begins
116  overload do_stageX_cycles() : the actual loops over trial-moves ...
117 
118 change scoring functions:
119  overload set_default_scores()
120  weight-changes effective for all stages: set_score_weight()
121 
122 */
123 
124 
125 class FragmentSampler : public moves::Mover { //when changing to new jobdist ====> public moves::Mover {
127  typedef moves::Mover BaseClass; //happens to be same as Parent
128 
129 public:
130  virtual ~FragmentSampler();
131  //@brief register cmd-line options in option system ( call before core::init )
132  static void register_options();
133 
134  ///@brief This constructor does not work -- Fix it before using it.
135  // constructor: supply mover classes for Fragment Moves
137 
138  //@brief FragmentSampler has virtual functions... use this to obtain a new instance
139  virtual
140  moves::MoverOP clone() const;
141 
142  //@brief run protocol on pose
143  virtual void apply( core::pose::Pose & pose );
144  virtual std::string get_name() const;
145 
146  //@brief override cycle setting ( init() -> sets it according to cmd-line options )
147  virtual void set_cycles( core::Real increase_cycles = 1.0 );
148 
149  //@brief set weight - effective for all scoring functions stage == -1 --> set weight for all stages
150  // mod -1 (ignored) , in stage3 mod = 1 --> 3a , mod = 2 --> 3b
151  virtual void set_score_weight( core::scoring::ScoreType, core::Real setting, StageID stage = ALL_STAGES );
152 
154 
155  // void output_debug_structure( core::pose::Pose&, std::string file_tag ); //make part of Mover class
156 
158 
159  //@brief currently used score function ( depends on stage ) -- publich
161 
162 
163 protected:
165 
166  //@brief set new monte-carlo object
167  void set_mc( moves::MonteCarloOP );
168 
169  //@brief obtain currently used monte-carlo object --> use to obtain current score-func: mc().score_function()
171  return *mc_;
172  }
173 
174  //@brief obtain currently used monte-carlo object --> use to obtain current score-func: mc().score_function()
175  moves::MonteCarlo const& mc() const {
176  return *mc_;
177  }
178 
179  //@brief called by constructor --- calls all set_default_XXX methods
180  void set_defaults();
181 
182  //@brief set current scorefunction
183  void current_scorefxn( core::scoring::ScoreFunction const& scorefxn );
184 
185  //@brief If appropriate for the stage then recover low mc.
186  void recover_low( core::pose::Pose& pose, StageID stage );
187 
188  //@brief this is called if the scorefxn is replaced with a new one
189  virtual void replace_scorefxn( core::pose::Pose& pose, StageID stage, core::Real intra_stage_progress );
190 
191  //@brief set individual weight of current scorefunction
192  //@details NOTE: does not change the predefined weights, this information is lost each time the score is set
193  // weight will be overwritten with default ->at beginning of stages, each iteration of loop in stage3
194  // we could change this behaviour by having a pointer to the current score and making sure that nobody can
195  // change the score inside the mc-object (only const accessor )
197 
198  //@brief run cycles for different scoring_stages, return number of steps used
199  virtual void do_stage1_cycles( core::pose::Pose &pose );
200  virtual void do_stage2_cycles( core::pose::Pose &pose );
201  virtual void do_stage3_cycles( core::pose::Pose &pose );
202  virtual void do_stage4_cycles( core::pose::Pose &pose );
203 
204  //@brief returns true if pose is < 3.0 A rms to last pose sent to this function
205  // bool convergence_check( core::pose::Pose const & pose );
206 
207  virtual moves::MoverOP
208  mover( core::pose::Pose const& pose, StageID stage_id, core::scoring::ScoreFunction const& scorefxn, core::Real progress = 1.0 );
209 // //@brief returns the Mover that is applied inside the stage1 loop
210 // virtual moves::MoverOP
211 // stage1_mover( core::pose::Pose const& pose );
212 
213 // //@brief returns the Mover that is applied inside the stage3 double loop
214 // virtual moves::MoverOP
215 // stage2_mover( core::pose::Pose const& pose );
216 
217 // //@brief returns the Mover that is applied inside the stage3 double loop
218 // virtual moves::MoverOP
219 // stage3_mover( core::pose::Pose const& pose, core::Size lct1, core::Size lct2 );
220 
221 // //@brief returns the Mover that is applied inside the stage4 loop
222 // virtual moves::MoverOP
223 // stage4_mover( core::pose::Pose const& pose, core::Size kk );
224 
225 
226  //@brief called by update_moves() creates the instances of TrialMover with the FragmentMoves
227  //virtual void set_trials();
228 
229  // anything you want to have done before the stages ?
230  //@brief prepare_stageX is called before do_stageX_cycles... overload to change status/scoring/conformation....
231  virtual void prepare_stage1( core::pose::Pose &pose );
232  virtual void prepare_stage2( core::pose::Pose &pose );
233  virtual void prepare_stage3( core::pose::Pose &pose );
234  virtual void prepare_stage4( core::pose::Pose &pose );
235 
236  //@brief called in each iteration of inner loop in stage3 before stage3_cycles_ of trials commence
237  virtual void prepare_loop_in_stage3(
239  Size, /* loop_iteration*/
240  Size /* total_iterations */
241  );
242 
243  //@brief called in each iteration of the loop in stage4 before the stage4_cycles_ of trials commence
244  virtual void prepare_loop_in_stage4(
246  Size, /* loop_iteration*/
247  Size /* total_iterations */
248  );
249 
250 public:
251  //@brief accessor for boolean flag: just_smooth_cycles
252  inline
253  bool just_smooth_cycles() const {
254  return just_smooth_cycles_;
255  }
256 
257  //@brief Accessor for number of stage1 cycles
258  inline
260  return stage1_cycles_;
261  }
262 
263  //@brief Accessor for number of stage2
264  inline
266  return stage2_cycles_;
267  }
268 
269  //@brief Accessor for number of stage3 cycles
270  inline
272  return stage3_cycles_;
273  }
274 
275  //@brief Setter for number of stage4 cycles
276  inline
277  void set_stage4_cycles( core::Size stage4_cycles_new) {
278  stage4_cycles_ = stage4_cycles_new;
279  }
280 
281  //@brief Accessor for number of stage4 cycles
282  inline
284  return stage4_cycles_;
285  }
286 
287  //@brief query this flag if you have time-intensive stuff and cut it short
288  bool bQuickTest() const {
289  return bQuickTest_;
290  }
291 
292 private:
293 
294  // made these set_default methods private since they are not virtual. call set_defaults() to get everything set up
295  //@brief read out cmd-line options
296  void set_default_options();
297 
298  //@brief assigns default score-functions to the 4 stages--> score0 / score1 / (score2/score5) / score3
299  void set_default_scores();
300 
301  //@brief construct default monto-carlo object
302  void set_default_mc( core::scoring::ScoreFunction const& scorefxn );
303 
304 
306 
307 protected:
308 
309  //@brief obtain currently used monte-carlo object --> use to obtain current score-func: mc().score_function()
311  return mc_;
312  }
313 
314  //@brief cycles_numbers -- modified by set_cycles(), set_default_options()
317  Size stage3_cycles_; //score25
319 
320 private:
321  //@brief scoring functions -- modified by set_default_scores() / set_score_weight()
327 
328  //@brief flags
329  bool apply_large_frags_; //above contig_cut2
330  bool short_insert_region_; //below contig_cut3
332  bool bQuickTest_; // this flag might land in base-class
333 
334  //@brief a temperature
336 
337  //@brief a MonteCarlo object -- set_default_mc() , access: mc()
339 
341 
343 
345 
348 
349 private:
350  static std::string const id2string_[];
351  static basic::ProfTag const id2proftag_[];
352 
354  assert( id < LAST_STAGE );
355  return id2string_[ id ];
356  }
357 
358  basic::ProfTag id2proftag( StageID id ) {
359  assert( id < LAST_STAGE );
360  return id2proftag_[ id ];
361  }
362 };
363 
364 } // abinitio
365 } // protocols
366 
367 #endif