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
6b710965
Commit
6b710965
authored
Jun 22, 2021
by
Miroslav Kratochvil
🚴
Browse files
fun accessors for initial amounts and concentrations
parent
a4ed3eae
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/utils.jl
View file @
6b710965
...
...
@@ -52,3 +52,75 @@ Extract the vector of objective coefficients of each reaction.
function
getOCs
(
m
::
SBML
.
Model
)
::
Vector
{
Float64
}
return
broadcast
(
x
->
x
.
oc
,
values
(
m
.
reactions
))
end
"""
initial_amounts(m::SBML.Model; convert_concentrations = false)
Return a vector of initial amounts for each species, or `nothing` if the
information is not available. If `convert_concentrations` is true and there is
information about initial concentration available together with compartment
size, the result is computed from the species' initial concentration.
In the current version, units of the measurements are completely ignored.
"""
function
initial_amounts
(
m
::
SBML
.
Model
;
convert_concentrations
=
false
,
)
::
Vector
{
Union
{
Float64
,
Nothing
}}
function
get_ia
(
x
::
Species
)
if
!
isnothing
(
x
.
initial_amount
)
x
.
initial_amount
[
1
]
elseif
!
isnothing
(
x
.
initial_concentration
)
&&
haskey
(
m
.
compartments
,
x
.
compartment
)
&&
!
isnothing
(
m
.
compartments
[
x
.
compartment
]
.
size
)
x
.
initial_concentration
[
1
]
*
m
.
compartments
[
x
.
compartment
]
.
size
else
nothing
end
end
if
convert_concentrations
get_ia
.
(
values
(
m
.
species
))
else
return
broadcast
(
x
->
isnothing
(
x
.
initial_amount
)
?
nothing
:
x
.
initial_amount
[
1
],
values
(
m
.
species
),
)
end
end
"""
initial_concentrations(m::SBML.Model; convert_amounts = false)
Return a vector of initial concentrations for each species, or `nothing` if
the information is not available. If `convert_amounts` is true and there is
information about initial amount available together with compartment size, the
result is computed from the species' initial amount.
In the current version, units of the measurements are completely ignored.
"""
function
initial_concentrations
(
m
::
SBML
.
Model
;
convert_amounts
=
false
,
)
::
Vector
{
Union
{
Float64
,
Nothing
}}
function
get_ic
(
x
::
Species
)
if
!
isnothing
(
x
.
initial_concentration
)
x
.
initial_concentration
[
1
]
elseif
!
isnothing
(
x
.
initial_amount
)
&&
haskey
(
m
.
compartments
,
x
.
compartment
)
&&
!
isnothing
(
m
.
compartments
[
x
.
compartment
]
.
size
)
x
.
initial_amount
[
1
]
/
m
.
compartments
[
x
.
compartment
]
.
size
else
nothing
end
end
if
convert_amounts
get_ic
.
(
values
(
m
.
species
))
else
broadcast
(
x
->
isnothing
(
x
.
initial_concentration
)
?
nothing
:
x
.
initial_concentration
[
1
],
values
(
m
.
species
),
)
end
end
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