Skip to content

Commit

Permalink
Resolve #495
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay committed Oct 25, 2018
1 parent 04dfa04 commit a64b2e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,15 @@ public DescriptorValue calculate(IAtomContainer atomContainer) {
// looking for suitable oxygen atoms
else if (atom.getSymbol().equals("O") && atom.getFormalCharge() <= 0) {
//excluding oxygens that are adjacent to a nitrogen or to an aromatic carbon
List<IAtom> neighbours = ac.getConnectedAtomsList(atom);
for (IAtom neighbour : neighbours)
if (neighbour.getSymbol().equals("N")
|| (neighbour.getSymbol().equals("C") && neighbour.getFlag(CDKConstants.ISAROMATIC)))
continue atomloop;
List<IBond> neighbours = ac.getConnectedBondsList(atom);
for (IBond bond : neighbours) {
IAtom neighbor = bond.getOther(atom);
if (neighbor.getSymbol().equals("N") ||
(neighbor.getSymbol().equals("C") &&
neighbor.isAromatic() &&
bond.getOrder() != IBond.Order.DOUBLE))
continue atomloop;;
}
hBondAcceptors++;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@

import javax.vecmath.Point3d;

import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.exception.InvalidSmilesException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
Expand Down Expand Up @@ -119,4 +121,17 @@ public void testCID9257() throws CDKException {
descriptor.setParameters(params);
Assert.assertEquals(2, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue());
}

/**
* @see <a href="https://github.com/cdk/cdk/issues/495">Issue 495</a>
*/
@Test
public void exocyclicOxygenInAromaticRing() throws InvalidSmilesException {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer m = sp.parseSmiles("Cn1c2nc([nH]c2c(=O)n(c1=O)C)C1CCCC1");

HBondAcceptorCountDescriptor hbond_acceptor_desc = new HBondAcceptorCountDescriptor();
int actual = ((IntegerResult)hbond_acceptor_desc.calculate(m).getValue()).intValue();
Assert.assertThat(actual, CoreMatchers.is(3));
}
}

0 comments on commit a64b2e0

Please sign in to comment.