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 molecule according to a given editing template. 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 used to iterate over the stored search/exclude pattern Chem::MolecularGraph objects. More...
 
typedef boost::transform_iterator< GetMolGraphFunc, PatternList::iterator > PatternIterator
 A mutable iterator used to iterate over the stored search/exclude pattern Chem::MolecularGraph objects. 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 substructure search pattern at index idx. More...
 
void removeSearchPattern (std::size_t idx)
 Removes the substructure search pattern at index idx. More...
 
void removeSearchPattern (const PatternIterator &it)
 Removes the substructure search pattern pointed to by it. More...
 
void clearSearchPatterns ()
 Clears the current set of substructure search patterns. More...
 
PatternIterator getSearchPatternsBegin ()
 Returns a mutable iterator pointing to the beginning of the stored search pattern Chem::MolecularGraph objects. More...
 
PatternIterator getSearchPatternsEnd ()
 Returns a mutable iterator pointing to the end of the stored search pattern Chem::MolecularGraph objects. More...
 
ConstPatternIterator getSearchPatternsBegin () const
 Returns a constant iterator pointing to the beginning of the stored search pattern const Chem::MolecularGraph objects. More...
 
ConstPatternIterator getSearchPatternsEnd () const
 Returns a constant iterator pointing to the end of the stored search pattern const Chem::MolecularGraph objects. 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 substructure exclude pattern at index idx. More...
 
void removeExcludePattern (std::size_t idx)
 Removes the substructure exclude pattern at index idx. More...
 
void removeExcludePattern (const PatternIterator &it)
 Removes the substructure 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 pattern Chem::MolecularGraph objects. More...
 
PatternIterator getExcludePatternsEnd ()
 Returns a mutable iterator pointing to the end of the stored exclude pattern Chem::MolecularGraph objects. More...
 
ConstPatternIterator getExcludePatternsBegin () const
 Returns a constant iterator pointing to the beginning of the stored exclude pattern const Chem::MolecularGraph objects. More...
 
ConstPatternIterator getExcludePatternsEnd () const
 Returns a constant iterator pointing to the end of the stored exclude pattern const Chem::MolecularGraph objects. 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 the molecule mol in place by applying the result pattern at every search pattern match that is not covered by an exclude pattern. More...
 
std::size_t edit (const MolecularGraph &molgraph, Molecule &res_mol)
 Copies the molecular graph molgraph into the molecule res_mol and then edits it by calling 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 molecule according to a given editing template.

Search patterns supply the substructures the editor will look for. The (single) result pattern defines what each match is rewritten to and 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 used to iterate over the stored search/exclude pattern Chem::MolecularGraph objects.

◆ PatternIterator

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

A mutable iterator used to iterate over the stored search/exclude pattern Chem::MolecularGraph objects.

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 other editor instance to copy.

◆ ~SubstructureEditor()

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

Destructor.

Destroys the SubstructureEditor instance and frees all allocated resources.

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
molgraphA smart pointer to the 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 substructure search pattern at index idx.

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

◆ removeSearchPattern() [1/2]

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

Removes the substructure search pattern at index idx.

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

◆ removeSearchPattern() [2/2]

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

Removes the substructure search pattern pointed to by it.

Parameters
itAn iterator pointing to the search pattern.
Exceptions
Base::RangeErrorif it is not in the range [getSearchPatternsBegin(), getSearchPatternsEnd()).

◆ clearSearchPatterns()

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

Clears the current set of substructure search patterns.

◆ getSearchPatternsBegin() [1/2]

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

Returns a mutable iterator pointing to the beginning of the stored search pattern Chem::MolecularGraph objects.

Returns
A mutable iterator pointing to the beginning of the stored search pattern Chem::MolecularGraph objects.

◆ getSearchPatternsEnd() [1/2]

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

Returns a mutable iterator pointing to the end of the stored search pattern Chem::MolecularGraph objects.

Returns
A mutable iterator pointing to the end of the stored search pattern Chem::MolecularGraph objects.

◆ getSearchPatternsBegin() [2/2]

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

Returns a constant iterator pointing to the beginning of the stored search pattern const Chem::MolecularGraph objects.

Returns
A constant iterator pointing to the beginning of the stored search pattern const Chem::MolecularGraph objects.

◆ getSearchPatternsEnd() [2/2]

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

Returns a constant iterator pointing to the end of the stored search pattern const Chem::MolecularGraph objects.

Returns
A constant iterator pointing to the end of the stored search pattern const Chem::MolecularGraph objects.

◆ addExcludePattern()

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

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

Parameters
molgraphA smart pointer to the 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 substructure exclude pattern at index idx.

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

◆ removeExcludePattern() [1/2]

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

Removes the substructure exclude pattern at index idx.

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

◆ removeExcludePattern() [2/2]

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

Removes the substructure exclude pattern pointed to by it.

Parameters
itAn iterator pointing to the exclude pattern.
Exceptions
Base::RangeErrorif it is not in the range [getExcludePatternsBegin(), getExcludePatternsEnd()).

◆ 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 pattern Chem::MolecularGraph objects.

Returns
A mutable iterator pointing to the beginning of the stored exclude pattern Chem::MolecularGraph objects.

◆ getExcludePatternsEnd() [1/2]

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

Returns a mutable iterator pointing to the end of the stored exclude pattern Chem::MolecularGraph objects.

Returns
A mutable iterator pointing to the end of the stored exclude pattern Chem::MolecularGraph objects.

◆ getExcludePatternsBegin() [2/2]

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

Returns a constant iterator pointing to the beginning of the stored exclude pattern const Chem::MolecularGraph objects.

Returns
A constant iterator pointing to the beginning of the stored exclude pattern const Chem::MolecularGraph objects.

◆ getExcludePatternsEnd() [2/2]

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

Returns a constant iterator pointing to the end of the stored exclude pattern const Chem::MolecularGraph objects.

Returns
A constant iterator pointing to the end of the stored exclude pattern const Chem::MolecularGraph objects.

◆ 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
patternA smart pointer to the molecular graph of the result pattern.

◆ getResultPattern()

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

Returns the currently set result pattern.

Returns
A smart pointer to the molecular graph of 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 the molecule mol in place by applying the result pattern at every search pattern match that is not covered by an exclude pattern.

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 the molecular graph molgraph into the molecule res_mol and then edits it by calling 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 other editor instance to copy.
Returns
A reference to itself.

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