ExtAtomContainerManipulator extends AtomContainerManipulator { public static void aromatizeMolecule(IAtomContainer mol) { IRingSet ringSet = null; try { AllRingsFinder arf = new AllRingsFinder(); ringSet = arf.findAllRings(mol); } catch (Exception e) { e.printStackTrace(); } try { ExtAtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); Aromaticity.cdkLegacy().apply(mol); RingSetManipulator.markAromaticRings(ringSet); } catch (Exception e) { e.printStackTrace(); } for (int i = 0; i <= mol.getAtomCount() - 1; i++) { mol.getAtom(i).setFlag(CDKConstants.ISAROMATIC, false); jloop: for (int j = 0; j <= ringSet.getAtomContainerCount() - 1; j++) { IRing ring = (IRing) ringSet.getAtomContainer(j); if (!ring.getFlag(CDKConstants.ISAROMATIC)) { continue jloop; } boolean haveatom = ring.contains(mol.getAtom(i)); if (haveatom && ring.getAtomCount() == 6) { mol.getAtom(i).setFlag(CDKConstants.ISAROMATIC, true); } } } }  static IAtomContainer makeDeepCopy(IAtomContainer container); static void aromatizeMolecule(IAtomContainer mol); static int getExplicitHydrogenCount(IAtomContainer atomContainer, IAtom atom); static int getImplicitHydrogenCount(IAtom atom); static int getHydrogenCount(IAtomContainer atomContainer, IAtom atom); static IAtomContainer removeHydrogensExceptSingleAndPreserveAtomID(IAtomContainer atomContainer); static IAtomContainer convertExplicitToImplicitHydrogens(IAtomContainer atomContainer); static void percieveAtomTypesAndConfigureAtoms(IAtomContainer container);  }
@Test public void testAromatizeMolecule() throws InvalidSmilesException { String rawMolSmiles = "C1=CC2=C(C=C1)C=CC=C2"; SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles(rawMolSmiles); ExtAtomContainerManipulator.aromatizeMolecule(mol); int count = 0; for (IBond b : mol.bonds()) { if (b.getFlag(CDKConstants.ISAROMATIC) && b.getOrder().equals(IBond.Order.DOUBLE)) { count++; } } assertEquals(5, count); }