Molassembler  3.0.0
Molecule graph and conformer library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Interpret.h
Go to the documentation of this file.
1 
11 #ifndef INCLUDE_MOLASSEMBLER_INTERPRET_H
12 #define INCLUDE_MOLASSEMBLER_INTERPRET_H
13 
14 #include "Molassembler/Export.h"
16 #include "boost/optional.hpp"
17 
18 namespace Scine {
19 namespace Utils {
20 
21 // External forward-declarations
22 enum class ElementType : unsigned;
23 class AtomCollection;
24 class BondOrderCollection;
25 using ElementTypeCollection = std::vector<ElementType>;
26 } // namespace Utils
27 
28 namespace Molassembler {
29 
30 // Forward-declarations
31 class Molecule;
32 class AngstromPositions;
33 
35 namespace Interpret {
36 
38 enum class MASM_EXPORT BondDiscretizationOption {
40  Binary,
43 };
44 
46 struct MASM_EXPORT ComponentMap {
49  unsigned component;
51  unsigned long atomIndex;
52  };
53 
55  ComponentIndexPair apply(unsigned index) const;
57  unsigned invert(const ComponentIndexPair& pair) const;
58 
59 
65  std::vector<
66  std::vector<unsigned>
67  > invert() const;
68 
77  std::vector<Utils::AtomCollection> apply(const Utils::AtomCollection& atomCollection) const;
78 
79  MASM_NO_EXPORT std::vector<AngstromPositions> apply(const AngstromPositions& positions) const;
80 
81  MASM_NO_EXPORT std::vector<PeriodicBoundaryDuplicates> apply(
82  const std::unordered_set<unsigned>& uninterestingAtoms,
83  const std::unordered_map<unsigned, unsigned>& ghostAtomMap
84  ) const;
85 
87  inline unsigned size() const { return map.size(); }
88 
89  unsigned countComponents() const;
90 
93  using Iterator = std::vector<unsigned>::iterator;
94  using ConstIterator = std::vector<unsigned>::const_iterator;
95  inline Iterator begin() { return std::begin(map); }
96  inline Iterator end() { return std::end(map); }
97  inline ConstIterator begin() const { return std::begin(map); }
98  inline ConstIterator end() const { return std::end(map); }
100 
101  std::vector<unsigned> map;
102 };
103 
105 struct MASM_EXPORT MoleculesResult {
107  std::vector<Molecule> molecules;
110 };
111 
130 MASM_EXPORT MoleculesResult molecules(
131  const Utils::ElementTypeCollection& elements,
132  const AngstromPositions& angstromWrapper,
133  const Utils::BondOrderCollection& bondOrders,
134  BondDiscretizationOption discretization = BondDiscretizationOption::Binary,
135  const boost::optional<double>& stereopermutatorThreshold = 1.4
136 );
137 
153 MASM_EXPORT MoleculesResult molecules(
154  const Utils::ElementTypeCollection& elements,
155  const AngstromPositions& angstromWrapper,
156  BondDiscretizationOption discretization = BondDiscretizationOption::Binary,
157  const boost::optional<double>& stereopermutatorThreshold = 1.4
158 );
159 
183 MASM_EXPORT MoleculesResult molecules(
184  const Utils::AtomCollection& atomCollection,
185  const Utils::BondOrderCollection& bondOrders,
186  BondDiscretizationOption discretization = BondDiscretizationOption::Binary,
187  const boost::optional<double>& stereopermutatorThreshold = 1.4
188 );
189 
221 MASM_EXPORT MoleculesResult molecules(
222  const Utils::AtomCollection& atoms,
223  const Utils::BondOrderCollection& periodicBonds,
224  const std::unordered_set<unsigned>& uninterestingAtoms,
225  const std::unordered_map<unsigned, unsigned>& ghostAtomMap,
226  BondDiscretizationOption discretization = BondDiscretizationOption::Binary,
227  const boost::optional<double>& stereopermutatorThreshold = 1.4
228 );
229 
250 MASM_EXPORT MoleculesResult molecules(
251  const Utils::AtomCollection& atomCollection,
252  BondDiscretizationOption discretization = BondDiscretizationOption::Binary,
253  const boost::optional<double>& stereopermutatorThreshold = 1.4
254 );
255 
257 struct MASM_EXPORT GraphsResult {
259  std::vector<Graph> graphs;
262 };
263 
280 MASM_EXPORT GraphsResult graphs(
281  const Utils::ElementTypeCollection& elements,
282  const AngstromPositions& angstromWrapper,
283  const Utils::BondOrderCollection& bondOrders,
284  BondDiscretizationOption discretization = BondDiscretizationOption::Binary
285 );
286 
305 MASM_EXPORT GraphsResult graphs(
306  const Utils::AtomCollection& atomCollection,
307  const Utils::BondOrderCollection& bondOrders,
308  BondDiscretizationOption discretization = BondDiscretizationOption::Binary
309 );
310 
313  unsigned i;
314  unsigned j;
315  double probability;
316 
317  inline bool operator < (const FalsePositive& other) const {
318  return probability < other.probability;
319  }
320 };
321 
332 MASM_EXPORT std::vector<FalsePositive> uncertainBonds(
333  const Utils::AtomCollection& atomCollection,
334  const Utils::BondOrderCollection& bondOrders
335 );
336 
351 MASM_EXPORT std::vector<FalsePositive> badHapticLigandBonds(
352  const Utils::AtomCollection& atomCollection,
353  const Utils::BondOrderCollection& bondOrders
354 );
355 
362  const Utils::AtomCollection& atoms,
364 );
365 
366 } // namespace Interpret
367 } // namespace Molassembler
368 } // namespace Scine
369 
370 #endif
MoleculesResult molecules(const Utils::ElementTypeCollection &elements, const AngstromPositions &angstromWrapper, const Utils::BondOrderCollection &bondOrders, BondDiscretizationOption discretization=BondDiscretizationOption::Binary, const boost::optional< double > &stereopermutatorThreshold=1.4)
The function that actually does all the work with the library-internal wrapper.
Result type of an interpret call.
Definition: Interpret.h:105
BondDiscretizationOption
How floating-point bond orders are discretized into bond types.
Definition: Interpret.h:38
A wrapper class around Utils&#39; PositionCollection to emphasize that the positions stored therein are i...
Definition: AngstromPositions.h:25
std::vector< Graph > graphs
Individual graphs found.
Definition: Interpret.h:259
Bond orders are rounded to the nearest integer.
std::vector< Molecule > molecules
The list of individual molecules found in the 3D information.
Definition: Interpret.h:107
Extras for dealing with periodic boundaries.
std::vector< FalsePositive > badHapticLigandBonds(const Utils::AtomCollection &atomCollection, const Utils::BondOrderCollection &bondOrders)
Suggests false positive haptic ligand bonds from a binary interpretation of bond orders.
ComponentMap componentMap
A map from an index within the AtomCollection to its index in molecules member.
Definition: Interpret.h:109
Utils::BondOrderCollection removeFalsePositives(const Utils::AtomCollection &atoms, Utils::BondOrderCollection bonds)
Iteratively applies false positive detection schemes.
ComponentMap componentMap
Mapping from atom collection index to graph component index.
Definition: Interpret.h:261
All bond orders &gt;= 0.5 are considered single bonds.
unsigned long atomIndex
Atom index.
Definition: Interpret.h:51
Type used to represent a map from an atom collection index to an interpreted object.
Definition: Interpret.h:46
constexpr auto map(const ArrayType< T, size > &array, UnaryFunction &&function)
Maps all elements of any array-like container with a unary function.
Definition: Containers.h:63
unsigned component
Index of component.
Definition: Interpret.h:49
unsigned size() const
Size of the map.
Definition: Interpret.h:87
Result type of a graph interpret call.
Definition: Interpret.h:257
Fn result datatype.
Definition: Interpret.h:312
GraphsResult graphs(const Utils::ElementTypeCollection &elements, const AngstromPositions &angstromWrapper, const Utils::BondOrderCollection &bondOrders, BondDiscretizationOption discretization=BondDiscretizationOption::Binary)
The function that actually does all the work with the library-internal wrapper.
std::vector< FalsePositive > uncertainBonds(const Utils::AtomCollection &atomCollection, const Utils::BondOrderCollection &bondOrders)
Suggests false positives from a binary interpretation of bond orders.