29 #ifndef CDPL_CHEM_MAXCOMMONBONDSUBSTRUCTURESEARCH_HPP
30 #define CDPL_CHEM_MAXCOMMONBONDSUBSTRUCTURESEARCH_HPP
37 #include <boost/iterator/indirect_iterator.hpp>
79 typedef std::vector<AtomBondMapping*> ABMappingList;
91 typedef boost::indirect_iterator<ABMappingList::iterator, AtomBondMapping>
MappingIterator;
96 typedef boost::indirect_iterator<ABMappingList::const_iterator, const AtomBondMapping>
ConstMappingIterator;
291 void initMatchExpressions();
293 bool findEquivAtoms();
295 bool atomsCompatible(
const Bond&,
const Bond&)
const;
297 const Atom* getCommonAtom(
const Bond&,
const Bond&)
const;
299 bool buildAssocGraph();
301 bool findAssocGraphCliques(std::size_t);
302 bool isLegal(
const AGNode*);
304 void undoAtomMapping(std::size_t);
308 bool hasPostMappingMatchExprs()
const;
311 bool foundMappingUnique(
bool);
313 void clearMappings();
316 void freeAtomBondMapping();
318 void freeAssocGraph();
319 void freeAtomBondMappings();
323 AGNode* allocAGNode(
const Bond*,
const Bond*);
324 AGEdge* allocAGEdge(
const Atom*,
const Atom*);
326 typedef std::vector<const AGEdge*> AGraphEdgeList;
332 void setQueryBond(
const Bond*);
333 const Bond* getQueryBond()
const;
335 void setAssocBond(
const Bond*);
336 const Bond* getAssocBond()
const;
338 void addEdge(
const AGEdge*);
340 bool isConnected(
const AGNode*)
const;
341 const AGEdge* findEdge(
const AGNode*)
const;
345 void setIndex(std::size_t idx);
349 const Bond* queryBond;
350 const Bond* assocBond;
352 AGraphEdgeList atomEdges;
359 void setQueryAtom(
const Atom*);
360 const Atom* getQueryAtom()
const;
362 void setAssocAtom(
const Atom*);
363 const Atom* getAssocAtom()
const;
365 void setNode1(
const AGNode*);
366 void setNode2(
const AGNode*);
368 const AGNode* getNode1()
const;
369 const AGNode* getNode2()
const;
371 const AGNode* getOther(
const AGNode*)
const;
374 const Atom* queryAtom;
375 const Atom* assocAtom;
384 void initQueryAtomMask(std::size_t);
385 void initTargetAtomMask(std::size_t);
387 void initQueryBondMask(std::size_t);
388 void initTargetBondMask(std::size_t);
390 void setQueryAtomBit(std::size_t);
391 void setTargetAtomBit(std::size_t);
393 void resetQueryAtomBit(std::size_t);
394 void resetTargetAtomBit(std::size_t);
396 bool testQueryAtomBit(std::size_t)
const;
397 bool testTargetAtomBit(std::size_t)
const;
399 void setQueryBondBit(std::size_t);
400 void setTargetBondBit(std::size_t);
402 void resetQueryAtomBits();
403 void resetTargetAtomBits();
405 void resetBondBits();
407 bool operator<(
const ABMappingMask&)
const;
408 bool operator>(
const ABMappingMask&)
const;
419 typedef std::vector<Util::BitSet> BitMatrix;
420 typedef std::vector<AGNode*> AGraphNodeList;
421 typedef std::vector<AGraphNodeList> AGraphNodeMatrix;
422 typedef std::set<ABMappingMask> UniqueMappingList;
423 typedef std::vector<const Atom*> AtomList;
424 typedef std::vector<const Bond*> BondList;
425 typedef std::vector<MatchExpression<Atom, MolecularGraph>::SharedPointer> AtomMatchExprTable;
426 typedef std::vector<MatchExpression<Bond, MolecularGraph>::SharedPointer> BondMatchExprTable;
427 typedef Util::ObjectStack<AGNode> NodeCache;
428 typedef Util::ObjectStack<AGEdge> EdgeCache;
429 typedef Util::ObjectStack<AtomBondMapping> MappingCache;
431 const MolecularGraph* query;
432 const MolecularGraph* target;
433 BitMatrix atomEquivMatrix;
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 std::size_t numQueryAtoms;
453 std::size_t numQueryBonds;
454 std::size_t numTargetAtoms;
455 std::size_t numTargetBonds;
456 std::size_t maxBondSubstructureSize;
457 std::size_t currNumNullNodes;
458 std::size_t minNumNullNodes;
459 std::size_t maxNumMappings;
460 std::size_t minSubstructureSize;
461 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 bond substructures between a query and a target molecular graph.
Definition: MaxCommonBondSubstructureSearch.hpp:77
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 const Chem::AtomBondMapping objects.
MaxCommonBondSubstructureSearch()
Constructs and initializes the 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 the MaxCommonBondSubstructureSearch instance for the query molecular graph...
bool findMappings(const MolecularGraph &target)
Searches for all atom/bond mappings of query subgraphs to substructures of the target molecular graph...
MappingIterator getMappingsBegin()
Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping objects.
~MaxCommonBondSubstructureSearch()
Destructor.
MappingIterator begin()
Returns a mutable iterator pointing to the beginning of the stored Chem::AtomBondMapping 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:86
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 const Chem::AtomBondMapping objects.
ConstMappingIterator getMappingsBegin() const
Returns a constant iterator pointing to the beginning of the stored const Chem::AtomBondMapping objec...
MaxCommonBondSubstructureSearch(const MaxCommonBondSubstructureSearch &)=delete
void setQuery(const MolecularGraph &query)
Sets query as the new query molecular graph.
bool mappingExists(const MolecularGraph &target)
Searches for a common substructure between the query and the target molecular graph target.
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: MaxCommonBondSubstructureSearch.hpp:96
MappingIterator getMappingsEnd()
Returns a mutable iterator pointing to the end of the stored Chem::AtomBondMapping objects.
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...
boost::indirect_iterator< ABMappingList::iterator, AtomBondMapping > MappingIterator
A mutable random access iterator used to iterate over the stored Chem::AtomBondMapping objects.
Definition: MaxCommonBondSubstructureSearch.hpp:91
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.