29 #ifndef CDPL_CHEM_SUBSTRUCTUREEDITOR_HPP
30 #define CDPL_CHEM_SUBSTRUCTUREEDITOR_HPP
35 #include <unordered_set>
37 #include <boost/iterator/transform_iterator.hpp>
53 class StereoDescriptor;
71 typedef std::vector<Pattern> PatternList;
88 typedef boost::transform_iterator<GetMolGraphFunc, PatternList::iterator>
PatternIterator;
284 bool edit(Molecule& mol,
const AtomMapping& mapping);
286 bool editAtomStereoDescriptors(Molecule& mol)
const;
287 bool editBondStereoDescriptors(Molecule& mol)
const;
289 void getExcludeMatches(
const MolecularGraph& molgraph);
291 bool createMatchedAtomAndBondMask(
const MolecularGraph& molgraph,
const AtomBondMapping& mapping,
294 Chem::Atom* getMappedAtomForID(
const AtomMapping& mapping, std::size_t
id)
const;
295 const Chem::Atom* getNeighbor(
const Atom* ctr_atom,
const Atom* excl_nbr)
const;
297 template <
typename T>
298 void copyProperty(
const T& src_cntnr,
T& tgt_cntnr,
const Base::LookupKey& key)
const;
300 template <
typename VT,
typename T>
301 bool copyPropertyWithChangeCheck(
const T& src_cntnr,
T& tgt_cntnr,
const Base::LookupKey& key)
const;
303 bool setStereoDescriptorWithChangeCheck(Atom& atom,
const StereoDescriptor& descr)
const;
304 bool setStereoDescriptorWithChangeCheck(Bond& bond,
const StereoDescriptor& descr)
const;
309 typedef std::vector<Util::BitSet*> BitSetList;
310 typedef std::vector<Atom*> AtomArray;
311 typedef std::unordered_set<Atom*> AtomSet;
312 typedef std::unordered_set<Bond*> BondSet;
314 PatternList searchPatterns;
315 PatternList excludePatterns;
317 BitSetList excludeMatches;
318 AtomArray resPtnAtomMapping;
319 AtomSet hybStateUpdateAtoms;
320 AtomSet configUpdateAtoms;
321 BondSet configUpdateBonds;
322 BitSetCache bitSetCache;
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::MolecularGraph.
Definition of class CDPL::Util::ObjectStack.
Definition of class CDPL::Chem::SubstructureSearch.
Unique lookup key for control-parameter and property values.
Definition: LookupKey.hpp:54
Abstract base class representing a chemical atom and its bonded neighborhood.
Definition: Atom.hpp:57
Abstract base class for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:63
Abstract base class representing a mutable molecular graph that owns its atoms and bonds.
Definition: Molecule.hpp:53
Pattern-driven editor that rewrites matched substructures of a Chem::Molecule using a result template...
Definition: SubstructureEditor.hpp:67
PatternIterator getExcludePatternsEnd()
Returns a mutable iterator pointing to the end of the stored exclude patterns.
ConstPatternIterator getExcludePatternsBegin() const
Returns a constant iterator pointing to the beginning of the stored exclude patterns.
ConstPatternIterator getExcludePatternsEnd() const
Returns a constant iterator pointing to the end of the stored exclude patterns.
const MolecularGraph::SharedPointer & getSearchPattern(std::size_t idx) const
Returns the molecular graph of the search pattern at index idx.
const MolecularGraph::SharedPointer & getResultPattern() const
Returns the currently set result pattern.
void addExcludePattern(const MolecularGraph::SharedPointer &molgraph)
Appends a new substructure exclude pattern to the current set of patterns.
boost::transform_iterator< GetMolGraphFunc, PatternList::iterator > PatternIterator
A mutable iterator over the molecular graphs of the stored search/exclude patterns.
Definition: SubstructureEditor.hpp:88
void removeExcludePattern(const PatternIterator &it)
Removes the exclude pattern pointed to by it.
std::size_t edit(const MolecularGraph &molgraph, Molecule &res_mol)
Copies molgraph into res_mol and then edits res_mol via edit(Molecule&).
void removeSearchPattern(std::size_t idx)
Removes the search pattern at index idx.
void setResultPattern(const MolecularGraph::SharedPointer &pattern)
Sets the result pattern that defines how each matched search-pattern instance will be rewritten.
PatternIterator getSearchPatternsBegin()
Returns a mutable iterator pointing to the beginning of the stored search patterns.
PatternIterator getSearchPatternsEnd()
Returns a mutable iterator pointing to the end of the stored search patterns.
PatternIterator getExcludePatternsBegin()
Returns a mutable iterator pointing to the beginning of the stored exclude patterns.
SubstructureEditor()
Constructs the SubstructureEditor instance.
SubstructureEditor(const SubstructureEditor &editor)
Constructs a copy of the SubstructureEditor instance editor.
~SubstructureEditor()
Destructor.
ConstPatternIterator getSearchPatternsEnd() const
Returns a constant iterator pointing to the end of the stored search patterns.
void clear()
Clears the current editing result pattern and the sets of substructure search and exclude patterns.
std::shared_ptr< SubstructureEditor > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SubstructureEditor instances.
Definition: SubstructureEditor.hpp:78
ConstPatternIterator getSearchPatternsBegin() const
Returns a constant iterator pointing to the beginning of the stored search patterns.
void addSearchPattern(const MolecularGraph::SharedPointer &molgraph)
Appends a new substructure search pattern to the current set of patterns.
boost::transform_iterator< GetMolGraphFunc, PatternList::const_iterator > ConstPatternIterator
A constant iterator over the molecular graphs of the stored search/exclude patterns.
Definition: SubstructureEditor.hpp:83
SubstructureEditor & operator=(const SubstructureEditor &gen)
Copies the state of the SubstructureEditor instance gen.
std::size_t getNumSearchPatterns() const
Returns the number of stored substructure search patterns.
const MolecularGraph::SharedPointer & getExcludePattern(std::size_t idx) const
Returns the molecular graph of the exclude pattern at index idx.
void clearSearchPatterns()
Clears the current set of substructuresearch patterns.
void clearExcludePatterns()
Clears the current set of substructure exclude patterns.
std::size_t getNumExcludePatterns() const
Returns the number of stored substructure-exclude patterns.
void removeExcludePattern(std::size_t idx)
Removes the exclude pattern at index idx.
void removeSearchPattern(const PatternIterator &it)
Removes the search pattern pointed to by it.
std::size_t edit(Molecule &mol)
Edits mol in place by applying the result pattern at every search-pattern match that is not covered b...
Subgraph-isomorphism search of a query molecular graph against a target molecular graph,...
Definition: SubstructureSearch.hpp:74
std::shared_ptr< SubstructureSearch > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SubstructureSearch instances.
Definition: SubstructureSearch.hpp:86
constexpr unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.