Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Model units create complicated SBML #37

Open
luciansmith opened this issue Feb 17, 2016 · 0 comments
Open

Model units create complicated SBML #37

luciansmith opened this issue Feb 17, 2016 · 0 comments

Comments

@luciansmith
Copy link
Contributor

Hi Lucian,

The create SBML when setting model units is overly complicated. If the substanceUnits, timeUnits, ... are one of the base units or defined units these should just be used in the model element instead of creating a new unitDefinition.

These unit definitions

import tellurium as te
r = te.loada('''
    // Units
    m2 = meter^2;
    m3 = meter^3;
    
    // base units
    substance = mole;
    volume = m2;
    area = m3;
    length = metre;
    extent = mole;
    time_unit = second;
''')
print(r.getSBML())

should create the following SBML

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by libAntimony version v2.8.1 on 2016-02-17 12:19 with libSBML version 5.12.1. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
  <model id="__main" name="__main" substanceUnits="mole" timeUnits="second" volumeUnits="m3" areaUnits="m2" lengthUnits="metre" extentUnits="mole">
    <listOfUnitDefinitions>
      <unitDefinition id="m2">
        <listOfUnits>
          <unit kind="metre" exponent="2" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
      <unitDefinition id="m3">
        <listOfUnits>
          <unit kind="metre" exponent="3" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
    </listOfUnitDefinitions>
  </model>

But currently result in the much more complicated and unreadable

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created by libAntimony version v2.8.1 on 2016-02-17 12:19 with libSBML version 5.12.1. -->
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
  <model id="__main" name="__main" substanceUnits="substance" timeUnits="time_unit" volumeUnits="volume" areaUnits="area" lengthUnits="length" extentUnits="extent">
    <listOfUnitDefinitions>
      <unitDefinition id="m2">
        <listOfUnits>
          <unit kind="metre" exponent="2" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
      <unitDefinition id="m3">
        <listOfUnits>
          <unit kind="metre" exponent="3" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
      <unitDefinition id="substance">
        <listOfUnits>
          <unit kind="mole" exponent="1" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
      <unitDefinition id="volume">
        <listOfUnits>
          <unit kind="metre" exponent="2" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
      <unitDefinition id="area">
        <listOfUnits>
          <unit kind="metre" exponent="3" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
      <unitDefinition id="length">
        <listOfUnits>
          <unit kind="metre" exponent="1" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
      <unitDefinition id="extent">
        <listOfUnits>
          <unit kind="mole" exponent="1" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
      <unitDefinition id="time_unit">
        <listOfUnits>
          <unit kind="second" exponent="1" scale="0" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
    </listOfUnitDefinitions>
  </model>

Only define the substance, volume, ... units if they are not defined in the model or are no base units.

The best
Matthias

Reported by: matthiaskoenig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant