Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Ag+ and Ag-* atom types (addressing #3388240)

  • Loading branch information...
commit 033fb9fa62e63704c1f217d5a5349be712fe616e 1 parent d98ec5b
@egonw egonw authored
View
9 src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
@@ -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;
}
View
16 src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
@@ -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"/>
View
32 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
@@ -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();

0 comments on commit 033fb9f

Please sign in to comment.
Something went wrong with that request. Please try again.