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> class CIPMolSpan {
25 public:
26  class CIPMolIter {
27  public:
28  CIPMolIter() = delete;
29  CIPMolIter(ROMol &mol, U pos) : d_mol{mol}, d_pos{std::move(pos)} {}
30 
31  T &operator*() {
32  d_current = d_mol[*d_pos];
33  return d_current;
34  }
35 
37  ++d_pos;
38  return *this;
39  }
40 
41  bool operator!=(const CIPMolIter &it) const { return d_pos != it.d_pos; }
42 
43  private:
44  ROMol &d_mol;
45  U d_pos;
46  T d_current = nullptr;
47  };
48 
49 public:
50  CIPMolSpan() = delete;
51  CIPMolSpan(ROMol &mol, std::pair<U, U> &&itr)
52  : d_mol{mol}, d_istart{std::move(itr.first)},
53  d_iend{std::move(itr.second)} {}
54 
55  CIPMolIter begin() { return {d_mol, d_istart}; }
56  CIPMolIter end() { return {d_mol, d_iend}; }
57 
58 private:
59  ROMol &d_mol;
60  const U d_istart;
61  const U d_iend;
62 };
63 
64 class CIPMol {
65 public:
66  CIPMol() = delete;
67 
68  explicit CIPMol(ROMol &mol);
69 
70  // Average atomic number with other atoms that are in an
71  // aromatic ring with this one.
72  boost::rational<int> getFractionalAtomicNum(Atom *atom) const;
73 
74  unsigned getNumAtoms() const;
75 
76  unsigned getNumBonds() const;
77 
78  Atom *getAtom(int idx) const;
79 
81 
82  Bond *getBond(int idx) const;
83 
85 
87 
88  bool isInRing(Bond *bond) const;
89 
90  // Integer bond order of a kekulized molecule
91  // Dative bonds get bond order 0.
92  int getBondOrder(Bond *bond) const;
93 
94 private:
95  ROMol &d_mol;
96  std::unique_ptr<RWMol> dp_kekulized_mol = nullptr;
97 
98  std::vector<boost::rational<int>> d_atomnums;
99 };
100 
101 } // namespace CIPLabeler
102 } // namespace RDKit
pulls in the core RDKit functionality
The class for representing atoms.
Definition: Atom.h:69
class for representing a bond
Definition: Bond.h:47
bool operator!=(const CIPMolIter &it) const
Definition: CIPMol.h:41
CIPMolSpan(ROMol &mol, std::pair< U, U > &&itr)
Definition: CIPMol.h:51
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:17