Skip to content

Commit

Permalink
Sb final
Browse files Browse the repository at this point in the history
  • Loading branch information
gilleain authored and egonw committed Sep 3, 2011
1 parent a8c44bc commit 9b1fe00
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -145,6 +145,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveGallium(atomContainer, atom);
} else if ("Ge".equals(atom.getSymbol())) {
type = perceiveGermanium(atomContainer, atom);
} else if ("Sb".equals(atom.getSymbol())) {
type = perceiveAntimony(atomContainer, atom);
} else if ("Pt".equals(atom.getSymbol())) {
type = perceivePlatinum(atomContainer, atom);
} else if ("Hg".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -2066,6 +2068,23 @@ private IAtomType perceivePlatinum(IAtomContainer atomContainer, IAtom atom) thr
}
return null;
}

private IAtomType perceiveAntimony(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (hasOneSingleElectron(atomContainer, atom)) {
return null;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 0 &&
atomContainer.getConnectedBondsCount(atom) == 3)) {
IAtomType type = getAtomType("Sb.3");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 0 &&
atomContainer.getConnectedBondsCount(atom) == 4)) {
IAtomType type = getAtomType("Sb.4");
if (isAcceptable(atom, atomContainer, type)) return type;
}
return null;
}

private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom) {
return countAttachedDoubleBonds(container, atom, null);
Expand Down
18 changes: 18 additions & 0 deletions src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1919,6 +1919,24 @@
<at:piBondCount>0</at:piBondCount>
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>

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

<at:AtomType rdf:ID="Sb.4">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Sb"/>
<at:formalNeighbourCount>4</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>1</at:piBondCount>
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>

<at:AtomType rdf:ID="Ra.neutral">
<at:formalCharge>0</at:formalCharge>
Expand Down
58 changes: 58 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -3646,6 +3646,64 @@ public void testPentaMethylPhosphane() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_Sb_4() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"C");
a1.setFormalCharge(0);
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"Sb");
a2.setFormalCharge(0);
mol.addAtom(a2);
IAtom a3 = builder.newInstance(IAtom.class,"C");
a3.setFormalCharge(0);
mol.addAtom(a3);
IAtom a4 = builder.newInstance(IAtom.class,"C");
a4.setFormalCharge(0);
mol.addAtom(a4);
IAtom a5 = builder.newInstance(IAtom.class,"C");
a5.setFormalCharge(0);
mol.addAtom(a5);
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a2, a3, IBond.Order.SINGLE);
mol.addBond(b2);
IBond b3 = builder.newInstance(IBond.class,a2, a4, IBond.Order.SINGLE);
mol.addBond(b3);
IBond b4 = builder.newInstance(IBond.class,a2, a5, IBond.Order.DOUBLE);
mol.addBond(b4);

String[] expectedTypes = {"C.sp3", "Sb.4", "C.sp3", "C.sp3", "C.sp2"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_Sb_3() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Sb");
a1.setFormalCharge(0);
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"C");
a2.setFormalCharge(0);
mol.addAtom(a2);
IAtom a3 = builder.newInstance(IAtom.class,"C");
a3.setFormalCharge(0);
mol.addAtom(a3);
IAtom a4 = builder.newInstance(IAtom.class,"C");
a4.setFormalCharge(0);
mol.addAtom(a4);
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.SINGLE);
mol.addBond(b3);

String[] expectedTypes = {"Sb.3", "C.sp3", "C.sp3", "C.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_B_3plus() throws Exception {
Expand Down

0 comments on commit 9b1fe00

Please sign in to comment.