public void TestIsolatedRingFragments()
        {
            var search   = new RingSearch(hexaphenylene);
            var isolated = search.IsolatedRingFragments();

            Assert.AreEqual(0, isolated.Count());
        }
Exemplo n.º 2
0
        public void TestIsolatedRingFragments()
        {
            var ringSearch = new RingSearch(fusedRings);
            var fragments  = ringSearch.IsolatedRingFragments();

            Assert.AreEqual(0, fragments.Count());
        }
Exemplo n.º 3
0
        public void TestIsolatedRingFragments()
        {
            var mock_cyclicSearch = new Mock <ICyclicVertexSearch>();
            var mock_container    = new Mock <IAtomContainer>();
            var mock_builder      = new Mock <IChemObjectBuilder>();
            var mock_atom         = new Mock <IAtom>();

            RingSearch ringSearch = new RingSearch(mock_container.Object, mock_cyclicSearch.Object);

            mock_cyclicSearch.Setup(n => n.Isolated()).Returns(new int[][] { new[] { 0, 1 }, new[] { 2 } });
            mock_container.Setup(n => n.Builder).Returns(mock_builder.Object);
            mock_container.Setup(n => n.Bonds).Returns(new List <IBond>());
            mock_container.Setup(n => n.Atoms[It.IsAny <int>()]).Returns(new Mock <IAtom>().Object);
            mock_builder.Setup(n => n.NewAtomContainer(It.IsAny <IEnumerable <IAtom> >(), It.IsAny <IEnumerable <IBond> >())).Returns(new Mock <IAtomContainer>().Object);

            ringSearch.IsolatedRingFragments().ToReadOnlyList();

            mock_cyclicSearch.Verify(n => n.Isolated(), Times.Once());

            // atoms were accessed
            mock_container.Verify(n => n.Atoms[0], Times.Once());
            mock_container.Verify(n => n.Atoms[1], Times.Once());
            mock_container.Verify(n => n.Atoms[2], Times.Once());

            // builder was invoked
            mock_builder.Verify(n => n.NewAtomContainer(It.IsAny <IEnumerable <IAtom> >(), It.IsAny <IEnumerable <IBond> >()), Times.Exactly(2));
        }
Exemplo n.º 4
0
        public void TestIsolatedRingFragments()
        {
            var search   = new RingSearch(spiro);
            var isolated = search.IsolatedRingFragments().ToReadOnlyList();

            Assert.AreEqual(2, isolated.Count);
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(new[] { 4, 7 }, new int[] { isolated[0].Atoms.Count, isolated[1].Atoms.Count }));
        }
Exemplo n.º 5
0
        public void TestIsolatedRingFragments()
        {
            var search   = new RingSearch(benzene);
            var isolated = search.IsolatedRingFragments().ToReadOnlyList();

            Assert.AreEqual(1, isolated.Count);
            Assert.AreEqual(6, isolated[0].Atoms.Count);
            Assert.AreEqual(6, isolated[0].Bonds.Count);
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            {
                #region
                // construct the search for a given molecule, if an adjacency list
                // representation (int[][]) is available this can be passed to the
                // constructor for improved performance
                IAtomContainer container  = TestMoleculeFactory.MakeAlphaPinene();
                RingSearch     ringSearch = new RingSearch(container);

                // indices of cyclic vertices
                int[] cyclic = ringSearch.Cyclic();

                // iterate over fused systems (atom indices)
                foreach (int[] fused in ringSearch.Fused())
                {
                    // ...
                }

                // iterate over isolated rings (atom indices)
                foreach (int[] isolated in ringSearch.Isolated())
                {
                    // ...
                }

                // convenience methods for getting the fragments
                IAtomContainer fragments = ringSearch.RingFragments();

                foreach (IAtomContainer fragment in ringSearch.FusedRingFragments())
                {
                    // ...
                }
                foreach (IAtomContainer fragment in ringSearch.IsolatedRingFragments())
                {
                    // ...
                }
                #endregion
            }
            {
                #region Cyclic
                IAtomContainer mol        = TestMoleculeFactory.MakeAlphaPinene();
                RingSearch     ringSearch = new RingSearch(mol);
                foreach (var atom in mol.Atoms)
                {
                    if (ringSearch.Cyclic(atom))
                    {
                        // ...
                    }
                }
                #endregion
            }
            {
                #region Cyclic_int
                IAtomContainer mol    = TestMoleculeFactory.MakeAlphaPinene();
                RingSearch     tester = new RingSearch(mol);

                int n = mol.Atoms.Count;
                for (int i = 0; i < n; i++)
                {
                    if (tester.Cyclic(i))
                    {
                        // ...
                    }
                }
                #endregion
            }
            {
                #region Isolated
                IAtomContainer biphenyl   = TestMoleculeFactory.MakeBiphenyl();
                RingSearch     ringSearch = new RingSearch(biphenyl);

                int[][] isolated = ringSearch.Isolated();
                Console.WriteLine(isolated.Length);    // 2 isolated rings in biphenyl
                Console.WriteLine(isolated[0].Length); // 6 vertices in one benzene
                Console.WriteLine(isolated[1].Length); // 6 vertices in the other benzene
                #endregion
            }
            if (true)
            {
                #region Fused
                IAtomContainer mol        = new Smiles.SmilesParser().ParseSmiles("c1cc(cc2cc(ccc12)C3C4CC34)C6CC5CCC6(C5)");
                RingSearch     ringSearch = new RingSearch(mol);

                int[][] fused = ringSearch.Fused();
                Console.WriteLine(fused.Length);    // e.g. 3 separate fused ring systems
                Console.WriteLine(fused[0].Length); // e.g. 10 vertices in the first system
                Console.WriteLine(fused[1].Length); // e.g. 4 vertices in the second system
                Console.WriteLine(fused[2].Length); // e.g. 7 vertices in the third system
                #endregion
            }
        }