Ejemplo n.º 1
0
        /// <summary>
        /// Convert to an identity template library.
        /// </summary>
        /// <returns>identity template library</returns>
        internal IdentityTemplateLibrary ToIdentityTemplateLibrary()
        {
            var lib = IdentityTemplateLibrary.Empty();

            foreach (var mol in templates)
            {
                lib.Add(AtomContainerManipulator.Anonymise(mol));
            }
            return(lib);
        }
        public void Store()
        {
            IdentityTemplateLibrary lib = IdentityTemplateLibrary.Empty();

            lib.Add(IdentityTemplateLibrary.DecodeEntry("[C][C][O] 0, 1, 2, 3, 4, 5"));
            lib.Add(IdentityTemplateLibrary.DecodeEntry("[C][C] 0, 1, 2, 3"));
            using (var baos = new MemoryStream())
            {
                lib.Store(baos);
                Assert.AreEqual(
                    "[C][C][O] |(0,1,;2,3,;4,5,)|\n[C][C] |(0,1,;2,3,)|\n",
                    Encoding.UTF8.GetString(baos.ToArray()));
            }
        }
        public void AssignEthanolNoEntry()
        {
            IAtomContainer container = new AtomContainer();

            container.Atoms.Add(new Atom("O"));
            container.Atoms.Add(new Atom("C"));
            container.Atoms.Add(new Atom("C"));
            container.Atoms[0].ImplicitHydrogenCount = 0;
            container.Atoms[1].ImplicitHydrogenCount = 0;
            container.Atoms[2].ImplicitHydrogenCount = 0;
            container.AddBond(container.Atoms[0], container.Atoms[1], BondOrder.Single);
            container.AddBond(container.Atoms[1], container.Atoms[2], BondOrder.Single);

            Assert.IsFalse(IdentityTemplateLibrary.Empty().AssignLayout(container));
        }
        public void AssignEthanol()
        {
            IAtomContainer container = new AtomContainer();

            container.Atoms.Add(new Atom("O"));
            container.Atoms.Add(new Atom("C"));
            container.Atoms.Add(new Atom("C"));
            container.Atoms[0].ImplicitHydrogenCount = 0;
            container.Atoms[1].ImplicitHydrogenCount = 0;
            container.Atoms[2].ImplicitHydrogenCount = 0;
            container.AddBond(container.Atoms[0], container.Atoms[1], BondOrder.Single);
            container.AddBond(container.Atoms[1], container.Atoms[2], BondOrder.Single);

            IdentityTemplateLibrary lib = IdentityTemplateLibrary.Empty();

            lib.Add(IdentityTemplateLibrary.DecodeEntry("OCC 4, 5, 2, 3, 0, 1"));
            Assert.IsTrue(lib.AssignLayout(container));
            Assert.AreEqual(4, container.Atoms[0].Point2D.Value.X, 0.01);
            Assert.AreEqual(5, container.Atoms[0].Point2D.Value.Y, 0.01);
            Assert.AreEqual(2, container.Atoms[1].Point2D.Value.X, 0.01);
            Assert.AreEqual(3, container.Atoms[1].Point2D.Value.Y, 0.01);
            Assert.AreEqual(0, container.Atoms[2].Point2D.Value.X, 0.01);
            Assert.AreEqual(1, container.Atoms[2].Point2D.Value.Y, 0.01);
        }