29 #ifndef CDPL_CHEM_MAXCOMMONATOMSUBSTRUCTURESEARCH_HPP
30 #define CDPL_CHEM_MAXCOMMONATOMSUBSTRUCTURESEARCH_HPP
37 #include <boost/iterator/indirect_iterator.hpp>
81 typedef std::vector<AtomBondMapping*> ABMappingList;
93 typedef boost::indirect_iterator<ABMappingList::iterator, AtomBondMapping>
MappingIterator;
98 typedef boost::indirect_iterator<ABMappingList::const_iterator, const AtomBondMapping>
ConstMappingIterator;
310 void initMatchExpressions();
312 bool buildAssocGraph();
314 bool findAssocGraphCliques(std::size_t);
315 bool isLegal(
const AGNode*);
319 bool hasPostMappingMatchExprs()
const;
322 bool foundMappingUnique();
324 void clearMappings();
326 void freeAtomBondMapping();
327 void freeAtomBondMappings();
328 void freeAssocGraph();
334 AGNode* allocAGNode(
const Atom*,
const Atom*);
335 AGEdge* allocAGEdge(
const Bond*,
const Bond*);
337 typedef std::vector<const AGEdge*> AGraphEdgeList;
343 void setQueryAtom(
const Atom*);
344 const Atom* getQueryAtom()
const;
346 void setAssocAtom(
const Atom*);
347 const Atom* getAssocAtom()
const;
349 void addEdge(
const AGEdge*);
351 bool isConnected(
const AGNode*)
const;
352 const AGEdge* findEdge(
const AGNode*)
const;
356 void setIndex(std::size_t idx);
360 const Atom* queryAtom;
361 const Atom* assocAtom;
363 AGraphEdgeList bondEdges;
370 void setQueryBond(
const Bond*);
371 const Bond* getQueryBond()
const;
373 void setAssocBond(
const Bond*);
374 const Bond* getAssocBond()
const;
376 void setNode1(
const AGNode*);
377 void setNode2(
const AGNode*);
379 const AGNode* getNode1()
const;
380 const AGNode* getNode2()
const;
382 const AGNode* getOther(
const AGNode*)
const;
385 const Bond* queryBond;
386 const Bond* assocBond;
395 void initQueryAtomMask(std::size_t);
396 void initTargetAtomMask(std::size_t);
398 void initQueryBondMask(std::size_t);
399 void initTargetBondMask(std::size_t);
401 void setQueryAtomBit(std::size_t);
402 void setTargetAtomBit(std::size_t);
404 void setQueryBondBit(std::size_t);
405 void setTargetBondBit(std::size_t);
409 bool operator<(
const ABMappingMask&)
const;
410 bool operator>(
const ABMappingMask&)
const;
421 typedef std::vector<AGNode*> AGraphNodeList;
422 typedef std::vector<AGraphNodeList> AGraphNodeMatrix;
423 typedef std::set<ABMappingMask> UniqueMappingList;
424 typedef std::vector<const Atom*> AtomList;
425 typedef std::vector<const Bond*> BondList;
426 typedef std::vector<MatchExpression<Atom, MolecularGraph>::SharedPointer> AtomMatchExprTable;
427 typedef std::vector<MatchExpression<Bond, MolecularGraph>::SharedPointer> BondMatchExprTable;
428 typedef Util::ObjectStack<AGNode> NodeCache;
429 typedef Util::ObjectStack<AGEdge> EdgeCache;
430 typedef Util::ObjectStack<AtomBondMapping> MappingCache;
432 const MolecularGraph* query;
433 const MolecularGraph* target;
434 AGraphNodeMatrix nodeMatrix;
435 ABMappingList foundMappings;
436 UniqueMappingList uniqueMappings;
437 AGraphEdgeList cliqueEdges;
438 AGraphNodeList cliqueNodes;
439 ABMappingMask mappingMask;
440 AtomMatchExprTable atomMatchExprTable;
441 BondMatchExprTable bondMatchExprTable;
442 MolGraphMatchExprPtr molGraphMatchExpr;
443 AtomList postMappingMatchAtoms;
444 BondList postMappingMatchBonds;
447 MappingCache mappingCache;
452 bool maxBondMappingsOnly;
453 std::size_t numQueryAtoms;
454 std::size_t numQueryBonds;
455 std::size_t numTargetAtoms;
456 std::size_t numTargetBonds;
457 std::size_t maxAtomSubstructureSize;
458 std::size_t maxBondSubstructureSize;
459 std::size_t currNumNullNodes;
460 std::size_t minNumNullNodes;
461 std::size_t maxNumMappings;
462 std::size_t minSubstructureSize;
463 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:58
Abstract base class representing a chemical bond between two atoms (represented by Chem::Atom instanc...
Definition: Bond.hpp:54
std::shared_ptr< MatchExpression > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MatchExpression instances.
Definition: MatchExpression.hpp:81
Searches for the maximum common atom substructures between a query and a target molecular graph.
Definition: MaxCommonAtomSubstructureSearch.hpp:79
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 the MaxCommonAtomSubstructureSearch instance for the query molecular graph...
bool mappingExists(const MolecularGraph &target)
Searches for a common substructure between the query and the target molecular graph target.
MappingIterator getMappingsEnd()
Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping objects.
MappingIterator begin()
Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping objects.
bool findAllMappings(const MolecularGraph &target)
Searches for all atom/bond mappings of query subgraphs to substructures of the target molecular graph...
MappingIterator end()
Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping 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 Chem::AtomBondMapping objects.
Definition: MaxCommonAtomSubstructureSearch.hpp:93
std::size_t getMaxNumMappings() const
Returns the specified limit on the number of stored atom/bond mappings.
MaxCommonAtomSubstructureSearch()
Constructs and initializes the 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 const Chem::AtomBondMapping objects.
ConstMappingIterator begin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objec...
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 target molecular graph...
void setQuery(const MolecularGraph &query)
Sets query as the new query molecular graph.
ConstMappingIterator getMappingsBegin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objec...
ConstMappingIterator end() const
Returns a constant iterator pointing to the end of the stored const Chem::AtomBondMapping objects.
MaxCommonAtomSubstructureSearch & operator=(const MaxCommonAtomSubstructureSearch &)=delete
MappingIterator getMappingsBegin()
Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping 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 const Chem::AtomBondMapping objects...
Definition: MaxCommonAtomSubstructureSearch.hpp:98
~MaxCommonAtomSubstructureSearch()
Destructor.
std::shared_ptr< MaxCommonAtomSubstructureSearch > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MaxCommonAtomSubstructureSearch i...
Definition: MaxCommonAtomSubstructureSearch.hpp:88
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 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.