AromaticityCalculator { public static boolean isAromatic(IRing ring, IAtomContainer atomContainer) { java.util.Iterator<IAtom> ringAtoms = ring.atoms().iterator(); int eCount = 0; java.util.List<IBond> conectedBonds; int numDoubleBond = 0; boolean allConnectedBondsSingle; while (ringAtoms.hasNext()) { IAtom atom = ringAtoms.next(); numDoubleBond = 0; allConnectedBondsSingle = true; conectedBonds = atomContainer.getConnectedBondsList(atom); for (IBond conectedBond : conectedBonds) { if (conectedBond.getOrder() == IBond.Order.DOUBLE && ring.contains(conectedBond)) { numDoubleBond++; } else if (conectedBond.getFlag(CDKConstants.ISAROMATIC) && ring.contains(conectedBond)) { numDoubleBond = 1; } if (conectedBond.getOrder() != IBond.Order.SINGLE) { allConnectedBondsSingle = false; } } if (numDoubleBond == 1) { eCount++; } else if (!atom.getSymbol().equals("C")) { eCount = eCount + 2; } else if (atom.getFlag(CDKConstants.ISAROMATIC)) { eCount++; } else if (allConnectedBondsSingle && atom.getSymbol().equals("C") && atom.getFormalCharge() == 1.0) { continue; } else { return false; } } return eCount - 2 != 0 && (eCount - 2) % 4 == 0; }  static boolean isAromatic(IRing ring, IAtomContainer atomContainer);  }
@Test public void testIsAromatic_IRing_IAtomContainer() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("c1ccncc1"); IRingSet rs = (new AllRingsFinder()).findAllRings(mol); Assert.assertEquals(1, rs.getAtomContainerCount()); Assert.assertTrue(AromaticityCalculator.isAromatic((IRing) rs.getAtomContainer(0), mol)); }