![]() |
Chemical Data Processing Library C++ API - Version 1.4.0
|
Searches for the maximum common atom substructures between a query and a target molecular graph. More...
#include <MaxCommonAtomSubstructureSearch.hpp>
Public Types | |
| typedef std::shared_ptr< MaxCommonAtomSubstructureSearch > | SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated MaxCommonAtomSubstructureSearch instances. More... | |
| typedef boost::indirect_iterator< ABMappingList::iterator, AtomBondMapping > | MappingIterator |
| A mutable random access iterator used to iterate over the stored Chem::AtomBondMapping objects. More... | |
| typedef boost::indirect_iterator< ABMappingList::const_iterator, const AtomBondMapping > | ConstMappingIterator |
A constant random access iterator used to iterate over the stored const Chem::AtomBondMapping objects. More... | |
Public Member Functions | |
| MaxCommonAtomSubstructureSearch () | |
Constructs and initializes the MaxCommonAtomSubstructureSearch instance. More... | |
| MaxCommonAtomSubstructureSearch (const MolecularGraph &query) | |
Constructs and initializes the MaxCommonAtomSubstructureSearch instance for the query molecular graph query. More... | |
| MaxCommonAtomSubstructureSearch (const MaxCommonAtomSubstructureSearch &)=delete | |
| ~MaxCommonAtomSubstructureSearch () | |
| Destructor. More... | |
| MaxCommonAtomSubstructureSearch & | operator= (const MaxCommonAtomSubstructureSearch &)=delete |
| void | setQuery (const MolecularGraph &query) |
| Sets query as the new query molecular graph. More... | |
| bool | mappingExists (const MolecularGraph &target) |
| Searches for a common substructure between the query and the target molecular graph target. More... | |
| bool | findAllMappings (const MolecularGraph &target) |
| Searches for all atom/bond mappings of query subgraphs to substructures of the target molecular graph target with a maximum atom count. More... | |
| bool | findMaxBondMappings (const MolecularGraph &target) |
| Searches for all atom/bond mappings of query subgraphs to substructures of the target molecular graph target with a maximum atom and bond count. More... | |
| std::size_t | getNumMappings () const |
| Returns the number of atom/bond mappings that were recorded in the last search for common substructures. More... | |
| AtomBondMapping & | getMapping (std::size_t idx) |
Returns a non-const reference to the stored atom/bond mapping object at index idx. More... | |
| const AtomBondMapping & | getMapping (std::size_t idx) const |
Returns a const reference to the stored atom/bond mapping object at index idx. More... | |
| MappingIterator | getMappingsBegin () |
| Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping objects. More... | |
| ConstMappingIterator | getMappingsBegin () const |
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objects. More... | |
| MappingIterator | getMappingsEnd () |
| Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping objects. More... | |
| ConstMappingIterator | getMappingsEnd () const |
Returns a constant iterator pointing to the end of the stored const Chem::AtomBondMapping objects. More... | |
| MappingIterator | begin () |
| Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping objects. More... | |
| ConstMappingIterator | begin () const |
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objects. More... | |
| MappingIterator | end () |
| Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping objects. More... | |
| ConstMappingIterator | end () const |
Returns a constant iterator pointing to the end of the stored const Chem::AtomBondMapping objects. More... | |
| void | uniqueMappingsOnly (bool unique) |
| Allows to specify whether or not to store only unique atom/bond mappings. More... | |
| bool | uniqueMappingsOnly () const |
| Tells whether duplicate atom/bond mappings are discarded. More... | |
| void | setMaxNumMappings (std::size_t max_num_mappings) |
| Allows to specify a limit on the number of stored atom/bond mappings. More... | |
| std::size_t | getMaxNumMappings () const |
| Returns the specified limit on the number of stored atom/bond mappings. More... | |
| void | setMinSubstructureSize (std::size_t min_size) |
| Allows to specify the minimum accepted common substructure size. More... | |
| std::size_t | getMinSubstructureSize () const |
| Returns the minimum accepted common substructure size. More... | |
Searches for the maximum common atom substructures between a query and a target molecular graph.
Successive calls to setQuery() and findAllMappings() or findMaxBondMappings() produce all possible common substructure atom/bond mapping solutions (subject to an atom count lower bound set by setMinSubstructureSize()). The method findAllMappings() enumerates all atom count-maximal common substructures, and findMaxBondMappings() restricts the output to atom and bond count-maximal substructures. 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. Per-atom, per-bond and per-molecular graph Chem::MatchExpression implementation instances are retrieved as values of the corresponding atom, bond and molecular graph properties (see Chem::AtomProperty::MATCH_EXPRESSION, Chem::BondProperty::MATCH_EXPRESSION and Chem::MolecularGraphProperty::MATCH_EXPRESSION). Result accumulation can be bounded by setMaxNumMappings() and uniqueMappingsOnly().
| typedef std::shared_ptr<MaxCommonAtomSubstructureSearch> CDPL::Chem::MaxCommonAtomSubstructureSearch::SharedPointer |
A reference-counted smart pointer [SHPTR] for dynamically allocated MaxCommonAtomSubstructureSearch instances.
| typedef boost::indirect_iterator<ABMappingList::iterator, AtomBondMapping> CDPL::Chem::MaxCommonAtomSubstructureSearch::MappingIterator |
A mutable random access iterator used to iterate over the stored Chem::AtomBondMapping objects.
| typedef boost::indirect_iterator<ABMappingList::const_iterator, const AtomBondMapping> CDPL::Chem::MaxCommonAtomSubstructureSearch::ConstMappingIterator |
A constant random access iterator used to iterate over the stored const Chem::AtomBondMapping objects.
| CDPL::Chem::MaxCommonAtomSubstructureSearch::MaxCommonAtomSubstructureSearch | ( | ) |
Constructs and initializes the MaxCommonAtomSubstructureSearch instance.
| CDPL::Chem::MaxCommonAtomSubstructureSearch::MaxCommonAtomSubstructureSearch | ( | const MolecularGraph & | query | ) |
Constructs and initializes the MaxCommonAtomSubstructureSearch instance for the query molecular graph query.
| query | A molecular graph that represents the query structure. |
|
delete |
| CDPL::Chem::MaxCommonAtomSubstructureSearch::~MaxCommonAtomSubstructureSearch | ( | ) |
Destructor.
Destroys the MaxCommonAtomSubstructureSearch instance and frees all allocated resources.
|
delete |
| void CDPL::Chem::MaxCommonAtomSubstructureSearch::setQuery | ( | const MolecularGraph & | query | ) |
Sets query as the new query molecular graph.
| query | A molecular graph that represents the new query. |
| bool CDPL::Chem::MaxCommonAtomSubstructureSearch::mappingExists | ( | const MolecularGraph & | target | ) |
Searches for a common 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 findMaxBondMappings() instead.
| target | The target molecular graph that has to be searched for a substructure in common with the query. |
true if a common substructure of at least the minimum accepted size could be found, and false otherwise. | bool CDPL::Chem::MaxCommonAtomSubstructureSearch::findAllMappings | ( | const MolecularGraph & | target | ) |
Searches for all atom/bond mappings of query subgraphs to substructures of the target molecular graph target with a maximum atom count.
The method will store all maximum-sized (in number of atoms) 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.
| target | The target molecular graph that has to be searched for all maximum-sized substructures in common with the query. |
true if common substructures of at least the minimum accepted size were found, and false otherwise. | bool CDPL::Chem::MaxCommonAtomSubstructureSearch::findMaxBondMappings | ( | const MolecularGraph & | target | ) |
Searches for all atom/bond mappings of query subgraphs to substructures of the target molecular graph target with a maximum atom and bond count.
The method will store all maximum-sized (both in number of atoms and bonds) 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.
| target | The target molecular graph that has to be searched for all maximum-sized substructures in common with the query. |
true if common substructures of at least the minimum accepted size were found, and false otherwise. | std::size_t CDPL::Chem::MaxCommonAtomSubstructureSearch::getNumMappings | ( | ) | const |
Returns the number of atom/bond mappings that were recorded in the last search for common substructures.
| AtomBondMapping& CDPL::Chem::MaxCommonAtomSubstructureSearch::getMapping | ( | std::size_t | idx | ) |
Returns a non-const reference to the stored atom/bond mapping object at index idx.
| idx | The zero-based index of the atom/bond mapping object to return. |
const reference to the Chem::AtomBondMapping object at index idx. | Base::IndexError | if idx is not in the range [0, getNumMappings()). |
| const AtomBondMapping& CDPL::Chem::MaxCommonAtomSubstructureSearch::getMapping | ( | std::size_t | idx | ) | const |
Returns a const reference to the stored atom/bond mapping object at index idx.
| idx | The zero-based index of the atom/bond mapping object to return. |
const reference to the Chem::AtomBondMapping object at index idx. | Base::IndexError | if idx is not in the range [0, getNumMappings()). |
| MappingIterator CDPL::Chem::MaxCommonAtomSubstructureSearch::getMappingsBegin | ( | ) |
Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping objects.
| ConstMappingIterator CDPL::Chem::MaxCommonAtomSubstructureSearch::getMappingsBegin | ( | ) | const |
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objects.
const Chem::AtomBondMapping objects. | MappingIterator CDPL::Chem::MaxCommonAtomSubstructureSearch::getMappingsEnd | ( | ) |
Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping objects.
| ConstMappingIterator CDPL::Chem::MaxCommonAtomSubstructureSearch::getMappingsEnd | ( | ) | const |
Returns a constant iterator pointing to the end of the stored const Chem::AtomBondMapping objects.
const Chem::AtomBondMapping objects. | MappingIterator CDPL::Chem::MaxCommonAtomSubstructureSearch::begin | ( | ) |
Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping objects.
| ConstMappingIterator CDPL::Chem::MaxCommonAtomSubstructureSearch::begin | ( | ) | const |
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objects.
const Chem::AtomBondMapping objects. | MappingIterator CDPL::Chem::MaxCommonAtomSubstructureSearch::end | ( | ) |
Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping objects.
| ConstMappingIterator CDPL::Chem::MaxCommonAtomSubstructureSearch::end | ( | ) | const |
Returns a constant iterator pointing to the end of the stored const Chem::AtomBondMapping objects.
const Chem::AtomBondMapping objects. | void CDPL::Chem::MaxCommonAtomSubstructureSearch::uniqueMappingsOnly | ( | bool | unique | ) |
Allows to specify whether or not to store only unique atom/bond mappings.
The mapping of a query pattern 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.
| unique | If true, only unique mappings will be stored, and all found mappings otherwise. |
| bool CDPL::Chem::MaxCommonAtomSubstructureSearch::uniqueMappingsOnly | ( | ) | const |
Tells whether duplicate atom/bond mappings are discarded.
true if duplicate mappings are discarded, and false otherwise. | void CDPL::Chem::MaxCommonAtomSubstructureSearch::setMaxNumMappings | ( | std::size_t | max_num_mappings | ) |
Allows to specify a limit on the number of stored atom/bond mappings.
In a call to findAllMappings() or findMaxBondMappings() 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.
| max_num_mappings | The maximum number of atom/bond mappings to store. |
| std::size_t CDPL::Chem::MaxCommonAtomSubstructureSearch::getMaxNumMappings | ( | ) | const |
Returns the specified limit on the number of stored atom/bond mappings.
| void CDPL::Chem::MaxCommonAtomSubstructureSearch::setMinSubstructureSize | ( | std::size_t | 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.
| min_size | The minimum accepted common substructure size in number of atoms. |
| std::size_t CDPL::Chem::MaxCommonAtomSubstructureSearch::getMinSubstructureSize | ( | ) | const |
Returns the minimum accepted common substructure size.