Chemical Data Processing Library C++ API - Version 1.1.1
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
CDPL::Chem::MolecularGraph::SharedPointer
std::shared_ptr< MolecularGraph > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated MolecularGraph instances.
Definition: MolecularGraph.hpp:58
CDPL::ConfGen::CanonicalFragment::getAtom
const Chem::Atom & getAtom(std::size_t idx) const
Returns a const reference to the Chem::Atom instance at index idx.
CDPL::ConfGen::CanonicalFragment::getBondsBegin
BondIterator getBondsBegin()
CDPL::Chem::AtomCompareFunction
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::ConfGen::CanonicalFragment::orderAtoms
void orderAtoms(const Chem::AtomCompareFunction &func)
Orders the stored atoms according to criteria implemented by the provided atom comparison function.
CDPL::ConfGen::CanonicalFragment::AtomMapping
std::vector< const Chem::Atom * > AtomMapping
Definition: CanonicalFragment.hpp:67
CDPL::Chem::Bond
Bond.
Definition: Bond.hpp:50
CDPL::ConfGen::CanonicalFragment::ConstAtomIterator
Chem::BasicMolecule::ConstAtomIterator ConstAtomIterator
Definition: CanonicalFragment.hpp:63
CDPL::Chem::calcHashCode
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::ConfGen::CanonicalFragment::getNumBonds
std::size_t getNumBonds() const
Returns the number of stored Chem::Bond objects.
CDPL::Chem::BasicMolecule
BasicMolecule.
Definition: BasicMolecule.hpp:54
CDPL::ConfGen::CanonicalFragment::getAtomsBegin
ConstAtomIterator getAtomsBegin() const
CDPL::ConfGen::CanonicalFragment::BondIterator
Chem::BasicMolecule::BondIterator BondIterator
Definition: CanonicalFragment.hpp:64
CDPL::Util::IndexedElementIterator
A STL compatible random access iterator for container elements accessible by index.
Definition: IndexedElementIterator.hpp:125
CDPL::Chem::Atom
Atom.
Definition: Atom.hpp:52
CDPL::ConfGen::CanonicalFragment::containsAtom
bool containsAtom(const Chem::Atom &atom) const
Tells whether the specified Chem::Atom instance is stored in this container.
CDPL::ConfGen::CanonicalFragment::CanonicalFragment
CanonicalFragment(const CanonicalFragment &frag)
CDPL::ConfGen::CanonicalFragment::getAtomMapping
const AtomMapping & getAtomMapping() const
CDPL::ConfGen::CanonicalFragment::getEntity
Chem::Entity3D & getEntity(std::size_t idx)
Returns a non-const reference to the entity at index idx.
CDPL::ConfGen::CanonicalFragment::getBondsEnd
ConstBondIterator getBondsEnd() const
CanonicalNumberingCalculator.hpp
Definition of the class CDPL::Chem::CanonicalNumberingCalculator.
CDPL::ConfGen::CanonicalFragment::getBondsEnd
BondIterator getBondsEnd()
CDPL::ConfGen::CanonicalFragment::getAtomIndex
std::size_t getAtomIndex(const Chem::Atom &atom) const
Returns the index of the specified Chem::Atom instance in this container.
CDPL::Chem::MolecularGraph
MolecularGraph.
Definition: MolecularGraph.hpp:52
CDPL::ConfGen::CanonicalFragment::create
void create(const Chem::MolecularGraph &molgraph, const Chem::MolecularGraph &parent, bool modify=true, bool strip_aro_subst=true)
Array.hpp
Definition of the class CDPL::Util::Array.
CDPL::ConfGen::CanonicalFragment::getHashCode
std::uint64_t getHashCode() const
CDPL::ConfGen::CanonicalFragment::clone
Chem::MolecularGraph::SharedPointer clone() const
Creates a copy of the molecular graph.
CDPL::ConfGen::CanonicalFragment
CanonicalFragment.
Definition: CanonicalFragment.hpp:54
CDPL::ConfGen::CanonicalFragment::getAtom
Chem::Atom & getAtom(std::size_t idx)
Returns a non-const reference to the atom at index idx.
APIPrefix.hpp
Definition of the preprocessor macro CDPL_CONFGEN_API.
CDPL::ConfGen::CanonicalFragment::clear
void clear()
CDPL::Chem::BondCompareFunction
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
CDPL::ConfGen::CanonicalFragment::SharedPointer
std::shared_ptr< CanonicalFragment > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated CanonicalFragment instances.
Definition: CanonicalFragment.hpp:60
CDPL::Chem::BasicMolecule::ConstBondIterator
boost::indirect_iterator< BondList::const_iterator, const BasicBond > ConstBondIterator
Definition: BasicMolecule.hpp:72
CDPL::ConfGen::CanonicalFragment::getAtomsEnd
AtomIterator getAtomsEnd()
CDPL::Chem::BasicMolecule::BondIterator
boost::indirect_iterator< BondList::iterator, BasicBond > BondIterator
Definition: BasicMolecule.hpp:71
CDPL_CONFGEN_API
#define CDPL_CONFGEN_API
Tells the compiler/linker which classes, functions and variables are part of the library API.
CDPL::Chem::BasicMolecule::AtomIterator
boost::indirect_iterator< AtomList::iterator, BasicAtom > AtomIterator
Definition: BasicMolecule.hpp:69
SmallestSetOfSmallestRings.hpp
Definition of the class CDPL::Chem::SmallestSetOfSmallestRings.
CDPL::ConfGen::CanonicalFragment::AtomIterator
Chem::BasicMolecule::AtomIterator AtomIterator
Definition: CanonicalFragment.hpp:62
CDPL::ConfGen::CanonicalFragment::getBond
Chem::Bond & getBond(std::size_t idx)
Returns a non-const reference to the bond at index idx.
CDPL::ConfGen::CanonicalFragment::getEntity
const Chem::Entity3D & getEntity(std::size_t idx) const
Returns a const reference to the Chem::Entity3D instance at index idx.
CDPL::Chem::SmallestSetOfSmallestRings::SharedPointer
std::shared_ptr< SmallestSetOfSmallestRings > SharedPointer
A reference-counted smart pointer [SHPTR] for dynamically allocated SmallestSetOfSmallestRings instan...
Definition: SmallestSetOfSmallestRings.hpp:64
CDPL::ConfGen::CanonicalFragment::getAtomsBegin
AtomIterator getAtomsBegin()
CDPL::Chem::CanonicalNumberingCalculator
CanonicalNumberingCalculator.
Definition: CanonicalNumberingCalculator.hpp:67
CDPL::ConfGen::CanonicalFragment::CanonicalFragment
CanonicalFragment()
Constructs an empty CanonicalFragment instance.
CDPL::ConfGen::CanonicalFragment::getBondIndex
std::size_t getBondIndex(const Chem::Bond &bond) const
Returns the index of the specified Chem::Bond instance in this container.
CDPL
The namespace of the Chemical Data Processing Library.
CDPL::Util::STArray
Array< std::size_t > STArray
An array of unsigned integers of type std::size_t.
Definition: Array.hpp:567
CDPL::ConfGen::CanonicalFragment::CanonicalFragment
CanonicalFragment(const Chem::MolecularGraph &molgraph, const Chem::MolecularGraph &parent)
Constructs a CanonicalFragment instance that contains the relevant atoms and bonds of the molecular g...
CDPL::ConfGen::CanonicalFragment::getNumEntities
std::size_t getNumEntities() const
Returns the number of stored Chem::Entity3D objects.
CDPL::ConfGen::CanonicalFragment::ConstBondIterator
Chem::BasicMolecule::ConstBondIterator ConstBondIterator
Definition: CanonicalFragment.hpp:65
CDPL::ConfGen::CanonicalFragment::perceiveSSSR
void perceiveSSSR()
CDPL::ConfGen::CanonicalFragment::getAtomsEnd
ConstAtomIterator getAtomsEnd() const
CDPL::ConfGen::CanonicalFragment::operator=
CanonicalFragment & operator=(const CanonicalFragment &frag)
CDPL::ConfGen::CanonicalFragment::getNumAtoms
std::size_t getNumAtoms() const
Returns the number of stored Chem::Atom objects.
CDPL::Chem::BasicMolecule::ConstAtomIterator
boost::indirect_iterator< AtomList::const_iterator, const BasicAtom > ConstAtomIterator
Definition: BasicMolecule.hpp:70
CDPL::ConfGen::CanonicalFragment::orderBonds
void orderBonds(const Chem::BondCompareFunction &func)
Orders the stored bonds according to criteria implemented by the provided bond comparison function.
CDPL::Chem::Entity3D
Entity3D.
Definition: Entity3D.hpp:46
CDPL::ConfGen::CanonicalFragment::containsBond
bool containsBond(const Chem::Bond &bond) const
Tells whether the specified Chem::Bond instance is stored in this container.
CDPL::Chem::canonicalize
CDPL_CHEM_API void canonicalize(MolecularGraph &molgraph, const AtomCompareFunction &func, bool atoms=true, bool atom_nbrs=true, bool bonds=true, bool bond_atoms=false)
BasicMolecule.hpp
Definition of the class CDPL::Chem::BasicMolecule.
CDPL::ConfGen::CanonicalFragment::getBond
const Chem::Bond & getBond(std::size_t idx) const
Returns a const reference to the Chem::Bond instance at index idx.
CDPL::ConfGen::CanonicalFragment::getBondsBegin
ConstBondIterator getBondsBegin() const