/// <summary>
        /// Get the total number of bonds inside an IChemFile.
        /// </summary>
        /// <param name="file">The IChemFile object.</param>
        /// <returns>The number of Bond object inside.</returns>
        public static int GetBondCount(IChemFile file)
        {
            int count = 0;

            for (int i = 0; i < file.Count; i++)
            {
                count += ChemSequenceManipulator.GetBondCount(file[i]);
            }
            return(count);
        }
        public void TestGetAllIDs_IChemSequence()
        {
            Assert.AreEqual(0, ChemSequenceManipulator.GetAllIDs(chemSequence).Count());
            IDCreator.CreateIDs(chemSequence);
            var allIDs = ChemSequenceManipulator.GetAllIDs(chemSequence);

            Assert.AreEqual(18, ChemSequenceManipulator.GetAllIDs(chemSequence).Count());
            var uniq = new HashSet <string>(allIDs);

            Assert.AreEqual(12, uniq.Count);
        }
 /// <summary>
 /// Returns all the AtomContainer's of a ChemFile.
 /// </summary>
 public static IEnumerable <IAtomContainer> GetAllAtomContainers(IChemFile file)
 {
     foreach (var sequence in file)
     {
         foreach (var ac in ChemSequenceManipulator.GetAllAtomContainers(sequence))
         {
             yield return(ac);
         }
     }
     yield break;
 }
        /// <summary>
        /// Returns a List of all IChemObject inside a ChemFile.
        /// </summary>
        /// <returns>A list of all ChemObjects</returns>
        public static IEnumerable <IChemObject> GetAllChemObjects(IChemFile file)
        {
            //list.Add(file); // should not add the original file
            foreach (var sequence in file)
            {
                yield return(sequence);

                foreach (var o in ChemSequenceManipulator.GetAllChemObjects(sequence))
                {
                    yield return(o);
                }
            }
            yield break;
        }
 public static IEnumerable <string> GetAllIDs(IChemFile file)
 {
     if (file.Id != null)
     {
         yield return(file.Id);
     }
     foreach (var sequence in file)
     {
         foreach (var id in ChemSequenceManipulator.GetAllIDs(sequence))
         {
             yield return(id);
         }
     }
     yield break;
 }
        public void TestGetAllChemObjects_IChemSequence()
        {
            var list             = ChemSequenceManipulator.GetAllChemObjects(chemSequence);
            int molCount         = 0;
            int molSetCount      = 0;
            int reactionCount    = 0;
            int reactionSetCount = 0;
            int chemModelCount   = 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
                {
                    Assert.Fail("Unexpected Object of type " + o.GetType());
                }
            }
            //Assert.AreEqual(3, atomCount);
            //Assert.AreEqual(1, bondCount);
            Assert.AreEqual(2, molCount);
            Assert.AreEqual(1, molSetCount);
            Assert.AreEqual(1, reactionCount);
            Assert.AreEqual(1, reactionSetCount);
            Assert.AreEqual(2, chemModelCount);
        }
        public void TestGetBondCount_IChemSequence()
        {
            int count = ChemSequenceManipulator.GetBondCount(chemSequence);

            Assert.AreEqual(2, count);
        }
        public void TestGetAllAtomContainers_IChemSequence()
        {
            var list = ChemSequenceManipulator.GetAllAtomContainers(chemSequence);

            Assert.AreEqual(4, list.Count());
        }