Chemical Data Processing Library C++ API - Version 1.1.1
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 
53  {
54 
55  public:
60 
65 
70 
75 
80  Reactor(const Reaction& rxn_pattern);
81 
88 
93  void setReactionPattern(const Reaction& rxn_pattern);
94 
109  bool findReactionSites(Reaction& rxn_target);
110 
115  std::size_t getNumReactionSites() const;
116 
124  ReactionSite& getReactionSite(std::size_t idx);
125 
133  const ReactionSite& getReactionSite(std::size_t idx) const;
134 
140 
146 
152 
158 
164 
170 
176 
182 
197  void performReaction(const ReactionSite& rxn_site);
198 
199  private:
200  Reactor(const Reactor&);
201 
202  Reactor& operator=(const Reactor&);
203 
204  void init();
205 
206  void createAtoms(Molecule*);
207  void createBonds(Molecule*);
208 
209  void deleteBonds(const ReactionSite&, Molecule*) const;
210  void deleteAtoms(const ReactionSite&, Molecule*) const;
211 
212  void editAtoms() const;
213  void editBonds() const;
214 
215  void editStereoProperties() const;
216 
217  void editProdAtomStereoDescriptor(const Atom*, Atom*) const;
218  void editProdBondStereoDescriptor(const Bond*, Bond*) const;
219 
220  template <typename T>
221  void copyProperty(const T*, T*, const Base::LookupKey&) const;
222 
223  const Base::Any& getProperty(const Atom*, const Base::LookupKey&) const;
224  const Base::Any& getProperty(const Bond*, const Base::LookupKey&) const;
225 
226  Molecule* copyReactants(const ReactionSite&);
227 
228  Atom* getMappedTgtProdAtom(const Atom*) const;
229  Bond* getMappedTgtProdBond(const Bond*) const;
230 
231  typedef std::pair<std::size_t, std::size_t> IDPair;
232 
233  struct IDPairLessCmpFunc
234  {
235 
236  bool operator()(const IDPair&, const IDPair&) const;
237  };
238 
239  typedef std::pair<const Atom*, const Atom*> AtomPair;
240  typedef std::pair<const Bond*, const Bond*> BondPair;
241  typedef std::map<std::size_t, const Atom*> IDAtomMap;
242  typedef std::map<IDPair, const Bond*, IDPairLessCmpFunc> IDPairBondMap;
243  typedef std::map<const Atom*, Atom*> AtomMap;
244  typedef std::map<const Bond*, Bond*> BondMap;
245  typedef std::vector<AtomPair> AtomPairList;
246  typedef std::vector<BondPair> BondPairList;
247 
248  const Reaction* rxnPattern;
249  Reaction* rxnTarget;
250  ReactionSubstructureSearch rxnSiteSearch;
251  IDAtomMap reacAtomsToDelete;
252  IDAtomMap prodAtomsToCreate;
253  IDPairBondMap reacBondsToDelete;
254  IDPairBondMap prodBondsToCreate;
255  AtomPairList ptnAtomMapping;
256  BondPairList ptnBondMapping;
257  AtomMap tgtAtomMapping;
258  BondMap tgtBondMapping;
259  Util::BitSet mappedAtomMask;
260  };
261  } // namespace Chem
262 } // namespace CDPL
263 
264 #endif // CDPL_CHEM_REACTOR_HPP
CDPL::Chem::Reactor::ReactionSite
AtomBondMapping ReactionSite
Stores information about perceived reaction-sites.
Definition: Reactor.hpp:59
CDPL::Chem::Reactor::ReactionSiteIterator
ReactionSubstructureSearch::MappingIterator ReactionSiteIterator
A mutable random access iterator used to iterate over the perceived reaction-sites.
Definition: Reactor.hpp:64
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL::Chem::ReactionSubstructureSearch::MappingIterator
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:70
CDPL_CHEM_API
#define CDPL_CHEM_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Chem::Bond
Bond.
Definition: Bond.hpp:50
CDPL::Chem::Reactor::getReactionSitesEnd
ConstReactionSiteIterator getReactionSitesEnd() const
Returns a constant iterator pointing to the end of the stored reaction-site data objects.
CDPL::Chem::Reactor::getNumReactionSites
std::size_t getNumReactionSites() const
Returns the number of recorded reactions-sites in the last call to findReactionSites().
CDPL::Chem::Reactor::begin
ReactionSiteIterator begin()
Returns a mutable iterator pointing to the beginning of the stored reaction-site data objects.
CDPL::Util::BitSet
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
ReactionSubstructureSearch.hpp
Definition of the class CDPL::Chem::ReactionSubstructureSearch.
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
CDPL::Chem::ReactionSubstructureSearch::ConstMappingIterator
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:75
CDPL::Chem::Reactor::getReactionSitesBegin
ReactionSiteIterator getReactionSitesBegin()
Returns a mutable iterator pointing to the beginning of the stored reaction-site data objects.
CDPL::Chem::Reactor::Reactor
Reactor()
Constructs and initializes a Reactor instance.
CDPL::Base::LookupKey
An unique lookup key for control-parameter and property values.
Definition: LookupKey.hpp:54
CDPL::Chem::Reactor::begin
ConstReactionSiteIterator begin() const
Returns a constant iterator pointing to the beginning of the stored reaction-site data objects.
CDPL::Chem::Reactor::setReactionPattern
void setReactionPattern(const Reaction &rxn_pattern)
Allows to specify a new reaction pattern for the transformation of reactants to products.
CDPL::Chem::Reactor::getReactionSite
ReactionSite & getReactionSite(std::size_t idx)
Returns a non-const reference to the stored reaction-site data object at index idx.
CDPL::Chem::ReactionSubstructureSearch
ReactionSubstructureSearch.
Definition: ReactionSubstructureSearch.hpp:62
BitSet.hpp
Definition of the type CDPL::Util::BitSet.
CDPL::Chem::Molecule
Molecule.
Definition: Molecule.hpp:49
CDPL::Base::Any
A safe, type checked container for arbitrary data of variable type.
Definition: Any.hpp:59
CDPL::Chem::Reactor::~Reactor
~Reactor()
Destructor.
CDPL::Chem::Reactor::Reactor
Reactor(const Reaction &rxn_pattern)
Constructs and initializes a Reactor instance for the specified reaction pattern.
CDPL::Chem::Reactor::getReactionSite
const ReactionSite & getReactionSite(std::size_t idx) const
Returns a const reference to the stored reaction-site data object at index idx.
CDPL::Chem::Reactor::end
ConstReactionSiteIterator end() const
Returns a constant iterator pointing to the end of the stored reaction-site data objects.
Reaction.hpp
Definition of the class CDPL::Chem::Reaction.
CDPL::Chem::AtomType::T
const unsigned int T
Specifies Hydrogen (Tritium).
Definition: AtomType.hpp:67
CDPL::Chem::Reactor::getReactionSitesEnd
ReactionSiteIterator getReactionSitesEnd()
Returns a mutable iterator pointing to the end of the stored reaction-site data objects.
CDPL::Chem::Reactor
Reactor.
Definition: Reactor.hpp:53
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::Reaction
Reaction.
Definition: Reaction.hpp:52
CDPL::Chem::Reactor::findReactionSites
bool findReactionSites(Reaction &rxn_target)
Perceives all possible reaction-sites on the reactants of the given reaction target where the specifi...
CDPL::Chem::Reactor::getReactionSitesBegin
ConstReactionSiteIterator getReactionSitesBegin() const
Returns a constant iterator pointing to the beginning of the stored reaction-site data objects.
CDPL::Chem::AtomBondMapping
A data structure for the common storage of related atom to atom and bond to bond mappings.
Definition: AtomBondMapping.hpp:55
CDPL::Chem::Reactor::performReaction
void performReaction(const ReactionSite &rxn_site)
Performs a transformation of the target reactants to corresponding products at the specified reaction...
CDPL::Chem::Reactor::ConstReactionSiteIterator
ReactionSubstructureSearch::ConstMappingIterator ConstReactionSiteIterator
A constant random access iterator used to iterate over the perceived reaction-sites.
Definition: Reactor.hpp:69
CDPL::Chem::Reactor::end
ReactionSiteIterator end()
Returns a mutable iterator pointing to the end of the stored reaction-site data objects.