Skip to content

Commit fd45bb3

Browse files
committed
Remove unused atomArom and clean up warnings/style.
1 parent 065380c commit fd45bb3

File tree

1 file changed

+15
-23
lines changed

1 file changed

+15
-23
lines changed

descriptor/qsarmolecular/src/main/java/org/openscience/cdk/qsar/descriptors/molecular/SmallRingDescriptor.java

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public class SmallRingDescriptor implements IMolecularDescriptor {
6868
private int[] ringBlock; // ring block identifier; 0=not in a ring
6969
private int[][] smallRings; // all rings of size 3 through 7
7070
private int[] bondOrder; // numeric bond order for easy reference
71-
private boolean[] atomArom, bondArom; // aromaticity precalculated
71+
private boolean[] bondArom; // aromaticity precalculated
7272
private boolean[] piAtom; // true for all atoms involved in a double bond
7373
private int[] implicitH; // hydrogens in addition to those encoded
7474

@@ -143,10 +143,7 @@ public Object getParameterType(String name) {
143143
@Override
144144
public DescriptorValue calculate(IAtomContainer mol) {
145145
this.mol = mol;
146-
try {
147-
excavateMolecule();
148-
} catch (CDKException ex) {
149-
}
146+
excavateMolecule();
150147

151148
int nSmallRings = smallRings.length;
152149
int nAromRings = 0;
@@ -200,7 +197,7 @@ else if (sz == 8)
200197
}
201198

202199
// analyze the molecule graph, and build up the desired properties
203-
private void excavateMolecule() throws CDKException {
200+
private void excavateMolecule() {
204201
final int na = mol.getAtomCount(), nb = mol.getBondCount();
205202

206203
// build up an index-based neighbour/edge graph
@@ -256,7 +253,7 @@ else if (bond.getOrder() == IBond.Order.TRIPLE)
256253

257254
markRingBlocks();
258255

259-
ArrayList<int[]> rings = new ArrayList<int[]>();
256+
ArrayList<int[]> rings = new ArrayList<>();
260257
for (int rsz = 3; rsz <= 7; rsz++) {
261258
int[] path = new int[rsz];
262259
for (int n = 0; n < na; n++)
@@ -355,8 +352,8 @@ private void recursiveRingFind(int[] path, int psize, int capacity, int rblk, Ar
355352
}
356353
if (!fnd) {
357354
int newPath[] = new int[capacity];
358-
for (int i = 0; i < psize; i++)
359-
newPath[i] = path[i];
355+
if (psize >= 0)
356+
System.arraycopy(path, 0, newPath, 0, psize);
360357
newPath[psize] = adj;
361358
recursiveRingFind(newPath, psize + 1, capacity, rblk, rings);
362359
}
@@ -376,11 +373,11 @@ private void recursiveRingFind(int[] path, int psize, int capacity, int rblk, Ar
376373

377374
// make sure every element in the path has exactly 2 neighbours within the path; otherwise it is spanning a bridge, which
378375
// is an undesirable ring definition
379-
for (int n = 0; n < path.length; n++) {
380-
int count = 0, p = path[n];
381-
for (int i = 0; i < atomAdj[p].length; i++)
382-
for (int j = 0; j < path.length; j++)
383-
if (atomAdj[p][i] == path[j]) {
376+
for (int aPath : path) {
377+
int count = 0;
378+
for (int i = 0; i < atomAdj[aPath].length; i++)
379+
for (int aPath1 : path)
380+
if (atomAdj[aPath][i] == aPath1) {
384381
count++;
385382
break;
386383
}
@@ -400,8 +397,7 @@ private void recursiveRingFind(int[] path, int psize, int capacity, int rblk, Ar
400397
path = newPath;
401398
}
402399

403-
for (int n = 0; n < rings.size(); n++) {
404-
int[] look = rings.get(n);
400+
for (int[] look : rings) {
405401
boolean same = true;
406402
for (int i = 0; i < psize; i++)
407403
if (look[i] != path[i]) {
@@ -419,7 +415,6 @@ private void recursiveRingFind(int[] path, int psize, int capacity, int rblk, Ar
419415
// rings such as thiophene, imidazolium, porphyrins, etc.: these systems will be left in their original single/double bond form
420416
private void detectStrictAromaticity() {
421417
final int na = mol.getAtomCount(), nb = mol.getBondCount();
422-
atomArom = new boolean[na];
423418
bondArom = new boolean[nb];
424419

425420
if (smallRings.length == 0) return;
@@ -432,7 +427,7 @@ private void detectStrictAromaticity() {
432427
piAtom[mol.indexOf(bond.getEnd())] = true;
433428
}
434429

435-
ArrayList<int[]> maybe = new ArrayList<int[]>(); // rings which may yet be aromatic
430+
ArrayList<int[]> maybe = new ArrayList<>(); // rings which may yet be aromatic
436431
for (int[] r : smallRings)
437432
if (r.length == 6) {
438433
boolean consider = true;
@@ -469,7 +464,6 @@ private void detectStrictAromaticity() {
469464

470465
// the ring is deemed aromatic: mark the flags and remove from the maybe list
471466
for (int i = 0; i < r.length; i++) {
472-
atomArom[r[i]] = true;
473467
bondArom[findBond(r[i], r[i == 5 ? 0 : i + 1])] = true;
474468
}
475469
maybe.remove(n);
@@ -509,7 +503,7 @@ private void detectRelaxedAromaticity() {
509503
}
510504

511505
// pull out all of the small rings that could be upgraded to aromatic
512-
ArrayList<int[]> rings = new ArrayList<int[]>();
506+
ArrayList<int[]> rings = new ArrayList<>();
513507
for (int[] r : smallRings)
514508
if (r.length <= 7) {
515509
boolean alreadyArom = true, isInvalid = false;
@@ -559,7 +553,6 @@ else if (bondOrder[b1] == 2)
559553
if (arom) {
560554
for (int i = 0; i < r.length; i++) {
561555
int a = r[i], b = findBond(r[i], r[i < r.length - 1 ? i + 1 : 0]);
562-
atomArom[a] = true;
563556
bondArom[b] = true;
564557
}
565558
rings.remove(n);
@@ -618,8 +611,7 @@ else if (first < 0) {
618611
private int[] appendInteger(int[] a, int v) {
619612
if (a == null || a.length == 0) return new int[]{v};
620613
int[] b = new int[a.length + 1];
621-
for (int n = a.length - 1; n >= 0; n--)
622-
b[n] = a[n];
614+
System.arraycopy(a, 0, b, 0, a.length);
623615
b[a.length] = v;
624616
return b;
625617
}

0 commit comments

Comments
 (0)