Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
DirectedConformerGenerator.h
Go to the documentation of this file.
1 
8 #ifndef INCLUDE_MOLASSEMBLER_DIRECTED_CONFORMER_GENERATOR_H
9 #define INCLUDE_MOLASSEMBLER_DIRECTED_CONFORMER_GENERATOR_H
10 
13 #include "Molassembler/Options.h"
14 
15 #include "boost/variant/variant_fwd.hpp"
16 
17 #include <unordered_map>
18 
19 namespace Scine {
20 namespace Utils {
21 class AtomCollection;
22 } // namespace Utils
23 
24 namespace Molassembler {
25 
26 class Molecule;
27 
88 class MASM_EXPORT DirectedConformerGenerator {
89 public:
93  using BondList = std::vector<BondIndex>;
100  using DecisionList = std::vector<std::uint8_t>;
101 
103  constexpr static std::uint8_t unknownDecision = std::numeric_limits<std::uint8_t>::max();
104 
105  //* @brief Reason why a bond is ignored
106  enum class IgnoreReason {
108  AtomStereopermutatorPreconditionsUnmet,
110  HasAssignedBondStereopermutator,
112  HasTerminalConstitutingAtom,
150  InCycle,
154  IsEtaBond,
158  RotationIsIsotropic
159  };
160 
161  struct Relabeler;
163 
166 
184  static boost::variant<IgnoreReason, BondStereopermutator> considerBond(
185  const BondIndex& bondIndex,
186  const Molecule& molecule,
188  );
189 
219  static unsigned distance(
220  const DecisionList& a,
221  const DecisionList& b,
222  const DecisionList& bounds
223  );
225 
228 
246  Molecule molecule,
248  const BondList& bondsToConsider = {}
249  );
251 
254  DirectedConformerGenerator(DirectedConformerGenerator&& other) noexcept;
255  DirectedConformerGenerator& operator = (DirectedConformerGenerator&& other) noexcept;
256  DirectedConformerGenerator(const DirectedConformerGenerator& other) = delete;
257  DirectedConformerGenerator& operator = (const DirectedConformerGenerator& other) = delete;
258  ~DirectedConformerGenerator();
260 
263 
281  DecisionList generateNewDecisionList(Random::Engine& engine = randomnessEngine());
282 
293  bool insert(const DecisionList& decisionList);
294 
303  bool contains(const DecisionList& decisionList) const;
305 
309  BondStereopermutator::Alignment alignment() const;
310 
318  const BondList& bondList() const;
319 
330  unsigned decisionListSetSize() const;
331 
339  unsigned idealEnsembleSize() const;
340 
353  Result<Utils::PositionCollection> generateRandomConformation(
354  const DecisionList& decisionList,
355  const DistanceGeometry::Configuration& configuration = DistanceGeometry::Configuration {},
357  ) const;
358 
369  Result<Utils::PositionCollection> generateConformation(
370  const DecisionList& decisionList,
371  unsigned seed,
372  const DistanceGeometry::Configuration& configuration = DistanceGeometry::Configuration {},
374  ) const;
375 
380  Molecule conformationMolecule(const DecisionList& decisionList) const;
381 
402  DecisionList getDecisionList(
403  const Utils::AtomCollection& atomCollection,
405  ) const;
406 
423  DecisionList getDecisionList(
424  const Utils::PositionCollection& positions,
426  ) const;
427 
430  EnumerationSettings() : configuration() {}
431 
433  unsigned dihedralRetries = 3;
438  };
439 
458  void enumerate(
459  std::function<void(const DecisionList&, Utils::PositionCollection)> callback,
460  unsigned seed,
461  const EnumerationSettings& settings = {}
462  );
463 
485  void enumerateRandom(
486  std::function<void(const DecisionList&, Utils::PositionCollection)> callback,
487  const EnumerationSettings& settings = {}
488  );
489 
491  Relabeler relabeler() const;
492 
497  [[deprecated]]
498  std::vector<int> binMidpointIntegers(const DecisionList& decision) const;
499 
501  std::vector<std::pair<int, int>> binBounds(const DecisionList& decision) const;
503 
504 private:
505  class Impl;
506  std::unique_ptr<Impl> pImpl_;
507 };
508 
522  struct DihedralInfo {
523  std::vector<AtomIndex> is;
524  AtomIndex j;
525  AtomIndex k;
526  std::vector<AtomIndex> ls;
527  unsigned symmetryOrder;
528  };
529  using Interval = std::pair<double, double>;
530  using Intervals = std::vector<Interval>;
532 
538  static Intervals densityBins(
539  const std::vector<double>& dihedrals,
540  double delta,
541  unsigned symmetryOrder = 1
542  );
543 
544  static std::pair<double, double> makeBounds(double phi, double tolerance);
545  static std::pair<int, int> integerBounds(const std::pair<double, double>& bounds);
546 
557  Relabeler(const DirectedConformerGenerator::BondList& bonds, const Molecule& mol);
558 
560  std::vector<double> add(const Utils::PositionCollection& positions);
561 
567  std::vector<Intervals> bins(double delta=M_PI / 6) const;
568 
578  std::vector<std::vector<unsigned>> binIndices(
579  const std::vector<Intervals>& allBins
580  ) const;
581 
583  std::vector<std::vector<int>> binMidpointIntegers(
584  const std::vector<std::vector<unsigned>>& binIndices,
585  const std::vector<Intervals>& allBins
586  ) const;
587 
589  std::vector<
590  std::vector<std::pair<int, int>>
591  > binBounds(
592  const std::vector<std::vector<unsigned>>& binIndices,
593  const std::vector<Intervals>& allBins
594  ) const;
595 
598  std::vector<DihedralInfo> sequences;
599  std::vector<std::vector<double>> observedDihedrals;
601 };
602 
603 } // namespace Molassembler
604 } // namespace Scine
605 
606 #endif
Models a molecule as a graph (connectivity of atoms) and a list of stereopermutators.
Definition: Molecule.h:77
std::vector< std::uint8_t > DecisionList
Type used to represent assignments at bonds.
Definition: DirectedConformerGenerator.h:100
std::vector< std::vector< int > > binMidpointIntegers(const std::vector< std::vector< unsigned >> &binIndices, const std::vector< Intervals > &allBins) const
Relabel bin indices for all structures with bin midpoint integers.
A configuration object for distance geometry runs with sane defaults.
Definition: Conformers.h:73
At least one pair of substituents are staggered along the axis.
static Intervals densityBins(const std::vector< double > &dihedrals, double delta, unsigned symmetryOrder=1)
Simplest density-based binning function.
Result< Utils::PositionCollection > generateConformation(const Molecule &molecule, unsigned seed, const DistanceGeometry::Configuration &configuration=DistanceGeometry::Configuration{})
Generate a 3D structure of a Molecule.
std::vector< unsigned > distance(AtomIndex source, const Graph &graph)
Calculates the graph distance from a single atom index to all others.
Choose whichever assignment best represents the geometry directly.
std::vector< std::vector< std::pair< int, int > > > binBounds(const std::vector< std::vector< unsigned >> &binIndices, const std::vector< Intervals > &allBins) const
Relabel bin indices for all structures with bin bounds.
std::vector< double > add(const Utils::PositionCollection &positions)
Add a structure to the set to relabel. Yields the considered dihedrals.
Positions must be close to the idealized assignment geometry.
std::size_t AtomIndex
Unsigned integer atom index type. Used to refer to particular atoms.
Definition: Types.h:51
Relabeler for decision lists with minimized structures.
Definition: DirectedConformerGenerator.h:519
Handle rotational arrangements of adjacent atom-centered shapes.
Settings for enumeration.
Definition: DirectedConformerGenerator.h:429
Type used to refer to particular bonds. Orders first &lt; second.
Definition: Types.h:54
DistanceGeometry::Configuration configuration
Conformer generation settings.
Definition: DirectedConformerGenerator.h:437
Centralizes the main customization points of the library&#39;s behavior.
std::vector< std::vector< unsigned > > binIndices(const std::vector< Intervals > &allBins) const
Determine relabeling for all added position sets in order.
std::vector< Intervals > bins(double delta=M_PI/6) const
Helper type for directed conformer generation.
Definition: DirectedConformerGenerator.h:88
Relabeler(const DirectedConformerGenerator::BondList &bonds, const Molecule &mol)
Construct a relabeler with a custom list of bonds.
IgnoreReason
Type used to represent the list of bonds relevant to directed conformer generation.
Definition: DirectedConformerGenerator.h:106
FittingMode
Differentiates how viable assignments are chosen during fitting.
Definition: BondStereopermutator.h:67
Random::Engine & randomnessEngine()
Randomness source for the entire library.
Alignment
How dihedrals are aligned in the generation of stereopermutations.
Definition: BondStereopermutator.h:53
Result< Utils::PositionCollection > generateRandomConformation(const Molecule &molecule, const DistanceGeometry::Configuration &configuration=DistanceGeometry::Configuration{})
Generate a 3D structure of a Molecule.
Interface for the generation of new conformations of Molecules.
std::vector< BondIndex > BondList
Type used to represent the list of bonds relevant to directed conformer generation.
Definition: DirectedConformerGenerator.h:93