Skip to content

Commit

Permalink
Cd final
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
gilleain authored and egonw committed Aug 7, 2011
1 parent 0eebd74 commit 4d68c27
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -1677,6 +1677,27 @@ private IAtomType perceivePlutonium(IAtomContainer atomContainer, IAtom atom) th
}
return null;
}

private IAtomType perceiveCadmium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
return null;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == +2)) {
IAtomType type = getAtomType("Cd.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0)) {
if (atomContainer.getConnectedAtomsCount(atom) == 0) {
IAtomType type = getAtomType("Cd.metallic");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atomContainer.getConnectedAtomsCount(atom) == 2) {
IAtomType type = getAtomType("Cd.2");
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 @@ -1670,4 +1670,26 @@
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

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

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

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

</rdf:RDF>
Expand Up @@ -3689,6 +3689,55 @@ public void testMethylphosphinicAcid() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

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


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

@Test
public void test_Cd_2() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Cd");
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);
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);


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

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


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

@Test
public void test_Pu() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
Expand All @@ -3697,7 +3746,6 @@ public void test_Pu() throws Exception {
a1.setFormalCharge(0);
mol.addAtom(a1);


String[] expectedTypes = {"Pu"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
Expand Down

0 comments on commit 4d68c27

Please sign in to comment.