Пример #1
0
        public void TestBug1851202()
        {
            string filename1 = "NCDK.Data.MDL.0002.stg01.rxn";

            Trace.TraceInformation("Testing: " + filename1);
            var ins1 = ResourceLoader.GetAsStream(filename1);
            MDLRXNV2000Reader reader1   = new MDLRXNV2000Reader(ins1, ChemObjectReaderMode.Strict);
            IReaction         reaction1 = new Reaction();

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

            Assert.IsNotNull(reaction1);
            Assert.AreEqual(1, reaction1.Reactants.Count);
            Assert.AreEqual(1, reaction1.Products.Count);
            IAtomContainer reactant = reaction1.Reactants[0];

            Assert.IsNotNull(reactant);
            Assert.AreEqual(30, reactant.Atoms.Count);
            Assert.AreEqual(25, reactant.Bonds.Count);
            IAtomContainer product = reaction1.Products[0];

            Assert.IsNotNull(product);
            Assert.AreEqual(30, product.Atoms.Count);
            Assert.AreEqual(26, product.Bonds.Count);
        }
Пример #2
0
        public void OptionalSdfSeparator()
        {
            const string dummyRecord = "ethanol\n" +
                                       "  Mrv1810 09251921392D          \n" +
                                       "\n" +
                                       "  3  2  0  0  0  0            999 V2000\n" +
                                       "    1.9520   -1.1270    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +
                                       "    1.2375   -0.7145    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0\n" +
                                       "    2.6664   -0.7145    0.0000 O   0  0  0  0  0  0  0  0  0  0  0  0\n" +
                                       "  1  2  1  0  0  0  0\n" +
                                       "  1  3  1  0  0  0  0\n" +
                                       "M  END\n" +
                                       "$$$$\n";
            var sb = new StringBuilder();

            sb.Append("$RXN\n");
            sb.Append("Test\n\n\n  2  1\n");
            sb.Append("$MOL\n");
            sb.Append(dummyRecord);
            sb.Append("$MOL\n");
            sb.Append(dummyRecord);
            sb.Append("$MOL\n");
            sb.Append(dummyRecord);

            var bldr = CDK.Builder;

            using (var reader = new MDLRXNV2000Reader(new StringReader(sb.ToString())))
            {
                var rxn = reader.Read(bldr.NewReaction());
                Assert.AreEqual(2, rxn.Reactants.Count);
                Assert.AreEqual(1, rxn.Products.Count);
                Assert.AreEqual(3, rxn.Reactants[0].Atoms.Count);
                Assert.AreEqual(3, rxn.Reactants[1].Atoms.Count);
            }
        }
Пример #3
0
        public void TestAccepts()
        {
            MDLRXNV2000Reader reader = new MDLRXNV2000Reader(new StringReader(""));

            Assert.IsTrue(reader.Accepts(typeof(ChemFile)));
            Assert.IsTrue(reader.Accepts(typeof(ChemModel)));
            Assert.IsTrue(reader.Accepts(typeof(Reaction)));
        }
Пример #4
0
 public void TestAgentParts()
 {
     using (var ins = ResourceLoader.GetAsStream(this.GetType(), ("ethylesterification.mol")))
     {
         MDLRXNV2000Reader rdr      = new MDLRXNV2000Reader(ins);
         IReaction         reaction = rdr.Read(new Reaction());
         Assert.AreEqual(1, reaction.Agents.Count);
     }
 }
Пример #5
0
        public void TestReadMapping()
        {
            string filename2 = "NCDK.Data.MDL.mappingTest.rxn";

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

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

            Assert.IsNotNull(reaction2);
            var maps = reaction2.Mappings.GetEnumerator();

            Assert.IsTrue(maps.MoveNext());
        }