From 58a2e0e76adb9de3ae34d0ad9dc6926c2f9b6d28 Mon Sep 17 00:00:00 2001 From: Egon Willighagen Date: Thu, 21 Oct 2010 14:52:53 +0200 Subject: [PATCH] Added missing atom type: positively charged P with three neighbors, of which one double bonded Signed-off-by: Rajarshi Guha --- .../cdk/atomtype/CDKAtomTypeMatcher.java | 10 ++++- .../cdk/dict/data/cdk-atom-types.owl | 9 +++++ .../cdk/atomtype/CDKAtomTypeMatcherTest.java | 37 +++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java b/src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java index 60e26ebcf97..0cd4e59a297 100644 --- a/src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java +++ b/src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java @@ -907,8 +907,14 @@ private IAtomType perceivePhosphors(IAtomContainer atomContainer, IAtom atom) // no idea how to deal with this yet return null; } else if (neighborcount == 3) { - IAtomType type = getAtomType("P.ine"); - if (isAcceptable(atom, atomContainer, type)) return type; + if (atom.getFormalCharge() != null & + atom.getFormalCharge().intValue() == 1) { + IAtomType type = getAtomType("P.anium"); + if (isAcceptable(atom, atomContainer, type)) return type; + } else { + IAtomType type = getAtomType("P.ine"); + if (isAcceptable(atom, atomContainer, type)) return type; + } } else if (neighborcount == 2) { if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { IAtomType type = getAtomType("P.irane"); diff --git a/src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl b/src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl index 0c8a961a713..6097946b547 100644 --- a/src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl +++ b/src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl @@ -1084,6 +1084,15 @@ + + 1 + + 3 + 0 + 1 + + + 0 diff --git a/src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java b/src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java index 480724e3a4f..abba0e88452 100644 --- a/src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java +++ b/src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java @@ -39,6 +39,7 @@ import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; +import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IAtomType.Hybridization; import org.openscience.cdk.interfaces.IBond.Order; @@ -1103,6 +1104,42 @@ public void testTetrahydropyran() throws Exception { assertAtomTypes(testedAtomTypes, expectedTypes, mol); } + /** + * @cdk.inchi InChI=1S/HO3P/c1-4(2)3/h(H-,1,2,3)/p+1 + */ + @Test public void testPhosphorousAcid() throws Exception { + IMolecule mol = new Molecule(); + IChemObjectBuilder builder = mol.getBuilder(); + IAtom a1 = builder.newInstance(IAtom.class,"P"); + a1.setFormalCharge(1); + mol.addAtom(a1); + IAtom a2 = builder.newInstance(IAtom.class,"O"); + mol.addAtom(a2); + IAtom a3 = builder.newInstance(IAtom.class,"O"); + mol.addAtom(a3); + IAtom a4 = builder.newInstance(IAtom.class,"O"); + mol.addAtom(a4); + IAtom a5 = builder.newInstance(IAtom.class,"H"); + mol.addAtom(a5); + IAtom a6 = builder.newInstance(IAtom.class,"H"); + mol.addAtom(a6); + IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE); + mol.addBond(b1); + IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE); + mol.addBond(b2); + IBond b3 = builder.newInstance(IBond.class,a1, a4, IBond.Order.DOUBLE); + mol.addBond(b3); + IBond b4 = builder.newInstance(IBond.class,a2, a5, IBond.Order.SINGLE); + mol.addBond(b4); + IBond b5 = builder.newInstance(IBond.class,a3, a6, IBond.Order.SINGLE); + mol.addBond(b5); + + String[] expectedTypes = { + "P.anium", "O.sp3", "O.sp3", "O.sp2", "H", "H" + }; + assertAtomTypes(testedAtomTypes, expectedTypes, mol); + } + @Test public void testDiethylPhosphine() throws Exception { IMolecule mol = new Molecule(); IAtom atom = new Atom("C");