Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
MoleculeImpl.h
Go to the documentation of this file.
1 
8 #ifndef INCLUDE_MOLASSEMBLER_MOLECULE_IMPL_H
9 #define INCLUDE_MOLASSEMBLER_MOLECULE_IMPL_H
10 
11 #include "Molassembler/Molecule.h"
12 
13 #include "Molassembler/Graph.h"
18 
19 namespace Scine {
20 namespace Molassembler {
21 
23  static Utils::AtomCollection applyCanonicalizationMap(
24  const std::vector<AtomIndex>& canonicalizationIndexMap,
25  const Utils::AtomCollection& atomCollection
26  );
27 
30 
31 /* "Private" helpers */
32  boost::optional<AtomStereopermutator> makePermutator(
33  AtomIndex candidateIndex,
35  const boost::optional<AngstromPositions>& maybePositions = boost::none,
36  const boost::optional<SubstitutionsGenerator::SubstitutionMap>& maybeSubstitutions = boost::none
37  ) const;
38 
39  boost::optional<BondStereopermutator> makePermutator(
40  const BondIndex& bond,
41  const StereopermutatorList& stereopermutators,
42  const boost::optional<AngstromPositions>& maybePositions = boost::none,
43  const boost::optional<SubstitutionsGenerator::SubstitutionMap>& maybeSubstitutions = boost::none,
45  ) const;
46 
49 
51  void ensureModelInvariants_() const;
52 
54  bool isValidIndex_(AtomIndex index) const;
55 
57  void propagateGraphChange_();
58 
59 
63  Impl() noexcept;
64 
66  Impl(Utils::ElementType element) noexcept;
67 
69  Impl(
70  Utils::ElementType a,
71  Utils::ElementType b,
72  BondType bondType
73  ) noexcept;
74 
76  explicit Impl(Graph graph);
77 
79  Impl(
80  Graph graph,
81  const AngstromPositions& positions,
82  const boost::optional<
83  std::vector<BondIndex>
84  >& bondStereopermutatorCandidatesOptional = boost::none,
85  const boost::optional<PeriodicBoundaryDuplicates>& periodics = boost::none
86  );
87 
89  Impl(
90  Graph graph,
91  StereopermutatorList stereopermutators,
92  boost::optional<AtomEnvironmentComponents> canonicalComponentsOption
93  );
95 
100  Utils::ElementType elementType,
101  AtomIndex adjacentTo,
102  BondType bondType
103  );
104 
107  AtomIndex a,
108  AtomIndex b,
109  BondType bondType
110  );
111 
114  const BondIndex& bond,
116  );
117 
119  void applyPermutation(const std::vector<AtomIndex>& permutation);
120 
135  AtomIndex a,
136  const boost::optional<unsigned>& assignment
137  );
138 
153  const BondIndex& edge,
154  const boost::optional<unsigned>& assignment
155  );
156 
173 
186 
211  std::vector<AtomIndex> canonicalize(
212  AtomEnvironmentComponents componentBitmask
213  );
214 
223  void removeAtom(AtomIndex a);
224 
238  void removeBond(AtomIndex a, AtomIndex b);
239 
244  bool removePermutator(const BondIndex& bond);
245 
247  bool setBondType(
248  AtomIndex a,
249  AtomIndex b,
250  BondType bondType
251  );
252 
254  void setElementType(
255  AtomIndex a,
256  Utils::ElementType elementType
257  );
258 
274  void setShapeAtAtom(
275  AtomIndex a,
277  );
278 
280  void thermalizeStereopermutator(AtomIndex a, bool thermalization);
282 
286  boost::optional<AtomEnvironmentComponents> canonicalComponents() const;
287 
293  boost::optional<Shapes::Shape> inferShape(
294  AtomIndex index,
295  const RankingInformation& ranking
296  ) const;
297 
299  std::string dumpGraphviz() const;
300 
302  const Graph& graph() const;
303 
305  std::size_t hash() const;
306 
309 
311  const AngstromPositions& angstromWrapper,
312  const boost::optional<
313  std::vector<BondIndex>
314  >& explicitBondStereopermutatorCandidatesOption = boost::none,
315  boost::optional<const std::unordered_set<AtomIndex>&> uninteresting = boost::none,
316  const boost::optional<SubstitutionsGenerator::SubstitutionMap>& substitutions = boost::none
317  ) const;
318 
320  bool canonicalCompare(
321  const Impl& other,
322  AtomEnvironmentComponents componentBitmask
323  ) const;
324 
326  boost::optional<std::vector<AtomIndex>> modularIsomorphism(
327  const Impl& other,
328  AtomEnvironmentComponents componentBitmask
329  ) const;
330 
332  std::string str() const;
333 
335  AtomIndex a,
336  const std::vector<AtomIndex>& excludeAdjacent = {},
337  const boost::optional<AngstromPositions>& positionsOption = boost::none
338  ) const;
340 
344  bool operator == (const Impl& other) const;
346  bool operator != (const Impl& other) const;
348 
351  Graph adjacencies_;
352  StereopermutatorList stereopermutators_;
353  boost::optional<AtomEnvironmentComponents> canonicalComponentsOption_;
355 };
356 
357 } // namespace Molassembler
358 } // namespace Scine
359 
360 #endif
bool canonicalCompare(const Impl &other, AtomEnvironmentComponents componentBitmask) const
Compares two canonical instances with one another.
StereopermutatorList detectStereopermutators_() const
Generates a list of stereopermutators based on graph properties alone.
std::string dumpGraphviz() const
Returns a graphivz string representation of the molecule.
void setElementType(AtomIndex a, Utils::ElementType elementType)
Changes an existing atom&#39;s element type.
Ranking data of substituents around a central vertex.
Definition: RankingInformation.h:23
Impl() noexcept
Default constructor.
Drives a PRNG.
Definition: Prng.h:24
double element(const PositionCollection &normalizedPositions, const Elements::Rotation &rotation)
Returns the CSM for a Rotation symmetry element along the rotation axis without optimizing the coordi...
A wrapper class around Utils&#39; PositionCollection to emphasize that the positions stored therein are i...
Definition: AngstromPositions.h:25
ShapeResult shape(const PositionCollection &normalizedPositions, Shape shape)
Forwarding function to calculate the continuous shape measure.
boost::optional< AtomEnvironmentComponents > canonicalComponents() const
Yield which components were used in canonicalization.
Definition: MoleculeImpl.h:22
Represents the connectivity of atoms of a molecule.
Definition: Graph.h:54
AtomEnvironmentComponents
For bitmasks grouping components of immediate atom environments.
Definition: Types.h:103
RankingInformation rankPriority(AtomIndex a, const std::vector< AtomIndex > &excludeAdjacent={}, const boost::optional< AngstromPositions > &positionsOption=boost::none) const
Yield which components were used in canonicalization.
Extras for dealing with periodic boundaries.
bool isValidIndex_(AtomIndex index) const
Returns whether the specified index is valid or not.
void applyPermutation(const std::vector< AtomIndex > &permutation)
Applies an index permutation to all member state.
const StereopermutatorList & stereopermutators() const
Provides read-only access to the list of stereopermutators.
At least two shape vertices eclipse one another along the axis.
Molecule class interface.
Handles specific relative arrangements of two atom stereopermutators joined by a bond.
Definition: BondStereopermutator.h:46
void thermalizeStereopermutator(AtomIndex a, bool thermalization)
Alters thermalization state of an atom stereopermutator.
std::string str() const
Returns a command-line interface information string.
BondIndex addBond(AtomIndex a, AtomIndex b, BondType bondType)
Adds a bond between existing atoms.
Manages all stereopermutators that are part of a Molecule.
Definition: StereopermutatorList.h:30
std::vector< AtomIndex > canonicalize(AtomEnvironmentComponents componentBitmask)
Canonicalizes the graph, invalidating all atom and bond indices.
const Graph & graph() const
Provides read-only access to the graph member.
std::size_t AtomIndex
Unsigned integer atom index type. Used to refer to particular atoms.
Definition: Types.h:51
StereopermutatorList inferStereopermutatorsFromPositions(const AngstromPositions &angstromWrapper, const boost::optional< std::vector< BondIndex > > &explicitBondStereopermutatorCandidatesOption=boost::none, boost::optional< const std::unordered_set< AtomIndex > & > uninteresting=boost::none, const boost::optional< SubstitutionsGenerator::SubstitutionMap > &substitutions=boost::none) const
Yield which components were used in canonicalization.
BondType
Discrete bond type numeration.
Definition: Types.h:26
Type used to refer to particular bonds. Orders first &lt; second.
Definition: Types.h:54
boost::optional< Shapes::Shape > inferShape(AtomIndex index, const RankingInformation &ranking) const
Interface class for the molecular graph.
void assignStereopermutatorRandomly(AtomIndex a, Random::Engine &engine)
void propagateGraphChange_()
Updates the molecule&#39;s StereopermutatorList after a graph modification.
AtomIndex addAtom(Utils::ElementType elementType, AtomIndex adjacentTo, BondType bondType)
Adds an atom by attaching it to an existing atom.
Shape
Enumeration of all contained symmetry names.
Definition: Shapes.h:28
boost::optional< std::vector< AtomIndex > > modularIsomorphism(const Impl &other, AtomEnvironmentComponents componentBitmask) const
Modular comparison of this Impl with another.
static bool isGraphBasedBondStereopermutatorCandidate_(BondType bondType)
Returns whether an edge is double, triple or higher bond order.
bool setBondType(AtomIndex a, AtomIndex b, BondType bondType)
Changes an existing bond&#39;s type.
const BondStereopermutator & addPermutator(const BondIndex &bond, BondStereopermutator::Alignment alignment)
Add a new BondStereopermutator to the molecule.
void removeBond(AtomIndex a, AtomIndex b)
std::size_t hash() const
Convolutional hash.
Boost Graph Library wrapper to help in concealing underlying type.
void setShapeAtAtom(AtomIndex a, Shapes::Shape shape)
Owning class storing all stereopermutators in a molecule.
Alignment
How dihedrals are aligned in the generation of stereopermutations.
Definition: BondStereopermutator.h:53
void ensureModelInvariants_() const
Ensures basic expectations about what constitutes a Molecule are met.
bool operator!=(const Impl &other) const
Negates.
bool operator==(const Impl &other) const
Equality operator, performs most strict equality comparison.
bool removePermutator(const BondIndex &bond)
Removes the BondStereopermutator on a specified edge, if present.
void assignStereopermutator(AtomIndex a, const boost::optional< unsigned > &assignment)