Exemplo n.º 1
0
        public void TestCyclic_Bond()
        {
            var mock_cyclicSearch            = new Mock <ICyclicVertexSearch>();
            ICyclicVertexSearch cyclicSearch = mock_cyclicSearch.Object;
            var            mock_container    = new Mock <IAtomContainer>();
            IAtomContainer container         = mock_container.Object;
            IAtom          a1        = new Mock <IAtom>().Object;
            IAtom          a2        = new Mock <IAtom>().Object;
            var            mock_bond = new Mock <IBond>();
            IBond          bond      = mock_bond.Object;

            mock_container.Setup(n => n.Atoms.IndexOf(a1)).Returns(42);
            mock_container.Setup(n => n.Atoms.IndexOf(a2)).Returns(43);
            mock_bond.Setup(n => n.Begin).Returns(a1);
            mock_bond.Setup(n => n.End).Returns(a2);

            RingSearch ringSearch = new RingSearch(container, cyclicSearch);

            ringSearch.Cyclic(bond);

            // verify the number returned from getAtomNumber is passed on
            mock_container.Verify(n => n.Atoms.IndexOf(a1), Times.Once());
            mock_container.Verify(n => n.Atoms.IndexOf(a2), Times.Once());
            mock_cyclicSearch.Verify(n => n.Cyclic(42, 43), Times.Once());
        }
Exemplo n.º 2
0
        public void TestCyclic_Int()
        {
            var ringSearch = new RingSearch(fusedRings);

            for (int i = 0; i < fusedRings.Atoms.Count; i++)
            {
                Assert.IsTrue(ringSearch.Cyclic(i));
            }
        }
Exemplo n.º 3
0
        public void TestCyclic_Int()
        {
            var n          = spiro.Atoms.Count;
            var ringSearch = new RingSearch(spiro);

            for (int i = 0; i < n; i++)
            {
                Assert.IsTrue(ringSearch.Cyclic(i));
            }
        }
        public void TestCyclic_Int()
        {
            var n          = hexaphenylene.Atoms.Count;
            var ringSearch = new RingSearch(hexaphenylene);

            for (int i = 0; i < n; i++)
            {
                Assert.IsTrue(ringSearch.Cyclic(i));
            }
        }
Exemplo n.º 5
0
        public void TestCyclic_Int()
        {
            int        n          = nonCyclic.Atoms.Count;
            RingSearch ringSearch = new RingSearch(nonCyclic);

            for (int i = 0; i < n; i++)
            {
                Assert.IsFalse(ringSearch.Cyclic(i));
            }
        }
Exemplo n.º 6
0
        public void TestCyclic_Int()
        {
            var n          = bicyclo.Atoms.Count;
            var ringSearch = new RingSearch(bicyclo);

            for (int i = 0; i < n; i++)
            {
                Assert.IsTrue(ringSearch.Cyclic(i), "all atoms should be cyclic");
            }
        }
Exemplo n.º 7
0
        public void TestCyclic()
        {
            var mock_cyclicSearch            = new Mock <ICyclicVertexSearch>();
            ICyclicVertexSearch cyclicSearch = mock_cyclicSearch.Object;
            IAtomContainer      container    = new Mock <IAtomContainer>().Object;

            RingSearch ringSearch = new RingSearch(container, cyclicSearch);

            ringSearch.Cyclic();

            mock_cyclicSearch.Verify(n => n.Cyclic(), Times.Once());
        }
Exemplo n.º 8
0
        public void TestCyclic_Atom_NotFound()
        {
            ICyclicVertexSearch cyclicSearch = new Mock <ICyclicVertexSearch>().Object;
            var            mock_container    = new Mock <IAtomContainer>();
            IAtomContainer container         = mock_container.Object;
            IAtom          atom = new Mock <IAtom>().Object;

            mock_container.Setup(n => n.Atoms.IndexOf(It.IsAny <IAtom>())).Returns(-1);

            RingSearch ringSearch = new RingSearch(container, cyclicSearch);

            ringSearch.Cyclic(atom);
        }
Exemplo n.º 9
0
        public void TestCyclic_Atom()
        {
            var mock_cyclicSearch            = new Mock <ICyclicVertexSearch>();
            ICyclicVertexSearch cyclicSearch = mock_cyclicSearch.Object;
            var            mock_container    = new Mock <IAtomContainer>();
            IAtomContainer container         = mock_container.Object;
            IAtom          atom = new Mock <IAtom>().Object;

            mock_container.Setup(n => n.Atoms.IndexOf(It.IsAny <IAtom>())).Returns(42);

            RingSearch ringSearch = new RingSearch(container, cyclicSearch);

            ringSearch.Cyclic(atom);

            // verify the number returned from getAtomNumber is passed on
            mock_container.Verify(n => n.Atoms.IndexOf(atom), Times.Once());
            mock_cyclicSearch.Verify(n => n.Cyclic(42), Times.Once());
        }
Exemplo n.º 10
0
        public void TestCyclic_Int()
        {
            var n          = benzylbenzene.Atoms.Count;
            var ringSearch = new RingSearch(benzylbenzene);

            int cyclic = 0, acyclic = 0;

            for (int i = 0; i < n; i++)
            {
                if (ringSearch.Cyclic(i))
                {
                    cyclic++;
                }
                else
                {
                    acyclic++;
                }
            }

            // single atom not in a ring
            Assert.AreEqual(1, acyclic);
            Assert.AreEqual(n - 1, cyclic);
        }
Exemplo n.º 11
0
        public void TestCyclic()
        {
            var ringSearch = new RingSearch(fusedRings);

            Assert.AreEqual(fusedRings.Atoms.Count, ringSearch.Cyclic().Length);
        }
Exemplo n.º 12
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
            }
        }