![]() |
Chemical Data Processing Library C++ API - Version 1.4.0
|
Generic rule-based molecule fragmentation engine that splits a molecular graph along bonds matching user-defined SMARTS fragmentation rules. More...
#include <FragmentGenerator.hpp>
Inheritance diagram for CDPL::Chem::FragmentGenerator:Classes | |
| class | ExcludePattern |
| A pattern overriding a fragmentation rule: bonds matching the pattern are not cleaved. More... | |
| class | FragmentationRule |
| A single fragmentation rule, consisting of a SMARTS match pattern and a numeric rule ID. More... | |
| class | FragmentLink |
| Records the connectivity between two fragments produced by a single bond cleavage. More... | |
Public Types | |
| typedef std::shared_ptr< FragmentGenerator > | SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated FragmentGenerator instances. More... | |
| typedef std::function< bool(const MolecularGraph &)> | FragmentFilterFunction |
| Type of a predicate accepting/rejecting a generated fragment. More... | |
| typedef FragmentationRuleList::const_iterator | ConstFragmentationRuleIterator |
| A constant iterator over the registered fragmentation rules. More... | |
| typedef FragmentationRuleList::iterator | FragmentationRuleIterator |
| A mutable iterator over the registered fragmentation rules. More... | |
| typedef ExcludePatternList::const_iterator | ConstExcludePatternIterator |
| A constant iterator over the registered exclude patterns. More... | |
| typedef ExcludePatternList::iterator | ExcludePatternIterator |
| A mutable iterator over the registered exclude patterns. More... | |
| typedef FragmentLinkList::const_iterator | ConstFragmentLinkIterator |
| A constant iterator over the generated fragment links. More... | |
Public Member Functions | |
| FragmentGenerator () | |
Constructs the FragmentGenerator instance. More... | |
| FragmentGenerator (const FragmentGenerator &gen) | |
Constructs a copy of the FragmentGenerator instance gen. More... | |
| virtual | ~FragmentGenerator () |
| Virtual destructor. More... | |
| FragmentGenerator & | operator= (const FragmentGenerator &gen) |
| Replaces the state of this generator by a copy of the state of gen. More... | |
| void | addFragmentationRule (const MolecularGraph::SharedPointer &match_ptn, unsigned int rule_id) |
| Registers a new fragmentation rule by its SMARTS match pattern and rule ID. More... | |
| void | addFragmentationRule (const FragmentationRule &rule) |
| Appends a copy of the pre-built fragmentation rule rule. More... | |
| const FragmentationRule & | getFragmentationRule (std::size_t idx) const |
| Returns the fragmentation rule at index idx. More... | |
| FragmentationRule & | getFragmentationRule (std::size_t idx) |
| Returns the fragmentation rule at index idx. More... | |
| ConstFragmentationRuleIterator | getFragmentationRulesBegin () const |
| Returns a constant iterator pointing to the first registered fragmentation rule. More... | |
| ConstFragmentationRuleIterator | getFragmentationRulesEnd () const |
| Returns a constant iterator pointing one past the last registered fragmentation rule. More... | |
| FragmentationRuleIterator | getFragmentationRulesBegin () |
| Returns a mutable iterator pointing to the first registered fragmentation rule. More... | |
| FragmentationRuleIterator | getFragmentationRulesEnd () |
| Returns a mutable iterator pointing one past the last registered fragmentation rule. More... | |
| void | removeFragmentationRule (std::size_t idx) |
| Removes the fragmentation rule at index idx. More... | |
| std::size_t | getNumFragmentationRules () const |
| Returns the number of registered fragmentation rules. More... | |
| void | clearFragmentationRules () |
| Removes all registered fragmentation rules. More... | |
| void | addExcludePattern (const MolecularGraph::SharedPointer &match_ptn, unsigned int rule_id) |
| Registers a rule-specific exclude pattern. More... | |
| void | addExcludePattern (const MolecularGraph::SharedPointer &match_ptn) |
| Registers a generic exclude pattern (applies to all fragmentation rules). More... | |
| void | addExcludePattern (const ExcludePattern &excl_ptn) |
| Appends a copy of the pre-built exclude pattern excl_ptn. More... | |
| const ExcludePattern & | getExcludePattern (std::size_t idx) const |
| Returns the exclude pattern at index idx. More... | |
| ExcludePattern & | getExcludePattern (std::size_t idx) |
| Returns the exclude pattern at index idx. More... | |
| ConstExcludePatternIterator | getExcludePatternsBegin () const |
| Returns a constant iterator pointing to the first registered exclude pattern. More... | |
| ConstExcludePatternIterator | getExcludePatternsEnd () const |
| Returns a constant iterator pointing one past the last registered exclude pattern. More... | |
| ExcludePatternIterator | getExcludePatternsBegin () |
| Returns a mutable iterator pointing to the first registered exclude pattern. More... | |
| ExcludePatternIterator | getExcludePatternsEnd () |
| Returns a mutable iterator pointing one past the last registered exclude pattern. More... | |
| void | removeExcludePattern (std::size_t idx) |
| Removes the exclude pattern at index idx. More... | |
| std::size_t | getNumExcludePatterns () const |
| Returns the number of registered exclude patterns. More... | |
| void | clearExcludePatterns () |
| Removes all registered exclude patterns. More... | |
| bool | splitBondsIncluded () const |
| Tells whether the split (cleaved) bonds are retained in the output fragments. More... | |
| void | includeSplitBonds (bool include) |
| Specifies whether the split (cleaved) bonds shall be retained in the output fragments. More... | |
| const FragmentFilterFunction & | getFragmentFilterFunction () const |
| Returns the predicate used to filter the generated fragments. More... | |
| void | setFragmentFilterFunction (const FragmentFilterFunction &func) |
Sets the predicate used to filter the generated fragments (fragments for which the predicate returns false are discarded). More... | |
| void | generate (const MolecularGraph &molgraph, FragmentList &frag_list, bool append=false) |
| Performs the fragmentation of molgraph and writes the resulting fragments to frag_list. More... | |
| std::size_t | getNumFragmentLinks () const |
| Returns the number of fragment links produced by the most recent generate() call. More... | |
| const FragmentLink & | getFragmentLink (std::size_t idx) const |
| Returns the fragment link at index idx. More... | |
| ConstFragmentLinkIterator | getFragmentLinksBegin () const |
| Returns a constant iterator pointing to the first fragment link. More... | |
| ConstFragmentLinkIterator | getFragmentLinksEnd () const |
| Returns a constant iterator pointing one past the last fragment link. More... | |
Generic rule-based molecule fragmentation engine that splits a molecular graph along bonds matching user-defined SMARTS fragmentation rules.
Fragmentation rules are added via addFragmentationRule() (each rule has a SMARTS pattern matching a bond plus a numeric rule ID). Bonds matching any registered rule are scheduled for splitting, unless a registered exclude pattern overrides the split. The optional fragment filter rejects generated fragments based on a user-supplied predicate. The connectivity between the resulting fragments is exposed via the FragmentLink list, recording for each cleaved bond the two adjacent fragment indices, the cleaved bond, the matching rule and per-side atom labels.
| typedef std::shared_ptr<FragmentGenerator> CDPL::Chem::FragmentGenerator::SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated FragmentGenerator instances.
| typedef std::function<bool(const MolecularGraph&)> CDPL::Chem::FragmentGenerator::FragmentFilterFunction |
Type of a predicate accepting/rejecting a generated fragment.
| typedef FragmentationRuleList::const_iterator CDPL::Chem::FragmentGenerator::ConstFragmentationRuleIterator |
A constant iterator over the registered fragmentation rules.
| typedef FragmentationRuleList::iterator CDPL::Chem::FragmentGenerator::FragmentationRuleIterator |
A mutable iterator over the registered fragmentation rules.
| typedef ExcludePatternList::const_iterator CDPL::Chem::FragmentGenerator::ConstExcludePatternIterator |
A constant iterator over the registered exclude patterns.
| typedef ExcludePatternList::iterator CDPL::Chem::FragmentGenerator::ExcludePatternIterator |
A mutable iterator over the registered exclude patterns.
| typedef FragmentLinkList::const_iterator CDPL::Chem::FragmentGenerator::ConstFragmentLinkIterator |
A constant iterator over the generated fragment links.
| CDPL::Chem::FragmentGenerator::FragmentGenerator | ( | ) |
Constructs the FragmentGenerator instance.
| CDPL::Chem::FragmentGenerator::FragmentGenerator | ( | const FragmentGenerator & | gen | ) |
Constructs a copy of the FragmentGenerator instance gen.
| gen | The FragmentGenerator to copy. |
|
inlinevirtual |
Virtual destructor.
| FragmentGenerator& CDPL::Chem::FragmentGenerator::operator= | ( | const FragmentGenerator & | gen | ) |
Replaces the state of this generator by a copy of the state of gen.
| gen | The source FragmentGenerator. |
| void CDPL::Chem::FragmentGenerator::addFragmentationRule | ( | const MolecularGraph::SharedPointer & | match_ptn, |
| unsigned int | rule_id | ||
| ) |
Registers a new fragmentation rule by its SMARTS match pattern and rule ID.
| match_ptn | The SMARTS match pattern (must match a single bond to be cleaved). |
| rule_id | The rule identifier. |
| void CDPL::Chem::FragmentGenerator::addFragmentationRule | ( | const FragmentationRule & | rule | ) |
Appends a copy of the pre-built fragmentation rule rule.
| rule | The rule to copy and register. |
| const FragmentationRule& CDPL::Chem::FragmentGenerator::getFragmentationRule | ( | std::size_t | idx | ) | const |
Returns the fragmentation rule at index idx.
| idx | The zero-based rule index. |
const reference to the rule. | Base::IndexError | if the number of rules is zero or idx is not in the range [0, getNumFragmentationRules() - 1]. |
| FragmentationRule& CDPL::Chem::FragmentGenerator::getFragmentationRule | ( | std::size_t | idx | ) |
Returns the fragmentation rule at index idx.
| idx | The zero-based rule index. |
| Base::IndexError | if the number of rules is zero or idx is not in the range [0, getNumFragmentationRules() - 1]. |
| ConstFragmentationRuleIterator CDPL::Chem::FragmentGenerator::getFragmentationRulesBegin | ( | ) | const |
Returns a constant iterator pointing to the first registered fragmentation rule.
| ConstFragmentationRuleIterator CDPL::Chem::FragmentGenerator::getFragmentationRulesEnd | ( | ) | const |
Returns a constant iterator pointing one past the last registered fragmentation rule.
| FragmentationRuleIterator CDPL::Chem::FragmentGenerator::getFragmentationRulesBegin | ( | ) |
Returns a mutable iterator pointing to the first registered fragmentation rule.
| FragmentationRuleIterator CDPL::Chem::FragmentGenerator::getFragmentationRulesEnd | ( | ) |
Returns a mutable iterator pointing one past the last registered fragmentation rule.
| void CDPL::Chem::FragmentGenerator::removeFragmentationRule | ( | std::size_t | idx | ) |
Removes the fragmentation rule at index idx.
| idx | The zero-based rule index. |
| Base::IndexError | if the number of rules is zero or idx is not in the range [0, getNumFragmentationRules() - 1]. |
| std::size_t CDPL::Chem::FragmentGenerator::getNumFragmentationRules | ( | ) | const |
Returns the number of registered fragmentation rules.
| void CDPL::Chem::FragmentGenerator::clearFragmentationRules | ( | ) |
Removes all registered fragmentation rules.
| void CDPL::Chem::FragmentGenerator::addExcludePattern | ( | const MolecularGraph::SharedPointer & | match_ptn, |
| unsigned int | rule_id | ||
| ) |
Registers a rule-specific exclude pattern.
| match_ptn | The SMARTS match pattern. |
| rule_id | The rule ID this exclusion applies to. |
| void CDPL::Chem::FragmentGenerator::addExcludePattern | ( | const MolecularGraph::SharedPointer & | match_ptn | ) |
Registers a generic exclude pattern (applies to all fragmentation rules).
| match_ptn | The SMARTS match pattern. |
| void CDPL::Chem::FragmentGenerator::addExcludePattern | ( | const ExcludePattern & | excl_ptn | ) |
Appends a copy of the pre-built exclude pattern excl_ptn.
| excl_ptn | The exclude pattern to copy and register. |
| const ExcludePattern& CDPL::Chem::FragmentGenerator::getExcludePattern | ( | std::size_t | idx | ) | const |
Returns the exclude pattern at index idx.
| idx | The zero-based pattern index. |
const reference to the exclude pattern. | Base::IndexError | if the number of exclude patterns is zero or idx is not in the range [0, getNumExcludePatterns() - 1]. |
| ExcludePattern& CDPL::Chem::FragmentGenerator::getExcludePattern | ( | std::size_t | idx | ) |
Returns the exclude pattern at index idx.
| idx | The zero-based pattern index. |
| Base::IndexError | if the number of exclude patterns is zero or idx is not in the range [0, getNumExcludePatterns() - 1]. |
| ConstExcludePatternIterator CDPL::Chem::FragmentGenerator::getExcludePatternsBegin | ( | ) | const |
Returns a constant iterator pointing to the first registered exclude pattern.
| ConstExcludePatternIterator CDPL::Chem::FragmentGenerator::getExcludePatternsEnd | ( | ) | const |
Returns a constant iterator pointing one past the last registered exclude pattern.
| ExcludePatternIterator CDPL::Chem::FragmentGenerator::getExcludePatternsBegin | ( | ) |
Returns a mutable iterator pointing to the first registered exclude pattern.
| ExcludePatternIterator CDPL::Chem::FragmentGenerator::getExcludePatternsEnd | ( | ) |
Returns a mutable iterator pointing one past the last registered exclude pattern.
| void CDPL::Chem::FragmentGenerator::removeExcludePattern | ( | std::size_t | idx | ) |
Removes the exclude pattern at index idx.
| idx | The zero-based pattern index. |
| Base::IndexError | if the number of exclude patterns is zero or idx is not in the range [0, getNumExcludePatterns() - 1]. |
| std::size_t CDPL::Chem::FragmentGenerator::getNumExcludePatterns | ( | ) | const |
Returns the number of registered exclude patterns.
| void CDPL::Chem::FragmentGenerator::clearExcludePatterns | ( | ) |
Removes all registered exclude patterns.
| bool CDPL::Chem::FragmentGenerator::splitBondsIncluded | ( | ) | const |
Tells whether the split (cleaved) bonds are retained in the output fragments.
true if split bonds are retained, and false otherwise. | void CDPL::Chem::FragmentGenerator::includeSplitBonds | ( | bool | include | ) |
Specifies whether the split (cleaved) bonds shall be retained in the output fragments.
| include | If true, the cleaved bonds remain part of the adjacent output fragments. |
| const FragmentFilterFunction& CDPL::Chem::FragmentGenerator::getFragmentFilterFunction | ( | ) | const |
Returns the predicate used to filter the generated fragments.
const reference to the fragment-filter function. | void CDPL::Chem::FragmentGenerator::setFragmentFilterFunction | ( | const FragmentFilterFunction & | func | ) |
Sets the predicate used to filter the generated fragments (fragments for which the predicate returns false are discarded).
| func | The new fragment-filter function. |
| void CDPL::Chem::FragmentGenerator::generate | ( | const MolecularGraph & | molgraph, |
| FragmentList & | frag_list, | ||
| bool | append = false |
||
| ) |
Performs the fragmentation of molgraph and writes the resulting fragments to frag_list.
| molgraph | The molecular graph to fragment. |
| frag_list | The output fragment list. |
| append | If true, new fragments are appended to frag_list; otherwise the list is cleared first. |
| std::size_t CDPL::Chem::FragmentGenerator::getNumFragmentLinks | ( | ) | const |
Returns the number of fragment links produced by the most recent generate() call.
| const FragmentLink& CDPL::Chem::FragmentGenerator::getFragmentLink | ( | std::size_t | idx | ) | const |
Returns the fragment link at index idx.
| idx | The zero-based link index. |
const reference to the fragment link. | Base::IndexError | if the number of fragment links is zero or idx is not in the range [0, getNumFragmentLinks() - 1]. |
| ConstFragmentLinkIterator CDPL::Chem::FragmentGenerator::getFragmentLinksBegin | ( | ) | const |
Returns a constant iterator pointing to the first fragment link.
| ConstFragmentLinkIterator CDPL::Chem::FragmentGenerator::getFragmentLinksEnd | ( | ) | const |
Returns a constant iterator pointing one past the last fragment link.