Exemplo n.º 1
0
 void Main()
 {
     {
         IAtomContainer molecule = null;
         #region
         using (var writer = new MDLRXNWriter(new FileStream("output.mol", FileMode.Create)))
         {
             writer.Write(molecule);
         }
         #endregion
     }
 }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void TestAccepts()
        {
            MDLRXNWriter reader = new MDLRXNWriter(new StringWriter());

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