Skip to content

Commit

Permalink
Split the C.sp atom type into C.sp for (-C#) and C.allene for (=C=)
Browse files Browse the repository at this point in the history
Change-Id: I4f496fdff6e4f04650831673bc573f3a6a3d5d1d
Signed-off-by: John May <john.wilkinsonmay@gmail.com>
  • Loading branch information
egonw committed Oct 7, 2012
1 parent 492a9cd commit 001f488
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -36,6 +36,7 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IBond.Order;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IPseudoAtom;
import org.openscience.cdk.interfaces.IRing;
Expand Down Expand Up @@ -375,8 +376,14 @@ private IAtomType perceiveCarbons(IAtomContainer atomContainer, IAtom atom)
IAtomType type = getAtomType("C.sp3");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atom.getHybridization() == Hybridization.SP1) {
IAtomType type = getAtomType("C.sp");
if (isAcceptable(atom, atomContainer, type)) return type;
IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom);
if (maxBondOrder == Order.TRIPLE) {
IAtomType type = getAtomType("C.sp");
if (isAcceptable(atom, atomContainer, type)) return type;
} else {
IAtomType type = getAtomType("C.allene");
if (isAcceptable(atom, atomContainer, type)) return type;
}
}
} else if (atom.getFlag(CDKConstants.ISAROMATIC)) {
IAtomType type = getAtomType("C.sp2");
Expand Down Expand Up @@ -435,7 +442,7 @@ private IAtomType perceiveCarbons(IAtomContainer atomContainer, IAtom atom)
// OK, one or two double bonds?
int doubleBondCount = countAttachedDoubleBonds(atomContainer, atom);
if (doubleBondCount == 2) {
IAtomType type = getAtomType("C.sp");
IAtomType type = getAtomType("C.allene");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (doubleBondCount == 1) {
IAtomType type = getAtomType("C.sp2");
Expand Down
18 changes: 14 additions & 4 deletions src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -191,19 +191,29 @@
<at:AtomType rdf:ID="C.sp">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;C"/>
<at:formalNeighbourCount>2</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>2</at:piBondCount>
<at:hybridization rdf:resource="&at;sp1"/>
<at:formalBondType rdf:resource="&bo;single"/>
<at:formalBondType rdf:resource="&bo;triple"/>
</at:AtomType>

<at:AtomType rdf:ID="C.allene">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;C"/>
<at:lonePairCount>0</at:lonePairCount>
<at:hybridization rdf:resource="&at;sp1"/>
<at:formalBondType rdf:resource="&bo;double"/>
<at:formalBondType rdf:resource="&bo;double"/>
</at:AtomType>

<at:AtomType rdf:ID="C.sp2">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;C"/>
<at:formalNeighbourCount>3</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>1</at:piBondCount>
<at:hybridization rdf:resource="&at;sp2"/>
<at:formalBondType rdf:resource="&bo;double"/>
<at:formalBondType rdf:resource="&bo;single"/>
<at:formalBondType rdf:resource="&bo;single"/>
</at:AtomType>

<at:AtomType rdf:ID="C.plus.planar">
Expand Down
15 changes: 15 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -1477,6 +1477,21 @@ public void testTetrahydropyran() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test public void testAllene() throws Exception {
IMolecule mol = new Molecule();
IAtom atom1 = new Atom("C");
IAtom atom2 = new Atom("C");
IAtom atom3 = new Atom("C");
mol.addAtom(atom1);
mol.addAtom(atom2);
mol.addAtom(atom3);
mol.addBond(0,1,Order.DOUBLE);
mol.addBond(1,2,Order.DOUBLE);

String[] expectedTypes = new String[]{"C.sp2", "C.allene", "C.sp2"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test public void testAzide2() throws Exception {
IAtomContainer mol = new AtomContainer();
IAtom atom = new Atom("C");
Expand Down

0 comments on commit 001f488

Please sign in to comment.