OpenStructure
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
coord_frame.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_MOL_COORD_FRAME_HH
20 #define OST_MOL_COORD_FRAME_HH
21 
22 /*
23  Authors: Marco Biasini, Niklaus Johner, Ansgar Philippsen
24  */
25 #include <ost/mol/module_config.hh>
26 #include <boost/shared_ptr.hpp>
27 #include <ost/geom/geom.hh>
28 #include <ost/mol/module_config.hh>
29 #include <ost/mol/entity_view.hh>
30 #include "atom_handle.hh"
31 
32 namespace ost { namespace mol {
33 
39 /*
40  TODO:
41  - move algorithmic code to separate functions in mol/alg
42  - clean up mix of views and atom indices methods/functions
43  - use existing UnitCell class
44 */
45 
47 private:
48  geom::Vec3 ucell_size_;
49  geom::Vec3 ucell_angles_;
50 public:
52 
54  CoordFrame(size_t size, const geom::Vec3& value=geom::Vec3()) : base_type(size, value) {}
55  CoordFrame(base_type::iterator b, base_type::iterator e): base_type(b, e) { }
56  CoordFrame(const base_type& rhs) : base_type(rhs) { }
57  CoordFrame(const std::vector<geom::Vec3>& rhs) : base_type(rhs) { }
58  CoordFrame(const std::vector<geom::Vec3>& rhs,
59  const geom::Vec3 box_size,
60  const geom::Vec3 box_angles) : base_type(rhs) {
61  ucell_size_=box_size;
62  ucell_angles_=box_angles;
63  }
64 
65  void SetCellSize(const geom::Vec3& s) {
66  ucell_size_=s;
67  }
68 
70  return this->ucell_size_;
71  }
72 
73  void SetCellAngles(const geom::Vec3& a) {
74  ucell_angles_=a;
75  }
76 
78  return this->ucell_angles_;
79  }
80 
81  geom::Vec3List GetCellVectors() const;
82 
83  geom::Vec3 GetAtomPos(const AtomHandle& atom) const;
84  geom::Vec3 GetAtomPos(int atom_index) const;
85  Real GetDistanceBetwAtoms(const AtomHandle& a1, const AtomHandle& a2) const;
86  Real GetDistanceBetwAtoms(int atom1_index, int atom2_index) const;
87 
94  Real GetAngle(const AtomHandle& a1, const AtomHandle& a2, const AtomHandle& a3) const;
95 
102  Real GetAngle(int atom1_index, int atom2_index, int atom3_index) const;
103 
105  Real GetDihedralAngle(const AtomHandle& a1, const AtomHandle& a2, const AtomHandle& a3, const AtomHandle& a4) const;
106 
108  Real GetDihedralAngle(int a1_index, int a2_index, int a3_index, int a4_index) const;
109 
111  geom::Vec3 GetCenterOfMassPos(const mol::EntityView& sele) const;
112 
114 
118  geom::Vec3 GetCenterOfMassPos(std::vector<unsigned long>& indices,
119  std::vector<Real>& masses) const;
120 
122  Real GetDistanceBetwCenterOfMass(const mol::EntityView& sele1, const mol::EntityView& sele2) const;
123 
129  Real GetDistanceBetwCenterOfMass(std::vector<unsigned long>& indices1, std::vector<Real>& masses1,
130  std::vector<unsigned long>& indices2, std::vector<Real>& masses2) const;
131 
136  Real GetRMSD(const std::vector<geom::Vec3>& ref_pos,
137  const std::vector<unsigned long>& indices_sele) const;
138 
145  Real GetRMSD(const mol::EntityView& reference_view,
146  const mol::EntityView& sele_view) const;
147 
149 
152  Real GetMinDistance(std::vector<unsigned long>& index_list1,
153  std::vector<unsigned long>& index_list2) const;
154 
156  Real GetMinDistance(const mol::EntityView& view1, const mol::EntityView& view2) const;
157 
163  Real GetMinDistBetwCenterOfMassAndView(std::vector<unsigned long>& indices_cm,
164  std::vector<Real>& masses_cm,
165  std::vector<unsigned long>& indices_atoms) const;
168  const mol::EntityView& view_atoms) const;
169 
171  geom::Line3 GetODRLine(std::vector<unsigned long>& indices_ca) const;
172 
174  geom::Plane GetODRPlane(std::vector<unsigned long>& indices_ca) const;
175 
177  geom::Line3 GetODRLine(const mol::EntityView& view1) const;
178  geom::Plane GetODRPlane(const mol::EntityView& view1) const;
179 
185  std::pair<geom::Line3, Real> FitCylinder(std::vector<unsigned long>& indices_ca) const;
186 
188  std::pair<geom::Line3, Real> FitCylinder(const mol::EntityView& view1) const;
189 
197  Real GetAlphaHelixContent(std::vector<unsigned long>& indices_ca,
198  std::vector<unsigned long>& indices_c,
199  std::vector<unsigned long>& indices_o,
200  std::vector<unsigned long>& indices_n) const;
201 
203  Real GetAlphaHelixContent(const mol::EntityView& segment) const;
204 };
205 
206  typedef boost::shared_ptr<CoordFrame> CoordFramePtr;
207  typedef std::vector<CoordFramePtr> CoordFrameList;
208 
209  // factory method
210  // create a frame from a Vec3List containing the positions of the atoms, optionally with unit cell
211  // TODO: why is this necessary? the ctor works fine
213  const geom::Vec3& cell_size=geom::Vec3(),
214  const geom::Vec3& cell_angles=geom::Vec3());
215 
216  // these should really be either in the entity view interface or in mol/alg
217 
222  DLLEXPORT_OST_MOL void GetIndices(const EntityView& sele, std::vector<unsigned long>& indices);
223 
228  DLLEXPORT_OST_MOL void GetMasses(const EntityView& sele, std::vector<Real>& masses);
229 
232  std::vector<unsigned long>& indices,
233  std::vector<Real>& masses);
234 
236  DLLEXPORT_OST_MOL void GetPositions(const EntityView& sele, std::vector<geom::Vec3>& ref_pos);
237 
239  DLLEXPORT_OST_MOL void GetCaIndices(const EntityView& segment, std::vector<unsigned long>& indices_ca);
240 
242  DLLEXPORT_OST_MOL void GetCaCONIndices(const EntityView& segment,
243  std::vector<unsigned long>& indices_ca,
244  std::vector<unsigned long>& indices_c,
245  std::vector<unsigned long>& indices_o,
246  std::vector<unsigned long>& indices_n);
247 
248 
249 }}
250 
251 #endif
DLLEXPORT_OST_MOL void GetIndices(const EntityView &sele, std::vector< unsigned long > &indices)
Handle to atom datatype.
Definition: atom_handle.hh:37
float Real
Definition: base.hh:44
CoordFrame(const base_type &rhs)
Definition: coord_frame.hh:56
geom::Vec3List base_type
Definition: coord_frame.hh:51
geom::Vec3 GetCellAngles() const
Definition: coord_frame.hh:77
void SetCellSize(const geom::Vec3 &s)
Definition: coord_frame.hh:65
Line3.
Definition: composite3.hh:39
CoordFrame(size_t size, const geom::Vec3 &value=geom::Vec3())
Definition: coord_frame.hh:54
std::vector< Vec3 > base_type
Definition: vec3.hh:241
boost::shared_ptr< CoordFrame > CoordFramePtr
Definition: coord_frame.hh:206
CoordFrame(const std::vector< geom::Vec3 > &rhs)
Definition: coord_frame.hh:57
geom::Vec3 GetCellSize() const
Definition: coord_frame.hh:69
void SetCellAngles(const geom::Vec3 &a)
Definition: coord_frame.hh:73
DLLEXPORT_OST_MOL void GetIndicesAndMasses(const EntityView &sele, std::vector< unsigned long > &indices, std::vector< Real > &masses)
conveniece for GetIndices and GetMasses in one call
CoordFrame(base_type::iterator b, base_type::iterator e)
Definition: coord_frame.hh:55
Three dimensional vector class, using Real precision.
Definition: vec3.hh:43
#define DLLEXPORT_OST_MOL
DLLEXPORT_OST_MOL void GetCaCONIndices(const EntityView &segment, std::vector< unsigned long > &indices_ca, std::vector< unsigned long > &indices_c, std::vector< unsigned long > &indices_o, std::vector< unsigned long > &indices_n)
Writes the backbone indices of all residues in the EntityView into the provided list.
DLLEXPORT_OST_MOL void GetPositions(const EntityView &sele, std::vector< geom::Vec3 > &ref_pos)
Writes the positions of all atoms in the EntityView into the provided vec3 list.
std::vector< CoordFramePtr > CoordFrameList
Definition: coord_frame.hh:207
DLLEXPORT_OST_MOL void GetMasses(const EntityView &sele, std::vector< Real > &masses)
DLLEXPORT_OST_MOL void GetCaIndices(const EntityView &segment, std::vector< unsigned long > &indices_ca)
Writes the indices of all atoms in the EntityView into the provided list.
DLLEXPORT_OST_MOL CoordFrame CreateCoordFrame(const geom::Vec3List &atom_pos, const geom::Vec3 &cell_size=geom::Vec3(), const geom::Vec3 &cell_angles=geom::Vec3())
definition of EntityView
Definition: entity_view.hh:86
CoordFrame(const std::vector< geom::Vec3 > &rhs, const geom::Vec3 box_size, const geom::Vec3 box_angles)
Definition: coord_frame.hh:58