Skip to content

Commit

Permalink
Sr 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 6207b4f commit 458d1aa
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
13 changes: 13 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 ("Sr".equals(atom.getSymbol())) {
type = perceiveStrontium(atomContainer, atom);
} else if ("Pb".equals(atom.getSymbol())) {
type = perceiveLead(atomContainer, atom);
} else if ("Tl".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -2173,6 +2175,17 @@ private IAtomType perceiveLead(IAtomContainer atomContainer, IAtom atom) throws
}
return null;
}

private IAtomType perceiveStrontium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (hasOneSingleElectron(atomContainer, atom)) {
return null;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 2)) {
IAtomType type = getAtomType("Sr.2plus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
return null;
}

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

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

<at:AtomType rdf:ID="Pb.neutral">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Pb"/>
Expand Down
14 changes: 14 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Expand Up @@ -3737,6 +3737,20 @@ public void test_B_3plus() throws Exception {
String[] expectedTypes = {"B.3plus", "C.sp3", "C.sp3", "C.sp3", "C.sp3"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}


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


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

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

0 comments on commit 458d1aa

Please sign in to comment.