Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExternalGeomSampler.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 // :noTabs=false:tabSize=4:indentSize=4:
4 //
5 // (c) Copyright Rosetta Commons Member Institutions.
6 // (c) This file is part of the Rosetta software suite and is made available under license.
7 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
8 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
9 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
10 
11 /// @file protocols/match/ExternalGeomSampler.hh
12 /// @brief
13 /// @author Alex Zanghellini (zanghell@u.washington.edu)
14 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com), porting to mini
15 
16 #ifndef INCLUDED_protocols_toolbox_match_enzdes_util_ExternalGeomSampler_hh
17 #define INCLUDED_protocols_toolbox_match_enzdes_util_ExternalGeomSampler_hh
18 
19 // Unit headers
21 
22 // Project headers
23 #include <core/types.hh>
24 
25 // Numeric headers
26 #include <numeric/HomogeneousTransform.hh>
27 
28 // Utility headers
29 // AUTO-REMOVED #include <utility/vector1.hh>
30 #include <utility/pointer/ReferenceCount.hh>
31 
32 // C++ headers
33 #include <list>
34 
35 #include <utility/vector1.hh>
36 
37 
38 namespace protocols {
39 namespace toolbox {
40 namespace match_enzdes_util {
41 
42 /// @brief The external geom sampler is a class that manages the data necessary
43 /// to construct the coordinates of the three atoms in the downstream partner.
44 ///
45 /// @details
46 /// The external geom sampler holds the data for the six degrees of freedom
47 /// that describe the downstream atoms relative to the upstream atoms.
48 /// The naming of the 6 atoms involved and the 6 degrees of freedom involved
49 /// is as follows:
50 ///
51 /// Atoms U1, U2, and U3 are on the upstream partner.
52 /// Atoms D1, D2, and D3 are on the downstream partner.
53 /// The numbers indicate the distance the atoms have from the "break" between the upstream
54 /// and downstream partners.
55 ///
56 /// DOF 1: "tor_U3D1" is the torsion between atoms U3, U2, U1 and D1.
57 /// DOF 2: "ang_U2D1" is angle between atoms U2, U1 and D1.
58 /// DOF 3: "dis_U1D1" is the distance between atoms U1 and D1.
59 /// DOF 4: "tor_U2D2" is the torsion between atoms U2, U1, D1 and D2.
60 /// DOF 5: "ang_U1D2" is the angle between atoms U1, D1 and D3
61 /// DOF 6: "tor_U1D3" is the torsion between atoms U1, D1, D2 and D3
62 ///
63 /// This naming convention describes a parameter by three letters followed by two atom names.
64 /// The letter is "d" for distance, "a" for angle, and "t" for torsion. The two numbers
65 /// describe the end points of that parameter assuming a continuous span of numbers
66 /// between. E.g. t25 describes the geometry of 4 atoms starting at 2 and going to 5,
67 /// hitting atoms 3 and 4 along the way.
68 ///
69 /// ASCII art:
70 /// Fig 1. The 6 atoms that define the geometry between the upstream partner
71 /// and the downstream partner. dis_U1D1 is the distance between atoms U1 and D1
72 /// U3
73 /// \.
74 /// U2 --- U1
75 ///
76 /// \ dis_U1D1
77 ///
78 /// D1 --- D2
79 /// \.
80 /// D3
81 ///
82 /// Fig 2. The two angles
83 /// U3
84 /// \.
85 /// U2 --- U1
86 /// ang_U2D1
87 /// \.
88 /// ang_U1D2
89 /// D1 --- D2
90 /// \.
91 /// D3
92 /// Fig 3. The three torsions
93 /// U3
94 /// \ tor_U3D1 tor_U3D1: torsion about U2-U1 axis starting at atom U3 and ending at D1
95 /// U2 --- U1
96 ///
97 /// \ tor_U2D2 tor_U2D2: torsion about U1-D1 axis starting at atom U2 and ending at D2
98 ///
99 /// D1 --- D2
100 /// tor_U1D3 \ tor_U1D3: torsion about D1-D2 axis starting at atom U1 and ending at D3
101 /// D3
102 ///
103 /// There are three other parameters needed to construct the location
104 /// of atoms 4, 5 and 6 from atoms 1, 2 and 3, but these are not
105 /// considered DOFs as they are not allowed to vary.
106 /// They are:
107 /// Extra 1: the distance between atom D1 and atom D2
108 /// Extra 2: the distance between atom D2 and atom D3
109 /// Extra 3: the angle between atoms D1, D2 and D3.
110 ///
111 /// These three parameters must be communicated to the ExternGeomSampler
112 /// through its functions set_dis_D1D2, set_dis_D2D3 and set_ang_D1D2D3.
113 ///
114 /// The ExternalGeomSampler holds the set of samples for each of the
115 /// 6 DOFs. For each sample, it precomputes a HomogeneousTransform
116 /// so that during the enumeration of all sample combinations the
117 /// coordinate computation requires matrix multiplication only: the
118 /// more expensive transcendental function evaluations evaluated before
119 /// coordinate construction begins, their results stored, and are thereby
120 /// avoided in the enumeration loops.
121 ///
122 /// To build the coordinates of atoms D1, D2 and D3, given the sample id's
123 /// for the 6 DOFs as the 6-tuple [ i, j, k, l, m, n ]:
124 /// start with a coordinate frame at atom U1 s.t. the z axis lies on the
125 /// vector from atom U2 to atom U1, the y axis lies in the plane defined
126 /// atoms U1, U2 and U3, and the x axis is the cross-product of y and z.
127 /// Call the start frame "frame1."
128 /// frame2 is the product: frame1 * transform( HT_tor_U3D1, i );
129 /// frame3 is the product: frame2 * transform( HT_ang_U2D1, j );
130 /// frame4 is computed from frame3 by walking along frame3's z-axis by dis_U1D1_samples( k );
131 /// frame4.point() is the coordinate for atom 4.
132 /// frame5 is the product: frame4 * transform( HT_tor_U2D2, l );
133 /// frame6 is the product: frame5 * transform( HT_ang_U1D2, m );
134 /// frame6.point() is the coordinate for atom 5.
135 /// NOTE: transform( HT_ang_U1D2, m ) is the product of the z-axis
136 /// rotation by ang_U1D2_sample_[ m ] and the transformation HT along the
137 /// z-axis by the distance between atoms D1 and D2. The ExternalGeomSampler
138 /// pre-multiplies these matricies.
139 /// frame7 is the product: frame6 * transform( HT_tor_U1D3, n );
140 /// frame7.point() is the coordinate for atom 6.
141 /// NOTE: transform( HT_tor_U1D3, n ) is the product of three HTs:
142 /// the HT representing the z-axis rotation by tor_U1D3_sample_[ n ],
143 /// the HT representing the x-axis rotation by ( -1 * ( 180 - ang_D1D2D3 ) )
144 /// and the HT representing the z-axis translation by the
145 /// distance between atoms D2 and D3. The ExternalGeomSampler
146 /// pre-multiplies these matrices.
147 
149 public:
151  typedef core::Size Size;
152  typedef core::Real Real;
153  typedef numeric::HomogeneousTransform< Real > HTReal;
154 
155 public:
156  virtual ~ExternalGeomSampler();
157 
160 
161  ExternalGeomSampler const &
162  operator = ( ExternalGeomSampler const & rhs );
163 
164 
165 public:
166  /// Intialization routines
167  /// all initialization routines must be invoked before building may begin.
168  /// Once each has been called, the function precompute_transforms() must
169  /// be called.
170 
177 
178  void set_tor_U3D1_samples( std::list< Real > const & tor_U3D1_samples );
179  void set_dis_U1D1_samples( std::list< Real > const & dis_U1D1_samples );
180  void set_ang_U2D1_samples( std::list< Real > const & ang_U2D1_samples );
181  void set_ang_U1D2_samples( std::list< Real > const & ang_U1D2_samples );
182  void set_tor_U2D2_samples( std::list< Real > const & tor_U2D2_samples );
183  void set_tor_U1D3_samples( std::list< Real > const & tor_U1D3_samples );
184 
185 
186  void set_dis_D1D2( Real distance );
187  void set_dis_D2D3( Real distance );
188  void set_ang_D1D2D3( Real ang_in_degrees );
189 
190  /// @brief Must be called after the samples are set, and the
191  /// internal geometry of the three downstream coordinates
192  /// (point 4, 5, and 6) are described. Does nothing if the transforms
193  /// are up to date.
194  void
196 
197  /// @brief convenience function if one wants to change the meaning of
198  /// upstream and downstream
199  void
201 
202 public:
203  /// Accessors
204 
205  Size n_tor_U3D1_samples() const { return tor_U3D1_samples_.size(); }
206  Size n_dis_U1D1_samples() const { return dis_U1D1_samples_.size(); }
207  Size n_ang_U2D1_samples() const { return ang_U2D1_samples_.size(); }
208  Size n_ang_U1D2_samples() const { return ang_U1D2_samples_.size(); }
209  Size n_tor_U2D2_samples() const { return tor_U2D2_samples_.size(); }
210  Size n_tor_U1D3_samples() const { return tor_U1D3_samples_.size(); }
211 
218 
219 public:
220  bool transforms_uptodate() const { return transforms_uptodate_; }
221 
222 
223  HTReal const &
224  transform( ExternalTransform id, Size which_state ) const {
225  assert( transforms_uptodate_ );
226  return transforms_[ id ][ which_state ];
227  }
228 
229 private:
236 
240 
242 
244 
245 };
246 
247 }
248 }
249 }
250 
251 #endif