Chemical Data Processing Library C++ API - Version 1.4.0
Reactor.hpp
Go to the documentation of this file.
1 /*
2  * Reactor.hpp
3  *
4  * This file is part of the Chemical Data Processing Toolkit
5  *
6  * Copyright (C) 2003 Thomas Seidel <thomas.seidel@univie.ac.at>
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this library; see the file COPYING. If not, write to
20  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
23 
29 #ifndef CDPL_CHEM_REACTOR_HPP
30 #define CDPL_CHEM_REACTOR_HPP
31 
32 #include <map>
33 #include <vector>
34 #include <utility>
35 #include <cstddef>
36 
37 #include "CDPL/Chem/APIPrefix.hpp"
38 #include "CDPL/Chem/Reaction.hpp"
40 #include "CDPL/Util/BitSet.hpp"
41 
42 
43 namespace CDPL
44 {
45 
46  namespace Chem
47  {
48 
61  {
62 
63  public:
68 
73 
78 
83 
88  Reactor(const Reaction& rxn_pattern);
89 
90  Reactor(const Reactor&) = delete;
91 
98 
99  Reactor& operator=(const Reactor&) = delete;
100 
105  void setReactionPattern(const Reaction& rxn_pattern);
106 
121  bool findReactionSites(Reaction& rxn_target);
122 
127  std::size_t getNumReactionSites() const;
128 
136  ReactionSite& getReactionSite(std::size_t idx);
137 
145  const ReactionSite& getReactionSite(std::size_t idx) const;
146 
152 
158 
164 
170 
176 
182 
188 
194 
209  void performReaction(const ReactionSite& rxn_site);
210 
211  private:
212  void init();
213 
214  void createAtoms(Molecule*);
215  void createBonds(Molecule*);
216 
217  void deleteBonds(const ReactionSite&, Molecule*) const;
218  void deleteAtoms(const ReactionSite&, Molecule*) const;
219 
220  void editAtoms() const;
221  void editBonds() const;
222 
223  void editStereoProperties() const;
224 
225  void editProdAtomStereoDescriptor(const Atom*, Atom*) const;
226  void editProdBondStereoDescriptor(const Bond*, Bond*) const;
227 
228  template <typename T>
229  void copyProperty(const T*, T*, const Base::LookupKey&) const;
230 
231  const Base::Any& getProperty(const Atom*, const Base::LookupKey&) const;
232  const Base::Any& getProperty(const Bond*, const Base::LookupKey&) const;
233 
234  Molecule* copyReactants(const ReactionSite&);
235 
236  Atom* getMappedTgtProdAtom(const Atom*) const;
237  Bond* getMappedTgtProdBond(const Bond*) const;
238 
239  typedef std::pair<std::size_t, std::size_t> IDPair;
240 
241  struct IDPairLessCmpFunc
242  {
243 
244  bool operator()(const IDPair&, const IDPair&) const;
245  };
246 
247  typedef std::pair<const Atom*, const Atom*> AtomPair;
248  typedef std::pair<const Bond*, const Bond*> BondPair;
249  typedef std::map<std::size_t, const Atom*> IDAtomMap;
250  typedef std::map<IDPair, const Bond*, IDPairLessCmpFunc> IDPairBondMap;
251  typedef std::map<const Atom*, Atom*> AtomMap;
252  typedef std::map<const Bond*, Bond*> BondMap;
253  typedef std::vector<AtomPair> AtomPairList;
254  typedef std::vector<BondPair> BondPairList;
255 
256  const Reaction* rxnPattern;
257  Reaction* rxnTarget;
258  ReactionSubstructureSearch rxnSiteSearch;
259  IDAtomMap reacAtomsToDelete;
260  IDAtomMap prodAtomsToCreate;
261  IDPairBondMap reacBondsToDelete;
262  IDPairBondMap prodBondsToCreate;
263  AtomPairList ptnAtomMapping;
264  BondPairList ptnBondMapping;
265  AtomMap tgtAtomMapping;
266  BondMap tgtBondMapping;
267  Util::BitSet mappedAtomMask;
268  };
269  } // namespace Chem
270 } // namespace CDPL
271 
272 #endif // CDPL_CHEM_REACTOR_HPP
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::ReactionSubstructureSearch.
Definition of class CDPL::Chem::Reaction.
Safe, type checked container for arbitrary data of variable type.
Definition: Any.hpp:60
Unique lookup key for control-parameter and property values.
Definition: LookupKey.hpp:54
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
Abstract base class representing a mutable molecular graph that owns its atoms and bonds.
Definition: Molecule.hpp:53
Reaction-level analogue of Chem::SubstructureSearch that locates atom/bond mappings of a query reacti...
Definition: ReactionSubstructureSearch.hpp:70
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: ReactionSubstructureSearch.hpp:83
boost::indirect_iterator< ABMappingList::iterator, AtomBondMapping > MappingIterator
A mutable random access iterator used to iterate over the stored atom/bond mapping objects.
Definition: ReactionSubstructureSearch.hpp:78
Abstract base class for chemical reactions composed of role-tagged Chem::Molecule components.
Definition: Reaction.hpp:59
Applies a Chem::Reaction template to the reactant components of a target Chem::Reaction to generate t...
Definition: Reactor.hpp:61
ReactionSiteIterator begin()
Returns a mutable iterator pointing to the beginning of the stored reaction-site data objects.
ReactionSubstructureSearch::ConstMappingIterator ConstReactionSiteIterator
A constant random access iterator used to iterate over the perceived reaction-sites.
Definition: Reactor.hpp:77
Reactor & operator=(const Reactor &)=delete
ConstReactionSiteIterator begin() const
Returns a constant iterator pointing to the beginning of the stored reaction-site data objects.
bool findReactionSites(Reaction &rxn_target)
Perceives all possible reaction-sites on the reactants of the given reaction target where the specifi...
AtomBondMapping ReactionSite
Stores information about perceived reaction-sites.
Definition: Reactor.hpp:67
ReactionSiteIterator getReactionSitesEnd()
Returns a mutable iterator pointing to the end of the stored reaction-site data objects.
ConstReactionSiteIterator getReactionSitesEnd() const
Returns a constant iterator pointing to the end of the stored reaction-site data objects.
~Reactor()
Destructor.
ReactionSiteIterator end()
Returns a mutable iterator pointing to the end of the stored reaction-site data objects.
Reactor()
Constructs and initializes a Reactor instance.
Reactor(const Reaction &rxn_pattern)
Constructs and initializes a Reactor instance for the specified reaction pattern.
Reactor(const Reactor &)=delete
void performReaction(const ReactionSite &rxn_site)
Performs a transformation of the target reactants to corresponding products at the specified reaction...
ReactionSubstructureSearch::MappingIterator ReactionSiteIterator
A mutable random access iterator used to iterate over the perceived reaction-sites.
Definition: Reactor.hpp:72
const ReactionSite & getReactionSite(std::size_t idx) const
Returns a const reference to the stored reaction-site data object at index idx.
ConstReactionSiteIterator getReactionSitesBegin() const
Returns a constant iterator pointing to the beginning of the stored reaction-site data objects.
void setReactionPattern(const Reaction &rxn_pattern)
Allows to specify a new reaction pattern for the transformation of reactants to products.
ReactionSiteIterator getReactionSitesBegin()
Returns a mutable iterator pointing to the beginning of the stored reaction-site data objects.
ConstReactionSiteIterator end() const
Returns a constant iterator pointing to the end of the stored reaction-site data objects.
std::size_t getNumReactionSites() const
Returns the number of recorded reactions-sites in the last call to findReactionSites().
ReactionSite & getReactionSite(std::size_t idx)
Returns a non-const reference to the stored reaction-site data object at index idx.
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.