SSSRFinder { public IRingSet findSSSR() { if (atomContainer == null) { return null; } IRingSet ringSet = toRingSet(atomContainer, cycleBasis().cycles()); return ringSet; } SSSRFinder(IAtomContainer container); IRingSet findSSSR(); IRingSet findEssentialRings(); IRingSet findRelevantRings(); List findEquivalenceClasses(); int[] getSSSRWeightVector(); int[] getEquivalenceClassesSizeVector();  }
@Test public void testFindSSSR() { IAtomContainer molecule = TestMoleculeFactory.makeAlphaPinene(); IRingSet ringSet = new SSSRFinder(molecule).findSSSR(); Assert.assertEquals(2, ringSet.getAtomContainerCount()); }
@Test public void testFindSSSR_IAtomContainer() { IAtomContainer molecule = TestMoleculeFactory.makeAlphaPinene(); SSSRFinder sssrFinder = new SSSRFinder(molecule); IRingSet ringSet = sssrFinder.findSSSR(); Assert.assertEquals(2, ringSet.getAtomContainerCount()); }
@Test public void testGetAtomContainerCount() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer molecule = sp.parseSmiles("c1ccccc1"); IRingSet ringSet = new SSSRFinder(molecule).findSSSR(); Assert.assertEquals(1, ringSet.getAtomContainerCount()); }
@Test public void testRingFlags1() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer molecule = sp.parseSmiles("c1ccccc1"); new SSSRFinder(molecule).findSSSR(); int count = 0; Iterator atoms = molecule.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom) atoms.next(); if (atom.getFlag(CDKConstants.ISINRING)) count++; } Assert.assertEquals("All atoms in benzene were not marked as being in a ring", 6, count); }
@Test public void testRingFlags2() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer molecule = sp.parseSmiles("C1CCCC1CC"); new SSSRFinder(molecule).findSSSR(); int count = 0; Iterator atoms = molecule.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom) atoms.next(); if (atom.getFlag(CDKConstants.ISINRING)) count++; } Assert.assertEquals("All ring atoms in 2-ethyl cyclopentane were not marked as being in a ring", 5, count); }
@Test public void testBicyclicCompound() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer molecule = sp.parseSmiles("C1CCC(CCCCC2)C2C1"); IRingSet ringSet = new SSSRFinder(molecule).findSSSR(); Assert.assertEquals(2, ringSet.getAtomContainerCount()); }
@Test public void testSFBug826942() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer molecule = sp.parseSmiles("C1CCC2C(C1)C4CCC3(CCCCC23)(C4)"); IRingSet ringSet = new SSSRFinder(molecule).findSSSR(); Assert.assertEquals(4, ringSet.getAtomContainerCount()); }
@Test public void testProblem1() throws Exception { IAtomContainer molecule = null; IRing ring = null; String filename = "data/mdl/figueras-test-sep3D.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.STRICT); molecule = (IAtomContainer) reader.read((IChemObject) new AtomContainer()); reader.close(); logger.debug("Testing " + filename); IRingSet ringSet = new SSSRFinder(molecule).findSSSR(); logger.debug("Found ring set of size: " + ringSet.getAtomContainerCount()); Assert.assertEquals(3, ringSet.getAtomContainerCount()); for (int f = 0; f < ringSet.getAtomContainerCount(); f++) { ring = (IRing) ringSet.getAtomContainer(f); logger.debug("ring: " + toString(ring, molecule)); } }
@Test public void testLoopProblem() throws Exception { String filename = "data/mdl/ring_03419.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.STRICT); IAtomContainer molecule = (IAtomContainer) reader.read((IChemObject) new AtomContainer()); reader.close(); logger.debug("Testing " + filename); IRingSet ringSet = new SSSRFinder(molecule).findSSSR(); logger.debug("Found ring set of size: " + ringSet.getAtomContainerCount()); Assert.assertEquals(12, ringSet.getAtomContainerCount()); for (int f = 0; f < ringSet.getAtomContainerCount(); f++) { IRing ring = (IRing) ringSet.getAtomContainer(f); logger.debug("ring: " + toString(ring, molecule)); } }
@Test public void testProblem2() throws Exception { IAtomContainer molecule = null; IRing ring = null; String filename = "data/mdl/figueras-test-buried.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.STRICT); molecule = (IAtomContainer) reader.read((IChemObject) new AtomContainer()); reader.close(); logger.debug("Testing " + filename); IRingSet ringSet = new SSSRFinder(molecule).findSSSR(); logger.debug("Found ring set of size: " + ringSet.getAtomContainerCount()); Assert.assertEquals(10, ringSet.getAtomContainerCount()); for (int f = 0; f < ringSet.getAtomContainerCount(); f++) { ring = (IRing) ringSet.getAtomContainer(f); logger.debug("ring: " + toString(ring, molecule)); } }
@Test public void testProblem3() throws Exception { IAtomContainer molecule = null; IRing ring = null; String filename = "data/mdl/figueras-test-inring.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.STRICT); molecule = (IAtomContainer) reader.read((IChemObject) new AtomContainer()); reader.close(); logger.debug("Testing " + filename); IRingSet ringSet = new SSSRFinder(molecule).findSSSR(); logger.debug("Found ring set of size: " + ringSet.getAtomContainerCount()); Assert.assertEquals(5, ringSet.getAtomContainerCount()); for (int f = 0; f < ringSet.getAtomContainerCount(); f++) { ring = (IRing) ringSet.getAtomContainer(f); logger.debug("ring: " + toString(ring, molecule)); } }
@Test public void testBug891021() throws Exception { IAtomContainer molecule = null; String filename = "data/mdl/too.many.rings.mol"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.STRICT); molecule = (IAtomContainer) reader.read((IChemObject) new AtomContainer()); reader.close(); logger.debug("Testing " + filename); IRingSet ringSet = new SSSRFinder(molecule).findSSSR(); logger.debug("Found ring set of size: " + ringSet.getAtomContainerCount()); Assert.assertEquals(57, ringSet.getAtomContainerCount()); }
@Category(SlowTest.class) @Test public void testBuckyballSSSR() throws Exception { IAtomContainer buckyball = createBuckyBall(); IRingSet ringSetSSSR = new SSSRFinder(buckyball).findSSSR(); ringCount(ringSetSSSR, 6, 19); ringCount(ringSetSSSR, 5, 12); Assert.assertFalse("Duplicate rings exist", checkForDuplicateRingsInSet(ringSetSSSR)); }