Skip to content

Commit dfbc328

Browse files
johnmayegonw
authored andcommitted
Fix phenol hbond acceptor count
1 parent 8ddd9a5 commit dfbc328

File tree

2 files changed

+29
-6
lines changed

2 files changed

+29
-6
lines changed

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

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,15 +192,27 @@ public DescriptorValue calculate(IAtomContainer atomContainer) {
192192
}
193193
// looking for suitable oxygen atoms
194194
else if (atom.getAtomicNumber() == IElement.O && atom.getFormalCharge() <= 0) {
195-
//excluding oxygens that are adjacent to a nitrogen or to an aromatic carbon
195+
196196
List<IBond> neighbours = ac.getConnectedBondsList(atom);
197+
198+
// get the "true" degree
199+
int degree = 0;
200+
for (IBond bond : neighbours) {
201+
IAtom nbor = bond.getOther(atom);
202+
if (nbor.getAtomicNumber() != IAtom.H)
203+
degree++;
204+
}
205+
197206
for (IBond bond : neighbours) {
198207
IAtom neighbor = bond.getOther(atom);
199-
if (neighbor.getAtomicNumber() == IElement.N ||
200-
(neighbor.getAtomicNumber() == IElement.C &&
201-
neighbor.isAromatic() &&
202-
bond.getOrder() != IBond.Order.DOUBLE))
203-
continue atomloop;;
208+
// adjacent to a nitrogen => reject
209+
if (neighbor.getAtomicNumber() == IElement.N)
210+
continue atomloop;
211+
// adjacent to an aromatic carbon and degree != 1
212+
if (neighbor.getAtomicNumber() == IElement.C &&
213+
neighbor.isAromatic() &&
214+
degree != 1)
215+
continue atomloop;
204216
}
205217
hBondAcceptors++;
206218
}

descriptor/qsarmolecular/src/test/java/org/openscience/cdk/qsar/descriptors/molecular/HBondAcceptorCountDescriptorTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,15 @@ public void exocyclicOxygenInAromaticRing() throws InvalidSmilesException {
134134
int actual = ((IntegerResult)hbond_acceptor_desc.calculate(m).getValue()).intValue();
135135
org.hamcrest.MatcherAssert.assertThat(actual, CoreMatchers.is(3));
136136
}
137+
138+
@Test
139+
public void testPhenol() throws CDKException {
140+
Object[] params = {new Boolean(true)};
141+
descriptor.setParameters(params);
142+
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
143+
// original molecule O=N(=O)c1cccc2cn[nH]c12 - correct kekulisation will give
144+
// the same result. this test though should depend on kekulisation working
145+
IAtomContainer mol = sp.parseSmiles("Oc1ccccc1");
146+
Assert.assertEquals(1, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue());
147+
}
137148
}

0 commit comments

Comments
 (0)