29 #ifndef CDPL_CHEM_COMMONCONNECTEDSUBSTRUCTURESEARCH_HPP
30 #define CDPL_CHEM_COMMONCONNECTEDSUBSTRUCTURESEARCH_HPP
39 #include <boost/iterator/indirect_iterator.hpp>
65 typedef std::vector<AtomBondMapping*> ABMappingList;
72 typedef std::shared_ptr<CommonConnectedSubstructureSearch>
SharedPointer;
77 typedef boost::indirect_iterator<ABMappingList::iterator, AtomBondMapping>
MappingIterator;
82 typedef boost::indirect_iterator<ABMappingList::const_iterator, const AtomBondMapping>
ConstMappingIterator;
300 void initMatchExpressions();
302 bool findEquivAtoms();
303 bool findEquivBonds();
306 bool mapAtoms(std::size_t);
307 bool mapAtoms(std::size_t, std::size_t);
309 bool nextTargetAtom(std::size_t, std::size_t&, std::size_t&)
const;
313 bool hasPostMappingMatchExprs()
const;
316 bool foundMappingUnique();
319 void clearMappings();
321 void freeAtomBondMappings();
322 void freeAtomBondMapping();
330 void initQueryAtomMask(std::size_t);
331 void initTargetAtomMask(std::size_t);
333 void initQueryBondMask(std::size_t);
334 void initTargetBondMask(std::size_t);
336 void setQueryAtomBit(std::size_t);
337 void setTargetAtomBit(std::size_t);
339 void resetQueryAtomBit(std::size_t);
340 void resetTargetAtomBit(std::size_t);
342 bool testTargetAtomBit(std::size_t)
const;
344 void setQueryBondBit(std::size_t);
345 void setTargetBondBit(std::size_t);
347 void resetBondMasks();
349 bool operator<(
const ABMappingMask&)
const;
350 bool operator>(
const ABMappingMask&)
const;
359 typedef std::vector<Util::BitSet> BitMatrix;
360 typedef std::vector<const Atom*> AtomMappingTable;
361 typedef std::vector<std::size_t> AtomIndexList;
362 typedef std::vector<std::size_t> BondMappingStack;
363 typedef std::deque<std::size_t> AtomQueue;
364 typedef std::set<ABMappingMask> UniqueMappingList;
365 typedef std::vector<const Atom*> AtomList;
366 typedef std::vector<const Bond*> BondList;
367 typedef std::vector<MatchExpression<Atom, MolecularGraph>::SharedPointer> AtomMatchExprTable;
368 typedef std::vector<MatchExpression<Bond, MolecularGraph>::SharedPointer> BondMatchExprTable;
373 AtomMatchExpressionFunction atomMatchExprFunc;
374 BondMatchExpressionFunction bondMatchExprFunc;
375 MolecularGraphMatchExpressionFunction molGraphMatchExprFunc;
376 BitMatrix atomEquivMatrix;
377 BitMatrix bondEquivMatrix;
378 AtomQueue termQueryAtoms;
379 AtomIndexList termTargetAtoms;
380 BondMappingStack bondMappingStack;
381 AtomMappingTable queryAtomMapping;
382 ABMappingMask mappingMask;
386 ABMappingList foundMappings;
387 UniqueMappingList uniqueMappings;
388 AtomMatchExprTable atomMatchExprTable;
389 BondMatchExprTable bondMatchExprTable;
390 MolGraphMatchExprPtr molGraphMatchExpr;
391 AtomList postMappingMatchAtoms;
392 BondList postMappingMatchBonds;
393 MappingCache mappingCache;
398 bool maxMappingsOnly;
399 std::size_t numQueryAtoms;
400 std::size_t numQueryBonds;
401 std::size_t numTargetAtoms;
402 std::size_t numTargetBonds;
403 std::size_t numMappedAtoms;
404 std::size_t currMaxSubstructureSize;
405 std::size_t maxBondStackSize;
406 std::size_t maxNumMappings;
407 std::size_t minSubstructureSize;
Definition of the class CDPL::Chem::AtomBondMapping.
Definition of the 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 the class CDPL::Chem::MatchExpression.
Definition of the class CDPL::Util::ObjectStack.
A data structure for the common storage of related atom to atom and bond to bond mappings.
Definition: AtomBondMapping.hpp:55
Atom.
Definition: Atom.hpp:52
Bond.
Definition: Bond.hpp:50
CommonConnectedSubstructureSearch.
Definition: CommonConnectedSubstructureSearch.hpp:63
std::function< const MolGraphMatchExprPtr &(const MolecularGraph &)> MolecularGraphMatchExpressionFunction
Definition: CommonConnectedSubstructureSearch.hpp:86
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:77
std::function< const AtomMatchExprPtr &(const Atom &)> AtomMatchExpressionFunction
Definition: CommonConnectedSubstructureSearch.hpp:84
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)
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:82
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
Definition: CommonConnectedSubstructureSearch.hpp:72
void setMolecularGraphMatchExpressionFunction(const MolecularGraphMatchExpressionFunction &func)
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
Definition: CommonConnectedSubstructureSearch.hpp:85
CommonConnectedSubstructureSearch & operator=(const CommonConnectedSubstructureSearch &)=delete
void setBondMatchExpressionFunction(const BondMatchExpressionFunction &func)
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.
A generic boolean expression interface for the implementation of query/target object equivalence test...
Definition: MatchExpression.hpp:75
MolecularGraph.
Definition: MolecularGraph.hpp:52
bool operator<(const Array< ValueType > &array1, const Array< ValueType > &array2)
Less than comparison operator.
boost::dynamic_bitset BitSet
A 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.