Ticket #944: dihedral.h

File dihedral.h, 2.3 KB (added by Tristan Croll, 8 years ago)
Line 
1
2#ifndef isolde_Dihedral
3#define isolde_Dihedral
4
5#include <vector>
6
7#include <atomstruct/AtomicStructure.h>
8#include <atomstruct/Atom.h>
9#include <atomstruct/Bond.h>
10#include <atomstruct/Coord.h>
11#include <atomstruct/Residue.h>
12
13#include "../geometry/geometry.h"
14
15using namespace atomstruct;
16
17//! Define a dihedral by four atoms.
18/*!
19 * Atoms must be provided in order, such that the central pair defines
20 * the dihedral axis. For the generic base class, the atoms needn't be
21 * bonded to each other, but the same atom must not appear more than
22 * once.
23 */
24class Dihedral {
25
26public:
27 typedef Atom* Atoms[4];
28
29private:
30 Atoms _atoms;
31 const char* err_msg_dup_atom() const
32 {return "All atoms must be unique";}
33 const char* err_msg_multi_struct() const
34 {return "All atoms must be in the same structure";}
35 const char* err_msg_no_residue() const
36 {return "This dihedral has not been attached to a residue";}
37 std::string _name=""; // Name of the dihedral (e.g. phi, psi, omega, ...)
38 // Most dihedrals belong to specific residues by convention, but
39 // we want to leave this optional for this base case.
40 Residue* _residue = nullptr;
41
42public:
43 Dihedral(Atom* a1, Atom* a2, Atom* a3, Atom* a4);
44 ~Dihedral() { auto du = DestructionUser(this); }
45 const Atoms& atoms() const {return _atoms;}
46 Structure* structure() const {return atoms()[0]->structure();}
47 double angle() const; // return the current dihedral angle in radians
48 const std::string& name() const { return _name; }
49 void set_name(const std::string& name) { _name = name; }
50 Residue* residue() const;
51 void set_residue(Residue* residue) { _residue = residue; }
52
53
54}; // class Dihedral
55
56
57//! Define a proper dihedral
58/*!
59 * Atoms must be provided in order and must all be bonded in strict
60 * order atom1--atom2--atom3--atom4.
61 */
62class Proper_Dihedral: public Dihedral {
63
64public:
65 typedef Bond* Bonds[3];
66 Proper_Dihedral(Atom* a1, Atom* a2, Atom* a3, Atom* a4);
67 const Bonds& bonds() const { return _bonds; }
68 Bond* axial_bond() const { return bonds()[1]; }
69
70private:
71 Bonds _bonds;
72 const char* err_msg_not_bonded() const
73 {return "Atoms must be bonded a1--a2--a3--a4";}
74
75}; // class Proper_Dihedral
76
77
78
79#endif // isolde_Dihedral