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 <boost/shared_ptr.hpp>
26 #include <ost/geom/geom.hh>
27 #include <ost/mol/module_config.hh>
28 #include <ost/mol/entity_view.hh>
29 #include "atom_handle.hh"
30 
31 namespace ost { namespace mol {
32 
38 /*
39  TODO:
40  - move algorithmic code to separate functions in mol/alg
41  - clean up mix of views and atom indices methods/functions
42  - use existing UnitCell class
43 */
44 
46 private:
47  geom::Vec3 ucell_size_;
48  geom::Vec3 ucell_angles_;
49 public:
51 
53  CoordFrame(size_t size, const geom::Vec3& value=geom::Vec3()) : base_type(size, value) {}
54  CoordFrame(base_type::iterator b, base_type::iterator e): base_type(b, e) { }
55  CoordFrame(const base_type& rhs) : base_type(rhs) { }
56  CoordFrame(const std::vector<geom::Vec3>& rhs) : base_type(rhs) { }
57  CoordFrame(const std::vector<geom::Vec3>& rhs,
58  const geom::Vec3 box_size,
59  const geom::Vec3 box_angles) : base_type(rhs) {
60  ucell_size_=box_size;
61  ucell_angles_=box_angles;
62  }
63 
64  void SetCellSize(const geom::Vec3& s) {
65  ucell_size_=s;
66  }
67 
69  return this->ucell_size_;
70  }
71 
72  void SetCellAngles(const geom::Vec3& a) {
73  ucell_angles_=a;
74  }
75 
77  return this->ucell_angles_;
78  }
79 
80  geom::Vec3 GetAtomPos(const AtomHandle& atom) const;
81  geom::Vec3 GetAtomPos(int atom_index) const;
82  Real GetDistanceBetwAtoms(const AtomHandle& a1, const AtomHandle& a2) const;
83  Real GetDistanceBetwAtoms(int atom1_index, int atom2_index) const;
84 
91  Real GetAngle(const AtomHandle& a1, const AtomHandle& a2, const AtomHandle& a3) const;
92 
99  Real GetAngle(int atom1_index, int atom2_index, int atom3_index) const;
100 
102  Real GetDihedralAngle(const AtomHandle& a1, const AtomHandle& a2, const AtomHandle& a3, const AtomHandle& a4) const;
103 
105  Real GetDihedralAngle(int a1_index, int a2_index, int a3_index, int a4_index) const;
106 
108  geom::Vec3 GetCenterOfMassPos(const mol::EntityView& sele) const;
109 
111 
115  geom::Vec3 GetCenterOfMassPos(std::vector<unsigned long>& indices,
116  std::vector<Real>& masses) const;
117 
119  Real GetDistanceBetwCenterOfMass(const mol::EntityView& sele1, const mol::EntityView& sele2) const;
120 
126  Real GetDistanceBetwCenterOfMass(std::vector<unsigned long>& indices1, std::vector<Real>& masses1,
127  std::vector<unsigned long>& indices2, std::vector<Real>& masses2) const;
128 
133  Real GetRMSD(const std::vector<geom::Vec3>& ref_pos,
134  const std::vector<unsigned long>& indices_sele) const;
135 
142  Real GetRMSD(const mol::EntityView& reference_view,
143  const mol::EntityView& sele_view) const;
144 
146 
149  Real GetMinDistance(std::vector<unsigned long>& index_list1,
150  std::vector<unsigned long>& index_list2) const;
151 
153  Real GetMinDistance(const mol::EntityView& view1, const mol::EntityView& view2) const;
154 
160  Real GetMinDistBetwCenterOfMassAndView(std::vector<unsigned long>& indices_cm,
161  std::vector<Real>& masses_cm,
162  std::vector<unsigned long>& indices_atoms) const;
165  const mol::EntityView& view_atoms) const;
166 
168  geom::Line3 GetODRLine(std::vector<unsigned long>& indices_ca) const;
169 
171  geom::Plane GetODRPlane(std::vector<unsigned long>& indices_ca) const;
172 
174  geom::Line3 GetODRLine(const mol::EntityView& view1) const;
175  geom::Plane GetODRPlane(const mol::EntityView& view1) const;
176 
182  geom::Line3 FitCylinder(std::vector<unsigned long>& indices_ca) const;
183 
185  geom::Line3 FitCylinder(const mol::EntityView& view1) const;
186 
194  Real GetAlphaHelixContent(std::vector<unsigned long>& indices_ca,
195  std::vector<unsigned long>& indices_c,
196  std::vector<unsigned long>& indices_o,
197  std::vector<unsigned long>& indices_n) const;
198 
200  Real GetAlphaHelixContent(const mol::EntityView& segment) const;
201 };
202 
203  typedef boost::shared_ptr<CoordFrame> CoordFramePtr;
204  typedef std::vector<CoordFramePtr> CoordFrameList;
205 
206  // factory method
207  // create a frame from a Vec3List containing the positions of the atoms, optionally with unit cell
208  // TODO: why is this necessary? the ctor works fine
210  const geom::Vec3& cell_size=geom::Vec3(),
211  const geom::Vec3& cell_angles=geom::Vec3());
212 
213  // these should really be either in the entity view interface or in mol/alg
214 
219  DLLEXPORT_OST_MOL void GetIndices(const EntityView& sele, std::vector<unsigned long>& indices);
220 
225  DLLEXPORT_OST_MOL void GetMasses(const EntityView& sele, std::vector<Real>& masses);
226 
229  std::vector<unsigned long>& indices,
230  std::vector<Real>& masses);
231 
233  DLLEXPORT_OST_MOL void GetPositions(const EntityView& sele, std::vector<geom::Vec3>& ref_pos);
234 
236  DLLEXPORT_OST_MOL void GetCaIndices(const EntityView& segment, std::vector<unsigned long>& indices_ca);
237 
239  DLLEXPORT_OST_MOL void GetCaCONIndices(const EntityView& segment,
240  std::vector<unsigned long>& indices_ca,
241  std::vector<unsigned long>& indices_c,
242  std::vector<unsigned long>& indices_o,
243  std::vector<unsigned long>& indices_n);
244 
245 
246 }}
247 
248 #endif