Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
...
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Aug 20, 2011
@asad asad Hg Test cases added
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
0e3d587
@asad asad Hg Atom type added
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
d9fc795
@asad asad Hg Atom type owl added
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
66d6321
View
64 src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
@@ -141,6 +141,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
type = perceiveGallium(atomContainer, atom);
} else if ("Ge".equals(atom.getSymbol())) {
type = perceiveGermanium(atomContainer, atom);
+ } else if ("Hg".equals(atom.getSymbol())) {
+ type = perceiveMercury(atomContainer, atom);
} else if ("Ra".equals(atom.getSymbol())) {
type = perceiveRadium(atomContainer, atom);
} else if ("Au".equals(atom.getSymbol())) {
@@ -849,6 +851,57 @@ private int countExplicitHydrogens(IAtom atom, IAtomContainer atomContainer) {
}
return count;
}
+
+
+ private IAtomType perceiveMercury(IAtomContainer atomContainer, IAtom atom) throws CDKException {
+ if ("Hg".equals(atom.getSymbol())) {
+ if (hasOneSingleElectron(atomContainer, atom)) {
+ // no idea how to deal with this yet
+ return null;
+ } else if ((atom.getFormalCharge() != null
+ && atom.getFormalCharge() == -1)) {
+ IAtomType type = getAtomType("Hg.minus");
+ if (isAcceptable(atom, atomContainer, type)) {
+ return type;
+ }
+ } else if ((atom.getFormalCharge() != null
+ && atom.getFormalCharge() == 2)) {
+ IAtomType type = getAtomType("Hg.2plus");
+ if (isAcceptable(atom, atomContainer, type)) {
+ return type;
+ }
+ } else if ((atom.getFormalCharge() != null
+ && atom.getFormalCharge() == +1)) {
+ int neighbors = atomContainer.getConnectedAtomsCount(atom);
+ if (neighbors <= 1) {
+ IAtomType type = getAtomType("Hg.plus");
+ if (isAcceptable(atom, atomContainer, type)) {
+ return type;
+ }
+ }
+ } else if ((atom.getFormalCharge() != null
+ && atom.getFormalCharge() == 0)) {
+ int neighbors = atomContainer.getConnectedAtomsCount(atom);
+ if (neighbors == 2) {
+ IAtomType type = getAtomType("Hg.2");
+ if (isAcceptable(atom, atomContainer, type)) {
+ return type;
+ }
+ } else if (neighbors == 1) {
+ IAtomType type = getAtomType("Hg.1");
+ if (isAcceptable(atom, atomContainer, type)) {
+ return type;
+ }
+ } else if (neighbors == 0) {
+ IAtomType type = getAtomType("Hg.metallic");
+ if (isAcceptable(atom, atomContainer, type)) {
+ return type;
+ }
+ }
+ }
+ }
+ return null;
+ }
private IAtomType perceiveSulphurs(IAtomContainer atomContainer, IAtom atom)
throws CDKException {
@@ -1403,16 +1456,7 @@ private IAtomType perceiveChromium(IAtomContainer atomContainer, IAtom atom) thr
return null;
}
private IAtomType perceiveOrganometallicCenters(IAtomContainer atomContainer, IAtom atom) throws CDKException {
- if ("Hg".equals(atom.getSymbol())) {
- if (hasOneSingleElectron(atomContainer, atom)) {
- // no idea how to deal with this yet
- return null;
- } else if ((atom.getFormalCharge() != CDKConstants.UNSET &&
- atom.getFormalCharge() == -1)) {
- IAtomType type = getAtomType("Hg.minus");
- if (isAcceptable(atom, atomContainer, type)) return type;
- }
- } else if ("Po".equals(atom.getSymbol())) {
+ if ("Po".equals(atom.getSymbol())) {
if (hasOneSingleElectron(atomContainer, atom)) {
// no idea how to deal with this yet
return null;
View
35 src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
@@ -1435,6 +1435,41 @@
<at:piBondCount>0</at:piBondCount>
</at:AtomType>
+ <at:AtomType rdf:ID="Hg.2plus">
+ <at:formalCharge>2</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Hg"/>
+ <at:formalNeighbourCount>0</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="Hg.plus">
+ <at:formalCharge>1</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Hg"/>
+ <at:formalNeighbourCount>1</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="Hg.metallic">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Hg"/>
+ <at:formalNeighbourCount>0</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="Hg.2">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Hg"/>
+ <at:formalNeighbourCount>2</at:formalNeighbourCount>
+ <at:piBondCount>0</at:piBondCount>
+ </at:AtomType>
+
+ <at:AtomType rdf:ID="Hg.1">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Hg"/>
+ <at:formalNeighbourCount>1</at:formalNeighbourCount>
+ <at:piBondCount>1</at:piBondCount>
+ </at:AtomType>
+
<at:AtomType rdf:ID="Hg.minus">
<at:formalCharge>-1</at:formalCharge>
<at:hasElement rdf:resource="&elem;Hg"/>
View
86 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
@@ -1520,6 +1520,92 @@ public void testTetrahydropyran() throws Exception {
String[] expectedTypes = new String[]{"Hg.minus", "O.plus.sp2", "C.sp2", "C.sp2", "N.sp2"};
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
+
+ @Test
+ public void test_Hg_2plus() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class, "Hg");
+ a1.setFormalCharge(2);
+ mol.addAtom(a1);
+
+
+ String[] expectedTypes = {"Hg.2plus"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ @Test
+ public void test_Hg_plus() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class, "Hg");
+ a1.setFormalCharge(1);
+ mol.addAtom(a1);
+ IAtom a2 = builder.newInstance(IAtom.class, "C");
+ a2.setFormalCharge(0);
+ mol.addAtom(a2);
+ IBond b1 = builder.newInstance(IBond.class, a1, a2, IBond.Order.SINGLE);
+ mol.addBond(b1);
+
+
+ String[] expectedTypes = {"Hg.plus", "C.sp3"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ @Test
+ public void test_Hg_metallic() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class, "Hg");
+ a1.setFormalCharge(0);
+ mol.addAtom(a1);
+
+
+ String[] expectedTypes = {"Hg.metallic"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ @Test
+ public void test_Hg_1() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class, "Hg");
+ a1.setFormalCharge(0);
+ mol.addAtom(a1);
+ IAtom a2 = builder.newInstance(IAtom.class, "C");
+ a2.setFormalCharge(0);
+ mol.addAtom(a2);
+ IBond b1 = builder.newInstance(IBond.class, a1, a2, IBond.Order.DOUBLE);
+ mol.addBond(b1);
+
+
+ String[] expectedTypes = {"Hg.1", "C.sp2"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
+ @Test
+ public void test_Hg_2() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class, "Hg");
+ 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 = {"Hg.2", "C.sp3", "C.sp3"};
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
@Test public void testPoloniumComplex() throws Exception {
IMolecule mol = new Molecule();

No commit comments for this range

Something went wrong with that request. Please try again.