Navigation Menu

Skip to content

Commit

Permalink
Added a constructor to set a custom ring finder instance (e.g. with a…
Browse files Browse the repository at this point in the history
… time out set)

Signed-off-by: Rajarshi Guha <rajarshi.guha@gmail.com>
  • Loading branch information
egonw authored and rajarshi committed Oct 16, 2010
1 parent e017551 commit b24820b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/main/org/openscience/cdk/smiles/DeduceBondSystemTool.java
Expand Up @@ -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);
Expand Down
Expand Up @@ -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;

/**
Expand All @@ -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)";
Expand All @@ -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
*/
Expand Down

0 comments on commit b24820b

Please sign in to comment.