sys-bio / simplesbml

Python package for building SBML models without needing to use libSBML.
http://simplesbml.readthedocs.io/en/latest/
MIT License
10 stars 12 forks source link

Unit warning when using default compartment #29

Closed kaisengit closed 3 years ago

kaisengit commented 4 years ago

Hello,

I am using simplesbml to create a rather large reaction network (hundreds of species and reactions). In principle this works fine. However I always get warnings about unexpected units for my reactions. Here is a minimum example to reproduce:

import simplesbml
m = simplesbml.sbmlModel()
m.addSpecies('S1', 1)
m.addSpecies('S2', 0)
m.addParameter('k', 0.1)
m.addReaction(['S1'], ['S2'], 'k * S1')
sbml = m.toSBML()

This would be some simple reaction in the form: S1 -> S2 with rate constant k The snippet will lead to the following warning:

Warning : The units of the 'math' formula in a definition are expected to be the equivalent of substance per time. Reference: L3V1 Sections 4.11.7, 4.2.4 AND 4.9.4 In level 3 the expected units are extent_per_time. Expected units are mole (exponent = 1, multiplier = 1, scale = 0), second (exponent = -1, multiplier = 1, scale = 0) but the units returned by the expression in the (from the with id 'v1') are second (exponent = -1, multiplier = 1, scale = 0), mole (exponent = 1, multiplier = 1, scale = 0), litre (exponent = -1, multiplier = 1, scale = 0).

This seems to happen to happen because SBML expects the overall unit to be mole/sec but the model has mole/(sec*litre). The litre now actually comes from the default compartment. These warnings are very annoying for me because they appear hundreds of times and will bury any possible useful warnings.

Now I have a few questions:

hsauro commented 3 years ago

The units are not a problem so long as you are consistent in your own mind. I'll see if we can suppress the warnings.

hsauro commented 3 years ago

I just checked the latest version (2.1.0) and it seems that it now ignores the unit error messages. If you have any other issues let me know.