Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Atom.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/Atom.hh
11 /// @brief Kinematics Atom interface class
12 /// @author Phil Bradley
13 
14 
15 #ifndef INCLUDED_core_kinematics_tree_Atom_hh
16 #define INCLUDED_core_kinematics_tree_Atom_hh
17 
18 
19 // Unit headers
21 
22 // Package headers
23 // AUTO-REMOVED #include <core/kinematics/types.hh>
24 #include <core/id/AtomID.fwd.hh>
33 #include <core/id/DOF_ID.fwd.hh>
35 
36 // Numeric headers
37 #include <numeric/xyzMatrix.fwd.hh>
38 
39 // ObjexxFCL headers
40 #include <ObjexxFCL/FArray1D.fwd.hh>
41 
42 // Utility headers
43 // AUTO-REMOVED #include <utility/vector0.hh>
44 // AUTO-REMOVED #include <utility/vector1.hh> // DOH! switch all to vector1
45 #include <utility/pointer/ReferenceCount.hh>
46 
47 #include <core/id/types.hh>
48 #include <utility/vector0_bool.hh>
49 
50 
51 
52 namespace core {
53 namespace kinematics {
54 namespace tree {
55 
56 /// Kinematics Atom interface class
57 class Atom : public utility::pointer::ReferenceCount // So we can hold it in owning_ptr
58 {
59 
60 
61 public: // Types
62 
63 
66  typedef Atoms::ConstIterator Atoms_ConstIterator;
67  typedef Atoms::Iterator Atoms_Iterator;
68 
70 
71 
72  // ids
74  typedef id::DOF_ID DOF_ID;
75  typedef id::AtomID AtomID;
78 
79 
80  // Types to prevent compile failure when std::distance is in scope
81  typedef void iterator_category;
82  typedef void difference_type;
83 
84 
85 private: // Friends
86 
87 
88  //friend class AtomTree;
89 
90 
91 protected: // Creation
92 
93 
94  /// @brief Default constructor
95  inline
96  Atom()
97  {}
98 
99 
100  /// @brief Copy constructor
101  inline
102  Atom( Atom const & /*atom*/ ) : // PBHACK!!!
103  ReferenceCount()
104  {}
105 
106 public: // Creation
107 
108 
109  /// @brief Destructor
110  virtual
112  {}
113 
114 
115 protected: // Assignment
116 
117 
118  /// @brief Copy assignment
119  inline
120  Atom &
121  operator =( Atom const & )
122  {
123  return *this;
124  }
125 
126 
127 public: // Methods
128 
129  /// @brief Set the weak-pointer-to-self for this atom. Must be called after the Atom is created and put inside of an owning_ptr.
130  /// Required for atoms to be able to hold pointers to their parents: parents must give child atoms weak pointers to themselves.
131  virtual
132  void
134  AtomAP weak_ptr
135  ) = 0;
136 
137 
138  /// @brief Perform a depth-first traversal of the tree that would be effected by
139  /// a DOF change from this atom. Stop at atoms that have already been traversed.
140  virtual
141  void
142  dfs(
143  AtomDOFChangeSet & changeset,
144  ResidueCoordinateChangeList & res_change_list,
145  Size const start_atom_index
146  ) const = 0;
147 
148 
149  /// @brief The atom must retrieve an appropriate stub from its parent; it is the root
150  /// of the subtree being refolded
151  virtual
152  void
153  update_xyz_coords() = 0;
154 
155  ///////////////////////////////////////////////////////////////////////////
156  // go back and forth between internal coords (DOF's) and xyz coords
157  ///\brief update xyz coords from stub and internal coords and
158  virtual
159  void
161  Stub & stub
162  ) = 0;
163 
164  ///\brief update internal coords from stub and xyz coords
165  virtual
166  void
168  Stub & stub,
169  bool const recursive = true
170  ) = 0;
171 
172 
173  ///\brief calculate my input_stub from the current xyz's and use that input_stub to update my torsions
174  virtual
175  void
177  bool const recursive
178  ) = 0;
179 
180  ///\brief update atom_pointer map for AtomTree
181 // virtual
182 // void
183 // update_atom_pointer(
184 // AtomPointers & atom_pointer,
185 // bool const allow_overwriting = false
186 // ) = 0;
187 
188 
189  /// @brief update the stub without actually updating coordinates
190  //Useful helper function for manipulating stubs
191  virtual
192  void
193  update_stub(
194  Stub & stub
195  ) const = 0;
196 
197 
198  ///////////////////////////////////////////////////////////////////////////
199  ///\brief copy DOFs and xyz coords from src Atom
200  virtual
201  void
202  copy_coords( Atom const & src ) = 0;
203 
204 
205  ///////////////////////////////////////////////////////////////////////////
206  // access DOFs
207 
208 
209  /// get dof
210  virtual
211  Real
212  dof(
213  DOF_Type const type
214  ) const = 0;
215 
216 
217  /// set dof, use "set_" syntax since we have multiple dof's
218  virtual
219  void
220  set_dof(
221  DOF_Type const type,
222  Real const value
223  ) = 0;
224 
225 
226  /// set dof, use "set_" syntax since we have multiple dof's -- for use in output-sensitive refold routine
227  virtual
228  void
229  set_dof(
230  DOF_Type const type,
231  Real const value,
232  AtomDOFChangeSet & set
233  ) = 0;
234 
235 
236  /// get Jump
237  virtual
238  Jump const &
239  jump() const = 0;
240 
241 
242  /// @brief set Jump
243  virtual
244  void
245  jump(
246  Jump const & jump_in
247  ) = 0;
248 
249 
250  /// set Jump -- for use in output-sensitive refolding
251  virtual
252  void
253  jump(
254  Jump const & jump_in,
255  AtomDOFChangeSet & set
256  ) = 0;
257 
258 
259  /// copy atom with new memory allocation
260  virtual
261  AtomOP
262  clone( AtomAP parent_in, AtomPointer2D & atom_pointer ) const = 0;
263 
264 
265  ///////////////////////////////////////////////////////////////////////////
266  // for minimizing
267  virtual
268  void
270  DOF_ID & last_torsion,
271  DOF_ID_Mask const & move_map,
272  MinimizerMapBase & min_map
273  ) const = 0;
274 
275 
276  virtual
277  void
279  Vector & axis,
280  Position & end_pos,
281  DOF_Type const type
282  ) const = 0;
283 
284 
285  ///////////////////////////////////////////////////////////////////////////
286  // miscellaneous inspection
287  ///\brief atom is a jump atom?
288  virtual
289  bool
290  is_jump() const = 0;
291 
292  ///\brief when other atoms are inserted insert after 1st child if available.
293  /// --> this enables us to keep a stub of Downstream Jump atoms inside a single residue
294  virtual
295  bool
296  keep_1st_child_pos() const = 0;
297 
298 
299  ///\brief DOF should be fixed for this atom?
300  ///
301  /// for DOFs which must be kept fixed due to topology of tree
302  /// eg, phi of stub_atoms for jump_atoms
303  inline
304  virtual
305  bool
307  DOF_Type const //type
308  ) const
309  {
310  return false;
311  }
312 
313  ///\brief dump out AtomID for this atom, its parent and all its offspring
314  virtual
315  void
316  show() const = 0;
317 
318  ///\brief dump out AtomID for this atom, its parent and all its offspring up to n_level
319  virtual
320  void
321  show(int const &) const = 0;
322 
323  ///\brief dihedral angle between two bonded children to this atom
324  virtual
325  Real
327  AtomCOP child1,
328  AtomCOP child2
329  ) const = 0;
330 
331 
332  ///////////////////////////////////////////////////////////////////////////
333  // update domain map
334  virtual
335  void
337  int & current_color,
338  int & biggest_color,
339  DomainMap & domain_map,
340  AtomID_Mask const & dof_moved,
341  AtomID_Mask const & atom_moved
342  ) const = 0;
343 
344 
345  ///////////////////////////////////////////////////////////////////////////
346  // manage atom_list
347 
348  virtual
350  atoms_begin() const = 0;
351 
352 
353  virtual
355  atoms_end() const = 0;
356 
357 
358  virtual
360  atoms_begin() = 0;
361 
362 
363  virtual
365  atoms_end() = 0;
366 
367 
368  virtual
369  Size
370  n_atom() const = 0;
371 
372 
373  // adds to the end, modulo the rule (which applies to the other methods
374  // as well) that all the JumpAtoms come before the BondedAtoms
375  virtual
376  void
377  append_atom( AtomOP ) = 0;
378 
379 
380  virtual
381  void
382  delete_atom( AtomOP ) = 0;
383 
384 
385  // inserts at the beginning
386  virtual
387  void
388  insert_atom( AtomOP ) = 0;
389 
390 
391  // tries to insert at the position specified by the second argument
392  virtual
393  void
394  insert_atom( AtomOP, int const /*index*/ ) = 0;
395 
396 
397  virtual
398  void
399  replace_atom(
400  AtomOP const old_atom,
401  AtomOP const new_atom
402  ) = 0;
403 
404 
405  virtual
406  AtomCOP
408  Size const i
409  ) const = 0;
410 
411 
412 // virtual
413 // void
414 // erase() = 0;
415 
416  virtual
417  Size
418  n_children() const = 0;
419 
420 
421  virtual
422  Size
423  n_nonjump_children() const = 0;
424 
425 
426  virtual
427  AtomCOP
428  child( Size const k ) const = 0;
429 
430 
431  virtual
432  AtomOP
433  child( Size const k ) = 0;
434 
435 
436  /// the atom-index of this child
437  virtual
438  Size
439  child_index( AtomCOP child ) const = 0;
440 
441  virtual
442  bool
443  downstream( AtomCOP atom1 ) const = 0;
444 
445 
446 public: // Properties
447 
448 
449  /// @brief Atom identifier
450  virtual
451  AtomID const &
452  id() const = 0;
453 
454 
455  /// AtomID assignment
456  virtual
457  void
458  id( AtomID const & id_in ) = 0;
459 
460 
461  /// @brief Atom identifier
462  virtual
463  AtomID const &
464  atom_id() const = 0;
465 
466 
467  /// @brief Position
468  virtual
469  Position const &
470  position() const = 0;
471 
472 
473  /// @brief Position assignment
474  virtual
475  void
476  position( Position const & position_a ) = 0;
477 
478 
479  /// @brief Position
480  virtual
481  Position const &
482  xyz() const = 0;
483 
484 
485  /// @brief Position assignment
486  virtual
487  void
488  xyz( Position const & position_a ) = 0;
489 
490 
491  /// @brief x coordinate
492  virtual
493  Length const &
494  x() const = 0;
495 
496 
497  /// @brief y coordinate
498  virtual
499  Length const &
500  y() const = 0;
501 
502 
503  /// @brief z coordinate
504  virtual
505  Length const &
506  z() const = 0;
507 
508 
509  /// @brief Distance to an Atom
510  virtual
511  Length
512  distance( Atom const & atom ) const = 0;
513 
514 
515  /// @brief Distance squared to an Atom
516  virtual
517  Length
518  distance_squared( Atom const & atom ) const = 0;
519 
520 
521  /// @brief Distance between two Atoms
522  friend
523  inline
524  Length
525  distance( Atom const & atom1, Atom const & atom2 );
526 
527 
528  /// @brief Distance squared between two Atoms
529  friend
530  inline
531  Length
532  distance_squared( Atom const & atom1, Atom const & atom2 );
533 
534  /// @brief Transform atom and children by linear transformation
535  //virtual
536  //void
537  //transform_Ax_plus_b_recursive( Matrix const & A, Vector const & b ) = 0;
538 
539  /// @brief Transform atom and children by linear transformation
540  virtual
541  void
542  transform_Ax_plus_b_recursive( Matrix const & A, Vector const & b, ResidueCoordinateChangeList & res_change_list ) = 0;
543 
544  /// @brief Parent atom pointer, NULL for root atom
545  virtual
546  AtomCOP
547  parent() const = 0;
548 
549  ///
550  virtual
551  void
553 
554  ///
555  virtual
556  bool
557  atom_is_on_path_from_root( AtomCOP atm ) const = 0;
558 
559  /// parent assignment
560  virtual
561  void
562  parent( AtomAP parent_in ) = 0;
563 
564 
565  /// @brief Parent atom pointer, NULL for root atom
566  virtual
567  AtomOP
568  parent() = 0;
569 
570 
571  /// @brief Get stub information
572  virtual
573  Stub
574  get_stub() const = 0;
575 
576 
577  virtual
578  Stub
579  get_input_stub() const = 0;
580 
581 
582  virtual
583  AtomCOP
584  stub_atom1() const = 0;
585 
586 
587  virtual
588  AtomCOP
589  stub_atom2() const = 0;
590 
591 
592  virtual
593  AtomCOP
594  stub_atom3() const = 0;
595 
596 
597  virtual
598  AtomID const &
599  stub_atom1_id() const = 0;
600 
601 
602  virtual
603  AtomID const &
604  stub_atom2_id() const = 0;
605 
606 
607  virtual
608  AtomID const &
609  stub_atom3_id() const = 0;
610 
611 
612  virtual
613  AtomCOP
614  input_stub_atom0() const = 0;
615 
616 
617  virtual
618  AtomCOP
619  input_stub_atom1() const = 0;
620 
621 
622  virtual
623  AtomCOP
624  input_stub_atom2() const = 0;
625 
626 
627  virtual
628  AtomCOP
629  input_stub_atom3() const = 0;
630 
631 
632  virtual
633  AtomID const &
634  input_stub_atom0_id() const = 0;
635 
636 
637  virtual
638  AtomID const &
639  input_stub_atom1_id() const = 0;
640 
641 
642  virtual
643  AtomID const &
644  input_stub_atom2_id() const = 0;
645 
646 
647  virtual
648  AtomID const &
649  input_stub_atom3_id() const = 0;
650 
651 
652  // routines for navigating the tree
653  virtual
654  AtomCOP
655  previous_sibling() const = 0;
656 
657  virtual
658  AtomCOP
660  AtomCOP child
661  ) const = 0;
662 
663 
664  virtual
665  AtomOP
666  next_child(
667  AtomCOP child
668  ) = 0;
669 
670 
671  virtual
672  bool
673  stub_defined() const = 0;
674 
675 
676 protected: // Methods
677 
678 
679  // when subtrees have changed their coordinates
680  virtual
681  void
683  AtomOP const child
684  ) = 0;
685 
686 
687  virtual
689  nonjump_atoms_begin() const = 0;
690 
691 
692  virtual
694  nonjump_atoms_begin() = 0;
695 
696 
697 }; // Atom
698 
699 
700 /// @brief Distance between two Atoms
701 inline
702 Length
703 distance( Atom const & atom1, Atom const & atom2 )
704 {
705  return atom1.distance( atom2 );
706 }
707 
708 /// @brief Distance squared between two Atoms
709 inline
710 Length
711 distance_squared( Atom const & atom1, Atom const & atom2 )
712 {
713  return atom1.distance_squared( atom2 );
714 }
715 
716 
717 
718 } // namespace tree
719 } // namespace kinematics
720 } // namespace core
721 
722 
723 #endif // INCLUDED_core_kinematics_Atom_HH