OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
atom_impl.hh
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 // This file is part of the OpenStructure project <www.openstructure.org>
3 //
4 // Copyright (C) 2008-2011 by the OpenStructure authors
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 3.0 of the License, or (at your option)
9 // any later version.
10 // This library is distributed in the hope that it will be useful, but WITHOUT
11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13 // details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this library; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 //------------------------------------------------------------------------------
19 #ifndef OST_ATOM_IMPL_HH
20 #define OST_ATOM_IMPL_HH
21 
22 #include <boost/enable_shared_from_this.hpp>
23 
24 #include <ost/mol/module_config.hh>
25 #include <ost/geom/geom.hh>
28 
34 
35 #include <ost/generic_property.hh>
36 #include <ost/mol/property_id.hh>
37 
38 namespace ost { namespace mol { namespace impl {
39 
50  public boost::enable_shared_from_this<AtomImpl> {
51 public:
52  AtomImpl(const EntityImplPtr& ent, const ResidueImplPtr& res,
53  const String& name, const geom::Vec3& pos, const String& ele,
54  unsigned long index);
55 
56  ~AtomImpl();
57  void Apply(EntityVisitor& h);
58 
59  // for efficiency reasons, the simple setter/getter methods are
60  // replaced by direct access - this is the impl layer after all
61 
62  const String& Name() const {return name_;}
63  String& Name() {return name_;}
64 
65  // DEPRECATED
66  const String& GetName() const {return name_;}
67 
68  const geom::Vec3& TransformedPos() const {return tf_pos_;}
69  geom::Vec3& TransformedPos() {return tf_pos_;}
70 
71  const geom::Vec3& OriginalPos() const {return pos_;}
72  geom::Vec3& OriginalPos() {return pos_;}
73 
74  ResidueImplPtr GetResidue() const;
75 
77  prim_connector_=bp;
78  }
79 
81  return prim_connector_;
82  }
83 
85  return connector_list_;
86  }
87 
88  void AddSecondaryConnector(const ConnectorImplP& bp);
89 
90  // updates position and then follows secondary connectors
91  void UpdateFromICS();
92 
93  // derive internal coordinates from position and linkage
94  void UpdateFromXCS();
95 
96  String GetQualifiedName() const;
97 
98  EntityImplPtr GetEntity() const;
99 
100  int GetConnectorCount() const {
101  return connector_list_.size()+(prim_connector_ ? 1 : 0);
102  }
103 
104  void SetVisited(bool f) {set_state_bit(0,f);}
105  bool IsVisited() const {return get_state_bit(0);}
106 
107  void SetTraced(bool f) {set_state_bit(1,f);}
108  bool IsTraced() const {return get_state_bit(1);}
109 
110 
111  Real GetBFactor() const { return b_factor_; }
112 
113  const String& GetElement() const { return element_; }
114 
115  void SetElement(const String& ele)
116  {
117  if (element_!=ele) {
118  element_=ele;
119  prop_=impl::AtomProp::GetDefaultProps(element_);
120  }
121  }
122  bool HasDefaultProps() const { return prop_->is_default; }
123  void SetAnisou(const geom::Mat3& anisou)
124  {
125  if (prop_->is_default && prop_->anisou!=anisou) {
126  prop_=new AtomProp(*prop_);
127  prop_->is_default=false;
128  prop_->has_anisou=true;
129  }
130 
131  prop_->anisou=anisou;
132  }
133 
134  const geom::Mat3& GetAnisou() const
135  {
136  return prop_->anisou;
137  }
138  void SetBFactor(Real factor)
139  {
140  b_factor_=factor;
141  }
142 
143  void SetOccupancy(Real occ)
144  {
145  occupancy_=occ;
146  }
147 
149  {
150  return occupancy_;
151  }
152 
153  Real GetRadius() const { return prop_->radius; }
154 
155  Real GetMass() const { return prop_->mass; }
156  Real GetCharge() const { return prop_->charge; }
157 
158  bool IsHetAtom() { return is_hetatm_; }
159 
160  void SetHetAtom(bool het) { is_hetatm_=het; }
161 
162  void SetMass(Real mass)
163  {
164  if (prop_->is_default && prop_->mass!=mass) {
165  prop_=new AtomProp(*prop_);
166  prop_->is_default=false;
167  }
168  prop_->mass=mass;
169  }
170 
171  void SetRadius(Real radius)
172  {
173  if (prop_->is_default && prop_->radius!=radius) {
174  prop_=new AtomProp(*prop_);
175  prop_->is_default=false;
176  }
177  prop_->radius=radius;
178  }
179 
180  void SetCharge(Real charge)
181  {
182  if (prop_->is_default && prop_->charge!=charge) {
183  prop_=new AtomProp(*prop_);
184  prop_->is_default=false;
185  }
186  prop_->charge=charge;
187  }
188 
189 
190  unsigned int GetState() const
191  {
192  return state_;
193  }
194 
195  void SetState(int state)
196  {
197  state_=state;
198  }
199 
200  void ClearDirectionality();
203  int n, unsigned int& c);
204 
205  bool HasPrevious() const {return prim_connector_.get()!=NULL;}
206 
207  void DeleteAllConnectors();
208 
209  void DeleteConnector(const ConnectorImplP& conn,
210  bool delete_other=true);
211 
212  void DeleteAllTorsions();
213 
214  String GetStringProperty(Prop::ID prop_id) const;
215 
216  Real GetFloatProperty(Prop::ID prop_id) const;
217 
218  int GetIntProperty(Prop::ID prop_id) const;
219 
220  unsigned long GetIndex() const {return index_;}
221  void SetIndex(unsigned long index) {index_=index;}
222 
223 private:
224  ResidueImplW res_;
225  String name_;
226  geom::Vec3 pos_;
227  geom::Vec3 tf_pos_;
228  Real occupancy_;
229  Real b_factor_;
230  AtomProp* prop_;
231  bool is_hetatm_;
232  String element_;
233  ConnectorImplP prim_connector_;
234  ConnectorImplList connector_list_;
235  FragmentImplP fragment_;
236 
239  geom::Mat3 total_rot_;
240 
243  unsigned int state_;
244 
245  void set_state_bit(unsigned int bit, bool state)
246  {
247  unsigned int mask = 0x1<<bit;
248  if(state) {
249  state_ |= mask;
250  } else {
251  state_ &= ~mask;
252  }
253  }
254 
255  bool get_state_bit(unsigned int bit) const {
256  unsigned int mask = 0x1<<bit;
257  return (state_ & mask)!=0;
258  }
259 
260  unsigned long index_;
261 };
262 
264 std::ostream& operator<<(std::ostream& o, const AtomImplPtr ap);
265 
267 bool ConnectorExists(const AtomImplPtr& a, const AtomImplPtr& b);
268 
271 
272 }}} // ns
273 
274 #endif
275 
EntityImplPtr GetEntity() const
Real GetBFactor() const
Definition: atom_impl.hh:111
void SetIndex(unsigned long index)
Definition: atom_impl.hh:221
unsigned int GetState() const
Definition: atom_impl.hh:190
Real GetMass() const
Definition: atom_impl.hh:155
Real GetOccupancy() const
Definition: atom_impl.hh:148
void SetState(int state)
Definition: atom_impl.hh:195
void SetPrimaryConnector(const ConnectorImplP &bp)
Definition: atom_impl.hh:76
const geom::Vec3 & OriginalPos() const
Definition: atom_impl.hh:71
int GetIntProperty(Prop::ID prop_id) const
unsigned long GetIndex() const
Definition: atom_impl.hh:220
bool HasDefaultProps() const
Definition: atom_impl.hh:122
const String & GetName() const
Definition: atom_impl.hh:66
std::string String
Definition: base.hh:54
float Real
Definition: base.hh:44
const String & GetElement() const
Definition: atom_impl.hh:113
const String & Name() const
Definition: atom_impl.hh:62
bool HasPrevious() const
Definition: atom_impl.hh:205
void SetHetAtom(bool het)
Definition: atom_impl.hh:160
boost::shared_ptr< FragmentImpl > FragmentImplP
String GetStringProperty(Prop::ID prop_id) const
ID
Defined properties.
Definition: property_id.hh:41
void TraceDirectionality(FragmentImplP frag, ConnectorImplP conn, int n, unsigned int &c)
trace directionality
void SetElement(const String &ele)
Definition: atom_impl.hh:115
boost::shared_ptr< ResidueImpl > ResidueImplPtr
bool IsTraced() const
Definition: atom_impl.hh:108
boost::shared_ptr< ConnectorImpl > ConnectorImplP
int GetConnectorCount() const
Definition: atom_impl.hh:100
void SetCharge(Real charge)
Definition: atom_impl.hh:180
boost::weak_ptr< ResidueImpl > ResidueImplW
const geom::Vec3 & TransformedPos() const
Definition: atom_impl.hh:68
EntityVisitor interface.
Atom implementation.
Definition: atom_impl.hh:49
void SetBFactor(Real factor)
Definition: atom_impl.hh:138
String GetQualifiedName() const
const ConnectorImplP & GetPrimaryConnector() const
Definition: atom_impl.hh:80
void SetAnisou(const geom::Mat3 &anisou)
Definition: atom_impl.hh:123
ResidueImplPtr GetResidue() const
void SetMass(Real mass)
Definition: atom_impl.hh:162
boost::shared_ptr< AtomImpl > AtomImplPtr
Definition: atom_impl_fw.hh:33
Real GetCharge() const
Definition: atom_impl.hh:156
void AddSecondaryConnector(const ConnectorImplP &bp)
void SetRadius(Real radius)
Definition: atom_impl.hh:171
boost::shared_ptr< EntityImpl > EntityImplPtr
Real GetRadius() const
Definition: atom_impl.hh:153
geom::Vec3 & TransformedPos()
Definition: atom_impl.hh:69
void SetTraced(bool f)
Definition: atom_impl.hh:107
static AtomProp * GetDefaultProps(const String &ele)
Three dimensional vector class, using Real precision.
Definition: vec3.hh:42
bool ConnectorExists(const AtomImplPtr &a, const AtomImplPtr &b)
Real GetFloatProperty(Prop::ID prop_id) const
AtomImpl(const EntityImplPtr &ent, const ResidueImplPtr &res, const String &name, const geom::Vec3 &pos, const String &ele, unsigned long index)
void SetOccupancy(Real occ)
Definition: atom_impl.hh:143
void Apply(EntityVisitor &h)
void DeleteConnector(const ConnectorImplP &conn, bool delete_other=true)
geom::Vec3 & OriginalPos()
Definition: atom_impl.hh:72
const geom::Mat3 & GetAnisou() const
Definition: atom_impl.hh:134
bool IsVisited() const
Definition: atom_impl.hh:105
std::list< ConnectorImplP > ConnectorImplList
base class for the implementation
const ConnectorImplList & GetSecondaryConnectors() const
Definition: atom_impl.hh:84
ConnectorImplP GetConnector(const AtomImplPtr &a, const AtomImplPtr &b)
void SetVisited(bool f)
Definition: atom_impl.hh:104
std::ostream & operator<<(std::ostream &o, const AtomImplPtr ap)