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 compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 3 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 03, 2012
@egonw egonw Added testing of the number of double bonds found (fixes #3514176)
Change-Id: I1d2740ce310a767c9fa236be5b602ac64ee9b5d9
Signed-off-by: ngn <jeliazkova.nina@gmail.com>
a6597e3
@egonw egonw Double bond orders are not properly assigned when using the SilentCOB
Change-Id: I299374c6ad0bf75f1e97ace99de52cb813e5c221
Signed-off-by: ngn <jeliazkova.nina@gmail.com>
fb37eab
@egonw egonw Fixed bond order assignment when using the SilentCOB
Change-Id: Ic6427e6399d645b600f5e6f1c0f438335cd91298
Signed-off-by: ngn <jeliazkova.nina@gmail.com>
1e936d0
View
1 src/META-INF/test-smiles.cdkdepends
@@ -4,6 +4,7 @@ cdk-core.jar
cdk-standard.jar
cdk-data.jar
cdk-datadebug.jar
+cdk-silent.jar
cdk-nonotify.jar
cdk-io.jar
cdk-ioformats.jar
View
27 src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java
@@ -26,13 +26,8 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import java.util.Collections;
-import org.openscience.cdk.Atom;
import org.openscience.cdk.CDKConstants;
-import org.openscience.cdk.Molecule;
-import org.openscience.cdk.Ring;
-import org.openscience.cdk.RingSet;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector;
@@ -371,7 +366,7 @@ private void sixMemberedRingPossibilities(IMolecule m, IRing r, List MasterList)
// 6 possibilities for placing 2 double bonds
// 6 possibilities for placing 1 double bonds
- IAtom [] ringatoms = new Atom [6];
+ IAtom [] ringatoms = new IAtom [6];
ringatoms[0] = r.getAtom(0);
@@ -477,7 +472,7 @@ private void sixMemberedRingPossibilities(IMolecule m, IRing r, List MasterList)
private void sevenMemberedRingPossibilities(IMolecule m, IRing r, List MasterList) {
// for now only consider case where have 3 double bonds
- IAtom[] ringatoms = new Atom[7];
+ IAtom[] ringatoms = new IAtom[7];
ringatoms[0] = r.getAtom(0);
@@ -584,7 +579,7 @@ private int getBadCount(IMolecule molecule, IRingSet ringSet) {
private boolean inRingSet(IAtom atom, IRingSet ringSet) {
for (int i = 0; i < ringSet.getAtomContainerCount(); i++) {
- Ring ring = (Ring) ringSet.getAtomContainer(i);
+ IRing ring = (IRing) ringSet.getAtomContainer(i);
if (ring.contains(atom)) return true;
}
return false;
@@ -621,7 +616,7 @@ private IMolecule loop(long starttime, IMolecule molecule, int index,
IMolecule mnew = null;
try {
- mnew = (Molecule) molecule.clone();
+ mnew = (IMolecule) molecule.clone();
} catch (Exception e) {
logger.error("Failed to clone molecule: ", e.getMessage());
logger.debug(e);
@@ -688,13 +683,13 @@ private boolean isStructureOK(IMolecule molecule) {
molecule.getAtom(i).setFlag(CDKConstants.ISAROMATIC, false);
}
for (int i = 0; i <= ringSet.getAtomContainerCount() - 1; i++) {
- Ring r = (Ring) ringSet.getAtomContainer(i);
+ IRing r = (IRing) ringSet.getAtomContainer(i);
r.setFlag(CDKConstants.ISAROMATIC, false);
}
// now, detect aromaticity from cratch, and mark rings as aromatic too (if ...)
CDKHueckelAromaticityDetector.detectAromaticity(molecule);
for (int i = 0; i <= ringSet.getAtomContainerCount() - 1; i++) {
- Ring ring = (Ring) ringSet.getAtomContainer(i);
+ IRing ring = (IRing) ringSet.getAtomContainer(i);
RingManipulator.markAromaticRings(ring);
}
@@ -706,7 +701,7 @@ private boolean isStructureOK(IMolecule molecule) {
// }
for (int i = 0; i <= ringSet.getAtomContainerCount() - 1; i++) {
- Ring ring = (Ring) ringSet.getAtomContainer(i);
+ IRing ring = (IRing) ringSet.getAtomContainer(i);
//logger.debug(k+"\t"+r.getAtomCount()+"\t"+r.getFlag(CDKConstants.ISAROMATIC));
//javax.swing.JOptionPane.showMessageDialog(null,i + " " + ring.getFlag(CDKConstants.ISAROMATIC));
@@ -754,7 +749,7 @@ private IRingSet removeExtraRings(IMolecule m) {
iloop:
for (int i = 0; i <= rs.getAtomContainerCount() - 1; i++) {
- IRing r = (Ring) rs.getAtomContainer(i);
+ IRing r = (IRing) rs.getAtomContainer(i);
if (r.getAtomCount() > 7 || r.getAtomCount() < 5) {
@@ -794,7 +789,7 @@ private IRingSet removeExtraRings(IMolecule m) {
return rs;
} catch (Exception e) {
- return new RingSet();
+ return m.getBuilder().newInstance(IRingSet.class);
}
}
@@ -809,7 +804,7 @@ private IRingSet removeExtraRings(IMolecule m) {
for (int i = 0; i <= rs.getAtomContainerCount() - 1; i++) {
- IRing r = (Ring) rs.getAtomContainer(i);
+ IRing r = (IRing) rs.getAtomContainer(i);
if (r.getAtomCount() > 7) {
Check[i] = false;
@@ -967,7 +962,7 @@ private Integer getRingGroupNumber(List<List<Integer>> ringGroups, Integer ringI
private IMolecule combineRetMols(List<IMolecule> retMols){
IMolecule combi = null;
try {
- combi = (Molecule) retMols.get(0).clone();
+ combi = (IMolecule) retMols.get(0).clone();
} catch (Exception e) {
logger.error("Failed to clone molecule: ", e.getMessage());
logger.debug(e);
View
26 src/test/org/openscience/cdk/smiles/DeduceBondSystemToolTest.java
@@ -36,6 +36,7 @@
import org.openscience.cdk.nonotify.NNBond;
import org.openscience.cdk.nonotify.NNMolecule;
import org.openscience.cdk.ringsearch.AllRingsFinder;
+import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
/**
@@ -76,10 +77,32 @@ public void testPyrrole() throws Exception {
Assert.assertNotNull(molecule);
molecule = (IMolecule) AtomContainerManipulator.removeHydrogens(molecule);
+ int doubleBondCount = 0;
+ for (int i = 0; i < molecule.getBondCount(); i++) {
+ IBond bond = molecule.getBond(i);
+ Assert.assertTrue(bond.getFlag(CDKConstants.ISAROMATIC));
+ if (bond.getOrder() == Order.DOUBLE) doubleBondCount++;
+ }
+ Assert.assertEquals(6, doubleBondCount);
+ }
+
+ @Test(timeout=1000)
+ public void testPyrrole_Silent() throws Exception {
+ String smiles = "c2ccc3n([H])c1ccccc1c3(c2)";
+ SmilesParser smilesParser = new SmilesParser(SilentChemObjectBuilder.getInstance());
+ IMolecule molecule = smilesParser.parseSmiles(smiles);
+
+ molecule = dbst.fixAromaticBondOrders(molecule);
+ Assert.assertNotNull(molecule);
+
+ molecule = (IMolecule) AtomContainerManipulator.removeHydrogens(molecule);
+ int doubleBondCount = 0;
for (int i = 0; i < molecule.getBondCount(); i++) {
IBond bond = molecule.getBond(i);
Assert.assertTrue(bond.getFlag(CDKConstants.ISAROMATIC));
+ if (bond.getOrder() == Order.DOUBLE) doubleBondCount++;
}
+ Assert.assertEquals(6, doubleBondCount);
}
@Test
@@ -142,10 +165,13 @@ public void testPyrrole_CustomRingFinder() throws Exception {
Assert.assertNotNull(molecule);
molecule = (IMolecule) AtomContainerManipulator.removeHydrogens(molecule);
+ int doubleBondCount = 0;
for (int i = 0; i < molecule.getBondCount(); i++) {
IBond bond = molecule.getBond(i);
Assert.assertTrue(bond.getFlag(CDKConstants.ISAROMATIC));
+ if (bond.getOrder() == Order.DOUBLE) doubleBondCount++;
}
+ Assert.assertEquals(6, doubleBondCount);
}
/**

No commit comments for this range

Something went wrong with that request. Please try again.