Skip to content

Commit cc46f63

Browse files
gilleainegonw
authored andcommitted
Pt final
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
1 parent 177e5bd commit cc46f63

File tree

3 files changed

+103
-19
lines changed

3 files changed

+103
-19
lines changed

src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
143143
type = perceiveGallium(atomContainer, atom);
144144
} else if ("Ge".equals(atom.getSymbol())) {
145145
type = perceiveGermanium(atomContainer, atom);
146+
} else if ("Pt".equals(atom.getSymbol())) {
147+
type = perceivePlatinum(atomContainer, atom);
146148
} else if ("Hg".equals(atom.getSymbol())) {
147149
type = perceiveMercury(atomContainer, atom);
148150
} else if ("Fe".equals(atom.getSymbol())) {
@@ -1425,25 +1427,6 @@ private IAtomType perceiveCommonSalts(IAtomContainer atomContainer, IAtom atom)
14251427
IAtomType type = getAtomType("Co.metallic");
14261428
if (isAcceptable(atom, atomContainer, type)) return type;
14271429
}
1428-
} else if ("Pt".equals(atom.getSymbol())) {
1429-
if (hasOneSingleElectron(atomContainer, atom)) {
1430-
// no idea how to deal with this yet
1431-
return null;
1432-
} else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
1433-
atom.getFormalCharge() == +2)) {
1434-
IAtomType type = getAtomType("Pt.2plus");
1435-
if (isAcceptable(atom, atomContainer, type)) return type;
1436-
} else if ((atom.getFormalCharge() == CDKConstants.UNSET ||
1437-
atom.getFormalCharge() == 0)) {
1438-
int neighbors = atomContainer.getConnectedAtomsCount(atom);
1439-
if (neighbors == 4) {
1440-
IAtomType type = getAtomType("Pt.4");
1441-
if (isAcceptable(atom, atomContainer, type)) return type;
1442-
} else if (neighbors == 6) {
1443-
IAtomType type = getAtomType("Pt.6");
1444-
if (isAcceptable(atom, atomContainer, type)) return type;
1445-
}
1446-
}
14471430
} else if ("Ni".equals(atom.getSymbol())) {
14481431
if (hasOneSingleElectron(atomContainer, atom)) {
14491432
// no idea how to deal with this yet
@@ -2034,6 +2017,37 @@ private IAtomType perceiveCalcium(IAtomContainer atomContainer, IAtom atom) thro
20342017
}
20352018
return null;
20362019
}
2020+
2021+
private IAtomType perceivePlatinum(IAtomContainer atomContainer, IAtom atom) throws CDKException {
2022+
if (hasOneSingleElectron(atomContainer, atom)) {
2023+
// no idea how to deal with this yet
2024+
return null;
2025+
} else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
2026+
atom.getFormalCharge() == +2)) {
2027+
int neighbors = atomContainer.getConnectedAtomsCount(atom);
2028+
if (neighbors == 4) {
2029+
IAtomType type = getAtomType("Pt.2plus.4");
2030+
if (isAcceptable(atom, atomContainer, type)) return type;
2031+
} else {
2032+
IAtomType type = getAtomType("Pt.2plus");
2033+
if (isAcceptable(atom, atomContainer, type)) return type;
2034+
}
2035+
} else if ((atom.getFormalCharge() == CDKConstants.UNSET ||
2036+
atom.getFormalCharge() == 0)) {
2037+
int neighbors = atomContainer.getConnectedAtomsCount(atom);
2038+
if (neighbors == 2) {
2039+
IAtomType type = getAtomType("Pt.2");
2040+
if (isAcceptable(atom, atomContainer, type)) return type;
2041+
} else if (neighbors == 4) {
2042+
IAtomType type = getAtomType("Pt.4");
2043+
if (isAcceptable(atom, atomContainer, type)) return type;
2044+
} else if (neighbors == 6) {
2045+
IAtomType type = getAtomType("Pt.6");
2046+
if (isAcceptable(atom, atomContainer, type)) return type;
2047+
}
2048+
}
2049+
return null;
2050+
}
20372051

20382052
private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom) {
20392053
return countAttachedDoubleBonds(container, atom, null);

src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,20 @@
13961396
<at:formalNeighbourCount>6</at:formalNeighbourCount>
13971397
<at:piBondCount>0</at:piBondCount>
13981398
</at:AtomType>
1399+
1400+
<at:AtomType rdf:ID="Pt.2plus.4">
1401+
<at:formalCharge>2</at:formalCharge>
1402+
<at:hasElement rdf:resource="&elem;Pt"/>
1403+
<at:formalNeighbourCount>4</at:formalNeighbourCount>
1404+
<at:piBondCount>0</at:piBondCount>
1405+
</at:AtomType>
1406+
1407+
<at:AtomType rdf:ID="Pt.2">
1408+
<at:formalCharge>0</at:formalCharge>
1409+
<at:hasElement rdf:resource="&elem;Pt"/>
1410+
<at:formalNeighbourCount>2</at:formalNeighbourCount>
1411+
<at:piBondCount>0</at:piBondCount>
1412+
</at:AtomType>
13991413

14001414
<at:AtomType rdf:ID="Co.2plus">
14011415
<at:formalCharge>2</at:formalCharge>

src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3896,6 +3896,62 @@ public void testMethylphosphinicAcid() throws Exception {
38963896
};
38973897
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
38983898
}
3899+
3900+
3901+
@Test
3902+
public void test_Pt_2() throws Exception {
3903+
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
3904+
IMolecule mol = builder.newInstance(IMolecule.class);
3905+
IAtom a1 = builder.newInstance(IAtom.class,"Pt");
3906+
a1.setFormalCharge(0);
3907+
mol.addAtom(a1);
3908+
IAtom a2 = builder.newInstance(IAtom.class,"C");
3909+
a2.setFormalCharge(0);
3910+
mol.addAtom(a2);
3911+
IAtom a3 = builder.newInstance(IAtom.class,"C");
3912+
a3.setFormalCharge(0);
3913+
mol.addAtom(a3);
3914+
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
3915+
mol.addBond(b1);
3916+
IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
3917+
mol.addBond(b2);
3918+
3919+
3920+
String[] expectedTypes = {"Pt.2", "C.sp3", "C.sp3"};
3921+
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
3922+
}
3923+
3924+
@Test
3925+
public void test_Pt_2plus_4() throws Exception {
3926+
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
3927+
IMolecule mol = builder.newInstance(IMolecule.class);
3928+
IAtom a1 = builder.newInstance(IAtom.class,"Pt");
3929+
a1.setFormalCharge(2);
3930+
mol.addAtom(a1);
3931+
IAtom a2 = builder.newInstance(IAtom.class,"C");
3932+
a2.setFormalCharge(0);
3933+
mol.addAtom(a2);
3934+
IAtom a3 = builder.newInstance(IAtom.class,"C");
3935+
a3.setFormalCharge(0);
3936+
mol.addAtom(a3);
3937+
IAtom a4 = builder.newInstance(IAtom.class,"C");
3938+
a4.setFormalCharge(0);
3939+
mol.addAtom(a4);
3940+
IAtom a5 = builder.newInstance(IAtom.class,"C");
3941+
a5.setFormalCharge(0);
3942+
mol.addAtom(a5);
3943+
IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
3944+
mol.addBond(b1);
3945+
IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
3946+
mol.addBond(b2);
3947+
IBond b3 = builder.newInstance(IBond.class,a1, a4, IBond.Order.SINGLE);
3948+
mol.addBond(b3);
3949+
IBond b4 = builder.newInstance(IBond.class,a1, a5, IBond.Order.SINGLE);
3950+
mol.addBond(b4);
3951+
3952+
String[] expectedTypes = {"Pt.2plus.4", "C.sp3", "C.sp3", "C.sp3", "C.sp3"};
3953+
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
3954+
}
38993955

39003956
@Test
39013957
public void test_Cu_metallic() throws Exception {

0 commit comments

Comments
 (0)