Esempio n. 1
0
        public void TestGetAllIDs_IChemFile()
        {
            Assert.AreEqual(0, ChemFileManipulator.GetAllIDs(chemFile).Count());
            IDCreator.CreateIDs(chemFile);
            var allIDs = ChemFileManipulator.GetAllIDs(chemFile);

            Assert.AreEqual(19, ChemFileManipulator.GetAllIDs(chemFile).Count());
            var uniq = new HashSet <string>(allIDs);

            Assert.AreEqual(13, uniq.Count);
        }
Esempio n. 2
0
        public void TestGetAllAtomContainers_IChemFile()
        {
            var filename = "NCDK.Data.MDL.prev2000.sd";

            Trace.TraceInformation("Testing: " + filename);
            var ins = ResourceLoader.GetAsStream(filename);

            var reader   = new MDLReader(ins, ChemObjectReaderMode.Strict);
            var chemFile = reader.Read(builder.NewChemFile());

            Assert.IsNotNull(chemFile);
            var containersList = ChemFileManipulator.GetAllAtomContainers(chemFile).ToReadOnlyList();

            Assert.AreEqual(2, containersList.Count);
        }
Esempio n. 3
0
        public void TestGetAllReactions_IChemFile()
        {
            var list = ChemFileManipulator.GetAllReactions(chemFile).ToReadOnlyList();

            Assert.AreEqual(1, list.Count);
        }
Esempio n. 4
0
        public void TestGetAllChemObjects_IChemFile()
        {
            var list = ChemFileManipulator.GetAllChemObjects(chemFile).ToReadOnlyList();

            Assert.AreEqual(8, list.Count); // not the file itself
            int atomCount         = 0;
            int bondCount         = 0;
            int molCount          = 0;
            int molSetCount       = 0;
            int reactionCount     = 0;
            int reactionSetCount  = 0;
            int chemModelCount    = 0;
            int chemSequenceCount = 0;

            foreach (var o in list)
            {
                if (o is IAtom)
                {
                    ++atomCount;
                }
                if (o is IBond)
                {
                    ++bondCount;
                }
                if (o is IAtomContainer)
                {
                    ++molCount;
                }
                else if (o is IChemObjectSet <IAtomContainer> )
                {
                    ++molSetCount;
                }
                else if (o is IReaction)
                {
                    ++reactionCount;
                }
                else if (o is IReactionSet)
                {
                    ++reactionSetCount;
                }
                else if (o is IChemModel)
                {
                    ++chemModelCount;
                }
                else if (o is IChemSequence)
                {
                    ++chemSequenceCount;
                }
                else
                {
                    Assert.Fail("Unexpected Object of type " + o.GetType());
                }
            }
            Assert.AreEqual(0, atomCount); /// it does not recurse into IAtomContainer
            Assert.AreEqual(0, bondCount);
            Assert.AreEqual(2, molCount);
            Assert.AreEqual(1, molSetCount);
            Assert.AreEqual(1, reactionCount);
            Assert.AreEqual(1, reactionSetCount);
            Assert.AreEqual(1, chemModelCount);
            Assert.AreEqual(2, chemSequenceCount);
        }
Esempio n. 5
0
        public void TestGetBondCount_IChemFile()
        {
            var count = ChemFileManipulator.GetBondCount(chemFile);

            Assert.AreEqual(2, count);
        }