29 #ifndef CDPL_CHEM_COMMONCONNECTEDSUBSTRUCTURESEARCH_HPP
30 #define CDPL_CHEM_COMMONCONNECTEDSUBSTRUCTURESEARCH_HPP
39 #include <boost/iterator/indirect_iterator.hpp>
82 typedef std::vector<AtomBondMapping*> ABMappingList;
93 typedef std::shared_ptr<CommonConnectedSubstructureSearch>
SharedPointer;
98 typedef boost::indirect_iterator<ABMappingList::iterator, AtomBondMapping>
MappingIterator;
344 void initMatchExpressions();
346 bool findEquivAtoms();
347 bool findEquivBonds();
350 bool mapAtoms(std::size_t);
351 bool mapAtoms(std::size_t, std::size_t);
353 bool nextTargetAtom(std::size_t, std::size_t&, std::size_t&)
const;
357 bool hasPostMappingMatchExprs()
const;
360 bool foundMappingUnique();
363 void clearMappings();
365 void freeAtomBondMappings();
366 void freeAtomBondMapping();
374 void initQueryAtomMask(std::size_t);
375 void initTargetAtomMask(std::size_t);
377 void initQueryBondMask(std::size_t);
378 void initTargetBondMask(std::size_t);
380 void setQueryAtomBit(std::size_t);
381 void setTargetAtomBit(std::size_t);
383 void resetQueryAtomBit(std::size_t);
384 void resetTargetAtomBit(std::size_t);
386 bool testTargetAtomBit(std::size_t)
const;
388 void setQueryBondBit(std::size_t);
389 void setTargetBondBit(std::size_t);
391 void resetBondMasks();
393 bool operator<(
const ABMappingMask&)
const;
394 bool operator>(
const ABMappingMask&)
const;
403 typedef std::vector<Util::BitSet> BitMatrix;
404 typedef std::vector<const Atom*> AtomMappingTable;
405 typedef std::vector<std::size_t> AtomIndexList;
406 typedef std::vector<std::size_t> BondMappingStack;
407 typedef std::deque<std::size_t> AtomQueue;
408 typedef std::set<ABMappingMask> UniqueMappingList;
409 typedef std::vector<const Atom*> AtomList;
410 typedef std::vector<const Bond*> BondList;
411 typedef std::vector<MatchExpression<Atom, MolecularGraph>::SharedPointer> AtomMatchExprTable;
412 typedef std::vector<MatchExpression<Bond, MolecularGraph>::SharedPointer> BondMatchExprTable;
417 AtomMatchExpressionFunction atomMatchExprFunc;
418 BondMatchExpressionFunction bondMatchExprFunc;
419 MolecularGraphMatchExpressionFunction molGraphMatchExprFunc;
420 BitMatrix atomEquivMatrix;
421 BitMatrix bondEquivMatrix;
422 AtomQueue termQueryAtoms;
423 AtomIndexList termTargetAtoms;
424 BondMappingStack bondMappingStack;
425 AtomMappingTable queryAtomMapping;
426 ABMappingMask mappingMask;
430 ABMappingList foundMappings;
431 UniqueMappingList uniqueMappings;
432 AtomMatchExprTable atomMatchExprTable;
433 BondMatchExprTable bondMatchExprTable;
434 MolGraphMatchExprPtr molGraphMatchExpr;
435 AtomList postMappingMatchAtoms;
436 BondList postMappingMatchBonds;
437 MappingCache mappingCache;
442 bool maxMappingsOnly;
443 std::size_t numQueryAtoms;
444 std::size_t numQueryBonds;
445 std::size_t numTargetAtoms;
446 std::size_t numTargetBonds;
447 std::size_t numMappedAtoms;
448 std::size_t currMaxSubstructureSize;
449 std::size_t maxBondStackSize;
450 std::size_t maxNumMappings;
451 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:58
Abstract base class representing a chemical bond between two atoms (represented by Chem::Atom instanc...
Definition: Bond.hpp:54
Enumerates all maximal common connected substructures shared between a query and a target molecular g...
Definition: CommonConnectedSubstructureSearch.hpp:80
std::function< const MolGraphMatchExprPtr &(const MolecularGraph &)> MolecularGraphMatchExpressionFunction
Type of the functor used to retrieve the Chem::MatchExpression implementation instance for the query ...
Definition: CommonConnectedSubstructureSearch.hpp:118
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 Chem::AtomBondMapping objects.
Definition: CommonConnectedSubstructureSearch.hpp:98
std::function< const AtomMatchExprPtr &(const Atom &)> AtomMatchExpressionFunction
Type of the functor used to retrieve the Chem::MatchExpression implementation instance for a query at...
Definition: CommonConnectedSubstructureSearch.hpp:108
ConstMappingIterator end() const
Returns a constant iterator pointing to the end of the stored const Chem::AtomBondMapping objects.
void setQuery(const MolecularGraph &query)
Sets query as the new query molecular graph.
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 Chem::AtomBondMapping objects.
bool mappingExists(const MolecularGraph &target)
Searches for a common connected substructure between the query and the target molecular graph target.
void setAtomMatchExpressionFunction(const AtomMatchExpressionFunction &func)
Installs a function that resolves the Chem::MatchExpression implementation instance 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 const Chem::AtomBondMapping objects...
Definition: CommonConnectedSubstructureSearch.hpp:103
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:93
void setMolecularGraphMatchExpressionFunction(const MolecularGraphMatchExpressionFunction &func)
Installs a function that resolves the Chem::MatchExpression implementation instance for the query mol...
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 tar...
bool uniqueMappingsOnly() const
Tells whether duplicate atom/bond mappings are discarded.
CommonConnectedSubstructureSearch(const MolecularGraph &query)
Constructs and initializes the CommonConnectedSubstructureSearch instance for the query molecular gra...
MappingIterator getMappingsBegin()
Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping 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 const Chem::AtomBondMapping objects.
CommonConnectedSubstructureSearch(const CommonConnectedSubstructureSearch &)=delete
std::function< const BondMatchExprPtr &(const Bond &)> BondMatchExpressionFunction
Type of the functor used to retrieve the Chem::MatchExpression implementation instance for a query bo...
Definition: CommonConnectedSubstructureSearch.hpp:113
CommonConnectedSubstructureSearch & operator=(const CommonConnectedSubstructureSearch &)=delete
void setBondMatchExpressionFunction(const BondMatchExpressionFunction &func)
Installs a function that resolves the Chem::MatchExpression implementation instance for a query bond.
ConstMappingIterator getMappingsBegin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objec...
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 Chem::AtomBondMapping objects.
ConstMappingIterator begin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objec...
std::size_t getMaxNumMappings() const
Returns the specified limit on the number of stored atom/bond mappings.
CommonConnectedSubstructureSearch()
Constructs and initializes the CommonConnectedSubstructureSearch instance.
MappingIterator getMappingsEnd()
Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping objects.
Generic boolean expression interface for the implementation of query/target object equivalence tests ...
Definition: MatchExpression.hpp:75
Abstract base class for data structures that represent chemical structures as molecular graphs.
Definition: MolecularGraph.hpp:60
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.