Skip to content

Commit

Permalink
Mo 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 cc46f63 commit a8c44bc
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -131,6 +131,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveChromium(atomContainer, atom);
} else if ("Se".equals(atom.getSymbol())) {
type = perceiveSelenium(atomContainer, atom);
} else if ("Mo".equals(atom.getSymbol())) {
type = perceiveMolybdenum(atomContainer, atom);
} else if ("Rb".equals(atom.getSymbol())) {
type = perceiveRubidium(atomContainer, atom);
} else if ("Te".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -606,7 +608,23 @@ private IAtomType perceiveNitrogenRadicals(IAtomContainer atomContainer, IAtom a
}
return null;
}

private IAtomType perceiveMolybdenum(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors == 4) {
IAtomType type = getAtomType("Mo.4");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
}
IAtomType type1 = getAtomType("Mo.metallic");
if (isAcceptable(atom, atomContainer, type1)) {
return type1;
}
}
return null;
}
private IAtomType perceiveNitrogens(IAtomContainer atomContainer, IAtom atom) throws CDKException {
// if hybridization is given, use that
if (hasOneSingleElectron(atomContainer, atom)) {
Expand Down
14 changes: 14 additions & 0 deletions src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1862,6 +1862,20 @@
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>

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

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

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

@Test
public void test_Mo_4() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Mo");
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);
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.DOUBLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.DOUBLE);
mol.addBond(b2);
IBond b3 = builder.newInstance(IBond.class,a1, a4, IBond.Order.SINGLE);
mol.addBond(b3);
IBond b4 = builder.newInstance(IBond.class,a1, a5, IBond.Order.SINGLE);
mol.addBond(b4);


String[] expectedTypes = {"Mo.4", "C.sp2", "C.sp2", "C.sp3", "C.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

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


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


@Test
Expand Down

0 comments on commit a8c44bc

Please sign in to comment.