Skip to content

Commit

Permalink
Al 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 033fb9f commit fed0c1a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 14 deletions.
42 changes: 29 additions & 13 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 ("Al".equals(atom.getSymbol())) {
type = perceiveAluminium(atomContainer, atom);
} else if ("Ni".equals(atom.getSymbol())) {
type = perceiveNickel(atomContainer, atom);
} else if ("Gd".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -1562,7 +1564,33 @@ private IAtomType perceiveBarium(IAtomContainer atomContainer, IAtom atom) throw
}
return null;
}

private IAtomType perceiveAluminium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 3) {
int connectedBondsCount = atomContainer.getConnectedBondsCount(atom);
if (connectedBondsCount == 0) {
IAtomType type = getAtomType("Al.3plus");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
}
} else if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0
&& atomContainer.getConnectedBondsCount(atom) == 3) {
IAtomType type = getAtomType("Al");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
} else if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == -3
&& atomContainer.getConnectedBondsCount(atom) == 6) {
IAtomType type = getAtomType("Al.3minus");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
}
return null;
}
private IAtomType perceiveChromium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0
Expand Down Expand Up @@ -1644,18 +1672,6 @@ private IAtomType perceiveOrganometallicCenters(IAtomContainer atomContainer, IA
IAtomType type = getAtomType("V.3minus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Al".equals(atom.getSymbol())) {
if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 3 &&
atomContainer.getConnectedBondsCount(atom) == 0) {
IAtomType type = getAtomType("Al.3plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 0 &&
atomContainer.getConnectedBondsCount(atom) == 3){
IAtomType type = getAtomType("Al");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Sc".equals(atom.getSymbol())) {
if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == -3 &&
Expand Down
9 changes: 8 additions & 1 deletion src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1317,7 +1317,7 @@
<at:lonePairCount>0</at:lonePairCount>
</at:AtomType>

<at:AtomType rdf:ID="Al">
<at:AtomType rdf:ID="Al">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Al"/>
<at:formalNeighbourCount>3</at:formalNeighbourCount>
Expand All @@ -1326,6 +1326,13 @@
<at:lonePairCount>0</at:lonePairCount>
</at:AtomType>

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

<at:AtomType rdf:ID="Fe.2plus">
<at:formalCharge>2</at:formalCharge>
<at:hasElement rdf:resource="&elem;Fe"/>
Expand Down
47 changes: 47 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -3520,6 +3520,53 @@ public void testPine() throws Exception {
}
}

/**
* Hexafluoroaluminate
* @cdk.inchi InChI=1S/Al.6FH.3Na/h;6*1H;;;/q+3;;;;;;;3*+1/p-6
*/
@Test
public void test_Al_3minus() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Al");
a1.setFormalCharge(-3);
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, a2, IBond.Order.SINGLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
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);
IBond b5 = builder.newInstance(IBond.class,a1, a6, IBond.Order.SINGLE);
mol.addBond(b5);
IBond b6 = builder.newInstance(IBond.class,a1, a7, IBond.Order.SINGLE);
mol.addBond(b6);


String[] expectedTypes = {"Al.3minus", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}


@Test
public void testSe_sp3d1_4() throws Exception {
Expand Down

0 comments on commit fed0c1a

Please sign in to comment.