Molassembler  1.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"
17 
18 namespace Scine {
19 namespace Molassembler {
20 
22  static Utils::AtomCollection applyCanonicalizationMap(
23  const std::vector<AtomIndex>& canonicalizationIndexMap,
24  const Utils::AtomCollection& atomCollection
25  );
26 
27  Graph adjacencies_;
28  StereopermutatorList stereopermutators_;
29  boost::optional<AtomEnvironmentComponents> canonicalComponentsOption_;
30 
31 /* "Private" helpers */
32  void tryAddAtomStereopermutator_(
33  AtomIndex candidateIndex,
35  ) const;
36 
37  void tryAddBondStereopermutator_(
38  const BondIndex& bond,
39  StereopermutatorList& stereopermutators
40  ) const;
41 
44 
46  void ensureModelInvariants_() const;
47 
49  bool isValidIndex_(AtomIndex index) const;
50 
53 
55  void propagateGraphChange_();
56 
57 
61  Impl() noexcept;
62 
64  Impl(Utils::ElementType element) noexcept;
65 
67  Impl(
68  Utils::ElementType a,
69  Utils::ElementType b,
70  BondType bondType
71  ) noexcept;
72 
74  explicit Impl(Graph graph);
75 
77  Impl(
78  Graph graph,
79  const AngstromPositions& positions,
80  const boost::optional<
81  std::vector<BondIndex>
82  >& bondStereopermutatorCandidatesOptional = boost::none
83  );
84 
86  Impl(
87  Graph graph,
88  StereopermutatorList stereopermutators,
89  boost::optional<AtomEnvironmentComponents> canonicalComponentsOption
90  );
92 
97  Utils::ElementType elementType,
98  AtomIndex adjacentTo,
99  BondType bondType
100  );
101 
104  AtomIndex a,
105  AtomIndex b,
106  BondType bondType
107  );
108 
110  void applyPermutation(const std::vector<AtomIndex>& permutation);
111 
126  AtomIndex a,
127  const boost::optional<unsigned>& assignment
128  );
129 
144  const BondIndex& edge,
145  const boost::optional<unsigned>& assignment
146  );
147 
164 
177 
202  std::vector<AtomIndex> canonicalize(
203  AtomEnvironmentComponents componentBitmask
204  );
205 
214  void removeAtom(AtomIndex a);
215 
229  void removeBond(AtomIndex a, AtomIndex b);
230 
232  bool setBondType(
233  AtomIndex a,
234  AtomIndex b,
235  BondType bondType
236  );
237 
239  void setElementType(
240  AtomIndex a,
241  Utils::ElementType elementType
242  );
243 
259  void setShapeAtAtom(
260  AtomIndex a,
262  );
264 
268  boost::optional<AtomEnvironmentComponents> canonicalComponents() const;
269 
275  boost::optional<Shapes::Shape> inferShape(
276  AtomIndex index,
277  const RankingInformation& ranking
278  ) const;
279 
281  std::string dumpGraphviz() const;
282 
284  const Graph& graph() const;
285 
287  std::size_t hash() const;
288 
291 
293  const AngstromPositions& angstromWrapper,
294  const boost::optional<
295  std::vector<BondIndex>
296  >& explicitBondStereopermutatorCandidatesOption = boost::none
297  ) const;
298 
300  bool canonicalCompare(
301  const Impl& other,
302  AtomEnvironmentComponents componentBitmask
303  ) const;
304 
306  boost::optional<std::vector<AtomIndex>> modularIsomorphism(
307  const Impl& other,
308  AtomEnvironmentComponents componentBitmask
309  ) const;
310 
312  std::string str() const;
313 
315  AtomIndex a,
316  const std::vector<AtomIndex>& excludeAdjacent = {},
317  const boost::optional<AngstromPositions>& positionsOption = boost::none
318  ) const;
320 
324  bool operator == (const Impl& other) const;
326  bool operator != (const Impl& other) const;
328 };
329 
330 } // namespace Molassembler
331 } // namespace Scine
332 
333 #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:21
Represents the connectivity of atoms of a molecule.
Definition: Graph.h:57
AtomEnvironmentComponents
For bitmasks grouping components of immediate atom environments.
Definition: Types.h:103
StereopermutatorList inferStereopermutatorsFromPositions(const AngstromPositions &angstromWrapper, const boost::optional< std::vector< BondIndex > > &explicitBondStereopermutatorCandidatesOption=boost::none) const
Yield which components were used in canonicalization.
bool isGraphBasedBondStereopermutatorCandidate_(BondType bondType) const
Returns whether an edge is double, triple or higher bond order.
RankingInformation rankPriority(AtomIndex a, const std::vector< AtomIndex > &excludeAdjacent={}, const boost::optional< AngstromPositions > &positionsOption=boost::none) const
Yield which components were used in canonicalization.
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.
Molecule class interface.
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
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.
bool setBondType(AtomIndex a, AtomIndex b, BondType bondType)
Changes an existing bond&#39;s type.
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.
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.
void assignStereopermutator(AtomIndex a, const boost::optional< unsigned > &assignment)