Browse files

Mn final

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information...
1 parent a872522 commit 105850ec67ea099534b1ae3bf27875a401ede7de @gilleain gilleain committed with egonw Jul 21, 2011
View
37 src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
@@ -134,6 +134,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveGallium(atomContainer, atom);
} else if ("Ge".equals(atom.getSymbol())) {
type = perceiveGermanium(atomContainer, atom);
+ } else if ("Mn".equals(atom.getSymbol())) {
+ type = perceiveManganese(atomContainer, atom);
} else {
if (type == null) type = perceiveHalogens(atomContainer, atom);
if (type == null) type = perceiveCommonSalts(atomContainer, atom);
@@ -1294,15 +1296,6 @@ private IAtomType perceiveCommonSalts(IAtomContainer atomContainer, IAtom atom)
IAtomType type = getAtomType("Cu.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
- } else if ("Mn".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("Mn.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
@@ -1544,6 +1537,32 @@ private IAtomType perceiveSilicon(IAtomContainer atomContainer, IAtom atom) thro
}
return null;
}
+
+ private IAtomType perceiveManganese(IAtomContainer atomContainer, IAtom atom) throws CDKException {
+ if (hasOneSingleElectron(atomContainer, atom)) {
+ // no idea how to deal with this yet
+ return null;
+ } else if ((atom.getFormalCharge() != null
+ && atom.getFormalCharge() == 0)) {
+ int neighbors = atomContainer.getConnectedAtomsCount(atom);
+ if (neighbors == 2) {
+ IAtomType type02 = getAtomType("Mn.2");
+ if (isAcceptable(atom, atomContainer, type02)) return type02;
+ } else if (neighbors == 0) {
+ IAtomType type03 = getAtomType("Mn.metallic");
+ if (isAcceptable(atom, atomContainer, type03)) return type03;
+ }
+ } else if ((atom.getFormalCharge() != null
+ && atom.getFormalCharge() == +2)) {
+ IAtomType type = getAtomType("Mn.2plus");
+ if (isAcceptable(atom, atomContainer, type)) return type;
+ } else if ((atom.getFormalCharge() != null
+ && atom.getFormalCharge() == +3)) {
+ IAtomType type = getAtomType("Mn.3plus");
+ if (isAcceptable(atom, atomContainer, type)) return type;
+ }
+ return null;
+ }
private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom) {
return countAttachedDoubleBonds(container, atom, null);
View
23 src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
@@ -1351,13 +1351,34 @@
<at:lonePairCount>0</at:lonePairCount>
</at:AtomType>
- <at:AtomType rdf:ID="Mn.2plus">
+ <at:AtomType rdf:ID="Mn.metallic">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Mn"/>
+ <at:formalNeighbourCount>0</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="Mn.2plus">
<at:formalCharge>2</at:formalCharge>
<at:hasElement rdf:resource="&elem;Mn"/>
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>
+ <at:AtomType rdf:ID="Mn.3plus">
+ <at:formalCharge>3</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Mn"/>
+ <at:formalNeighbourCount>0</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="Mn.2">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Mn"/>
+ <at:formalNeighbourCount>2</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
<at:AtomType rdf:ID="He">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;He"/>
View
50 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
@@ -3616,4 +3616,54 @@ public void testMethylphosphinicAcid() throws Exception {
};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
+
+
+ @Test
+ public void test_Mn_3plus() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class,"Mn");
+ a1.setFormalCharge(3);
+ mol.addAtom(a1);
+
+
+ String[] expectedTypes = {"Mn.3plus"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ @Test
+ public void test_Mn_2() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class,"Mn");
+ 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 = {"Mn.2", "C.sp3", "C.sp3"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ @Test
+ public void test_Mn_metallic() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class,"Mn");
+ a1.setFormalCharge(0);
+ mol.addAtom(a1);
+
+
+ String[] expectedTypes = {"Mn.metallic"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
}

0 comments on commit 105850e

Please sign in to comment.