Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LCSB-BioCore
SBML.jl
Commits
c2a182e9
Unverified
Commit
c2a182e9
authored
Aug 09, 2021
by
Miroslav Kratochvil
🚴
Committed by
GitHub
Aug 09, 2021
Browse files
Merge pull request #145 from giordano/mg/fix-units
Fix definition of units
parents
8f87883a
04b8ef81
Changes
2
Show whitespace changes
Inline
Side-by-side
src/utils.jl
View file @
c2a182e9
...
@@ -239,17 +239,22 @@ const UNIT_KIND_STRINGS_TO_UNIT = Dict(
...
@@ -239,17 +239,22 @@ const UNIT_KIND_STRINGS_TO_UNIT = Dict(
)
)
# Get a `Unitful` quantity out of a `Unit_t`.
# Get a `Unitful` quantity out of a `Unit_t`.
get_unit
(
u
::
VPtr
)
=
function
get_unit
(
u
::
VPtr
)
UNIT_KIND_STRINGS_TO_UNIT
[
unsafe_string
(
multiplier
=
ccall
(
sbml
(
:
Unit_getMultiplier
),
Cdouble
,
(
VPtr
,),
u
)
unit
=
UNIT_KIND_STRINGS_TO_UNIT
[
unsafe_string
(
ccall
(
ccall
(
sbml
(
:
UnitKind_toString
),
sbml
(
:
UnitKind_toString
),
Cstring
,
Cstring
,
(
Cint
,),
(
Cint
,),
ccall
(
sbml
(
:
Unit_getKind
),
Cint
,
(
VPtr
,),
u
),
ccall
(
sbml
(
:
Unit_getKind
),
Cint
,
(
VPtr
,),
u
),
),
),
)]
^
ccall
(
sbml
(
:
Unit_getExponent
),
Cint
,
(
VPtr
,),
u
)
*
)]
exp10
(
ccall
(
sbml
(
:
Unit_getScale
),
Cint
,
(
VPtr
,),
u
))
*
scale
=
ccall
(
sbml
(
:
Unit_getScale
),
Cint
,
(
VPtr
,),
u
)
ccall
(
sbml
(
:
Unit_getMultiplier
),
Cdouble
,
(
VPtr
,),
u
)
exponent
=
ccall
(
sbml
(
:
Unit_getExponent
),
Cint
,
(
VPtr
,),
u
)
# See page 44 of
# http://sbml.org/Special/specifications/sbml-level-3/version-2/core/release-2/sbml-level-3-version-2-release-2-core.pdf
return
(
multiplier
*
unit
*
exp10
(
scale
))
^
exponent
end
# Get `Unitful` quantity out of a `UnitDefinition_t`.
# Get `Unitful` quantity out of a `UnitDefinition_t`.
get_units
(
ud
::
VPtr
)
=
prod
(
get_units
(
ud
::
VPtr
)
=
prod
(
...
...
test/ecoli_flux.jl
View file @
c2a182e9
...
@@ -22,7 +22,7 @@ end
...
@@ -22,7 +22,7 @@ end
sbmlfile
*
".does.not.really.exist"
,
sbmlfile
*
".does.not.really.exist"
,
)
)
@test
mdl
.
units
[
"mmol_per_gDW_per_hr"
]
==
2.7777e-7
*
u
"mol * g^-1 * s^-1"
@test
mdl
.
units
[
"mmol_per_gDW_per_hr"
]
≈
3.6001008028224795
*
u
"mol * g^-1 * s^-1"
@test
length
(
mdl
.
compartments
)
==
2
@test
length
(
mdl
.
compartments
)
==
2
...
...
cylon-x
🤖
@cylon-x
mentioned in commit
e39ef83b
·
Aug 09, 2021
mentioned in commit
e39ef83b
mentioned in commit e39ef83bc63c21c71e42130f2c8daa2b7f436dc8
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment