Chemical Data Processing Library Python API - Version 1.4.0
Public Member Functions | Properties | 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...

+ Inheritance diagram for CDPL.Chem.SubstructureEditor:

Public Member Functions

None __init__ ()
 Constructs the SubstructureEditor instance.
 
None __init__ (SubstructureEditor editor)
 Constructs a copy of the SubstructureEditor instance editor. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
SubstructureEditor assign (SubstructureEditor editor)
 Replaces the current state of self with a copy of the state of the SubstructureEditor instance editor. More...
 
None addSearchPattern (MolecularGraph molgraph)
 Appends a new substructure search pattern to the current set of patterns. More...
 
int getNumSearchPatterns ()
 Returns the number of stored substructure search patterns. More...
 
MolecularGraph getSearchPattern (int idx)
 Returns the molecular graph of the search pattern at index idx. More...
 
None removeSearchPattern (int idx)
 Removes the search pattern at index idx. More...
 
None clearSearchPatterns ()
 Clears the current set of substructuresearch patterns.
 
None addExcludePattern (MolecularGraph molgraph)
 Appends a new substructure exclude pattern to the current set of patterns. More...
 
int getNumExcludePatterns ()
 Returns the number of stored substructure-exclude patterns. More...
 
MolecularGraph getExcludePattern (int idx)
 Returns the molecular graph of the exclude pattern at index idx. More...
 
None removeExcludePattern (int idx)
 Removes the exclude pattern at index idx. More...
 
None clearExcludePatterns ()
 Clears the current set of substructure exclude patterns.
 
None setResultPattern (MolecularGraph molgraph)
 
MolecularGraph getResultPattern ()
 Returns the currently set result pattern. More...
 
None clear ()
 Clears the current editing result pattern and the sets of substructure search and exclude patterns.
 
int 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...
 
int edit (MolecularGraph molgraph, Molecule res_mol)
 Copies molgraph into res_mol and then edits res_mol via edit(Molecule&). More...
 

Properties

 objectID = property(getObjectID)
 
 numSearchPatterns = property(getNumSearchPatterns)
 
 numExcludePatterns = property(getNumExcludePatterns)
 
 resultPattern = property(getResultPattern, setResultPattern)
 

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

Constructor & Destructor Documentation

◆ __init__()

None CDPL.Chem.SubstructureEditor.__init__ ( SubstructureEditor  editor)

Constructs a copy of the SubstructureEditor instance editor.

Parameters
editorThe SubstructureEditor instance to copy.

Member Function Documentation

◆ getObjectID()

int CDPL.Chem.SubstructureEditor.getObjectID ( )

Returns the numeric identifier (ID) of the wrapped C++ class instance.

Different Python SubstructureEditor 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 SubstructureEditor 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().

Returns
The numeric ID of the internally referenced C++ class instance.

◆ assign()

SubstructureEditor CDPL.Chem.SubstructureEditor.assign ( SubstructureEditor  editor)

Replaces the current state of self with a copy of the state of the SubstructureEditor instance editor.

Parameters
editorThe SubstructureEditor instance to copy.
Returns
self

◆ addSearchPattern()

None CDPL.Chem.SubstructureEditor.addSearchPattern ( MolecularGraph  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()

int CDPL.Chem.SubstructureEditor.getNumSearchPatterns ( )

Returns the number of stored substructure search patterns.

Returns
The number of stored search patterns.

◆ getSearchPattern()

MolecularGraph CDPL.Chem.SubstructureEditor.getSearchPattern ( int  idx)

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()

None CDPL.Chem.SubstructureEditor.removeSearchPattern ( int  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].

◆ addExcludePattern()

None CDPL.Chem.SubstructureEditor.addExcludePattern ( MolecularGraph  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()

int CDPL.Chem.SubstructureEditor.getNumExcludePatterns ( )

Returns the number of stored substructure-exclude patterns.

Returns
The number of stored exclude patterns.

◆ getExcludePattern()

MolecularGraph CDPL.Chem.SubstructureEditor.getExcludePattern ( int  idx)

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()

None CDPL.Chem.SubstructureEditor.removeExcludePattern ( int  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].

◆ setResultPattern()

None CDPL.Chem.SubstructureEditor.setResultPattern ( MolecularGraph  molgraph)
Parameters
molgraph

◆ getResultPattern()

MolecularGraph CDPL.Chem.SubstructureEditor.getResultPattern ( )

Returns the currently set result pattern.

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

◆ edit() [1/2]

int 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]

int CDPL.Chem.SubstructureEditor.edit ( 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.