MmffAromaticTypeMapping { static boolean normaliseCycle(int[] cycle, int[] contribution) { int offset = indexOfHetro(cycle, contribution); if (offset < 0) return false; if (offset == 0) return true; int[] cpy = Arrays.copyOf(cycle, cycle.length); int len = cycle.length - 1; for (int j = 0; j < len; j++) { cycle[j] = cpy[(offset + j) % len]; } cycle[len] = cycle[0]; return true; } MmffAromaticTypeMapping();   }
@Test public void normaliseNoHetro() { int[] cycle = new int[]{3, 2, 1, 4, 5, 3}; int[] contr = new int[]{1, 1, 1, 1, 1, 1}; assertFalse(MmffAromaticTypeMapping.normaliseCycle(cycle, contr)); }
@Test public void normaliseHetroAt3() { int[] cycle = new int[]{3, 2, 1, 4, 5, 3}; int[] contr = new int[]{1, 1, 1, 1, 1, 1}; contr[cycle[3]] = 2; Assert.assertTrue(MmffAromaticTypeMapping.normaliseCycle(cycle, contr)); Assert.assertArrayEquals(new int[]{4, 5, 3, 2, 1, 4}, cycle); }
@Test public void normaliseHetroAt2() { int[] cycle = new int[]{3, 2, 1, 4, 5, 3}; int[] contr = new int[]{1, 1, 1, 1, 1, 1}; contr[cycle[2]] = 2; Assert.assertTrue(MmffAromaticTypeMapping.normaliseCycle(cycle, contr)); Assert.assertArrayEquals(new int[]{1, 4, 5, 3, 2, 1}, cycle); }