sys-bio/simplesbml

Unit warning when using default compartment

Closed this issue · 2 comments

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:

  • Are these warnings actually a problem?
  • If not can I specifically suppress them?
  • Or is there an approach to prevent them from happening altogether? I.E. not defining a compartment is something I could think of.
    What also works is the following:
m.getCompartment('c1').setUnits('dimensionless')

But I am not sure whether I am "allowed" to do that or if it could hurt my model.

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.

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.