Molassembler  1.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 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  const 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 
433  : dihedralRetries(3),
435  configuration()
436  {}
437 
439  unsigned dihedralRetries;
444  };
445 
464  void enumerate(
465  std::function<void(const DecisionList&, Utils::PositionCollection)> callback,
466  unsigned seed,
467  const EnumerationSettings& settings = {}
468  );
469 
491  void enumerateRandom(
492  std::function<void(const DecisionList&, Utils::PositionCollection)> callback,
493  const EnumerationSettings& settings = {}
494  );
495 
497  Relabeler relabeler() const;
498 
500  std::vector<int> binMidpointIntegers(const DecisionList& decision) const;
502 
503 private:
504  class Impl;
505  std::unique_ptr<Impl> pImpl_;
506 };
507 
521  struct DihedralInfo {
522  std::vector<AtomIndex> is;
523  AtomIndex j;
524  AtomIndex k;
525  std::vector<AtomIndex> ls;
526  unsigned symmetryOrder;
527  };
528  using Interval = std::pair<double, double>;
529  using Intervals = std::vector<Interval>;
531 
537  static Intervals densityBins(
538  const std::vector<double>& dihedrals,
539  double delta,
540  unsigned symmetryOrder = 1
541  );
542 
554 
556  void add(const Utils::PositionCollection& positions);
557 
563  std::vector<Intervals> bins(double delta=M_PI / 6) const;
564 
574  std::vector<std::vector<unsigned>> binIndices(
575  const std::vector<Intervals>& allBins
576  ) const;
577 
579  std::vector<std::vector<int>> binMidpointIntegers(
580  const std::vector<std::vector<unsigned>>& binIndices,
581  const std::vector<Intervals>& allBins
582  ) const;
583 
586  std::vector<DihedralInfo> sequences;
587  std::vector<std::vector<double>> observedDihedrals;
589 };
590 
591 } // namespace Molassembler
592 } // namespace Scine
593 
594 #endif
Models a molecule as a graph (connectivity of atoms) and a list of stereopermutators.
Definition: Molecule.h:73
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.
std::vector< unsigned > distance(AtomIndex i, const Graph &graph)
Calculates the graph distance from a single atom index to all others.
static Intervals densityBins(const std::vector< double > &dihedrals, double delta, unsigned symmetryOrder=1)
Simplest density-based binning function.
unsigned dihedralRetries
Number of attempts to generate the correct decision list.
Definition: DirectedConformerGenerator.h:439
Choose whichever assignment best represents the geometry directly.
outcome::result< Utils::PositionCollection > generateRandomConformation(const Molecule &molecule, const DistanceGeometry::Configuration &configuration=DistanceGeometry::Configuration{})
Generate a 3D structure of a Molecule.
void add(const Utils::PositionCollection &positions)
Add a particular position to the set to relabel.
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:518
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:443
Centralizes the main customization points of the library&#39;s behavior.
Relabeler(DirectedConformerGenerator::BondList bonds, const Molecule &mol)
Construct a relabeler with a custom list of bonds.
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
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
BondStereopermutator::FittingMode fitting
How a decision list is fitted to a generated conformer.
Definition: DirectedConformerGenerator.h:441
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