Chemical Data Processing Library C++ API - Version 1.4.0
Classes | Public Types | Public Member Functions | List of all members
CDPL::Chem::SubstructureEditor Class Reference

Pattern-driven editor that rewrites matched substructures of a Chem::Molecule using a result template, with optional exclude patterns guarding sites that must not be touched. More...

#include <SubstructureEditor.hpp>

Public Types

typedef std::shared_ptr< SubstructureEditorSharedPointer
 A reference-counted smart pointer [SHPTR] for dynamically allocated SubstructureEditor instances. More...
 
typedef boost::transform_iterator< GetMolGraphFunc, PatternList::const_iterator > ConstPatternIterator
 A constant iterator over the molecular graphs of the stored search/exclude patterns. More...
 
typedef boost::transform_iterator< GetMolGraphFunc, PatternList::iterator > PatternIterator
 A mutable iterator over the molecular graphs of the stored search/exclude patterns. More...
 

Public Member Functions

 SubstructureEditor ()
 Constructs the SubstructureEditor instance. More...
 
 SubstructureEditor (const SubstructureEditor &editor)
 Constructs a copy of the SubstructureEditor instance editor. More...
 
 ~SubstructureEditor ()
 Destructor. More...
 
void addSearchPattern (const MolecularGraph::SharedPointer &molgraph)
 Appends a new substructure search pattern to the current set of patterns. More...
 
std::size_t getNumSearchPatterns () const
 Returns the number of stored substructure search patterns. More...
 
const MolecularGraph::SharedPointergetSearchPattern (std::size_t idx) const
 Returns the molecular graph of the search pattern at index idx. More...
 
void removeSearchPattern (std::size_t idx)
 Removes the search pattern at index idx. More...
 
void removeSearchPattern (const PatternIterator &it)
 Removes the search pattern pointed to by it. More...
 
void clearSearchPatterns ()
 Clears the current set of substructuresearch patterns. More...
 
PatternIterator getSearchPatternsBegin ()
 Returns a mutable iterator pointing to the beginning of the stored search patterns. More...
 
PatternIterator getSearchPatternsEnd ()
 Returns a mutable iterator pointing to the end of the stored search patterns. More...
 
ConstPatternIterator getSearchPatternsBegin () const
 Returns a constant iterator pointing to the beginning of the stored search patterns. More...
 
ConstPatternIterator getSearchPatternsEnd () const
 Returns a constant iterator pointing to the end of the stored search patterns. More...
 
void addExcludePattern (const MolecularGraph::SharedPointer &molgraph)
 Appends a new substructure exclude pattern to the current set of patterns. More...
 
std::size_t getNumExcludePatterns () const
 Returns the number of stored substructure-exclude patterns. More...
 
const MolecularGraph::SharedPointergetExcludePattern (std::size_t idx) const
 Returns the molecular graph of the exclude pattern at index idx. More...
 
void removeExcludePattern (std::size_t idx)
 Removes the exclude pattern at index idx. More...
 
void removeExcludePattern (const PatternIterator &it)
 Removes the exclude pattern pointed to by it. More...
 
void clearExcludePatterns ()
 Clears the current set of substructure exclude patterns. More...
 
PatternIterator getExcludePatternsBegin ()
 Returns a mutable iterator pointing to the beginning of the stored exclude patterns. More...
 
PatternIterator getExcludePatternsEnd ()
 Returns a mutable iterator pointing to the end of the stored exclude patterns. More...
 
ConstPatternIterator getExcludePatternsBegin () const
 Returns a constant iterator pointing to the beginning of the stored exclude patterns. More...
 
ConstPatternIterator getExcludePatternsEnd () const
 Returns a constant iterator pointing to the end of the stored exclude patterns. More...
 
void setResultPattern (const MolecularGraph::SharedPointer &pattern)
 Sets the result pattern that defines how each matched search-pattern instance will be rewritten. More...
 
const MolecularGraph::SharedPointergetResultPattern () const
 Returns the currently set result pattern. More...
 
void clear ()
 Clears the current editing result pattern and the sets of substructure search and exclude patterns. More...
 
std::size_t edit (Molecule &mol)
 Edits mol in place by applying the result pattern at every search-pattern match that is not covered by an exclude pattern; repeats until no further changes occur. More...
 
std::size_t edit (const MolecularGraph &molgraph, Molecule &res_mol)
 Copies molgraph into res_mol and then edits res_mol via edit(Molecule&). More...
 
SubstructureEditoroperator= (const SubstructureEditor &gen)
 Copies the state of the SubstructureEditor instance gen. More...
 

Detailed Description

Pattern-driven editor that rewrites matched substructures of a Chem::Molecule using a result template, with optional exclude patterns guarding sites that must not be touched.

Search patterns supply the substructures the editor will look for; the (single) result pattern defines what each match is rewritten to; exclude patterns mark matches that must be skipped (a search match is discarded when its atoms/bonds form a subset of any exclude match). The editor iterates until no further matches can be transformed and returns the number of applied edits.

Since
1.3.0

Member Typedef Documentation

◆ SharedPointer

A reference-counted smart pointer [SHPTR] for dynamically allocated SubstructureEditor instances.

◆ ConstPatternIterator

typedef boost::transform_iterator<GetMolGraphFunc, PatternList::const_iterator> CDPL::Chem::SubstructureEditor::ConstPatternIterator

A constant iterator over the molecular graphs of the stored search/exclude patterns.

◆ PatternIterator

typedef boost::transform_iterator<GetMolGraphFunc, PatternList::iterator> CDPL::Chem::SubstructureEditor::PatternIterator

A mutable iterator over the molecular graphs of the stored search/exclude patterns.

Constructor & Destructor Documentation

◆ SubstructureEditor() [1/2]

CDPL::Chem::SubstructureEditor::SubstructureEditor ( )

Constructs the SubstructureEditor instance.

◆ SubstructureEditor() [2/2]

CDPL::Chem::SubstructureEditor::SubstructureEditor ( const SubstructureEditor editor)

Constructs a copy of the SubstructureEditor instance editor.

Parameters
editorThe SubstructureEditor instance to copy.

◆ ~SubstructureEditor()

CDPL::Chem::SubstructureEditor::~SubstructureEditor ( )

Destructor.

Member Function Documentation

◆ addSearchPattern()

void CDPL::Chem::SubstructureEditor::addSearchPattern ( const MolecularGraph::SharedPointer molgraph)

Appends a new substructure search pattern to the current set of patterns.

Parameters
molgraphThe molecular graph of the substructure search pattern to add.

◆ getNumSearchPatterns()

std::size_t CDPL::Chem::SubstructureEditor::getNumSearchPatterns ( ) const

Returns the number of stored substructure search patterns.

Returns
The number of stored search patterns.

◆ getSearchPattern()

const MolecularGraph::SharedPointer& CDPL::Chem::SubstructureEditor::getSearchPattern ( std::size_t  idx) const

Returns the molecular graph of the search pattern at index idx.

Parameters
idxThe zero-based search-pattern index.
Returns
The molecular graph of the search pattern at index idx.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumSearchPatterns() - 1].

◆ removeSearchPattern() [1/2]

void CDPL::Chem::SubstructureEditor::removeSearchPattern ( std::size_t  idx)

Removes the search pattern at index idx.

Parameters
idxThe zero-based search-pattern index to remove.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumSearchPatterns() - 1].

◆ removeSearchPattern() [2/2]

void CDPL::Chem::SubstructureEditor::removeSearchPattern ( const PatternIterator it)

Removes the search pattern pointed to by it.

Parameters
itAn iterator pointing to the search pattern to remove.
Exceptions
Base::RangeErrorif it does not point into the current search-pattern range.

◆ clearSearchPatterns()

void CDPL::Chem::SubstructureEditor::clearSearchPatterns ( )

Clears the current set of substructuresearch patterns.

◆ getSearchPatternsBegin() [1/2]

PatternIterator CDPL::Chem::SubstructureEditor::getSearchPatternsBegin ( )

Returns a mutable iterator pointing to the beginning of the stored search patterns.

Returns
A mutable iterator pointing to the beginning of the stored search patterns.

◆ getSearchPatternsEnd() [1/2]

PatternIterator CDPL::Chem::SubstructureEditor::getSearchPatternsEnd ( )

Returns a mutable iterator pointing to the end of the stored search patterns.

Returns
A mutable iterator pointing to the end of the stored search patterns.

◆ getSearchPatternsBegin() [2/2]

ConstPatternIterator CDPL::Chem::SubstructureEditor::getSearchPatternsBegin ( ) const

Returns a constant iterator pointing to the beginning of the stored search patterns.

Returns
A constant iterator pointing to the beginning of the stored search patterns.

◆ getSearchPatternsEnd() [2/2]

ConstPatternIterator CDPL::Chem::SubstructureEditor::getSearchPatternsEnd ( ) const

Returns a constant iterator pointing to the end of the stored search patterns.

Returns
A constant iterator pointing to the end of the stored search patterns.

◆ addExcludePattern()

void CDPL::Chem::SubstructureEditor::addExcludePattern ( const MolecularGraph::SharedPointer molgraph)

Appends a new substructure exclude pattern to the current set of patterns.

Parameters
molgraphThe molecular graph of the substructure exclude pattern to add.

◆ getNumExcludePatterns()

std::size_t CDPL::Chem::SubstructureEditor::getNumExcludePatterns ( ) const

Returns the number of stored substructure-exclude patterns.

Returns
The number of stored exclude patterns.

◆ getExcludePattern()

const MolecularGraph::SharedPointer& CDPL::Chem::SubstructureEditor::getExcludePattern ( std::size_t  idx) const

Returns the molecular graph of the exclude pattern at index idx.

Parameters
idxThe zero-based exclude-pattern index.
Returns
The molecular graph of the exclude pattern at index idx.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumExcludePatterns() - 1].

◆ removeExcludePattern() [1/2]

void CDPL::Chem::SubstructureEditor::removeExcludePattern ( std::size_t  idx)

Removes the exclude pattern at index idx.

Parameters
idxThe zero-based exclude-pattern index to remove.
Exceptions
Base::IndexErrorif idx is not in the range [0, getNumExcludePatterns() - 1].

◆ removeExcludePattern() [2/2]

void CDPL::Chem::SubstructureEditor::removeExcludePattern ( const PatternIterator it)

Removes the exclude pattern pointed to by it.

Parameters
itAn iterator pointing to the exclude pattern to remove.
Exceptions
Base::RangeErrorif it does not point into the current exclude-pattern range.

◆ clearExcludePatterns()

void CDPL::Chem::SubstructureEditor::clearExcludePatterns ( )

Clears the current set of substructure exclude patterns.

◆ getExcludePatternsBegin() [1/2]

PatternIterator CDPL::Chem::SubstructureEditor::getExcludePatternsBegin ( )

Returns a mutable iterator pointing to the beginning of the stored exclude patterns.

Returns
A mutable iterator pointing to the beginning of the stored exclude patterns.

◆ getExcludePatternsEnd() [1/2]

PatternIterator CDPL::Chem::SubstructureEditor::getExcludePatternsEnd ( )

Returns a mutable iterator pointing to the end of the stored exclude patterns.

Returns
A mutable iterator pointing to the end of the stored exclude patterns.

◆ getExcludePatternsBegin() [2/2]

ConstPatternIterator CDPL::Chem::SubstructureEditor::getExcludePatternsBegin ( ) const

Returns a constant iterator pointing to the beginning of the stored exclude patterns.

Returns
A constant iterator pointing to the beginning of the stored exclude patterns.

◆ getExcludePatternsEnd() [2/2]

ConstPatternIterator CDPL::Chem::SubstructureEditor::getExcludePatternsEnd ( ) const

Returns a constant iterator pointing to the end of the stored exclude patterns.

Returns
A constant iterator pointing to the end of the stored exclude patterns.

◆ setResultPattern()

void CDPL::Chem::SubstructureEditor::setResultPattern ( const MolecularGraph::SharedPointer pattern)

Sets the result pattern that defines how each matched search-pattern instance will be rewritten.

Parameters
patternThe molecular graph of the result pattern.

◆ getResultPattern()

const MolecularGraph::SharedPointer& CDPL::Chem::SubstructureEditor::getResultPattern ( ) const

Returns the currently set result pattern.

Returns
The currently set result pattern, or a null pointer if none has been set.

◆ clear()

void CDPL::Chem::SubstructureEditor::clear ( )

Clears the current editing result pattern and the sets of substructure search and exclude patterns.

◆ edit() [1/2]

std::size_t CDPL::Chem::SubstructureEditor::edit ( Molecule mol)

Edits mol in place by applying the result pattern at every search-pattern match that is not covered by an exclude pattern; repeats until no further changes occur.

Parameters
molThe molecule to edit.
Returns
The number of applied transformations.

◆ edit() [2/2]

std::size_t CDPL::Chem::SubstructureEditor::edit ( const MolecularGraph molgraph,
Molecule res_mol 
)

Copies molgraph into res_mol and then edits res_mol via edit(Molecule&).

Parameters
molgraphThe source molecular graph.
res_molThe molecule receiving the edited result.
Returns
The number of applied transformations.

◆ operator=()

SubstructureEditor& CDPL::Chem::SubstructureEditor::operator= ( const SubstructureEditor gen)

Copies the state of the SubstructureEditor instance gen.

Parameters
genThe SubstructureEditor instance to copy.
Returns
A reference to itself.

The documentation for this class was generated from the following file: