StandardBondGenerator { static Map<IBond, IAtomContainer> ringPreferenceMap(IAtomContainer container, IRingSet smallest) { if (smallest == null) smallest = Cycles.edgeShort(container).toRingSet(); final List<IAtomContainer> rings = AtomContainerSetManipulator.getAllAtomContainers(smallest); Collections.sort(rings, new RingBondOffsetComparator(container)); final Map<IBond, IAtomContainer> ringMap = new HashMap<IBond, IAtomContainer>(); for (IAtomContainer ring : rings) { normalizeRingWinding(ring); for (IBond bond : ring.bonds()) { if (ringMap.containsKey(bond)) continue; ringMap.put(bond, ring); } } return Collections.unmodifiableMap(ringMap); } private  StandardBondGenerator(IAtomContainer container,
                                  AtomSymbol[] symbols,
                                  RendererModel parameters,
                                  ElementGroup annotations,
                                  Font font,
                                  double stroke,
                                  StandardDonutGenerator donutGen);   }
@Test public void adenineRingPreference() throws Exception { IAtomContainer adenine = TestMoleculeFactory.makeAdenine(); Map<IBond, IAtomContainer> ringMap = StandardBondGenerator.ringPreferenceMap(adenine); int nSize5 = 0, nSize6 = 0; for (IBond bond : adenine.bonds()) { IAtomContainer ring = ringMap.get(bond); if (ring == null) continue; int size = ring.getAtomCount(); if (size == 5) nSize5++; if (size == 6) nSize6++; } assertThat(nSize5, is(4)); assertThat(nSize6, is(6)); }
@Test public void metalRingPreference() throws Exception { SmilesParser smipar = new SmilesParser(SilentChemObjectBuilder.getInstance()); IAtomContainer mol = smipar.parseSmiles("C1[Fe]C=CC2=C1C=CN2"); for (IAtom atom : mol.atoms()) atom.setPoint2d(new Point2d(0,0)); Map<IBond, IAtomContainer> ringMap = StandardBondGenerator.ringPreferenceMap(mol); int nSize5 = 0, nSize6 = 0; for (IBond bond : mol.bonds()) { IAtomContainer ring = ringMap.get(bond); if (ring == null) continue; int size = ring.getAtomCount(); if (size == 5) nSize5++; if (size == 6) nSize6++; } assertThat(nSize5, is(5)); assertThat(nSize6, is(5)); }