Enumerates all maximal common connected substructures shared between a query and a target molecular graph.
More...
Enumerates all maximal common connected substructures shared between a query and a target molecular graph.
Unlike Chem.MaxCommonAtomSubstructureSearch and Chem.MaxCommonBondSubstructureSearch, the matches reported here are required to be connected — i.e. each mapping covers a single connected subgraph of both the query and the target. Successive calls to setQuery() and findAllMappings() or findMaxMappings() produce all possible common substructure atom/bond mapping solutions (subject to an atom count lower bound set by setMinSubstructureSize()). If just the information whether or not a common substructure (fulfilling the size lower bound) exists is of interest then the more efficient method mappingExists() can be used. Found common substructures 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. User-defined per-atom, per-bond and per-molecular graph Chem.MatchExpression implementation instance accessor functions can be installed to extend equivalence tests beyond pure topology. The default functions retrieve the expressions saved as corresponding atom, bond and molecular graph property values (see Chem.AtomProperty.MATCH_EXPRESSION, Chem.BondProperty.MATCH_EXPRESSION and Chem.MolecularGraphProperty.MATCH_EXPRESSION). Result accumulation can be bounded by setMaxNumMappings() and uniqueMappingsOnly().
- See also
- [MCSA]
◆ __init__()
| None CDPL.Chem.CommonConnectedSubstructureSearch.__init__ |
( |
MolecularGraph |
query | ) |
|
Constructs and initializes the CommonConnectedSubstructureSearch instance for the query molecular graph query.
- Parameters
-
| query | A molecular graph that represents the query structure. |
◆ getObjectID()
| int CDPL.Chem.CommonConnectedSubstructureSearch.getObjectID |
( |
| ) |
|
Returns the numeric identifier (ID) of the wrapped C++ class instance.
Different Python CommonConnectedSubstructureSearch 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 CommonConnectedSubstructureSearch 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.
◆ setAtomMatchExpressionFunction()
Installs a function that resolves the Chem.MatchExpression implementation instance for a query atom.
- Parameters
-
| func | The accessor function to use. |
◆ setBondMatchExpressionFunction()
Installs a function that resolves the Chem.MatchExpression implementation instance for a query bond.
- Parameters
-
| func | The accessor function to use. |
◆ setMolecularGraphMatchExpressionFunction()
Installs a function that resolves the Chem.MatchExpression implementation instance for the query molecular graph.
- Parameters
-
| func | The accessor function to use. |
◆ mappingExists()
| bool CDPL.Chem.CommonConnectedSubstructureSearch.mappingExists |
( |
MolecularGraph |
target | ) |
|
Searches for a common connected substructure between the query and the target molecular graph target.
The method does not store any atom/bond mappings between query and target molecular graphs — it just tells if a valid common substructure mapping solution involving at least getMinSubstructureSize() atoms could be found. If you need access to the atom/bond mappings, use findAllMappings() or findMaxMappings() instead.
- Parameters
-
| target | The molecular graph that has to be searched for a connected substructure in common with the query. |
- Returns
True if a common substructure of at least the minimum accepted size could be found, and False otherwise.
- Note
- Any atom/bond mappings that were recorded in a previous call to findAllMappings() or findMaxMappings() will be discarded.
◆ findAllMappings()
| bool CDPL.Chem.CommonConnectedSubstructureSearch.findAllMappings |
( |
MolecularGraph |
target | ) |
|
Searches for all possible atom/bond mappings of connected query subgraphs to substructures of the target molecular graph target.
The method will store all found common substructure mapping solutions involving at least getMinSubstructureSize() atoms 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
-
| target | The target molecular graph that has to be searched for all connected substructures in common with the query. |
- Returns
True if common substructures of at least the minimum accepted size were found, and False otherwise.
- Note
- Any atom/bond mappings that were recorded in a previous call to findAllMappings() or findMaxMappings() will be discarded.
◆ findMaxMappings()
| bool CDPL.Chem.CommonConnectedSubstructureSearch.findMaxMappings |
( |
MolecularGraph |
target | ) |
|
Searches for all maximum-sized atom/bond mappings of connected query subgraphs to substructures of the target molecular graph target.
The method will store all maximum-sized common substructure mapping solutions involving at least getMinSubstructureSize() atoms 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
-
| target | The target molecular graph that has to be searched for all maximum-sized connected substructures in common with the query. |
- Returns
True if common substructures of at least the minimum accepted size were found, and False otherwise.
- Note
- Any atom/bond mappings that were recorded in a previous call to findAllMappings() or findMaxMappings() will be discarded.
◆ getNumMappings()
| int CDPL.Chem.CommonConnectedSubstructureSearch.getNumMappings |
( |
| ) |
|
Returns the number of atom/bond mappings that were recorded in the last search for common substructures.
- Returns
- The number of atom/bond mappings that were recorded in the last search for common substructures.
- See also
- findAllMappings(), findMaxMappings()
◆ getMapping()
| AtomBondMapping CDPL.Chem.CommonConnectedSubstructureSearch.getMapping |
( |
int |
idx | ) |
|
Returns a reference to the stored atom/bond mapping object at index idx.
- Parameters
-
| idx | The zero-based index of the atom/bond mapping object to return. |
- Returns
- A reference to the Chem.AtomBondMapping object at index idx.
- Exceptions
-
◆ uniqueMappingsOnly() [1/2]
| None CDPL.Chem.CommonConnectedSubstructureSearch.uniqueMappingsOnly |
( |
bool |
unique | ) |
|
Allows to specify whether or not to store only unique atom/bond mappings.
The mapping of a query subgraph to a substructure of the target molecular graph 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
-
| unique | If 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.CommonConnectedSubstructureSearch.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.CommonConnectedSubstructureSearch.getMaxNumMappings |
( |
| ) |
|
◆ setMaxNumMappings()
| None CDPL.Chem.CommonConnectedSubstructureSearch.setMaxNumMappings |
( |
int |
max_num_mappings | ) |
|
Allows to specify a limit on the number of stored atom/bond mappings.
In a call to findAllMappings() or findMaxMappings() the common 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_mappings | The maximum number of atom/bond mappings to store. |
- Note
- By default, no limit is imposed on the number of stored mappings.
◆ getMinSubstructureSize()
| int CDPL.Chem.CommonConnectedSubstructureSearch.getMinSubstructureSize |
( |
| ) |
|
Returns the minimum accepted common substructure size.
- Returns
- The minimum accepted common substructure size in number of atoms.
- See also
- setMinSubstructureSize()
◆ setMinSubstructureSize()
| None CDPL.Chem.CommonConnectedSubstructureSearch.setMinSubstructureSize |
( |
int |
min_size | ) |
|
Allows to specify the minimum accepted common substructure size.
Any found common substructures which cover less than min_size atoms are not accepted as a valid solution and will be discarded.
- Parameters
-
| min_size | The minimum accepted common substructure size in number of atoms. |
- Note
- By default, the minimum common substructure size is set to zero.
◆ setQuery()
| None CDPL.Chem.CommonConnectedSubstructureSearch.setQuery |
( |
MolecularGraph |
query | ) |
|
Sets query as the new query molecular graph.
- Parameters
-
| query | A molecular graph that represents the new query. |