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:
72  typedef std::shared_ptr<StereoisomerGenerator> SharedPointer;
73 
78 
83  void setAtomPredicate(const AtomPredicate& pred);
84 
90 
95  void setBondPredicate(const BondPredicate& pred);
96 
102 
107  void enumerateAtomConfig(bool enumerate);
108 
113  bool atomConfigEnumerated() const;
114 
119  void enumerateBondConfig(bool enumerate);
120 
125  bool bondConfigEnumerated() const;
126 
131  void includeSpecifiedCenters(bool include);
132 
138 
143  void includeSymmetricCenters(bool include);
144 
150 
155  void includeBridgeheadAtoms(bool include);
156 
162 
167  void includeInvertibleNitrogens(bool include);
168 
174 
179  void includeRingBonds(bool include);
180 
185  bool ringBondsIncluded() const;
186 
191  void setMinRingSize(std::size_t min_size);
192 
197  std::size_t getMinRingSize() const;
198 
203  void setup(const MolecularGraph& molgraph);
204 
209  bool generate();
210 
216 
222 
223  private:
224  typedef std::pair<bool, std::size_t> StereoCenterID;
225 
226  bool isExcluded(const Atom& atom, const MolecularGraph& molgraph, bool has_config);
227  bool isExcluded(const Bond& bond, const MolecularGraph& molgraph, bool has_config) const;
228 
229  void findBridgeheadAtoms(const MolecularGraph& molgraph);
230 
231  void flipConfiguration(const StereoCenterID& ctr_id);
232 
233  typedef std::vector<StereoCenterID> StereoCenterIDList;
234 
235  AtomPredicate atomPred;
236  BondPredicate bondPred;
237  bool enumAtomConfig{true};
238  bool enumBondConfig{true};
239  bool incSpecifiedCtrs{false};
240  bool incSymmetricCtrs{false};
241  bool incBridgeheads{false};
242  bool incInvNitrogens{false};
243  bool incRingBonds{false};
244  std::size_t minRingSize{8};
245  StereoDescriptorArray atomDescrs;
246  StereoDescriptorArray bondDescrs;
247  StereoCenterIDList procCtrs;
248  Util::BitSet flipStates;
249  };
250  } // namespace Chem
251 } // namespace CDPL
252 
253 #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:77
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:72
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.