コード例 #1
0
        public static IEnumerable <string> GetAllIDs(IChemModel chemModel)
        {
            if (chemModel.Id != null)
            {
                yield return(chemModel.Id);
            }
            var crystal = chemModel.Crystal;

            if (crystal != null)
            {
                foreach (var e in AtomContainerManipulator.GetAllIDs(crystal))
                {
                    yield return(e);
                }
            }
            var moleculeSet = chemModel.MoleculeSet;

            if (moleculeSet != null)
            {
                foreach (var e in MoleculeSetManipulator.GetAllIDs(moleculeSet))
                {
                    yield return(e);
                }
            }
            var reactionSet = chemModel.ReactionSet;

            if (reactionSet != null)
            {
                foreach (var e in ReactionSetManipulator.GetAllIDs(reactionSet))
                {
                    yield return(e);
                }
            }
            yield break;
        }
コード例 #2
0
        public void TestGetAllIDs_IReactionSet()
        {
            IReactionSet set       = builder.NewReactionSet();
            IReaction    reaction1 = builder.NewReaction();

            set.Add(reaction1);
            reaction1.Id = "r1";
            IAtomContainer water = new AtomContainer {
                Id = "m1"
            };
            Atom oxygen = new Atom("O")
            {
                Id = "a1"
            };

            water.Atoms.Add(oxygen);
            reaction1.Reactants.Add(water);
            reaction1.Products.Add(water);
            IReaction reaction2 = builder.NewReaction();

            reaction2.Id = "r2";
            set.Add(reaction2);

            var ids = ReactionSetManipulator.GetAllIDs(set);

            Assert.IsNotNull(ids);
            Assert.AreEqual(6, ids.Count());
        }