![]() |
Chemical Data Processing Library Python API - Version 1.4.0
|
Counts occurrences of registered substructure patterns in a molecular graph, emitting the per-pattern hit counts into a user-supplied histogram container. More...
Inheritance diagram for CDPL.Chem.SubstructureHistogramCalculator:Classes | |
| class | Pattern |
| Stores a single substructure query molecular graph, its histogram ID, its priority and match-handling flags. More... | |
Public Member Functions | |
| None | __init__ () |
Constructs an empty SubstructureHistogramCalculator instance. | |
| None | __init__ (SubstructureHistogramCalculator calc) |
Initializes a copy of the SubstructureHistogramCalculator instance calc. More... | |
| int | getObjectID () |
| Returns the numeric identifier (ID) of the wrapped C++ class instance. More... | |
| None | addPattern (MolecularGraph molgraph, int id=0, int priority=0, bool all_matches=True, bool unique_matches=True) |
| Registers a new pattern by its query molecular graph and per-pattern settings. More... | |
| None | addPattern (Pattern pattern) |
| Appends a copy of the pre-built pattern pattern. More... | |
| Pattern | getPattern (int idx) |
| Returns the registered pattern at index idx. More... | |
| None | removePattern (int idx) |
| Removes the registered pattern at index idx. More... | |
| None | clear () |
| Removes all registered patterns. | |
| int | getNumPatterns () |
| Returns the number of registered patterns. More... | |
| None | calculate (MolecularGraph molgraph, object histo) |
| Counts substructure occurrences in molgraph and writes the per-pattern hit counts to histo. More... | |
| SubstructureHistogramCalculator | assign (SubstructureHistogramCalculator calc) |
Replaces the current state of self with a copy of the state of the SubstructureHistogramCalculator instance calc. More... | |
Properties | |
| objectID = property(getObjectID) | |
| numPatterns = property(getNumPatterns) | |
Counts occurrences of registered substructure patterns 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 query molecular graph, 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.
| None CDPL.Chem.SubstructureHistogramCalculator.__init__ | ( | SubstructureHistogramCalculator | calc | ) |
Initializes a copy of the SubstructureHistogramCalculator instance calc.
| calc | The SubstructureHistogramCalculator instance to copy. |
| int CDPL.Chem.SubstructureHistogramCalculator.getObjectID | ( | ) |
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python SubstructureHistogramCalculator instances may reference the same underlying C++ class instance. The commonly used Python expression a is not b thus cannot tell reliably whether the two SubstructureHistogramCalculator instances a and b reference different C++ objects. The numeric identifier returned by this method allows to correctly implement such an identity test via the simple expression a.getObjectID() != b.getObjectID().
| None CDPL.Chem.SubstructureHistogramCalculator.addPattern | ( | MolecularGraph | molgraph, |
| int | id = 0, |
||
| int | 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 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. |
| None CDPL.Chem.SubstructureHistogramCalculator.addPattern | ( | Pattern | pattern | ) |
Appends a copy of the pre-built pattern pattern.
| pattern | The pattern to copy and register. |
| Pattern CDPL.Chem.SubstructureHistogramCalculator.getPattern | ( | int | idx | ) |
Returns 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]. |
| None CDPL.Chem.SubstructureHistogramCalculator.removePattern | ( | int | 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]. |
| int CDPL.Chem.SubstructureHistogramCalculator.getNumPatterns | ( | ) |
Returns the number of registered patterns.
| None CDPL.Chem.SubstructureHistogramCalculator.calculate | ( | MolecularGraph | molgraph, |
| object | 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.
| molgraph | The molecular graph to be analyzed. |
| histo | The histogram receiving the hit counts. |
| SubstructureHistogramCalculator CDPL.Chem.SubstructureHistogramCalculator.assign | ( | SubstructureHistogramCalculator | calc | ) |
Replaces the current state of self with a copy of the state of the SubstructureHistogramCalculator instance calc.
| calc | The SubstructureHistogramCalculator instance to copy. |