Molassembler  3.0.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  std::vector<std::vector<SiteIndex>> siteGroups
98  )
99  >;
100 
102  using PropagatedState = std::tuple<RankingInformation, ShapeMap>;
103 
108  using MinimalChiralConstraint = std::array<boost::optional<SiteIndex>, 4>;
109 
112  AtomStereopermutator(AtomStereopermutator&& other) noexcept;
113  AtomStereopermutator& operator = (AtomStereopermutator&& other) noexcept;
115  AtomStereopermutator& operator = (const AtomStereopermutator& other);
117 
134  [[deprecated("Prefer constructor without graph argument")]]
136  const Graph& graph,
137  Shapes::Shape shape,
138  AtomIndex centerAtom,
139  RankingInformation ranking
140  );
141 
162  AtomIndex centerAtom,
163  Shapes::Shape shape,
164  RankingInformation ranking,
165  const FeasiblesGenerator& feasibility = {},
166  const ThermalizationPredicate& thermalization = {},
167  const std::vector<std::vector<SiteIndex>>& siteGroups = {}
168  );
170 
173 
179  static Shapes::Shape up(Shapes::Shape shape);
180 
188  static Shapes::Shape down(Shapes::Shape shape, Shapes::Vertex removedVertex);
190 
193 
207  static bool thermalized(
208  AtomIndex centerAtom,
210  const RankingInformation& ranking,
211  const Graph& graph
212  );
213 
215  static auto thermalizationFunctor(const Graph& g) {
216  return [&g](AtomIndex centerAtom, Shapes::Shape shape, const RankingInformation& ranking) {
217  return AtomStereopermutator::thermalized(centerAtom, shape, ranking, g);
218  };
219  }
221 
224 
234  void assign(boost::optional<unsigned> assignment,
235  const std::vector<std::vector<SiteIndex>>& siteGroups = {});
236 
253  void assignRandom(Random::Engine& engine);
254 
261  void applyPermutation(const std::vector<AtomIndex>& permutation);
262 
279  boost::optional<ShapeMap> fit(
280  const SiteCentroids& centroids,
281  const FeasiblesGenerator& feasibility = {},
282  const ThermalizationPredicate& thermalization = {}
283  );
284 
300  boost::optional<ShapeMap> fit(
301  const AngstromPositions& wrapper,
302  const FeasiblesGenerator& feasibility = {},
303  const ThermalizationPredicate& thermalization = {}
304  );
305 
306  [[deprecated("Prefer graph-less alternative parameters")]]
307  boost::optional<ShapeMap> fit(
308  const Graph& graph,
309  const AngstromPositions& angstromWrapper
310  );
311 
321  MASM_NO_EXPORT boost::optional<PropagatedState> propagate(
322  RankingInformation newRanking,
323  boost::optional<Shapes::Shape> shapeOption,
324  const FeasiblesGenerator& feasibility = {},
325  const ThermalizationPredicate& thermalization = {}
326  );
327 
335  void propagateVertexRemoval(AtomIndex removedIndex);
336 
345  void setShape(
347  const FeasiblesGenerator& feasibility = {},
348  const ThermalizationPredicate& thermalization = {},
349  const std::vector<std::vector<SiteIndex>>& siteGroups = {}
350  );
351 
352  [[deprecated("Prefer graph-less alternative parameters")]]
353  void setShape(
354  Shapes::Shape shape,
355  const Graph& graph,
356  const std::vector<std::vector<SiteIndex>>& siteGroups = {}
357  );
358 
360  void thermalize(bool thermalization = true);
362 
365 
379  double angle(SiteIndex i, SiteIndex j) const;
380 
388  boost::optional<unsigned> assigned() const;
389 
394  AtomIndex placement() const;
395 
404  boost::optional<unsigned> indexOfPermutation() const;
405 
422  std::vector<MinimalChiralConstraint> minimalChiralConstraints(bool enforce = false) const;
423 
428  std::string info() const;
429 
434  std::string rankInfo() const;
435 
444  std::vector<std::vector<SiteIndex>> siteGroups() const;
445 
447  SiteCentroids sitePositions(
448  const AngstromPositions& wrapper,
449  const std::vector<std::pair<AtomIndex, AtomIndex>>& substitutions = {}
450  ) const;
451 
453  bool thermalized() const;
454 
460  MASM_NO_EXPORT const Stereopermutators::Abstract& getAbstract() const;
461 
467  MASM_NO_EXPORT const std::vector<unsigned>& getFeasible() const;
468 
473  const RankingInformation& getRanking() const;
474 
479  Shapes::Shape getShape() const;
480 
486  const ShapeMap& getShapePositionMap() const;
487 
509  unsigned numAssignments() const;
510 
532  unsigned numStereopermutations() const;
534 
535 
538 
546  bool operator == (const AtomStereopermutator& other) const;
548  bool operator != (const AtomStereopermutator& other) const;
549 
558  bool operator < (const AtomStereopermutator& other) const;
560 
561 private:
562  class Impl;
563  std::unique_ptr<Impl> pImpl_;
564 };
565 
566 } // namespace Molassembler
567 } // namespace Scine
568 
569 #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:108
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:102
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, std::vector< std::vector< SiteIndex >> siteGroups) > FeasiblesGenerator
Generator function to list spatially feasible permutation indices.
Definition: AtomStereopermutator.h:99
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:215
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.