Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ti final
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
gilleain authored and egonw committed Sep 4, 2011
1 parent 682d0a1 commit ee1ac09
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -149,6 +149,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveGadolinum(atomContainer, atom);
} else if ("Ge".equals(atom.getSymbol())) {
type = perceiveGermanium(atomContainer, atom);
} else if ("Ti".equals(atom.getSymbol())) {
type = perceiveTitanium(atomContainer, atom);
} else if ("Sr".equals(atom.getSymbol())) {
type = perceiveStrontium(atomContainer, atom);
} else if ("Pb".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -1591,18 +1593,6 @@ private IAtomType perceiveOrganometallicCenters(IAtomContainer atomContainer, IA
IAtomType type = getAtomType("Sn.sp3");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("Ti".equals(atom.getSymbol())) {
if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == -3 &&
atomContainer.getConnectedBondsCount(atom) == 6) {
IAtomType type = getAtomType("Ti.3minus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() == CDKConstants.UNSET ||
atom.getFormalCharge() == 0) &&
atomContainer.getConnectedBondsCount(atom) == 4) {
IAtomType type = getAtomType("Ti.sp3");
if (isAcceptable(atom, atomContainer, type)) return type;
}
} else if ("V".equals(atom.getSymbol())) {
if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == -3 &&
Expand Down Expand Up @@ -2207,6 +2197,26 @@ private IAtomType perceiveStrontium(IAtomContainer atomContainer, IAtom atom) th
}
return null;
}

private IAtomType perceiveTitanium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (atom.getFormalCharge() != CDKConstants.UNSET &&
atom.getFormalCharge() == -3 &&
atomContainer.getConnectedBondsCount(atom) == 6) {
IAtomType type = getAtomType("Ti.3minus");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() == CDKConstants.UNSET ||
atom.getFormalCharge() == 0) &&
atomContainer.getConnectedBondsCount(atom) == 4) {
IAtomType type = getAtomType("Ti.sp3");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0)
&& atomContainer.getConnectedBondsCount(atom) == 2) {
IAtomType type = getAtomType("Ti.2");
if (isAcceptable(atom, atomContainer, type)) return type;
}
return null;
}

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

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

<at:AtomType rdf:ID="V.3minus">
<at:formalCharge>-3</at:formalCharge>
Expand Down
22 changes: 22 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -3969,6 +3969,28 @@ public void testMethylphosphinicAcid() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

@Test
public void test_Ti_2() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Ti");
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);
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.DOUBLE);
mol.addBond(b1);
IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.DOUBLE);
mol.addBond(b2);


String[] expectedTypes = {"Ti.2", "C.sp2", "C.sp2"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
@Test
public void test_Ni_metallic() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
Expand Down

0 comments on commit ee1ac09

Please sign in to comment.