RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
Node.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 <cstdint>
14#include <vector>
15
16#include "Descriptor.h"
17#include "Mancude.h"
18#include "Edge.h"
19
20namespace RDKit {
21
22class Atom;
23
24namespace CIPLabeler {
25
26class Digraph;
27
28class Node {
29 public:
30 /**
31 * Flag indicates whether the node has been expanded.
32 */
33 static constexpr uint8_t EXPANDED = 0x1;
34
35 /**
36 * Flag indicates whether the node was duplicated
37 * at a ring closure.
38 */
39 static constexpr uint8_t RING_DUPLICATE = 0x2;
40
41 /**
42 * Flag indicates whether the node was duplicated
43 * at a bond with order &gt; 1.
44 */
45 static constexpr uint8_t BOND_DUPLICATE = 0x4;
46
47 /**
48 * Mask to check if a node is duplicated.
49 */
50
51 static constexpr uint8_t DUPLICATE = RING_DUPLICATE | BOND_DUPLICATE;
52
53 /**
54 * Node was created for an implicit hydrogen,
55 * the 'atom' value will be null.
56 */
57 static constexpr uint8_t IMPL_HYDROGEN = 0x8;
58
59 /**
60 * Mask to check if a node is duplicated or created for an implicit H (not a
61 * primary node).
62 */
63 static constexpr uint8_t DUPLICATE_OR_H =
65
66 Node() = delete;
67 Node(const Node &) = delete;
68 Node &operator=(const Node &) = delete;
69
70 Node(Digraph *g, std::vector<std::uint32_t> &&visit, Atom *atom,
71 boost::rational<int> &&frac, int dist, uint8_t flags);
72
74
75 Atom *getAtom() const;
76
77 unsigned int getAtomIdx() const;
78
79 int getDistance() const;
80
81 boost::rational<int> getAtomicNumFraction() const;
82
83 int getAtomicNum() const;
84
85 unsigned getMassNum() const;
86
87 double getAtomicMass() const;
88
90
91 bool isSet(uint8_t mask) const;
92
93 bool isDuplicate() const;
94
95 bool isDuplicateOrH() const;
96
97 bool isTerminal() const;
98
99 bool isExpanded() const;
100
101 bool isVisited(int idx) const;
102
103 Node *newChild(int idx, Atom *atom) const;
104
105 Node *newBondDuplicateChild(int idx, Atom *atom) const;
106
107 Node *newRingDuplicateChild(int idx, Atom *atom) const;
108
110
111 void add(Edge *e);
112
113 void setAux(Descriptor desc);
114
115 const std::vector<Edge *> &getEdges() const;
116
117 std::vector<Edge *> getEdges(Atom *end) const;
118
119 std::vector<Edge *> getNonTerminalOutEdges() const;
120
121 private:
122 Digraph *dp_g;
123 Atom *dp_atom;
124 int d_dist;
125 boost::rational<int> d_atomic_num;
126 double d_atomic_mass;
128 uint8_t d_flags = 0x0;
129
130 std::vector<Edge *> d_edges;
131
132 std::vector<std::uint32_t> d_visit;
133
134 Node *newTerminalChild(int idx, Atom *atom, uint8_t flags) const;
135};
136
137} // namespace CIPLabeler
138} // namespace RDKit
The class for representing atoms.
Definition Atom.h:75
Node * newRingDuplicateChild(int idx, Atom *atom) const
double getAtomicMass() const
Node * newBondDuplicateChild(int idx, Atom *atom) const
Node(const Node &)=delete
Node & operator=(const Node &)=delete
bool isDuplicateOrH() const
Digraph * getDigraph() const
Node * newImplicitHydrogenChild() const
static constexpr uint8_t DUPLICATE_OR_H
Definition Node.h:63
void setAux(Descriptor desc)
unsigned int getAtomIdx() const
static constexpr uint8_t BOND_DUPLICATE
Definition Node.h:45
const std::vector< Edge * > & getEdges() const
static constexpr uint8_t EXPANDED
Definition Node.h:33
static constexpr uint8_t DUPLICATE
Definition Node.h:51
Atom * getAtom() const
std::vector< Edge * > getNonTerminalOutEdges() const
Node * newChild(int idx, Atom *atom) const
static constexpr uint8_t RING_DUPLICATE
Definition Node.h:39
Descriptor getAux() const
bool isSet(uint8_t mask) const
std::vector< Edge * > getEdges(Atom *end) const
static constexpr uint8_t IMPL_HYDROGEN
Definition Node.h:57
unsigned getMassNum() const
Node(Digraph *g, std::vector< std::uint32_t > &&visit, Atom *atom, boost::rational< int > &&frac, int dist, uint8_t flags)
bool isDuplicate() const
boost::rational< int > getAtomicNumFraction() const
bool isVisited(int idx) const
Std stuff.