Molassembler  1.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 
14 #include "boost/optional.hpp"
15 
16 #include "Molassembler/Options.h"
17 
18 namespace Scine {
19 // External forward declarations
20 namespace Utils {
21 using ElementTypeCollection = std::vector<ElementType>;
22 class AtomCollection;
23 } // namespace Utils
24 
25 namespace Molassembler {
26 
27 // Forward declarations
28 class Graph;
29 class StereopermutatorList;
30 struct RankingInformation;
31 
73 class MASM_EXPORT Molecule {
74 public:
75 
78 
87  static Utils::AtomCollection applyCanonicalizationMap(
88  const std::vector<AtomIndex>& canonicalizationIndexMap,
89  const Utils::AtomCollection& atomCollection
90  );
92 
95  /* Rule of five members */
96  Molecule(Molecule&& other) noexcept;
97  Molecule& operator = (Molecule&& rhs) noexcept;
98  Molecule(const Molecule& other);
99  Molecule& operator = (const Molecule& rhs);
100  ~Molecule();
101 
107  Molecule() noexcept;
108 
114  Molecule(Utils::ElementType element) noexcept;
115 
121  Molecule(
122  Utils::ElementType a,
123  Utils::ElementType b,
124  BondType bondType = BondType::Single
125  ) noexcept;
126 
138  explicit Molecule(Graph graph);
139 
160  Molecule(
161  Graph graph,
162  const AngstromPositions& positions,
163  const boost::optional<
164  std::vector<BondIndex>
165  >& bondStereopermutatorCandidatesOptional = boost::none
166  );
167 
178  MASM_NO_EXPORT Molecule(
179  Graph graph,
180  StereopermutatorList stereopermutators,
181  boost::optional<AtomEnvironmentComponents> canonicalComponentsOption = boost::none
182  );
184 
187 
208  AtomIndex addAtom(
209  Utils::ElementType elementType,
210  AtomIndex adjacentTo,
211  BondType bondType = BondType::Single
212  );
213 
239  BondIndex addBond(
240  AtomIndex a,
241  AtomIndex b,
242  BondType bondType = BondType::Single
243  );
244 
251  void applyPermutation(const std::vector<AtomIndex>& permutation);
252 
281  void assignStereopermutator(
282  AtomIndex a,
283  const boost::optional<unsigned>& assignmentOption
284  );
285 
314  void assignStereopermutator(
315  const BondIndex& edge,
316  const boost::optional<unsigned>& assignmentOption
317  );
318 
348  void assignStereopermutatorRandomly(AtomIndex a, Random::Engine& engine = randomnessEngine());
349 
376  void assignStereopermutatorRandomly(const BondIndex& e, Random::Engine& engine = randomnessEngine());
377 
403  std::vector<AtomIndex> canonicalize(
404  AtomEnvironmentComponents componentBitmask = AtomEnvironmentComponents::All
405  );
406 
430  void removeAtom(AtomIndex a);
431 
459  void removeBond(AtomIndex a, AtomIndex b);
460 
462  void removeBond(const BondIndex& bond);
463 
490  bool setBondType(
491  AtomIndex a,
492  AtomIndex b,
493  BondType bondType
494  );
495 
515  void setElementType(
516  AtomIndex a,
517  Utils::ElementType elementType
518  );
519 
544  void setShapeAtAtom(
545  AtomIndex a,
547  );
549 
552 
556  boost::optional<AtomEnvironmentComponents> canonicalComponents() const;
557 
586  boost::optional<Shapes::Shape> inferShape(
587  AtomIndex index,
588  const RankingInformation& ranking
589  ) const;
590 
602  std::string dumpGraphviz() const;
603 
608  const Graph& graph() const;
609 
632  std::size_t hash() const;
633 
638  const StereopermutatorList& stereopermutators() const;
639 
660  StereopermutatorList inferStereopermutatorsFromPositions(
661  const AngstromPositions& angstromWrapper,
662  const boost::optional<
663  std::vector<BondIndex>
664  >& explicitBondStereopermutatorCandidatesOption = boost::none
665  ) const;
666 
668  std::string str() const;
669 
695  RankingInformation rankPriority(
696  AtomIndex a,
697  const std::vector<AtomIndex>& excludeAdjacent = {},
698  const boost::optional<AngstromPositions>& positionsOption = boost::none
699  ) const;
701 
704 
721  bool canonicalCompare(
722  const Molecule& other,
723  AtomEnvironmentComponents componentBitmask = AtomEnvironmentComponents::All
724  ) const;
725 
759  boost::optional<std::vector<AtomIndex>> modularIsomorphism(
760  const Molecule& other,
761  AtomEnvironmentComponents componentBitmask
762  ) const;
764 
767 
784  bool operator == (const Molecule& other) const;
786  bool operator != (const Molecule& other) const;
788 
789 private:
791  struct Impl;
792  std::unique_ptr<Impl> pImpl_;
793 
794  /* Allow access to implementation to editor class that enables more
795  * macro-oriented editing as opposed to the low-level editing provided here
796  */
797  friend struct Editing;
798 
799  /* Allow access to implementation to DirectedConformerGenerator. This class
800  * needs to make additions to the StereopermutatorList that should not be
801  * part of the public interface.
802  */
803  friend class DirectedConformerGenerator;
804 };
805 
806 } // namespace Molassembler
807 } // namespace Scine
808 
810 MASM_EXPORT std::ostream& operator << (
811  std::ostream& os,
812  const Scine::Molassembler::Molecule& molecule
813 );
814 
815 #endif
Models a molecule as a graph (connectivity of atoms) and a list of stereopermutators.
Definition: Molecule.h:73
Ranking data of substituents around a central vertex.
Definition: RankingInformation.h:23
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.
Definition: MoleculeImpl.h:21
Represents the connectivity of atoms of a molecule.
Definition: Graph.h:57
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
std::ostream & operator<<(std::ostream &os, const Scine::Molassembler::Molecule &molecule)
Writes some information about a molecule to a stream.
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.
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.
Helper type for directed conformer generation.
Definition: DirectedConformerGenerator.h:90
Shape
Enumeration of all contained symmetry names.
Definition: Shapes.h:28
Class with static functions providing higher-level molecule operations.
Definition: Editing.h:22
Random::Engine & randomnessEngine()
Randomness source for the entire library.