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-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_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::Vec3 GetAtomPos(const AtomHandle& atom) const;
82  geom::Vec3 GetAtomPos(int atom_index) const;
83  Real GetDistanceBetwAtoms(const AtomHandle& a1, const AtomHandle& a2) const;
84  Real GetDistanceBetwAtoms(int atom1_index, int atom2_index) const;
85 
92  Real GetAngle(const AtomHandle& a1, const AtomHandle& a2, const AtomHandle& a3) const;
93 
100  Real GetAngle(int atom1_index, int atom2_index, int atom3_index) const;
101 
103  Real GetDihedralAngle(const AtomHandle& a1, const AtomHandle& a2, const AtomHandle& a3, const AtomHandle& a4) const;
104 
106  Real GetDihedralAngle(int a1_index, int a2_index, int a3_index, int a4_index) const;
107 
109  geom::Vec3 GetCenterOfMassPos(const mol::EntityView& sele) const;
110 
112 
116  geom::Vec3 GetCenterOfMassPos(std::vector<unsigned long>& indices,
117  std::vector<Real>& masses) const;
118 
120  Real GetDistanceBetwCenterOfMass(const mol::EntityView& sele1, const mol::EntityView& sele2) const;
121 
127  Real GetDistanceBetwCenterOfMass(std::vector<unsigned long>& indices1, std::vector<Real>& masses1,
128  std::vector<unsigned long>& indices2, std::vector<Real>& masses2) const;
129 
134  Real GetRMSD(const std::vector<geom::Vec3>& ref_pos,
135  const std::vector<unsigned long>& indices_sele) const;
136 
143  Real GetRMSD(const mol::EntityView& reference_view,
144  const mol::EntityView& sele_view) const;
145 
147 
150  Real GetMinDistance(std::vector<unsigned long>& index_list1,
151  std::vector<unsigned long>& index_list2) const;
152 
154  Real GetMinDistance(const mol::EntityView& view1, const mol::EntityView& view2) const;
155 
161  Real GetMinDistBetwCenterOfMassAndView(std::vector<unsigned long>& indices_cm,
162  std::vector<Real>& masses_cm,
163  std::vector<unsigned long>& indices_atoms) const;
166  const mol::EntityView& view_atoms) const;
167 
169  geom::Line3 GetODRLine(std::vector<unsigned long>& indices_ca) const;
170 
172  geom::Plane GetODRPlane(std::vector<unsigned long>& indices_ca) const;
173 
175  geom::Line3 GetODRLine(const mol::EntityView& view1) const;
176  geom::Plane GetODRPlane(const mol::EntityView& view1) const;
177 
183  geom::Line3 FitCylinder(std::vector<unsigned long>& indices_ca) const;
184 
186  geom::Line3 FitCylinder(const mol::EntityView& view1) const;
187 
195  Real GetAlphaHelixContent(std::vector<unsigned long>& indices_ca,
196  std::vector<unsigned long>& indices_c,
197  std::vector<unsigned long>& indices_o,
198  std::vector<unsigned long>& indices_n) const;
199 
201  Real GetAlphaHelixContent(const mol::EntityView& segment) const;
202 };
203 
204  typedef boost::shared_ptr<CoordFrame> CoordFramePtr;
205  typedef std::vector<CoordFramePtr> CoordFrameList;
206 
207  // factory method
208  // create a frame from a Vec3List containing the positions of the atoms, optionally with unit cell
209  // TODO: why is this necessary? the ctor works fine
211  const geom::Vec3& cell_size=geom::Vec3(),
212  const geom::Vec3& cell_angles=geom::Vec3());
213 
214  // these should really be either in the entity view interface or in mol/alg
215 
220  DLLEXPORT_OST_MOL void GetIndices(const EntityView& sele, std::vector<unsigned long>& indices);
221 
226  DLLEXPORT_OST_MOL void GetMasses(const EntityView& sele, std::vector<Real>& masses);
227 
230  std::vector<unsigned long>& indices,
231  std::vector<Real>& masses);
232 
234  DLLEXPORT_OST_MOL void GetPositions(const EntityView& sele, std::vector<geom::Vec3>& ref_pos);
235 
237  DLLEXPORT_OST_MOL void GetCaIndices(const EntityView& segment, std::vector<unsigned long>& indices_ca);
238 
240  DLLEXPORT_OST_MOL void GetCaCONIndices(const EntityView& segment,
241  std::vector<unsigned long>& indices_ca,
242  std::vector<unsigned long>& indices_c,
243  std::vector<unsigned long>& indices_o,
244  std::vector<unsigned long>& indices_n);
245 
246 
247 }}
248 
249 #endif