diff --git a/src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java b/src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java index 043c07bb1a4..543bb806247 100644 --- a/src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java +++ b/src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java @@ -84,6 +84,15 @@ public DeduceBondSystemTool() { allRingsFinder = new AllRingsFinder(); } + /** + * Constructor for the DeduceBondSystemTool object accepting a custom {@link AllRingsFinder}. + * + * @param ringFinger a custom {@link AllRingsFinder}. + */ + public DeduceBondSystemTool(AllRingsFinder ringFinder) { + allRingsFinder = ringFinder; + } + public boolean isOK(IMolecule m) throws CDKException { IRingSet rs = allRingsFinder.findAllRings(m); storeRingSystem(m, rs); diff --git a/src/test/org/openscience/cdk/smiles/DeduceBondSystemToolTest.java b/src/test/org/openscience/cdk/smiles/DeduceBondSystemToolTest.java index 56f29aa56b8..68653575d45 100644 --- a/src/test/org/openscience/cdk/smiles/DeduceBondSystemToolTest.java +++ b/src/test/org/openscience/cdk/smiles/DeduceBondSystemToolTest.java @@ -34,6 +34,7 @@ import org.openscience.cdk.nonotify.NNAtom; import org.openscience.cdk.nonotify.NNBond; import org.openscience.cdk.nonotify.NNMolecule; +import org.openscience.cdk.ringsearch.AllRingsFinder; import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; /** @@ -49,7 +50,7 @@ public class DeduceBondSystemToolTest extends CDKTestCase { @BeforeClass public static void setup() { dbst = new DeduceBondSystemTool(); } - + @Test(timeout=1000) public void testPyrrole() throws Exception { String smiles = "c2ccc3n([H])c1ccccc1c3(c2)"; @@ -66,6 +67,25 @@ public void testPyrrole() throws Exception { } } + @Test(timeout=1000) + public void testPyrrole_CustomRingFinder() throws Exception { + String smiles = "c2ccc3n([H])c1ccccc1c3(c2)"; + SmilesParser smilesParser = new SmilesParser(DefaultChemObjectBuilder.getInstance()); + IMolecule molecule = smilesParser.parseSmiles(smiles); + + DeduceBondSystemTool dbst = new DeduceBondSystemTool( + new AllRingsFinder() + ); + molecule = dbst.fixAromaticBondOrders(molecule); + Assert.assertNotNull(molecule); + + molecule = (IMolecule) AtomContainerManipulator.removeHydrogens(molecule); + for (int i = 0; i < molecule.getBondCount(); i++) { + IBond bond = molecule.getBond(i); + Assert.assertTrue(bond.getFlag(CDKConstants.ISAROMATIC)); + } + } + /** * @cdk.inchi InChI=1/C6H4O2/c7-5-1-2-6(8)4-3-5/h1-4H */