RDKit
Open-source cheminformatics and machine learning.
CIPMol.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright (C) 2020 Schrödinger, LLC
4 //
5 // @@ All Rights Reserved @@
6 // This file is part of the RDKit.
7 // The contents are covered by the terms of the BSD license
8 // which is included in the file license.txt, found at the root
9 // of the RDKit source tree.
10 //
11 #pragma once
12 
13 #include <memory>
14 
15 #include <GraphMol/RDKitBase.h>
16 
17 #include "Descriptor.h"
18 #include "Mancude.h"
19 
20 namespace RDKit {
21 
22 namespace CIPLabeler {
23 
24 template <typename T, typename U>
25 class CIPMolSpan {
26  public:
27  class CIPMolIter {
28  public:
29  CIPMolIter() = delete;
30  CIPMolIter(ROMol &mol, U pos) : d_mol{mol}, d_pos{std::move(pos)} {}
31 
32  T &operator*() {
33  d_current = d_mol[*d_pos];
34  return d_current;
35  }
36 
38  ++d_pos;
39  return *this;
40  }
41 
42  bool operator!=(const CIPMolIter &it) const { return d_pos != it.d_pos; }
43 
44  private:
45  ROMol &d_mol;
46  U d_pos;
47  T d_current = nullptr;
48  };
49 
50  public:
51  CIPMolSpan() = delete;
52  CIPMolSpan(ROMol &mol, std::pair<U, U> &&itr)
53  : d_mol{mol},
54  d_istart{std::move(itr.first)},
55  d_iend{std::move(itr.second)} {}
56 
57  CIPMolIter begin() { return {d_mol, d_istart}; }
58  CIPMolIter end() { return {d_mol, d_iend}; }
59 
60  private:
61  ROMol &d_mol;
62  const U d_istart;
63  const U d_iend;
64 };
65 
66 class CIPMol {
67  public:
68  CIPMol() = delete;
69 
70  explicit CIPMol(ROMol &mol);
71 
72  // Average atomic number with other atoms that are in an
73  // aromatic ring with this one.
74  boost::rational<int> getFractionalAtomicNum(Atom *atom) const;
75 
76  unsigned getNumAtoms() const;
77 
78  unsigned getNumBonds() const;
79 
80  Atom *getAtom(int idx) const;
81 
83 
84  Bond *getBond(int idx) const;
85 
87 
89 
90  bool isInRing(Bond *bond) const;
91 
92  // Integer bond order of a kekulized molecule
93  // Dative bonds get bond order 0.
94  int getBondOrder(Bond *bond) const;
95 
96  private:
97  ROMol &d_mol;
98  std::unique_ptr<RWMol> dp_kekulized_mol = nullptr;
99 
100  std::vector<boost::rational<int>> d_atomnums;
101 };
102 
103 } // namespace CIPLabeler
104 } // namespace RDKit
pulls in the core RDKit functionality
The class for representing atoms.
Definition: Atom.h:68
class for representing a bond
Definition: Bond.h:47
bool operator!=(const CIPMolIter &it) const
Definition: CIPMol.h:42
CIPMolSpan(ROMol &mol, std::pair< U, U > &&itr)
Definition: CIPMol.h:52
int getBondOrder(Bond *bond) const
Bond * getBond(int idx) const
CIPMolSpan< Atom *, ROMol::ADJ_ITER > getNeighbors(Atom *atom) const
CXXAtomIterator< MolGraph, Atom * > atoms() const
CIPMolSpan< Bond *, ROMol::OEDGE_ITER > getBonds(Atom *atom) const
bool isInRing(Bond *bond) const
Atom * getAtom(int idx) const
unsigned getNumBonds() const
unsigned getNumAtoms() const
boost::rational< int > getFractionalAtomicNum(Atom *atom) const
Std stuff.
Definition: Abbreviations.h:19