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
COBREXA.jl
Commits
c26aa15b
Commit
c26aa15b
authored
Jun 09, 2021
by
Miroslav Kratochvil
🚴
Browse files
just reformat everything
...to be able to continue pushing formatted code sanely
parent
a1987d7d
Pipeline
#42960
passed with stages
in 9 minutes and 58 seconds
Changes
20
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/base/types/CoreModel.jl
View file @
c26aa15b
...
...
@@ -99,8 +99,11 @@ end
Return the reaction equation of reaction with id `rxn_id` in model. The reaction
equation maps metabolite ids to their stoichiometric coefficients.
"""
function
reaction_stoichiometry
(
m
::
CoreModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
Dict
(
m
.
mets
[
k
]
=>
v
for
(
k
,
v
)
in
zip
(
findnz
(
m
.
S
[
:
,
first
(
indexin
([
rxn_id
],
m
.
rxns
))])
...
))
function
reaction_stoichiometry
(
m
::
CoreModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
Dict
(
m
.
mets
[
k
]
=>
v
for
(
k
,
v
)
in
zip
(
findnz
(
m
.
S
[
:
,
first
(
indexin
([
rxn_id
],
m
.
rxns
))])
...
)
)
end
"""
...
...
@@ -109,8 +112,8 @@ end
Return the reaction equation of reaction with id `rxn_ind` in model. The reaction
equation maps metabolite ids to their stoichiometric coefficients.
"""
function
reaction_stoichiometry
(
m
::
CoreModel
,
rxn_ind
::
Int
)
::
Dict
{
String
,
Float64
}
Dict
(
m
.
mets
[
k
]
=>
v
for
(
k
,
v
)
in
zip
(
findnz
(
m
.
S
[
:
,
rxn_ind
])
...
))
function
reaction_stoichiometry
(
m
::
CoreModel
,
rxn_ind
::
Int
)
::
Dict
{
String
,
Float64
}
Dict
(
m
.
mets
[
k
]
=>
v
for
(
k
,
v
)
in
zip
(
findnz
(
m
.
S
[
:
,
rxn_ind
])
...
))
end
"""
...
...
src/base/types/CoreModelCoupled.jl
View file @
c26aa15b
...
...
@@ -110,7 +110,7 @@ end
Return the reaction equation of reaction with id `rxn_id` in model. The reaction
equation maps metabolite ids to their stoichiometric coefficients.
"""
function
reaction_stoichiometry
(
m
::
CoreModelCoupled
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
function
reaction_stoichiometry
(
m
::
CoreModelCoupled
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
reaction_stoichiometry
(
m
.
lm
,
rxn_id
)
end
...
...
@@ -120,7 +120,7 @@ end
Return the reaction equation of reaction with id `rxn_ind` in model. The reaction
equation maps metabolite ids to their stoichiometric coefficients.
"""
function
reaction_stoichiometry
(
m
::
CoreModelCoupled
,
rxn_ind
::
Int
)
::
Dict
{
String
,
Float64
}
function
reaction_stoichiometry
(
m
::
CoreModelCoupled
,
rxn_ind
::
Int
)
::
Dict
{
String
,
Float64
}
reaction_stoichiometry
(
m
.
lm
,
rxn_ind
)
end
...
...
src/base/types/JSONModel.jl
View file @
c26aa15b
...
...
@@ -282,7 +282,7 @@ end
Return the reaction equation of reaction with id `rxn_id` in model. The reaction
equation maps metabolite ids to their stoichiometric coefficients.
"""
function
reaction_stoichiometry
(
m
::
JSONModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
function
reaction_stoichiometry
(
m
::
JSONModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
ind
=
findfirst
(
x
->
x
[
"id"
]
==
rxn_id
,
m
.
json
[
"reactions"
])
m
.
json
[
"reactions"
][
ind
][
"metabolites"
]
end
...
...
src/base/types/MATModel.jl
View file @
c26aa15b
...
...
@@ -174,7 +174,7 @@ metabolite_compartment(m::MATModel, mid::String) = _maybemap(
Return the reaction equation of reaction with id `rxn_id` in model. The reaction
equation maps metabolite ids to their stoichiometric coefficients.
"""
function
reaction_stoichiometry
(
m
::
MATModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
function
reaction_stoichiometry
(
m
::
MATModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
rxn_ind
=
first
(
indexin
([
rxn_id
],
m
.
mat
[
"rxns"
]))
reaction_stoichiometry
(
m
,
rxn_ind
)
end
...
...
@@ -186,7 +186,7 @@ Return the reaction equation of reaction with index `rxn_index` in model. The re
equation maps metabolite ids to their stoichiometric coefficients. Note, `rxn_index` can
be any suitable type that can index into an array.
"""
function
reaction_stoichiometry
(
m
::
MATModel
,
rxn_ind
)
::
Dict
{
String
,
Float64
}
function
reaction_stoichiometry
(
m
::
MATModel
,
rxn_ind
)
::
Dict
{
String
,
Float64
}
met_inds
=
findall
(
m
.
mat
[
"S"
][
:
,
rxn_ind
]
.!=
0.0
)
Dict
(
m
.
mat
[
"mets"
][
met_ind
]
=>
m
.
mat
[
"S"
][
met_ind
,
rxn_ind
]
for
met_ind
in
met_inds
)
end
...
...
src/base/types/SBMLModel.jl
View file @
c26aa15b
...
...
@@ -143,7 +143,7 @@ _sbml_export_notes = _sbml_export_annotation
Return the reaction equation of reaction with id `rxn_id` in model. The reaction
equation maps metabolite ids to their stoichiometric coefficients.
"""
function
reaction_stoichiometry
(
m
::
SBMLModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
function
reaction_stoichiometry
(
m
::
SBMLModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
m
.
sbml
.
reactions
[
rxn_id
]
.
stoichiometry
end
...
...
src/base/types/StandardModel.jl
View file @
c26aa15b
...
...
@@ -288,7 +288,7 @@ end
Return the reaction equation of reaction with id `rxn_id` in model. The reaction
equation maps metabolite ids to their stoichiometric coefficients.
"""
function
reaction_stoichiometry
(
m
::
StandardModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
function
reaction_stoichiometry
(
m
::
StandardModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
m
.
reactions
[
rxn_id
]
.
metabolites
end
...
...
src/base/types/abstract/MetabolicModel.jl
View file @
c26aa15b
...
...
@@ -312,9 +312,12 @@ end
Return the reaction equation of reaction with id `rxn_id` in model. The reaction
equation maps metabolite ids to their stoichiometric coefficients.
"""
function
reaction_stoichiometry
(
m
::
MetabolicModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
function
reaction_stoichiometry
(
m
::
MetabolicModel
,
rxn_id
::
String
)
::
Dict
{
String
,
Float64
}
mets
=
metabolites
(
m
)
Dict
(
mets
[
k
]
=>
v
for
(
k
,
v
)
in
zip
(
findnz
(
stoichiometry
(
m
)[
:
,
first
(
indexin
([
rxn_id
],
reactions
(
m
)))])
...
))
Dict
(
mets
[
k
]
=>
v
for
(
k
,
v
)
in
zip
(
findnz
(
stoichiometry
(
m
)[
:
,
first
(
indexin
([
rxn_id
],
reactions
(
m
)))])
...
)
)
end
"""
...
...
src/base/utils/StandardModel.jl
View file @
c26aa15b
...
...
@@ -59,7 +59,8 @@ function atom_exchange(flux_dict::Dict{String,Float64}, model::StandardModel)
for
(
met
,
stoich_rxn
)
in
model
.
reactions
[
rxn_id
]
.
metabolites
adict
=
get_atoms
(
model
.
metabolites
[
met
])
for
(
atom
,
stoich_molecule
)
in
adict
atom_flux
[
atom
]
=
get
(
atom_flux
,
atom
,
0.0
)
+
flux
*
stoich_rxn
*
stoich_molecule
atom_flux
[
atom
]
=
get
(
atom_flux
,
atom
,
0.0
)
+
flux
*
stoich_rxn
*
stoich_molecule
end
end
end
...
...
src/reconstruction/CoreModelCoupled.jl
View file @
c26aa15b
...
...
@@ -21,20 +21,12 @@ function add_reactions(
xu
::
AbstractFloat
;
check_consistency
=
false
,
)
where
{
V1
<:
VecType
,
V2
<:
VecType
}
new_lm
=
add_reactions
(
m
.
lm
,
s
,
b
,
c
,
xl
,
xu
,
check_consistency
=
check_consistency
,
)
new_lm
=
add_reactions
(
m
.
lm
,
s
,
b
,
c
,
xl
,
xu
,
check_consistency
=
check_consistency
)
return
CoreModelCoupled
(
new_lm
,
hcat
(
m
.
C
,
spzeros
(
size
(
m
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m
.
lm
))),
hcat
(
m
.
C
,
spzeros
(
size
(
m
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m
.
lm
))),
m
.
cl
,
m
.
cu
m
.
cu
,
)
end
...
...
@@ -64,21 +56,21 @@ function add_reactions(
check_consistency
=
false
,
)
where
{
V1
<:
VecType
,
V2
<:
VecType
,
K
<:
StringVecType
}
new_lm
=
add_reactions
(
m
.
lm
,
s
,
b
,
c
,
xl
,
xu
,
rxn
,
mets
,
check_consistency
=
check_consistency
)
m
.
lm
,
s
,
b
,
c
,
xl
,
xu
,
rxn
,
mets
,
check_consistency
=
check_consistency
,
)
return
CoreModelCoupled
(
new_lm
,
hcat
(
m
.
C
,
spzeros
(
size
(
m
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m
.
lm
))),
hcat
(
m
.
C
,
spzeros
(
size
(
m
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m
.
lm
))),
m
.
cl
,
m
.
cu
m
.
cu
,
)
end
...
...
@@ -103,20 +95,12 @@ function add_reactions(
xu
::
V
;
check_consistency
=
false
,
)
where
{
M
<:
MatType
,
V
<:
VecType
}
new_lm
=
add_reactions
(
m
.
lm
,
Sp
,
b
,
c
,
xl
,
xu
,
check_consistency
=
check_consistency
,
)
new_lm
=
add_reactions
(
m
.
lm
,
Sp
,
b
,
c
,
xl
,
xu
,
check_consistency
=
check_consistency
)
return
CoreModelCoupled
(
new_lm
,
hcat
(
m
.
C
,
spzeros
(
size
(
m
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m
.
lm
))),
hcat
(
m
.
C
,
spzeros
(
size
(
m
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m
.
lm
))),
m
.
cl
,
m
.
cu
m
.
cu
,
)
end
...
...
@@ -127,16 +111,12 @@ Add all reactions from `m2` to `m1`.
"""
function
add_reactions
(
m1
::
CoreModelCoupled
,
m2
::
CoreModel
;
check_consistency
=
false
)
new_lm
=
add_reactions
(
m1
.
lm
,
m2
,
check_consistency
=
check_consistency
)
new_lm
=
add_reactions
(
m1
.
lm
,
m2
,
check_consistency
=
check_consistency
)
return
CoreModelCoupled
(
new_lm
,
hcat
(
m1
.
C
,
spzeros
(
size
(
m1
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m1
.
lm
))),
hcat
(
m1
.
C
,
spzeros
(
size
(
m1
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m1
.
lm
))),
m1
.
cl
,
m1
.
cu
m1
.
cu
,
)
end
...
...
@@ -166,21 +146,21 @@ function add_reactions(
check_consistency
=
false
,
)
where
{
M
<:
MatType
,
V
<:
VecType
,
K
<:
StringVecType
}
new_lm
=
add_reactions
(
m
.
lm
,
Sp
,
b
,
c
,
xl
,
xu
,
rxns
,
mets
,
check_consistency
=
check_consistency
)
m
.
lm
,
Sp
,
b
,
c
,
xl
,
xu
,
rxns
,
mets
,
check_consistency
=
check_consistency
,
)
return
CoreModelCoupled
(
new_lm
,
hcat
(
m
.
C
,
spzeros
(
size
(
m
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m
.
lm
))),
hcat
(
m
.
C
,
spzeros
(
size
(
m
.
C
,
1
),
n_reactions
(
new_lm
)
-
n_reactions
(
m
.
lm
))),
m
.
cl
,
m
.
cu
m
.
cu
,
)
end
...
...
@@ -194,11 +174,11 @@ Also removes any metabolites not involved in any reaction after the deletion.
"""
function
remove_reactions
(
m
::
CoreModelCoupled
,
rxns
::
Vector
{
Int
})
return
CoreModelCoupled
(
remove_reactions
(
m
.
lm
,
rxns
),
m
.
C
[
:
,
filter
(
e
->
e
∉
rxns
,
1
:
n_reactions
(
m
))],
m
.
cl
,
m
.
cu
)
remove_reactions
(
m
.
lm
,
rxns
),
m
.
C
[
:
,
filter
(
e
->
e
∉
rxns
,
1
:
n_reactions
(
m
))],
m
.
cl
,
m
.
cu
,
)
end
"""
...
...
@@ -222,7 +202,8 @@ end
"""
function
remove_reactions
(
m
::
CoreModelCoupled
,
rxns
::
Vector
{
String
})
rxn_indices
=
[
findfirst
(
isequal
(
name
),
m
.
lm
.
rxns
)
for
name
in
intersect
(
rxns
,
m
.
lm
.
rxns
)]
rxn_indices
=
[
findfirst
(
isequal
(
name
),
m
.
lm
.
rxns
)
for
name
in
intersect
(
rxns
,
m
.
lm
.
rxns
)]
if
isempty
(
rxn_indices
)
return
m
else
...
...
@@ -398,12 +379,7 @@ function change_bounds!(
xl
::
V
=
Float64
[],
xu
::
V
=
Float64
[],
)
where
{
V
<:
VecType
}
change_bounds!
(
model
.
lm
,
rxns
,
xl
=
xl
,
xu
=
xu
)
change_bounds!
(
model
.
lm
,
rxns
,
xl
=
xl
,
xu
=
xu
)
end
"""
...
...
@@ -421,10 +397,5 @@ function change_bounds!(
xl
::
V
=
Float64
[],
xu
::
V
=
Float64
[],
)
where
{
V
<:
VecType
}
change_bounds!
(
model
.
lm
,
rxns
,
xl
=
xl
,
xu
=
xu
)
change_bounds!
(
model
.
lm
,
rxns
,
xl
=
xl
,
xu
=
xu
)
end
src/reconstruction/StandardModel.jl
View file @
c26aa15b
...
...
@@ -32,8 +32,8 @@ end
Add `met` to `model` based on metabolite `id`.
"""
add_metabolite!
(
model
::
StandardModel
,
met
::
Metabolite
)
=
add_metabolites!
(
model
,
[
met
])
add_metabolite!
(
model
::
StandardModel
,
met
::
Metabolite
)
=
add_metabolites!
(
model
,
[
met
])
"""
add_genes!(model::StandardModel, genes::Vector{Gene})
...
...
@@ -50,7 +50,7 @@ end
Add `gene` to `model` based on gene `id`.
"""
add_gene!
(
model
::
StandardModel
,
gene
::
Gene
)
=
add_genes!
(
model
,
[
gene
])
add_gene!
(
model
::
StandardModel
,
gene
::
Gene
)
=
add_genes!
(
model
,
[
gene
])
"""
@add_reactions!(model::Symbol, ex::Expr)
...
...
@@ -130,7 +130,7 @@ Remove reaction with `id` from `model`. Note, may result in orphan metabolites.
remove_reaction!(model, "
EX_glc__D_e
")
```
"""
remove_reaction!
(
model
::
StandardModel
,
id
::
String
)
=
remove_reactions!
(
model
,
[
id
])
remove_reaction!
(
model
::
StandardModel
,
id
::
String
)
=
remove_reactions!
(
model
,
[
id
])
"""
remove_metabolites!(model::StandardModel, ids::Vector{String})
...
...
@@ -145,7 +145,7 @@ remove_metabolites!(model, ["atp_c", "adp_c"])
```
"""
function
remove_metabolites!
(
model
::
StandardModel
,
ids
::
Vector
{
String
})
pop!
.
(
Ref
(
model
.
metabolites
),
ids
)
pop!
.
(
Ref
(
model
.
metabolites
),
ids
)
end
"""
...
...
@@ -160,7 +160,7 @@ require the deleted metabolite, in which case analysis functions will error.
remove_metabolite!(model, "
atp_c
")
```
"""
remove_metabolite!
(
model
::
StandardModel
,
id
::
String
)
=
remove_metabolites!
(
model
,
[
id
])
remove_metabolite!
(
model
::
StandardModel
,
id
::
String
)
=
remove_metabolites!
(
model
,
[
id
])
"""
remove_genes!(
...
...
@@ -210,7 +210,8 @@ constrain reactions that require the genes to function to carry zero flux.
remove_gene!(model, "
g1
")
```
"""
remove_gene!
(
model
::
StandardModel
,
gid
::
String
;
knockout_reactions
::
Bool
=
false
)
=
remove_genes!
(
model
,
[
gid
];
knockout_reactions
=
knockout_reactions
)
remove_gene!
(
model
::
StandardModel
,
gid
::
String
;
knockout_reactions
::
Bool
=
false
)
=
remove_genes!
(
model
,
[
gid
];
knockout_reactions
=
knockout_reactions
)
function
set_bound
(
model
::
StandardModel
,
reaction_id
::
String
;
ub
,
lb
)
reaction
=
model
.
reactions
[
reaction_id
]
...
...
src/reconstruction/community.jl
View file @
c26aa15b
...
...
@@ -151,8 +151,7 @@ function add_model_with_exchanges(
rxnsadd
=
"
$(model_name)
_"
.*
reactions
(
model
)
if
!
isnothing
(
biomass_id
)
metsadd
=
[
"
$(model_name)
_"
.*
metabolites
(
model
);
"
$(model_name)
_"
*
biomass_id
]
metsadd
=
[
"
$(model_name)
_"
.*
metabolites
(
model
);
"
$(model_name)
_"
*
biomass_id
]
else
metsadd
=
"
$(model_name)
_"
.*
metabolites
(
model
)
end
...
...
@@ -247,7 +246,7 @@ function join_with_exchanges(
add_biomass_objective
=
true
,
biomass_ids
=
String
[],
model_names
=
String
[],
)
::
CoreModel
where
M
<:
MetabolicModel
)
::
CoreModel
where
{
M
<:
MetabolicModel
}
if
add_biomass_objective
&&
isempty
(
biomass_ids
)
throw
(
...
...
@@ -284,7 +283,8 @@ function join_with_exchanges(
nnz_total
=
sum
(
length
(
first
(
nnz
))
for
nnz
in
nnzs
)
+
length
(
models
)
*
length
(
exchange_rxn_ids
)
+
length
(
exchange_met_ids
)
+
nnz_add
length
(
exchange_met_ids
)
+
nnz_add
n_reactions_metabolic
=
sum
(
reaction_lengths
)
n_reactions_total
=
n_reactions_metabolic
+
length
(
exchange_rxn_ids
)
+
column_add
n_metabolites_metabolic
=
sum
(
metabolite_lengths
)
...
...
test/analysis/flux_balance_analysis.jl
View file @
c26aa15b
...
...
@@ -19,8 +19,8 @@
lp
=
flux_balance_analysis
(
cp
,
Tulip
.
Optimizer
)
@test
termination_status
(
lp
)
==
MOI
.
OPTIMAL
sol
=
JuMP
.
value
.
(
lp
[
:
x
])
@test
isapprox
(
objective_value
(
lp
),
expected_optimum
,
atol
=
TEST_TOLERANCE
)
@test
isapprox
(
cp
.
c
'
*
sol
,
expected_optimum
,
atol
=
TEST_TOLERANCE
)
@test
isapprox
(
objective_value
(
lp
),
expected_optimum
,
atol
=
TEST_TOLERANCE
)
@test
isapprox
(
cp
.
c
'
*
sol
,
expected_optimum
,
atol
=
TEST_TOLERANCE
)
# test the "nicer output" variants
fluxes_vec
=
flux_balance_analysis_vec
(
cp
,
Tulip
.
Optimizer
)
...
...
test/analysis/knockouts.jl
View file @
c26aa15b
...
...
@@ -5,7 +5,10 @@
add_gene!
(
m
,
Gene
(
"g1"
))
add_gene!
(
m
,
Gene
(
"g2"
))
add_reaction!
(
m
,
Reaction
(
"v1"
,
metabolites
=
Dict
(
"A"
=>
-
1.0
,
"B"
=>
1.0
),
grr
=
[[
"g1"
]]))
add_reaction!
(
m
,
Reaction
(
"v1"
,
metabolites
=
Dict
(
"A"
=>
-
1.0
,
"B"
=>
1.0
),
grr
=
[[
"g1"
]]),
)
add_reaction!
(
m
,
Reaction
(
"v2"
,
metabolites
=
Dict
(
"A"
=>
-
1.0
,
"B"
=>
1.0
),
grr
=
[[
"g1"
,
"g2"
]]),
...
...
test/base/utils/StandardModel.jl
View file @
c26aa15b
...
...
@@ -12,14 +12,18 @@
# atom tracker
atom_fluxes
=
atom_exchange
(
sol
,
model
)
@test
isapprox
(
atom_fluxes
[
"C"
],
37.19016648975907
;
atol
=
TEST_TOLERANCE
)
@test
isapprox
(
atom_fluxes
[
"C"
],
37.19016648975907
;
atol
=
TEST_TOLERANCE
)
@test
atom_exchange
(
"FBA"
,
model
)[
"C"
]
==
0.0
@test
isapprox
(
atom_exchange
(
"BIOMASS_Ecoli_core_w_GAM"
,
model
)[
"C"
],
-
42.5555
;
atol
=
TEST_TOLERANCE
)
@test
isapprox
(
atom_exchange
(
"BIOMASS_Ecoli_core_w_GAM"
,
model
)[
"C"
],
-
42.5555
;
atol
=
TEST_TOLERANCE
,
)
# metabolite trackers
consuming
,
producing
=
metabolite_fluxes
(
sol
,
model
)
@test
isapprox
(
consuming
[
"atp_c"
][
"PFK"
],
-
7.47738
;
atol
=
TEST_TOLERANCE
)
@test
isapprox
(
producing
[
"atp_c"
][
"PYK"
],
1.75818
;
atol
=
TEST_TOLERANCE
)
@test
isapprox
(
consuming
[
"atp_c"
][
"PFK"
],
-
7.47738
;
atol
=
TEST_TOLERANCE
)
@test
isapprox
(
producing
[
"atp_c"
][
"PYK"
],
1.75818
;
atol
=
TEST_TOLERANCE
)
# set bounds
cbm
=
make_optimization_model
(
model
,
optimizer
)
...
...
test/base/utils/looks_like.jl
View file @
c26aa15b
...
...
@@ -25,17 +25,29 @@
[
"EX_m1"
;
"Exch_m3"
;
"Ex_m2"
],
[
"m1"
;
"m2"
;
"m3_e"
],
)
@test
filter
(
looks_like_exchange_reaction
,
reactions
(
cp
))
==
[
"EX_m1"
,
"Exch_m3"
,
"Ex_m2"
]
@test
filter
(
x
->
looks_like_exchange_reaction
(
x
;
exchange_prefixes
=
[
"Exch_"
]),
reactions
(
cp
))
==
[
"Exch_m3"
]
@test
filter
(
looks_like_exchange_reaction
,
reactions
(
cp
))
==
[
"EX_m1"
,
"Exch_m3"
,
"Ex_m2"
]
@test
filter
(
x
->
looks_like_exchange_reaction
(
x
;
exchange_prefixes
=
[
"Exch_"
]),
reactions
(
cp
),
)
==
[
"Exch_m3"
]
# this is originally the "toyModel1.mat"
cp
=
test_toyModel
()
@test
filter
(
looks_like_exchange_reaction
,
reactions
(
cp
))
==
[
"EX_m1(e)"
,
"EX_m3(e)"
,
"EX_biomass(e)"
]
@test
filter
(
x
->
looks_like_exchange_reaction
(
x
;
exclude_biomass
=
true
),
reactions
(
cp
))
==
[
"EX_m1(e)"
,
"EX_m3(e)"
]
@test
filter
(
looks_like_exchange_reaction
,
reactions
(
cp
))
==
[
"EX_m1(e)"
,
"EX_m3(e)"
,
"EX_biomass(e)"
]
@test
filter
(
x
->
looks_like_exchange_reaction
(
x
;
exclude_biomass
=
true
),
reactions
(
cp
),
)
==
[
"EX_m1(e)"
,
"EX_m3(e)"
]
@test
filter
(
looks_like_exchange_metabolite
,
metabolites
(
cp
))
==
[
"m1[e]"
,
"m3[e]"
]
@test
filter
(
looks_like_biomass_reaction
,
reactions
(
cp
))
==
[
"EX_biomass(e)"
,
"biomass1"
]
@test
filter
(
x
->
looks_like_biomass_reaction
(
x
;
exclude_exchanges
=
true
),
reactions
(
cp
))
==
[
"biomass1"
]
@test
filter
(
looks_like_biomass_reaction
,
reactions
(
cp
))
==
[
"EX_biomass(e)"
,
"biomass1"
]
@test
filter
(
x
->
looks_like_biomass_reaction
(
x
;
exclude_exchanges
=
true
),
reactions
(
cp
),
)
==
[
"biomass1"
]
end
@testset
"Looks like functions, basic"
begin
...
...
@@ -43,25 +55,25 @@ end
@test
length
(
filter
(
looks_like_exchange_reaction
,
reactions
(
model
)))
==
20
@test
length
(
filter
(
looks_like_exchange_metabolite
,
metabolites
(
model
)))
==
20
@test
length
(
filter
(
looks_like_biomass_reaction
,
reactions
(
model
)))
==
1
model
=
load_model
(
model_paths
[
"e_coli_core.xml"
])
@test
length
(
filter
(
looks_like_exchange_reaction
,
reactions
(
model
)))
==
20
@test
length
(
filter
(
looks_like_exchange_metabolite
,
metabolites
(
model
)))
==
20
@test
length
(
filter
(
looks_like_biomass_reaction
,
reactions
(
model
)))
==
1
model
=
load_model
(
model_paths
[
"e_coli_core.mat"
])
@test
length
(
filter
(
looks_like_exchange_reaction
,
reactions
(
model
)))
==
20
@test
length
(
filter
(
looks_like_exchange_metabolite
,
metabolites
(
model
)))
==
20
@test
length
(
filter
(
looks_like_biomass_reaction
,
reactions
(
model
)))
==
1
model
=
convert
(
StandardModel
,
model
)
@test
length
(
filter
(
looks_like_exchange_reaction
,
reactions
(
model
)))
==
20
@test
length
(
filter
(
looks_like_exchange_metabolite
,
metabolites
(
model
)))
==
20
@test
length
(
filter
(
looks_like_biomass_reaction
,
reactions
(
model
)))
==
1
model
=
convert
(
CoreModelCoupled
,
model
)
@test
length
(
filter
(
looks_like_exchange_reaction
,
reactions
(
model
)))
==
20
@test
length
(
filter
(
looks_like_exchange_metabolite
,
metabolites
(
model
)))
==
20
@test
length
(
filter
(
looks_like_biomass_reaction
,
reactions
(
model
)))
==
1
end
test/reconstruction/CoreModel.jl
View file @
c26aa15b
...
...
@@ -175,10 +175,10 @@ end
lp
=
CoreModel
(
[
1.0
1
1
0
;
1
1
1
0
;
1
1
1
0
;
0
0
0
1
],
collect
(
1.
:
4
),
collect
(
1.
:
4
),
collect
(
1.
:
4
),
collect
(
1.
:
4
),
collect
(
1.
0
:
4
),
collect
(
1.
0
:
4
),
collect
(
1.
0
:
4
),
collect
(
1.
0
:
4
),
[
"r1"
;
"r2"
;
"r3"
;
"r4"
],
[
"m1"
;
"m2"
;
"m3"
;
"m4"
],
)
...
...
test/reconstruction/CoreModelCoupled.jl
View file @
c26aa15b
...
...
@@ -54,7 +54,16 @@ end
@test
cp
.
cl
==
new_cp
.
cl
@test
cp
.
cu
==
new_cp
.
cu
new_cp
=
add_reactions
(
cp
,
2.0
*
ones
(
4
),
3
.*
ones
(
4
),
2.0
,
-
1.0
,
1.0
,
"r4"
,
[
"m
$
i"
for
i
in
1
:
4
])
new_cp
=
add_reactions
(
cp
,
2.0
*
ones
(
4
),
3
.*
ones
(
4
),
2.0
,
-
1.0
,
1.0
,
"r4"
,
[
"m
$
i"
for
i
=
1
:
4
],
)
@test
cp
.
C
==
new_cp
.
C
[
:
,
1
:
end
-
1
]
@test
cp
.
cl
==
new_cp
.
cl
@test
cp
.
cu
==
new_cp
.
cu
...
...
@@ -78,34 +87,28 @@ end
2
.*
ones
(
10
),
-
ones
(
10
),
ones
(
10
),
[
"r
$
i"
for
i
in
1
:
10
],
[
"m
$
i"
for
i
in
1
:
4
]
[
"r
$
i"
for
i
=
1
:
10
],
[
"m
$
i"
for
i
=
1
:
4
]
,
)
@test
cp
.
C
==
new_cp
.
C
[
:
,
1
:
end
-
7
]
# 3 reactions were already present
@test
cp
.
cl
==
new_cp
.
cl
@test
cp
.
cu
==
new_cp
.
cu
new_cp
=
add_reactions
(
cp
,
2.0
*
sprand
(
4000
,
0.5
),
3
.*
sprand
(
4000
,
0.5
),
2.0
,
-
1.0
,
1.0
)
new_cp
=
add_reactions
(
cp
,
2.0
*
sprand
(
4000
,
0.5
),
3
.*
sprand
(
4000
,
0.5
),
2.0
,
-
1.0
,
1.0
)
@test
cp
.
C
==
new_cp
.
C
[
:
,
1
:
end
-
1
]
@test
cp
.
cl
==
new_cp
.
cl
@test
cp
.
cu
==
new_cp
.
cu
cm
=
CoreModel
(
2.0
*
ones
(
4
,
10
),
3
.*
ones
(
4
),
2
.*
ones
(
10
),
-
ones
(
10
),
ones
(
10
),
[
"r
$
i"
for
i
in
1
:
10
],
[
"m
$
i"
for
i
in
1
:
4
]
)
2.0
*
ones
(
4
,
10
),
3
.*
ones
(
4
),
2
.*
ones
(
10
),
-
ones
(
10
),
ones
(
10
),
[
"r
$
i"
for
i
=
1
:
10
],
[
"m
$
i"
for
i
=
1
:
4
]
,
)
new_cp
=
add_reactions
(
cp
,
cm
)
@test
cp
.
C
==
new_cp
.
C
[
:
,
1
:
end
-
7
]
# 3 reactions were already present
@test
cp
.
cl
==
new_cp
.
cl
...
...
@@ -114,9 +117,9 @@ end
@testset
"Remove reactions"
begin
cp
=
convert
(
CoreModelCoupled
,
test_LP
())