Skip to content

Commit 0599c87

Browse files
committed
When there are three atoms in the ring we need to make a choice for these atom types. To be consistent with VEGA we prioritise putting X (hetero) in the ring.
1 parent e820858 commit 0599c87

File tree

1 file changed

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

1 file changed

+14
-7
lines changed

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -919,20 +919,27 @@ private void calcGroup025_026_028_029_031_032_034_035_043_044(int i) {
919919

920920
if (sameringatomscount == 2) {
921921
int count = 0;
922-
for (int j = 0; j <= ca.size() - 1; j++) {
923-
if (inSameAromaticRing(atomContainer, ai, ((IAtom) ca.get(j)), rs)) {
924-
sameringatoms[count] = (IAtom) ca.get(j);
922+
for (int j = 0; j <= nbors.size() - 1; j++) {
923+
if (inSameAromaticRing(atomContainer, atm, ((IAtom) nbors.get(j)), rs)) {
924+
sameringatoms[count] = (IAtom) nbors.get(j);
925925
count++;
926926
} else {
927-
nonringatom = (IAtom) ca.get(j);
927+
nonringatom = (IAtom) nbors.get(j);
928928
}
929929

930930
}
931931
} else { // sameringsatomscount==3
932932
// arbitrarily assign atoms: (no way to decide consistently)
933-
sameringatoms[0] = (IAtom) ca.get(0);
934-
sameringatoms[1] = (IAtom) ca.get(1);
935-
nonringatom = (IAtom) ca.get(2);
933+
// but to match VEGA we choose to but hetero atoms in the ring
934+
Collections.sort(nbors, new Comparator<IAtom>() {
935+
@Override
936+
public int compare(IAtom a, IAtom b) {
937+
return -Boolean.compare(isHetero(a), isHetero(b));
938+
}
939+
});
940+
sameringatoms[0] = (IAtom) nbors.get(0);
941+
sameringatoms[1] = (IAtom) nbors.get(1);
942+
nonringatom = (IAtom) nbors.get(2);
936943
}
937944

938945
// check if both hetero atoms have at least one double bond

0 commit comments

Comments
 (0)