Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cd final

Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information...
commit 4d68c277e5d3cd74b12fcfaef99437b37e1b8d54 1 parent 0eebd74
@gilleain gilleain authored egonw committed
View
21 src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
@@ -1677,6 +1677,27 @@ private IAtomType perceivePlutonium(IAtomContainer atomContainer, IAtom atom) th
}
return null;
}
+
+ private IAtomType perceiveCadmium(IAtomContainer atomContainer, IAtom atom) throws CDKException {
+ if (hasOneSingleElectron(atomContainer, atom)) {
+ // no idea how to deal with this yet
+ return null;
+ } else if ((atom.getFormalCharge() != CDKConstants.UNSET
+ && atom.getFormalCharge() == +2)) {
+ IAtomType type = getAtomType("Cd.2plus");
+ if (isAcceptable(atom, atomContainer, type)) return type;
+ } else if ((atom.getFormalCharge() != CDKConstants.UNSET
+ && atom.getFormalCharge() == 0)) {
+ if (atomContainer.getConnectedAtomsCount(atom) == 0) {
+ IAtomType type = getAtomType("Cd.metallic");
+ if (isAcceptable(atom, atomContainer, type)) return type;
+ } else if (atomContainer.getConnectedAtomsCount(atom) == 2) {
+ IAtomType type = getAtomType("Cd.2");
+ if (isAcceptable(atom, atomContainer, type)) return type;
+ }
+ }
+ return null;
+ }
private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom) {
return countAttachedDoubleBonds(container, atom, null);
View
22 src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
@@ -1670,4 +1670,26 @@
<at:piBondCount>0</at:piBondCount>
</at:AtomType>
+ <at:AtomType rdf:ID="Cd.metallic">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Cd"/>
+ <at:formalNeighbourCount>0</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="Cd.2plus">
+ <at:formalCharge>2</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Cd"/>
+ <at:formalNeighbourCount>0</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="Cd.2">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Cd"/>
+ <at:formalNeighbourCount>2</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ <at:hybridization rdf:resource="&at;sp1"/>
+ </at:AtomType>
+
</rdf:RDF>
View
50 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
@@ -3690,6 +3690,55 @@ public void testMethylphosphinicAcid() throws Exception {
}
@Test
+ public void test_Cd_2plus() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class,"Cd");
+ a1.setFormalCharge(2);
+ mol.addAtom(a1);
+
+
+ String[] expectedTypes = {"Cd.2plus"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ @Test
+ public void test_Cd_2() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class,"Cd");
+ a1.setFormalCharge(0);
+ mol.addAtom(a1);
+ IAtom a2 = builder.newInstance(IAtom.class,"C");
+ a2.setFormalCharge(0);
+ mol.addAtom(a2);
+ IAtom a3 = builder.newInstance(IAtom.class,"C");
+ a3.setFormalCharge(0);
+ mol.addAtom(a3);
+ IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);
+ mol.addBond(b1);
+ IBond b2 = builder.newInstance(IBond.class,a1, a3, IBond.Order.SINGLE);
+ mol.addBond(b2);
+
+
+ String[] expectedTypes = {"Cd.2", "C.sp3", "C.sp3"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ @Test
+ public void test_Cd_metallic() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class,"Cd");
+ a1.setFormalCharge(0);
+ mol.addAtom(a1);
+
+
+ String[] expectedTypes = {"Cd.metallic"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ @Test
public void test_Pu() throws Exception {
IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
IMolecule mol = builder.newInstance(IMolecule.class);
@@ -3697,7 +3746,6 @@ public void test_Pu() throws Exception {
a1.setFormalCharge(0);
mol.addAtom(a1);
-
String[] expectedTypes = {"Pu"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
Please sign in to comment.
Something went wrong with that request. Please try again.