Skip to content

Commit

Permalink
Ru 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 55ed20d commit 220d183
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 1 deletion.
19 changes: 19 additions & 0 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 ("Ru".equals(atom.getSymbol())) {
type = perceiveRuthenium(atomContainer, atom);
} else if ("Zn".equals(atom.getSymbol())) {
type = perceiveZinc(atomContainer, atom);
} else if ("Al".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -1918,6 +1920,23 @@ private IAtomType perceiveIodine(IAtomContainer atomContainer, IAtom atom) throw
return null;
}

private IAtomType perceiveRuthenium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0) {
IAtomType type = getAtomType("Ru.6");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == -2) {
IAtomType type = getAtomType("Ru.2minus.6");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == -3) {
IAtomType type = getAtomType("Ru.3minus.6");
if (isAcceptable(atom, atomContainer, type)) return type;
}
return null;
}

private IAtomType perceivePotassium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
Expand Down
27 changes: 27 additions & 0 deletions src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1607,6 +1607,33 @@
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>

<at:AtomType rdf:ID="Ru.6">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Ru"/>
<at:formalNeighbourCount>6</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>0</at:piBondCount>
<at:hybridization rdf:resource="&at;sp3d2"/>
</at:AtomType>

<at:AtomType rdf:ID="Ru.2minus.6">
<at:formalCharge>-2</at:formalCharge>
<at:hasElement rdf:resource="&elem;Ru"/>
<at:formalNeighbourCount>6</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>0</at:piBondCount>
<at:hybridization rdf:resource="&at;octahedral"/>
</at:AtomType>

<at:AtomType rdf:ID="Ru.3minus.6">
<at:formalCharge>-3</at:formalCharge>
<at:hasElement rdf:resource="&elem;Ru"/>
<at:formalNeighbourCount>6</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>0</at:piBondCount>
<at:hybridization rdf:resource="&at;octahedral"/>
</at:AtomType>

<at:AtomType rdf:ID="As.5">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;As"/>
Expand Down
175 changes: 174 additions & 1 deletion src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -5875,12 +5875,185 @@ public void testSulphur4() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

/**
* One of the ruthenium atom types in ruthenium red (CHEBI:34956).
*/
@Test
public void test_Ru_3minus_6() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Ru");
a1.setFormalCharge(-3);
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"N");
a2.setFormalCharge(+1);
mol.addAtom(a2);
IAtom a3 = builder.newInstance(IAtom.class,"N");
a3.setFormalCharge(+1);
mol.addAtom(a3);
IAtom a4 = builder.newInstance(IAtom.class,"N");
a4.setFormalCharge(+1);
mol.addAtom(a4);
IAtom a5 = builder.newInstance(IAtom.class,"N");
a5.setFormalCharge(+1);
mol.addAtom(a5);
IAtom a6 = builder.newInstance(IAtom.class,"N");
a6.setFormalCharge(+1);
mol.addAtom(a6);
IAtom a7 = builder.newInstance(IAtom.class,"O");
a7.setFormalCharge(0);
mol.addAtom(a7);
IBond b1 = builder.newInstance(IBond.class,a1, a4, IBond.Order.SINGLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a6, a1, IBond.Order.SINGLE);
mol.addBond(b2);
IBond b3 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
mol.addBond(b3);
IBond b4 = builder.newInstance(IBond.class,a1, a7, IBond.Order.SINGLE);
mol.addBond(b4);
IBond b5 = builder.newInstance(IBond.class,a1, a5, IBond.Order.SINGLE);
mol.addBond(b5);
IBond b6 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
mol.addBond(b6);

String[] expectedTypes = {"Ru.3minus.6", "N.plus", "N.plus", "N.plus", "N.plus", "N.plus", "O.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

/**
* One of the ruthenium atom types in ruthenium red (CHEBI:34956).
*/
@Test
public void test_Ru_2minus_6() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Ru");
a1.setFormalCharge(-2);
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"N");
a2.setFormalCharge(+1);
mol.addAtom(a2);
IAtom a3 = builder.newInstance(IAtom.class,"N");
a3.setFormalCharge(+1);
mol.addAtom(a3);
IAtom a4 = builder.newInstance(IAtom.class,"N");
a4.setFormalCharge(+1);
mol.addAtom(a4);
IAtom a5 = builder.newInstance(IAtom.class,"N");
a5.setFormalCharge(+1);
mol.addAtom(a5);
IAtom a6 = builder.newInstance(IAtom.class,"O");
a6.setFormalCharge(0);
mol.addAtom(a6);
IAtom a7 = builder.newInstance(IAtom.class,"O");
a7.setFormalCharge(0);
mol.addAtom(a7);
IBond b1 = builder.newInstance(IBond.class,a1, a4, IBond.Order.SINGLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a6, a1, IBond.Order.SINGLE);
mol.addBond(b2);
IBond b3 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
mol.addBond(b3);
IBond b4 = builder.newInstance(IBond.class,a1, a7, IBond.Order.SINGLE);
mol.addBond(b4);
IBond b5 = builder.newInstance(IBond.class,a1, a5, IBond.Order.SINGLE);
mol.addBond(b5);
IBond b6 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
mol.addBond(b6);

String[] expectedTypes = {"Ru.2minus.6", "N.plus", "N.plus", "N.plus", "N.plus", "O.sp3", "O.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_Ru_10plus_6() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Ru");
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);
IAtom a5 = builder.newInstance(IAtom.class,"C");
a5.setFormalCharge(0);
mol.addAtom(a5);
IAtom a6 = builder.newInstance(IAtom.class,"C");
a6.setFormalCharge(0);
mol.addAtom(a6);
IAtom a7 = builder.newInstance(IAtom.class,"C");
a7.setFormalCharge(0);
mol.addAtom(a7);
IBond b1 = builder.newInstance(IBond.class,a1, a4, IBond.Order.SINGLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a6, a1, IBond.Order.SINGLE);
mol.addBond(b2);
IBond b3 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
mol.addBond(b3);
IBond b4 = builder.newInstance(IBond.class,a1, a7, IBond.Order.SINGLE);
mol.addBond(b4);
IBond b5 = builder.newInstance(IBond.class,a1, a5, IBond.Order.SINGLE);
mol.addBond(b5);
IBond b6 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
mol.addBond(b6);

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

@Test
public void test_Ru_6() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Ru");
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);
IAtom a5 = builder.newInstance(IAtom.class,"C");
a5.setFormalCharge(0);
mol.addAtom(a5);
IAtom a6 = builder.newInstance(IAtom.class,"C");
a6.setFormalCharge(0);
mol.addAtom(a6);
IAtom a7 = builder.newInstance(IAtom.class,"C");
a7.setFormalCharge(0);
mol.addAtom(a7);
IBond b1 = builder.newInstance(IBond.class,a1, a5, IBond.Order.SINGLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a1, a6, IBond.Order.SINGLE);
mol.addBond(b2);
IBond b3 = builder.newInstance(IBond.class,a7, a1, IBond.Order.SINGLE);
mol.addBond(b3);
IBond b4 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
mol.addBond(b4);
IBond b5 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
mol.addBond(b5);
IBond b6 = builder.newInstance(IBond.class,a1, a4, IBond.Order.SINGLE);
mol.addBond(b6);

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

/*
* This method *must* be the last method in the class.
*/
@Test public void countTestedAtomTypes() {
super.countTestedAtomTypes(testedAtomTypes);
}

}

0 comments on commit 220d183

Please sign in to comment.