Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
COBREXA.jl
Manage
Activity
Members
Plan
External wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LCSB-BioCore
COBREXA.jl
Commits
b2953ef6
Commit
b2953ef6
authored
3 years ago
by
Laurent Heirendt
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #46 from LCSB-BioCore/mk-fix-nice-fba-variants
fix the nice FBA variants (again)
parents
3c09bc0f
d04cff63
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/analysis/fba.jl
+29
-0
29 additions, 0 deletions
src/analysis/fba.jl
test/analysis/fba.jl
+5
-6
5 additions, 6 deletions
test/analysis/fba.jl
with
34 additions
and
6 deletions
src/analysis/fba.jl
+
29
−
0
View file @
b2953ef6
...
...
@@ -13,6 +13,35 @@ Returns a solved model from [`optimize_model`](@ref).
flux_balance_analysis
(
model
::
M
,
optimizer
)
where
{
M
<:
MetabolicModel
}
=
optimize_model
(
model
,
optimizer
;
sense
=
MOI
.
MAX_SENSE
)
"""
flux_balance_analysis_vec(args...)::Union{Vector{Float64},Nothing}
A variant of FBA that returns a vector of fluxes in the same order as reactions
of the model, if the solution is found.
Arguments are passed to [`flux_balance_analysis`](@ref).
"""
function
flux_balance_analysis_vec
(
args
...
)
::
Union
{
Vector
{
Float64
},
Nothing
}
(
optmodel
,
vars
)
=
flux_balance_analysis
(
args
...
)
termination_status
(
optmodel
)
in
[
MOI
.
OPTIMAL
,
MOI
.
LOCALLY_SOLVED
]
||
return
nothing
value
.
(
vars
)
end
"""
flux_balance_analysis_dict(model::M, args...)::Union{Dict{String, Float64},Nothing} where {M <: MetabolicModel}
A variant of FBA that returns a dictionary assigning fluxes to reactions, if
the solution is found. Arguments are passed to [`flux_balance_analysis`](@ref).
"""
function
flux_balance_analysis_dict
(
model
::
M
,
args
...
,
)
::
Union
{
Dict
{
String
,
Float64
},
Nothing
}
where
{
M
<:
MetabolicModel
}
v
=
flux_balance_analysis_vec
(
model
,
args
...
)
isnothing
(
v
)
&&
return
nothing
Dict
(
zip
(
reactions
(
model
),
v
))
end
"""
fba(model::CobraModel, optimizer; objective_func::Union{Reaction, Array{Reaction, 1}}=Reaction[], weights=Float64[], solver_attributes=Dict{Any, Any}(), constraints=Dict{String, Tuple{Float64,Float64}}())
...
...
This diff is collapsed.
Click to expand it.
test/analysis/fba.jl
+
5
−
6
View file @
b2953ef6
...
...
@@ -34,12 +34,11 @@
@test
cp
.
c
'
*
sol
≈
expected_optimum
# test the "nicer output" variants
@test_broken
false
# reminder to implement these methods
# fluxes_vec = flux_balance_analysis_vec(cp, GLPK.Optimizer)
# @test_broken all(fluxes_vec .== sol)
# fluxes_dict = flux_balance_analysis_dict(cp, GLPK.Optimizer)
# rxns = reactions(cp)
# @test all([fluxes_dict[rxns[i]] == sol[i] for i in eachindex(rxns)])
fluxes_vec
=
flux_balance_analysis_vec
(
cp
,
GLPK
.
Optimizer
)
@test
all
(
fluxes_vec
.==
sol
)
fluxes_dict
=
flux_balance_analysis_dict
(
cp
,
GLPK
.
Optimizer
)
rxns
=
reactions
(
cp
)
@test
all
([
fluxes_dict
[
rxns
[
i
]]
==
sol
[
i
]
for
i
in
eachindex
(
rxns
)])
end
@testset
"Flux balance analysis with CobraModel"
begin
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment