Chemical Data Processing Library C++ API - Version 1.1.1
|
#include <SubstructureSearch.hpp>
Public Types | |
typedef std::shared_ptr< SubstructureSearch > | SharedPointer |
typedef boost::indirect_iterator< ABMappingList::iterator, AtomBondMapping > | MappingIterator |
A mutable random access iterator used to iterate over the stored atom/bond mapping objects. More... | |
typedef boost::indirect_iterator< ABMappingList::const_iterator, const AtomBondMapping > | ConstMappingIterator |
A constant random access iterator used to iterate over the stored atom/bond mapping objects. More... | |
typedef std::function< const AtomMatchExprPtr &(const Atom &)> | AtomMatchExpressionFunction |
typedef std::function< const BondMatchExprPtr &(const Bond &)> | BondMatchExpressionFunction |
typedef std::function< const MolGraphMatchExprPtr &(const MolecularGraph &)> | MolecularGraphMatchExpressionFunction |
Public Member Functions | |
SubstructureSearch () | |
Constructs and initializes a SubstructureSearch instance. More... | |
SubstructureSearch (const MolecularGraph &query) | |
Constructs and initializes a SubstructureSearch instance for the specified query structure. More... | |
~SubstructureSearch () | |
Destructor. More... | |
void | setAtomMatchExpressionFunction (const AtomMatchExpressionFunction &func) |
void | setBondMatchExpressionFunction (const BondMatchExpressionFunction &func) |
void | setMolecularGraphMatchExpressionFunction (const MolecularGraphMatchExpressionFunction &func) |
void | setQuery (const MolecularGraph &query) |
Allows to specify a new query structure. More... | |
bool | mappingExists (const MolecularGraph &target) |
Tells whether the query structure matches a substructure of the specified target molecular graph. More... | |
bool | findMappings (const MolecularGraph &target) |
Searches for all possible atom/bond mappings of the query structure to substructures of the specified target molecular graph. More... | |
void | stopSearch () |
std::size_t | getNumMappings () const |
Returns the number of atom/bond mappings that were recorded in the last call to findMappings(). 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 atom/bond mapping objects. More... | |
ConstMappingIterator | getMappingsBegin () const |
Returns a constant iterator pointing to the beginning of the stored atom/bond mapping objects. More... | |
MappingIterator | getMappingsEnd () |
Returns a mutable iterator pointing to the end of the stored atom/bond mapping objects. More... | |
ConstMappingIterator | getMappingsEnd () const |
Returns a constant iterator pointing to the end of the stored atom/bond mapping objects. More... | |
MappingIterator | begin () |
Returns a mutable iterator pointing to the beginning of the stored atom/bond mapping objects. More... | |
ConstMappingIterator | begin () const |
Returns a constant iterator pointing to the beginning of the stored atom/bond mapping objects. More... | |
MappingIterator | end () |
Returns a mutable iterator pointing to the end of the stored atom/bond mapping objects. More... | |
ConstMappingIterator | end () const |
Returns a constant iterator pointing to the end of the stored atom/bond mapping 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 | addAtomMappingConstraint (std::size_t query_atom_idx, std::size_t target_atom_idx) |
Adds a constraint on the allowed mappings between query and target structure atoms. More... | |
void | clearAtomMappingConstraints () |
Clears all previously defined query to target atom mapping constraints. More... | |
void | addBondMappingConstraint (std::size_t query_bond_idx, std::size_t target_bond_idx) |
Adds a constraint on the allowed mappings between query and target structure bonds. More... | |
void | clearBondMappingConstraints () |
Clears all previously defined query to target bond mapping constraints. More... | |
typedef std::shared_ptr<SubstructureSearch> CDPL::Chem::SubstructureSearch::SharedPointer |
typedef boost::indirect_iterator<ABMappingList::iterator, AtomBondMapping> CDPL::Chem::SubstructureSearch::MappingIterator |
A mutable random access iterator used to iterate over the stored atom/bond mapping objects.
typedef boost::indirect_iterator<ABMappingList::const_iterator, const AtomBondMapping> CDPL::Chem::SubstructureSearch::ConstMappingIterator |
A constant random access iterator used to iterate over the stored atom/bond mapping objects.
typedef std::function<const AtomMatchExprPtr&(const Atom&)> CDPL::Chem::SubstructureSearch::AtomMatchExpressionFunction |
typedef std::function<const BondMatchExprPtr&(const Bond&)> CDPL::Chem::SubstructureSearch::BondMatchExpressionFunction |
typedef std::function<const MolGraphMatchExprPtr&(const MolecularGraph&)> CDPL::Chem::SubstructureSearch::MolecularGraphMatchExpressionFunction |
CDPL::Chem::SubstructureSearch::SubstructureSearch | ( | ) |
Constructs and initializes a SubstructureSearch
instance.
CDPL::Chem::SubstructureSearch::SubstructureSearch | ( | const MolecularGraph & | query | ) |
Constructs and initializes a SubstructureSearch
instance for the specified query structure.
query | A molecular graph that represents the query structure. |
CDPL::Chem::SubstructureSearch::~SubstructureSearch | ( | ) |
Destructor.
Destroys the SubstructureSearch
instance and frees all allocated resources.
void CDPL::Chem::SubstructureSearch::setAtomMatchExpressionFunction | ( | const AtomMatchExpressionFunction & | func | ) |
void CDPL::Chem::SubstructureSearch::setBondMatchExpressionFunction | ( | const BondMatchExpressionFunction & | func | ) |
void CDPL::Chem::SubstructureSearch::setMolecularGraphMatchExpressionFunction | ( | const MolecularGraphMatchExpressionFunction & | func | ) |
void CDPL::Chem::SubstructureSearch::setQuery | ( | const MolecularGraph & | query | ) |
Allows to specify a new query structure.
query | A molecular graph that represents the query structure. |
bool CDPL::Chem::SubstructureSearch::mappingExists | ( | const MolecularGraph & | target | ) |
Tells whether the query structure matches a substructure of the specified target molecular graph.
The method does not store any atom/bond mappings between the query and target structure - it just tells if a complete mapping of the query is possible. If you need access to the atom/bond mappings, use findMappings() instead.
target | The molecular graph that has to be searched for a match of the query structure. |
true
if the query matches a substructure of the target molecular graph, and false
otherwise. bool CDPL::Chem::SubstructureSearch::findMappings | ( | const MolecularGraph & | target | ) |
Searches for all possible atom/bond mappings of the query structure to substructures of the specified target molecular graph.
The method will store all found subgraph 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.
target | The molecular graph that has to be searched for matches of the query structure. |
true
if the query matches at least one substructure of the specified target molecular graph, and false
otherwise. void CDPL::Chem::SubstructureSearch::stopSearch | ( | ) |
std::size_t CDPL::Chem::SubstructureSearch::getNumMappings | ( | ) | const |
Returns the number of atom/bond mappings that were recorded in the last call to findMappings().
AtomBondMapping& CDPL::Chem::SubstructureSearch::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 atom/bond mapping object at index idx. Base::IndexError | if no mappings are available or idx is not in the range [0, getNumMappings() - 1]. |
const AtomBondMapping& CDPL::Chem::SubstructureSearch::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 atom/bond mapping object at index idx. Base::IndexError | if no mappings are available or idx is not in the range [0, getNumMappings() - 1]. |
MappingIterator CDPL::Chem::SubstructureSearch::getMappingsBegin | ( | ) |
Returns a mutable iterator pointing to the beginning of the stored atom/bond mapping objects.
ConstMappingIterator CDPL::Chem::SubstructureSearch::getMappingsBegin | ( | ) | const |
Returns a constant iterator pointing to the beginning of the stored atom/bond mapping objects.
MappingIterator CDPL::Chem::SubstructureSearch::getMappingsEnd | ( | ) |
Returns a mutable iterator pointing to the end of the stored atom/bond mapping objects.
ConstMappingIterator CDPL::Chem::SubstructureSearch::getMappingsEnd | ( | ) | const |
Returns a constant iterator pointing to the end of the stored atom/bond mapping objects.
MappingIterator CDPL::Chem::SubstructureSearch::begin | ( | ) |
Returns a mutable iterator pointing to the beginning of the stored atom/bond mapping objects.
ConstMappingIterator CDPL::Chem::SubstructureSearch::begin | ( | ) | const |
Returns a constant iterator pointing to the beginning of the stored atom/bond mapping objects.
MappingIterator CDPL::Chem::SubstructureSearch::end | ( | ) |
Returns a mutable iterator pointing to the end of the stored atom/bond mapping objects.
ConstMappingIterator CDPL::Chem::SubstructureSearch::end | ( | ) | const |
Returns a constant iterator pointing to the end of the stored atom/bond mapping objects.
void CDPL::Chem::SubstructureSearch::uniqueMappingsOnly | ( | bool | unique | ) |
Allows to specify whether or not to store only unique atom/bond mappings.
A mapping of the query pattern 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::SubstructureSearch::uniqueMappingsOnly | ( | ) | const |
Tells whether duplicate atom/bond mappings are discarded.
true
if duplicate mappings are discarded, and false
otherwise. void CDPL::Chem::SubstructureSearch::setMaxNumMappings | ( | std::size_t | max_num_mappings | ) |
Allows to specify a limit on the number of stored atom/bond mappings.
In a call to findMappings() the 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::SubstructureSearch::getMaxNumMappings | ( | ) | const |
Returns the specified limit on the number of stored atom/bond mappings.
void CDPL::Chem::SubstructureSearch::addAtomMappingConstraint | ( | std::size_t | query_atom_idx, |
std::size_t | target_atom_idx | ||
) |
Adds a constraint on the allowed mappings between query and target structure atoms.
By default, an atom of the query structure is free to match any suitable target structure atom. When this method gets called for a particular query/target atom pair (specified by query_atom_idx and target_atom_idx), future substructure searches will find only those subgraph mapping solutions (if any) where the given query atom maps to the specified target structure atom. Multiple calls to addAtomMappingConstraint() for the same query atom have an additive effect and allow to restrict the valid query atom mappings not only to a single but also a larger set of target structure atoms.
query_atom_idx | The index of the query structure atom. |
target_atom_idx | The index of the target structure atom that has to be matched by the query atom. |
void CDPL::Chem::SubstructureSearch::clearAtomMappingConstraints | ( | ) |
Clears all previously defined query to target atom mapping constraints.
void CDPL::Chem::SubstructureSearch::addBondMappingConstraint | ( | std::size_t | query_bond_idx, |
std::size_t | target_bond_idx | ||
) |
Adds a constraint on the allowed mappings between query and target structure bonds.
By default, a bond of the query structure is free to match any suitable target structure bond. When this method gets called for a particular query/target bond pair (specified by query_bond_idx and target_bond_idx), future substructure searches will find only those subgraph mapping solutions (if any) where the given query bond maps to the specified target structure bond. Multiple calls to addBondMappingConstraint() for the same query bond have an additive effect and allow to restrict the valid query bond mappings not only to a single but also a larger set of target structure bonds.
query_bond_idx | The index of the query structure bond. |
target_bond_idx | The index of the target structure bond that has to be matched by the query bond. |
void CDPL::Chem::SubstructureSearch::clearBondMappingConstraints | ( | ) |
Clears all previously defined query to target bond mapping constraints.