Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LCSB-BioCore
SBML.jl
Commits
86df302a
Commit
86df302a
authored
Mar 14, 2021
by
St. Elmo
Committed by
Miroslav Kratochvil
Mar 14, 2021
Browse files
support reading FBC flux bounds
Co-authored-by:
Mirek Kratochvil
<
miroslav.kratochvil@uni.lu
>
parent
d1a2ab50
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/readsbml.jl
View file @
86df302a
...
...
@@ -32,6 +32,14 @@ function readSBML(fn::String)::Model
end
function
extractModel
(
mdl
::
VPtr
)
::
Model
parameters
=
Dict
{
String
,
Float64
}()
for
i
=
1
:
ccall
(
sbml
(
:
Model_getNumParameters
),
Cuint
,
(
VPtr
,),
mdl
)
p
=
ccall
(
sbml
(
:
Model_getParameter
),
VPtr
,
(
VPtr
,
Cuint
),
mdl
,
i
-
1
)
id
=
unsafe_string
(
ccall
(
sbml
(
:
Parameter_getId
),
Cstring
,
(
VPtr
,),
p
))
v
=
ccall
(
sbml
(
:
Parameter_getValue
),
Cdouble
,
(
VPtr
,),
p
)
parameters
[
id
]
=
v
end
units
=
Dict
{
String
,
Vector
{
UnitPart
}}()
for
i
=
1
:
ccall
(
sbml
(
:
Model_getNumUnitDefinitions
),
Cuint
,
(
VPtr
,),
mdl
)
ud
=
ccall
(
sbml
(
:
Model_getUnitDefinition
),
VPtr
,
(
VPtr
,
Cuint
),
mdl
,
i
-
1
)
...
...
@@ -103,6 +111,26 @@ function extractModel(mdl::VPtr)::Model
end
end
# TRICKY: SBML spec is completely silent about the situation when
# someone specifies both the above and below formats of the flux bounds
# for one reaction. Notably, these do not really specify much
# interaction with units. In this case, we'll just set a special
# "[fbc]" unit that has no specification in `units`, and hope the users
# can make something out of it.
re_fbc
=
ccall
(
sbml
(
:
SBase_getPlugin
),
VPtr
,
(
VPtr
,
Cstring
),
re
,
"fbc"
)
if
re_fbc
!=
C_NULL
fbcb
=
ccall
(
sbml
(
:
FbcReactionPlugin_getLowerFluxBound
),
Cstring
,
(
VPtr
,),
re_fbc
)
if
fbcb
!=
C_NULL
&&
haskey
(
parameters
,
unsafe_string
(
fbcb
))
lb
=
(
parameters
[
unsafe_string
(
fbcb
)],
"[fbc]"
)
end
fbcb
=
ccall
(
sbml
(
:
FbcReactionPlugin_getUpperFluxBound
),
Cstring
,
(
VPtr
,),
re_fbc
)
if
fbcb
!=
C_NULL
&&
haskey
(
parameters
,
unsafe_string
(
fbcb
))
ub
=
(
parameters
[
unsafe_string
(
fbcb
)],
"[fbc]"
)
end
end
stoi
=
Dict
{
String
,
Float64
}()
add_stoi
=
(
sr
,
factor
)
->
...
...
@@ -126,5 +154,5 @@ function extractModel(mdl::VPtr)::Model
Reaction
(
stoi
,
lb
,
ub
,
oc
)
end
return
Model
(
units
,
compartments
,
species
,
reactions
)
return
Model
(
parameters
,
units
,
compartments
,
species
,
reactions
)
end
src/structs.jl
View file @
86df302a
...
...
@@ -50,9 +50,10 @@ Structure that collects the model-related data. Contains `units`,
indexed by identifiers of the corresponding objects.
"""
struct
Model
params
::
Dict
{
String
,
Float64
}
units
::
Dict
{
String
,
Vector
{
UnitPart
}}
compartments
::
Vector
{
String
}
species
::
Dict
{
String
,
Species
}
reactions
::
Dict
{
String
,
Reaction
}
Model
(
u
,
c
,
s
,
r
)
=
new
(
u
,
c
,
s
,
r
)
Model
(
p
,
u
,
c
,
s
,
r
)
=
new
(
p
,
u
,
c
,
s
,
r
)
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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