OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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-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_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:
90  EntityView();
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 
115  geom::Vec3 GetCenterOfMass() const;
116 
121  geom::Vec3 GetCenterOfAtoms() const;
122 
123  geom::AlignedCuboid GetBounds() const;
124 
125 public:
127 
128  EntityView(const EntityViewDataPtr& data,
130  const impl::EntityImplPtr impl);
131 
133  const EntityViewDataPtr& ViewData() const;
135  EntityViewDataPtr& ViewData();
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 
264  void RemoveResidue(ResidueView view);
265 
267  void RemoveChain(ChainView view);
268 
271  void AddAllInclusiveBonds();
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 
284  ResidueViewList GetResidueList() const;
285 
287  AtomViewList GetAtomList() const;
288 
290  void Apply(EntityVisitor& visitor);
291 
293  void Apply(EntityViewVisitor& visitor);
294 
296  EntityHandle GetHandle() const;
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 
312  EntityView ExtendViewToResidues() const;
313 
318  EntityView ExtendViewToSurrounding(Real gap) const;
319 
322  String Dump() const;
326  EntityView CreateFullView() const;
328  EntityView CreateEmptyView() 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 
std::vector< ChainView > ChainViewList
Definition: view_type_fw.hh:43
std::string String
Definition: base.hh:54
Handle to atom datatype.
Definition: atom_handle.hh:37
float Real
Definition: base.hh:44
axis-aligned cuboid
Protein or molecule.
std::vector< ResidueView > ResidueViewList
Definition: view_type_fw.hh:37
EntityVisitor interface.
Selection Query.
Definition: query.hh:74
boost::shared_ptr< EntityViewData > EntityViewDataPtr
Definition: view_type_fw.hh:46
uint QueryFlags
Definition: query.hh:69
boost::shared_ptr< EntityImpl > EntityImplPtr
linear chain of residues
Definition: chain_handle.hh:52
definition of ChainView
Definition: chain_view.hh:37
int ViewAddFlags
Definition: view_type_fw.hh:71
Three dimensional vector class, using Real precision.
Definition: vec3.hh:42
#define DLLEXPORT_OST_MOL
std::pair< EntityView, EntityView > EntityViewPair
Definition: entity_view.hh:349
std::vector< AtomView > AtomViewList
Definition: view_type_fw.hh:31
std::vector< BondHandle > BondHandleList
definition of AtomView
Definition: atom_view.hh:34
chemical bond
Definition: bond_handle.hh:34
EntityViewVisitor interface.
bool IsValid() const
check validity of handle
Definition: entity_view.hh:109
definition of EntityView
Definition: entity_view.hh:86
definition of EntityBase
Definition: entity_base.hh:30