Skip to content

Commit

Permalink
Zn 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 Sep 11, 2011
1 parent 862b91d commit 8cf1d4d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 17 deletions.
45 changes: 30 additions & 15 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -143,6 +143,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveBarium(atomContainer, atom);
} else if ("Ga".equals(atom.getSymbol())) {
type = perceiveGallium(atomContainer, atom);
} else if ("Zn".equals(atom.getSymbol())) {
type = perceiveZinc(atomContainer, atom);
} else if ("Al".equals(atom.getSymbol())) {
type = perceiveAluminium(atomContainer, atom);
} else if ("Ni".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -1593,6 +1595,33 @@ private IAtomType perceiveAluminium(IAtomContainer atomContainer, IAtom atom) th
}
return null;
}
private IAtomType perceiveZinc(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
return null;
} else if (atomContainer.getConnectedBondsCount(atom) == 0
&& (atom.getFormalCharge() != null
&& atom.getFormalCharge() == 0)) {
IAtomType type = getAtomType("Zn.metallic");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atomContainer.getConnectedBondsCount(atom) == 0
&& (atom.getFormalCharge() != null
&& atom.getFormalCharge() == 2)) {
IAtomType type = getAtomType("Zn.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atomContainer.getConnectedBondsCount(atom) == 1
&& (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0)) {
IAtomType type = getAtomType("Zn.1");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atomContainer.getConnectedBondsCount(atom) == 2
&& (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0)) {
IAtomType type = getAtomType("Zn");
if (isAcceptable(atom, atomContainer, type)) return type;
}
return null;
}
private IAtomType perceiveChromium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0
Expand Down Expand Up @@ -1643,21 +1672,7 @@ private IAtomType perceiveOrganometallicCenters(IAtomContainer atomContainer, IA
IAtomType type = getAtomType("Po");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Zn".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
return null;
} else if (atomContainer.getConnectedBondsCount(atom) == 2 &&
(atom.getFormalCharge() == CDKConstants.UNSET ||
atom.getFormalCharge() == 0)) {
IAtomType type = getAtomType("Zn");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atom.getFormalCharge() != CDKConstants.UNSET ||
atom.getFormalCharge() == 2) {
IAtomType type = getAtomType("Zn.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Sn".equals(atom.getSymbol())) {
} else if ("Sn".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
return null;
Expand Down
18 changes: 16 additions & 2 deletions src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1653,14 +1653,14 @@
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

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

<at:AtomType rdf:ID="Zn.2plus">
<at:AtomType rdf:ID="Zn.2plus">
<at:formalCharge>2</at:formalCharge>
<at:hasElement rdf:resource="&elem;Zn"/>
<at:formalNeighbourCount>0</at:formalNeighbourCount>
Expand All @@ -1676,6 +1676,20 @@
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

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

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

<at:AtomType rdf:ID="Mn.2plus">
<at:formalCharge>2</at:formalCharge>
<at:hasElement rdf:resource="&elem;Mn"/>
Expand Down
31 changes: 31 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -3520,6 +3520,37 @@ public void testPine() throws Exception {
}
}

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


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

@Test
public void test_Zn_1() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Zn");
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 = {"Zn.1", "C.sp2"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

/**
* Vanadate. PDB HET ID : VO4.
*
Expand Down

0 comments on commit 8cf1d4d

Please sign in to comment.