Main Content

updateDuplicateNames

Disambiguate duplicate component names in SimBiology model

Since R2022b

Description

example

updateDuplicateNames(model) renames components with same names in a SimBiology model. Use this function to disambiguate duplicate model component names in your model if any. In a future release, within a single model, model components will be required to have unique names even when they are of different types with the following two exceptions:

  • Species in different compartments can have the same name.

  • Parameters can have the same name if they are scoped to different parents. Specifically, you can use the same name for a model-scoped parameter and reaction-scoped parameters, where each reaction-scoped parameter belongs to a different reaction.

For details, see Guidelines for Naming Model Components.

example

[isUpdated,changes,modelBackup] = updateDuplicateNames(model) returns additional information about the changes made to the model, including the logical flag isUpdated that indicates whether any updates were made to the model, a list of changes, and a backup copy modelBackup of your model without any changes made.

Examples

collapse all

Suppose that you have a species and parameter with the same name as the model.

model = sbiomodel('m1');
compartment = addcompartment(model,'comp');
s1 = addspecies(compartment,'x');
p1 = addparameter(model,'x');
Warning: Model 'm1' contains components with the following duplicated names: x. <a href="matlab: helpview('simbio', 'naming_restriction_simbiology')">Click here</a> to learn about future naming restrictions and how to update your model.

To avoid the warning, use updateDuplicatNames to automatically disambiguate the duplicate names.

[isUpdated, changes, modelBackup] = updateDuplicateNames(model);

Open the Comparison Tool to see the name changes. In this example, the function updated the parameter name from x to x_1.

visdiff(changes);

In a future release, within a single model, model components will be required to have unique names even when they are of different types with the following two exceptions:

  • Species in different compartments can have the same name.

  • Parameters can have the same name if they are scoped to different parents. Specifically, you can use the same name for a model-scoped parameter and reaction-scoped parameters, where each reaction-scoped parameter belongs to a different reaction.

To illustrate the first exception, add another species named x to a different compartment.

compartment2 = addcompartment(model,'comp2');
s2 = addspecies(compartment2,'x');

Note that no warning is issued for two species (s1 and s2) with the same name because they belong to different compartments.

To give an example of the second exception, add two reaction-scoped parameters with the same name param to two different reactions r1 and r2.

r1 = addreaction(model,'comp.x -> comp.y');
kl1 = addkineticlaw(r1,'MassAction');
p2 = addparameter(kl1,'param');
kl1.ParameterVariableNames = 'param';

r2 = addreaction(model,'comp2.x -> comp2.y');
kl2 = addkineticlaw(r2,'MassAction');
p3 = addparameter(kl2,'param');
kl2.ParameterVariableNames = 'param';

Note that no warning is issued for two parameters (p2 and p3) with the same name because they are scoped to different reactions.

Input Arguments

collapse all

Input model, specified as a scalar SimBiology Model object.

Output Arguments

collapse all

Flag indicating whether model was updated by the function, returned as a logical 1 (true) or 0 (false).

List of changes made to the model, returned as a SimBiology.DiffResults object. Use the visdiff function to inspect the changes in the Comparison Tool.

Copy of the input model before changes were made to it by the function, returned as a scalar SimBiology Model object.

Version History

Introduced in R2022b