示例#1
0
        public void TestAsadExamples()
        {
            var filename = "NCDK.Data.MDL.output.rxn";

            Trace.TraceInformation("Testing: " + filename);
            var          ins         = ResourceLoader.GetAsStream(filename);
            MDLRXNReader reader      = new MDLRXNReader(ins);
            IReactionSet reactionSet = (IReactionSet)reader.Read(builder.NewReactionSet());

            reader.Close();
            filename = "NCDK.Data.MDL.output_Cleaned.rxn";
            Trace.TraceInformation("Testing: " + filename);
            ins    = ResourceLoader.GetAsStream(filename);
            reader = new MDLRXNReader(ins);
            IReactionSet reactionSet2 = (IReactionSet)reader.Read(builder.NewReactionSet());

            reader.Close();
            Assert.AreEqual(reactionSet[0].Mappings.Count, reactionSet2[0].Mappings.Count);
            for (int i = 0; i < reactionSet[0].Mappings.Count; i++)
            {
                Assert.AreEqual(
                    _GetAtomNumber(reactionSet, reactionSet[0].Mappings[i][0]),
                    _GetAtomNumber(reactionSet2, reactionSet2[0].Mappings[i][0]));
                Assert.AreEqual(
                    _GetAtomNumber(reactionSet, reactionSet[0].Mappings[i][1]),
                    _GetAtomNumber(reactionSet2, reactionSet2[0].Mappings[i][1]));
            }
        }
示例#2
0
        public void TestRDFReactioniSet()
        {
            var filename = "NCDK.Data.MDL.qsar-reaction-test.rdf";

            Trace.TraceInformation("Testing: " + filename);
            var          ins         = ResourceLoader.GetAsStream(filename);
            MDLRXNReader reader      = new MDLRXNReader(ins);
            IReactionSet reactionSet = (IReactionSet)reader.Read(builder.NewReactionSet());

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

            Assert.AreEqual(2, reactionSet.Count);
            Assert.AreEqual(2, reactionSet[0].Reactants.Count);
            Assert.AreEqual(3, reactionSet[0].Reactants[0].Atoms.Count);
            Assert.AreEqual(2, reactionSet[0].Reactants[1].Atoms.Count);
            Assert.AreEqual(2, reactionSet[0].Products.Count);
            Assert.AreEqual(2, reactionSet[0].Products[0].Atoms.Count);
            Assert.AreEqual(2, reactionSet[0].Products[1].Atoms.Count);

            Assert.AreEqual(1, reactionSet[1].Reactants.Count);
            Assert.AreEqual(3, reactionSet[1].Reactants[0].Atoms.Count);
            Assert.AreEqual(1, reactionSet[1].Products.Count);
            Assert.AreEqual(2, reactionSet[1].Products[0].Atoms.Count);
        }
示例#3
0
        public void TestReadReactions2()
        {
            string filename2 = "NCDK.Data.MDL.reaction-2.rxn";

            Trace.TraceInformation("Testing: " + filename2);
            var          ins2      = ResourceLoader.GetAsStream(filename2);
            MDLRXNReader reader2   = new MDLRXNReader(ins2);
            IReaction    reaction2 = builder.NewReaction();

            reaction2 = (IReaction)reader2.Read(reaction2);
            reader2.Close();

            Assert.IsNotNull(reaction2);
            Assert.AreEqual(2, reaction2.Reactants.Count);
            Assert.AreEqual(2, reaction2.Products.Count);
        }
示例#4
0
        public void TestReadMapping()
        {
            string filename2 = "NCDK.Data.MDL.mappingTest.rxn";

            Trace.TraceInformation("Testing: " + filename2);
            var          ins2      = ResourceLoader.GetAsStream(filename2);
            MDLRXNReader reader2   = new MDLRXNReader(ins2);
            IReaction    reaction2 = builder.NewReaction();

            reaction2 = (IReaction)reader2.Read(reaction2);
            reader2.Close();

            Assert.IsNotNull(reaction2);
            IEnumerator <IMapping> maps = reaction2.Mappings.GetEnumerator();

            Assert.IsTrue(maps.MoveNext());
        }
示例#5
0
        public void TestReactionSet_1()
        {
            IReaction      reaction11 = builder.NewReaction();
            IAtomContainer hydroxide  = builder.NewAtomContainer();

            hydroxide.Atoms.Add(builder.NewAtom("O"));
            reaction11.Reactants.Add(hydroxide);
            IAtomContainer proton = builder.NewAtomContainer();

            proton.Atoms.Add(builder.NewAtom("H"));
            reaction11.Reactants.Add(proton);

            IAtomContainer water = builder.NewAtomContainer();

            water.Atoms.Add(builder.NewAtom("O"));
            reaction11.Products.Add(water);

            IReactionSet reactionSet = new ReactionSet();

            reactionSet.Add(reaction11);

            // now serialize to MDL RXN
            StringWriter writer    = new StringWriter();
            string       file      = "";
            MDLRXNWriter mdlWriter = new MDLRXNWriter(writer);

            mdlWriter.Write(reactionSet);
            mdlWriter.Close();
            file = writer.ToString();

            Assert.IsTrue(file.Length > 0);

            // now deserialize the MDL RXN output
            IReaction    reaction2 = builder.NewReaction();
            MDLRXNReader reader    = new MDLRXNReader(new StringReader(file));

            reaction2 = (IReaction)reader.Read(reaction2);
            reader.Close();

            Assert.AreEqual(2, reaction2.Reactants.Count);
            Assert.AreEqual(1, reaction2.Reactants[0].Atoms.Count);
            Assert.AreEqual(1, reaction2.Reactants[1].Atoms.Count);
            Assert.AreEqual(1, reaction2.Products.Count);
            Assert.AreEqual(1, reaction2.Products[0].Atoms.Count);
        }
示例#6
0
        public void TestReadReactions1()
        {
            string filename1 = "NCDK.Data.MDL.reaction-1.rxn";

            Trace.TraceInformation("Testing: " + filename1);
            var          ins1      = ResourceLoader.GetAsStream(filename1);
            MDLRXNReader reader1   = new MDLRXNReader(ins1);
            IReaction    reaction1 = builder.NewReaction();

            reaction1 = (IReaction)reader1.Read(reaction1);
            reader1.Close();

            Assert.IsNotNull(reaction1);
            Assert.AreEqual(2, reaction1.Reactants.Count);
            Assert.AreEqual(1, reaction1.Products.Count);

            var educts = reaction1.Reactants;

            // Check Atom symbols of first educt
            string[] atomSymbolsOfEduct1 = { "C", "C", "O", "Cl" };
            for (int i = 0; i < educts[0].Atoms.Count; i++)
            {
                Assert.AreEqual(atomSymbolsOfEduct1[i], educts[0].Atoms[i].Symbol);
            }

            // Check Atom symbols of second educt
            for (int i = 0; i < educts[1].Atoms.Count; i++)
            {
                Assert.AreEqual("C", educts[1].Atoms[i].Symbol);
            }

            // Check Atom symbols of first product
            var products = reaction1.Products;

            string[] atomSymbolsOfProduct1 = { "C", "C", "C", "C", "C", "C", "C", "O", "C" };
            for (int i = 0; i < products[0].Atoms.Count; i++)
            {
                Assert.AreEqual(atomSymbolsOfProduct1[i], products[0].Atoms[i].Symbol);
            }
        }