Molassembler  1.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Composites.h
Go to the documentation of this file.
1 
12 #ifndef INCLUDE_MOLASSEMBLER_STEREOPERMUTATION_COMPOSITES_H
13 #define INCLUDE_MOLASSEMBLER_STEREOPERMUTATION_COMPOSITES_H
14 
19 
20 #include "boost/optional.hpp"
21 
22 namespace Scine {
23 namespace Molassembler {
24 namespace Stereopermutations {
25 
33 class MASM_EXPORT Composite {
34 public:
38  struct AngleGroup {
40  double angle;
42  std::vector<Shapes::Vertex> vertices;
47  bool isotropic;
48  };
49 
55  struct OrientationState : public Temple::Crtp::LexicographicComparable<OrientationState> {
61  std::vector<char> characters;
69  std::size_t identifier;
70 
73  Shapes::Shape passShape,
74  Shapes::Vertex passFusedVertex,
75  std::vector<char> passCharacters,
76  std::size_t passIdentifier
77  );
78 
83  std::vector<char> applyCharacterRotation(const std::vector<Shapes::Vertex>& rotation) const;
84 
89  Shapes::Vertex lowestEqualVertexInShape() const;
90 
98  std::vector<Shapes::Vertex> findReductionMapping(Shapes::Vertex reducedFusedVertex) const;
99 
100  /* c++17 nodiscard */
115  std::vector<Shapes::Vertex> transformToCanonical();
116 
123  void revert(const std::vector<Shapes::Vertex>& reversionMapping);
124 
132  AngleGroup smallestAngleGroup() const;
133 
135  inline auto tie() const {
136  // Comparisons should be performed in canonical space
137  const Shapes::Vertex reducedVertex = lowestEqualVertexInShape();
138  return std::make_tuple(
139  shape,
140  reducedVertex,
141  applyCharacterRotation(findReductionMapping(reducedVertex))
142  );
143  }
144  };
145 
147  enum class Alignment {
149  Eclipsed,
151  Staggered,
153  EclipsedAndStaggered,
155  BetweenEclipsedAndStaggered
156  };
157 
159  struct Permutation {
160  using DihedralTuple = std::tuple<Shapes::Vertex, Shapes::Vertex, double>;
161  using VertexPair = std::pair<Shapes::Vertex, Shapes::Vertex>;
162 
163  bool close(const std::vector<DihedralTuple>& comparisonDihedrals) const;
164 
166  VertexPair alignedVertices;
170  std::vector<DihedralTuple> dihedrals;
172  boost::optional<VertexPair> rankingEquivalentTo;
173  };
174 
175  using PermutationsList = std::vector<Permutation>;
176 
178  static bool isDuplicate(
179  Permutation permutation,
180  const PermutationsList& permutations,
181  double degrees
182  );
183 
184  static PermutationsList deduplicate(PermutationsList permutations, double degrees);
185 
187 
188  double dihedral(
189  const Shapes::Vertex firstVertex,
190  const Shapes::Vertex secondVertex
191  ) const;
192 
193  Permutation align(
194  const Shapes::Vertex firstVertex,
195  const Shapes::Vertex secondVertex,
196  Alignment alignment
197  );
198 
199  PermutationsList generateEclipsedOrStaggered(
200  Alignment alignment,
201  double deduplicationDegrees
202  );
203 
205  Alignment alignment,
206  double deduplicationDegrees=15
207  );
208 
212  std::pair<Shapes::Permutation, Shapes::Permutation> reversionMappings;
213  std::pair<AngleGroup, AngleGroup> angleGroups;
214  std::pair<Eigen::MatrixXd, Eigen::MatrixXd> coordinates;
216  };
218 
221 
228  Composite(
231  Alignment alignment = Alignment::Eclipsed
232  );
234 //
239  Temple::Math::toRadians(1.0)
240  };
241 
250  static std::vector<Shapes::Vertex> generateRotation(
252  Shapes::Vertex fixedVertex,
253  const std::vector<Shapes::Vertex>& changedVertices
254  );
255 
256  static std::vector<Shapes::Vertex> rotation(
258  Shapes::Vertex fixedVertex,
259  const std::vector<Shapes::Vertex>& perpendicularPlaneVertices
260  );
262 
265  void applyIdentifierPermutation(const std::vector<std::size_t>& permutation);
267 
271  const PermutationsList& allPermutations() const;
272 
277  bool isIsotropic() const;
278 
280  std::pair<unsigned, unsigned> orders() const;
281 
288  unsigned order() const;
289 
291  unsigned rotationalAxisSymmetryOrder() const;
292 
297  const Temple::OrderedPair<OrientationState>& orientations() const;
298 
300  unsigned rankingEquivalentBase(const unsigned permutation) const;
301 
303  std::vector<unsigned> nonEquivalentPermutationIndices() const;
304 
310  unsigned countNonEquivalentPermutations() const;
311 
316  Alignment alignment() const;
318 
322  PermutationsList::const_iterator begin() const;
323  PermutationsList::const_iterator end() const;
325 
329  bool operator < (const Composite& other) const;
331  bool operator == (const Composite& other) const;
333  bool operator != (const Composite& other) const;
335 
336 private:
341 
344 
348 
363  static double perpendicularSubstituentAngle(
364  double angleFromBoundShapeVertex,
365  double angleBetweenSubstituents
366  );
367 };
368 
369 } // namespace Stereopermutations
370 } // namespace Molassembler
371 } // namespace Scine
372 
373 #endif
Alignment
Relative orientation of substituent groups along the dihedral.
Definition: Composites.h:147
Temple::OrderedPair< OrientationState > orientations_
Stores the relative orientation with which the permutations were generated.
Definition: Composites.h:340
double angle
The angle this group is placed at from the fused position.
Definition: Composites.h:40
Generates all operators using a method returning a tuple.
Definition: OperatorSuppliers.h:84
Alignment alignment_
Stores with which Alignment the stereopermutations were generated.
Definition: Composites.h:346
ShapeResult shape(const PositionCollection &normalizedPositions, Shape shape)
Forwarding function to calculate the continuous shape measure.
A group of shape vertices at an angle from the fused position.
Definition: Composites.h:38
auto tie() const
Full tuple-like lexicographical comparison of members in order of declaration.
Definition: Composites.h:135
std::vector< WideHashType > generate(const PrivateGraph &inner, boost::optional< const StereopermutatorList & > stereopermutatorsOption, AtomEnvironmentComponents bitmask)
Generates the hashes for every atom in a molecule&#39;s components.
Class representing a single rotational permutation.
Definition: Composites.h:159
PURITY_STRONG unsigned order(PointGroup group)
Returns the number of symmetry elements in a point group.
Encompasses the orientation of a shape along a fused bond.
Definition: Composites.h:55
Centralizes basic shape data in runtime types.
A class that imitates std::pair&lt;T, U&gt;, but whose template arguments are homogeneous and the stored va...
Definition: OrderedPair.h:36
constexpr Get< 1 > second
Calls std::get&lt;1&gt; on any argument it is invoked with.
Definition: Functor.h:125
PermutationsList stereopermutations_
List of dihedral sets that comprise all spatial arrangements.
Definition: Composites.h:343
std::vector< Permutation > PermutationsList
Relative orientation of substituent groups along the dihedral.
Definition: Composites.h:175
Alignment alignment
Alignment used to generate this permutation.
Definition: Composites.h:168
constexpr Get< 0 > first
Calls std::get&lt;0&gt; on any argument it is invoked with.
Definition: Functor.h:123
bool isotropic
Whether the ranking characters indicate that this group of shape vertices is isotropic.
Definition: Composites.h:47
Defines symmetry names and total count.
std::vector< char > characters
Abstract ranking-characters of the sites at their shape vertices.
Definition: Composites.h:61
Shape
Enumeration of all contained symmetry names.
Definition: Shapes.h:28
Shapes::Shape shape
The shape of either positional shape.
Definition: Composites.h:57
boost::optional< VertexPair > rankingEquivalentTo
Shape vertices this permutation is ranking equivalent to, if applicable.
Definition: Composites.h:172
std::size_t identifier
An identifier to the shape source.
Definition: Composites.h:69
Coordinates coordinates(const Shape shape)
Fetch a shape&#39;s idealized coordiantes.
Shapes::Vertex fusedVertex
The shape vertex of the local shape that the other is fused at.
Definition: Composites.h:59
VertexPair alignedVertices
Shape vertices aligned for this set of dihedrals.
Definition: Composites.h:166
An ordered homogeneous pair-like class.
std::vector< DihedralTuple > dihedrals
Set of dihedrals between all relevant vertices along the bond.
Definition: Composites.h:170
Helpers for comparing floating point values.
std::vector< Shapes::Vertex > vertices
The shape vertices making up this group.
Definition: Composites.h:42
Represents the composite of two shapes joined by a bond at arbitrary shape vertices.
Definition: Composites.h:33