diff --git a/src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java b/src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java index d14e1b6dfa3..c6823797745 100755 --- a/src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java +++ b/src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java @@ -135,6 +135,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom) type = perceiveGallium(atomContainer, atom); } else if ("Ge".equals(atom.getSymbol())) { type = perceiveGermanium(atomContainer, atom); + } else if ("In".equals(atom.getSymbol())) { + type = perceiveIndium(atomContainer, atom); } else if ("Pu".equals(atom.getSymbol())) { type = perceivePlutonium(atomContainer, atom); } else if ("Th".equals(atom.getSymbol())) { @@ -1700,6 +1702,23 @@ private IAtomType perceiveCadmium(IAtomContainer atomContainer, IAtom atom) thro } return null; } + + private IAtomType perceiveIndium(IAtomContainer atomContainer, IAtom atom) throws CDKException { + if (atom.getFormalCharge() == 0 && atomContainer.getConnectedBondsCount(atom) == 3) { + IAtomType type = getAtomType("In.3"); + if (isAcceptable(atom, atomContainer, type)) return type; + } else if (atom.getFormalCharge() == 3 && atomContainer.getConnectedBondsCount(atom) == 0) { + IAtomType type = getAtomType("In.3plus"); + if (isAcceptable(atom, atomContainer, type)) return type; + } else if (atom.getFormalCharge() == 0 && atomContainer.getConnectedBondsCount(atom) == 1) { + IAtomType type = getAtomType("In.1"); + if (isAcceptable(atom, atomContainer, type)) return type; + } else { + IAtomType type = getAtomType("In"); + if (isAcceptable(atom, atomContainer, type)) return type; + } + return null; + } private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom) { return countAttachedDoubleBonds(container, atom, null); diff --git a/src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl b/src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl index d1c21e56b24..3f889ae9c9e 100755 --- a/src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl +++ b/src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl @@ -1692,4 +1692,36 @@ + + 0 + + 0 + 0 + 0 + + + + 0 + + 1 + 0 + 2 + + + + 0 + + 3 + 0 + 0 + + + + 3 + + 0 + 0 + 0 + + diff --git a/src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java b/src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java index 3faa6d3f63c..b976cdd91f5 100644 --- a/src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java +++ b/src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java @@ -3688,6 +3688,78 @@ public void testMethylphosphinicAcid() throws Exception { }; assertAtomTypes(testedAtomTypes, expectedTypes, mol); } + + @Test + public void test_In_3plus() throws Exception { + IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); + IMolecule mol = builder.newInstance(IMolecule.class); + IAtom a1 = builder.newInstance(IAtom.class,"In"); + a1.setFormalCharge(3); + mol.addAtom(a1); + + + String[] expectedTypes = {"In.3plus"}; + assertAtomTypes(testedAtomTypes, expectedTypes, mol); + } + + @Test + public void test_In_3() throws Exception { + IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); + IMolecule mol = builder.newInstance(IMolecule.class); + IAtom a1 = builder.newInstance(IAtom.class,"In"); + 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); + 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); + + + String[] expectedTypes = {"In.3", "C.sp3", "C.sp3", "C.sp3"}; + assertAtomTypes(testedAtomTypes, expectedTypes, mol); + } + + @Test + public void test_In_1() throws Exception { + IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); + IMolecule mol = builder.newInstance(IMolecule.class); + IAtom a1 = builder.newInstance(IAtom.class,"In"); + a1.setFormalCharge(0); + mol.addAtom(a1); + IAtom a2 = builder.newInstance(IAtom.class,"C"); + a2.setFormalCharge(0); + mol.addAtom(a2); + IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.TRIPLE); + mol.addBond(b1); + + + String[] expectedTypes = {"In.1", "C.sp"}; + assertAtomTypes(testedAtomTypes, expectedTypes, mol); + } + + @Test + public void test_In() throws Exception { + IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance(); + IMolecule mol = builder.newInstance(IMolecule.class); + IAtom a1 = builder.newInstance(IAtom.class,"In"); + a1.setFormalCharge(0); + mol.addAtom(a1); + + + String[] expectedTypes = {"In"}; + assertAtomTypes(testedAtomTypes, expectedTypes, mol); + } @Test public void test_Cd_2plus() throws Exception { @@ -3697,7 +3769,6 @@ public void test_Cd_2plus() throws Exception { a1.setFormalCharge(2); mol.addAtom(a1); - String[] expectedTypes = {"Cd.2plus"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol); } @@ -3756,8 +3827,7 @@ public void test_Th() throws Exception { IMolecule mol = builder.newInstance(IMolecule.class); IAtom a1 = builder.newInstance(IAtom.class,"Th"); a1.setFormalCharge(0); - mol.addAtom(a1); - + mol.addAtom(a1); String[] expectedTypes = {"Th"}; assertAtomTypes(testedAtomTypes, expectedTypes, mol);