Ejemplo n.º 1
0
        public void AromaticBenzene()
        {
            Graph g = new Graph(6);

            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddAtom(AtomImpl.AromaticSubset.Carbon);
            g.AddEdge(new Edge(0, 1, Bond.Implicit));
            g.AddEdge(new Edge(1, 2, Bond.Implicit));
            g.AddEdge(new Edge(2, 3, Bond.Implicit));
            g.AddEdge(new Edge(3, 4, Bond.Implicit));
            g.AddEdge(new Edge(4, 5, Bond.Implicit));
            g.AddEdge(new Edge(5, 0, Bond.Implicit));

            Graph h = new ImplicitToExplicit().Apply(g);

            Assert.AreNotSame(h, g);

            for (int u = 0; u < h.Order; u++)
            {
                foreach (var e in h.GetEdges(u))
                {
                    Assert.AreEqual(Bond.Aromatic, e.Bond);
                }
            }
        }
Ejemplo n.º 2
0
        public void KekuleBenzene()
        {
            Graph g = new Graph(6);

            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddAtom(AtomImpl.AliphaticSubset.Carbon);
            g.AddEdge(new Edge(0, 1, Bond.Implicit));
            g.AddEdge(new Edge(1, 2, Bond.Double));
            g.AddEdge(new Edge(2, 3, Bond.Implicit));
            g.AddEdge(new Edge(3, 4, Bond.Double));
            g.AddEdge(new Edge(4, 5, Bond.Implicit));
            g.AddEdge(new Edge(5, 0, Bond.Double));

            Graph h = new ImplicitToExplicit().Apply(g);

            Assert.AreNotSame(h, g);

            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(0, 1, Bond.Single),
                new Edge(0, 5, Bond.Double)
            },
                              h.GetEdges(0)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(1, 0, Bond.Single),
                new Edge(1, 2, Bond.Double)
            },
                              h.GetEdges(1)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(2, 1, Bond.Double),
                new Edge(2, 3, Bond.Single)
            },
                              h.GetEdges(2)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(3, 2, Bond.Single),
                new Edge(3, 4, Bond.Double)
            },
                              h.GetEdges(3)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(4, 3, Bond.Double),
                new Edge(4, 5, Bond.Single)
            },
                              h.GetEdges(4)));
            Assert.IsTrue(Compares.AreOrderLessDeepEqual(
                              new[] {
                new Edge(5, 0, Bond.Double),
                new Edge(5, 4, Bond.Single)
            },
                              h.GetEdges(5)));
        }
Ejemplo n.º 3
0
        static void Transform(string smi, string exp)
        {
            ImplicitToExplicit ite = new ImplicitToExplicit();
            ToTrigonalTopology ttt = new ToTrigonalTopology();
            ExplicitToImplicit eti = new ExplicitToImplicit();

            Assert.AreEqual(exp, Generator
                            .Generate(eti.Apply(ttt.Apply(ite.Apply(Parser.Parse(smi))))));
        }
Ejemplo n.º 4
0
        public void AromaticType()
        {
            var mock_a = new Mock <IAtom>();
            var mock_b = new Mock <IAtom>();

            mock_a.Setup(n => n.IsAromatic()).Returns(true);
            mock_b.Setup(n => n.IsAromatic()).Returns(true);
            Assert.AreEqual(Bond.Aromatic, ImplicitToExplicit.Type(mock_a.Object, mock_b.Object));
        }
Ejemplo n.º 5
0
        static void Transform(string smi, int[] p, string exp)
        {
            ImplicitToExplicit   ite = new ImplicitToExplicit();
            FromTrigonalTopology ftt = new FromTrigonalTopology();
            ExplicitToImplicit   eti = new ExplicitToImplicit();

            Assert.AreEqual(exp, Generator
                            .Generate(eti.Apply(ftt.Apply(ite.Apply(Parser.Parse(smi)
                                                                    .Permute(p))))));
        }
Ejemplo n.º 6
0
        private void Transform(string input, string expected)
        {
            Graph g = Parser.Parse(input);
            ImplicitToExplicit ite    = new ImplicitToExplicit();
            FromSubsetAtoms    fsa    = new FromSubsetAtoms();
            ExplicitToImplicit eti    = new ExplicitToImplicit();
            string             actual = Generator.Generate(eti.Apply(
                                                               fsa.Apply(
                                                                   ite.Apply(g))));

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 7
0
        public void ToExplicitEdge_NonImplicitIdentity()
        {
            Graph g = new Graph(0);

            foreach (var b in Bond.Values)
            {
                if (b != Bond.Implicit)
                {
                    Edge e = new Edge(0, 1, Bond.Single);
                    Assert.AreSame(e, ImplicitToExplicit
                                   .ToExplicitEdge(g, e));
                }
            }
        }
Ejemplo n.º 8
0
        public void ToExplicitEdge()
        {
            Graph g = new Graph(2);

            var mock_u = new Mock <IAtom>();
            var mock_v = new Mock <IAtom>();

            mock_u.Setup(n => n.IsAromatic()).Returns(false);
            mock_v.Setup(n => n.IsAromatic()).Returns(false);

            g.AddAtom(mock_u.Object);
            g.AddAtom(mock_v.Object);

            Edge e = new Edge(0, 1, Bond.Implicit);

            Assert.AreNotSame(e, ImplicitToExplicit.ToExplicitEdge(g, e));

            Assert.AreEqual(new Edge(0, 1, Bond.Single), ImplicitToExplicit.ToExplicitEdge(g, e));
        }