Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RBSegmentMover.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
11 /// @brief
12 /// @author Frank DiMaio
13 /// @author Srivatsan Raman
14 
15 #ifndef INCLUDED_protocols_rbsegment_relax_RBSegmentMover_hh
16 #define INCLUDED_protocols_rbsegment_relax_RBSegmentMover_hh
17 
18 // Package headers
19 #include <protocols/moves/Mover.hh>
20 // AUTO-REMOVED #include <protocols/rigid/RB_geometry.hh>
21 
22 #include <core/types.hh>
23 #include <core/pose/Pose.fwd.hh>
24 // AUTO-REMOVED #include <core/kinematics/MoveMap.fwd.hh>
25 //#include <core/chemical/ResidueTypeSet.hh>
26 // AUTO-REMOVED #include <core/scoring/ScoreFunction.hh>
27 
28 //devel Headers
30 
31 // C++ Headers
32 #include <map>
33 
34 // Utility Headers
35 // AUTO-REMOVED #include <numeric/xyzVector.io.hh>
36 #include <numeric/xyzVector.hh>
37 // AUTO-REMOVED #include <numeric/xyz.functions.hh>
38 
39 #include <utility/pointer/ReferenceCount.hh>
40 
41 #include <utility/vector1.hh>
42 #include <numeric/conversions.hh>
43 #include <numeric/xyzMatrix.hh>
44 
45 
46 namespace protocols {
47 namespace rbsegment_relax {
48 
49 //////////////////////////////////////////////////////////
50 ///@brief Performs a rigid-body movement on a segment of a protein
51 /// Derived classes must implement 'getCoordinateTransform' and 'apply'
52 /////////////////////////////////////////////////////////
54 protected:
56 
57  /// @brief Helper function to get a coordinate transformation from 3 points:
58  /// the origin, a point specifying the +z axis, and a point specifying the x-z plane
63 
64  /// @brief Helper function computes center of mass of the segment in the pose
66 
67 public:
68  /// @brief constructor
70 
71  /// @brief constructor
72  RBSegmentMover( RBSegment const & seg ) :
73  segment_(seg) { }
74 
75  /// @brief Apply the rigid-body fragment mover to a pose. Must be defined by derived classes.
76  virtual void apply( core::pose::Pose & pose ) = 0;
77 
78  virtual std::string get_name() const;
79 
80  /// @brief Returns: (a) the matrix that rotates global coordinates into local fragment coordinates and
81  /// (b) the center of rotation of the fragment.
82  /// Default implementation sets them to global coords
84  core::pose::Pose const & /*pose*/ ,
85  numeric::xyzVector< core::Real > &rotationCenter,
86  numeric::xyzMatrix< core::Real > &coordinateTransform
87  )
88  {
89  rotationCenter = numeric::xyzVector< core::Real >(0,0,0);
90  coordinateTransform.clear();
91  coordinateTransform.xx(1); coordinateTransform.yy(1); coordinateTransform.zz(1);
92  }
93 
94  /// @brief Set mover-specific movement parameters. Do nothing by default.
95  virtual void set_movement( core::Real p1=0.0, core::Real p2=0.0, core::Real p3=0.0, core::Real p4=0.0);
96 
97  /// @brief steal movement params from a segment definition
98  virtual void set_movement( RBSegment const & rb) {
99  core::Real p1,p2,p3,p4;
100  rb.get_movement( p1,p2,p3,p4 );
101  set_movement( p1,p2,p3,p4 );
102  }
103 
104  /// @brief Apply an arbitrary rotation specified by Euler angles (in degrees!)
105  inline
106  void applyRotation( core::pose::Pose & pose, core::Real alpha, core::Real beta, core::Real gamma ) {
107  double sa = std::sin( numeric::conversions::radians( alpha ) );
108  double ca = std::cos( numeric::conversions::radians( alpha ) );
109  double sb = std::sin( numeric::conversions::radians( beta ) );
110  double cb = std::cos( numeric::conversions::radians( beta ) );
111  double sg = std::sin( numeric::conversions::radians( gamma ) );
112  double cg = std::cos( numeric::conversions::radians( gamma ) );
113 
115  rotation.xx( -sa*cb*sg + ca*cg ); rotation.xy( ca*cb*sg + sa*cg ); rotation.xz( sb*sg );
116  rotation.yx( -sa*cb*cg - ca*sg ); rotation.yy( ca*cb*cg - sa*sg ); rotation.yz( sb*cg );
117  rotation.zx( sa*sb ); rotation.zy( -ca*sb ); rotation.zz( cb );
118 
119  applyRotation( pose, rotation );
120  }
121 
122  /// @brief Apply an arbitrary rotation specified by a rotation matrix
124 
125  /// @brief Apply an arbitrary translation
127 
128  /// @brief Apply a rotation followed by a translation (does not recompute coordinate transformation between the two!)
130 
131  /// @brief Apply a spin of the specified angle (in degrees) about arbitrary axis
132  void applySpin( core::pose::Pose & pose, numeric::xyzVector< core::Real > rotationAxis, core::Real degrees );
133 
134  /// @brief (re)set the starting and ending residues of this transform
135  void setResidueRange( RBSegment const & seg );
136 
137  /// @brief Get the the starting and ending residues of transform
138  RBSegment const & getResidueRange();
139 
140  /// @brief Print debugging info
141  void print() {
142  int nsegs = segment_.nContinuousSegments();
143  std::cerr << nsegs << " segment object\n";
144  for (int i=1; i<=nsegs; ++i) {
145  std::cerr << " " << i << ": " << segment_[i].start() << " to " << segment_[i].end() << std::endl;
146  }
147  }
148 };
149 
150 
151 ///////////////////////////////////////////
152 ///
153 /// Random movements wrt the helical axis
154 ///
155 ///////////////////////////////////////////
157 private:
162 
163 public:
164  /// @brief constructor:
165  /// @li sigAxisR: the stdev of rotation along the helical axis
166  /// @li sigAxisT: the stdev of movement along the helical axis
167  /// @li sigOffAxisR: the stdev of rotation normal to the helical axis
168  /// @li sigOffAxisT: the stdev of movement normal to the helical axis
170  core::Real sigAxisR=0.0,
171  core::Real sigAxisT=0.0,
172  core::Real sigOffAxisR=0.0,
173  core::Real sigOffAxisT=0.0 ) :
174  RBSegmentMover(seg),
175  sigAxisT_( sigAxisT ),
176  sigAxisR_( sigAxisR ),
177  sigOffAxisT_( sigOffAxisT ),
178  sigOffAxisR_( sigOffAxisR )
179  { }
180 
181  /// @brief constructor:
182  /// @li sigAxisR: the stdev of rotation along the helical axis
183  /// @li sigAxisT: the stdev of movement along the helical axis
184  /// @li sigOffAxisR: the stdev of rotation normal to the helical axis
185  /// @li sigOffAxisT: the stdev of movement normal to the helical axis
186  HelicalGaussianMover( core::Real sigAxisR=0.0, core::Real sigAxisT=0.0, core::Real sigOffAxisR=0.0, core::Real sigOffAxisT=0.0 ) :
187  sigAxisT_( sigAxisT ),
188  sigAxisR_( sigAxisR ),
189  sigOffAxisT_( sigOffAxisT ),
190  sigOffAxisR_( sigOffAxisR )
191  { }
192 
193  /// @brief set movement parameters
194  /// @li sigAxisR: the stdev of rotation along the helical axis
195  /// @li sigAxisT: the stdev of movement along the helical axis
196  /// @li sigOffAxisR: the stdev of rotation normal to the helical axis
197  /// @li sigOffAxisT: the stdev of movement normal to the helical axis
198  virtual void set_movement( core::Real sigAxisR=0.0, core::Real sigAxisT=0.0, core::Real sigOffAxisR=0.0, core::Real sigOffAxisT=0.0)
199  {
200  if (sigAxisT != 0.0) sigAxisT_ = sigAxisT;
201  if (sigAxisR != 0.0) sigAxisR_ = sigAxisR;
202  if (sigOffAxisT != 0.0) sigOffAxisT_ = sigOffAxisT;
203  if (sigOffAxisR != 0.0) sigOffAxisR_ = sigOffAxisR;
204 
205  std::cerr << "HelicalGaussianMover : Setting params (" << sigAxisR_ << ", " << sigAxisT_ << ", " << sigOffAxisR_ << ", " << sigOffAxisT_ << ")\n";
206  }
207 
209 
210  /// @brief Apply a +1 or -1 residue "shift" to this helix
211  void apply( core::pose::Pose & pose );
212  virtual std::string get_name() const;
213 
214  /// @brief Get the fragment center / matrix that rotates global coordinates into local fragment coordinates.
215  /// Defined such that +z points to the C-terminal end of the helix axis,
216  /// +x from the helix axis to the N-terminal residue
218  numeric::xyzVector< core::Real > &rotationCenter,
219  numeric::xyzMatrix< core::Real > &coordinateTransform );
220 };
221 
222 ///////////////////////////////////////////
223 ///
224 /// "Register shift" a segment by one amino-acid
225 /// Works in both centroid and all-atom
226 ///
227 ///////////////////////////////////////////
229 public:
230  /// @brief constructor
231  SequenceShiftMover(RBSegment const & seg, core::Size magnitude=2) :
232  RBSegmentMover(seg),
233  magnitude_(magnitude)
234  {}
235 
236  /// @brief constructor
237  SequenceShiftMover(RBResidueRange const &rb, core::Size magnitude=2) :
239  magnitude_(magnitude)
240  {}
241 
243  magnitude_ = 2;
244  }
245 
246  /// @brief clone this object
247  virtual protocols::moves::MoverOP clone() const { return RBSegmentMoverOP(new SequenceShiftMover(*this)); }
248 
249  /// @brief set movement parameters. ignore all input args
250  virtual void set_movement( core::Real sigAxisR=0.0, core::Real sigAxisT=0.0, core::Real sigOffAxisR=0.0, core::Real sigOffAxisT=0.0)
251  {
252  if ( sigAxisR != 0.0 || sigAxisT != 0.0 || sigOffAxisR != 0.0 || sigOffAxisT != 0.0 )
253  std::cerr << "SequenceShiftMover : Ignore params (" << sigAxisR << ", " << sigAxisT << ", " << sigOffAxisR << ", " << sigOffAxisT << ")\n";
254  }
255 
256  /// @brief Apply a +1 or -1 residue "shift" to this helix
257  void apply( core::pose::Pose & pose ) ;
258 
259 private:
261 
262  virtual std::string get_name() const;
263 
264 };
265 
266 ///////////////////////////////////////////
267 ///
268 /// Generic random segment mover
269 ///
270 ///////////////////////////////////////////
272 private:
274 
275 public:
276  /// @brief constructor
277  /// @li sigT: the stdev of movement along the helical axis
278  /// @li sigR: the stdev of rotation along the helical axis
279  GaussianRBSegmentMover(RBSegment const & seg, core::Real sigR = 0.0, core::Real sigT = 0.0) :
280  RBSegmentMover(seg),
281  sigma_rot(sigR),
282  sigma_trans(sigT)
283  {}
284 
285  GaussianRBSegmentMover(core::Real sigR = 0.0, core::Real sigT = 0.0) :
286  sigma_rot(sigR),
287  sigma_trans(sigT)
288  {}
289 
290  /// @brief set movement parameters
291  /// @li sigR: the stdev of rotation
292  /// @li sigT: the stdev of movement
293  virtual void set_movement( core::Real sigAxisR=0.0, core::Real sigAxisT=0.0, core::Real sigOffAxisR=0.0, core::Real sigOffAxisT=0.0)
294  {
295  if (sigAxisT != 0.0) sigma_trans = sigAxisT;
296  if (sigAxisR != 0.0) sigma_rot = sigAxisR;
297 
298  std::cerr << "GaussianRBSegmentMover : Setting params (" << sigma_rot << ", " << sigma_trans << ")\n";
299  if (sigOffAxisR != 0.0 || sigOffAxisT != 0.0 )
300  std::cerr << "GaussianRBSegmentMover : Ignore params (" << sigOffAxisR << ", " << sigOffAxisT << ")\n";
301  }
302 
303  /// @brief clone this object
305 
306  /// @brief Randomly perturb the segment
307  void apply( core::pose::Pose & pose );
308 
309  virtual std::string get_name() const;
310 
311  /// @brief Get the fragment center / matrix that rotates global coordinates into local fragment coordinates.
312  /// Defined such that +z points to the C-terminal end of the helix axis,
313  /// +x from the helix axis to the N-terminal residue
315  numeric::xyzVector< core::Real > &rotationCenter,
316  numeric::xyzMatrix< core::Real > &coordinateTransform );
317 };
318 
319 ///////////////////////////////////////////
320 ///
321 /// Strand Twisting
322 ///
323 ///////////////////////////////////////////
325 private:
330 
331 public:
332  /// @brief constructor:
333  /// @li sigAxisR: the stdev of rotation along the helical axis
334  /// @li sigAxisT: the stdev of movement along the helical axis
335  /// @li sigOffAxisR: the stdev of rotation normal to the helical axis
336  /// @li sigOffAxisT: the stdev of movement normal to the helical axis
338  core::Real sigAxisR=0.0,
339  core::Real sigAxisT=0.0,
340  core::Real sigOffAxisR=0.0,
341  core::Real sigOffAxisT=0.0 ) :
342  RBSegmentMover(seg),
343  sigAxisT_( sigAxisT ),
344  sigAxisR_( sigAxisR ),
345  sigOffAxisT_( sigOffAxisT ),
346  sigOffAxisR_( sigOffAxisR )
347  { }
348 
349  /// @brief constructor:
350  /// @li sigAxisR: the stdev of rotation along the helical axis
351  /// @li sigAxisT: the stdev of movement along the helical axis
352  /// @li sigOffAxisR: the stdev of rotation normal to the helical axis
353  /// @li sigOffAxisT: the stdev of movement normal to the helical axis
354  StrandTwistingMover( core::Real sigAxisR=0.0, core::Real sigAxisT=0.0, core::Real sigOffAxisR=0.0, core::Real sigOffAxisT=0.0 ) :
355  sigAxisT_( sigAxisT ),
356  sigAxisR_( sigAxisR ),
357  sigOffAxisT_( sigOffAxisT ),
358  sigOffAxisR_( sigOffAxisR )
359  { }
360 
361  /// @brief set movement parameters
362  /// @li sigAxisR: the stdev of rotation along the helical axis
363  /// @li sigAxisT: the stdev of movement along the helical axis
364  /// @li sigOffAxisR: the stdev of rotation normal to the helical axis
365  /// @li sigOffAxisT: the stdev of movement normal to the helical axis
366  virtual void set_movement( core::Real sigAxisR=0.0, core::Real sigAxisT=0.0, core::Real sigOffAxisR=0.0, core::Real sigOffAxisT=0.0)
367  {
368  if (sigAxisT != 0.0) sigAxisT_ = sigAxisT;
369  if (sigAxisR != 0.0) sigAxisR_ = sigAxisR;
370  if (sigOffAxisT != 0.0) sigOffAxisT_ = sigOffAxisT;
371  if (sigOffAxisR != 0.0) sigOffAxisR_ = sigOffAxisR;
372 
373  std::cerr << "StrandTwistingMover : Setting params (" << sigAxisR_ << ", " << sigAxisT_ << ", " << sigOffAxisR_ << ", " << sigOffAxisT_ << ")\n";
374  }
375 
376  virtual protocols::moves::MoverOP clone() const { return RBSegmentMoverOP(new StrandTwistingMover(*this)); }
377 
378  /// @brief Apply a +1 or -1 residue "shift" to this helix
379  void apply( core::pose::Pose & pose );
380 
381  virtual std::string get_name() const;
382 
383  /// @brief Get the fragment center / matrix that rotates global coordinates into local fragment coordinates.
384  /// Defined such that +z points to the C-terminal end of the helix axis,
385  /// +x from the helix axis to the N-terminal residue
387  core::pose::Pose const & pose,
388  numeric::xyzVector< core::Real > &rotationCenter,
389  numeric::xyzMatrix< core::Real > &coordinateTransform
390  );
391 };
392 
393 
394 
395 }
396 }
397 
398 #endif