MathSBML

MathSBML Home Page MathSBML Site Map

MathSBML Model Builder: unitToSBML


unitToSBML[options] returns an SBML <unitDefinition .../>

unitToSBML[{{options},{options},...}] returns a <listOfUnitDefinitions .../> where each option list corresponds to the options for single unitDefinition.

unitToSymbolicSBML[arguments] returns Symbolic XML for a <unitDefinition .../>.

New in version 2.1.5.; revised 2.4.13

Options

Option Default Description
id generated* Value of SBML id. *If not specified, an id of the form unitn, where n is an integer, is generated.
name Uses id* Value of SBML name. *If not specified, the value of the id is used.
unit No default. Options list of the form {kind_string->{options},kind_string->{options},...}, where options are as described in table below, and each kind_string is one ofthe allowed unit kinds listed in tables 2 (unitKind units) or 3 (build in units) of the spec. Defines <unit ... />

Options within units

Option Default Description
exponent 1 unit exponent, ignored unless different from 1.
scale 0 unit scale, ignored unless different from 0.
multiplier 1 unit multiplier, ignored unless different from 1.
offset 0 unit offset, ignored unless different from 0.
The following formula is used:
unit = [ multiplier × 10scale × kind ]exponent + offset
Note that on earlier versions the exponent was only applied to kind because of an error in the spec.

Example 1: Single unit definition:

unitToSBML[
   id->"mmlh",
   name->"millimoles_per_liter_per_hour",
   unit-> {"mole"-> {scale-> -3}, 
           "litre"-> {exponent-> -1}, 
           "second"-> {multiplier->3600, exponent-> -1}}]

which means:

mmlh = (10-3 mole )×(litre-1)×( (3600 second)-1)

returns the string
<unitDefinition id="mmlh"
    name="millimoles_per_liter_per_hour">
 <listOfUnits>
  <unit kind="mole"
      scale="-3"/>
  <unit kind="litre"
      exponent="-1"/>
  <unit kind="second"
      exponent="-1"
      multiplier="3600"/>
 </listOfUnits>
</unitDefinition>

Example 2: list of unit definitions:

The input string:
unitToSBML[
  { {id->"mmlh",name->"millimoles_per_liter_per_hour",
     unit->{"mole"->{scale->-3},
            "litre"->{exponent->->1},
            "second"->{multiplier->3600,exponent->-1}}
     },
     {id->"fred",
      unit->{"ampere"->{exponent->-1},
             "ohm"->{scale->4}}
     }
   }]
returns

<listOfUnitDefinitions>
 <unitDefinition id="mmlh"
     name="millimoles_per_liter_per_hour">
  <listOfUnits>
   <unit kind="mole"
       scale="-3"/>
   <unit kind="litre"
       exponent="-1"/>
   <unit kind="second"
       exponent="-1"
       multiplier="3600"/>
  </listOfUnits>
 </unitDefinition>
 <unitDefinition id="fred"
     name="fred">
  <listOfUnits>
   <unit kind="ampere"
       exponent="-1"/>
   <unit kind="ohm"
       scale="4"/>
  </listOfUnits>
 </unitDefinition>
</listOfUnitDefinitions>"
Go to the top of this page