Skip to content

Commit

Permalink
Tl 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 4, 2011
1 parent 81ce6e5 commit ae54e0c
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -147,6 +147,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveGadolinum(atomContainer, atom);
} else if ("Ge".equals(atom.getSymbol())) {
type = perceiveGermanium(atomContainer, atom);
} else if ("Tl".equals(atom.getSymbol())) {
type = perceiveThallium(atomContainer, atom);
} else if ("Sb".equals(atom.getSymbol())) {
type = perceiveAntimony(atomContainer, atom);
} else if ("Pt".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -2129,6 +2131,26 @@ private IAtomType perceiveMagnesium(IAtomContainer atomContainer, IAtom atom) th
}
return null;
}

private IAtomType perceiveThallium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == +1 &&
atomContainer.getConnectedBondsCount(atom) == 0) {
IAtomType type = getAtomType("Tl.plus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 0 &&
atomContainer.getConnectedBondsCount(atom) == 0) {
IAtomType type = getAtomType("Tl");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == 0 &&
atomContainer.getConnectedBondsCount(atom) == 1) {
IAtomType type = getAtomType("Tl.1");
if (isAcceptable(atom, atomContainer, type)) return type;
}
return null;
}

private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom) {
return countAttachedDoubleBonds(container, atom, null);
Expand Down
25 changes: 25 additions & 0 deletions src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -1941,6 +1941,31 @@
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>

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

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

<at:AtomType rdf:ID="Tl">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Tl"/>
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:lonePairCount>0</at:lonePairCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>

<at:AtomType rdf:ID="Gd.3plus">
<at:formalCharge>3</at:formalCharge>
<at:hasElement rdf:resource="&elem;Gd"/>
Expand Down
45 changes: 45 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -3954,6 +3954,51 @@ public void testMethylphosphinicAcid() throws Exception {
};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}


@Test
public void test_Tl_neutral() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Tl");
a1.setFormalCharge(0);
mol.addAtom(a1);


String[] expectedTypes = {"Tl"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_Tl_1() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"C");
a1.setFormalCharge(0);
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"Tl");
a2.setFormalCharge(0);
mol.addAtom(a2);
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
mol.addBond(b1);


String[] expectedTypes = {"C.sp3", "Tl.1"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_Tl_plus() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Tl");
a1.setFormalCharge(1);
mol.addAtom(a1);


String[] expectedTypes = {"Tl.plus"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

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

0 comments on commit ae54e0c

Please sign in to comment.