Chemical Data Processing Library Python API - Version 1.4.0
Public Member Functions | Properties | List of all members
CDPL.Chem.ReactionSubstructureSearch Class Reference

Searches for substructures of the components of a target reaction that match a given query reaction pattern. More...

+ Inheritance diagram for CDPL.Chem.ReactionSubstructureSearch:

Public Member Functions

None __init__ ()
 Constructs and initializes the ReactionSubstructureSearch instance.
 
None __init__ (Reaction query)
 Constructs and initializes the ReactionSubstructureSearch instance for the specified query reaction pattern query. More...
 
int getObjectID ()
 Returns the numeric identifier (ID) of the wrapped C++ class instance. More...
 
bool mappingExists (Reaction target)
 Tells whether the query reaction pattern matches the target reaction target. More...
 
bool findMappings (Reaction target)
 Searches for all possible atom/bond mappings between the query reaction pattern and the target reaction target. More...
 
int getNumMappings ()
 Returns the number of atom/bond mappings that were recorded in the last call to findMappings(). More...
 
AtomBondMapping getMapping (int idx)
 Returns a reference to the stored atom/bond mapping object at index idx. More...
 
None uniqueMappingsOnly (bool unique)
 Allows to specify whether or not to store only unique atom/bond mappings. More...
 
bool uniqueMappingsOnly ()
 Tells whether duplicate atom/bond mappings are discarded. More...
 
int getMaxNumMappings ()
 Returns the specified limit on the number of stored atom/bond mappings. More...
 
None setMaxNumMappings (int max_num_mappings)
 Allows to specify a limit on the number of stored atom/bond mappings. More...
 
int getEnabledReactionRoles ()
 Tells which reaction component roles are considered in the search for matching reaction substructures. More...
 
None setEnabledReactionRoles (int roles)
 Allows the reaction role specific exclusion of query and target components from the search for matching reaction substructures. More...
 
None setQuery (Reaction query)
 Sets query as the new query reaction pattern. More...
 
AtomBondMapping __getitem__ (int idx)
 
int __len__ ()
 
bool __nonzero__ (Reaction self)
 
bool __bool__ (Reaction self)
 

Properties

 objectID = property(getObjectID)
 
 enabledReactionRoles = property(getEnabledReactionRoles, setEnabledReactionRoles)
 
 numMappings = property(getNumMappings)
 
 uniqueMappings = property(uniqueMappingsOnly, uniqueMappingsOnly)
 
 maxNumMappings = property(getMaxNumMappings, setMaxNumMappings)
 

Detailed Description

Searches for substructures of the components of a target reaction that match a given query reaction pattern.

Use setQuery() to fix the query reaction pattern and mappingExists() or findMappings() to evaluate it against a specified target Chem.Reaction instance. Found mappings are recorded as Chem.AtomBondMapping objects that can be accessed via index through the method getMapping() or iteration using the iterator pair returned by the methods begin() and end(), respectively. Component visibility based on reaction role is controlled with setEnabledReactionRoles() (see namespace Chem.ReactionRole). The search algorithm considers atom-, bond-, and reaction-level Chem.MatchExpression implementation instances attached to the query reaction and its components as corresponding property values (see Chem.SubstructureSearch and Chem.ReactionProperty.MATCH_EXPRESSION). The result set can be limited by the methods setMaxNumMappings() and uniqueMappingsOnly().

Constructor & Destructor Documentation

◆ __init__()

None CDPL.Chem.ReactionSubstructureSearch.__init__ ( Reaction  query)

Constructs and initializes the ReactionSubstructureSearch instance for the specified query reaction pattern query.

Parameters
queryThe query reaction.

Member Function Documentation

◆ getObjectID()

int CDPL.Chem.ReactionSubstructureSearch.getObjectID ( )

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

Different Python ReactionSubstructureSearch 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 ReactionSubstructureSearch 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.

◆ mappingExists()

bool CDPL.Chem.ReactionSubstructureSearch.mappingExists ( Reaction  target)

Tells whether the query reaction pattern matches the target reaction target.

The method does not store any atom/bond mappings between the query and target reaction — it just tells if a complete mapping of the query is possible. If you need access to the atom/bond mappings, use findMappings() instead.

Parameters
targetThe target reaction that has to be searched for a match of the query.
Returns
True if the query matches the target reaction, and False otherwise.
Note
Any atom/bond mappings that were recorded in a previous call to findMappings() will be discarded.

◆ findMappings()

bool CDPL.Chem.ReactionSubstructureSearch.findMappings ( Reaction  target)

Searches for all possible atom/bond mappings between the query reaction pattern and the target reaction target.

The method will store all found atom/bond mapping solutions up to the maximum number of recorded mappings specified by setMaxNumMappings(). If only unique mappings have to be stored (see uniqueMappingsOnly(bool unique)), any duplicates of previously found mappings will be discarded.

Parameters
targetThe target reaction that has to be searched for matches of the query.
Returns
True if the query can be mapped to the specified target reaction, and False otherwise.
Note
Any atom/bond mappings that were recorded in a previous call to findMappings() will be discarded.

◆ getNumMappings()

int CDPL.Chem.ReactionSubstructureSearch.getNumMappings ( )

Returns the number of atom/bond mappings that were recorded in the last call to findMappings().

Returns
The number of atom/bond mappings that were recorded in the last call to findMappings().

◆ getMapping()

AtomBondMapping CDPL.Chem.ReactionSubstructureSearch.getMapping ( int  idx)

Returns a reference to the stored atom/bond mapping object at index idx.

Parameters
idxThe zero-based index of the atom/bond mapping object to return.
Returns
A reference to the Chem.AtomBondMapping object at index idx.
Exceptions
Base.IndexErrorif idx is not in the range [0, getNumMappings()).

◆ uniqueMappingsOnly() [1/2]

None CDPL.Chem.ReactionSubstructureSearch.uniqueMappingsOnly ( bool  unique)

Allows to specify whether or not to store only unique atom/bond mappings.

A mapping of the query to the target reaction is considered to be unique if it differs from all previously found mappings by at least one atom or bond. If the unique argument is True and a newly discovered mapping covers the same atoms and bonds of the target (including all permutations) as a mapping that was found earlier in the search process, it is considered as a duplicate and will be discarded.

Parameters
uniqueIf True, only unique mappings will be stored, and all found mappings otherwise.
Note
By default, duplicate mappings are not discarded.

◆ uniqueMappingsOnly() [2/2]

bool CDPL.Chem.ReactionSubstructureSearch.uniqueMappingsOnly ( )

Tells whether duplicate atom/bond mappings are discarded.

Returns
True if duplicate mappings are discarded, and False otherwise.
See also
uniqueMappingsOnly(bool unique)

◆ getMaxNumMappings()

int CDPL.Chem.ReactionSubstructureSearch.getMaxNumMappings ( )

Returns the specified limit on the number of stored atom/bond mappings.

Returns
The specified maximum number of stored atom/bond mappings.
See also
setMaxNumMappings(), findMappings()

◆ setMaxNumMappings()

None CDPL.Chem.ReactionSubstructureSearch.setMaxNumMappings ( int  max_num_mappings)

Allows to specify a limit on the number of stored atom/bond mappings.

In a call to findMappings() the reaction substructure search will terminate as soon as the specified maximum number of stored atom/bond mappings has been reached. A previously set limit on the number of mappings can be disabled by providing zero for the value of max_num_mappings.

Parameters
max_num_mappingsThe maximum number of atom/bond mappings to store.
Note
By default, no limit is imposed on the number of stored mappings.

◆ getEnabledReactionRoles()

int CDPL.Chem.ReactionSubstructureSearch.getEnabledReactionRoles ( )

Tells which reaction component roles are considered in the search for matching reaction substructures.

Returns
A bitmask specifying the considered reaction component roles.
See also
setEnabledReactionRoles(), Chem.ReactionRole

◆ setEnabledReactionRoles()

None CDPL.Chem.ReactionSubstructureSearch.setEnabledReactionRoles ( int  roles)

Allows the reaction role specific exclusion of query and target components from the search for matching reaction substructures.

The roles argument is a bitwise-OR combination of the flags defined in namespace Chem.ReactionRole. When the flag for a particular reaction role is missing in the provided bitmask then all reaction components with this role assignment (both in the query and target reaction) will be simply ignored during the reaction substructure search. This has the same effect as 'removing' the affected components from the query and target reaction prior to starting the search and adding them again afterwards.

Parameters
rolesA bitmask specifying the non-excluded reaction component roles.
Note
By default, all types of reaction components are considered.

◆ setQuery()

None CDPL.Chem.ReactionSubstructureSearch.setQuery ( Reaction  query)

Sets query as the new query reaction pattern.

Parameters
queryA reaction that represents the new query.