Browse files

In final

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information...
1 parent bd3ca4d commit 78b3d27099638e68223de2491fe7ed3169de1b66 @gilleain gilleain committed with egonw Jul 21, 2011
View
19 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);
View
32 src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
@@ -1692,4 +1692,36 @@
<at:hybridization rdf:resource="&at;sp1"/>
</at:AtomType>
+ <at:AtomType rdf:ID="In">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;In"/>
+ <at:formalNeighbourCount>0</at:formalNeighbourCount>
+ <at:lonePairCount>0</at:lonePairCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="In.1">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;In"/>
+ <at:formalNeighbourCount>1</at:formalNeighbourCount>
+ <at:lonePairCount>0</at:lonePairCount>
+ <at:piBondCount>2</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="In.3">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;In"/>
+ <at:formalNeighbourCount>3</at:formalNeighbourCount>
+ <at:lonePairCount>0</at:lonePairCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="In.3plus">
+ <at:formalCharge>3</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;In"/>
+ <at:formalNeighbourCount>0</at:formalNeighbourCount>
+ <at:lonePairCount>0</at:lonePairCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
</rdf:RDF>
View
76 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);

0 comments on commit 78b3d27

Please sign in to comment.