Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BondedAtom.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 core/kinematics/tree/BondedAtom.hh
11 /// @brief Kinematics
12 /// @author Phil Bradley
13 
14 
15 #ifndef INCLUDED_core_kinematics_tree_BondedAtom_hh
16 #define INCLUDED_core_kinematics_tree_BondedAtom_hh
17 
18 
19 // Package headers
22 
23 // Project headers
25 #include <core/types.hh>
26 
27 // C++ headers
28 #include <cassert>
29 
30 
31 namespace core {
32 namespace kinematics {
33 namespace tree {
34 
35 extern Jump BOGUS_JUMP; // for return statement to keep compiler happy
36 
37 /// @brief an atom which are bonded to its parentt, derived from Atom_
38 ///
39 /// See @ref atomtree_overview "AtomTree overview and concepts" for details.
40 ///
41 class BondedAtom : public Atom_
42 {
43 
44 public:
45 
46  // default constructor
48  phi_(0.0),
49  theta_(0.0),
50  d_(0.0),
52  {}
53 
54 private: // Types
55 
56 
57  typedef Atom_ Super;
58 
59 
60 public:
61 
62  /// @brief Perform a depth-first traversal of the tree that would be effected by
63  /// a DOF change from this atom. Stop at atoms that have already been traversed.
64  /// Will recurse on younger siblings if a phi on this atom has changed.
65  virtual
66  void
67  dfs(
68  AtomDOFChangeSet & changeset,
69  ResidueCoordinateChangeList & res_change_list,
70  Size const start_atom_index
71  ) const;
72 
73  ///////////////////////////////////////////////////////////////////////////
74  // go back and forth between DOFs and coords
75 
76  /// @brief The atom must retrieve an appropriate stub from its parent; it is the root
77  /// of the subtree being refolded. Valid only if this atom is the maximal root of a subtree
78  /// requiring coordinate updates -- if any ancestor of this atom requires a coordinate update,
79  /// then the Stub this atom generates for itself will be invalid.
80  virtual
81  void
83 
84 
85  /// @brief update cartesian coordinates for this atom from its input stub and internal cooridnates
86  virtual
87  void
89  Stub & stub
90  );
91 
93 
94  /// @brief update internal coordinates for this atom from its xyz position and input stub
95  virtual
96  void
98  Stub & stub,
99  bool const recursive = true
100  );
101 
102 
103  // useful helper function for manipulating stubs
104  /// @brief update the stub without actually updating coordinates
105  virtual
106  void
107  update_stub(
108  Stub & stub
109  ) const;
110 
111 
112  ///////////////////////////////////////////////////////////////////////////
113  // access DOFs
114 
115  /// @brief set degrees of freedom (internal coordinates)
116  virtual
117  void
118  set_dof(
119  DOF_Type const type,
120  core::Real const value
121  );
122 
123  /// @brief set degrees of freedom (internal coordinates). For use in
124  /// output-sensitive refold subroutine.
125  virtual
126  void
127  set_dof(
128  DOF_Type const type,
129  core::Real const value,
130  AtomDOFChangeSet & changeset
131  );
132 
133  /// @brief get degrees of freedom
134  virtual
135  core::Real
136  dof(
137  DOF_Type const type
138  ) const;
139 
140  /// @brief abort if attempt to get jump for a bonded atom
141  inline
142  virtual
143  Jump const &
144  jump() const { abort_bad_call(); return BOGUS_JUMP; /* we never get here */ }
145 
146 
147  /// @brief abort if attempt to set jump for a bonded atom
148  inline
149  virtual
150  void
151  jump( Jump const & /* jump_in */ ) { abort_bad_call(); }
152 
153  /// @brief abort if attempt to set jump for a bonded atom
154  inline
155  virtual
156  void
157  jump( Jump const & /* jump_in */, AtomDOFChangeSet & /*changeset*/ ) { abort_bad_call(); }
158 
159 
160  /// @brief copy this atom
161  virtual
162  AtomOP
163  clone( AtomAP parent_in, AtomPointer2D & atom_pointer ) const;
164 
165 
166  ///////////////////////////////////////////////////////////////////////////
167  ///@brief for minimizing,add DOF(PHI,THETA,D) for a BondedAtom into the MinimizerMap
168  virtual
169  void
171  DOF_ID & last_torsion,
172  DOF_ID_Mask const & allow_move,
173  MinimizerMapBase & min_map
174  ) const;
175 
176  ///@brief get rotation axis and end_pos for a BondedAtom.
177  virtual
178  void
180  Vector & axis,
181  Position & end_pos,
182  DOF_Type const type
183  ) const;
184 
185 
186  ///////////////////////////////////////////////////////////////////////////
187  // miscellaneous inspection
188 
189  /// @brief bonded atom is a jump? of course not!!!
190  inline
191  virtual
192  bool
193  is_jump() const { return false; }
194 
195  ///\brief when other atoms are inserted insert after 1st child if available.
196  /// --> this enables us to keep a stub of Downstream Jump atoms inside a single residue
197  virtual
198  bool
199  keep_1st_child_pos() const { return false; }
200 
201 
202  /// @brief whether a DOF for this atom should be fixed?
203  virtual
204  bool
206  DOF_Type const type
207  ) const;
208 
209 
210  ///////////////////////////////////////////////////////////////////////////
211 
212  /// @brief copy DOFs, xyz's
213  virtual
214  void
215  copy_coords( Atom const & src );
216 
217 
218 public: // Properties
219 
220 
221  /////////////////////////////////////////////////////////////////////////////
222  /// @brief stub_atom1 of a bonded atom
223  /** it is itself */
224  inline
225  AtomCOP
226  stub_atom1() const
227  {
228  return this;
229  }
230 
231 
232  /////////////////////////////////////////////////////////////////////////////
233  /// @brief stub_atom2 of a bonded atom
234  /** it is its parent */
235  inline
236  AtomCOP
237  stub_atom2() const
238  {
239  return parent();
240  }
241 
242 
243  /////////////////////////////////////////////////////////////////////////////
244  /// @brief stub_atom3 of a bonded atom
245  /**
246  - if this atom's parent is a bonded_atom it is this atom's parent's parent.
247  - if this atom's parent is a jump atom, it is this atom's first non-jump
248  sibling or its second non-jump sibling (if it itself is the first) or
249  its first non-jump child (if it does not have any sibling)
250  */
251  inline
252  AtomCOP
253  stub_atom3() const
254  {
255  //std::cout << "stub_atom3: " << this << ' ' << parent_ << std::endl();
256  if ( parent()->is_jump() ) {
257  assert( parent()->stub_defined() ); // weird behavior otherwise
258  AtomCOP p_stub2( parent()->stub_atom2() );
259  AtomID const & p_stub2_id( p_stub2->id() );
260  if ( id() == p_stub2_id ) {
261  // very special case!!
262  return parent()->stub_atom3();
263  } else {
264  return p_stub2;
265  }
266  } else {
267  return parent()->stub_atom2();
268  }
269  }
270 
271 
272 private: // Fields
273 
274 
275  ///////////////////////////////////////////////////////////////////////////
276  ///////////////////////////////////////////////////////////////////////////
277  // data
278  ///////////////////////////////////////////////////////////////////////////
279  ///////////////////////////////////////////////////////////////////////////
280 
281  /// @brief DOF properties of a bonded atom
282  /**
283  - a bonded atom is an atom who connects to its parent by a "bond" (covalent
284  or virtual) and therefore its position is defined by three internal
285  coordinates: d_, theta_, and phi_.
286  - d_ is the bond distance between this atom and its parent.
287  - theta_ is the bond angle between this atom(A), its parent's stub_atom1(B)
288  and its parent's stub_atom2(C), i.e., angle in between B->A ^ C->B.
289  - phi_ is either the torsion angle defined by A, B, C and D (C's parents),
290  or the improper angle defined by A, B, C and D (B's child and A's previous sibling).
291  */
293 
294  /// @brief Track whether a dof change from this node (since the last update_xyz)
295  /// induces a coordinate change for this node's younger siblings.
297 
298 
299 }; // BondedAtom
300 
305 
306 } // namespace tree
307 } // namespace kinematics
308 } // namespace core
309 
310 
311 #endif // INCLUDED_core_kinematics_BondedAtom_HH