sbmlteam / libsbml

LibSBML is a native library for reading, writing and manipulating files and data streams containing the Systems Biology Markup Language (SBML). It offers language bindings for C, C++, C#, Java, JavaScript, MATLAB, Perl, PHP, Python, R and Ruby.

Home Page:https://sbml.org/software/libsbml

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unit validation is giving incorrect warnings

fbergmann opened this issue · comments

The attached model model gives a validation warning because of an issue with the time unit:

Warning Line 155 Column 20: (SBML Validation Rule #10541) The units of the 'math' formula in a definition are expected to be the equivalent of substance per time. Reference: L2V4 Section 4.13.5 Expected units are mole (exponent = 1, multiplier = 1, scale = -9), second (exponent = -1, multiplier = 1, scale = -3) but the units returned by the expression in the (from the with id 'R1') are second (exponent = -1, multiplier = 0.0001, scale = 0), mole (exponent = 1, multiplier = 1, scale = -9).

Somehow the multiplier is used instead of the scale.

actually the reason why it gives the error is that the units are wrong:

`

       <minus/>

            <apply>

              <times/>

              <ci> kf_R1 </ci>  <!--one_over_nM_ms-->

              <ci> gaba </ci>   <!--substance-->

              <ci> GABABR </ci> <!--substance-->

            </apply>

            <apply>

              <times/>

              <ci> kr_R1 </ci>      <!--one_over_nM_ms-->

              <ci> gabaGABABR </ci> <!--substance-->

            </apply>

          </apply>

`

is trying to subtract a unit that is time x substance from a unit that is time x substance x substance

@skeating for me kr_R1 has the unit one_over_ms, so it is different. Since we have

      <unitDefinition id="one_over_ms">
        <listOfUnits>
          <unit kind="dimensionless" exponent="1" scale="0" multiplier="1"/>
          <unit kind="second" exponent="-1" scale="-3" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>
      <unitDefinition id="one_over_nM_ms">
        <listOfUnits>
          <unit kind="dimensionless" exponent="1" scale="0" multiplier="1"/>
          <unit kind="mole" exponent="-1" scale="-9" multiplier="1"/>
          <unit kind="litre" exponent="1" scale="1" multiplier="1"/>
          <unit kind="second" exponent="-1" scale="-3" multiplier="1"/>
        </listOfUnits>
      </unitDefinition>

regardless, does this explain the issue for you?

you still cannot subtract something with units AB from something with units ABB

Stefan found the issue. since volume and liter are defined with a scale=0, then the litre component in the one_over_nM_ms unit should also have a scale=0. If that is corrected, then the validator does not complain anymore either.

yes it was trying to subtract two different units!!