public static IEnumerable <string> GetAllIDs(IReactionSet set) { if (set.Id != null) { yield return(set.Id); } foreach (var reaction in set) { foreach (var e in ReactionManipulator.GetAllIDs(reaction)) { yield return(e); } } yield break; }
/// <summary> /// Get all ID of this IReactionSet. /// </summary> /// <param name="scheme">The IReactionScheme to analyze</param> /// <returns>A List with all ID</returns> public static IEnumerable <string> GetAllIDs(IReactionScheme scheme) { var IDlist = new List <string>(); if (scheme.Id != null) { IDlist.Add(scheme.Id); } foreach (var reaction in scheme.Reactions) { IDlist.AddRange(ReactionManipulator.GetAllIDs(reaction)); } if (scheme.Schemes.Count != 0) { foreach (var rs in scheme.Schemes) { IDlist.AddRange(GetAllIDs(rs)); } } return(IDlist); }
public void TestGetAllIDs_IReaction() { Reaction reaction = new Reaction() { Id = "r1" }; IAtomContainer water = new AtomContainer { Id = "m1" }; Atom oxygen = new Atom("O") { Id = "a1" }; water.Atoms.Add(oxygen); reaction.Reactants.Add(water); reaction.Products.Add(water); var ids = ReactionManipulator.GetAllIDs(reaction); Assert.IsNotNull(ids); Assert.AreEqual(5, ids.Count()); }