indigoX
molecule_impl.hpp
Go to the documentation of this file.
1 #ifndef INDIGOX_CLASSES_MOLECULE_IMPL_HPP
2 #define INDIGOX_CLASSES_MOLECULE_IMPL_HPP
3 
4 #include "../graph/condensed.hpp"
5 #include "../graph/molecular.hpp"
6 #include "../utils/fwd_declares.hpp"
7 #include "angle.hpp"
8 #include "atom.hpp"
9 #include "bond.hpp"
10 #include "dihedral.hpp"
11 #include "forcefield.hpp"
12 #include "molecule.hpp"
13 #include "periodictable.hpp"
14 #include "residue.hpp"
15 
16 #include <bitset>
17 
18 namespace indigox {
19 
20  // =======================================================================
21  // == ANGLE IMPLEMENTATION ===============================================
22  // =======================================================================
23 
24  struct Angle::Impl {
27  int64_t tag;
28  int64_t unique_id;
30 
31  template <typename Archive>
32  void serialise(Archive &archive, const uint32_t);
33 
34  Impl() = default;
35  Impl(const Atom &a, const Atom &b, const Atom &c, const Molecule &mol);
36  };
37 
38  // =======================================================================
39  // == ATOM IMPLEMENTATION ================================================
40  // =======================================================================
41 
42  struct Atom::Impl {
45  int32_t formal_charge;
46  int64_t tag;
47  int64_t unique_id;
48  int32_t charge_group_id;
49  int32_t residue_id;
51  Eigen::Vector3d position;
52  std::string name;
53  std::string residue_name;
60 
61  template <typename Archive>
62  void serialise(Archive &archive, const uint32_t);
63 
64  Impl() = default;
65  Impl(const Molecule &mol, const Element &elem, double x, double y, double z,
66  std::string n);
67  };
68 
69  // =======================================================================
70  // == BOND IMPLEMENTATION ================================================
71  // =======================================================================
72 
73  struct Bond::Impl {
76  int64_t tag;
77  int64_t unique_id;
81 
82  template <typename Archive>
83  void serialise(Archive &archive, const uint32_t version);
84 
85  Impl() = default;
86  Impl(const Atom &a, const Atom &b, const Molecule &mol, BondOrder o);
87  };
88 
89  // =======================================================================
90  // == DIHEDRAL IMPLEMENTATION ============================================
91  // =======================================================================
92 
93  struct Dihedral::Impl {
96  int64_t tag;
97  int64_t unique_id;
99  int32_t priority;
100 
101  template <typename Archive>
102  void serialise(Archive &archive, const uint32_t version);
103 
104  Impl() = default;
105  Impl(const Atom &a, const Atom &b, const Atom &c, const Atom &d,
106  const Molecule &molecule);
107  };
108 
109  // =======================================================================
110  // == RESIDUE IMPLEMENTATION =============================================
111  // =======================================================================
112 
113  struct Residue::Impl {
118  eastl::vector_set<int32_t> cache_aa_length;
119 
120  template <typename Archive>
121  void serialise(Archive &archive, const uint32_t version);
122 
123  Impl() = default;
124  Impl(const std::vector<Atom> &atms, const Molecule &mol);
125 
126  bool AminoAcidTest();
127 
128  void DetermineType();
129  };
130 
131  // =======================================================================
132  // == MOLECULE IMPLEMENTATION ============================================
133  // =======================================================================
134 
135  enum class CalculatedData : uint8_t {
136  Formula,
142  Number
143  };
144 
145  struct Molecule::Impl {
146  std::string name;
147  int64_t next_unique_id;
157 
158  std::bitset<static_cast<uint8_t>(CalculatedData::Number)> calculated_data;
159 
160  // Cached variables
161  std::string cached_formula;
162 
163  template <typename Archive>
164  void serialise(Archive &archive, const uint32_t);
165 
166  Impl() = default;
167  Impl(std::string n);
168 
169  // Return the index in a's bonds if found, -1 if not found
170  int64_t FindBond(const Atom &a, const Atom &b) const;
171  // Return the index in b's angles if found, -1 if not found
172  int64_t FindAngle(const Atom &a, const Atom &b, const Atom &c) const;
173  // Return the index in a's dihedrals if found, -1 if not found
174  int64_t FindDihedral(const Atom &a, const Atom &b, const Atom &c,
175  const Atom &d) const;
176 
177  inline bool Test(CalculatedData dat) const {
178  return calculated_data.test(static_cast<uint8_t>(dat));
179  }
180  inline void Set(CalculatedData dat) {
181  calculated_data.set(static_cast<uint8_t>(dat));
182  }
183  inline void Reset(CalculatedData dat) {
184  calculated_data.reset(static_cast<uint8_t>(dat));
185  }
186  inline void Reset() { calculated_data.reset(); }
187  };
188 } // namespace indigox
189 
190 #endif /* molecule_impl_hpp */
Definition: forcefield.hpp:18
BondAtoms atoms
Definition: molecule_impl.hpp:74
DihedralAtoms atoms
Definition: molecule_impl.hpp:94
Definition: forcefield.hpp:58
std::vector< Angle > MoleculeAngles
Container for storing IXAngle instances.
Definition: molecule.hpp:28
BondStereo stereochemistry
Definition: molecule_impl.hpp:79
std::vector< Atom > MoleculeAtoms
Container for storing IXAtom instances.
Definition: molecule.hpp:22
void Reset(CalculatedData dat)
Definition: molecule_impl.hpp:183
Atom::AtomDihedrals dihedrals
Definition: molecule_impl.hpp:59
std::string cached_formula
Definition: molecule_impl.hpp:161
MoleculeResidues residues
Definition: molecule_impl.hpp:153
std::vector< Angle > AtomAngles
Container for storing IXAngle references.
Definition: atom.hpp:23
MoleculeAtoms atoms
Definition: molecule_impl.hpp:149
Definition: atom.hpp:13
Type
Definition: residue.hpp:19
graph::MolecularGraph residue_graph
Definition: molecule_impl.hpp:117
std::vector< Dihedral > AtomDihedrals
Container for storing IXDihedral references.
Definition: atom.hpp:25
void Set(CalculatedData dat)
Definition: molecule_impl.hpp:180
Definition: molecule_impl.hpp:73
Molecule molecule
Definition: molecule_impl.hpp:26
int64_t tag
Definition: molecule_impl.hpp:96
Definition: condensed.hpp:131
CalculatedData
Definition: molecule_impl.hpp:135
int32_t charge_group_id
Definition: molecule_impl.hpp:48
void serialise(Archive &archive, const uint32_t)
Element element
Definition: molecule_impl.hpp:44
eastl::vector_set< int32_t > cache_aa_length
Definition: molecule_impl.hpp:118
double partial_charge
Definition: molecule_impl.hpp:54
graph::MolecularGraph molecular_graph
Definition: molecule_impl.hpp:155
Definition: molecule_impl.hpp:113
void serialise(Archive &archive, const uint32_t version)
Molecule molecule
Definition: molecule_impl.hpp:95
void serialise(Archive &archive, const uint32_t)
Atom::AtomAngles angles
Definition: molecule_impl.hpp:58
int32_t residue_id
Definition: molecule_impl.hpp:49
Class containing a graph representation of a molecule.
Definition: molecular.hpp:95
std::string residue_name
Definition: molecule_impl.hpp:53
void serialise(Archive &archive, const uint32_t version)
graph::CondensedMolecularGraph condensed_molecular_graph
Definition: molecule_impl.hpp:156
ResidueType type
Definition: molecule_impl.hpp:114
std::vector< Residue > MoleculeResidues
Definition: molecule.hpp:33
Namespace for all graph related functionality.
Definition: access.hpp:7
int64_t FindDihedral(const Atom &a, const Atom &b, const Atom &c, const Atom &d) const
int64_t unique_id
Definition: molecule_impl.hpp:47
int64_t FindBond(const Atom &a, const Atom &b) const
void serialise(Archive &archive, const uint32_t)
std::vector< Bond > AtomBonds
Container for storing Bond references.
Definition: atom.hpp:21
Order
Enum for the different possible bond orders.
Definition: bond.hpp:31
int64_t unique_id
Definition: molecule_impl.hpp:97
std::string name
Definition: molecule_impl.hpp:52
Molecule molecule
Definition: molecule_impl.hpp:43
MoleculeDihedrals dihedrals
Definition: molecule_impl.hpp:152
int64_t tag
Definition: molecule_impl.hpp:76
MoleculeAngles angles
Definition: molecule_impl.hpp:151
int32_t priority
Definition: molecule_impl.hpp:99
std::vector< Dihedral > MoleculeDihedrals
Container for storing IXDihedral instances.
Definition: molecule.hpp:31
int32_t implicit_hydrogens
Definition: molecule_impl.hpp:50
Forcefield forcefield
Definition: molecule_impl.hpp:154
int64_t tag
Definition: molecule_impl.hpp:46
Definition: molecule_impl.hpp:42
std::array< Atom, 3 > AngleAtoms
Container for storing Atom reference assigned to an Angle.
Definition: angle.hpp:20
Molecule molecule
Definition: molecule_impl.hpp:75
std::vector< Bond > MoleculeBonds
Container for storing IXBond instances.
Definition: molecule.hpp:25
std::vector< FFDihedral > DihedralTypes
Type for storing dihedral parameters.
Definition: dihedral.hpp:25
int64_t FindAngle(const Atom &a, const Atom &b, const Atom &c) const
void serialise(Archive &archive, const uint32_t version)
Definition: molecule_impl.hpp:145
Stereo stereochemistry
Definition: molecule_impl.hpp:55
void Reset()
Definition: molecule_impl.hpp:186
Definition: molecule.hpp:15
Read only class for storing elemental information.
Definition: periodictable.hpp:28
Definition: forcefield.hpp:333
FFBond forcefield_type
Definition: molecule_impl.hpp:80
MoleculeBonds bonds
Definition: molecule_impl.hpp:150
BondOrder order
Definition: molecule_impl.hpp:78
int32_t molecular_charge
Definition: molecule_impl.hpp:148
int64_t tag
Definition: molecule_impl.hpp:27
Definition: molecule_impl.hpp:24
int32_t formal_charge
Definition: molecule_impl.hpp:45
int64_t next_unique_id
Definition: molecule_impl.hpp:147
eastl::vector_set< Atom > ResidueAtoms
Definition: residue.hpp:16
DihedralTypes forcefield_types
Definition: molecule_impl.hpp:98
Eigen::Vector3d position
Definition: molecule_impl.hpp:51
int64_t unique_id
Definition: molecule_impl.hpp:77
FFAtom forcefield_type
Definition: molecule_impl.hpp:56
std::bitset< static_cast< uint8_t >CalculatedData::Number)> calculated_data
Definition: molecule_impl.hpp:158
std::string name
Definition: molecule_impl.hpp:146
AngleAtoms atoms
Definition: molecule_impl.hpp:25
bool Test(CalculatedData dat) const
Definition: molecule_impl.hpp:177
ResidueAtoms atoms
Definition: molecule_impl.hpp:115
int64_t unique_id
Definition: molecule_impl.hpp:28
FFAngle forcefield_type
Definition: molecule_impl.hpp:29
Definition: forcefield.hpp:151
Molecule molecule
Definition: molecule_impl.hpp:116
Atom::AtomBonds bonds
Definition: molecule_impl.hpp:57
std::array< Atom, 2 > BondAtoms
Container for storing Atom references assigned to an Bond.
Definition: bond.hpp:19
Definition: molecule_impl.hpp:93
Stereo
Enum for the different possible bond stereochemistry states.
Definition: bond.hpp:23
std::array< Atom, 4 > DihedralAtoms
Container for storing IXAtom references assigned to an IXDihedral.
Definition: dihedral.hpp:23
Stereo
Enum for the different types of atom stereochemistry.
Definition: atom.hpp:29