Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HBAtom.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/scoring/etable/etrie/EtableAtom.hh
11 /// @brief
12 /// @author Andrew Leaver-Fay (aleaverfay@gmail.com)
13 
14 #ifndef INCLUDED_core_scoring_hbonds_hbtrie_HBAtom_hh
15 #define INCLUDED_core_scoring_hbonds_hbtrie_HBAtom_hh
16 
17 // Unit Headers
19 
20 // Package Headers
22 
23 // Project Headers
24 // AUTO-REMOVED #include <core/conformation/Atom.hh>
25 #include <core/types.hh>
26 
27 // STL Headers
28 #include <iostream>
29 
30 // Numceric Headers
31 #include <numeric/xyzVector.hh>
32 
33 namespace core {
34 namespace scoring {
35 namespace hbonds {
36 namespace hbtrie {
37 
38 class HBAtom
39 {
40 public:
41  HBAtom();
42 
43  ~HBAtom();
44 
45  // Accessors and mutators
46  Vector const & xyz() const { return xyz_; }
47  void xyz( Vector const & coord ) { xyz_ = coord; }
48 
49  Vector const & base_xyz() const { return base_xyz_; }
50  void base_xyz( Vector const & xyz ) { base_xyz_ = xyz; }
51 
52  Vector const & base2_xyz() const { return base2_xyz_; }
53  void base2_xyz( Vector const & xyz ) { base2_xyz_ = xyz; }
54 
57  void hb_chem_type( int chemtype ) { hb_chem_type_ = chemtype; }
58 
59  //int seqpos() const { return seqpos_;}
60  //void seqpos( int setting ) { seqpos_ = setting; }
61 
62 
63  /// @brief property required by RotamerTrie class
64  inline
65  bool is_hydrogen() const { return is_hydrogen_; }
66 
67  /// @brief setter method for data required by RotamerTrie class
68  inline
69  void is_hydrogen( bool setting ) { is_hydrogen_ = setting; }
70 
71  inline
72  bool is_backbone() const { return is_backbone_; }
73 
74  inline
75  void is_backbone( bool setting ) { is_backbone_ = setting; }
76 
77  inline
78  bool is_protein() const { return is_protein_; }
79 
80  inline
81  void is_protein( bool setting ) { is_protein_ = setting; }
82 
83  inline
84  bool is_dna() const { return is_dna_; }
85 
86  inline
87  void is_dna( bool setting ) { is_dna_ = setting; }
88 
89  /// @brief send a description of the atom to standard out
90  void print() const;
91 
92  /// @brief send a description of the atom to an output stream
93  void print( std::ostream & os ) const;
94 
95  /// @brief compairison operator for sorting
96  inline
97  bool operator < ( HBAtom const & other ) const
98  {
99  if ( is_hydrogen_ < other.is_hydrogen_ ) {
100  return true;
101  } else if ( is_hydrogen_ == other.is_hydrogen_ ) {
102  if ( hb_chem_type_ < other.hb_chem_type_ ) {
103  return true;
104  } else if ( hb_chem_type_ == other.hb_chem_type_ ) {
105  if (is_backbone_ < other.is_backbone_ ) {
106  return true;
107  } else if (is_backbone_ == other.is_backbone_ ) {
108  if ( is_protein_ < other.is_protein_ ) {
109  return true;
110  } else if ( is_protein_ == other.is_protein_ ) {
111  if ( is_dna_ < other.is_dna_ ) {
112  return true;
113  } else if ( is_dna_ == other.is_dna_ ) {
114  //if ( seqpos_ < other.seqpos_ ) {
115  // return true;
116  //} else if ( seqpos_ == other.seqpos_ ) {
117  // Quoting Jack Snoeyink: "Epsilons in code are evil." But whatcha gonna do?
118  // Previously, computed xyz_.distance_squared( other.xyz_ ) and compared against an epsilon
119  // In this case, though, you could get points a, b, and c such that a == b, b == c, but a < c.
120  // In rare cases this would cause the std::sort() insertion sort step
121  // to run off the end of the array/vector and cause a segfault in the trie.
122  for ( int ii = 0; ii< 3; ++ii ) {
123  if ( float(xyz_[ ii ]) != float(other.xyz_[ ii ]) ) {
124  return xyz_[ ii ] < other.xyz_[ ii ];
125  }
126  if ( float(base_xyz_[ ii ]) != float(other.base_xyz_[ ii ]) ) {
127  return base_xyz_[ ii ] < other.base_xyz_[ ii ];
128  }
129 
130  if ( float(base2_xyz_[ ii ]) != float(other.base2_xyz_[ ii ]) ) {
131  return base2_xyz_[ ii ] < other.base2_xyz_[ ii ];
132  }
133  }
134  }
135  }
136  }
137  //}
138  }
139  }
140  return false;
141  }
142 
143 
144  /// @brief equality operator for shared-prefix detection
145  inline
146  bool operator == ( HBAtom const & other ) const
147  {
148  if ( is_hydrogen_ == other.is_hydrogen_ &&
149  hb_chem_type_ == other.hb_chem_type_ &&
150  is_backbone_ == other.is_backbone_ &&
151  is_protein_ == other.is_protein_ &&
152  is_dna_ == other.is_dna_
153  //&& seqpos_ == other.seqpos_
154  ) {
155  for ( int ii = 0; ii< 3; ++ii ) {
156  // Epsilons bad -- see above.
157  //Distance diff = std::abs( xyz_[ ii ] - other.xyz_[ ii ] );
158  //if ( diff > EPSILON ) {
159  if ( float(xyz_[ ii ]) != float(other.xyz_[ ii ]) ) {
160  return false;
161  }
162  //Distance odiff = std::abs( orientation_vector_[ ii ] - other.orientation_vector_[ ii ] );
163  //if ( odiff > EPSILON ) {
164  if ( float(base_xyz_[ ii ]) != float(other.base_xyz_[ ii ]) ) {
165  return false;
166  }
167  if ( float(base2_xyz_[ ii ]) != float(other.base2_xyz_[ ii ]) ) {
168  return false;
169  }
170  }
171  } else {
172  return false;
173  }
174  return true;
175  }
176 
177  bool non_hbonding_atom() const {
178  return hb_chem_type_ == 0;
179  }
180 
181 private:
185 
187 
189 
191  bool is_dna_;
192 
193  int hb_chem_type_; // an integer either representing an HBDonChemType or an HBAccChemType
194  //int seqpos_; // for hbe_classify_BB_by_separation
195 
196 };
197 
198 std::ostream & operator << ( std::ostream & os, HBAtom const & atom );
199 
200 } // namespace hbtrie
201 } // namespace hbonds
202 } // namespace scoring
203 } // namespace core
204 
205 #endif