public void TestContainsByID_IAtomContainerSet_IAtomContainer() { var relevantAtomContainer = builder.NewAtomContainer(); var atomContainerSet = builder.NewAtomContainerSet(); atomContainerSet.Add(relevantAtomContainer); Assert.IsFalse(AtomContainerSetManipulator.ContainsByID(atomContainerSet, relevantAtomContainer.Id)); relevantAtomContainer.Id = "1"; Assert.IsTrue(AtomContainerSetManipulator.ContainsByID(atomContainerSet, relevantAtomContainer.Id)); }
/// <summary> /// Gets a reaction from a ReactionSet by ID of any product or reactant. If several exist, /// only the first one will be returned. /// </summary> /// <param name="reactionSet">The reactionSet to search in</param> /// <param name="id">The id to search for.</param> /// <returns>The Reaction or null;</returns> public static IReaction GetReactionByAtomContainerID(IReactionSet reactionSet, string id) { foreach (var reaction in reactionSet) { if (AtomContainerSetManipulator.ContainsByID(reaction.Products, id)) { return(reaction); } } foreach (var reaction in reactionSet) { if (AtomContainerSetManipulator.ContainsByID(reaction.Reactants, id)) { return(reaction); } } return(null); }