Ejemplo n.º 1
0
        public void CreateExplicitH()
        {
            var m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            m_container.SetupGet(n => n.Atoms.Count).Returns(5);

            var m_c1 = new Mock <IAtom>(); var c1 = m_c1.Object;
            var m_o2 = new Mock <IAtom>(); var o2 = m_o2.Object;
            var m_n3 = new Mock <IAtom>(); var n3 = m_n3.Object;
            var m_c4 = new Mock <IAtom>(); var c4 = m_c4.Object;
            var m_h5 = new Mock <IAtom>(); var h5 = m_h5.Object;

            m_container.SetupGet(n => n.Atoms[0]).Returns(c1);
            m_container.SetupGet(n => n.Atoms[1]).Returns(o2);
            m_container.SetupGet(n => n.Atoms[2]).Returns(n3);
            m_container.SetupGet(n => n.Atoms[3]).Returns(c4);
            m_container.SetupGet(n => n.Atoms[4]).Returns(h5);

            m_container.SetupGet(n => n.Atoms).Returns(new[] { c1, o2, n3, c4, h5 });

            var m_tc = new Mock <ITetrahedralChirality>(); var tc = m_tc.Object;

            m_tc.SetupGet(n => n.ChiralAtom).Returns(c1);
            m_tc.SetupGet(n => n.Ligands).Returns(new IAtom[] { o2, n3, c4, h5 });
            m_tc.SetupGet(n => n.Stereo).Returns(TetrahedralStereo.Clockwise);
            m_container.Setup(n => n.StereoElements).Returns(new[] { tc });

            IStereoEncoder encoder = new TetrahedralElementEncoderFactory().Create(container, Array.Empty <int[]>()); // graph not used

            Assert.AreEqual(-1, GetGeometricParity(encoder).Parity);                                                  // clockwise
        }
Ejemplo n.º 2
0
        public void CreateImplicitH_back()
        {
            var m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            var m_c1 = new Mock <IAtom>(); var c1 = m_c1.Object;
            var m_o2 = new Mock <IAtom>(); var o2 = m_o2.Object;
            var m_n3 = new Mock <IAtom>(); var n3 = m_n3.Object;
            var m_c4 = new Mock <IAtom>(); var c4 = m_c4.Object;

            m_container.SetupGet(n => n.Atoms[0]).Returns(c1);
            m_container.SetupGet(n => n.Atoms[1]).Returns(o2);
            m_container.SetupGet(n => n.Atoms[2]).Returns(n3);
            m_container.SetupGet(n => n.Atoms[3]).Returns(c4);

            m_container.SetupGet(n => n.Atoms).Returns(new[] { c1, o2, n3, c4 });

            var m_tc = new Mock <ITetrahedralChirality>(); var tc = m_tc.Object;

            m_tc.SetupGet(n => n.ChiralAtom).Returns(c1);
            m_tc.SetupGet(n => n.Ligands).Returns(new IAtom[] { o2, n3, c4, c1 // <-- represents implicit H
                                                  });
            m_tc.SetupGet(n => n.Stereo).Returns(TetrahedralStereo.Clockwise);
            m_container.Setup(n => n.StereoElements).Returns(new[] { tc });

            IStereoEncoder encoder = new TetrahedralElementEncoderFactory().Create(container, Array.Empty <int[]>()); // graph not used

            Assert.AreEqual(-1, GetGeometricParity(encoder).Parity);                                                  // clockwise (we didn't have to move the implied H)
        }
Ejemplo n.º 3
0
        public void CreateImplicitH_front()
        {
            var m_container = new Mock <IAtomContainer>(); var container = m_container.Object;

            var m_c1 = new Mock <IAtom>(); var c1 = m_c1.Object;
            var m_o2 = new Mock <IAtom>(); var o2 = m_o2.Object;
            var m_n3 = new Mock <IAtom>(); var n3 = m_n3.Object;
            var m_c4 = new Mock <IAtom>(); var c4 = m_c4.Object;

            m_container.SetupGet(n => n.Atoms[0]).Returns(c1);
            m_container.SetupGet(n => n.Atoms[1]).Returns(o2);
            m_container.SetupGet(n => n.Atoms[2]).Returns(n3);
            m_container.SetupGet(n => n.Atoms[3]).Returns(c4);

            m_container.SetupGet(n => n.Atoms).Returns(new[] { c1, o2, n3, c4 });

            var m_tc = new Mock <ITetrahedralChirality>(); var tc = m_tc.Object;

            m_tc.SetupGet(n => n.ChiralAtom).Returns(c1);
            m_tc.SetupGet(n => n.Ligands).Returns(new IAtom[] { c1, // <-- represents implicit H
                                                                o2, n3, c4, });
            m_tc.SetupGet(n => n.Stereo).Returns(TetrahedralStereo.Clockwise);
            m_container.Setup(n => n.StereoElements).Returns(new[] { tc });

            IStereoEncoder encoder = new TetrahedralElementEncoderFactory().Create(container, Array.Empty <int[]>()); // graph not used

            // anti-clockwise (inverted as we had to move the implicit H to the back
            // with an odd number of inversions)
            Assert.AreEqual(1, GetGeometricParity(encoder).Parity);
        }