RDKit: CIPMol.h Source File

| RDKit Open-source cheminformatics and machine learning.

Loading...
Searching...
No Matches
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
20namespace RDKit {
21
22namespace CIPLabeler {
23
24template <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
37 CIPMolIter &operator++() {
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
82 CXXAtomIterator<MolGraph, Atom *> atoms() const;
83
84 Bond *getBond(int idx) const;
85
86 CIPMolSpan<Bond *, ROMol::OEDGE_ITER> getBonds(Atom *atom) const;
87
88 CIPMolSpan<Atom *, ROMol::ADJ_ITER> getNeighbors(Atom *atom) const;
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::vector<RDKit::Bond::BondType> d_kekulized_bonds;
99 std::vector<boost::rational<int>> d_atomnums;
100};
101
102} // namespace CIPLabeler
103} // namespace RDKit
Descriptor.h
Mancude.h
RDKitBase.h
pulls in the core RDKit functionality
RDKit::Atom
The class for representing atoms.
Definition Atom.h:74
RDKit::Bond
class for representing a bond
Definition Bond.h:46
RDKit::CIPLabeler::CIPMolSpan::CIPMolIter
Definition CIPMol.h:27
RDKit::CIPLabeler::CIPMolSpan::CIPMolIter::operator++
CIPMolIter & operator++()
Definition CIPMol.h:37
RDKit::CIPLabeler::CIPMolSpan::CIPMolIter::operator!=
bool operator!=(const CIPMolIter &it) const
Definition CIPMol.h:42
RDKit::CIPLabeler::CIPMolSpan::CIPMolIter::CIPMolIter
CIPMolIter()=delete
RDKit::CIPLabeler::CIPMolSpan::CIPMolIter::operator*
T & operator*()
Definition CIPMol.h:32
RDKit::CIPLabeler::CIPMolSpan::CIPMolIter::CIPMolIter
CIPMolIter(ROMol &mol, U pos)
Definition CIPMol.h:30
RDKit::CIPLabeler::CIPMolSpan
Definition CIPMol.h:25
RDKit::CIPLabeler::CIPMolSpan::CIPMolSpan
CIPMolSpan(ROMol &mol, std::pair< U, U > &&itr)
Definition CIPMol.h:52
RDKit::CIPLabeler::CIPMolSpan::begin
CIPMolIter begin()
Definition CIPMol.h:57
RDKit::CIPLabeler::CIPMolSpan::CIPMolSpan
CIPMolSpan()=delete
RDKit::CIPLabeler::CIPMolSpan::end
CIPMolIter end()
Definition CIPMol.h:58
RDKit::CIPLabeler::CIPMol::CIPMol
CIPMol(ROMol &mol)
RDKit::CIPLabeler::CIPMol::getBondOrder
int getBondOrder(Bond *bond) const
RDKit::CIPLabeler::CIPMol::isInRing
bool isInRing(Bond *bond) const
RDKit::CIPLabeler::CIPMol::getNeighbors
CIPMolSpan< Atom *, ROMol::ADJ_ITER > getNeighbors(Atom *atom) const
RDKit::CIPLabeler::CIPMol::CIPMol
CIPMol()=delete
RDKit::CIPLabeler::CIPMol::atoms
CXXAtomIterator< MolGraph, Atom * > atoms() const
RDKit::CIPLabeler::CIPMol::getFractionalAtomicNum
boost::rational< int > getFractionalAtomicNum(Atom *atom) const
RDKit::CIPLabeler::CIPMol::getBonds
CIPMolSpan< Bond *, ROMol::OEDGE_ITER > getBonds(Atom *atom) const
RDKit::CIPLabeler::CIPMol::getNumBonds
unsigned getNumBonds() const
RDKit::CIPLabeler::CIPMol::getBond
Bond * getBond(int idx) const
RDKit::CIPLabeler::CIPMol::getNumAtoms
unsigned getNumAtoms() const
RDKit::CIPLabeler::CIPMol::getAtom
Atom * getAtom(int idx) const
RDKit::ROMol
Definition ROMol.h:199
RDKit::CIPLabeler
Definition CIPLabeler.h:27
RDKit
Std stuff.
Definition Abbreviations.h:19
RDKit::CXXAtomIterator
Definition ROMol.h:115