![]() |
Chemical Data Processing Library C++ API - Version 1.4.0
|
Counts occurrences of registered SMARTS substructure queries in a molecular graph, emitting the per-pattern hit counts into a user-supplied histogram container. More...
#include <SubstructureHistogramCalculator.hpp>
Classes | |
| class | Pattern |
| Holds a single SMARTS query pattern, its histogram ID, its priority and match-handling flags. More... | |
Public Types | |
| typedef std::shared_ptr< SubstructureHistogramCalculator > | SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated SubstructureHistogramCalculator instances. More... | |
| typedef PatternList::const_iterator | ConstPatternIterator |
| A constant iterator over the registered patterns. More... | |
| typedef PatternList::iterator | PatternIterator |
| A mutable iterator over the registered patterns. More... | |
Public Member Functions | |
| SubstructureHistogramCalculator () | |
Constructs an empty SubstructureHistogramCalculator instance. More... | |
| SubstructureHistogramCalculator (const SubstructureHistogramCalculator &gen) | |
Constructs a copy of the SubstructureHistogramCalculator instance gen. More... | |
| 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. More... | |
| void | addPattern (const Pattern &pattern) |
| Appends a copy of the pre-built pattern pattern. More... | |
| const Pattern & | getPattern (std::size_t idx) const |
| Returns the registered pattern at index idx. More... | |
| void | removePattern (std::size_t idx) |
| Removes the registered pattern at index idx. More... | |
| void | removePattern (const PatternIterator &it) |
| Removes the registered pattern referenced by it. More... | |
| void | clear () |
| Removes all registered patterns. More... | |
| std::size_t | getNumPatterns () const |
| Returns the number of registered patterns. More... | |
| ConstPatternIterator | getPatternsBegin () const |
| Returns a constant iterator pointing to the first registered pattern. More... | |
| ConstPatternIterator | getPatternsEnd () const |
| Returns a constant iterator pointing one past the last registered pattern. More... | |
| PatternIterator | getPatternsBegin () |
| Returns a mutable iterator pointing to the first registered pattern. More... | |
| PatternIterator | getPatternsEnd () |
| Returns a mutable iterator pointing one past the last registered pattern. More... | |
| ConstPatternIterator | begin () const |
| Returns a constant iterator pointing to the first registered pattern (range-based for support). More... | |
| ConstPatternIterator | end () const |
| Returns a constant iterator pointing one past the last registered pattern (range-based for support). More... | |
| PatternIterator | begin () |
| Returns a mutable iterator pointing to the first registered pattern (range-based for support). More... | |
| PatternIterator | end () |
| Returns a mutable iterator pointing one past the last registered pattern (range-based for support). More... | |
| template<typename T > | |
| void | calculate (const MolecularGraph &molgraph, T &histo) |
| Counts substructure occurrences in molgraph and writes the per-pattern hit counts to histo. More... | |
| SubstructureHistogramCalculator & | operator= (const SubstructureHistogramCalculator &gen) |
| Replaces the state of this calculator by a copy of the state of gen. More... | |
Counts occurrences of registered SMARTS substructure queries in a molecular graph, emitting the per-pattern hit counts into a user-supplied histogram container.
Patterns are added via addPattern() (each pattern carries a numeric ID, a priority and match-handling flags). On calculate() the registered patterns are run in priority order against the input molecular graph; matched atom/bond regions are masked so that subsequent lower-priority patterns cannot re-count overlapping substructures. The per-pattern hit count is then forwarded to the histogram via the expression histo[id]++ for every accepted match.
| typedef std::shared_ptr<SubstructureHistogramCalculator> CDPL::Chem::SubstructureHistogramCalculator::SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated SubstructureHistogramCalculator instances.
| typedef PatternList::const_iterator CDPL::Chem::SubstructureHistogramCalculator::ConstPatternIterator |
A constant iterator over the registered patterns.
| typedef PatternList::iterator CDPL::Chem::SubstructureHistogramCalculator::PatternIterator |
A mutable iterator over the registered patterns.
| CDPL::Chem::SubstructureHistogramCalculator::SubstructureHistogramCalculator | ( | ) |
Constructs an empty SubstructureHistogramCalculator instance.
| CDPL::Chem::SubstructureHistogramCalculator::SubstructureHistogramCalculator | ( | const SubstructureHistogramCalculator & | gen | ) |
Constructs a copy of the SubstructureHistogramCalculator instance gen.
| gen | The SubstructureHistogramCalculator to copy. |
| void CDPL::Chem::SubstructureHistogramCalculator::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.
| molgraph | The SMARTS query molecular graph. |
| id | The histogram-bin ID to which matches of this pattern contribute. |
| priority | The pattern's priority; higher-priority patterns are evaluated first. |
| all_matches | If true, every match of the query is processed; otherwise only the first. |
| unique_matches | If true, only one of multiple equivalent substructure mappings is processed per match. |
| void CDPL::Chem::SubstructureHistogramCalculator::addPattern | ( | const Pattern & | pattern | ) |
Appends a copy of the pre-built pattern pattern.
| pattern | The pattern to copy and register. |
| const Pattern& CDPL::Chem::SubstructureHistogramCalculator::getPattern | ( | std::size_t | idx | ) | const |
Returns the registered pattern at index idx.
| idx | The zero-based pattern index. |
const reference to the pattern. | Base::IndexError | if the number of patterns is zero or idx is not in the range [0, getNumPatterns() - 1]. |
| void CDPL::Chem::SubstructureHistogramCalculator::removePattern | ( | std::size_t | idx | ) |
Removes the registered pattern at index idx.
| idx | The zero-based pattern index. |
| Base::IndexError | if the number of patterns is zero or idx is not in the range [0, getNumPatterns() - 1]. |
| void CDPL::Chem::SubstructureHistogramCalculator::removePattern | ( | const PatternIterator & | it | ) |
Removes the registered pattern referenced by it.
| it | Iterator referencing the pattern to remove. |
| Base::IndexError | if it is not in the range [getPatternsBegin(), getPatternsEnd() - 1]. |
| void CDPL::Chem::SubstructureHistogramCalculator::clear | ( | ) |
Removes all registered patterns.
| std::size_t CDPL::Chem::SubstructureHistogramCalculator::getNumPatterns | ( | ) | const |
Returns the number of registered patterns.
| ConstPatternIterator CDPL::Chem::SubstructureHistogramCalculator::getPatternsBegin | ( | ) | const |
Returns a constant iterator pointing to the first registered pattern.
| ConstPatternIterator CDPL::Chem::SubstructureHistogramCalculator::getPatternsEnd | ( | ) | const |
Returns a constant iterator pointing one past the last registered pattern.
| PatternIterator CDPL::Chem::SubstructureHistogramCalculator::getPatternsBegin | ( | ) |
Returns a mutable iterator pointing to the first registered pattern.
| PatternIterator CDPL::Chem::SubstructureHistogramCalculator::getPatternsEnd | ( | ) |
Returns a mutable iterator pointing one past the last registered pattern.
| ConstPatternIterator CDPL::Chem::SubstructureHistogramCalculator::begin | ( | ) | const |
Returns a constant iterator pointing to the first registered pattern (range-based for support).
| ConstPatternIterator CDPL::Chem::SubstructureHistogramCalculator::end | ( | ) | const |
Returns a constant iterator pointing one past the last registered pattern (range-based for support).
| PatternIterator CDPL::Chem::SubstructureHistogramCalculator::begin | ( | ) |
Returns a mutable iterator pointing to the first registered pattern (range-based for support).
| PatternIterator CDPL::Chem::SubstructureHistogramCalculator::end | ( | ) |
Returns a mutable iterator pointing one past the last registered pattern (range-based for support).
| void CDPL::Chem::SubstructureHistogramCalculator::calculate | ( | const MolecularGraph & | molgraph, |
| T & | histo | ||
| ) |
Counts substructure occurrences in molgraph and writes the per-pattern hit counts to histo.
For every accepted match, the histogram is updated via histo[id] += 1 with the ID being the histogram-bin ID of the matching pattern.
| T | The histogram type (must support operator[] returning an arithmetic value). |
| molgraph | The molecular graph to be analyzed. |
| histo | The histogram receiving the hit counts. |
| SubstructureHistogramCalculator& CDPL::Chem::SubstructureHistogramCalculator::operator= | ( | const SubstructureHistogramCalculator & | gen | ) |
Replaces the state of this calculator by a copy of the state of gen.
| gen | The source SubstructureHistogramCalculator. |