Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
LCSB-BioCore
COBREXA.jl
Commits
0a68a3b4
Unverified
Commit
0a68a3b4
authored
Apr 22, 2021
by
St. Elmo
Browse files
fixed remaining tests
parent
730aaafd
Changes
9
Hide whitespace changes
Inline
Side-by-side
src/analysis/flux_variability_analysis.jl
View file @
0a68a3b4
...
...
@@ -165,7 +165,7 @@ function flux_variability_analysis(
λmin
<=
COBREXA
.
JuMP
.
objective_function
(
opt_model
)
<=
λmax
# in case there is a negative bound
)
for
i
=
1
:
length
(
v
)
for
(
i
,
r_id
)
in
enumerate
(
reactions
(
model
)
)
COBREXA
.
JuMP
.
@objective
(
opt_model
,
Max
,
v
[
i
])
COBREXA
.
JuMP
.
optimize!
(
opt_model
)
status
=
(
...
...
@@ -173,11 +173,11 @@ function flux_variability_analysis(
COBREXA
.
JuMP
.
termination_status
(
opt_model
)
==
MOI
.
LOCALLY_SOLVED
)
if
status
fva_max
[
model
.
reactions
[
i
]
.
id
]
=
fva_max
[
r_
id
]
=
Dict
(
zip
(
reactions
(
model
),
value
.
(
opt_model
[
:
x
])))
else
@warn
"Error maximizing index:
$
i with error
$
(termination_status(opt_model))"
fva_max
[
model
.
reactions
[
i
]
.
id
]
=
nothing
fva_max
[
r_
id
]
=
nothing
end
@objective
(
opt_model
,
Min
,
v
[
i
])
...
...
@@ -187,11 +187,11 @@ function flux_variability_analysis(
termination_status
(
opt_model
)
==
MOI
.
LOCALLY_SOLVED
)
if
status
fva_min
[
model
.
reactions
[
i
]
.
id
]
=
fva_min
[
r_
id
]
=
Dict
(
zip
(
reactions
(
model
),
value
.
(
opt_model
[
:
x
])))
else
@warn
"Error minimizing index:
$
i with error
$
(termination_status(opt_model))"
fva_min
[
model
.
reactions
[
i
]
.
id
]
=
nothing
fva_min
[
r_
id
]
=
nothing
end
end
...
...
src/analysis/loopless_flux_balance_analysis.jl
View file @
0a68a3b4
function
_get_boundary_reaction_ids
(
model
::
StandardModel
)
::
Array
{
String
,
1
}
return
[
i
.
id
for
i
in
model
.
reactions
if
length
(
i
.
metabolites
)
==
1
]
return
[
r
.
id
for
r
in
values
(
model
.
reactions
)
if
is_boundary
(
r
)
]
end
function
add_cycle_free
(
fluxes
::
Dict
{
String
,
Float64
})
...
...
@@ -8,7 +8,7 @@ function add_cycle_free(fluxes::Dict{String,Float64})
old_objective
=
objective_function
(
opt_model
)
boundary_ids
=
_get_boundary_reaction_ids
(
model
)
min_objectives
=
zeros
(
Int64
,
1
,
length
(
v
))
for
(
i
,
reaction
)
in
enumerate
(
model
.
reactions
)
for
(
i
,
reaction
)
in
enumerate
(
values
(
model
.
reactions
)
)
id
=
reaction
.
id
if
v
[
i
]
in
old_objective
.
terms
.
keys
continue
...
...
test/analysis/flux_balance_analysis.jl
View file @
0a68a3b4
...
...
@@ -50,8 +50,8 @@ end
model
=
read_model
(
model_path
,
StandardModel
)
biomass
=
findfirst
(
model
.
reactions
,
"BIOMASS_Ecoli_core_w_GAM"
)
glucose
=
findfirst
(
model
.
reactions
,
"EX_glc__D_e"
)
biomass
=
model
.
reactions
[
"BIOMASS_Ecoli_core_w_GAM"
]
glucose
=
model
.
reactions
[
"EX_glc__D_e"
]
sol
=
flux_balance_analysis_dict
(
model
,
Tulip
.
Optimizer
;
...
...
@@ -68,7 +68,7 @@ end
atol
=
TEST_TOLERANCE
,
)
pfl
=
findfirst
(
model
.
reactions
,
"PFL"
)
pfl
=
model
.
reactions
[
"PFL"
]
pfl_frac
=
0.8
biomass_frac
=
0.2
sol_multi
=
flux_balance_analysis_dict
(
...
...
test/analysis/flux_variability_analysis.jl
View file @
0a68a3b4
...
...
@@ -69,9 +69,9 @@ end
model
=
read_model
(
model_path
,
StandardModel
)
biomass
=
findfirst
(
model
.
reactions
,
"BIOMASS_Ecoli_core_w_GAM"
)
glucose
=
findfirst
(
model
.
reactions
,
"EX_glc__D_e"
)
oxygen
=
findfirst
(
model
.
reactions
,
"EX_o2_e"
)
biomass
=
model
.
reactions
[
"BIOMASS_Ecoli_core_w_GAM"
]
glucose
=
model
.
reactions
[
"EX_glc__D_e"
]
oxygen
=
model
.
reactions
[
"EX_o2_e"
]
fva_max
,
fva_min
=
flux_variability_analysis
(
model
,
Tulip
.
Optimizer
;
...
...
test/analysis/parsimonious_flux_balance_analysis.jl
View file @
0a68a3b4
...
...
@@ -7,8 +7,8 @@
model
=
read_model
(
model_path
,
StandardModel
)
biomass
=
findfirst
(
model
.
reactions
,
"BIOMASS_Ecoli_core_w_GAM"
)
glucose
=
findfirst
(
model
.
reactions
,
"EX_glc__D_e"
)
biomass
=
model
.
reactions
[
"BIOMASS_Ecoli_core_w_GAM"
]
glucose
=
model
.
reactions
[
"EX_glc__D_e"
]
d
=
parsimonious_flux_balance_analysis_dict
(
model
,
...
...
test/analysis/test_loopless.jl
View file @
0a68a3b4
...
...
@@ -45,7 +45,7 @@ end
model
=
create_loopless_test_model
()
optimizer
=
Tulip
.
Optimizer
# first test that fba in fact does not give the loopless solution
objective
=
findfirst
(
model
.
reactions
,
"v5"
)
objective
=
model
.
reactions
[
"v5"
]
res_fba
=
flux_balance_analysis_dict
(
model
,
optimizer
,
...
...
test/runtests.jl
View file @
0a68a3b4
...
...
@@ -58,10 +58,10 @@ run_test_file("data", "test_models.jl")
# import base files
@testset
"COBREXA test suite"
begin
#
run_test_dir("types", "Data structures")
#
run_test_dir("base", "Base functionality")
#
run_test_dir("io", "I/O functions")
run_test_dir
(
"types"
,
"Data structures"
)
run_test_dir
(
"base"
,
"Base functionality"
)
run_test_dir
(
"io"
,
"I/O functions"
)
run_test_dir
(
"reconstruction"
)
#
run_test_dir("analysis")
#
run_test_dir("sampling")
run_test_dir
(
"analysis"
)
run_test_dir
(
"sampling"
)
end
test/sampling/artificially_centered_hit_and_run.jl
View file @
0a68a3b4
...
...
@@ -8,8 +8,8 @@
model
=
read_model
(
model_path
,
StandardModel
)
biomass
=
findfirst
(
model
.
reactions
,
"BIOMASS_Ecoli_core_w_GAM"
)
glucose
=
findfirst
(
model
.
reactions
,
"EX_glc__D_e"
)
biomass
=
model
.
reactions
[
"BIOMASS_Ecoli_core_w_GAM"
glucose
=
model
.
reactions
[
"EX_glc__D_e"
opt_model
=
flux_balance_analysis
(
model
,
Tulip
.
Optimizer
;
...
...
@@ -19,7 +19,7 @@
change_solver_attribute
(
"IPM_IterationsLimit"
,
500
),
],
)
biomass_index
=
model
[
biomass
]
biomass_index
=
index_of
(
biomass
,
model
)
λ
=
JuMP
.
value
(
opt_model
[
:
x
][
biomass_index
])
change_constraint
(
biomass
,
0.99
*
λ
,
λ
)(
model
,
opt_model
)
...
...
test/sampling/hit_and_run.jl
View file @
0a68a3b4
@testset
"Sampling Tests"
begin
# these tests are not very good - sampling needs work
#
#
these tests are not very good - sampling needs work
model_path
=
download_data_file
(
"http://bigg.ucsd.edu/static/models/e_coli_core.json"
,
joinpath
(
"data"
,
"e_coli_core.json"
),
...
...
@@ -8,8 +8,8 @@
model
=
read_model
(
model_path
,
StandardModel
)
biomass
=
findfirst
(
model
.
reactions
,
"BIOMASS_Ecoli_core_w_GAM"
)
glucose
=
findfirst
(
model
.
reactions
,
"EX_glc__D_e"
)
biomass
=
model
.
reactions
[
"BIOMASS_Ecoli_core_w_GAM"
]
glucose
=
model
.
reactions
[
"EX_glc__D_e"
]
opt_model
=
flux_balance_analysis
(
model
,
Tulip
.
Optimizer
;
...
...
@@ -19,13 +19,13 @@
change_solver_attribute
(
"IPM_IterationsLimit"
,
500
),
],
)
biomass_index
=
model
[
biomass
]
biomass_index
=
index_of
(
biomass
,
reactions
(
model
))
λ
=
JuMP
.
value
(
opt_model
[
:
x
][
biomass_index
])
change_constraint
(
biomass
,
0.99
*
λ
,
λ
)(
model
,
opt_model
)
samples
=
hit_and_run
(
100_000
,
opt_model
,
keepevery
=
10
,
samplesize
=
5000
)
# The sampling converges very randomly and extremely approximately, so only
# test a rough result
#
#
The sampling converges very randomly and extremely approximately, so only
#
#
test a rough result
@test
isapprox
(
mean
(
samples
[
64
,
:
]),
8.9
,
atol
=
0.1
)
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