Skip to content

Commit 3d502b1

Browse files
committed
Renamed bondOrderSum to valence, add the implH count to the valence in the first pass
1 parent 120e17e commit 3d502b1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

base/standard/src/main/java/org/openscience/cdk/aromaticity/DaylightModel.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int[] contribution(IAtomContainer container, RingSearch ringSearch) {
8585
// - this avoids costly operations such as looking up connected
8686
// bonds on each atom at the cost of memory
8787
int[] degree = new int[n];
88-
int[] bondOrderSum = new int[n];
88+
int[] valence = new int[n];
8989
int[] nCyclicPiBonds = new int[n];
9090
int[] exocyclicPiBond = new int[n];
9191
int[] electrons = new int[n];
@@ -97,8 +97,10 @@ int[] contribution(IAtomContainer container, RingSearch ringSearch) {
9797
for (int i = 0; i < n; i++) {
9898
IAtom a = container.getAtom(i);
9999
atomIndex.put(a, i);
100-
degree[i] = checkNotNull(a.getImplicitHydrogenCount(),
101-
"Aromaticity model requires implicit hydrogen count is set.");
100+
int implH = checkNotNull(a.getImplicitHydrogenCount(),
101+
"Aromaticity model requires implicit hydrogen count is set.");
102+
degree[i] = implH;
103+
valence[i] = implH;
102104
}
103105

104106
// for each bond we increase the degree count and check for cyclic and
@@ -128,8 +130,8 @@ int[] contribution(IAtomContainer container, RingSearch ringSearch) {
128130
case SINGLE:
129131
case TRIPLE:
130132
case QUADRUPLE:
131-
bondOrderSum[u] += order.numeric();
132-
bondOrderSum[v] += order.numeric();
133+
valence[u] += order.numeric();
134+
valence[v] += order.numeric();
133135
}
134136
}
135137

@@ -141,7 +143,7 @@ int[] contribution(IAtomContainer container, RingSearch ringSearch) {
141143

142144
// abnormal valence, usually indicated a radical. these cause problems
143145
// with kekulisations
144-
int bondedValence = bondOrderSum[i] + container.getAtom(i).getImplicitHydrogenCount();
146+
int bondedValence = valence[i];
145147
if (!normal(element, charge, bondedValence)) {
146148
electrons[i] = -1;
147149
}
@@ -170,7 +172,7 @@ else if (nCyclicPiBonds[i] == 1) {
170172
// here is we count the number free valence electrons but also
171173
// check if the bonded valence is okay (i.e. not a radical)
172174
else if (charge <= 0 && charge > -3) {
173-
if (valence(element, charge) - bondOrderSum[i] >= 2)
175+
if (valence(element, charge) - valence[i] >= 2)
174176
electrons[i] = 2;
175177
else
176178
electrons[i] = -1;

0 commit comments

Comments
 (0)