| MathSBML Home Page | MathSBML Site Map |
addRule[options] adds a rule to the current model. Options are the same as ruleToSBML. In addition, if the id option is not specified, a metaid is automatically assigned to the rule; otherwise, the value of the id field is used for the metaid. The following restrictions are enforced by addRule:
modifyRule[id, options] modifies a rule in the current model. The argument id refers to the metaid field of the rule. (Note that both addRule and SBMLRead automatically assign a metaid to a rule if it is not already specified, so every rule in the model builder is guaranteed to already have a metaid already assigned to it.) When a rule is modified its order relative to other rules in the model is retained, e.g., if a rule is the 7th of 13 rules before invoking modifyRule it will still be the 7th of 13 rules afterwards.
removeRule[i] removes the ith rule from the current model.
addRule, removeRule, modifyRule new in 2.2, 2.6input: newModel["ruler", name -> "example with rules"]; addSpecies[x, compartment -> "c1"]; addSpecies[y, compartment -> "c1"]; addSpecies[z, compartment -> "c1"]; output: Compartment c1 added. Species x added to compartment c1 Species y added to compartment c1 species z added to compartment c1 input: addRule[type -> assignmentRule, variable -> x, math -> z^2 + Sqrt[z]]; output: Rule rule1 added. input: addRule[type -> "rateRule", variable -> y, math -> x*y]; output: Error: rule2 refers to y on both sides of the equation and is not permitted. input: addRule[type -> "rateRule", variable -> y, math -> x*z]; output: Error: A rule with z on its right hand side has been previously defined and therefore this rule can not be added. input: addRule[type -> "rateRule", variable -> y, math -> x*z] output: Rule rule4 added. input: addRule[type -> "algebraicRule", math -> x + y + z] output: Rule rule5 added. input: createModel[] output: <?xml version="1.0" encoding="UTF-8"?> <!-- Generated 30-September-2003 13:42:00.160781 --> <!-- Generated by MathSBML 2.1.5b15 (30 Sept 2003) --> <sbml xmlns="http://www.sbml.org/sbml/level2" level="2" version="1"> <model id="ruler" name="example with rules"> <listOfFunctionDefinitions/> <listOfUnitDefinitions/> <listOfCompartments> <compartment id="c1" name="c1"/> </listOfCompartments> <listOfSpecies> <species id="x" name="x" compartment="c1" boundaryCondition="false" constant="false"/> <species id="y" name="y" compartment="c1" boundaryCondition="false" constant="false"/> <species id="z" name="z" compartment="c1" boundaryCondition="false" constant="false"/> </listOfSpecies> <listOfParameters/> <listOfRules> <assignmentRule variable="x" metaid="rule1"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <plus/> <apply> <power/> <ci>z</ci> <cn type="integer">2</cn> </apply> <apply> <power/> <ci>z</ci> <cn type="rational">1<sep/>2</cn> </apply> </apply> </math> </assignmentRule> <rateRule variable="y" metaid="rule4"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <times/> <ci>x</ci> <ci>z</ci> </apply> </math> </rateRule> <algebraicRule metaid="rule5"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <plus/> <ci>x</ci> <ci>y</ci> <ci>z</ci> </apply> </math> </algebraicRule> </listOfRules> <listOfReactions/> <listOfEvents/> </model> </sbml> input: modifyRule[rule5, math -> Sqrt[x^2 + y^2 + z^2]] output: Rule rule5 modified. input: createModel[] output: <?xml version="1.0" encoding="UTF-8"?> <!-- Generated 30-September-2003 13:46:34.924475 --> <!-- Generated by MathSBML 2.1.5b15 (30 Sept 2003) --> <sbml xmlns="http://www.sbml.org/sbml/level2" level="2" version="1"> <model id="ruler" name="example with rules"> <listOfFunctionDefinitions/> <listOfUnitDefinitions/> <listOfCompartments> <compartment id="c1" name="c1"/> </listOfCompartments> <listOfSpecies> <species id="x" name="x" compartment="c1" boundaryCondition="false" constant="false"/> <species id="y" name="y" compartment="c1" boundaryCondition="false" constant="false"/> <species id="z" name="z" compartment="c1" boundaryCondition="false" constant="false"/> </listOfSpecies> <listOfParameters/> <listOfRules> <assignmentRule variable="x" metaid="rule1"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <plus/> <apply> <power/> <ci>z</ci> <cn type="integer">2</cn> </apply> <apply> <power/> <ci>z</ci> <cn type="rational">1<sep/>2</cn> </apply> </apply> </math> </assignmentRule> <rateRule variable="y" metaid="rule4"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <times/> <ci>x</ci> <ci>z</ci> </apply> </math> </rateRule> <algebraicRule metaid="rule5"> <math xmlns="http://www.w3.org/1998/Math/MathML"> <apply> <power/> <apply> <plus/> <apply> <power/> <ci>x</ci> <cn type="integer">2</cn> </apply> <apply> <power/> <ci>y</ci> <cn type="integer">2</cn> </apply> <apply> <power/> <ci>z</ci> <cn type="integer">2</cn> </apply> </apply> <cn type="rational">1<sep/>2</cn> </apply> </math> </algebraicRule> </listOfRules> <listOfReactions/> <listOfEvents/> </model> </sbml>