Molassembler  1.2.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 
20 
21 #include "boost/optional.hpp"
22 
23 namespace Scine {
24 namespace Molassembler {
25 namespace Stereopermutations {
26 
34 class MASM_EXPORT Composite {
35 public:
39  struct AngleGroup {
41  double angle;
43  std::vector<Shapes::Vertex> vertices;
48  bool isotropic;
49  };
50 
56  struct OrientationState : public Temple::Crtp::LexicographicComparable<OrientationState> {
70  std::size_t identifier;
71 
74  Shapes::Shape passShape,
75  Shapes::Vertex passFusedVertex,
76  Stereopermutation::Occupation passOccupation,
77  std::size_t passIdentifier
78  );
79 
84  Stereopermutation::Occupation rotateOccupation(const std::vector<Shapes::Vertex>& rotation) const;
85 
90  Shapes::Vertex lowestEqualVertexInShape() const;
91 
99  std::vector<Shapes::Vertex> findReductionMapping(Shapes::Vertex reducedFusedVertex) const;
100 
101  /* c++17 nodiscard */
116  std::vector<Shapes::Vertex> transformToCanonical();
117 
124  void revert(const std::vector<Shapes::Vertex>& reversionMapping);
125 
133  AngleGroup smallestAngleGroup() const;
134 
136  inline auto tie() const {
137  // Comparisons should be performed in canonical space
138  const Shapes::Vertex reducedVertex = lowestEqualVertexInShape();
139  return std::make_tuple(
140  shape,
141  reducedVertex,
142  rotateOccupation(findReductionMapping(reducedVertex))
143  );
144  }
145  };
146 
148  enum class Alignment {
150  Eclipsed,
152  Staggered,
154  EclipsedAndStaggered,
156  BetweenEclipsedAndStaggered
157  };
158 
160  struct Permutation {
161  using DihedralTuple = std::tuple<Shapes::Vertex, Shapes::Vertex, double>;
162  using VertexPair = std::pair<Shapes::Vertex, Shapes::Vertex>;
163 
164  bool close(const std::vector<DihedralTuple>& comparisonDihedrals) const;
165 
167  VertexPair alignedVertices;
171  std::vector<DihedralTuple> dihedrals;
173  boost::optional<VertexPair> rankingEquivalentTo;
174  };
175 
176  using PermutationsList = std::vector<Permutation>;
177 
179  static bool isDuplicate(
180  Permutation permutation,
181  const PermutationsList& permutations,
182  double degrees
183  );
184 
185  static PermutationsList deduplicate(PermutationsList permutations, double degrees);
186 
188 
189  double dihedral(
190  Shapes::Vertex firstVertex,
191  Shapes::Vertex secondVertex
192  ) const;
193 
194  Permutation align(
195  Shapes::Vertex firstVertex,
196  Shapes::Vertex secondVertex,
197  Alignment alignment
198  );
199 
200  PermutationsList generateEclipsedOrStaggered(
201  Alignment alignment,
202  double deduplicationDegrees
203  );
204 
206  Alignment alignment,
207  double deduplicationDegrees=15
208  );
209 
213  std::pair<Shapes::Permutation, Shapes::Permutation> reversionMappings;
214  std::pair<AngleGroup, AngleGroup> angleGroups;
215  std::pair<Eigen::MatrixXd, Eigen::MatrixXd> coordinates;
217  };
219 
222 
229  Composite(
232  Alignment alignment = Alignment::Eclipsed
233  );
235 //
240  Temple::Math::toRadians(1.0)
241  };
242 
251  static std::vector<Shapes::Vertex> generateRotation(
253  Shapes::Vertex fixedVertex,
254  const std::vector<Shapes::Vertex>& changedVertices
255  );
256 
257  static std::vector<Shapes::Vertex> rotation(
259  Shapes::Vertex fixedVertex,
260  const std::vector<Shapes::Vertex>& perpendicularPlaneVertices
261  );
263 
266  void applyIdentifierPermutation(const std::vector<std::size_t>& permutation);
267 
268  template<typename F>
269  void updateIdentifiers(F f) {
270  // NOTE: OrientationState identifiers are not part of their comparison
271  // operators, so no reordering can take place
272  for(auto& orientationState : orientations_) {
273  orientationState.identifier = f(orientationState.identifier);
274  }
275  }
277 
281  const PermutationsList& allPermutations() const;
282 
287  bool isIsotropic() const;
288 
290  std::pair<unsigned, unsigned> orders() const;
291 
298  unsigned order() const;
299 
301  unsigned rotationalAxisSymmetryOrder() const;
302 
307  const Temple::OrderedPair<OrientationState>& orientations() const;
308 
310  unsigned rankingEquivalentBase(unsigned permutation) const;
311 
313  std::vector<unsigned> nonEquivalentPermutationIndices() const;
314 
320  unsigned countNonEquivalentPermutations() const;
321 
326  Alignment alignment() const;
328 
332  PermutationsList::const_iterator begin() const;
333  PermutationsList::const_iterator end() const;
335 
339  bool operator < (const Composite& other) const;
341  bool operator == (const Composite& other) const;
343  bool operator != (const Composite& other) const;
345 
346 private:
351 
354 
358 
373  static double perpendicularSubstituentAngle(
374  double angleFromBoundShapeVertex,
375  double angleBetweenSubstituents
376  );
377 };
378 
379 } // namespace Stereopermutations
380 } // namespace Molassembler
381 } // namespace Scine
382 
383 #endif
Alignment
Relative orientation of substituent groups along the dihedral.
Definition: Composites.h:148
Temple::OrderedPair< OrientationState > orientations_
Stores the relative orientation with which the permutations were generated.
Definition: Composites.h:350
double angle
The angle from this vertex group to the fused position in radians.
Definition: Composites.h:41
Generates all operators using a method returning a tuple.
Definition: OperatorSuppliers.h:78
Alignment alignment_
Stores with which Alignment the stereopermutations were generated.
Definition: Composites.h:356
Base class to describe substituent arrangements in shapes.
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:39
auto tie() const
Full tuple-like lexicographical comparison of members in order of declaration.
Definition: Composites.h:136
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:160
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:56
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:353
Stereopermutation::Occupation occupation
Ranking occupation of shape vertices of this shape.
Definition: Composites.h:62
std::vector< Permutation > PermutationsList
Relative orientation of substituent groups along the dihedral.
Definition: Composites.h:176
Alignment alignment
Alignment used to generate this permutation.
Definition: Composites.h:169
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:48
Defines symmetry names and total count.
Coordinates coordinates(Shape shape)
Fetch a shape&#39;s idealized coordiantes.
Shape
Enumeration of all contained symmetry names.
Definition: Shapes.h:28
Shapes::Shape shape
The shape of either positional shape.
Definition: Composites.h:58
boost::optional< VertexPair > rankingEquivalentTo
Shape vertices this permutation is ranking equivalent to, if applicable.
Definition: Composites.h:173
std::size_t identifier
An identifier to the shape source.
Definition: Composites.h:70
Shapes::Vertex fusedVertex
The shape vertex of the local shape that the other is fused at.
Definition: Composites.h:60
VertexPair alignedVertices
Shape vertices aligned for this set of dihedrals.
Definition: Composites.h:167
An ordered homogeneous pair-like class.
std::vector< DihedralTuple > dihedrals
Set of dihedrals between all relevant vertices along the bond.
Definition: Composites.h:171
Helpers for comparing floating point values.
std::vector< Shapes::Vertex > vertices
The shape vertices making up this group.
Definition: Composites.h:43
Represents the composite of two shapes joined by a bond at arbitrary shape vertices.
Definition: Composites.h:34