Chemical Data Processing Library C++ API - Version 1.2.0
CanonicalFragment.hpp
Go to the documentation of this file.
1 /*
2  * CanonicalFragment.hpp
3  *
4  * This file is part of the ConfGenical 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_CONFGEN_CANONICALFRAGMENT_HPP
30 #define CDPL_CONFGEN_CANONICALFRAGMENT_HPP
31 
32 #include <vector>
33 #include <cstddef>
34 #include <cstdint>
35 #include <memory>
36 
41 #include "CDPL/Util/Array.hpp"
42 
43 
44 namespace CDPL
45 {
46 
47  namespace ConfGen
48  {
49 
54  {
55 
56  public:
60  typedef std::shared_ptr<CanonicalFragment> SharedPointer;
61 
66 
67  typedef std::vector<const Chem::Atom*> AtomMapping;
68 
73 
80 
82 
83  void clear();
84 
85  std::size_t getNumAtoms() const;
86 
87  const Chem::Atom& getAtom(std::size_t idx) const;
88 
89  Chem::Atom& getAtom(std::size_t idx);
90 
92 
94 
96 
98 
99  bool containsAtom(const Chem::Atom& atom) const;
100 
101  std::size_t getAtomIndex(const Chem::Atom& atom) const;
102 
103  std::size_t getNumEntities() const;
104 
105  const Chem::Entity3D& getEntity(std::size_t idx) const;
106 
107  Chem::Entity3D& getEntity(std::size_t idx);
108 
109  std::size_t getNumBonds() const;
110 
111  const Chem::Bond& getBond(std::size_t idx) const;
112 
113  Chem::Bond& getBond(std::size_t idx);
114 
116 
118 
120 
122 
123  bool containsBond(const Chem::Bond& bond) const;
124 
125  std::size_t getBondIndex(const Chem::Bond& bond) const;
126 
128 
130 
131  std::uint64_t getHashCode() const;
132 
134 
136 
137  void create(const Chem::MolecularGraph& molgraph, const Chem::MolecularGraph& parent,
138  bool modify = true, bool strip_aro_subst = true);
139 
140  const AtomMapping& getAtomMapping() const;
141 
142  void perceiveSSSR();
143 
144  private:
145  void copyAtoms(const Chem::MolecularGraph& molgraph, const Chem::MolecularGraph& parent,
146  bool modify, bool strip_aro_subst);
147  bool copyBonds(const Chem::MolecularGraph& molgraph);
148 
149  void fixStereoDescriptors(const Chem::MolecularGraph& molgraph, bool clear_stereo);
150  void hydrogenize();
151  void canonicalize(bool stereo);
152  void calcHashCode(bool stereo);
153 
154  bool compareCanonNumber(const Chem::Atom& atom1, const Chem::Atom& atom2) const;
155 
156  typedef std::vector<std::uint32_t> HashInputData;
157  typedef Chem::SmallestSetOfSmallestRings::SharedPointer SmallestSetOfSmallestRingsPtr;
158 
159  Chem::BasicMolecule molecule;
160  std::uint64_t hashCode;
162  SmallestSetOfSmallestRingsPtr sssr;
163  Util::STArray canonNumbers;
164  HashInputData hashInputData;
165  AtomMapping atomMapping;
166  };
167  } // namespace ConfGen
168 } // namespace CDPL
169 
170 #endif // CDPL_CONFGEN_CANONICALFRAGMENT_HPP
Definition of the class CDPL::Util::Array.
Definition of the class CDPL::Chem::BasicMolecule.
Definition of the class CDPL::Chem::CanonicalNumberingCalculator.
Definition of the preprocessor macro CDPL_CONFGEN_API.
#define CDPL_CONFGEN_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
Definition of the class CDPL::Chem::SmallestSetOfSmallestRings.
Atom.
Definition: Atom.hpp:52
BasicMolecule.
Definition: BasicMolecule.hpp:54
boost::indirect_iterator< AtomList::const_iterator, const BasicAtom > ConstAtomIterator
Definition: BasicMolecule.hpp:70
boost::indirect_iterator< BondList::iterator, BasicBond > BondIterator
Definition: BasicMolecule.hpp:71
boost::indirect_iterator< BondList::const_iterator, const BasicBond > ConstBondIterator
Definition: BasicMolecule.hpp:72
boost::indirect_iterator< AtomList::iterator, BasicAtom > AtomIterator
Definition: BasicMolecule.hpp:69
Bond.
Definition: Bond.hpp:50
CanonicalNumberingCalculator.
Definition: CanonicalNumberingCalculator.hpp:67
Entity3D.
Definition: Entity3D.hpp:46
MolecularGraph.
Definition: MolecularGraph.hpp:52
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:58
std::shared_ptr< SmallestSetOfSmallestRings > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SmallestSetOfSmallestRings instan...
Definition: SmallestSetOfSmallestRings.hpp:64
CanonicalFragment.
Definition: CanonicalFragment.hpp:54
Chem::BasicMolecule::BondIterator BondIterator
Definition: CanonicalFragment.hpp:64
void orderBonds(const Chem::BondCompareFunction &func)
Orders the stored bonds according to criteria implemented by the provided bond comparison function.
ConstAtomIterator getAtomsBegin() const
const AtomMapping & getAtomMapping() const
std::shared_ptr< CanonicalFragment > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated CanonicalFragment instances.
Definition: CanonicalFragment.hpp:60
ConstBondIterator getBondsBegin() const
std::size_t getNumEntities() const
Returns the number of stored Chem::Entity3D objects.
void create(const Chem::MolecularGraph &molgraph, const Chem::MolecularGraph &parent, bool modify=true, bool strip_aro_subst=true)
bool containsAtom(const Chem::Atom &atom) const
Tells whether the specified Chem::Atom instance is stored in this container.
Chem::BasicMolecule::ConstAtomIterator ConstAtomIterator
Definition: CanonicalFragment.hpp:63
CanonicalFragment(const CanonicalFragment &frag)
std::size_t getAtomIndex(const Chem::Atom &atom) const
Returns the index of the specified Chem::Atom instance in this container.
CanonicalFragment & operator=(const CanonicalFragment &frag)
Chem::Bond & getBond(std::size_t idx)
Returns a non-const reference to the bond at index idx.
ConstAtomIterator getAtomsEnd() const
std::uint64_t getHashCode() const
const Chem::Atom & getAtom(std::size_t idx) const
Returns a const reference to the Chem::Atom instance at index idx.
CanonicalFragment(const Chem::MolecularGraph &molgraph, const Chem::MolecularGraph &parent)
Constructs a CanonicalFragment instance that contains the relevant atoms and bonds of the molecular g...
const Chem::Bond & getBond(std::size_t idx) const
Returns a const reference to the Chem::Bond instance at index idx.
const Chem::Entity3D & getEntity(std::size_t idx) const
Returns a const reference to the Chem::Entity3D instance at index idx.
Chem::MolecularGraph::SharedPointer clone() const
Creates a copy of the molecular graph.
bool containsBond(const Chem::Bond &bond) const
Tells whether the specified Chem::Bond instance is stored in this container.
std::vector< const Chem::Atom * > AtomMapping
Definition: CanonicalFragment.hpp:67
Chem::Atom & getAtom(std::size_t idx)
Returns a non-const reference to the atom at index idx.
CanonicalFragment()
Constructs an empty CanonicalFragment instance.
std::size_t getNumAtoms() const
Returns the number of stored Chem::Atom objects.
Chem::Entity3D & getEntity(std::size_t idx)
Returns a non-const reference to the entity at index idx.
ConstBondIterator getBondsEnd() const
std::size_t getNumBonds() const
Returns the number of stored Chem::Bond objects.
Chem::BasicMolecule::ConstBondIterator ConstBondIterator
Definition: CanonicalFragment.hpp:65
std::size_t getBondIndex(const Chem::Bond &bond) const
Returns the index of the specified Chem::Bond instance in this container.
Chem::BasicMolecule::AtomIterator AtomIterator
Definition: CanonicalFragment.hpp:62
void orderAtoms(const Chem::AtomCompareFunction &func)
Orders the stored atoms according to criteria implemented by the provided atom comparison function.
A STL compatible random access iterator for container elements accessible by index.
Definition: IndexedElementIterator.hpp:125
std::function< bool(const Chem::Atom &, const Chem::Atom &)> AtomCompareFunction
A generic wrapper class used to store a user-defined atom compare function.
Definition: AtomCompareFunction.hpp:41
CDPL_CHEM_API std::uint64_t calcHashCode(const MolecularGraph &molgraph, unsigned int atom_flags=AtomPropertyFlag::DEFAULT, unsigned int bond_flags=BondPropertyFlag::DEFAULT, bool ord_h_deplete=true)
CDPL_CHEM_API void canonicalize(MolecularGraph &molgraph, const AtomCompareFunction &func, bool atoms=true, bool atom_nbrs=true, bool bonds=true, bool bond_atoms=false)
std::function< bool(const Chem::Bond &, const Chem::Bond &)> BondCompareFunction
A generic wrapper class used to store a user-defined bond compare function.
Definition: BondCompareFunction.hpp:41
Array< std::size_t > STArray
An array of unsigned integers of type std::size_t.
Definition: Array.hpp:567
The namespace of the Chemical Data Processing Library.