Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MMEnergyTableAtom.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 // This file is made available under the Rosetta Commons license.
5 // See http://www.rosettacommons.org/license
6 // (C) 199x-2007 University of Washington
7 // (C) 199x-2007 University of California Santa Cruz
8 // (C) 199x-2007 University of California San Francisco
9 // (C) 199x-2007 Johns Hopkins University
10 // (C) 199x-2007 University of North Carolina, Chapel Hill
11 // (C) 199x-2007 Vanderbilt University
12 
13 /// @file core/scoring/mm/mmtrie/MMEnergyTableAtom.hh
14 /// @brief Header for the MMEnergyTableAtom. Heavily coppied from the EtableAtom.hh
15 /// @author P. Douglas Renfrew (renfrew@unc.edu)
16 
17 #ifndef INCLUDED_core_scoring_mm_mmtrie_MMEnergyTableAtom_hh
18 #define INCLUDED_core_scoring_mm_mmtrie_MMEnergyTableAtom_hh
19 
20 // Unit Headers
22 
23 // Project Headers
26 #include <core/types.hh>
27 
28 // STL Headers
29 #include <iostream>
30 
31 // Numceric Headers
32 #include <numeric/xyzVector.hh>
33 
34 namespace core {
35 namespace scoring {
36 namespace mm {
37 namespace mmtrie {
38 
40 {
41 public:
43 
44 public:
46 
47  MMEnergyTableAtom( conformation::Residue const & res, Size mm_atom_index );
48 
49  /// @brief non-virtual destructor to keep MMEnergyTableAtom small and lightweight
50  /// as a virtual destructor would add a vtable to the class
51  /// But I fear leaks... do I know how xyzVector dealloates its data?
52  virtual ~MMEnergyTableAtom();
53 
54  /// @brief deprecated!
55  inline
56  Size mm_atom_type() const { return mm_type(); }
57  /// @brief deprecated!
58  inline
59  void mm_atom_type( Size setting ) { mm_type( setting ); }
60 
61  /// @brief property required by RotamerTrie class
62  inline
63  bool is_hydrogen() const { return is_hydrogen_; }
64 
65  /// @brief setter method for data required by RotamerTrie class
66  inline
67  void is_hydrogen( bool setting ) { is_hydrogen_ = setting; }
68 
69  /// @brief send a description of the atom to standard out
70  void print() const;
71 
72  /// @brief send a description of the atom to an output stream
73  void print( std::ostream & os ) const;
74 
75  /// @brief compairison operator for sorting
76  inline
77  bool operator < ( MMEnergyTableAtom const & other ) const
78  {
79  if ( mm_type() == other.mm_type() ) {
80  // Quoting Jack Snoeyink: "Epsilons in code are evil." But whatcha gonna do?
81  // In this case, though, you could get points a, b, and c such that a == b, b == c, but a < c.
82  // In rare cases this would cause the std::sort() insertion sort step
83  // to run off the end of the array/vector and cause a segfault in the trie.
84  for ( int ii = 0; ii< 3; ++ii ) {
85  //Distance diff = std::abs( xyz()[ ii ] - other.xyz()[ ii ] );
86  //if ( diff > EPSILON ) {
87  if ( float(xyz()[ ii ]) != float(other.xyz()[ ii ]) ) {
88  return xyz()[ ii ] < other.xyz()[ ii ];
89  }
90  }
91  } else {
92  return mm_type() < other.mm_type();
93  }
94  return false;
95  }
96 
97  /// @brief equality operator for shared-prefix detection
98  inline
99  bool operator == ( MMEnergyTableAtom const & other ) const
100  {
101  if ( mm_type() == other.mm_type() ) {
102  for ( int ii = 0; ii< 3; ++ii ) {
103  // Epsilons bad -- see above.
104  //Distance diff = std::abs( xyz()[ ii ] - other.xyz()[ ii ] );
105  //if ( diff > EPSILON ) {
106  if ( float(xyz()[ ii ]) != float(other.xyz()[ ii ]) ) {
107  return false;
108  }
109  }
110  } else {
111  return false;
112  }
113  return true;
114  }
115 
116 
117 private:
118 
120 
121 };
122 
123 std::ostream & operator << ( std::ostream & os, MMEnergyTableAtom const & atom );
124 
125 } // namespace mmtrie
126 } // namespace mm
127 } // namespace scoring
128 } // namespace core
129 
130 #endif