Molassembler  1.1.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 namespace outcome = OUTCOME_V2_NAMESPACE;
27 
28 class Molecule;
29 
90 class MASM_EXPORT DirectedConformerGenerator {
91 public:
95  using BondList = std::vector<BondIndex>;
102  using DecisionList = std::vector<std::uint8_t>;
103 
105  constexpr static std::uint8_t unknownDecision = std::numeric_limits<std::uint8_t>::max();
106 
107  //* @brief Reason why a bond is ignored
108  enum class IgnoreReason {
110  AtomStereopermutatorPreconditionsUnmet,
112  HasAssignedBondStereopermutator,
114  HasTerminalConstitutingAtom,
152  InCycle,
156  IsEtaBond,
160  RotationIsIsotropic
161  };
162 
163  struct Relabeler;
165 
168 
186  static boost::variant<IgnoreReason, BondStereopermutator> considerBond(
187  const BondIndex& bondIndex,
188  const Molecule& molecule,
190  );
191 
221  static unsigned distance(
222  const DecisionList& a,
223  const DecisionList& b,
224  const DecisionList& bounds
225  );
227 
230 
248  Molecule molecule,
250  const BondList& bondsToConsider = {}
251  );
253 
256  DirectedConformerGenerator(DirectedConformerGenerator&& other) noexcept;
257  DirectedConformerGenerator& operator = (DirectedConformerGenerator&& other) noexcept;
258  DirectedConformerGenerator(const DirectedConformerGenerator& other) = delete;
259  DirectedConformerGenerator& operator = (const DirectedConformerGenerator& other) = delete;
260  ~DirectedConformerGenerator();
262 
265 
283  DecisionList generateNewDecisionList(Random::Engine& engine = randomnessEngine());
284 
295  bool insert(const DecisionList& decisionList);
296 
305  bool contains(const DecisionList& decisionList) const;
307 
311  BondStereopermutator::Alignment alignment() const;
312 
320  const BondList& bondList() const;
321 
332  unsigned decisionListSetSize() const;
333 
341  unsigned idealEnsembleSize() const;
342 
355  outcome::result<Utils::PositionCollection> generateRandomConformation(
356  const DecisionList& decisionList,
357  const DistanceGeometry::Configuration& configuration = DistanceGeometry::Configuration {},
359  ) const;
360 
371  outcome::result<Utils::PositionCollection> generateConformation(
372  const DecisionList& decisionList,
373  unsigned seed,
374  const DistanceGeometry::Configuration& configuration = DistanceGeometry::Configuration {},
376  ) const;
377 
382  Molecule conformationMolecule(const DecisionList& decisionList) const;
383 
404  DecisionList getDecisionList(
405  const Utils::AtomCollection& atomCollection,
407  ) const;
408 
425  DecisionList getDecisionList(
426  const Utils::PositionCollection& positions,
428  ) const;
429 
432  EnumerationSettings() : configuration() {}
433 
435  unsigned dihedralRetries = 3;
440  };
441 
460  void enumerate(
461  std::function<void(const DecisionList&, Utils::PositionCollection)> callback,
462  unsigned seed,
463  const EnumerationSettings& settings = {}
464  );
465 
487  void enumerateRandom(
488  std::function<void(const DecisionList&, Utils::PositionCollection)> callback,
489  const EnumerationSettings& settings = {}
490  );
491 
493  Relabeler relabeler() const;
494 
496  std::vector<int> binMidpointIntegers(const DecisionList& decision) const;
497 
499  std::vector<std::pair<int, int>> binBounds(const DecisionList& decision) const;
501 
502 private:
503  class Impl;
504  std::unique_ptr<Impl> pImpl_;
505 };
506 
520  struct DihedralInfo {
521  std::vector<AtomIndex> is;
522  AtomIndex j;
523  AtomIndex k;
524  std::vector<AtomIndex> ls;
525  unsigned symmetryOrder;
526  };
527  using Interval = std::pair<double, double>;
528  using Intervals = std::vector<Interval>;
530 
536  static Intervals densityBins(
537  const std::vector<double>& dihedrals,
538  double delta,
539  unsigned symmetryOrder = 1
540  );
541 
542  static std::pair<double, double> makeBounds(double phi, double tolerance);
543  static std::pair<int, int> integerBounds(const std::pair<double, double>& bounds);
544 
555  Relabeler(const DirectedConformerGenerator::BondList& bonds, const Molecule& mol);
556 
558  std::vector<double> add(const Utils::PositionCollection& positions);
559 
565  std::vector<Intervals> bins(double delta=M_PI / 6) const;
566 
576  std::vector<std::vector<unsigned>> binIndices(
577  const std::vector<Intervals>& allBins
578  ) const;
579 
581  std::vector<std::vector<int>> binMidpointIntegers(
582  const std::vector<std::vector<unsigned>>& binIndices,
583  const std::vector<Intervals>& allBins
584  ) const;
585 
587  std::vector<
588  std::vector<std::pair<int, int>>
589  > binBounds(
590  const std::vector<std::vector<unsigned>>& binIndices,
591  const std::vector<Intervals>& allBins
592  ) const;
593 
596  std::vector<DihedralInfo> sequences;
597  std::vector<std::vector<double>> observedDihedrals;
599 };
600 
601 } // namespace Molassembler
602 } // namespace Scine
603 
604 #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:102
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.
outcome::result< Utils::PositionCollection > generateConformation(const Molecule &molecule, unsigned seed, const DistanceGeometry::Configuration &configuration=DistanceGeometry::Configuration{})
Generate a 3D structure of a Molecule.
A configuration object for distance geometry runs with sane defaults.
Definition: Conformers.h:75
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.
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.
outcome::result< Utils::PositionCollection > generateRandomConformation(const Molecule &molecule, const DistanceGeometry::Configuration &configuration=DistanceGeometry::Configuration{})
Generate a 3D structure of a Molecule.
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:517
Handle rotational arrangements of adjacent atom-centered shapes.
Settings for enumeration.
Definition: DirectedConformerGenerator.h:431
Type used to refer to particular bonds. Orders first &lt; second.
Definition: Types.h:54
DistanceGeometry::Configuration configuration
Conformer generation settings.
Definition: DirectedConformerGenerator.h:439
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:90
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:108
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
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:95