Skip to content

Commit ce8edd7

Browse files
committed
replaced all getSymbol().equals("X") in cdk/descriptor
1 parent b36ab1a commit ce8edd7

File tree

20 files changed

+73
-52
lines changed

20 files changed

+73
-52
lines changed

base/atomtype/src/main/java/org/openscience/cdk/atomtype/SybylAtomTypeMatcher.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import org.openscience.cdk.interfaces.IAtomType;
3333
import org.openscience.cdk.interfaces.IBond;
3434
import org.openscience.cdk.interfaces.IChemObjectBuilder;
35+
import org.openscience.cdk.interfaces.IElement;
36+
3537

3638
/**
3739
* Atom Type matcher for Sybyl atom types. It uses the {@link CDKAtomTypeMatcher}

descriptor/fingerprint/src/main/java/org/openscience/cdk/fingerprint/CircularFingerprinter.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import org.openscience.cdk.interfaces.IAtomContainer;
4747
import org.openscience.cdk.interfaces.IBond;
4848
import org.openscience.cdk.interfaces.IStereoElement;
49-
49+
import org.openscience.cdk.interfaces.IElement;
5050

5151
/**
5252
* <p>Circular fingerprints: for generating fingerprints that are functionally equivalent to ECFP-2/4/6 and FCFP-2/4/6
@@ -1032,7 +1032,7 @@ private void calculateBioTypes() {
10321032
bondSum = new int[na];
10331033
for (int n = 0; n < na; n++)
10341034
if (amask[n]) {
1035-
aliphatic[n] = mol.getAtom(n).getSymbol().equals("C");
1035+
aliphatic[n] = mol.getAtom(n).getAtomicNumber() == IElement.C;
10361036
bondSum[n] = hcount[n];
10371037
}
10381038

@@ -1048,8 +1048,8 @@ private void calculateBioTypes() {
10481048
if (o == 2) {
10491049
hasDouble[a1] = true;
10501050
hasDouble[a2] = true;
1051-
if (mol.getAtom(a1).getSymbol().equals("O")) isOxide[a2] = true;
1052-
if (mol.getAtom(a2).getSymbol().equals("O")) isOxide[a1] = true;
1051+
if (mol.getAtom(a1).getAtomicNumber() == IElement.O) isOxide[a2] = true;
1052+
if (mol.getAtom(a2).getAtomicNumber() == IElement.O) isOxide[a1] = true;
10531053
}
10541054
if (o != 1) {
10551055
aliphatic[a1] = false;
@@ -1119,7 +1119,7 @@ private void considerBioTypeTetrazole(final int[] ring) {
11191119
}
11201120
if (countC != 1 || countN != 4 || ndbl != 2) return;
11211121
for (int n = 0; n < 5; n++)
1122-
if (mol.getAtom(ring[n]).getSymbol().equals("N")) tetrazole[ring[n]] = true;
1122+
if (mol.getAtom(ring[n]).getAtomicNumber() == IElement.N) tetrazole[ring[n]] = true;
11231123
}
11241124

11251125
// hydrogen bond donor
@@ -1137,7 +1137,7 @@ private boolean determineDonor(int aidx) {
11371137
// of amides, which are consider nonacidic
11381138
for (int n = 0; n < atomAdj[aidx].length; n++)
11391139
if (isOxide[atomAdj[aidx][n]]) {
1140-
if (!mol.getAtom(atomAdj[aidx][n]).getSymbol().equals("C") || !el.equals("N")) return false;
1140+
if (mol.getAtom(atomAdj[aidx][n]).getAtomicNumber() != IElement.C || !el.equals("N")) return false;
11411141
}
11421142
return true;
11431143
} else if (el.equals("S")) {
@@ -1163,7 +1163,7 @@ private boolean determineAcceptor(int aidx) {
11631163
if (!lonePair[aidx] || mol.getAtom(aidx).getFormalCharge() > 0) return false;
11641164

11651165
// basic nitrogens do not qualify
1166-
if (atom.getSymbol().equals("N")) {
1166+
if (atom.getAtomicNumber() == IElement.N) {
11671167
boolean basic = true;
11681168
for (int n = 0; n < atomAdj[aidx].length; n++)
11691169
if (!aliphatic[atomAdj[aidx][n]]) {
@@ -1243,7 +1243,7 @@ private boolean determinePositive(int aidx) {
12431243
amine = false;
12441244
break;
12451245
}
1246-
if (!mol.getAtom(a).getSymbol().equals("N")) continue;
1246+
if (mol.getAtom(a).getAtomicNumber() != IElement.N) continue;
12471247
if (bondOrderBioType(bondAdj[aidx][n]) == 2)
12481248
imine = true;
12491249
else if (hcount[a] == 1) amine = true;
@@ -1277,7 +1277,7 @@ private boolean determineNegative(int aidx) {
12771277
for (int n = 0; n < atomAdj[aidx].length; n++)
12781278
if (bondOrderBioType(bondAdj[aidx][n]) == 1) {
12791279
final int a = atomAdj[aidx][n];
1280-
if (mol.getAtom(a).getSymbol().equals("O") && hcount[a] > 0) return true;
1280+
if (mol.getAtom(a).getAtomicNumber() == IElement.O && hcount[a] > 0) return true;
12811281
}
12821282
}
12831283

descriptor/fingerprint/src/main/java/org/openscience/cdk/fingerprint/PubchemFingerprinter.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@
3030
import org.openscience.cdk.interfaces.IBond;
3131
import org.openscience.cdk.interfaces.IChemObjectBuilder;
3232
import org.openscience.cdk.interfaces.IRingSet;
33+
import org.openscience.cdk.interfaces.IElement;
3334
import org.openscience.cdk.smarts.SmartsPattern;
3435
import org.openscience.cdk.tools.periodictable.PeriodicTable;
3536

37+
3638
import java.io.IOException;
3739
import java.util.BitSet;
3840
import java.util.HashMap;
@@ -181,7 +183,7 @@ public int countAnyRing(int size) {
181183

182184
private boolean isCarbonOnlyRing(IAtomContainer ring) {
183185
for (IAtom ringAtom : ring.atoms()) {
184-
if (!ringAtom.getSymbol().equals("C")) return false;
186+
if (ringAtom.getAtomicNumber() != IElement.C) return false;
185187
}
186188
return true;
187189
}
@@ -201,15 +203,15 @@ private boolean isRingUnsaturated(IAtomContainer ring) {
201203
private int countNitrogenInRing(IAtomContainer ring) {
202204
int c = 0;
203205
for (IAtom ringAtom : ring.atoms()) {
204-
if (ringAtom.getSymbol().equals("N")) c++;
206+
if (ringAtom.getAtomicNumber() == IElement.N) c++;
205207
}
206208
return c;
207209
}
208210

209211
private int countHeteroInRing(IAtomContainer ring) {
210212
int c = 0;
211213
for (IAtom ringAtom : ring.atoms()) {
212-
if (!ringAtom.getSymbol().equals("C") && !ringAtom.getSymbol().equals("H")) c++;
214+
if (ringAtom.getAtomicNumber() != IElement.C && ringAtom.getAtomicNumber() != IElement.H) c++;
213215
}
214216
return c;
215217
}

descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/AtomDegreeDescriptor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.openscience.cdk.exception.CDKException;
2626
import org.openscience.cdk.interfaces.IAtom;
2727
import org.openscience.cdk.interfaces.IAtomContainer;
28+
import org.openscience.cdk.interfaces.IElement;
2829
import org.openscience.cdk.qsar.AbstractAtomicDescriptor;
2930
import org.openscience.cdk.qsar.DescriptorSpecification;
3031
import org.openscience.cdk.qsar.DescriptorValue;
@@ -100,7 +101,7 @@ public DescriptorValue calculate(IAtom atom, IAtomContainer container) {
100101
int atomDegree = 0;
101102
List<IAtom> neighboors = container.getConnectedAtomsList(atom);
102103
for (IAtom neighboor : neighboors) {
103-
if (!neighboor.getSymbol().equals("H")) atomDegree += 1;
104+
if (neighboor.getAtomicNumber() != IElement.H) atomDegree += 1;
104105
}
105106
return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(
106107
atomDegree), getDescriptorNames());

descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/IsProtonInAromaticSystemDescriptor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.openscience.cdk.exception.CDKException;
2626
import org.openscience.cdk.interfaces.IAtom;
2727
import org.openscience.cdk.interfaces.IAtomContainer;
28+
import org.openscience.cdk.interfaces.IElement;
2829
import org.openscience.cdk.qsar.AbstractAtomicDescriptor;
2930
import org.openscience.cdk.qsar.DescriptorSpecification;
3031
import org.openscience.cdk.qsar.DescriptorValue;
@@ -150,7 +151,7 @@ public DescriptorValue calculate(IAtom atom, IAtomContainer atomContainer) {
150151
}
151152
List<IAtom> neighboor = mol.getConnectedAtomsList(clonedAtom);
152153
IAtom neighbour0 = (IAtom) neighboor.get(0);
153-
if (atom.getSymbol().equals("H")) {
154+
if (atom.getAtomicNumber() == IElement.H) {
154155
//logger.debug("aromatic proton");
155156
if (neighbour0.getFlag(CDKConstants.ISAROMATIC)) {
156157
isProtonInAromaticSystem = 1;

descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/IsProtonInConjugatedPiSystemDescriptor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.openscience.cdk.interfaces.IAtom;
2828
import org.openscience.cdk.interfaces.IAtomContainer;
2929
import org.openscience.cdk.interfaces.IAtomContainerSet;
30+
import org.openscience.cdk.interfaces.IElement;
3031
import org.openscience.cdk.qsar.AbstractAtomicDescriptor;
3132
import org.openscience.cdk.qsar.DescriptorSpecification;
3233
import org.openscience.cdk.qsar.DescriptorValue;
@@ -147,7 +148,7 @@ public DescriptorValue calculate(IAtom atom, IAtomContainer atomContainer) {
147148
false), NAMES, e);
148149
}
149150
}
150-
if (atom.getSymbol().equals("H")) {
151+
if (atom.getAtomicNumber() == IElement.H) {
151152
if (acold != clonedAtomContainer) {
152153
acold = clonedAtomContainer;
153154
acSet = ConjugatedPiSystemsDetector.detect(mol);

descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/ProtonTotalPartialChargeDescriptor.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.openscience.cdk.exception.CDKException;
2323
import org.openscience.cdk.interfaces.IAtom;
2424
import org.openscience.cdk.interfaces.IAtomContainer;
25+
import org.openscience.cdk.interfaces.IElement;
2526
import org.openscience.cdk.qsar.AbstractAtomicDescriptor;
2627
import org.openscience.cdk.qsar.DescriptorSpecification;
2728
import org.openscience.cdk.qsar.DescriptorValue;
@@ -145,7 +146,7 @@ public DescriptorValue calculate(IAtom atom, IAtomContainer ac) {
145146
protonPartialCharge.add(localAtom.getCharge());
146147
int hydrogenNeighbors = 0;
147148
for (IAtom neighboor : neighboors) {
148-
if (neighboor.getSymbol().equals("H")) {
149+
if (neighboor.getAtomicNumber() == IElement.H) {
149150
hydrogenNeighbors++;
150151
protonPartialCharge.add(neighboor.getCharge());
151152
}

descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/RDFProtonDescriptor_G3R.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.openscience.cdk.interfaces.IBond;
3838
import org.openscience.cdk.interfaces.IRing;
3939
import org.openscience.cdk.interfaces.IRingSet;
40+
import org.openscience.cdk.interfaces.IElement;
4041
import org.openscience.cdk.qsar.AbstractAtomicDescriptor;
4142
import org.openscience.cdk.qsar.DescriptorSpecification;
4243
import org.openscience.cdk.qsar.DescriptorValue;
@@ -176,7 +177,7 @@ public DescriptorValue calculate(IAtom atom, IAtomContainer atomContainer, IRing
176177
int atomPosition = atomContainer.indexOf(atom);
177178
IAtom clonedAtom = varAtomContainer.getAtom(atomPosition);
178179
DoubleArrayResult rdfProtonCalculatedValues = new DoubleArrayResult(G3R_DESC_LENGTH);
179-
if (!atom.getSymbol().equals("H")) {
180+
if (atom.getAtomicNumber() != IElement.H) {
180181
return getDummyDescriptorValue(new CDKException("Invalid atom specified"));
181182
}
182183

@@ -492,16 +493,16 @@ private boolean getIfBondIsNotRotatable(IAtomContainer mol, IBond bond, IAtomCon
492493
if (atom1.getFlag(CDKConstants.ISINRING)) {
493494
counter += 1;
494495
} else {
495-
if (atom1.getSymbol().equals("H"))
496+
if (atom1.getAtomicNumber() == IElement.H)
496497
counter += 1;
497498
else
498499
counter += 0;
499500
}
500501
}
501-
if (atom0.getSymbol().equals("N") && atom1.getSymbol().equals("C")) {
502+
if (atom0.getAtomicNumber() == IElement.N && atom1.getAtomicNumber() == IElement.C) {
502503
if (getIfACarbonIsDoubleBondedToAnOxygen(mol, atom1)) counter += 1;
503504
}
504-
if (atom0.getSymbol().equals("C") && atom1.getSymbol().equals("N")) {
505+
if (atom0.getAtomicNumber() == IElement.C && atom1.getAtomicNumber() == IElement.N) {
505506
if (getIfACarbonIsDoubleBondedToAnOxygen(mol, atom0)) counter += 1;
506507
}
507508
if (counter > 0) isBondNotRotatable = true;
@@ -514,7 +515,7 @@ private boolean getIfACarbonIsDoubleBondedToAnOxygen(IAtomContainer mol, IAtom c
514515
IBond tmpBond;
515516
int counter = 0;
516517
for (IAtom neighbour : neighToCarbon) {
517-
if (neighbour.getSymbol().equals("O")) {
518+
if (neighbour.getAtomicNumber() == IElement.O) {
518519
tmpBond = mol.getBond(neighbour, carbonAtom);
519520
if (tmpBond.getOrder() == IBond.Order.DOUBLE) counter += 1;
520521
}

descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/RDFProtonDescriptor_GDR.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.openscience.cdk.interfaces.IBond;
3939
import org.openscience.cdk.interfaces.IRing;
4040
import org.openscience.cdk.interfaces.IRingSet;
41+
import org.openscience.cdk.interfaces.IElement;
4142
import org.openscience.cdk.qsar.AbstractAtomicDescriptor;
4243
import org.openscience.cdk.qsar.DescriptorSpecification;
4344
import org.openscience.cdk.qsar.DescriptorValue;
@@ -173,7 +174,7 @@ public DescriptorValue calculate(IAtom atom, IAtomContainer atomContainer, IRing
173174
IAtom clonedAtom = varAtomContainer.getAtom(atomPosition);
174175

175176
DoubleArrayResult rdfProtonCalculatedValues = new DoubleArrayResult(gdr_desc_length);
176-
if (!atom.getSymbol().equals("H")) {
177+
if (atom.getAtomicNumber() != IElement.H) {
177178
return getDummyDescriptorValue(new CDKException("Invalid atom specified"));
178179
}
179180

@@ -466,16 +467,16 @@ private boolean getIfBondIsNotRotatable(IAtomContainer mol, IBond bond, IAtomCon
466467
if (atom1.getFlag(CDKConstants.ISINRING)) {
467468
counter += 1;
468469
} else {
469-
if (atom1.getSymbol().equals("H"))
470+
if (atom1.getAtomicNumber() == IElement.H)
470471
counter += 1;
471472
else
472473
counter += 0;
473474
}
474475
}
475-
if (atom0.getSymbol().equals("N") && atom1.getSymbol().equals("C")) {
476+
if (atom0.getAtomicNumber() == IElement.N && atom1.getAtomicNumber() == IElement.C) {
476477
if (getIfACarbonIsDoubleBondedToAnOxygen(mol, atom1)) counter += 1;
477478
}
478-
if (atom0.getSymbol().equals("C") && atom1.getSymbol().equals("N")) {
479+
if (atom0.getAtomicNumber() == IElement.C && atom1.getAtomicNumber() == IElement.N) {
479480
if (getIfACarbonIsDoubleBondedToAnOxygen(mol, atom0)) counter += 1;
480481
}
481482
if (counter > 0) isBondNotRotatable = true;
@@ -488,7 +489,7 @@ private boolean getIfACarbonIsDoubleBondedToAnOxygen(IAtomContainer mol, IAtom c
488489
IBond tmpBond;
489490
int counter = 0;
490491
for (IAtom neighbour : neighToCarbon) {
491-
if (neighbour.getSymbol().equals("O")) {
492+
if (neighbour.getAtomicNumber() == IElement.O) {
492493
tmpBond = mol.getBond(neighbour, carbonAtom);
493494
if (tmpBond.getOrder() == IBond.Order.DOUBLE) counter += 1;
494495
}

descriptor/qsaratomic/src/main/java/org/openscience/cdk/qsar/descriptors/atomic/RDFProtonDescriptor_GHR.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import org.openscience.cdk.interfaces.IBond;
3838
import org.openscience.cdk.interfaces.IRing;
3939
import org.openscience.cdk.interfaces.IRingSet;
40+
import org.openscience.cdk.interfaces.IElement;
4041
import org.openscience.cdk.qsar.AbstractAtomicDescriptor;
4142
import org.openscience.cdk.qsar.DescriptorSpecification;
4243
import org.openscience.cdk.qsar.DescriptorValue;
@@ -171,7 +172,7 @@ public DescriptorValue calculate(IAtom atom, IAtomContainer atomContainer, IRing
171172
IAtom clonedAtom = varAtomContainer.getAtom(atomPosition);
172173

173174
DoubleArrayResult rdfProtonCalculatedValues = new DoubleArrayResult(ghr_desc_length);
174-
if (!atom.getSymbol().equals("H")) {
175+
if (atom.getAtomicNumber() != IElement.H) {
175176
return getDummyDescriptorValue(new CDKException("Invalid atom specified"));
176177
}
177178

@@ -434,16 +435,16 @@ private boolean getIfBondIsNotRotatable(IAtomContainer mol, IBond bond, IAtomCon
434435
if (atom1.getFlag(CDKConstants.ISINRING)) {
435436
counter += 1;
436437
} else {
437-
if (atom1.getSymbol().equals("H"))
438+
if (atom1.getAtomicNumber() == IElement.H)
438439
counter += 1;
439440
else
440441
counter += 0;
441442
}
442443
}
443-
if (atom0.getSymbol().equals("N") && atom1.getSymbol().equals("C")) {
444+
if (atom0.getAtomicNumber() == IElement.N && atom1.getAtomicNumber() == IElement.C) {
444445
if (getIfACarbonIsDoubleBondedToAnOxygen(mol, atom1)) counter += 1;
445446
}
446-
if (atom0.getSymbol().equals("C") && atom1.getSymbol().equals("N")) {
447+
if (atom0.getAtomicNumber() == IElement.C && atom1.getAtomicNumber() == IElement.N) {
447448
if (getIfACarbonIsDoubleBondedToAnOxygen(mol, atom0)) counter += 1;
448449
}
449450
if (counter > 0) isBondNotRotatable = true;
@@ -457,7 +458,7 @@ private boolean getIfACarbonIsDoubleBondedToAnOxygen(IAtomContainer mol, IAtom c
457458
int counter = 0;
458459
for (int nei = 0; nei < neighToCarbon.size(); nei++) {
459460
IAtom neighbour = neighToCarbon.get(nei);
460-
if (neighbour.getSymbol().equals("O")) {
461+
if (neighbour.getAtomicNumber() == IElement.O) {
461462
tmpBond = mol.getBond(neighbour, carbonAtom);
462463
if (tmpBond.getOrder() == IBond.Order.DOUBLE) counter += 1;
463464
}

0 commit comments

Comments
 (0)