Molassembler  1.2.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
AtomStereopermutator.h
Go to the documentation of this file.
1 
17 #ifndef INCLUDE_MOLASSEMBLER_ATOM_STEREOPERMUTATOR_H
18 #define INCLUDE_MOLASSEMBLER_ATOM_STEREOPERMUTATOR_H
19 
23 
24 #include <array>
25 #include <memory>
26 
27 namespace Scine {
28 namespace Molassembler {
29 
30 /* Forward declarations */
31 struct RankingInformation;
32 class AngstromPositions;
33 class Graph;
34 
35 namespace Stereopermutators {
36 struct Abstract;
37 struct Feasible;
38 } // namespace Stereopermutators
39 
40 namespace Random {
41 class Engine;
42 } // namespace Random
43 
44 namespace DistanceGeometry {
45 
46 class SpatialModel;
47 struct ChiralConstraint;
48 
49 } // namespace DistanceGeometry
50 
79 class MASM_EXPORT AtomStereopermutator {
80 public:
83 
85  using SiteCentroids = Eigen::Matrix<double, 3, Eigen::Dynamic>;
86 
88  using ThermalizationPredicate = std::function<bool(AtomIndex, Shapes::Shape, const RankingInformation&)>;
89 
91  using FeasiblesGenerator = std::function<
92  std::vector<unsigned>(
93  const Stereopermutators::Abstract& abstract,
95  AtomIndex placement,
96  const RankingInformation& ranking
97  )
98  >;
99 
101  using PropagatedState = std::tuple<RankingInformation, ShapeMap>;
102 
107  using MinimalChiralConstraint = std::array<boost::optional<SiteIndex>, 4>;
108 
111  AtomStereopermutator(AtomStereopermutator&& other) noexcept;
112  AtomStereopermutator& operator = (AtomStereopermutator&& other) noexcept;
114  AtomStereopermutator& operator = (const AtomStereopermutator& other);
116 
133  [[deprecated("Prefer constructor without graph argument")]]
135  const Graph& graph,
136  Shapes::Shape shape,
137  AtomIndex centerAtom,
138  RankingInformation ranking
139  );
140 
160  AtomIndex centerAtom,
161  Shapes::Shape shape,
162  RankingInformation ranking,
163  const FeasiblesGenerator& feasibility = {},
164  const ThermalizationPredicate& thermalization = {}
165  );
167 
170 
176  static Shapes::Shape up(Shapes::Shape shape);
177 
185  static Shapes::Shape down(Shapes::Shape shape, Shapes::Vertex removedVertex);
187 
190 
204  static bool thermalized(
205  AtomIndex centerAtom,
207  const RankingInformation& ranking,
208  const Graph& graph
209  );
210 
212  static auto thermalizationFunctor(const Graph& g) {
213  return [&g](AtomIndex centerAtom, Shapes::Shape shape, const RankingInformation& ranking) {
214  return AtomStereopermutator::thermalized(centerAtom, shape, ranking, g);
215  };
216  }
218 
221 
230  void assign(boost::optional<unsigned> assignment);
231 
248  void assignRandom(Random::Engine& engine);
249 
256  void applyPermutation(const std::vector<AtomIndex>& permutation);
257 
274  boost::optional<ShapeMap> fit(
275  const SiteCentroids& centroids,
276  const FeasiblesGenerator& feasibility = {},
277  const ThermalizationPredicate& thermalization = {}
278  );
279 
295  boost::optional<ShapeMap> fit(
296  const AngstromPositions& wrapper,
297  const FeasiblesGenerator& feasibility = {},
298  const ThermalizationPredicate& thermalization = {}
299  );
300 
301  [[deprecated("Prefer graph-less alternative parameters")]]
302  boost::optional<ShapeMap> fit(
303  const Graph& graph,
304  const AngstromPositions& angstromWrapper
305  );
306 
316  MASM_NO_EXPORT boost::optional<PropagatedState> propagate(
317  RankingInformation newRanking,
318  boost::optional<Shapes::Shape> shapeOption,
319  const FeasiblesGenerator& feasibility = {},
320  const ThermalizationPredicate& thermalization = {}
321  );
322 
330  void propagateVertexRemoval(AtomIndex removedIndex);
331 
340  void setShape(
342  const FeasiblesGenerator& feasibility = {},
343  const ThermalizationPredicate& thermalization = {}
344  );
345 
346  [[deprecated("Prefer graph-less alternative parameters")]]
347  void setShape(
348  Shapes::Shape shape,
349  const Graph& graph
350  );
351 
353  void thermalize(bool thermalization = true);
355 
358 
372  double angle(SiteIndex i, SiteIndex j) const;
373 
381  boost::optional<unsigned> assigned() const;
382 
387  AtomIndex placement() const;
388 
397  boost::optional<unsigned> indexOfPermutation() const;
398 
415  std::vector<MinimalChiralConstraint> minimalChiralConstraints(bool enforce = false) const;
416 
421  std::string info() const;
422 
427  std::string rankInfo() const;
428 
437  std::vector<std::vector<SiteIndex>> siteGroups() const;
438 
440  SiteCentroids sitePositions(
441  const AngstromPositions& wrapper,
442  const std::vector<std::pair<AtomIndex, AtomIndex>>& substitutions = {}
443  ) const;
444 
446  bool thermalized() const;
447 
453  MASM_NO_EXPORT const Stereopermutators::Abstract& getAbstract() const;
454 
460  MASM_NO_EXPORT const std::vector<unsigned>& getFeasible() const;
461 
466  const RankingInformation& getRanking() const;
467 
472  Shapes::Shape getShape() const;
473 
479  const ShapeMap& getShapePositionMap() const;
480 
502  unsigned numAssignments() const;
503 
525  unsigned numStereopermutations() const;
527 
528 
531 
539  bool operator == (const AtomStereopermutator& other) const;
541  bool operator != (const AtomStereopermutator& other) const;
542 
551  bool operator < (const AtomStereopermutator& other) const;
553 
554 private:
555  class Impl;
556  std::unique_ptr<Impl> pImpl_;
557 };
558 
559 } // namespace Molassembler
560 } // namespace Scine
561 
562 #endif
std::array< boost::optional< SiteIndex >, 4 > MinimalChiralConstraint
Site index sequence defining a chiral constraint. If a site index is None, then it denotes the positi...
Definition: AtomStereopermutator.h:107
std::function< bool(AtomIndex, Shapes::Shape, const RankingInformation &)> ThermalizationPredicate
Predicate to decide whether an atom stereopermutator is thermalized.
Definition: AtomStereopermutator.h:88
Strongly typed index permutations.
Ranking data of substituents around a central vertex.
Definition: RankingInformation.h:23
bool thermalized() const
Returns whether the stereopermutations are thermalized.
Drives a PRNG.
Definition: Prng.h:24
ShapeResult shape(const PositionCollection &normalizedPositions, Shape shape)
Forwarding function to calculate the continuous shape measure.
std::tuple< RankingInformation, ShapeMap > PropagatedState
Old state dumped upon propagation.
Definition: AtomStereopermutator.h:101
Eigen::Matrix< double, 3, Eigen::Dynamic > SiteCentroids
Spatial positions of the centroids of sites.
Definition: AtomStereopermutator.h:85
Represents the connectivity of atoms of a molecule.
Definition: Graph.h:54
Class performing spatial modeling of molecules.
Definition: SpatialModel.h:40
Centralizes basic shape data in runtime types.
Handles the steric permutation of substituents of a non-terminal central atom.
Definition: AtomStereopermutator.h:79
std::function< std::vector< unsigned >(const Stereopermutators::Abstract &abstract, Shapes::Shape shape, AtomIndex placement, const RankingInformation &ranking) > FeasiblesGenerator
Generator function to list spatially feasible permutation indices.
Definition: AtomStereopermutator.h:98
std::size_t AtomIndex
Unsigned integer atom index type. Used to refer to particular atoms.
Definition: Types.h:51
Permutation applyPermutation(const Permutation &occupation, const Permutation &permutation)
Rotates a passed list of indices with a specified rotation vector.
static auto thermalizationFunctor(const Graph &g)
Binds a graph instance into a functor invoking thermalized.
Definition: AtomStereopermutator.h:212
Temple::StrongIndex< vertex_index_tag, unsigned > Vertex
Index of a shape vertex.
Definition: Data.h:33
Class to compute the set of abstract permutations from ranking and shape.
Definition: AbstractPermutations.h:24
Shape
Enumeration of all contained symmetry names.
Definition: Shapes.h:28
Definition: FeasiblePermutations.h:51
Data struct representing a chiral constraint.
Definition: DistanceGeometry.h:32
Data struct storing results of ranking and local graph algorithms.