29 #ifndef CDPL_CHEM_COMMONCONNECTEDSUBSTRUCTURESEARCH_HPP
30 #define CDPL_CHEM_COMMONCONNECTEDSUBSTRUCTURESEARCH_HPP
39 #include <boost/iterator/indirect_iterator.hpp>
76 typedef std::vector<AtomBondMapping*> ABMappingList;
87 typedef std::shared_ptr<CommonConnectedSubstructureSearch>
SharedPointer;
92 typedef boost::indirect_iterator<ABMappingList::iterator, AtomBondMapping>
MappingIterator;
97 typedef boost::indirect_iterator<ABMappingList::const_iterator, const AtomBondMapping>
ConstMappingIterator;
338 void initMatchExpressions();
340 bool findEquivAtoms();
341 bool findEquivBonds();
344 bool mapAtoms(std::size_t);
345 bool mapAtoms(std::size_t, std::size_t);
347 bool nextTargetAtom(std::size_t, std::size_t&, std::size_t&)
const;
351 bool hasPostMappingMatchExprs()
const;
354 bool foundMappingUnique();
357 void clearMappings();
359 void freeAtomBondMappings();
360 void freeAtomBondMapping();
368 void initQueryAtomMask(std::size_t);
369 void initTargetAtomMask(std::size_t);
371 void initQueryBondMask(std::size_t);
372 void initTargetBondMask(std::size_t);
374 void setQueryAtomBit(std::size_t);
375 void setTargetAtomBit(std::size_t);
377 void resetQueryAtomBit(std::size_t);
378 void resetTargetAtomBit(std::size_t);
380 bool testTargetAtomBit(std::size_t)
const;
382 void setQueryBondBit(std::size_t);
383 void setTargetBondBit(std::size_t);
385 void resetBondMasks();
387 bool operator<(
const ABMappingMask&)
const;
388 bool operator>(
const ABMappingMask&)
const;
397 typedef std::vector<Util::BitSet> BitMatrix;
398 typedef std::vector<const Atom*> AtomMappingTable;
399 typedef std::vector<std::size_t> AtomIndexList;
400 typedef std::vector<std::size_t> BondMappingStack;
401 typedef std::deque<std::size_t> AtomQueue;
402 typedef std::set<ABMappingMask> UniqueMappingList;
403 typedef std::vector<const Atom*> AtomList;
404 typedef std::vector<const Bond*> BondList;
405 typedef std::vector<MatchExpression<Atom, MolecularGraph>::SharedPointer> AtomMatchExprTable;
406 typedef std::vector<MatchExpression<Bond, MolecularGraph>::SharedPointer> BondMatchExprTable;
411 AtomMatchExpressionFunction atomMatchExprFunc;
412 BondMatchExpressionFunction bondMatchExprFunc;
413 MolecularGraphMatchExpressionFunction molGraphMatchExprFunc;
414 BitMatrix atomEquivMatrix;
415 BitMatrix bondEquivMatrix;
416 AtomQueue termQueryAtoms;
417 AtomIndexList termTargetAtoms;
418 BondMappingStack bondMappingStack;
419 AtomMappingTable queryAtomMapping;
420 ABMappingMask mappingMask;
424 ABMappingList foundMappings;
425 UniqueMappingList uniqueMappings;
426 AtomMatchExprTable atomMatchExprTable;
427 BondMatchExprTable bondMatchExprTable;
428 MolGraphMatchExprPtr molGraphMatchExpr;
429 AtomList postMappingMatchAtoms;
430 BondList postMappingMatchBonds;
431 MappingCache mappingCache;
436 bool maxMappingsOnly;
437 std::size_t numQueryAtoms;
438 std::size_t numQueryBonds;
439 std::size_t numTargetAtoms;
440 std::size_t numTargetBonds;
441 std::size_t numMappedAtoms;
442 std::size_t currMaxSubstructureSize;
443 std::size_t maxBondStackSize;
444 std::size_t maxNumMappings;
445 std::size_t minSubstructureSize;
Definition of class CDPL::Chem::AtomBondMapping.
Declaration of type CDPL::Util::BitSet.
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 class CDPL::Chem::MatchExpression.
Definition of class CDPL::Util::ObjectStack.
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:57
Abstract base class representing a chemical bond between two Chem::Atom instances.
Definition: Bond.hpp:54
Enumerates all maximal common connected substructures shared between a query and a target molecular g...
Definition: CommonConnectedSubstructureSearch.hpp:74
std::function< const MolGraphMatchExprPtr &(const MolecularGraph &)> MolecularGraphMatchExpressionFunction
Type of the functor used to retrieve the graph-level Chem::MatchExpression for the query molecular gr...
Definition: CommonConnectedSubstructureSearch.hpp:112
std::size_t getNumMappings() const
Returns the number of atom/bond mappings that were recorded in the last search for common substructur...
boost::indirect_iterator< ABMappingList::iterator, AtomBondMapping > MappingIterator
A mutable random access iterator used to iterate over the stored atom/bond mapping objects.
Definition: CommonConnectedSubstructureSearch.hpp:92
std::function< const AtomMatchExprPtr &(const Atom &)> AtomMatchExpressionFunction
Type of the functor used to retrieve the atom-level Chem::MatchExpression for a query atom.
Definition: CommonConnectedSubstructureSearch.hpp:102
ConstMappingIterator end() const
Returns a constant iterator pointing to the end of the stored atom/bond mapping objects.
void setQuery(const MolecularGraph &query)
Allows to specify a new query structure.
void setMaxNumMappings(std::size_t max_num_mappings)
Allows to specify a limit on the number of stored atom/bond mappings.
MappingIterator begin()
Returns a mutable iterator pointing to the beginning of the stored atom/bond mapping objects.
bool mappingExists(const MolecularGraph &target)
Searches for a common connected substructure between the query and the specified target molecular gra...
void setAtomMatchExpressionFunction(const AtomMatchExpressionFunction &func)
Installs a function that resolves the atom-level Chem::MatchExpression for a query atom.
const AtomBondMapping & getMapping(std::size_t idx) const
Returns a const reference to the stored atom/bond mapping object at index idx.
boost::indirect_iterator< ABMappingList::const_iterator, const AtomBondMapping > ConstMappingIterator
A constant random access iterator used to iterate over the stored atom/bond mapping objects.
Definition: CommonConnectedSubstructureSearch.hpp:97
bool findMaxMappings(const MolecularGraph &target)
Searches for all maximum-sized atom/bond mappings of connected query subgraphs to substructures of th...
std::shared_ptr< CommonConnectedSubstructureSearch > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated CommonConnectedSubstructureSearch...
Definition: CommonConnectedSubstructureSearch.hpp:87
void setMolecularGraphMatchExpressionFunction(const MolecularGraphMatchExpressionFunction &func)
Installs a function that resolves the graph-level Chem::MatchExpression for the query molecular graph...
void setMinSubstructureSize(std::size_t min_size)
Allows to specify the minimum accepted common substructure size.
bool findAllMappings(const MolecularGraph &target)
Searches for all possible atom/bond mappings of connected query subgraphs to substructures of the spe...
bool uniqueMappingsOnly() const
Tells whether duplicate atom/bond mappings are discarded.
CommonConnectedSubstructureSearch(const MolecularGraph &query)
Constructs and initializes a CommonConnectedSubstructureSearch instance for the specified query struc...
MappingIterator getMappingsBegin()
Returns a mutable iterator pointing to the beginning of the stored atom/bond mapping objects.
AtomBondMapping & getMapping(std::size_t idx)
Returns a non-const reference to the stored atom/bond mapping object at index idx.
~CommonConnectedSubstructureSearch()
Destructor.
std::size_t getMinSubstructureSize() const
Returns the minimum accepted common substructure size.
ConstMappingIterator getMappingsEnd() const
Returns a constant iterator pointing to the end of the stored atom/bond mapping objects.
CommonConnectedSubstructureSearch(const CommonConnectedSubstructureSearch &)=delete
std::function< const BondMatchExprPtr &(const Bond &)> BondMatchExpressionFunction
Type of the functor used to retrieve the bond-level Chem::MatchExpression for a query bond.
Definition: CommonConnectedSubstructureSearch.hpp:107
CommonConnectedSubstructureSearch & operator=(const CommonConnectedSubstructureSearch &)=delete
void setBondMatchExpressionFunction(const BondMatchExpressionFunction &func)
Installs a function that resolves the bond-level Chem::MatchExpression for a query bond.
ConstMappingIterator getMappingsBegin() const
Returns a constant iterator pointing to the beginning of the stored atom/bond mapping objects.
void uniqueMappingsOnly(bool unique)
Allows to specify whether or not to store only unique atom/bond mappings.
MappingIterator end()
Returns a mutable iterator pointing to the end of the stored atom/bond mapping objects.
ConstMappingIterator begin() const
Returns a constant iterator pointing to the beginning of the stored atom/bond mapping objects.
std::size_t getMaxNumMappings() const
Returns the specified limit on the number of stored atom/bond mappings.
CommonConnectedSubstructureSearch()
Constructs and initializes a CommonConnectedSubstructureSearch instance.
MappingIterator getMappingsEnd()
Returns a mutable iterator pointing to the end of the stored atom/bond mapping objects.
Generic boolean expression interface for the implementation of query/target object equivalence tests ...
Definition: MatchExpression.hpp:75
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
bool operator<(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less than comparison operator.
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
bool operator>(const Array< ValueType > &array1, const Array< ValueType > &array2)
Greater than comparison operator.
The namespace of the Chemical Data Processing Library.