Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MoverContainer.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 MoverContainer.hh
11 /// @brief base class for containers of movers such as SequenceMover
12 /// @author Monica Berrondo
13 
14 
15 #ifndef INCLUDED_protocols_moves_MoverContainer_hh
16 #define INCLUDED_protocols_moves_MoverContainer_hh
17 
18 // Unit headers
20 #include <protocols/moves/Mover.hh>
21 
22 // Package headers
23 #include <core/types.hh>
24 #include <core/pose/Pose.fwd.hh>
25 
26 #include <utility/tag/Tag.fwd.hh>
29 
30 
31 
32 // C++ Headers
33 #include <map>
34 #include <string>
35 
36 // Utility Headers
37 #include <utility/vector0.hh>
38 #include <utility/vector1.hh>
39 #include <utility/pointer/ReferenceCount.hh>
40 
41 namespace protocols {
42 namespace moves {
43 
44 // A MoverContainer is an array of movers. Movers placed inside MoverContainers must be cloneable.
45 // you can either apply them randomly using a RandomOneMover
46 // or sequentially using a SequenceMover (see .cc for implementation)
47 // @todo relative weighting of the moves should be handled by this class
48 class MoverContainer : public Mover {
49 public:
50 
51  // constructor with arguments
53 
54  /// @brief to be called by derived-class clone() methods; copy all data from the source MoverContainer
55  MoverContainer( MoverContainer const & source );
56 
57  /// @brief Adds a mover to the end of this container
58  void add_mover( MoverOP mover_in, core::Real weight_in = 1.0 );
59 
60  std::string get_mover( core::Size index) const;
61 
62  void clear(){ movers_.clear(); };
63 
64  /// @brief Sets the input Pose for both the container
65  /// and the contained movers, for rmsd
66  virtual void set_input_pose( PoseCOP pose );
67 
68  // @brief Sets the native pose for both the container
69  // and the contained movers, for rmsd
70  virtual void set_native_pose( PoseCOP pose );
71 
72  virtual void apply( core::pose::Pose & pose ) = 0;
73  Size nr_moves() { return movers_.size(); };
74  Size size() const { return movers_.size(); };
75 
76  MoverOP front() { return movers_.front(); };
77 
79  return weight_;
80  }
81 
83  return movers_;
84  }
85 
86  friend std::ostream &operator<< (std::ostream &os, MoverContainer const &mover);
87 
88 protected:
89  // the weight is only used for RandomMover to pick which one is used, can this be changed?
90  utility::vector0< core::Real > weight_; ///< relative weight when part of MoverContainer.
92 
93 }; // MoverContainer class
94 
95 /// @brief A Mover that iterates through a vector of Movers,
96 /// applying each one sequentially
97 ///
98 /// Common Methods:
99 /// SequenceMover.add_mover
100 /// SequenceMover.apply
102 public:
103 
104  // constructor
105  /// @brief Constructs a SequenceMover
106  /// seqmover = SequenceMover()
107  SequenceMover( bool ms=false ) :
108  MoverContainer(),
109  use_mover_status_( ms )
110  {}
111 
112  /// @brief Copy constructor -- performs a deep copy of all contained movers. Invoked by clone()
113  SequenceMover( SequenceMover const & );
114 
115  /// @brief Convenience constructor: initial sequence of 2 movers
116  /// seqmover = SequenceMover( mover1 , mover2 )
117  ///
118  /// Mover mover1 /first mover to apply with SequenceMover.apply
119  /// Mover mover2 /second mover to apply with SequenceMover.apply
120  SequenceMover(MoverOP mover1, MoverOP mover2) :
121  MoverContainer(),
122  use_mover_status_( false )
123  {
124  add_mover(mover1);
125  add_mover(mover2);
126  }
127 
128  /// @brief Convenience constructor: initial sequence of 3 movers
129  /// seqmover = SequenceMover( mover1 , mover2 , mover3 )
130  ///
131  /// Mover mover1 /first mover to apply with SequenceMover.apply
132  /// Mover mover2 /second mover to apply with SequenceMover.apply
133  /// Mover mover3 /third mover to apply with SequenceMover.apply
134  SequenceMover(MoverOP mover1, MoverOP mover2, MoverOP mover3) :
135  MoverContainer(),
136  use_mover_status_( false )
137  {
138  add_mover(mover1);
139  add_mover(mover2);
140  add_mover(mover3);
141  }
142 
143  /// @brief deep copy of all contained movers.
144  virtual MoverOP clone() const;
145 
146  /// @brief MoverStatus of the mover will be evaluated after each mover
147  void use_mover_status( bool const flag ){
148  use_mover_status_ = flag;
149  }
150 
151  /// @brief
153 
154  /// @brief Applies a series of movers sequentially on a Pose
155  ///
156  /// example(s):
157  /// seqmover.apply(pose)
158  /// See also:
159  /// MinMover
160  /// RepeatMover
161  /// SequenceMover
162  /// TrialMover
163  virtual void apply( core::pose::Pose & pose );
164  virtual std::string get_name() const;
165 
166 private:
167 
168  /// @brief use mover status ( default false )
170 
171 }; // SequenceMover class
172 
173 
174 /// @brief RandomMover picks a random move and applies it
175 /// @details If nmoves is greater than 1, it repeats this process
176 /// nmoves times for each call to apply(). This mover supports
177 /// weights --- the individual moves are sampled with frequency
178 /// proportional to their weight given with add_mover( mover, weight );
179 class RandomMover : public MoverContainer {
180 public:
181 
182  // constructor
183  /// APL NOTE: Liz, I'm making up a value of "1.0" here, because you haven't set this value. Is this a reasonable initial value?
185 
186  /// @brief Copy constructor. Performs a deep copy of all contained movers.
187  RandomMover( RandomMover const & );
188 
189  virtual MoverOP clone() const;
190 
191  virtual void apply( core::pose::Pose & pose );
192  virtual std::string get_name() const;
193 
195 
196  //fpd Only making this MoverContainer parsile since the other MoverContainers already have an RS equivalent
197  void parse_my_tag(
198  utility::tag::TagPtr const tag,
202  core::pose::Pose const & );
203 
204 
205 private:
207  core::Real last_proposal_density_ratio_; //ek added this member 2/25/10
208 }; // RandomMover class
209 
210 // /// @brief WeightedRandomMover picks a random move and applies it.
211 // /// weights determine how often each move is selected.
212 // /// @details If nmoves is greater than 1, it repeats this process nmoves times for each call to apply().
213 // class WeightedRandomMover : public MoverContainer {
214 // public:
215 
216 // // constructor
217 // RandomMover() : MoverContainer(), nmoves_(1) {}
218 
219 // virtual void apply( core::pose::Pose & pose );
220 
221 // private:
222 // Size nmoves_;
223 // }; // RandomMover class
224 
225 
226 
227 /// @brief CycleMover iterates through its vector of Movers one at a time over many calls to apply().
228 /// @details Each time CycleMover.apply() is called, it calls apply() on the next Mover in its sequence,
229 /// until reaching the end of the list and starting over.
230 /// Useful for things like doing a full repack one out of every eight cycles, and a rotamer trials on the other seven.
231 class CycleMover : public MoverContainer {
232 public:
233 
234  // constructor
236 
237  // @brief Copy constructor. Performs a deep copy of all contained movers.
238  CycleMover( CycleMover const & source );
239 
240  // @breif Clone returns a new instance of CycleMover representing a deep copy of this mover.
241  virtual MoverOP clone() const;
242 
243  virtual void apply( core::pose::Pose& pose );
244  void reset_cycle_index(); //JQX: add reset the cycle mover index next_move_
245  virtual std::string get_name() const;
246 
247 private:
248  Size next_move_; //< index into movers_, may need modulo operation first
249 }; // CycleMover class
250 
251 } // moves
252 } // protocols
253 
254 
255 #endif //INCLUDED_protocols_moves_MoverContainer_HH