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;
70 typedef std::vector<Pattern> PatternList;
87 typedef boost::transform_iterator<GetMolGraphFunc, PatternList::iterator>
PatternIterator;
285 bool edit(Molecule& mol,
const AtomMapping& mapping);
287 bool editAtomStereoDescriptors(Molecule& mol)
const;
288 bool editBondStereoDescriptors(Molecule& mol)
const;
290 void getExcludeMatches(
const MolecularGraph& molgraph);
292 bool createMatchedAtomAndBondMask(
const MolecularGraph& molgraph,
const AtomBondMapping& mapping,
295 Chem::Atom* getMappedAtomForID(
const AtomMapping& mapping, std::size_t
id)
const;
296 const Chem::Atom* getNeighbor(
const Atom* ctr_atom,
const Atom* excl_nbr)
const;
298 template <
typename T>
299 void copyProperty(
const T& src_cntnr,
T& tgt_cntnr,
const Base::LookupKey& key)
const;
301 template <
typename VT,
typename T>
302 bool copyPropertyWithChangeCheck(
const T& src_cntnr,
T& tgt_cntnr,
const Base::LookupKey& key)
const;
304 bool setStereoDescriptorWithChangeCheck(Atom& atom,
const StereoDescriptor& descr)
const;
305 bool setStereoDescriptorWithChangeCheck(Bond& bond,
const StereoDescriptor& descr)
const;
310 typedef std::vector<Util::BitSet*> BitSetList;
311 typedef std::vector<Atom*> AtomArray;
312 typedef std::unordered_set<Atom*> AtomSet;
313 typedef std::unordered_set<Bond*> BondSet;
315 PatternList searchPatterns;
316 PatternList excludePatterns;
318 BitSetList excludeMatches;
319 AtomArray resPtnAtomMapping;
320 AtomSet hybStateUpdateAtoms;
321 AtomSet configUpdateAtoms;
322 BondSet configUpdateBonds;
323 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:58
Abstract base class for data structures that represent chemical structures as molecular graphs.
Definition: MolecularGraph.hpp:60
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:66
Abstract base class representing a mutable molecular graph that owns and manages its atoms and bonds.
Definition: Molecule.hpp:53
Pattern-driven editor that rewrites matched substructures of a molecule according to a given editing ...
Definition: SubstructureEditor.hpp:66
PatternIterator getExcludePatternsEnd()
Returns a mutable iterator pointing to the end of the stored exclude pattern Chem::MolecularGraph obj...
ConstPatternIterator getExcludePatternsBegin() const
Returns a constant iterator pointing to the beginning of the stored exclude pattern const Chem::Molec...
ConstPatternIterator getExcludePatternsEnd() const
Returns a constant iterator pointing to the end of the stored exclude pattern const Chem::MolecularGr...
const MolecularGraph::SharedPointer & getSearchPattern(std::size_t idx) const
Returns the molecular graph of the substructure 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 used to iterate over the stored search/exclude pattern Chem::MolecularGraph object...
Definition: SubstructureEditor.hpp:87
void removeExcludePattern(const PatternIterator &it)
Removes the substructure exclude pattern pointed to by it.
std::size_t edit(const MolecularGraph &molgraph, Molecule &res_mol)
Copies the molecular graph molgraph into the molecule res_mol and then edits it by calling edit(Molec...
void removeSearchPattern(std::size_t idx)
Removes the substructure 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 pattern Chem::MolecularGrap...
PatternIterator getSearchPatternsEnd()
Returns a mutable iterator pointing to the end of the stored search pattern Chem::MolecularGraph obje...
PatternIterator getExcludePatternsBegin()
Returns a mutable iterator pointing to the beginning of the stored exclude pattern Chem::MolecularGra...
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 pattern const Chem::MolecularGra...
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:77
ConstPatternIterator getSearchPatternsBegin() const
Returns a constant iterator pointing to the beginning of the stored search pattern const Chem::Molecu...
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 used to iterate over the stored search/exclude pattern Chem::MolecularGraph objec...
Definition: SubstructureEditor.hpp:82
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 substructure exclude pattern at index idx.
void clearSearchPatterns()
Clears the current set of substructure search 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 substructure exclude pattern at index idx.
void removeSearchPattern(const PatternIterator &it)
Removes the substructure search pattern pointed to by it.
std::size_t edit(Molecule &mol)
Edits the molecule mol in place by applying the result pattern at every search pattern match that is ...
Searches for substructures of a target molecular graph that match the topology of a given query molec...
Definition: SubstructureSearch.hpp:78
std::shared_ptr< SubstructureSearch > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SubstructureSearch instances.
Definition: SubstructureSearch.hpp:90
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.