/** * Removes rings which do not have all sp2/planar3 aromatic atoms. * and also gets rid of rings that have more than 8 atoms in them. * * @param m The {@link IAtomContainer} from which we want to remove rings * @return The set of reduced rings */ private IRingSet removeExtraRings(IAtomContainer m) throws Exception { IRingSet rs = Cycles.sssr(m).toRingSet(); //remove rings which dont have all aromatic atoms (according to hybridization set by lower case symbols in smiles): Iterator<IAtomContainer> i = rs.atomContainers().iterator(); while (i.hasNext()) { IRing r = (IRing) i.next(); if (r.getAtomCount() > 8) { i.remove(); } else { for (IAtom a : r.atoms()) { Hybridization h = a.getHybridization(); if (h == CDKConstants.UNSET || !(h == Hybridization.SP2 || h == Hybridization.PLANAR3)) { i.remove(); break; } } } } return rs; }
private boolean ringIsAromatic(IRing ring) { boolean isAromatic = true; for (IAtom atom : ring.atoms()) { if (!atom.getFlag(ISAROMATIC)) { isAromatic = false; break; } } if (!isAromatic) { isAromatic = true; for (IBond b : ring.bonds()) { if (!b.getFlag(ISAROMATIC)) { return false; } } } return isAromatic; }
/** * Marks the ring aromatic if all atoms and all bonds are aromatic. * * The method assumes that aromaticity of atoms and bonds have been * detected beforehand * * @param ring The ring to examine */ public static void markAromaticRings(IRing ring) { // return as soon as the conditions are not met: // 1. all atoms are labeled aromatic for (IAtom atom : ring.atoms()) if (!atom.getFlag(CDKConstants.ISAROMATIC)) return; // 2. all bonds are labeled aromatic for (IBond bond : ring.bonds()) if (!bond.getFlag(CDKConstants.ISAROMATIC)) return; // OK, all conditions are met, so ring is aromatic ring.setFlag(CDKConstants.ISAROMATIC, true); }
java.util.Iterator<IAtom> ringAtoms = ring.atoms().iterator(); int eCount = 0; java.util.List<IBond> conectedBonds;
@Test public void testMarkAromaticRings() { IRing ring = new Ring(3, "C"); Assert.assertNotNull(ring); RingManipulator.markAromaticRings(ring); Assert.assertFalse(ring.getFlag(CDKConstants.ISAROMATIC)); Iterator<IAtom> atoms = ring.atoms().iterator(); while (atoms.hasNext()) atoms.next().setFlag(CDKConstants.ISAROMATIC, true); RingManipulator.markAromaticRings(ring); Assert.assertFalse(ring.getFlag(CDKConstants.ISAROMATIC)); Iterator<IBond> bonds = ring.bonds().iterator(); while (bonds.hasNext()) bonds.next().setFlag(CDKConstants.ISAROMATIC, true); RingManipulator.markAromaticRings(ring); Assert.assertTrue(ring.getFlag(CDKConstants.ISAROMATIC)); }
chemModelRelay.getRenderer().getRenderer2DModel().getMerge().clear(); for(IAtom atom : newRing.atoms()){ IAtom closestAtomInRing = this.chemModelRelay.getClosestAtom(atom); if( closestAtomInRing != null) { toleave.getPoint2d().sub(toshift.getPoint2d()); Point2d pointSub = new Point2d(toleave.getPoint2d().x, toleave.getPoint2d().y); for(IAtom atom: newRing.atoms()){ atom.getPoint2d().sub(pointSub);
/** * Completes the layout of a partially laid out ring. * * @param rset ring set * @param ring the ring to complete * @param bondLength the bond length */ boolean completePartiallyPlacedRing(IRingSet rset, IRing ring, double bondLength) { if (ring.getFlag(CDKConstants.ISPLACED)) return true; IRing partiallyPlacedRing = molecule.getBuilder().newInstance(IRing.class); for (IAtom atom : ring.atoms()) if (atom.getPoint2d() != null) atom.setFlag(CDKConstants.ISPLACED, true); AtomPlacer.copyPlaced(partiallyPlacedRing, ring); if (partiallyPlacedRing.getAtomCount() > 1 && partiallyPlacedRing.getAtomCount() < ring.getAtomCount()) { placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.FUSED, bondLength); placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.BRIDGED, bondLength); placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.SPIRO, bondLength); ring.setFlag(CDKConstants.ISPLACED, true); return true; } else { return false; } }
/** * Completes the layout of a partially laid out ring. * * @param rset ring set * @param ring the ring to complete * @param bondLength the bond length */ boolean completePartiallyPlacedRing(IRingSet rset, IRing ring, double bondLength) { if (ring.getFlag(CDKConstants.ISPLACED)) return true; IRing partiallyPlacedRing = molecule.getBuilder().newInstance(IRing.class); for (IAtom atom : ring.atoms()) if (atom.getPoint2d() != null) atom.setFlag(CDKConstants.ISPLACED, true); AtomPlacer.copyPlaced(partiallyPlacedRing, ring); if (partiallyPlacedRing.getAtomCount() > 1 && partiallyPlacedRing.getAtomCount() < ring.getAtomCount()) { placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.FUSED, bondLength); placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.BRIDGED, bondLength); placeConnectedRings(rset, partiallyPlacedRing, RingPlacer.SPIRO, bondLength); ring.setFlag(CDKConstants.ISPLACED, true); return true; } else { return false; } }
ringPlacer.placeFusedRing(newRing, sharedAtoms, ringCenterVector, bondLength); for (IAtom ringAtom : newRing.atoms()) { if (ringAtom != firstAtom && ringAtom != secondAtom) { if (phantom) updateAtoms(sourceContainer, newRing.atoms()); for (IAtom atom : newRing.atoms()) { if (atom != firstAtom && atom != secondAtom && getClosestAtom(atom) != null) {
for (IAtom atom : ring.atoms()) { if (ring.getConnectedBondsCount(atom) == 1) terminalOnly.addAtom(atom);
for (IAtom atom : ring.atoms()) { if (ring.getConnectedBondsCount(atom) == 1) terminalOnly.addAtom(atom);
chemModel.getMoleculeSet().addAtomContainer(newAtomContainer); newAtomContainer.add(ring); updateAtoms(ring, ring.atoms()); structureChanged(); if (undoable && getUndoRedoFactory() != null
chemModel.getMoleculeSet().addAtomContainer(newAtomContainer); newAtomContainer.add(ring); updateAtoms(ring, ring.atoms()); structureChanged(); if (undoable && getUndoRedoFactory() != null