Skip to content

Commit 8ae5460

Browse files
committed
Cont replacing getSymbol.equals in ALOGPDescriptor using regex
1 parent cc814c3 commit 8ae5460

File tree

1 file changed

+25
-25
lines changed
  • descriptor/qsarmolecular/src/main/java/org/openscience/cdk/qsar/descriptors/molecular

1 file changed

+25
-25
lines changed

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

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -476,11 +476,11 @@ private void calcGroup001_005(int i) {
476476
int htype = getHAtomType(atom, ca);
477477
frags[htype] += atom.getImplicitHydrogenCount();
478478
for (int j = 0; j < ca.size(); j++) {
479-
if (ca.get(j).getSymbol().equals("C")) {
479+
if (ca.get(j).getAtomicNumber() == IElement.C) {
480480
frags[1]++;
481481
alogpfrag[i] = 1;
482482
}
483-
else if (ca.get(j).getSymbol().equals("H")) {
483+
else if (ca.get(j).getAtomicNumber() == IElement.H) {
484484
frags[htype]++;
485485
alogpfrag[atomContainer.indexOf(ca.get(j))] = htype;
486486
}
@@ -507,9 +507,9 @@ private void calcGroup002_006_007(int i) {
507507
int heteroCount = 0;
508508
// logger.debug("here");
509509
for (int j = 0; j < nbors.size(); j++) {
510-
if (nbors.get(j).getSymbol().equals("C"))
510+
if (nbors.get(j).getAtomicNumber() == IElement.C)
511511
carbonCount++;
512-
else if (nbors.get(j).getSymbol().equals("H")) {
512+
else if (nbors.get(j).getAtomicNumber() == IElement.H) {
513513
frags[htype]++;
514514
alogpfrag[atomContainer.indexOf(nbors.get(j))] = htype;
515515
}
@@ -545,9 +545,9 @@ private void calcGroup003_008_009_010(int i) {
545545
int heteroCount = 0;
546546
// logger.debug("here");
547547
for (int j = 0; j <= ca.size() - 1; j++) {
548-
if (((IAtom) ca.get(j)).getSymbol().equals("C"))
548+
if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.C)
549549
carbonCount++;
550-
else if (((IAtom) ca.get(j)).getSymbol().equals("H")) {
550+
else if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.H) {
551551
frags[htype]++;
552552
alogpfrag[((IAtom) ca.get(j)).getIndex()] = htype;
553553
}
@@ -582,7 +582,7 @@ private void calcGroup004_011_to_014(int i) {
582582
int heteroCount = 0;
583583
// logger.debug("here");
584584
for (int j = 0; j <= ca.size() - 1; j++) {
585-
if (((IAtom) ca.get(j)).getSymbol().equals("C"))
585+
if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.C)
586586
carbonCount++;
587587
else
588588
heteroCount++;
@@ -640,7 +640,7 @@ private void calcGroup016_018_036_037(int i) {
640640
boolean haveCsAr = false;
641641

642642
for (int j = 0; j <= ca.size() - 1; j++) {
643-
if (((IAtom) ca.get(j)).getSymbol().equals("H")) {
643+
if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.H) {
644644
alogpfrag[atomContainer.indexOf(ca.get(j))] = htype;
645645
continue;
646646
}
@@ -778,7 +778,7 @@ private void calcGroup021_to_023_040(int i) {
778778
}
779779
}
780780
else if (fragment[i].equals("SddC")) {
781-
if (((IAtom) nbors.get(0)).getSymbol().equals("C") && ((IAtom) nbors.get(1)).getSymbol().equals("C")) {// R==C==R
781+
if (((IAtom) nbors.get(0)).getAtomicNumber() == IElement.C && ((IAtom) nbors.get(1)).getAtomicNumber() == IElement.C) {// R==C==R
782782
frags[22]++;
783783
alogpfrag[i] = 22;
784784
}
@@ -999,7 +999,7 @@ public int compare(IAtom a, IAtom b) {
999999
}
10001000

10011001
}
1002-
} else if (sameringatoms[0].getSymbol().equals("C") && sameringatoms[1].getSymbol().equals("C")) {
1002+
} else if (sameringatoms[0].getAtomicNumber() == IElement.C && sameringatoms[1].getAtomicNumber() == IElement.C) {
10031003

10041004
if (nonringatom.getAtomicNumber() == IElement.C) {// R--CR--R
10051005
frags[25]++;
@@ -1009,8 +1009,8 @@ public int compare(IAtom a, IAtom b) {
10091009
alogpfrag[i] = 26;
10101010
}
10111011

1012-
} else if ((sameringatoms[0].getSymbol().equals("C") && sameringatoms[1].getAtomicNumber() != IElement.C)
1013-
|| (sameringatoms[0].getAtomicNumber() != IElement.C && sameringatoms[1].getSymbol().equals("C"))) {
1012+
} else if ((sameringatoms[0].getAtomicNumber() == IElement.C && sameringatoms[1].getAtomicNumber() != IElement.C)
1013+
|| (sameringatoms[0].getAtomicNumber() != IElement.C && sameringatoms[1].getAtomicNumber() == IElement.C)) {
10141014

10151015
if (haveDouble1 && haveDouble2) { // R--CR--X
10161016
if (nonringatom.getAtomicNumber() == IElement.C) {
@@ -1290,7 +1290,7 @@ private void calcGroup059_060_063(int i) {
12901290
} else {
12911291

12921292
for (int j = 0; j <= ca.size() - 1; j++) {
1293-
if (((IAtom)ca.get(j)).getSymbol().equals("C")) {
1293+
if (((IAtom)ca.get(j)).getAtomicNumber() == IElement.C) {
12941294
List ca2 = atomContainer.getConnectedAtomsList(((IAtom) ca.get(j)));
12951295
for (int k = 0; k <= ca2.size() - 1; k++) {
12961296
if (atomContainer.getBond(((IAtom) ca.get(j)), (IAtom) ca2.get(k)).getOrder() == IBond.Order.DOUBLE) {
@@ -1338,7 +1338,7 @@ private void calcGroup066_to_079(int i) {
13381338
frags[htype] += atom.getImplicitHydrogenCount();
13391339

13401340
for (int j = 0; j <= nbors.size() - 1; j++) {
1341-
if (((IAtom) nbors.get(j)).getSymbol().equals("H")) continue;
1341+
if (((IAtom) nbors.get(j)).getAtomicNumber() == IElement.H) continue;
13421342
if (((IAtom) nbors.get(j)).getFlag(CDKConstants.ISAROMATIC))
13431343
nAr++;
13441344
else
@@ -1473,9 +1473,9 @@ private void calcGroup066_to_079(int i) {
14731473
boolean flag2 = false;
14741474

14751475
for (int j = 0; j <= nbors.size() - 1; j++) {
1476-
if (((IAtom) nbors.get(j)).getSymbol().equals("H")) continue;
1476+
if (((IAtom) nbors.get(j)).getAtomicNumber() == IElement.H) continue;
14771477
if (atomContainer.getBond(ai, ((IAtom) nbors.get(j))).getOrder() == IBond.Order.DOUBLE) {
1478-
if (((IAtom) nbors.get(j)).getSymbol().equals("C")) {
1478+
if (((IAtom) nbors.get(j)).getAtomicNumber() == IElement.C) {
14791479
frags[74]++;
14801480
alogpfrag[i] = 74;
14811481
return;
@@ -1867,10 +1867,10 @@ private void calcGroup107(int i) {
18671867
}
18681868
// IAtom [] ca=atomContainer.getConnectedAtoms(atomContainer.getAtomAt(i));
18691869
//
1870-
// if ((ca[0].getSymbol().equals("C") && ca[1].getSymbol().equals("C"))
1870+
// if ((ca[0].getAtomicNumber() == IElement.C && ca[1].getAtomicNumber() == IElement.C)
18711871
// ||
1872-
// (ca[0].getSymbol().equals("C") && ca[1].getSymbol().equals("S")) ||
1873-
// (ca[0].getSymbol().equals("S") && ca[1].getSymbol().equals("C"))) {
1872+
// (ca[0].getAtomicNumber() == IElement.C && ca[1].getAtomicNumber() == IElement.S) ||
1873+
// (ca[0].getAtomicNumber() == IElement.S && ca[1].getAtomicNumber() == IElement.C)) {
18741874
// frags[107]++;
18751875
// alogpfrag[i]=107;
18761876
// }
@@ -1898,11 +1898,11 @@ private void calcGroup109(int i) {
18981898

18991899
for (int j = 0; j <= ca.size() - 1; j++) {
19001900
if (atomContainer.getBond(ai, ((IAtom) ca.get(j))).getOrder() == IBond.Order.SINGLE) {
1901-
if (((IAtom) ca.get(j)).getSymbol().equals("C")) {
1901+
if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.C) {
19021902
ssCCount++;
19031903
}
19041904
} else if (atomContainer.getBond(ai, ((IAtom) ca.get(j))).getOrder() == IBond.Order.DOUBLE) {
1905-
if (((IAtom) ca.get(j)).getSymbol().equals("O")) {
1905+
if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.O) {
19061906
sdOCount++;
19071907
}
19081908
}
@@ -1923,11 +1923,11 @@ private void calcGroup110(int i) {
19231923

19241924
for (int j = 0; j <= ca.size() - 1; j++) {
19251925
if (atomContainer.getBond(ai, ((IAtom) ca.get(j))).getOrder() == IBond.Order.SINGLE) {
1926-
if (((IAtom) ca.get(j)).getSymbol().equals("C")) {
1926+
if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.C) {
19271927
ssCCount++;
19281928
}
19291929
} else if (atomContainer.getBond(ai, ((IAtom) ca.get(j))).getOrder() == IBond.Order.DOUBLE) {
1930-
if (((IAtom) ca.get(j)).getSymbol().equals("O")) {
1930+
if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.O) {
19311931
sdOCount++;
19321932
}
19331933
}
@@ -1976,7 +1976,7 @@ private void calcGroup116_117_120(int i) {
19761976

19771977
for (int j = 0; j <= ca.size() - 1; j++) {
19781978
if (atomContainer.getBond(ai, ((IAtom) ca.get(j))).getOrder() == IBond.Order.SINGLE) {
1979-
if (((IAtom) ca.get(j)).getSymbol().equals("C")) {
1979+
if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.C) {
19801980
rCount++;
19811981
} else {
19821982
xCount++;
@@ -2013,7 +2013,7 @@ private void calcGroup118_119(int i) {
20132013

20142014
for (int j = 0; j <= ca.size() - 1; j++) {
20152015
if (atomContainer.getBond(ai, ((IAtom) ca.get(j))).getOrder() == IBond.Order.SINGLE) {
2016-
if (((IAtom) ca.get(j)).getSymbol().equals("C")) {
2016+
if (((IAtom) ca.get(j)).getAtomicNumber() == IElement.C) {
20172017
rCount++;
20182018
} else {
20192019
xCount++;

0 commit comments

Comments
 (0)