Main Content

move

Move SimBiology species or parameter object to new parent

Since R2020b

Description

example

spObj = move(spObj,parentObj) moves a SimBiology® species or parameter object spObj to a new parent SimBiology object parentObj. The function automatically updates the corresponding expressions, observables, variants, and parameterized dose properties that reference spObj. Expressions include reactions, kinetic laws, rules, and events.

example

spObj = move(spObj,parentObj,conflictOption) specifies how to handle naming conflicts if parentObj is already the parent of another object with the same name as spObj.

Examples

collapse all

Create a model with two compartments.

m = sbiomodel('cell');
c1 = addcompartment(m,'c1');
c2 = addcompartment(m,'c2');
B_c1 = addspecies(c1,'B');
B_c2 = addspecies(c2,'B');
p = addparameter(m,'k1',5);
r = addreaction(m,'c1.A + c1.B -> c2.B');
k = addkineticlaw(r,'MassAction');
k.ParameterVariableNames = 'k1';

The parameter is scoped to the model, which is the parent.

p.Parent
ans = 
   SimBiology Model - cell 

   Model Components:
     Compartments:      2
     Events:            0
     Parameters:        1
     Reactions:         1
     Rules:             0
     Species:           3
     Observables:       0

Move the model-scoped parameter to the kinetic law.

p = move(p,k);

The parent is now the kinetic law object instead of the model object.

p.Parent
ans = 
   SimBiology Kinetic Law Array

   Index:    KineticLawName:
   1         MassAction     

Move species B from compartment c1 to c2. c2 already has another species with the same name, so use the 'force' option to resolve the naming conflict. The move function renames B to B_1.

B = move(B_c1,c2,'force')
B = 
   SimBiology Species Array

   Index:    Compartment:    Name:    Value:    Units:
   1         c2              B_1      0               

Input Arguments

collapse all

SimBiology species or parameter, specified as a species object or parameter object.

If spObj is a:

  • Parameter object, parentObj must be a model, reaction, or kinetic law object.

  • Species object, parentObj must be a compartment object.

If you move a parameter to a reaction, the reaction kinetic law is the new parent of the parameter. The function creates an unknown kinetic law if the reaction does not already have a kinetic law.

Parent object, specified as a model object, reaction object, kinetic law object, or compartment object.

Method to resolve naming conflicts, specified as a character vector or string. Valid options are:

  • 'strict' — The function throws an error if parentObj is already the parent of another object with the same name as spObj.

  • 'force' — The function changes the name of spObj by appending '_N', where N is the smallest number such that the new name of spObj is unique among all objects parented to parentObj.

Version History

Introduced in R2020b