Skip to content

Commit

Permalink
Cu 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 3, 2011
1 parent 3152dd0 commit 177e5bd
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 10 deletions.
44 changes: 35 additions & 9 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -135,6 +135,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveRubidium(atomContainer, atom);
} else if ("Te".equals(atom.getSymbol())) {
type = perceiveTellurium(atomContainer, atom);
} else if ("Cu".equals(atom.getSymbol())) {
type = perceiveCopper(atomContainer, atom);
} else if ("Ba".equals(atom.getSymbol())) {
type = perceiveBarium(atomContainer, atom);
} else if ("Ga".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -1423,15 +1425,6 @@ private IAtomType perceiveCommonSalts(IAtomContainer atomContainer, IAtom atom)
IAtomType type = getAtomType("Co.metallic");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Cu".equals(atom.getSymbol())) {
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("Cu.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Pt".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
Expand Down Expand Up @@ -1477,6 +1470,39 @@ private IAtomType perceiveCommonSalts(IAtomContainer atomContainer, IAtom atom)
}
return null;
}
private IAtomType perceiveCopper(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("Cu.2plus");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
} else if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors == 1) {
IAtomType type = getAtomType("Cu.1");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
} else {
IAtomType type01 = getAtomType("Cu.metallic");
if (isAcceptable(atom, atomContainer, type01)) {
return type01;
}
}
} else if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == +1) {
IAtomType type02 = getAtomType("Cu.plus");
if (isAcceptable(atom, atomContainer, type02)) {
return type02;
}
}
return null;
}
private IAtomType perceiveBarium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (hasOneSingleElectron(atomContainer, atom)) {
return null;
Expand Down
23 changes: 22 additions & 1 deletion src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1418,13 +1418,34 @@
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

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

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

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

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

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

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


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

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


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

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


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

@Test
public void test_Ra() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
Expand Down

0 comments on commit 177e5bd

Please sign in to comment.