29 #ifndef CDPL_CHEM_MAXCOMMONBONDSUBSTRUCTURESEARCH_HPP
30 #define CDPL_CHEM_MAXCOMMONBONDSUBSTRUCTURESEARCH_HPP
37 #include <boost/iterator/indirect_iterator.hpp>
73 typedef std::vector<AtomBondMapping*> ABMappingList;
85 typedef boost::indirect_iterator<ABMappingList::iterator, AtomBondMapping>
MappingIterator;
90 typedef boost::indirect_iterator<ABMappingList::const_iterator, const AtomBondMapping>
ConstMappingIterator;
285 void initMatchExpressions();
287 bool findEquivAtoms();
289 bool atomsCompatible(
const Bond&,
const Bond&)
const;
291 const Atom* getCommonAtom(
const Bond&,
const Bond&)
const;
293 bool buildAssocGraph();
295 bool findAssocGraphCliques(std::size_t);
296 bool isLegal(
const AGNode*);
298 void undoAtomMapping(std::size_t);
302 bool hasPostMappingMatchExprs()
const;
305 bool foundMappingUnique(
bool);
307 void clearMappings();
310 void freeAtomBondMapping();
312 void freeAssocGraph();
313 void freeAtomBondMappings();
317 AGNode* allocAGNode(
const Bond*,
const Bond*);
318 AGEdge* allocAGEdge(
const Atom*,
const Atom*);
320 typedef std::vector<const AGEdge*> AGraphEdgeList;
326 void setQueryBond(
const Bond*);
327 const Bond* getQueryBond()
const;
329 void setAssocBond(
const Bond*);
330 const Bond* getAssocBond()
const;
332 void addEdge(
const AGEdge*);
334 bool isConnected(
const AGNode*)
const;
335 const AGEdge* findEdge(
const AGNode*)
const;
339 void setIndex(std::size_t idx);
343 const Bond* queryBond;
344 const Bond* assocBond;
346 AGraphEdgeList atomEdges;
353 void setQueryAtom(
const Atom*);
354 const Atom* getQueryAtom()
const;
356 void setAssocAtom(
const Atom*);
357 const Atom* getAssocAtom()
const;
359 void setNode1(
const AGNode*);
360 void setNode2(
const AGNode*);
362 const AGNode* getNode1()
const;
363 const AGNode* getNode2()
const;
365 const AGNode* getOther(
const AGNode*)
const;
368 const Atom* queryAtom;
369 const Atom* assocAtom;
378 void initQueryAtomMask(std::size_t);
379 void initTargetAtomMask(std::size_t);
381 void initQueryBondMask(std::size_t);
382 void initTargetBondMask(std::size_t);
384 void setQueryAtomBit(std::size_t);
385 void setTargetAtomBit(std::size_t);
387 void resetQueryAtomBit(std::size_t);
388 void resetTargetAtomBit(std::size_t);
390 bool testQueryAtomBit(std::size_t)
const;
391 bool testTargetAtomBit(std::size_t)
const;
393 void setQueryBondBit(std::size_t);
394 void setTargetBondBit(std::size_t);
396 void resetQueryAtomBits();
397 void resetTargetAtomBits();
399 void resetBondBits();
401 bool operator<(
const ABMappingMask&)
const;
402 bool operator>(
const ABMappingMask&)
const;
413 typedef std::vector<Util::BitSet> BitMatrix;
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 BitMatrix atomEquivMatrix;
428 AGraphNodeMatrix nodeMatrix;
429 ABMappingList foundMappings;
430 UniqueMappingList uniqueMappings;
431 AGraphEdgeList cliqueEdges;
432 AGraphNodeList cliqueNodes;
433 ABMappingMask mappingMask;
434 AtomMatchExprTable atomMatchExprTable;
435 BondMatchExprTable bondMatchExprTable;
436 MolGraphMatchExprPtr molGraphMatchExpr;
437 AtomList postMappingMatchAtoms;
438 BondList postMappingMatchBonds;
441 MappingCache mappingCache;
446 std::size_t numQueryAtoms;
447 std::size_t numQueryBonds;
448 std::size_t numTargetAtoms;
449 std::size_t numTargetBonds;
450 std::size_t maxBondSubstructureSize;
451 std::size_t currNumNullNodes;
452 std::size_t minNumNullNodes;
453 std::size_t maxNumMappings;
454 std::size_t minSubstructureSize;
455 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 bond substructure between a query and a target molecular graph by reducin...
Definition: MaxCommonBondSubstructureSearch.hpp:71
std::size_t getMinSubstructureSize() const
Returns the minimum accepted common substructure size.
AtomBondMapping & getMapping(std::size_t idx)
Returns a non-const reference to the stored atom/bond mapping object at index idx.
void setMaxNumMappings(std::size_t max_num_mappings)
Allows to specify a limit on the number of stored atom/bond mappings.
ConstMappingIterator getMappingsEnd() const
Returns a constant iterator pointing to the end of the stored atom/bond mapping objects.
MaxCommonBondSubstructureSearch()
Constructs and initializes a MaxCommonBondSubstructureSearch instance.
bool uniqueMappingsOnly() const
Tells whether duplicate atom/bond mappings are discarded.
std::size_t getMaxNumMappings() const
Returns the specified limit on the number of stored atom/bond mappings.
MaxCommonBondSubstructureSearch(const MolecularGraph &query)
Constructs and initializes a MaxCommonBondSubstructureSearch instance for the specified query structu...
bool findMappings(const MolecularGraph &target)
Searches for all atom/bond mappings of query subgraphs to substructures of the specified target molec...
MappingIterator getMappingsBegin()
Returns a mutable iterator pointing to the beginning of the stored atom/bond mapping objects.
~MaxCommonBondSubstructureSearch()
Destructor.
MappingIterator begin()
Returns a mutable 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...
void setMinSubstructureSize(std::size_t min_size)
Allows to specify the minimum accepted common substructure size.
void uniqueMappingsOnly(bool unique)
Allows to specify whether or not to store only unique atom/bond mappings.
std::shared_ptr< MaxCommonBondSubstructureSearch > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MaxCommonBondSubstructureSearch i...
Definition: MaxCommonBondSubstructureSearch.hpp:80
MaxCommonBondSubstructureSearch & operator=(const MaxCommonBondSubstructureSearch &)=delete
const AtomBondMapping & getMapping(std::size_t idx) const
Returns a const reference to the stored atom/bond mapping object at index idx.
ConstMappingIterator end() const
Returns a constant iterator pointing to the end of the stored atom/bond mapping objects.
ConstMappingIterator getMappingsBegin() const
Returns a constant iterator pointing to the beginning of the stored atom/bond mapping objects.
MaxCommonBondSubstructureSearch(const MaxCommonBondSubstructureSearch &)=delete
void setQuery(const MolecularGraph &query)
Allows to specify a new query structure.
bool mappingExists(const MolecularGraph &target)
Searches for a common substructure between the query and the specified target molecular graph.
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: MaxCommonBondSubstructureSearch.hpp:90
MappingIterator getMappingsEnd()
Returns a mutable iterator pointing to the end of the stored atom/bond mapping objects.
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.
boost::indirect_iterator< ABMappingList::iterator, AtomBondMapping > MappingIterator
A mutable random access iterator used to iterate over the stored atom/bond mapping objects.
Definition: MaxCommonBondSubstructureSearch.hpp:85
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.