/** * We define the heaviest ring as the one with the highest number of double bonds. * Needed for example for the placement of in-ring double bonds. * * @param ringSet The collection of rings * @param bond A bond which must be contained by the heaviest ring * @return The ring with the higest number of double bonds connected to a given bond */ public static IRing getHeaviestRing(IRingSet ringSet, IBond bond) { IRingSet rings = ringSet.getRings(bond); IRing ring = null; int maxOrderSum = 0; for (Object ring1 : rings.atomContainers()) { if (maxOrderSum < ((IRing) ring1).getBondOrderSum()) { ring = (IRing) ring1; maxOrderSum = ring.getBondOrderSum(); } } return ring; }
@Test public void testGetBondOrderSum() { IChemObject object = newChemObject(); IRing r = object.getBuilder().newInstance(IRing.class, 5, "C"); Assert.assertEquals(5, r.getBondOrderSum()); BondManipulator.increaseBondOrder(r.getBond(0)); Assert.assertEquals(6, r.getBondOrderSum()); BondManipulator.increaseBondOrder(r.getBond(0)); Assert.assertEquals(7, r.getBondOrderSum()); BondManipulator.increaseBondOrder(r.getBond(4)); Assert.assertEquals(8, r.getBondOrderSum()); }