private boolean inRingSet(IAtom atom, IRingSet ringSet) { for (int i = 0; i < ringSet.getAtomContainerCount(); i++) { IRing ring = (IRing) ringSet.getAtomContainer(i); if (ring.contains(atom)) return true; } return false; }
/** * True if coordinates have been assigned to all atoms in all rings. * * @param rs The ringset to be checked * @return True if coordinates have been assigned to all atoms in all rings. */ public boolean allPlaced(IRingSet rs) { for (int i = 0; i < rs.getAtomContainerCount(); i++) { if (!((IRing) rs.getAtomContainer(i)).getFlag(CDKConstants.ISPLACED)) { return false; } } return true; }
/** * True if coordinates have been assigned to all atoms in all rings. * * @param rs The ringset to be checked * @return True if coordinates have been assigned to all atoms in all rings. */ public boolean allPlaced(IRingSet rs) { for (int i = 0; i < rs.getAtomContainerCount(); i++) { if (!((IRing) rs.getAtomContainer(i)).getFlag(CDKConstants.ISPLACED)) { return false; } } return true; }
/** * Are all rings in the Vector placed? * * @param rings The Vector to be checked * @return true if all rings are placed, false otherwise */ private boolean allPlaced(IRingSet rings) { for (int f = 0; f < rings.getAtomContainerCount(); f++) { if (!((IRing) rings.getAtomContainer(f)).getFlag(CDKConstants.ISPLACED)) { logger.debug("allPlaced->Ring " + f + " not placed"); return false; } } return true; }
public static boolean inSameAromaticRing(IAtomContainer m, IAtom atom1, IAtom atom2, IRingSet rs) { if (rs == null) return false; for (int i = 0; i <= rs.getAtomContainerCount() - 1; i++) { IRing r = (IRing) rs.getAtomContainer(i); if (r.contains(atom1) && r.contains(atom2)) { if (isAromaticRing(r)) return (true); } } return false; }
/** * Adds all rings of another RingSet if they are not already part of this ring set. * * If you want to add a single ring to the set use {@link #addAtomContainer(org.openscience.cdk.interfaces.IAtomContainer)} * * @param ringSet the ring set to be united with this one. */ @Override public void add(IRingSet ringSet) { for (int f = 0; f < ringSet.getAtomContainerCount(); f++) { if (!contains(ringSet.getAtomContainer(f))) { addAtomContainer(ringSet.getAtomContainer(f)); } } }
/** * Adds all rings of another RingSet if they are not already part of this ring set. * * If you want to add a single ring to the set use {@link #addAtomContainer(org.openscience.cdk.interfaces.IAtomContainer)} * * @param ringSet the ring set to be united with this one. */ @Override public void add(IRingSet ringSet) { for (int f = 0; f < ringSet.getAtomContainerCount(); f++) { if (!contains(ringSet.getAtomContainer(f))) { addAtomContainer(ringSet.getAtomContainer(f)); } } }
@Test public void testGetBasicRings() throws Exception { IRingSet ringSet = azulene.getBasicRings(); Assert.assertEquals(2, ringSet.getAtomContainerCount()); ringSet = ethane.getBasicRings(); Assert.assertEquals(0, ringSet.getAtomContainerCount()); }
@Test public void testGetAllRings() throws Exception { IRingSet ringSet = azulene.getAllRings(); Assert.assertEquals(3, ringSet.getAtomContainerCount()); ringSet = ethane.getAllRings(); Assert.assertEquals(0, ringSet.getAtomContainerCount()); }
@Test public void testGetLargestRingSet_List_IRingSet() throws Exception { List<IRingSet> list = new Vector<IRingSet>(); list.add(ringset); IAtomContainer mol = TestMoleculeFactory.makeBiphenyl(); AllRingsFinder arf = new AllRingsFinder(); IRingSet ringSet = arf.findAllRings(mol); list.add(ringSet); Assert.assertEquals(2, RingSetManipulator.getLargestRingSet(list).getAtomContainerCount()); } }
@Test public void testSort_IRingSet() { RingSetManipulator.sort(ringset); Assert.assertEquals(4, ringset.getAtomContainerCount()); int currentSize = ringset.getAtomContainer(0).getAtomCount(); for (int i = 1; i < ringset.getAtomContainerCount(); ++i) { Assert.assertTrue(ringset.getAtomContainer(i).getAtomCount() >= currentSize); currentSize = ringset.getAtomContainer(i).getAtomCount(); } }
@Test public void testFindAllRings_IAtomContainer() throws Exception { IRingSet ringSet = null; AllRingsFinder arf = new AllRingsFinder(); IAtomContainer molecule = TestMoleculeFactory.makeEthylPropylPhenantren(); //display(molecule); ringSet = arf.findAllRings(molecule); Assert.assertEquals(6, ringSet.getAtomContainerCount()); }
@Test public void testCholoylCoA() throws Exception { IRingSet ringSet = null; AllRingsFinder arf = new AllRingsFinder(); String filename = "data/mdl/choloylcoa.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); IChemFile chemFile = (IChemFile) reader.read(new org.openscience.cdk.ChemFile()); IChemSequence seq = chemFile.getChemSequence(0); IChemModel model = seq.getChemModel(0); IAtomContainer molecule = model.getMoleculeSet().getAtomContainer(0); ringSet = arf.findAllRings(molecule); Assert.assertEquals(14, ringSet.getAtomContainerCount()); }
@Test public void testPorphyrine() throws Exception { IRingSet ringSet = null; AllRingsFinder arf = new AllRingsFinder(); String filename = "data/mdl/porphyrin.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); IChemFile chemFile = (IChemFile) reader.read(new org.openscience.cdk.ChemFile()); IChemSequence seq = chemFile.getChemSequence(0); IChemModel model = seq.getChemModel(0); IAtomContainer molecule = model.getMoleculeSet().getAtomContainer(0); ringSet = arf.findAllRings(molecule); Assert.assertEquals(20, ringSet.getAtomContainerCount()); }
@Test public void testBigRingSystem_MaxRingSize6_03419() throws Exception { IRingSet ringSet = null; AllRingsFinder arf = new AllRingsFinder(); String filename = "data/mdl/ring_03419.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); IChemFile chemFile = (IChemFile) reader.read(new ChemFile()); IChemSequence seq = chemFile.getChemSequence(0); IChemModel model = seq.getChemModel(0); IAtomContainer molecule = model.getMoleculeSet().getAtomContainer(0); ringSet = arf.findAllRings(molecule, 6); Assert.assertEquals(12, ringSet.getAtomContainerCount()); }
@Test public void testAzulene() throws Exception { IRingSet ringSet = null; AllRingsFinder arf = new AllRingsFinder(); String filename = "data/mdl/azulene.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins); IChemFile chemFile = (IChemFile) reader.read(new org.openscience.cdk.ChemFile()); IChemSequence seq = chemFile.getChemSequence(0); IChemModel model = seq.getChemModel(0); IAtomContainer molecule = model.getMoleculeSet().getAtomContainer(0); ringSet = arf.findAllRings(molecule); Assert.assertEquals(3, ringSet.getAtomContainerCount()); }
@Test public void testGetBondCount() throws Exception { IAtomContainer mol = TestMoleculeFactory.makeAdenine(); AllRingsFinder arf = new AllRingsFinder(); IRingSet ringSet = arf.findAllRings(mol); Assert.assertEquals(3, ringSet.getAtomContainerCount()); Assert.assertEquals(20, RingSetManipulator.getBondCount(ringSet)); mol = TestMoleculeFactory.makeBiphenyl(); ringSet = arf.findAllRings(mol); Assert.assertEquals(2, ringSet.getAtomContainerCount()); Assert.assertEquals(12, RingSetManipulator.getBondCount(ringSet)); }
@Test public void testAdd_IRingSet() { IRingSet rs = (IRingSet) newChemObject(); IRing r1 = rs.getBuilder().newInstance(IRing.class, 5, "C"); IRing r2 = rs.getBuilder().newInstance(IRing.class, 3, "C"); rs.addAtomContainer(r1); IRingSet rs2 = (IRingSet) newChemObject(); rs2.addAtomContainer(r2); rs2.add(rs); Assert.assertEquals(1, rs.getAtomContainerCount()); Assert.assertEquals(2, rs2.getAtomContainerCount()); }
@Test public void markAromatic() throws Exception { IAtomContainer mol = TestMoleculeFactory.makeBiphenyl(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); Aromaticity.cdkLegacy().apply(mol); AllRingsFinder arf = new AllRingsFinder(); IRingSet ringSet = arf.findAllRings(mol); Assert.assertEquals(2, ringSet.getAtomContainerCount()); RingSetManipulator.markAromaticRings(ringSet); for (int i = 0; i < ringSet.getAtomContainerCount(); i++) { IRing ring = (IRing) ringSet.getAtomContainer(i); Assert.assertTrue(ring.getFlag(CDKConstants.ISAROMATIC)); } }
@Test @Override public void testClone() throws CloneNotSupportedException { IRingSet ringset = (IRingSet) newChemObject(); IRing ring = ringset.getBuilder().newInstance(IRing.class); ringset.addAtomContainer(ring); IRingSet clone = (IRingSet) ringset.clone(); Assert.assertNotNull(clone); Assert.assertTrue(clone instanceof IRingSet); Assert.assertEquals(1, clone.getAtomContainerCount()); Assert.assertNotSame(ring, clone.getAtomContainer(0)); }