Chemical Data Processing Library C++ API - Version 1.4.0
StereoisomerGenerator.hpp
Go to the documentation of this file.
1 /*
2  * StereoisomerGenerator.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_STEREOISOMERGENERATOR_HPP
30 #define CDPL_CHEM_STEREOISOMERGENERATOR_HPP
31 
32 #include <memory>
33 #include <vector>
34 #include <cstddef>
35 #include <utility>
36 
37 #include "CDPL/Chem/APIPrefix.hpp"
41 #include "CDPL/Util/Array.hpp"
42 #include "CDPL/Util/BitSet.hpp"
43 
44 
45 namespace CDPL
46 {
47 
48  namespace Chem
49  {
50 
51  class MolecularGraph;
52 
66  {
67 
68  public:
70  typedef std::shared_ptr<StereoisomerGenerator> SharedPointer;
71 
74 
79  void setAtomPredicate(const AtomPredicate& pred);
80 
86 
91  void setBondPredicate(const BondPredicate& pred);
92 
98 
103  void enumerateAtomConfig(bool enumerate);
104 
109  bool atomConfigEnumerated() const;
110 
115  void enumerateBondConfig(bool enumerate);
116 
121  bool bondConfigEnumerated() const;
122 
127  void includeSpecifiedCenters(bool include);
128 
134 
139  void includeSymmetricCenters(bool include);
140 
146 
151  void includeBridgeheadAtoms(bool include);
152 
158 
163  void includeInvertibleNitrogens(bool include);
164 
170 
175  void includeRingBonds(bool include);
176 
181  bool ringBondsIncluded() const;
182 
187  void setMinRingSize(std::size_t min_size);
188 
193  std::size_t getMinRingSize() const;
194 
199  void setup(const MolecularGraph& molgraph);
200 
205  bool generate();
206 
212 
218 
219  private:
220  typedef std::pair<bool, std::size_t> StereoCenterID;
221 
222  bool isExcluded(const Atom& atom, const MolecularGraph& molgraph, bool has_config);
223  bool isExcluded(const Bond& bond, const MolecularGraph& molgraph, bool has_config) const;
224 
225  void findBridgeheadAtoms(const MolecularGraph& molgraph);
226 
227  void flipConfiguration(const StereoCenterID& ctr_id);
228 
229  typedef std::vector<StereoCenterID> StereoCenterIDList;
230 
231  AtomPredicate atomPred;
232  BondPredicate bondPred;
233  bool enumAtomConfig{true};
234  bool enumBondConfig{true};
235  bool incSpecifiedCtrs{false};
236  bool incSymmetricCtrs{false};
237  bool incBridgeheads{false};
238  bool incInvNitrogens{false};
239  bool incRingBonds{false};
240  std::size_t minRingSize{8};
241  StereoDescriptorArray atomDescrs;
242  StereoDescriptorArray bondDescrs;
243  StereoCenterIDList procCtrs;
244  Util::BitSet flipStates;
245  };
246  } // namespace Chem
247 } // namespace CDPL
248 
249 #endif // CDPL_CHEM_STEREOISOMERGENERATOR_HPP
Definition of class CDPL::Util::Array.
Type declaration of a generic wrapper class for storing user-defined Chem::Atom predicates.
Declaration of type CDPL::Util::BitSet.
Type declaration of a generic wrapper class for storing user-defined Chem::Bond predicates.
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 the type CDPL::Chem::StereoDescriptor.
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 for representations of a chemical structure as a graph of bonded atoms.
Definition: MolecularGraph.hpp:57
Enumerates the stereoisomers of a molecular graph by flipping the configurations of selected atom and...
Definition: StereoisomerGenerator.hpp:66
std::size_t getMinRingSize() const
Returns the minimum ring size for a ring bond to be eligible as a stereocenter.
const StereoDescriptorArray & getBondDescriptors()
Returns the per-bond stereo descriptors for the current stereoisomer.
void setBondPredicate(const BondPredicate &pred)
Sets the predicate used to filter bond stereocenters considered during enumeration.
void enumerateAtomConfig(bool enumerate)
Specifies whether atom-stereocenter configurations shall be enumerated.
void includeSymmetricCenters(bool include)
Specifies whether topologically-symmetric stereocenters shall be enumerated.
void setMinRingSize(std::size_t min_size)
Sets the minimum ring size for a ring bond to be eligible as a stereocenter.
void includeSpecifiedCenters(bool include)
Specifies whether stereocenters with explicitly specified configurations shall be enumerated.
bool ringBondsIncluded() const
Tells whether ring bonds are enumerated.
bool symmetricCentersIncluded() const
Tells whether topologically-symmetric stereocenters are enumerated.
void setAtomPredicate(const AtomPredicate &pred)
Sets the predicate used to filter atom stereocenters considered during enumeration.
void includeBridgeheadAtoms(bool include)
Specifies whether bridgehead atoms in fused ring systems shall be enumerated as stereocenters.
bool generate()
Advances the enumeration by one step and updates the per-atom/per-bond stereo-descriptor arrays.
bool specifiedCentersIncluded() const
Tells whether specified stereocenters are enumerated.
void enumerateBondConfig(bool enumerate)
Specifies whether bond-stereocenter configurations shall be enumerated.
bool invertibleNitrogensIncluded() const
Tells whether invertible nitrogen stereocenters are enumerated.
void setup(const MolecularGraph &molgraph)
Prepares the generator for enumerating the stereoisomers of molgraph.
Util::Array< StereoDescriptor > StereoDescriptorArray
Array of StereoDescriptor values (one per atom or one per bond of the input molecular graph).
Definition: StereoisomerGenerator.hpp:73
const BondPredicate & getBondPredicate() const
Returns the currently configured bond predicate.
void includeInvertibleNitrogens(bool include)
Specifies whether invertible (pyramidal) nitrogen stereocenters shall be enumerated.
bool bondConfigEnumerated() const
Tells whether bond-stereocenter configurations are enumerated.
bool atomConfigEnumerated() const
Tells whether atom-stereocenter configurations are enumerated.
const StereoDescriptorArray & getAtomDescriptors()
Returns the per-atom stereo descriptors for the current stereoisomer.
std::shared_ptr< StereoisomerGenerator > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated StereoisomerGenerator instances.
Definition: StereoisomerGenerator.hpp:70
void includeRingBonds(bool include)
Specifies whether ring bonds (large enough to allow cis/trans isomerism) shall be enumerated.
bool bridgeheadAtomsIncluded() const
Tells whether bridgehead atoms are enumerated.
const AtomPredicate & getAtomPredicate() const
Returns the currently configured atom predicate.
std::function< bool(const Chem::Atom &)> AtomPredicate
Generic wrapper class used to store a user-defined atom predicate.
Definition: AtomPredicate.hpp:41
std::function< bool(const Chem::Bond &)> BondPredicate
Generic wrapper class used to store a user-defined bond predicate.
Definition: BondPredicate.hpp:41
boost::dynamic_bitset BitSet
Dynamic bitset class.
Definition: BitSet.hpp:46
The namespace of the Chemical Data Processing Library.