public void testRenaming() { MuCell.Model.SBML.Model model = new MuCell.Model.SBML.Model(); MuCell.Model.SBML.Species species1 = new MuCell.Model.SBML.Species(); MuCell.Model.SBML.Species species2 = new MuCell.Model.SBML.Species(); model.listOfSpecies = new List<MuCell.Model.SBML.Species>(); model.listOfSpecies.Add(species1); model.listOfSpecies.Add(species2); // Set some values for species1 species1.ID = "species1"; species1.InitialAmount = 4.0d; species1.InitialConcentration = 7.0d; species1.xPosition = 2.0f; // Set some values for species2 that has the same id and same values species2.ID = "species2"; species2.InitialAmount = 4.0d; species2.InitialConcentration = 7.0d; species2.xPosition = 2.0f; // Add to the model model.AddId(species1.ID, species1); model.AddId(species2.ID, species2); // Rename species1.ID = "new_species1"; // Check the id in the species object Assert.AreEqual("new_species1", species1.ID); Assert.AreEqual("species1", species1.getOldID()); model.updateID(species1); // Check the ids in the model Assert.IsTrue(model.idExists("new_species1")); Assert.IsTrue(model.idExists("species2")); Assert.IsFalse(model.idExists("species1")); }
public void testInterrogateModelForIDs() { MuCell.Model.SBML.Model model = new MuCell.Model.SBML.Model(); model.listOfReactions = new List<MuCell.Model.SBML.Reaction>(); model.listOfSpecies = new List<MuCell.Model.SBML.Species>(); MuCell.Model.SBML.Species species1 = new MuCell.Model.SBML.Species(); MuCell.Model.SBML.Species species2 = new MuCell.Model.SBML.Species(); MuCell.Model.SBML.Species species3 = new MuCell.Model.SBML.Species(); species1.ID = "species1"; species2.ID = "species2"; species3.ID = "species 3"; model.AddId("species1", species1); MuCell.Model.SBML.Reaction r1 = new MuCell.Model.SBML.Reaction(); MuCell.Model.SBML.SpeciesReference sp1r = new MuCell.Model.SBML.SpeciesReference(); sp1r.species = species1; MuCell.Model.SBML.SpeciesReference sp2r = new MuCell.Model.SBML.SpeciesReference(); sp2r.species = species2; MuCell.Model.SBML.SpeciesReference sp3r = new MuCell.Model.SBML.SpeciesReference(); sp3r.species = species3; r1.Reactants.Add(sp1r); r1.Reactants.Add(sp2r); r1.Products.Add(sp3r); MuCell.Model.SBML.KineticLaw kl = new MuCell.Model.SBML.KineticLaw(model); r1.KineticLaw = kl; MuCell.Model.SBML.Parameter k1 = new MuCell.Model.SBML.Parameter(); k1.ID = "k1"; r1.Parameters.Add(k1); r1.Formula = "species1*species_3*k1"; model.listOfSpecies.Add(species1); model.listOfReactions.Add(r1); // Assert the unknown entities Assert.AreEqual(2, r1.KineticLaw.UnknownEntitiesFromFormula().Count); Assert.AreEqual("species_3", r1.KineticLaw.UnknownEntitiesFromFormula().ToArray()[0].ID); Assert.AreEqual("k1", r1.KineticLaw.UnknownEntitiesFromFormula().ToArray()[1].ID); // Assert missing items in model Assert.IsTrue(model.idExists("species1")); Assert.IsFalse(model.idExists("species2")); Assert.IsFalse(model.idExists("species 3")); Assert.IsFalse(model.idExists("k1")); model.InterrogateModelForMissingIDs(); // redo formula r1.Formula = "species1*species_3*k1"; // assert no unknown entities Assert.AreEqual(0, r1.KineticLaw.UnknownEntitiesFromFormula().Count); // Assert everything is in the model Assert.IsTrue(model.idExists("species1")); Assert.IsTrue(model.idExists("species2")); Assert.IsTrue(model.idExists("species 3")); Assert.IsTrue(model.idExists("k1")); }