MmffAromaticTypeMapping { static boolean isAromaticRing(int[] cycle, int[] contribution, int[] dbs, boolean[] aromatic) { int len = cycle.length - 1; int sum = 0; int i = 0; int iPrev = len - 1; int iNext = 1; while (i < len) { int prev = cycle[iPrev]; int curr = cycle[i]; int next = cycle[iNext]; int pElectrons = contribution[curr]; if (pElectrons < 0) return false; if (pElectrons == 1) { final int other = dbs[curr]; if (other < 0) return false; if (other != prev && other != next && !aromatic[other]) return false; } iPrev = i; i = iNext; iNext = iNext + 1; sum += pElectrons; } return (sum - 2) % 4 == 0; } MmffAromaticTypeMapping();   }
@Test public void benzeneIsAromatic() { int[] cycle = new int[]{0, 1, 2, 3, 4, 5, 0}; int[] contr = new int[]{1, 1, 1, 1, 1, 1}; int[] dbs = new int[]{1, 0, 3, 2, 5, 4}; boolean[] arom = new boolean[contr.length]; Assert.assertTrue(MmffAromaticTypeMapping.isAromaticRing(cycle, contr, dbs, arom)); }
@Test public void pyrroleIsAromatic() { int[] cycle = new int[]{0, 1, 2, 3, 4, 0}; int[] contr = new int[]{2, 1, 1, 1, 1}; int[] dbs = new int[]{-1, 2, 1, 4, 3}; boolean[] arom = new boolean[contr.length]; Assert.assertTrue(MmffAromaticTypeMapping.isAromaticRing(cycle, contr, dbs, arom)); }
@Test public void exocyclicDoubleBondsBreakAromaticity() { int[] cycle = new int[]{0, 1, 2, 3, 4, 5, 0}; int[] contr = new int[]{1, 1, 1, 1, 1, 1, 1, 1}; int[] dbs = new int[]{1, 0, 6, 7, 5, 4}; boolean[] arom = new boolean[contr.length]; assertFalse(MmffAromaticTypeMapping.isAromaticRing(cycle, contr, dbs, arom)); }
@Test public void delocalisedExocyclicDoubleBondsMaintainAromaticity() { int[] cycle = new int[]{0, 1, 2, 3, 4, 5, 0}; int[] contr = new int[]{1, 1, 1, 1, 1, 1, 1, 1}; int[] dbs = new int[]{1, 0, 6, 7, 5, 4}; boolean[] arom = new boolean[contr.length]; arom[2] = arom[3] = arom[6] = arom[7] = true; Assert.assertTrue(MmffAromaticTypeMapping.isAromaticRing(cycle, contr, dbs, arom)); }
@Test public void elementContributingOneElectronRejectWhenNoDoubleBond() throws Exception { int[] cycle = new int[]{0, 1, 2, 3, 4, 5, 0}; int[] contr = new int[]{1, 1, 1, 1, 1, 1}; int[] dbs = new int[]{1, 0, 3, -1, 5, 4}; assertFalse(MmffAromaticTypeMapping.isAromaticRing(cycle, contr, dbs, new boolean[contr.length])); }