Skip to content

Commit

Permalink
cleaner patch for Fe atomtype added
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
asad authored and egonw committed Aug 21, 2011
1 parent 66d6321 commit da8d3d0
Showing 1 changed file with 89 additions and 10 deletions.
99 changes: 89 additions & 10 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -143,6 +143,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveGermanium(atomContainer, atom);
} else if ("Hg".equals(atom.getSymbol())) {
type = perceiveMercury(atomContainer, atom);
} else if ("Fe".equals(atom.getSymbol())) {
type = perceiveIron(atomContainer, atom);
} else if ("Ra".equals(atom.getSymbol())) {
type = perceiveRadium(atomContainer, atom);
} else if ("Au".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -852,7 +854,93 @@ private int countExplicitHydrogens(IAtom atom, IAtomContainer atomContainer) {
return count;
}


private IAtomType perceiveIron(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if ("Fe".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
return null;
} else if ((atom.getFormalCharge() != null
&& atom.getFormalCharge() == 0)) {
IAtomType type = getAtomType("Fe.metallic");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors == 2) {
IAtomType type5 = getAtomType("Fe.2");
if (isAcceptable(atom, atomContainer, type5)) {
return type5;
}
} else if (neighbors == 3) {
IAtomType type6 = getAtomType("Fe.3");
if (isAcceptable(atom, atomContainer, type6)) {
return type6;
}
} else if (neighbors == 4) {
IAtomType type7 = getAtomType("Fe.4");
if (isAcceptable(atom, atomContainer, type7)) {
return type7;
}
} else if (neighbors == 5) {
IAtomType type8 = getAtomType("Fe.5");
if (isAcceptable(atom, atomContainer, type8)) {
return type8;
}
} else if (neighbors == 6) {
IAtomType type9 = getAtomType("Fe.6");
if (isAcceptable(atom, atomContainer, type9)) {
return type9;
}
}
} else if ((atom.getFormalCharge() != null
&& atom.getFormalCharge() == 2)) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors <= 1) {
IAtomType type = getAtomType("Fe.2plus");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
}
} else if ((atom.getFormalCharge() != null
&& atom.getFormalCharge() == 1)) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);

if (neighbors == 2) {
IAtomType type0 = getAtomType("Fe.plus");
if (isAcceptable(atom, atomContainer, type0)) {
return type0;
}
}
} else if ((atom.getFormalCharge() != null
&& atom.getFormalCharge() == 3)) {
IAtomType type1 = getAtomType("Fe.3plus");
if (isAcceptable(atom, atomContainer, type1)) {
return type1;
}
} else if ((atom.getFormalCharge() != null
&& atom.getFormalCharge() == -2)) {
IAtomType type2 = getAtomType("Fe.2minus");
if (isAcceptable(atom, atomContainer, type2)) {
return type2;
}
} else if ((atom.getFormalCharge() != null
&& atom.getFormalCharge() == -3)) {
IAtomType type3 = getAtomType("Fe.3minus");
if (isAcceptable(atom, atomContainer, type3)) {
return type3;
}
} else if ((atom.getFormalCharge() != null
&& atom.getFormalCharge() == -4)) {
IAtomType type4 = getAtomType("Fe.4minus");
if (isAcceptable(atom, atomContainer, type4)) {
return type4;
}
}
}
return null;
}


private IAtomType perceiveMercury(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if ("Hg".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
Expand Down Expand Up @@ -1321,15 +1409,6 @@ private IAtomType perceiveCommonSalts(IAtomContainer atomContainer, IAtom atom)
IAtomType type = getAtomType("Mg.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Fe".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("Fe.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Co".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
Expand Down

0 comments on commit da8d3d0

Please sign in to comment.