29 #ifndef CDPL_CHEM_MAXCOMMONATOMSUBSTRUCTURESEARCH_HPP
30 #define CDPL_CHEM_MAXCOMMONATOMSUBSTRUCTURESEARCH_HPP
37 #include <boost/iterator/indirect_iterator.hpp>
74 typedef std::vector<AtomBondMapping*> ABMappingList;
86 typedef boost::indirect_iterator<ABMappingList::iterator, AtomBondMapping>
MappingIterator;
91 typedef boost::indirect_iterator<ABMappingList::const_iterator, const AtomBondMapping>
ConstMappingIterator;
303 void initMatchExpressions();
305 bool buildAssocGraph();
307 bool findAssocGraphCliques(std::size_t);
308 bool isLegal(
const AGNode*);
312 bool hasPostMappingMatchExprs()
const;
315 bool foundMappingUnique();
317 void clearMappings();
319 void freeAtomBondMapping();
320 void freeAtomBondMappings();
321 void freeAssocGraph();
327 AGNode* allocAGNode(
const Atom*,
const Atom*);
328 AGEdge* allocAGEdge(
const Bond*,
const Bond*);
330 typedef std::vector<const AGEdge*> AGraphEdgeList;
336 void setQueryAtom(
const Atom*);
337 const Atom* getQueryAtom()
const;
339 void setAssocAtom(
const Atom*);
340 const Atom* getAssocAtom()
const;
342 void addEdge(
const AGEdge*);
344 bool isConnected(
const AGNode*)
const;
345 const AGEdge* findEdge(
const AGNode*)
const;
349 void setIndex(std::size_t idx);
353 const Atom* queryAtom;
354 const Atom* assocAtom;
356 AGraphEdgeList bondEdges;
363 void setQueryBond(
const Bond*);
364 const Bond* getQueryBond()
const;
366 void setAssocBond(
const Bond*);
367 const Bond* getAssocBond()
const;
369 void setNode1(
const AGNode*);
370 void setNode2(
const AGNode*);
372 const AGNode* getNode1()
const;
373 const AGNode* getNode2()
const;
375 const AGNode* getOther(
const AGNode*)
const;
378 const Bond* queryBond;
379 const Bond* assocBond;
388 void initQueryAtomMask(std::size_t);
389 void initTargetAtomMask(std::size_t);
391 void initQueryBondMask(std::size_t);
392 void initTargetBondMask(std::size_t);
394 void setQueryAtomBit(std::size_t);
395 void setTargetAtomBit(std::size_t);
397 void setQueryBondBit(std::size_t);
398 void setTargetBondBit(std::size_t);
402 bool operator<(
const ABMappingMask&)
const;
403 bool operator>(
const ABMappingMask&)
const;
414 typedef std::vector<AGNode*> AGraphNodeList;
415 typedef std::vector<AGraphNodeList> AGraphNodeMatrix;
416 typedef std::set<ABMappingMask> UniqueMappingList;
417 typedef std::vector<const Atom*> AtomList;
418 typedef std::vector<const Bond*> BondList;
419 typedef std::vector<MatchExpression<Atom, MolecularGraph>::SharedPointer> AtomMatchExprTable;
420 typedef std::vector<MatchExpression<Bond, MolecularGraph>::SharedPointer> BondMatchExprTable;
421 typedef Util::ObjectStack<AGNode> NodeCache;
422 typedef Util::ObjectStack<AGEdge> EdgeCache;
423 typedef Util::ObjectStack<AtomBondMapping> MappingCache;
425 const MolecularGraph* query;
426 const MolecularGraph* target;
427 AGraphNodeMatrix nodeMatrix;
428 ABMappingList foundMappings;
429 UniqueMappingList uniqueMappings;
430 AGraphEdgeList cliqueEdges;
431 AGraphNodeList cliqueNodes;
432 ABMappingMask mappingMask;
433 AtomMatchExprTable atomMatchExprTable;
434 BondMatchExprTable bondMatchExprTable;
435 MolGraphMatchExprPtr molGraphMatchExpr;
436 AtomList postMappingMatchAtoms;
437 BondList postMappingMatchBonds;
440 MappingCache mappingCache;
445 bool maxBondMappingsOnly;
446 std::size_t numQueryAtoms;
447 std::size_t numQueryBonds;
448 std::size_t numTargetAtoms;
449 std::size_t numTargetBonds;
450 std::size_t maxAtomSubstructureSize;
451 std::size_t maxBondSubstructureSize;
452 std::size_t currNumNullNodes;
453 std::size_t minNumNullNodes;
454 std::size_t maxNumMappings;
455 std::size_t minSubstructureSize;
456 std::size_t currNodeIdx;
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
std::shared_ptr< MatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MatchExpression instances.
Definition: MatchExpression.hpp:81
Computes the maximum common atom substructure between a query and a target molecular graph by reducin...
Definition: MaxCommonAtomSubstructureSearch.hpp:72
MaxCommonAtomSubstructureSearch(const MaxCommonAtomSubstructureSearch &)=delete
AtomBondMapping & getMapping(std::size_t idx)
Returns a non-const reference to the stored atom/bond mapping object at index idx.
MaxCommonAtomSubstructureSearch(const MolecularGraph &query)
Constructs and initializes a MaxCommonAtomSubstructureSearch instance for the specified query structu...
bool mappingExists(const MolecularGraph &target)
Searches for a common substructure between the query and the specified target molecular graph.
MappingIterator getMappingsEnd()
Returns a mutable iterator pointing to the end of the stored atom/bond mapping objects.
MappingIterator begin()
Returns a mutable iterator pointing to the beginning of the stored atom/bond mapping objects.
bool findAllMappings(const MolecularGraph &target)
Searches for all atom/bond mappings of query subgraphs to substructures of the specified target molec...
MappingIterator end()
Returns a mutable iterator pointing to the end of the stored atom/bond mapping objects.
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::iterator, AtomBondMapping > MappingIterator
A mutable random access iterator used to iterate over the stored atom/bond mapping objects.
Definition: MaxCommonAtomSubstructureSearch.hpp:86
std::size_t getMaxNumMappings() const
Returns the specified limit on the number of stored atom/bond mappings.
MaxCommonAtomSubstructureSearch()
Constructs and initializes a MaxCommonAtomSubstructureSearch instance.
bool uniqueMappingsOnly() const
Tells whether duplicate atom/bond mappings are discarded.
void setMinSubstructureSize(std::size_t min_size)
Allows to specify the minimum accepted common substructure size.
ConstMappingIterator getMappingsEnd() const
Returns a constant 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 getNumMappings() const
Returns the number of atom/bond mappings that were recorded in the last search for common substructur...
bool findMaxBondMappings(const MolecularGraph &target)
Searches for all atom/bond mappings of query subgraphs to substructures of the specified target molec...
void setQuery(const MolecularGraph &query)
Allows to specify a new query structure.
ConstMappingIterator getMappingsBegin() const
Returns a constant iterator pointing to the beginning of the stored atom/bond mapping objects.
ConstMappingIterator end() const
Returns a constant iterator pointing to the end of the stored atom/bond mapping objects.
MaxCommonAtomSubstructureSearch & operator=(const MaxCommonAtomSubstructureSearch &)=delete
MappingIterator getMappingsBegin()
Returns a mutable iterator pointing to the beginning of the stored atom/bond mapping objects.
std::size_t getMinSubstructureSize() const
Returns the minimum accepted common substructure size.
void uniqueMappingsOnly(bool unique)
Allows to specify whether or not to store only unique atom/bond mappings.
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: MaxCommonAtomSubstructureSearch.hpp:91
~MaxCommonAtomSubstructureSearch()
Destructor.
std::shared_ptr< MaxCommonAtomSubstructureSearch > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MaxCommonAtomSubstructureSearch i...
Definition: MaxCommonAtomSubstructureSearch.hpp:81
void setMaxNumMappings(std::size_t max_num_mappings)
Allows to specify a limit on the number of stored atom/bond mappings.
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.