Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Molecule.h
Go to the documentation of this file.
1 
11 #ifndef INCLUDE_MOLASSEMBLER_MOLECULE_H
12 #define INCLUDE_MOLASSEMBLER_MOLECULE_H
13 
15 #include "boost/optional.hpp"
16 
18 #include "Molassembler/Options.h"
19 
20 namespace Scine {
21 // External forward declarations
22 namespace Utils {
23 using ElementTypeCollection = std::vector<ElementType>;
24 class AtomCollection;
25 } // namespace Utils
26 
27 namespace Molassembler {
28 
29 // Forward declarations
30 class Graph;
31 class StereopermutatorList;
32 struct RankingInformation;
33 class AtomStereopermutator;
34 struct PeriodicBoundaryDuplicates;
35 
77 class MASM_EXPORT Molecule final : public GraphInterface {
78 public:
79 
82 
91  static Utils::AtomCollection applyCanonicalizationMap(
92  const std::vector<AtomIndex>& canonicalizationIndexMap,
93  const Utils::AtomCollection& atomCollection
94  );
96 
99  /* Rule of five members */
100  Molecule(Molecule&& other) noexcept;
101  Molecule& operator = (Molecule&& rhs) noexcept;
102  Molecule(const Molecule& other);
103  Molecule& operator = (const Molecule& rhs);
104  ~Molecule() final;
105 
111  Molecule() noexcept;
112 
118  Molecule(Utils::ElementType element) noexcept;
119 
125  Molecule(
126  Utils::ElementType a,
127  Utils::ElementType b,
128  BondType bondType = BondType::Single
129  ) noexcept;
130 
142  explicit Molecule(Graph graph);
143 
164  Molecule(
165  Graph graph,
166  const AngstromPositions& positions,
167  const boost::optional<
168  std::vector<BondIndex>
169  >& bondStereopermutatorCandidatesOptional = boost::none
170  );
171 
172  MASM_NO_EXPORT Molecule(
173  Graph graph,
174  const AngstromPositions& positions,
175  const boost::optional<
176  std::vector<BondIndex>
177  >& bondStereopermutatorCandidatesOptional,
178  const PeriodicBoundaryDuplicates& boundaries
179  );
180 
191  MASM_NO_EXPORT Molecule(
192  Graph graph,
193  StereopermutatorList stereopermutators,
194  boost::optional<AtomEnvironmentComponents> canonicalComponentsOption = boost::none
195  );
197 
200 
221  AtomIndex addAtom(
222  Utils::ElementType elementType,
223  AtomIndex adjacentTo,
224  BondType bondType = BondType::Single
225  ) final;
226 
252  BondIndex addBond(
253  AtomIndex a,
254  AtomIndex b,
255  BondType bondType = BondType::Single
256  ) final;
257 
263  const BondStereopermutator& addPermutator(
264  const BondIndex& bond,
266  );
267 
274  void applyPermutation(const std::vector<AtomIndex>& permutation);
275 
304  void assignStereopermutator(
305  AtomIndex a,
306  const boost::optional<unsigned>& assignmentOption
307  );
308 
337  void assignStereopermutator(
338  const BondIndex& edge,
339  const boost::optional<unsigned>& assignmentOption
340  );
341 
371  void assignStereopermutatorRandomly(AtomIndex a, Random::Engine& engine = randomnessEngine());
372 
399  void assignStereopermutatorRandomly(const BondIndex& e, Random::Engine& engine = randomnessEngine());
400 
426  std::vector<AtomIndex> canonicalize(
427  AtomEnvironmentComponents componentBitmask = AtomEnvironmentComponents::All
428  );
429 
453  void removeAtom(AtomIndex a) final;
454 
482  void removeBond(AtomIndex a, AtomIndex b);
483 
485  void removeBond(const BondIndex& bond) final;
486 
491  bool removePermutator(const BondIndex& bond);
492 
519  bool setBondType(
520  AtomIndex a,
521  AtomIndex b,
522  BondType bondType
523  ) final;
524 
544  void setElementType(
545  AtomIndex a,
546  Utils::ElementType elementType
547  ) final;
548 
573  void setShapeAtAtom(
574  AtomIndex a,
576  );
577 
588  void thermalizeStereopermutator(AtomIndex a, bool thermalization = true);
590 
593  struct MASM_NO_EXPORT unsafe_tag_t {};
594  static constexpr unsafe_tag_t unsafe_tag {};
595  MASM_NO_EXPORT StereopermutatorList& stereopermutators(unsafe_tag_t /* tag */);
596  MASM_NO_EXPORT Graph& graph(unsafe_tag_t /* tag */);
597  MASM_NO_EXPORT void propagate(unsafe_tag_t /* tag */);
599 
602  bool adjacent(AtomIndex a, AtomIndex b) const final;
603 
604  boost::optional<BondIndex> bond(AtomIndex a, AtomIndex b) const final;
605 
606  BondType bondType(const BondIndex& edge) const final;
607 
608  bool canRemove(AtomIndex a) const final;
609 
610  bool canRemove(const BondIndex& edge) const final;
611 
612  const Cycles& cycles() const final;
613 
614  unsigned degree(AtomIndex a) const final;
615 
616  Utils::ElementType elementType(AtomIndex a) const final;
617 
618  AtomIndex V() const final;
619 
620  unsigned E() const final;
622 
625 
629  boost::optional<AtomEnvironmentComponents> canonicalComponents() const;
630 
659  boost::optional<Shapes::Shape> inferShape(
660  AtomIndex index,
661  const RankingInformation& ranking
662  ) const;
663 
675  std::string dumpGraphviz() const;
676 
681  const Graph& graph() const;
682 
705  std::size_t hash() const;
706 
711  const StereopermutatorList& stereopermutators() const;
712 
733  StereopermutatorList inferStereopermutatorsFromPositions(
734  const AngstromPositions& angstromWrapper,
735  const boost::optional<
736  std::vector<BondIndex>
737  >& explicitBondStereopermutatorCandidatesOption = boost::none
738  ) const;
739 
741  std::string str() const;
742 
768  RankingInformation rankPriority(
769  AtomIndex a,
770  const std::vector<AtomIndex>& excludeAdjacent = {},
771  const boost::optional<AngstromPositions>& positionsOption = boost::none
772  ) const;
774 
777 
794  bool canonicalCompare(
795  const Molecule& other,
796  AtomEnvironmentComponents componentBitmask = AtomEnvironmentComponents::All
797  ) const;
798 
832  boost::optional<std::vector<AtomIndex>> modularIsomorphism(
833  const Molecule& other,
834  AtomEnvironmentComponents componentBitmask
835  ) const;
837 
840 
857  bool operator == (const Molecule& other) const;
859  bool operator != (const Molecule& other) const;
861 
862 private:
864  struct Impl;
865  std::unique_ptr<Impl> pImpl_;
866 };
867 
868 } // namespace Molassembler
869 } // namespace Scine
870 
872 MASM_EXPORT std::ostream& operator << (
873  std::ostream& os,
874  const Scine::Molassembler::Molecule& molecule
875 );
876 
877 #endif
Models a molecule as a graph (connectivity of atoms) and a list of stereopermutators.
Definition: Molecule.h:77
Ranking data of substituents around a central vertex.
Definition: RankingInformation.h:23
Interface class for the molecular graph.
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.
Represents the connectivity of atoms of a molecule.
Definition: Graph.h:54
boost::optional< Shapes::Shape > inferShape(const Graph &graph, AtomIndex index, const RankingInformation &ranking)
Forwards inference to appropriate model depending on environment.
AtomEnvironmentComponents
For bitmasks grouping components of immediate atom environments.
Definition: Types.h:103
Definition: GraphInterface.h:21
Wrapper class to make working with RDL in C++ more pleasant.
Definition: Cycles.h:44
std::ostream & operator<<(std::ostream &os, const Scine::Molassembler::Molecule &molecule)
Writes some information about a molecule to a stream.
Definition: PeriodicBoundaries.h:22
At least two shape vertices eclipse one another along the axis.
Handles specific relative arrangements of two atom stereopermutators joined by a bond.
Definition: BondStereopermutator.h:46
Manages all stereopermutators that are part of a Molecule.
Definition: StereopermutatorList.h:30
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.
Handle rotational arrangements of adjacent atom-centered shapes.
BondType
Discrete bond type numeration.
Definition: Types.h:26
Type used to refer to particular bonds. Orders first &lt; second.
Definition: Types.h:54
Centralizes the main customization points of the library&#39;s behavior.
WideHashType hash(AtomEnvironmentComponents bitmask, Utils::ElementType elementType, const std::vector< BondInformation > &sortedBonds, const boost::optional< Shapes::Shape > &shapeOptional, const boost::optional< unsigned > &assignedOptional)
Convolutes the atom&#39;s element type and bonds into an unsigned integer.
Shape
Enumeration of all contained symmetry names.
Definition: Shapes.h:28
Random::Engine & randomnessEngine()
Randomness source for the entire library.
Alignment
How dihedrals are aligned in the generation of stereopermutations.
Definition: BondStereopermutator.h:53