OpenStructure
entity_view.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_VIEW_HN
20 #define OST_ENTITY_VIEW_HN
21 /*
22  Author: Marco Biasini
23  */
24 #include <ost/mol/module_config.hh>
25 
26 #include <ost/mol/residue_prop.hh>
27 #include <ost/mol/entity_base.hh>
28 #include <ost/mol/view_type_fw.hh>
32 #include <ost/mol/query.hh>
33 #include <ost/mol/property_id.hh>
34 #include <ost/geom/geom.hh>
35 
36 #ifdef _MSC_VER
37 # ifdef FindAtom
38 # undef FindAtom
39 # endif
40 # ifdef AddAtom
41 # undef AddAtom
42 # endif
43 #endif
44 
45 namespace ost { namespace mol {
46 
87  friend class AtomView;
88  friend class ResidueView;
89 public:
95  explicit EntityView(const EntityHandle& entity,
96  ViewAddFlags flags=0);
97 
99 
100  operator bool() const { return this->IsValid(); }
109  bool IsValid() const { return data_.get()!=0; }
111  Real GetMass() const;
113 
116 
122 
124 
125 public:
127 
128  EntityView(const EntityViewDataPtr& data,
130  const impl::EntityImplPtr impl);
131 
133  const EntityViewDataPtr& ViewData() const;
137 public:
141  EntityView Copy() const;
151  ChainView AddChain(const ChainHandle& chain_handle,
152  ViewAddFlags flags=0);
153 
163  ChainView AddChain(const ChainView& chain_view,
164  ViewAddFlags flags=0);
165 
174  ResidueView AddResidue(const ResidueHandle& residue_handle,
175  ViewAddFlags flags=0);
183  ResidueView AddResidue(const ResidueView& residue_view,
184  ViewAddFlags flags=0);
194  AtomView AddAtom(const AtomHandle& atom_handle,
195  ViewAddFlags flags=0);
196 
197  AtomView AddAtom(const AtomView& atom_view,
198  ViewAddFlags flags=0);
201  EntityView Select(const String& query_string, QueryFlags flags=0) const;
202 
205  EntityView Select(const Query& query, QueryFlags flags=0) const;
206 
208  bool AddBond(const BondHandle& bond_handle);
209 
211  int GetAtomCount() const;
212 
214  int GetResidueCount() const;
215 
217  int GetChainCount() const;
218 
220  ChainView FindChain(const String& chain_name) const;
221 
225  ResidueView FindResidue(const ResidueHandle& residue) const;
226 
227  ResidueView FindResidue(const String& chain, const ResNum& num) const;
228 
233  ResidueView ViewForHandle(const ResidueHandle& residue) const;
237  AtomView FindAtom(const AtomHandle& atom) const;
238  AtomView ViewForHandle(const AtomHandle& atom) const;
239 
244  AtomView FindAtom(const String& chain_name, const ResNum& num,
245  const String& atom_name) const;
249 
250  ChainView FindChain(const ChainHandle& chain) const;
255  ChainView ViewForHandle(const ChainHandle& chain) const;
258  bool IsChainIncluded(const ChainHandle& chain) const;
259 
261  void RemoveAtom(AtomView view);
262 
265 
267  void RemoveChain(ChainView view);
268 
272 
273  const BondHandleList& GetBondList() const;
274 
276  AtomViewList FindWithin(const geom::Vec3& center, Real radius) const;
277 
279  int GetBondCount() const;
280 
281  const ChainViewList& GetChainList() const;
282 
285 
288 
290  void Apply(EntityVisitor& visitor);
291 
293  void Apply(EntityViewVisitor& visitor);
294 
297 
299  std::pair<Real,Real> GetMinMax(const String& prop,
300  Prop::Level hint=Prop::UNSPECIFIED) const;
301 
303  Real GetAngle(const AtomHandle& a1, const AtomHandle& a2,
304  const AtomHandle& a3) const;
305 
307  Real GetAngle(const AtomView& a1, const AtomView& a2,
308  const AtomView& a3) const;
309 
313 
319 
322  String Dump() const;
329 
331  bool HasAtoms() const;
332 #ifdef _MSC_VER
333  // alternative routines for msvc
334  AtomView AddXAtom(const AtomHandle& ah, ViewAddFlags flags=0);
335  AtomView FindXAtom(const AtomHandle& ah);
336 #endif
337  void RemoveBond(const BondHandle& bond);
338 protected:
340  void AddAtomInternal(const AtomView& av);
341  void RemoveAtomInternal(const AtomView& av);
342 
343 private:
344 
345 
346  EntityViewDataPtr data_;
347 };
348 
349 typedef std::pair<EntityView, EntityView> EntityViewPair;
350 
351 }} // ns
352 
353 #endif // OST_ENTITY_VIEW_HH
354 
axis-aligned cuboid
Three dimensional vector class, using Real precision.
Definition: vec3.hh:48
Handle to atom datatype.
Definition: atom_handle.hh:37
definition of AtomView
Definition: atom_view.hh:34
chemical bond
Definition: bond_handle.hh:35
linear chain of residues
Definition: chain_handle.hh:52
definition of ChainView
Definition: chain_view.hh:37
definition of EntityBase
Definition: entity_base.hh:31
Protein or molecule.
definition of EntityView
Definition: entity_view.hh:86
void RemoveAtomInternal(const AtomView &av)
const EntityViewDataPtr & ViewData() const
Get entity view-specific data.
ResidueViewList GetResidueList() const
Get list of all residues included in the view.
void RemoveChain(ChainView view)
remove chain from view
EntityView(const EntityHandle &entity, ViewAddFlags flags=0)
create new entity view from entity handle
EntityViewDataPtr & ViewData()
Get entity view-specific data.
EntityView CreateFullView() const
create a new full view
String Dump() const
returns a string containing a human-readable summary of the entity view
void Apply(EntityViewVisitor &visitor)
Apply entity view visitor to whole view.
const BondHandleList & GetBondList() const
bool AddBond(const BondHandle &bond_handle)
Add a bond.
void RemoveBond(const BondHandle &bond)
EntityView ExtendViewToSurrounding(Real gap) const
Extend current view to include all atoms that are within the sum of their vdw radii + gap.
EntityView ExtendViewToResidues() const
Extend current view to include all atoms of each residue where at least one atom is selected currentl...
void RemoveResidue(ResidueView view)
remove residue from view
AtomViewList GetAtomList() const
Get list of all atoms included in the view.
void AddAtomInternal(const AtomView &av)
std::pair< Real, Real > GetMinMax(const String &prop, Prop::Level hint=Prop::UNSPECIFIED) const
Return the min/max pair for the given property.
ChainView ViewForHandle(const ChainHandle &chain) const
locate chain view for given chain handle
ResidueView AddResidue(const ResidueView &residue_view, ViewAddFlags flags=0)
Add residue to view.
EntityView CreateEmptyView() const
create empty view
void RemoveAtom(AtomView view)
remove atom from view
void Apply(EntityVisitor &visitor)
Apply entity visitor to whole view.
bool IsChainIncluded(const ChainHandle &chain) const
Check whether the view includes the given chain.
AtomView FindAtom(const AtomHandle &atom) const
Find view for given atom handle.
AtomView ViewForHandle(const AtomHandle &atom) const
EntityView Select(const Query &query, QueryFlags flags=0) const
Select a structural subset of the entity view.
const ChainViewList & GetChainList() const
geom::AlignedCuboid GetBounds() const
AtomView AddAtom(const AtomHandle &atom_handle, ViewAddFlags flags=0)
Add atom to view.
int GetAtomCount() const
Get total number of atoms in this entity.
geom::Vec3 GetCenterOfMass() const
Get entity's center of mass (mass weighted)
bool HasAtoms() const
true if view contains at least one atom
Real GetAngle(const AtomHandle &a1, const AtomHandle &a2, const AtomHandle &a3) const
Get angle in radians between bonds a1-a2 and a2-a3.
ChainView AddChain(const ChainHandle &chain_handle, ViewAddFlags flags=0)
Add chain to view.
Real GetAngle(const AtomView &a1, const AtomView &a2, const AtomView &a3) const
Get angle in radians between bonds a1-a2 and a2-a3.
EntityHandle GetHandle() const
Get handle this view points to.
AtomView AddAtom(const AtomView &atom_view, ViewAddFlags flags=0)
ResidueView AddResidue(const ResidueHandle &residue_handle, ViewAddFlags flags=0)
Add residue to view.
ChainView AddChain(const ChainView &chain_view, ViewAddFlags flags=0)
Add chain to view.
bool IsValid() const
check validity of handle
Definition: entity_view.hh:109
ChainView FindChain(const ChainHandle &chain) const
Find chain for given chain handle.
ChainView FindChain(const String &chain_name) const
Find chain by name.
AtomView FindAtom(const String &chain_name, const ResNum &num, const String &atom_name) const
locate atom view for given atom handle
int GetBondCount() const
Get number of bonds.
int GetResidueCount() const
Get total number of residues in this entity.
int GetChainCount() const
Get number of chains in this entity.
EntityView Copy() const
create copy of view
AtomViewList FindWithin(const geom::Vec3 &center, Real radius) const
find atoms close to point
geom::Vec3 GetCenterOfAtoms() const
Get entity's center of atoms (not mass weighted)
ResidueView FindResidue(const ResidueHandle &residue) const
Find atom for given residue handle.
void AddAllInclusiveBonds()
clear bonds and add all inclusive ones (ie where both atoms are present)
EntityView Select(const String &query_string, QueryFlags flags=0) const
Select a structural subset of the entity view.
ResidueView FindResidue(const String &chain, const ResNum &num) const
ResidueView ViewForHandle(const ResidueHandle &residue) const
locate residue view for given residue handle
EntityViewVisitor interface.
EntityVisitor interface.
Selection Query.
Definition: query.hh:74
float Real
Definition: base.hh:44
std::string String
Definition: base.hh:54
#define DLLEXPORT_OST_MOL
boost::shared_ptr< EntityImpl > EntityImplPtr
std::pair< EntityView, EntityView > EntityViewPair
Definition: entity_view.hh:349
uint QueryFlags
Definition: query.hh:69
std::vector< BondHandle > BondHandleList
boost::shared_ptr< EntityViewData > EntityViewDataPtr
Definition: view_type_fw.hh:46
std::vector< AtomView > AtomViewList
Definition: view_type_fw.hh:31
int ViewAddFlags
Definition: view_type_fw.hh:71
std::vector< ResidueView > ResidueViewList
Definition: view_type_fw.hh:37
std::vector< ChainView > ChainViewList
Definition: view_type_fw.hh:43
Definition: base.dox:1