コード例 #1
0
        public void TestReading()
        {
            var filename = "NCDK.Data.ASN.PubChem.cid1.asn";

            Trace.TraceInformation("Testing: " + filename);
            var ins = ResourceLoader.GetAsStream(filename);
            PCCompoundASNReader reader = new PCCompoundASNReader(ins);
            IChemFile           cFile  = (IChemFile)reader.Read(builder.NewChemFile());

            reader.Close();
            var containers = ChemFileManipulator.GetAllAtomContainers(cFile).ToReadOnlyList();

            Assert.AreEqual(1, containers.Count);
            Assert.IsTrue(containers[0] is IAtomContainer);
            IAtomContainer molecule = containers[0];

            Assert.IsNotNull(molecule);

            // check atom stuff
            Assert.AreEqual(31, molecule.Atoms.Count);
            Assert.IsNotNull(molecule.Atoms[3]);
            Assert.AreEqual("O", molecule.Atoms[3].Symbol);
            Assert.IsNotNull(molecule.Atoms[4]);
            Assert.AreEqual("N", molecule.Atoms[4].Symbol);

            // check bond stuff
            Assert.AreEqual(30, molecule.Bonds.Count);
            Assert.IsNotNull(molecule.Bonds[3]);
            Assert.AreEqual(molecule.Atoms[2], molecule.Bonds[3].Begin);
            Assert.AreEqual(molecule.Atoms[11], molecule.Bonds[3].End);

            // some extracted props
            Assert.AreEqual("InChI=1/C9H17NO4/c1-7(11)14-8(5-9(12)13)6-10(2,3)4/h8H,5-6H2,1-4H3",
                            molecule.GetProperty <string>(CDKPropertyName.InChI));
            Assert.AreEqual("CC(=O)OC(CC(=O)[O-])C[N+](C)(C)C", molecule.GetProperty <string>(CDKPropertyName.SMILES));
        }
コード例 #2
0
        public void TestAccepts()
        {
            PCCompoundASNReader reader = new PCCompoundASNReader(new StringReader(""));

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