Skip to content

Commit

Permalink
Co 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 24, 2011
1 parent a75eece commit abf6b33
Show file tree
Hide file tree
Showing 3 changed files with 434 additions and 1 deletion.
59 changes: 59 additions & 0 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -155,6 +155,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveGadolinum(atomContainer, atom);
} else if ("Ge".equals(atom.getSymbol())) {
type = perceiveGermanium(atomContainer, atom);
} else if ("Co".equals(atom.getSymbol())) {
type = perceiveCobalt(atomContainer, atom);
} else if ("Br".equals(atom.getSymbol())) {
type = perceiveBromine(atomContainer, atom);
} else if ("V".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -2370,6 +2372,63 @@ private IAtomType perceiveBromine(IAtomContainer atomContainer, IAtom atom) thro
private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom, String symbol) {
return countAttachedBonds(container, atom, IBond.Order.DOUBLE, symbol);
}

private IAtomType perceiveCobalt(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("Co.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == +3)) {
IAtomType type = getAtomType("Co.3plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() == CDKConstants.UNSET ||
atom.getFormalCharge() == 0)) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors == 2) {
IAtomType type = getAtomType("Co.2");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 4) {
IAtomType type = getAtomType("Co.4");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 6) {
IAtomType type = getAtomType("Co.6");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 1) {
IAtomType type = getAtomType("Co.1");
if (isAcceptable(atom, atomContainer, type)) return type;
} else {
IAtomType type = getAtomType("Co.metallic");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ((atom.getFormalCharge() != null
&& atom.getFormalCharge() == +1)) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors == 2) {
IAtomType type = getAtomType("Co.plus.2");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 4) {
IAtomType type = getAtomType("Co.plus.4");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 1) {
IAtomType type = getAtomType("Co.plus.1");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 6) {
IAtomType type = getAtomType("Co.plus.6");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (neighbors == 5) {
IAtomType type = getAtomType("Co.plus.5");
if (isAcceptable(atom, atomContainer, type)) return type;
} else {
IAtomType type = getAtomType("Co.plus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
}
return null;
}

private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom) {
return countAttachedBonds(container, atom, IBond.Order.DOUBLE, null);
Expand Down
65 changes: 64 additions & 1 deletion src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1494,7 +1494,7 @@
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Co.3plus">
<at:formalCharge>3</at:formalCharge>
<at:hasElement rdf:resource="&elem;Co"/>
Expand All @@ -1508,6 +1508,69 @@
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

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

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

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

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

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

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

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

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

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

<at:AtomType rdf:ID="Cu.plus">
<at:formalCharge>1</at:formalCharge>
Expand Down

0 comments on commit abf6b33

Please sign in to comment.