Skip to content

Commit

Permalink
Rb 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 Aug 12, 2011
1 parent 5ebe425 commit af5f764
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveChromium(atomContainer, atom);
} else if ("Se".equals(atom.getSymbol())) {
type = perceiveSelenium(atomContainer, atom);
} else if ("Rb".equals(atom.getSymbol())) {
type = perceiveRubidium(atomContainer, atom);
} else if ("Te".equals(atom.getSymbol())) {
type = perceiveTellurium(atomContainer, atom);
} else if ("Ba".equals(atom.getSymbol())) {
Expand Down Expand Up @@ -1224,6 +1226,24 @@ private IAtomType perceiveThorium(IAtomContainer atomContainer, IAtom atom)
return null;
}

private IAtomType perceiveRubidium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if (hasOneSingleElectron(atomContainer, atom)) {
return null;
} else if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == +1) {
IAtomType type = getAtomType("Rb.plus");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
} else if (atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0) {
IAtomType type = getAtomType("Rb.neutral");
if (isAcceptable(atom, atomContainer, type)) {
return type;
}
}
return null;
}
private IAtomType perceiveCommonSalts(IAtomContainer atomContainer, IAtom atom) throws CDKException {
if ("Ca".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
Expand Down
16 changes: 16 additions & 0 deletions src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Original file line number Diff line number Diff line change
Expand Up @@ -1666,6 +1666,22 @@
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>

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

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

<at:AtomType rdf:ID="Se.3">
<at:formalCharge>0</at:formalCharge>
<at:hasElement rdf:resource="&elem;Se"/>
Expand Down
26 changes: 26 additions & 0 deletions src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3751,6 +3751,32 @@ public void test_Cr_neutral() throws Exception {
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

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


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

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


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

@Test
public void test_Cr_4() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
Expand Down

0 comments on commit af5f764

Please sign in to comment.