Chemical Data Processing Library C++ API - Version 1.1.1
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  class BondContainer;
53 
59  {
60 
61  public:
62  typedef std::shared_ptr<StereoisomerGenerator> SharedPointer;
63 
65 
66  void setAtomPredicate(const AtomPredicate& pred);
67 
69 
70  void setBondPredicate(const BondPredicate& pred);
71 
73 
74  void enumerateAtomConfig(bool enumerate);
75 
76  bool atomConfigEnumerated() const;
77 
78  void enumerateBondConfig(bool enumerate);
79 
80  bool bondConfigEnumerated() const;
81 
82  void includeSpecifiedCenters(bool include);
83 
85 
86  void includeSymmetricCenters(bool include);
87 
89 
90  void includeBridgeheadAtoms(bool include);
91 
93 
94  void includeInvertibleNitrogens(bool include);
95 
97 
98  void includeRingBonds(bool include);
99 
100  bool ringBondsIncluded() const;
101 
102  void setMinRingSize(std::size_t min_size);
103 
104  std::size_t getMinRingSize() const;
105 
106  void setup(const MolecularGraph& molgraph);
107 
108  bool generate();
109 
111 
113 
114  private:
115  typedef std::pair<bool, std::size_t> StereoCenterID;
116 
117  bool isExcluded(const Atom& atom, const MolecularGraph& molgraph, bool has_config);
118  bool isExcluded(const Bond& bond, const MolecularGraph& molgraph, bool has_config) const;
119 
120  void findBridgeheadAtoms(const MolecularGraph& molgraph);
121  bool isSpiroCenter(const Atom& atom, const MolecularGraph& molgraph);
122  bool haveCommonBond(const BondContainer& ring1, const BondContainer& ring2) const;
123 
124  void flipConfiguration(const StereoCenterID& ctr_id);
125 
126  typedef std::vector<StereoCenterID> StereoCenterIDList;
127  typedef std::vector<std::size_t> IndexList;
128 
129  AtomPredicate atomPred;
130  BondPredicate bondPred;
131  bool enumAtomConfig{true};
132  bool enumBondConfig{true};
133  bool incSpecifiedCtrs{false};
134  bool incSymmetricCtrs{false};
135  bool incBridgeheads{false};
136  bool incInvNitrogens{false};
137  bool incRingBonds{false};
138  std::size_t minRingSize{8};
139  StereoDescriptorArray atomDescrs;
140  StereoDescriptorArray bondDescrs;
141  StereoCenterIDList procCtrs;
142  Util::BitSet flipStates;
143  Util::BitSet bhAtoms;
144  IndexList atomRingSet;
145  };
146  } // namespace Chem
147 } // namespace CDPL
148 
149 #endif // CDPL_CHEM_STEREOISOMERGENERATOR_HPP
CDPL::Chem::StereoisomerGenerator::includeBridgeheadAtoms
void includeBridgeheadAtoms(bool include)
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CHEM_API.
CDPL::Chem::StereoisomerGenerator::setAtomPredicate
void setAtomPredicate(const AtomPredicate &pred)
CDPL::Chem::StereoisomerGenerator::getAtomPredicate
const AtomPredicate & getAtomPredicate() const
CDPL::Chem::StereoisomerGenerator::setBondPredicate
void setBondPredicate(const BondPredicate &pred)
CDPL::Chem::StereoisomerGenerator::enumerateBondConfig
void enumerateBondConfig(bool enumerate)
CDPL::Chem::StereoisomerGenerator::StereoDescriptorArray
Util::Array< StereoDescriptor > StereoDescriptorArray
Definition: StereoisomerGenerator.hpp:64
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::BondPredicate
std::function< bool(const Chem::Bond &)> BondPredicate
A generic wrapper class used to store a user-defined bond predicate.
Definition: BondPredicate.hpp:41
CDPL::Chem::StereoisomerGenerator::includeSymmetricCenters
void includeSymmetricCenters(bool include)
CDPL::Util::BitSet
boost::dynamic_bitset BitSet
A dynamic bitset class.
Definition: BitSet.hpp:46
CDPL::Chem::StereoisomerGenerator::bridgeheadAtomsIncluded
bool bridgeheadAtomsIncluded() const
CDPL::Chem::StereoisomerGenerator::SharedPointer
std::shared_ptr< StereoisomerGenerator > SharedPointer
Definition: StereoisomerGenerator.hpp:62
CDPL::Util::Array< StereoDescriptor >
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
CDPL::Chem::StereoisomerGenerator::enumerateAtomConfig
void enumerateAtomConfig(bool enumerate)
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
BitSet.hpp
Definition of the type CDPL::Util::BitSet.
Array.hpp
Definition of the class CDPL::Util::Array.
CDPL::Chem::StereoisomerGenerator::atomConfigEnumerated
bool atomConfigEnumerated() const
CDPL::Chem::AtomPredicate
std::function< bool(const Chem::Atom &)> AtomPredicate
A generic wrapper class used to store a user-defined atom predicate.
Definition: AtomPredicate.hpp:41
BondPredicate.hpp
Type definition of a generic wrapper class for storing user-defined Chem::Bond predicates.
CDPL::Chem::StereoisomerGenerator::setup
void setup(const MolecularGraph &molgraph)
CDPL::Chem::StereoisomerGenerator::bondConfigEnumerated
bool bondConfigEnumerated() const
CDPL::Chem::StereoisomerGenerator::specifiedCentersIncluded
bool specifiedCentersIncluded() const
CDPL::Chem::StereoisomerGenerator::includeRingBonds
void includeRingBonds(bool include)
AtomPredicate.hpp
Type definition of a generic wrapper class for storing user-defined Chem::Atom predicates.
CDPL::Chem::StereoisomerGenerator::invertibleNitrogensIncluded
bool invertibleNitrogensIncluded() const
CDPL::Chem::StereoisomerGenerator::ringBondsIncluded
bool ringBondsIncluded() const
CDPL::Chem::StereoisomerGenerator::getBondDescriptors
const StereoDescriptorArray & getBondDescriptors()
CDPL::Chem::StereoisomerGenerator::symmetricCentersIncluded
bool symmetricCentersIncluded() const
CDPL::Chem::StereoisomerGenerator::setMinRingSize
void setMinRingSize(std::size_t min_size)
CDPL::Chem::StereoisomerGenerator::getAtomDescriptors
const StereoDescriptorArray & getAtomDescriptors()
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Chem::StereoisomerGenerator::includeSpecifiedCenters
void includeSpecifiedCenters(bool include)
CDPL::Chem::StereoisomerGenerator::includeInvertibleNitrogens
void includeInvertibleNitrogens(bool include)
CDPL::Chem::StereoisomerGenerator::generate
bool generate()
CDPL::Chem::StereoisomerGenerator::getMinRingSize
std::size_t getMinRingSize() const
CDPL::Chem::BondContainer
A common interface for data-structures that support a random access to stored Chem::Bond instances.
Definition: BondContainer.hpp:54
StereoDescriptor.hpp
Definition of the type CDPL::Chem::StereoDescriptor.
CDPL::Chem::StereoisomerGenerator
StereoisomerGenerator.
Definition: StereoisomerGenerator.hpp:59
CDPL::Chem::StereoisomerGenerator::getBondPredicate
const BondPredicate & getBondPredicate() const