Skip to content

Commit 44e2aa2

Browse files
committed
Simplify and correct alpha carbon hydrogen check, type := 51.
1 parent c793b01 commit 44e2aa2

File tree

1 file changed

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

1 file changed

+10
-18
lines changed

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

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -995,44 +995,36 @@ private void calcGroup025_026_028_029_031_032_034_035_043_044(int i) {
995995
}
996996
}
997997

998-
private int getHAtomType(IAtom ai, java.util.List connectedAtoms) {
998+
private int getHAtomType(IAtom ai, List connectedAtoms) {
999999
//ai is the atom connected to a H atoms.
10001000
//ai environment determines what is the H atom type
10011001
//This procedure is applied only for carbons
10021002
//i.e. H atom type 50 is never returned
10031003

1004-
java.util.List ca;
1004+
List<IAtom> ca;
10051005
if (connectedAtoms == null)
10061006
ca = atomContainer.getConnectedAtomsList(ai);
10071007
else
10081008
ca = connectedAtoms;
10091009

10101010
// first check for alpha carbon:
1011+
// -C=X, -C#X and -C:X
10111012
if (ai.getSymbol().equals("C") && !ai.getFlag(CDKConstants.ISAROMATIC)) {
10121013
for (int j = 0; j <= ca.size() - 1; j++) {
10131014
if (atomContainer.getBond(ai, ((IAtom) ca.get(j))).getOrder() == IBond.Order.SINGLE
10141015
&& ((IAtom) ca.get(j)).getSymbol().equals("C")) { // single bonded
1015-
java.util.List ca2 = atomContainer.getConnectedAtomsList((IAtom) ca.get(j));
1016-
1017-
for (int k = 0; k <= ca2.size() - 1; k++) {
1018-
IAtom ca2k = (IAtom) ca2.get(k);
1019-
if (!ca2k.getSymbol().equals("C")) {
1020-
if (atomContainer.getBond(((IAtom) ca.get(j)), ca2k).getOrder() != IBond.Order.SINGLE)
1016+
IAtom aCarbon = ca.get(j);
1017+
for (IBond bond : aCarbon.bonds()) {
1018+
IAtom nbor = bond.getOther(aCarbon);
1019+
if (nbor.getAtomicNumber() != 6)
1020+
if (bond.isAromatic() || bond.getOrder() != IBond.Order.SINGLE)
10211021
return 51;
1022-
1023-
if (((IAtom) ca.get(j)).getFlag(CDKConstants.ISAROMATIC)
1024-
&& ca2k.getFlag(CDKConstants.ISAROMATIC)) {
1025-
if (inSameAromaticRing(atomContainer, ((IAtom) ca.get(j)), ca2k, rs)) {
1026-
return 51;
1027-
}
1028-
}
1029-
} // end !ca2[k].getSymbol().equals("C"))
1030-
} // end k loop
1022+
}
10311023
} // end if (atomContainer.getBond(ai, ((IAtom)ca.get(j))).getOrder() == IBond.Order.SINGLE) {
10321024
}// end j loop
10331025
} // end if(ai.getSymbol().equals("C") && !ai.getFlag(CDKConstants.ISAROMATIC))
10341026

1035-
java.util.List bonds = atomContainer.getConnectedBondsList(ai);
1027+
List bonds = atomContainer.getConnectedBondsList(ai);
10361028
int doublebondcount = 0;
10371029
int triplebondcount = 0;
10381030
String hybrid = "";

0 commit comments

Comments
 (0)