29 #ifndef CDPL_CHEM_AUTOMORPHISMGROUPSEARCH_HPP
30 #define CDPL_CHEM_AUTOMORPHISMGROUPSEARCH_HPP
71 static constexpr
unsigned int DEF_ATOM_PROPERTY_FLAGS =
80 static constexpr
unsigned int DEF_BOND_PROPERTY_FLAGS =
114 unsigned int bond_flags = DEF_BOND_PROPERTY_FLAGS);
324 getAtomMatchExpression(
const Atom& atom)
const;
327 getBondMatchExpression(
const Bond& bond)
const;
332 class AtomMatchExpression :
public MatchExpression<Atom, MolecularGraph>
339 bool requiresAtomBondMapping()
const;
351 mutable unsigned int type;
352 mutable unsigned int hybState;
353 mutable std::size_t isotope;
354 mutable std::size_t hCount;
356 mutable bool aromatic;
357 mutable std::size_t expBondCount;
360 class BondMatchExpression :
public MatchExpression<Bond, MolecularGraph>
364 BondMatchExpression(AutomorphismGroupSearch* parent):
367 bool requiresAtomBondMapping()
const;
369 bool operator()(
const Bond& query_bond,
const MolecularGraph& query_molgraph,
370 const Bond& target_bond,
const MolecularGraph& target_molgraph,
373 bool operator()(
const Bond& query_bond,
const MolecularGraph& query_molgraph,
374 const Bond& target_bond,
const MolecularGraph& target_molgraph,
375 const AtomBondMapping& mapping,
const Base::Any& aux_data)
const;
378 AutomorphismGroupSearch* parent;
379 mutable std::size_t order;
381 mutable bool aromatic;
384 class MolGraphMatchExpression :
public MatchExpression<MolecularGraph>
388 MolGraphMatchExpression(
const AutomorphismGroupSearch* parent):
391 bool requiresAtomBondMapping()
const;
393 bool operator()(
const MolecularGraph& query_molgraph,
394 const MolecularGraph& target_molgraph,
397 bool operator()(
const MolecularGraph& query_molgraph,
398 const MolecularGraph& target_molgraph,
399 const AtomBondMapping& mapping,
const Base::Any& aux_data)
const;
402 const AutomorphismGroupSearch* parent;
409 SubstructureSearch substructSearch;
410 bool incIdentityMapping;
411 unsigned int atomPropFlags;
412 unsigned int bondPropFlags;
413 AtomMatchExprPtr atomMatchExpr;
414 BondMatchExprPtr bondMatchExpr;
415 MolGraphMatchExprPtr molGraphMatchExpr;
416 MappingCallbackFunction mappingCallbackFunc;
417 const Atom* lastQueryAtom;
418 const Bond* lastQueryBond;
Definition of constants in namespace CDPL::Chem::BondPropertyFlag.
Definition of the preprocessor macro CDPL_CHEM_API.
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of constants in namespace CDPL::Chem::AtomPropertyFlag.
Definition of class CDPL::Chem::MatchExpression.
Definition of class CDPL::Chem::SubstructureSearch.
Safe, type checked container for arbitrary data of variable type.
Definition: Any.hpp:60
Data structure for the common storage of related atom to atom and bond to bond mappings.
Definition: AtomBondMapping.hpp:55
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:58
Enumerates the atom and bond self-mappings (automorphism group) of a molecular graph.
Definition: AutomorphismGroupSearch.hpp:66
AutomorphismGroupSearch(const AutomorphismGroupSearch &)=delete
AutomorphismGroupSearch(unsigned int atom_flags=DEF_ATOM_PROPERTY_FLAGS, unsigned int bond_flags=DEF_BOND_PROPERTY_FLAGS)
Constructs and initializes the AutomorphismGroupSearch instance for the specified atom and bond prope...
MappingIterator getMappingsEnd()
Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping objects.
bool identityMappingIncluded() const
Tells whether the identity mapping is included in the search results.
AutomorphismGroupSearch & operator=(const AutomorphismGroupSearch &)=delete
SubstructureSearch::ConstMappingIterator ConstMappingIterator
A constant random access iterator used to iterate over the stored const Chem::AtomBondMapping objects...
Definition: AutomorphismGroupSearch.hpp:97
void clearAtomMappingConstraints()
Clears all previously defined atom mapping constraints.
bool findMappings(const MolecularGraph &molgraph)
Searches for the possible atom/bond mappings in the automorphism group of the molecular graph molgrap...
MappingIterator end()
Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping objects.
void addAtomMappingConstraint(std::size_t atom1_idx, std::size_t atom2_idx)
Adds a constraint on the allowed atom mappings.
void includeIdentityMapping(bool include)
Specifies whether the identity mapping shall be included in the search results.
void setMaxNumMappings(std::size_t max_num_mappings)
Allows to specify a limit on the number of stored atom/bond mappings.
ConstMappingIterator getMappingsBegin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objec...
const AtomBondMapping & getMapping(std::size_t idx) const
Returns a const reference to the stored atom/bond mapping object at index idx.
void stopSearch()
Aborts a currently running findMappings() call.
ConstMappingIterator getMappingsEnd() const
Returns a constant iterator pointing to the end of the stored const Chem::AtomBondMapping objects.
std::shared_ptr< AutomorphismGroupSearch > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated AutomorphismGroupSearch instances...
Definition: AutomorphismGroupSearch.hpp:87
void setBondPropertyFlags(unsigned int flags)
Specifies the bond properties considered for bond matching during automorphism search.
unsigned int getAtomPropertyFlags() const
Returns the atomic properties currently considered for atom matching.
const MappingCallbackFunction & getFoundMappingCallback() const
Returns the currently installed callback function invoked for every found atom/bond mapping.
ConstMappingIterator end() const
Returns a constant iterator pointing to the end of the stored const Chem::AtomBondMapping objects.
void addBondMappingConstraint(std::size_t bond1_idx, std::size_t bond2_idx)
Adds a constraint on the allowed bond mappings.
std::size_t getMaxNumMappings() const
Returns the specified limit on the number of stored atom/bond mappings.
ConstMappingIterator begin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objec...
void setFoundMappingCallback(const MappingCallbackFunction &func)
Sets a callback function that is invoked for every atom/bond mapping found during findMappings().
std::function< bool(const MolecularGraph &, const AtomBondMapping &)> MappingCallbackFunction
Type of the callback function invoked for every found mapping.
Definition: AutomorphismGroupSearch.hpp:104
std::size_t getNumMappings() const
Returns the number of atom/bond mappings that were recorded in the last call to findMappings().
MappingIterator begin()
Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping objects.
unsigned int getBondPropertyFlags() const
Returns the bond properties currently considered for bond matching.
SubstructureSearch::MappingIterator MappingIterator
A mutable random access iterator used to iterate over the stored Chem::AtomBondMapping objects.
Definition: AutomorphismGroupSearch.hpp:92
void setAtomPropertyFlags(unsigned int flags)
Specifies the atomic properties considered for atom matching during automorphism search.
AtomBondMapping & getMapping(std::size_t idx)
Returns a non-const reference to the stored atom/bond mapping object at index idx.
void clearBondMappingConstraints()
Clears all previously defined bond mapping constraints.
MappingIterator getMappingsBegin()
Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping objects.
Abstract base class representing a chemical bond between two atoms (represented by Chem::Atom instanc...
Definition: Bond.hpp:54
Generic boolean expression interface for the implementation of query/target object equivalence tests ...
Definition: MatchExpression.hpp:75
std::shared_ptr< MatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MatchExpression instances.
Definition: MatchExpression.hpp:81
Abstract base class for data structures that represent chemical structures as molecular graphs.
Definition: MolecularGraph.hpp:60
boost::indirect_iterator< ABMappingList::const_iterator, const AtomBondMapping > ConstMappingIterator
A constant random access iterator used to iterate over the stored const Chem::AtomBondMapping objects...
Definition: SubstructureSearch.hpp:100
boost::indirect_iterator< ABMappingList::iterator, AtomBondMapping > MappingIterator
A mutable random access iterator used to iterate over the stored Chem::AtomBondMapping objects.
Definition: SubstructureSearch.hpp:95
constexpr unsigned int FORMAL_CHARGE
Specifies the formal charge of an atom.
Definition: Chem/AtomPropertyFlag.hpp:73
constexpr unsigned int H_COUNT
Specifies the hydrogen count of an atom.
Definition: Chem/AtomPropertyFlag.hpp:78
constexpr unsigned int AROMATICITY
Specifies the membership of an atom in aromatic rings.
Definition: Chem/AtomPropertyFlag.hpp:93
constexpr unsigned int ISOTOPE
Specifies the isotopic mass of an atom.
Definition: Chem/AtomPropertyFlag.hpp:68
constexpr unsigned int CONFIGURATION
Specifies the configuration of a stereogenic atom.
Definition: Chem/AtomPropertyFlag.hpp:98
constexpr unsigned int HYBRIDIZATION_STATE
Specifies the hybridization state an atom.
Definition: Chem/AtomPropertyFlag.hpp:123
constexpr unsigned int TYPE
Specifies the generic type or element of an atom.
Definition: Chem/AtomPropertyFlag.hpp:63
constexpr unsigned int EXPLICIT_BOND_COUNT
Specifies the explicit bond count of an atom.
Definition: Chem/AtomPropertyFlag.hpp:118
constexpr unsigned int AROMATICITY
Specifies the membership of a bond in aromatic rings.
Definition: BondPropertyFlag.hpp:73
constexpr unsigned int ORDER
Specifies the order of a bond.
Definition: BondPropertyFlag.hpp:63
constexpr unsigned int CONFIGURATION
Specifies the steric configuration of a double bond.
Definition: BondPropertyFlag.hpp:78
constexpr unsigned int TOPOLOGY
Specifies the ring/chain topology of a bond.
Definition: BondPropertyFlag.hpp:68
constexpr unsigned int Any
Specifies any atom.
Definition: SybylAtomType.hpp:198
The namespace of the Chemical Data Processing Library.