Exemplo n.º 1
0
        public void TestReading()
        {
            var filename = "NCDK.Data.ASN.PubChem.cid1145.xml";

            Trace.TraceInformation("Testing: " + filename);
            var ins = ResourceLoader.GetAsStream(filename);
            PCCompoundXMLReader reader   = new PCCompoundXMLReader(ins);
            IAtomContainer      molecule = (IAtomContainer)reader.Read(builder.NewAtomContainer());

            reader.Close();
            Assert.IsNotNull(molecule);

            // check atom stuff
            Assert.AreEqual(14, molecule.Atoms.Count);
            Assert.AreEqual("O", molecule.Atoms[0].Symbol);
            Assert.AreEqual(-1, molecule.Atoms[0].FormalCharge);
            Assert.AreEqual("N", molecule.Atoms[1].Symbol);
            Assert.AreEqual(1, molecule.Atoms[1].FormalCharge);

            // check bond stuff
            Assert.AreEqual(13, molecule.Bonds.Count);
            Assert.IsNotNull(molecule.Bonds[3]);

            // coordinates
            Assert.IsNull(molecule.Atoms[0].Point3D);
            var npoint = molecule.Atoms[0].Point2D;

            Assert.IsNotNull(npoint);
            var point = npoint.Value;

            Assert.AreEqual(3.7320508956909, point.X, 0.00000001);
            Assert.AreEqual(0.5, point.Y, 0.00000001);
        }
Exemplo n.º 2
0
        public void TestReading3DCoords()
        {
            var filename = "NCDK.Data.ASN.PubChem.cid176.xml";

            Trace.TraceInformation("Testing: " + filename);
            var ins = ResourceLoader.GetAsStream(filename);
            PCCompoundXMLReader reader   = new PCCompoundXMLReader(ins);
            IAtomContainer      molecule = (IAtomContainer)reader.Read(builder.NewAtomContainer());

            reader.Close();
            Assert.IsNotNull(molecule);

            // check atom stuff
            Assert.AreEqual(8, molecule.Atoms.Count);
            Assert.IsNull(molecule.Atoms[0].Point2D);
            var npoint = molecule.Atoms[0].Point3D;

            Assert.IsNotNull(npoint);
            var point = npoint.Value;

            Assert.AreEqual(-0.9598, point.X, 0.0001);
            Assert.AreEqual(1.5616, point.Y, 0.0001);
            Assert.AreEqual(1.8714, point.Z, 0.0001);
        }
Exemplo n.º 3
0
        public void TestAccepts()
        {
            PCCompoundXMLReader reader = new PCCompoundXMLReader(new StringReader(""));

            Assert.IsTrue(reader.Accepts(typeof(IAtomContainer)));
        }