Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Pb final
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
gilleain authored and egonw committed Sep 4, 2011
1 parent ae54e0c commit 6207b4f
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -147,6 +147,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveGadolinum(atomContainer, atom);
} else if ("Ge".equals(atom.getSymbol())) {
type = perceiveGermanium(atomContainer, atom);
} else if ("Pb".equals(atom.getSymbol())) {
type = perceiveLead(atomContainer, atom);
} else if ("Tl".equals(atom.getSymbol())) {
type = perceiveThallium(atomContainer, atom);
} else if ("Sb".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -2151,6 +2153,26 @@ private IAtomType perceiveThallium(IAtomContainer atomContainer, IAtom atom) thr
}
return null;
}

private IAtomType perceiveLead(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 0 &&
atomContainer.getConnectedBondsCount(atom) == 0) {
IAtomType type = getAtomType("Pb.neutral");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 2 &&
atomContainer.getConnectedBondsCount(atom) == 0) {
IAtomType type = getAtomType("Pb.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 0 &&
atomContainer.getConnectedBondsCount(atom) == 1) {
IAtomType type = getAtomType("Pb.1");
if (isAcceptable(atom, atomContainer, type)) return type;
}
return null;
}

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

<at:AtomType rdf:ID="Pb.neutral">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Pb"/>
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Pb.2plus">
<at:formalCharge>2</at:formalCharge>
<at:hasElement rdf:resource="&elem;Pb"/>
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Pb.1">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Pb"/>
<at:formalNeighbourCount>1</at:formalNeighbourCount>
<at:piBondCount>1</at:piBondCount>
<at:hybridization rdf:resource="&at;sp1"/>
</at:AtomType>

<at:AtomType rdf:ID="Tl.plus">
<at:formalCharge>1</at:formalCharge>
<at:hasElement rdf:resource="&elem;Tl"/>
Expand Down
43 changes: 43 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -3955,6 +3955,49 @@ public void testMethylphosphinicAcid() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_Pb_1() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Pb");
a1.setFormalCharge(0);
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"C");
a2.setFormalCharge(0);
mol.addAtom(a2);
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.DOUBLE);
mol.addBond(b1);


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

@Test
public void test_Pb_2plus() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Pb");
a1.setFormalCharge(2);
mol.addAtom(a1);


String[] expectedTypes = {"Pb.2plus"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_Pb_neutral() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Pb");
a1.setFormalCharge(0);
mol.addAtom(a1);


String[] expectedTypes = {"Pb.neutral"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

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

0 comments on commit 6207b4f

Please sign in to comment.