RDKit
Open-source cheminformatics and machine learning.
Toggle main menu visibility
Loading...
Searching...
No Matches
Digraph.h
Go to the documentation of this file.
1
//
2
// Digraph is the core data structure for determining
3
// Cahn–Ingold–Prelog (CIP) chirality of a molecule.
4
//
5
// It's a "directed graph" - meaning that each bond
6
// has a start and an end. For CIP determination,
7
// the start points back towards the atom that is
8
// being labelled.
9
//
10
// Copyright (C) 2020 Schrödinger, LLC
11
//
12
// @@ All Rights Reserved @@
13
// This file is part of the RDKit.
14
// The contents are covered by the terms of the BSD license
15
// which is included in the file license.txt, found at the root
16
// of the RDKit source tree.
17
//
18
#pragma once
19
20
#include <cstdint>
21
#include <list>
22
#include <vector>
23
24
#include <
RDGeneral/BoostStartInclude.h
>
25
#include <boost/rational.hpp>
26
#include <
RDGeneral/BoostEndInclude.h
>
27
28
#include "
TooManyNodesException.h
"
29
30
namespace
RDKit
{
31
32
class
Atom
;
33
class
Bond
;
34
35
namespace
CIPLabeler
{
36
37
class
Node
;
38
class
Edge
;
39
class
CIPMol
;
40
41
/**
42
* A class to hold directed acyclic graphs representing the molecule.
43
*
44
* The root of the DAG is one of the foci of the configuration for
45
* which the label is being calculated. The tmproot may be set to
46
* other nodes that may become relevant in the calculation.
47
*
48
*/
49
class
Digraph
{
50
public
:
51
Digraph
() =
delete
;
52
Digraph
(
const
Digraph
&) =
delete
;
53
Digraph
&
operator=
(
const
Digraph
&) =
delete
;
54
55
Digraph
(
const
CIPMol
&mol,
Atom
*atom,
bool
atropsomerMode =
false
);
56
Digraph
(
CIPMol
&&mol,
Atom
*atom,
bool
atropsomerMode =
false
) =
delete
;
57
Digraph
(
const
CIPMol
&&mol,
Atom
*atom,
bool
atropsomerMode =
false
) =
delete
;
58
59
const
CIPMol
&
getMol
()
const
;
60
61
Node
*
getOriginalRoot
()
const
;
62
63
Node
*
getCurrentRoot
()
const
;
64
65
int
getNumNodes
()
const
;
66
67
/**
68
* Get all nodes which refer to `atom` in order of
69
* distance from the root.
70
*/
71
std::vector<Node *>
getNodes
(
Atom
*atom)
const
;
72
73
/**
74
* Access the reference atom for Rule 6 (if one is set).
75
*/
76
Atom
*
getRule6Ref
()
const
;
77
78
/**
79
* Used exclusively for Rule 6, we set one atom as the reference.
80
* @param ref reference atom
81
*/
82
void
setRule6Ref
(
Atom
*ref);
83
84
/**
85
* Sets the root node of this digraph by flipping the directions
86
* of edges as required.
87
*
88
* This is more efficient than building a new Digraph, but is
89
* only valid for neighboring Nodes.
90
*
91
* @param newroot the new root
92
*/
93
void
changeRoot
(
Node
*newroot);
94
95
void
expand
(
Node
*beg);
96
97
Node
&
addNode
(std::vector<std::uint32_t> &&visit,
Atom
*atom,
98
boost::rational<int> &&frac,
int
dist, uint8_t flags);
99
100
// Has `atom` been seen yet?
101
bool
seenAtom
(
Atom
*atom)
const
;
102
103
private
:
104
const
CIPMol
&d_mol;
105
106
// The node from which the Digraph is first initialized.
107
// It matches the atom that is being labeled.
108
Node
*dp_origin =
nullptr
;
109
110
// in atropisomer mode, we expand the two atoms of the atrop bond
111
112
bool
d_atropisomerMode =
false
;
113
114
// The current root of the Digraph
115
Node
*dp_root =
nullptr
;
116
117
Atom
*dp_rule6Ref =
nullptr
;
118
119
// We can't store these in a vector, as adding new items will
120
// cause it to reallocate and invalidate the references
121
std::list<Node> d_nodes;
122
std::list<Edge> d_edges;
123
124
void
addEdge(
Node
*beg,
Bond
*bond,
Node
*end);
125
};
126
127
}
// namespace CIPLabeler
128
}
// namespace RDKit
BoostEndInclude.h
BoostStartInclude.h
TooManyNodesException.h
RDKit::Atom
The class for representing atoms.
Definition
Atom.h:75
RDKit::Bond
class for representing a bond
Definition
Bond.h:48
RDKit::CIPLabeler::CIPMol
Definition
CIPMol.h:66
RDKit::CIPLabeler::Digraph::Digraph
Digraph(const CIPMol &mol, Atom *atom, bool atropsomerMode=false)
RDKit::CIPLabeler::Digraph::operator=
Digraph & operator=(const Digraph &)=delete
RDKit::CIPLabeler::Digraph::changeRoot
void changeRoot(Node *newroot)
RDKit::CIPLabeler::Digraph::getOriginalRoot
Node * getOriginalRoot() const
RDKit::CIPLabeler::Digraph::setRule6Ref
void setRule6Ref(Atom *ref)
RDKit::CIPLabeler::Digraph::getRule6Ref
Atom * getRule6Ref() const
RDKit::CIPLabeler::Digraph::expand
void expand(Node *beg)
RDKit::CIPLabeler::Digraph::Digraph
Digraph(const CIPMol &&mol, Atom *atom, bool atropsomerMode=false)=delete
RDKit::CIPLabeler::Digraph::getMol
const CIPMol & getMol() const
RDKit::CIPLabeler::Digraph::getCurrentRoot
Node * getCurrentRoot() const
RDKit::CIPLabeler::Digraph::Digraph
Digraph(CIPMol &&mol, Atom *atom, bool atropsomerMode=false)=delete
RDKit::CIPLabeler::Digraph::seenAtom
bool seenAtom(Atom *atom) const
RDKit::CIPLabeler::Digraph::Digraph
Digraph(const Digraph &)=delete
RDKit::CIPLabeler::Digraph::Digraph
Digraph()=delete
RDKit::CIPLabeler::Digraph::addNode
Node & addNode(std::vector< std::uint32_t > &&visit, Atom *atom, boost::rational< int > &&frac, int dist, uint8_t flags)
RDKit::CIPLabeler::Digraph::getNumNodes
int getNumNodes() const
RDKit::CIPLabeler::Digraph::getNodes
std::vector< Node * > getNodes(Atom *atom) const
RDKit::CIPLabeler::Edge
Definition
Edge.h:23
RDKit::CIPLabeler::Node
Definition
Node.h:28
RDKit::CIPLabeler
Definition
CIPLabeler.h:27
RDKit
Std stuff.
Definition
Abbreviations.h:19
GraphMol
CIPLabeler
Digraph.h
Generated on
for RDKit by
1.17.0