OpenStructure
entity_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-2020 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_ENTITY_IMPL_HH
20 #define OST_ENTITY_IMPL_HH
21 
22 #include <map>
23 #include <vector>
24 
25 #include <boost/enable_shared_from_this.hpp>
26 
27 #include <ost/mol/module_config.hh>
28 #include <ost/geom/geom.hh>
29 
31 
32 #include <ost/mol/entity_view.hh>
33 
34 #include <ost/mol/residue_prop.hh>
44 #include <ost/mol/entity_view.hh>
45 #include <ost/mol/entity_handle.hh>
47 
48 
49 #include <ost/generic_property.hh>
50 
51 namespace ost { namespace mol { namespace impl {
52 
54 typedef std::map<AtomImpl*,AtomImplPtr> AtomImplMap;
56 typedef std::map<ResidueImpl*,ResidueImplPtr> ResidueImplMap;
58 typedef std::vector<ChainImplPtr> ChainImplList;
60 typedef std::map<ConnectorImpl*,ConnectorImplP> ConnectorImplMap;
62 typedef std::map<TorsionImpl*,TorsionImplP> TorsionImplMap;
64 typedef std::vector<FragmentImplP> FragmentImplList;
66 typedef std::map<EntityObserver*,EntityObserverPtr> EntityObserverMap;
69 
71 typedef enum {
74  // dirty trace (implies dirty ICS)
77  DisableICS=16
79 
80 
83  public boost::enable_shared_from_this<EntityImpl>
84 {
85 public:
88 
91 
92  Real GetMass() const;
97 
98 
99 
100  // default copy ctor and assignment op should work for now
101  AtomImplPtr CreateAtom(const ResidueImplPtr& rp, const String& name,
102  const geom::Vec3& pos, const String& ele);
103 
105  const ResNum& n,
106  const ResidueKey& k);
107 
112  // force deep to be set explicitely, because it is better than implicit
113  // (and since we are on the impl level interface consistency isn't that critical)
114  ChainImplPtr InsertChain(const String& chain_name, const ChainImplPtr& chain, bool deep);
115  ConnectorImplP Connect(const AtomImplPtr& first, const AtomImplPtr& second,
116  Real len, Real theta, Real phi,
117  unsigned char bond_order);
118 
119  TorsionImplP AddTorsion(const String& name, const AtomImplPtr& a1,
120  const AtomImplPtr& a2, const AtomImplPtr& a3,
121  const AtomImplPtr& a4);
122 
124 
127  const AtomImplPtr& a2,
128  const AtomImplPtr& a3,
129  const AtomImplPtr& a4) const;
130 
131  void RenameChain(ChainImplPtr chain, const String& new_name);
132  bool SetAngle(const AtomImplPtr& a1, const AtomImplPtr& a2,
133  const AtomImplPtr& a3, Real angle);
134 
135  Real GetAngle(const AtomImplPtr& a1, const AtomImplPtr& a2,
136  const AtomImplPtr& a3) const;
137  Real GetAngleXCS(const AtomImplPtr& a1, const AtomImplPtr& a2,
138  const AtomImplPtr& a3) const;
139  Real GetAngleICS(const AtomImplPtr& a1, const AtomImplPtr& a2,
140  const AtomImplPtr& a3) const;
141  // update positions from internal coordinate system
143 
144  // update internal coordinate system from positions
146 
149 
151  const geom::Transform& GetTransform() const {return transform_;}
152  bool HasTransform() const {return has_transform_;}
154  void FixTransform();
155 
159 
160 
162 
163  AtomImplList FindWithin(const geom::Vec3& pos, Real radius);
164  // use query flag defaults
165  EntityView Select(const EntityHandle& h, const Query& q) const;
166  // override query flag defaults with given flags
167  EntityView Select(const EntityHandle& h, const Query& q,
168  QueryFlags flags) const;
170  void SetDefaultQueryFlags(QueryFlags f) {default_query_flags_=f;}
171  QueryFlags GetDefaultQueryFlags() const {return default_query_flags_;}
172 
173 
176  ChainImplPtr FindChain(const String& name) const;
177 
178  ResidueImplPtr FindResidue(const String& chain_name,
179  const ResNum& residue) const;
180 
181  AtomImplPtr FindAtom(const String& chain_name,
182  const ResNum& residue,
183  const String& atom_name) const;
184  /*
185  this is a deep-swap which will exchange the internal structure
186  of two implementations, which by design affects _all_ entity handles
187  that point two either of these two implementations
188  */
189  void Swap(EntityImpl& impl);
190 
192  int GetAtomCount() const;
193 
195  int GetBondCount() const;
196 
199 
200 
202  int GetResidueCount() const;
203 
205  int GetChainCount() const;
206 
207  const ChainImplList& GetChainList() const { return chain_list_; }
208 
209  ChainImplList& GetChainList() { return chain_list_; }
210 
212 
213  void DeleteChain(const ChainImplPtr& chain);
214 
215  void DeleteAtom(const AtomImplPtr& atom);
216 
219 
222 
224 
226 
228 
230 
231  void EnableICS();
232 
233  bool HasICS() const;
234 
235  bool IsXCSDirty() const;
236 
237  void MarkXCSDirty();
238  void MarkICSDirty();
241 
243 
244  const String& GetName() const;
245 
246  impl::ChainImplList::iterator GetChain(const String& name);
247 
249  void SetName(const String& ent_name);
250 
252 
253  void RenumberAllResidues(int start, bool keep_spacing);
254 
255  void RenumberChain(const String& name, int start, bool keep_spacing);
256 
257 private:
258  void DoCopy(EntityImplPtr dest);
259 
260  void ReplicateHierarchy(EntityImplPtr dest);
261 
262  void DoCopyBondsAndTorsions(EntityImplPtr dest);
263 
264  AtomImplMap atom_map_;
265  ChainImplList chain_list_;
266  ConnectorImplMap connector_map_;
267  TorsionImplMap torsion_map_;
268 
269  geom::Transform transform_;
270  bool has_transform_;
271 
272  SpatialAtomOrganizer atom_organizer_;
273  FragmentImplList fragment_list_;
274  EntityObserverMap observer_map_;
275 
276  int xcs_editor_count_;
277  int ics_editor_count_;
278  int dirty_flags_;
279  String name_;
280 
281  unsigned long next_index_;
282 
283  QueryFlags default_query_flags_;
284 
285  template <bool always_true>
286  EntityView do_selection(const EntityHandle&, const Query&, QueryFlags) const;
287 };
288 
289 }}} // ns
290 
291 #endif
axis-aligned cuboid
basic and essential transformation class, including translation, rotation and center of rotation
Definition: transform.hh:39
Three dimensional vector class, using Real precision.
Definition: vec3.hh:48
base class for the implementation
Protein or molecule.
definition of EntityView
Definition: entity_view.hh:86
EntityVisitor interface.
Selection Query.
Definition: query.hh:74
EntityView Select(const EntityHandle &h, const Query &q, QueryFlags flags) const
void DeleteFromConnMap(const ConnectorImplP &conn)
Real GetAngleXCS(const AtomImplPtr &a1, const AtomImplPtr &a2, const AtomImplPtr &a3) const
AtomImplList FindWithin(const geom::Vec3 &pos, Real radius)
TorsionImplP AddTorsion(const String &name, const AtomImplPtr &a1, const AtomImplPtr &a2, const AtomImplPtr &a3, const AtomImplPtr &a4)
AtomImplPtr FindAtom(const String &chain_name, const ResNum &residue, const String &atom_name) const
EntityView CreateFullView(const EntityHandle &h) const
void AttachObserver(const EntityObserverPtr &o)
void SetName(const String &ent_name)
EntityView Select(const EntityHandle &h, const Query &q) const
void RenumberChain(const String &name, int start, bool keep_spacing)
void RenumberAllResidues(int start, bool keep_spacing)
ConnectorImplP Connect(const AtomImplPtr &first, const AtomImplPtr &second, Real len, Real theta, Real phi, unsigned char bond_order)
pointer_it< ChainImplPtr > GetChainIter(const String &name)
void SetTransform(const geom::Transform &t)
void DeleteAtom(const AtomImplPtr &atom)
ChainImplPtr InsertChain(const String &cname)
void RenameChain(ChainImplPtr chain, const String &new_name)
void SetDefaultQueryFlags(QueryFlags f)
Definition: entity_impl.hh:170
geom::AlignedCuboid GetBounds() const
returns the axis-aligned bounding box of the entity
void DeleteChain(const ChainImplPtr &chain)
EntityImplPtr Copy()
copy entity
Real GetAngleICS(const AtomImplPtr &a1, const AtomImplPtr &a2, const AtomImplPtr &a3) const
int GetAtomCount() const
Get total number of atoms of all chains belonging to this entity.
TorsionImplMap & GetTorsionMap()
geom::Vec3 GetCenterOfMass() const
AtomImplPtr CreateAtom(const ResidueImplPtr &rp, const String &name, const geom::Vec3 &pos, const String &ele)
impl::ChainImplList::iterator GetChain(const String &name)
const ChainImplList & GetChainList() const
Definition: entity_impl.hh:207
ChainImplPtr FindChain(const String &name) const
void Apply(EntityVisitor &v)
Real GetAngle(const AtomImplPtr &a1, const AtomImplPtr &a2, const AtomImplPtr &a3) const
ResidueImplPtr CreateResidue(const ChainImplPtr &cp, const ResNum &n, const ResidueKey &k)
const geom::Transform & GetTransform() const
Definition: entity_impl.hh:151
mol::BondHandleList GetBondList() const
Get list of bonds.
void ApplyTransform(const geom::Transform &t)
bool SetAngle(const AtomImplPtr &a1, const AtomImplPtr &a2, const AtomImplPtr &a3, Real angle)
ResidueImplPtr FindResidue(const String &chain_name, const ResNum &residue) const
void Swap(EntityImpl &impl)
int GetBondCount() const
Get total number of bonds belonging to this entity.
int GetResidueCount() const
Get total number of residues of all chains belonging to this entity.
int GetChainCount() const
Get number of chains.
geom::Vec3 GetCenterOfAtoms() const
TorsionImplP FindTorsion(const AtomImplPtr &a1, const AtomImplPtr &a2, const AtomImplPtr &a3, const AtomImplPtr &a4) const
Search for torsion.
const String & GetName() const
void DetachObserver(const EntityObserverPtr &o)
ChainImplPtr InsertChain(const String &chain_name, const ChainImplPtr &chain, bool deep)
insert a new chain based on parameters of the given chain
QueryFlags GetDefaultQueryFlags() const
Definition: entity_impl.hh:171
ChainImplList & GetChainList()
Definition: entity_impl.hh:209
float Real
Definition: base.hh:44
std::string String
Definition: base.hh:54
boost::shared_ptr< AtomImpl > AtomImplPtr
Definition: atom_impl_fw.hh:33
boost::shared_ptr< TorsionImpl > TorsionImplP
std::map< ConnectorImpl *, ConnectorImplP > ConnectorImplMap
Definition: entity_impl.hh:60
std::vector< AtomImplPtr > AtomImplList
Definition: atom_impl_fw.hh:38
boost::shared_ptr< ChainImpl > ChainImplPtr
std::vector< FragmentImplP > FragmentImplList
Definition: entity_impl.hh:64
std::map< TorsionImpl *, TorsionImplP > TorsionImplMap
Definition: entity_impl.hh:62
boost::shared_ptr< EntityImpl > EntityImplPtr
std::vector< ChainImplPtr > ChainImplList
Definition: entity_impl.hh:58
std::map< EntityObserver *, EntityObserverPtr > EntityObserverMap
Definition: entity_impl.hh:66
boost::shared_ptr< ConnectorImpl > ConnectorImplP
boost::shared_ptr< ResidueImpl > ResidueImplPtr
SpatialOrganizer< AtomImplPtr > SpatialAtomOrganizer
Definition: entity_impl.hh:68
std::map< ResidueImpl *, ResidueImplPtr > ResidueImplMap
Definition: entity_impl.hh:56
std::map< AtomImpl *, AtomImplPtr > AtomImplMap
Definition: entity_impl.hh:54
boost::shared_ptr< EntityObserver > EntityObserverPtr
uint QueryFlags
Definition: query.hh:69
std::vector< BondHandle > BondHandleList
String ResidueKey
Definition: base.dox:1