Skip to content

Commit

Permalink
Added missing atom type: positively charged P with three neighbors, o…
Browse files Browse the repository at this point in the history
…f which one double bonded

Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Oct 21, 2010
1 parent f6b13dc commit 58a2e0e
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -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");
Expand Down
9 changes: 9 additions & 0 deletions src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1084,6 +1084,15 @@
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>

<at:AtomType rdf:ID="P.anium">
<at:formalCharge>1</at:formalCharge>
<at:hasElement rdf:resource="&elem;P"/>
<at:formalNeighbourCount>3</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>1</at:piBondCount>
<at:hybridization rdf:resource="&at;sp2"/>
</at:AtomType>

<at:AtomType rdf:ID="P.irane">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;P"/>
Expand Down
37 changes: 37 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 58a2e0e

Please sign in to comment.