Skip to content

Commit

Permalink
Added Ag+ and Ag-* atom types (addressing #3388240)
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Sep 10, 2011
1 parent d98ec5b commit 033fb9f
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
Expand Up @@ -2045,8 +2045,17 @@ private IAtomType perceiveSilver(IAtomContainer atomContainer, IAtom atom) throw
return null;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 0)) {
int neighbors = atomContainer.getConnectedAtomsCount(atom);
if (neighbors == 1) {
IAtomType type = getAtomType("Ag.1");
if (isAcceptable(atom, atomContainer, type)) return type;
}
IAtomType type = getAtomType("Ag.neutral");
if (isAcceptable(atom, atomContainer, type)) return type;
} else if ((atom.getFormalCharge() != CDKConstants.UNSET
&& atom.getFormalCharge() == 1)) {
IAtomType type = getAtomType("Ag.plus");
if (isAcceptable(atom, atomContainer, type)) return type;
}
return null;
}
Expand Down
16 changes: 15 additions & 1 deletion src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
Expand Up @@ -2136,7 +2136,21 @@
<at:formalNeighbourCount>0</at:formalNeighbourCount>
<at:piBondCount>0</at:piBondCount>
</at:AtomType>


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

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

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

/**
* For example PubChem CID 3808730.
*/
@Test
public void test_Ag_plus() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Ag");
a1.setFormalCharge(1);
mol.addAtom(a1);

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

/**
* For example PubChem CID 139654.
*/
@Test
public void test_Ag_covalent() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
IAtom a1 = builder.newInstance(IAtom.class,"Ag");
mol.addAtom(a1);
IAtom a2 = builder.newInstance(IAtom.class,"Cl");
mol.addAtom(a2);
mol.addBond(0, 1, IBond.Order.SINGLE);

String[] expectedTypes = {"Ag.1", "Cl"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}

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

0 comments on commit 033fb9f

Please sign in to comment.