29 #ifndef CDPL_CHEM_SUBSTRUCTUREHISTOGRAMCALCULATOR_HPP
30 #define CDPL_CHEM_SUBSTRUCTUREHISTOGRAMCALCULATOR_HPP
68 typedef std::vector<Pattern> PatternList;
96 bool all_matches =
true,
bool unique_matches =
true);
131 std::size_t priority;
156 bool all_matches =
true,
bool unique_matches =
true);
255 template <
typename T>
266 typedef std::function<void(std::size_t)> HistoUpdateFunction;
268 template <
typename T>
269 class HistoUpdateFunctor
273 HistoUpdateFunctor(
T& histo):
276 void operator()(std::size_t
id)
285 void doCalculate(
const MolecularGraph& molgraph,
const HistoUpdateFunction& func);
287 void init(
const MolecularGraph& molgraph);
289 void processPattern(
const Pattern& ptn,
const HistoUpdateFunction& func);
290 bool processMatch(
const AtomBondMapping& mapping,
const Pattern& ptn,
const HistoUpdateFunction& func);
292 typedef std::pair<Util::BitSet, Util::BitSet> AtomBondMask;
293 typedef std::map<std::size_t, AtomBondMask> PriorityToAtomBondMaskMap;
295 const MolecularGraph* molGraph;
296 PatternList patterns;
297 SubstructureSearch subSearch;
298 PriorityToAtomBondMaskMap matchedSubstructMasks;
299 AtomBondMask testingAtomBondMask;
306 template <
typename T>
309 doCalculate(molgraph, HistoUpdateFunctor<T>(histo));
Declaration of type CDPL::Util::BitSet.
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of class CDPL::Chem::MolecularGraph.
Definition of class CDPL::Chem::SubstructureSearch.
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:63
Holds a single SMARTS query pattern, its histogram ID, its priority and match-handling flags.
Definition: SubstructureHistogramCalculator.hpp:83
Pattern(const MolecularGraph::SharedPointer &molgraph, std::size_t id, std::size_t priority=0, bool all_matches=true, bool unique_matches=true)
Constructs a pattern from the query molecular graph molgraph.
bool processUniqueMatchesOnly() const
Tells whether only one of multiple equivalent mappings is processed per match.
const MolecularGraph::SharedPointer & getStructure() const
Returns the SMARTS query molecular graph of this pattern.
std::size_t getPriority() const
Returns the pattern priority.
bool processAllMatches() const
Tells whether all substructure matches are processed.
std::size_t getID() const
Returns the histogram-bin ID of this pattern.
Counts occurrences of registered SMARTS substructure queries in a molecular graph,...
Definition: SubstructureHistogramCalculator.hpp:62
PatternIterator end()
Returns a mutable iterator pointing one past the last registered pattern (range-based for support).
PatternIterator begin()
Returns a mutable iterator pointing to the first registered pattern (range-based for support).
ConstPatternIterator begin() const
Returns a constant iterator pointing to the first registered pattern (range-based for support).
void removePattern(const PatternIterator &it)
Removes the registered pattern referenced by it.
SubstructureHistogramCalculator & operator=(const SubstructureHistogramCalculator &gen)
Replaces the state of this calculator by a copy of the state of gen.
ConstPatternIterator end() const
Returns a constant iterator pointing one past the last registered pattern (range-based for support).
ConstPatternIterator getPatternsEnd() const
Returns a constant iterator pointing one past the last registered pattern.
PatternList::iterator PatternIterator
A mutable iterator over the registered patterns.
Definition: SubstructureHistogramCalculator.hpp:77
PatternIterator getPatternsBegin()
Returns a mutable iterator pointing to the first registered pattern.
PatternIterator getPatternsEnd()
Returns a mutable iterator pointing one past the last registered pattern.
void addPattern(const MolecularGraph::SharedPointer &molgraph, std::size_t id, std::size_t priority=0, bool all_matches=true, bool unique_matches=true)
Registers a new pattern by its query molecular graph and per-pattern settings.
std::size_t getNumPatterns() const
Returns the number of registered patterns.
void removePattern(std::size_t idx)
Removes the registered pattern at index idx.
void addPattern(const Pattern &pattern)
Appends a copy of the pre-built pattern pattern.
PatternList::const_iterator ConstPatternIterator
A constant iterator over the registered patterns.
Definition: SubstructureHistogramCalculator.hpp:75
SubstructureHistogramCalculator()
Constructs an empty SubstructureHistogramCalculator instance.
void clear()
Removes all registered patterns.
SubstructureHistogramCalculator(const SubstructureHistogramCalculator &gen)
Constructs a copy of the SubstructureHistogramCalculator instance gen.
void calculate(const MolecularGraph &molgraph, T &histo)
Counts substructure occurrences in molgraph and writes the per-pattern hit counts to histo.
Definition: SubstructureHistogramCalculator.hpp:307
const Pattern & getPattern(std::size_t idx) const
Returns the registered pattern at index idx.
ConstPatternIterator getPatternsBegin() const
Returns a constant iterator pointing to the first registered pattern.
std::shared_ptr< SubstructureHistogramCalculator > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SubstructureHistogramCalculator i...
Definition: SubstructureHistogramCalculator.hpp:72
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.