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
COBREXA.jl
Commits
63d9a3ca
Unverified
Commit
63d9a3ca
authored
Aug 11, 2021
by
St. Elmo
Browse files
Fix docstrings and simplify function arguments
parent
558c8629
Pipeline
#45294
passed with stages
in 13 minutes and 12 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
docs/src/notebooks/7_community_model.jl
View file @
63d9a3ca
...
...
@@ -49,7 +49,6 @@ model_names = ["cytbd_ko", "atps4r_ko"]
community_model
=
join_with_exchanges
(
[
cytbd_knockout_model
,
atps4r_knockout_model
],
ex_rxn_mets
;
add_biomass_objective
=
true
,
biomass_ids
=
[
"BIOMASS_Ecoli_core_w_GAM"
,
"BIOMASS_Ecoli_core_w_GAM"
],
model_names
=
model_names
,
)
...
...
src/reconstruction/community.jl
View file @
63d9a3ca
...
...
@@ -175,7 +175,6 @@ end
"""
join_with_exchanges(models::Vector{M},
exchange_rxn_mets::Dict{String, String};
add_biomass_objective=false,
biomass_ids::Vector{String},
model_names=String[]
)
...
...
@@ -190,12 +189,12 @@ bounds of the environmental variables are all set to zero. Thus, to run a simula
need to constrain them appropriately. All the other bounds are inherited from the models
used to construct the community model.
If `
add_
biomass_
objective` is true then `biomass_ids` needs to be supplied as well. This
creates a model with an extra reaction
added to the end of the stoichiometric matrix (last
column) that can be assigned as the
objective reaction. It also creates biomass
"
metabolites
" that can be used in this objective reaction. Note, this reaction is
unspecified, further action needs to be taken to specify it, e.g. assign weights to
the
last
column of the stoichiometric matrix in the rows
corresponding to the biomass metabolites.
If `biomass_
ids` is supplied, then a community model is returned that has an extra reaction
added to the end of the stoichiometric matrix (last
column) that can be assigned as the
objective reaction. It also creates biomass
"
metabolites
" that can be used in this objective
reaction. Note, this reaction is unspecified, further action needs to be taken to specify
it, e.g. assign weights to the last column of the stoichiometric matrix in
the
rows
corresponding to the biomass metabolites.
To further clarify how this `join` works. Suppose you have 2 organisms with stoichiometric
matrices S₁ and S₂ and you want to link them with `exchange_rxn_mets = Dict(er₁ => em₁, er₂
...
...
@@ -215,7 +214,7 @@ S = em₂| |
```
The exchange reactions in each model get linked to environmental metabolites, `emᵢ`, and
these get linked to environmental exchanges, `erᵢ`. These `erᵢ` behave like normal single
organism exchange reactions. When `
add_
biomass_
objective` is true
each model's biomass
organism exchange reactions. When `biomass_
ids` are supplied,
each model's biomass
becomes a pseudo-metabolite (`bmᵢ`). These can be weighted in column `b`, called the
`community_biomass` reaction in the community model, if desired. Refer to the tutorial if
this is unclear.
...
...
@@ -234,7 +233,6 @@ biomass_ids = ["BIOMASS_Ecoli_core_w_GAM", "BIOMASS_Ecoli_core_w_GAM"]
community = join_with_exchanges(
[m1, m2],
exchange_rxn_mets;
add_biomass_objective = true,
biomass_ids = biomass_ids,
)
```
...
...
@@ -242,23 +240,13 @@ community = join_with_exchanges(
function
join_with_exchanges
(
models
::
Vector
{
M
},
exchange_rxn_mets
::
Dict
{
String
,
String
};
add_biomass_objective
=
true
,
biomass_ids
=
String
[],
model_names
=
String
[],
)
::
CoreModel
where
{
M
<:
MetabolicModel
}
exchange_rxn_ids
=
keys
(
exchange_rxn_mets
)
exchange_met_ids
=
values
(
exchange_rxn_mets
)
if
add_biomass_objective
&&
isempty
(
biomass_ids
)
throw
(
DomainError
(
"biomass_ids"
,
"Please add supply the string ids of the biomass functions when
`add_biomass_objective` is true."
,
),
)
end
add_biomass_objective
=
isempty
(
biomass_ids
)
?
false
:
true
if
length
(
exchange_met_ids
)
!=
length
(
exchange_rxn_ids
)
throw
(
DomainError
(
...
...
test/reconstruction/community.jl
View file @
63d9a3ca
...
...
@@ -3,7 +3,7 @@
m2
=
test_toyModel
()
ex_rxn_mets
=
Dict
(
"EX_m1(e)"
=>
"m1[e]"
,
"EX_m3(e)"
=>
"m3[e]"
)
c1
=
join_with_exchanges
([
m1
,
m2
],
ex_rxn_mets
;
add_biomass_objective
=
false
)
c1
=
join_with_exchanges
([
m1
,
m2
],
ex_rxn_mets
)
# test of stoichs are the same
@test
all
(
c1
.
S
[
1
:
6
,
1
:
7
]
.==
c1
.
S
[
7
:
12
,
8
:
14
])
...
...
@@ -24,12 +24,7 @@
@test
all
(
lb
[
1
:
14
]
.==
-
ub
[
1
:
14
]
.==
-
1000
)
@test
all
(
lb
[
15
:
16
]
.==
-
ub
[
15
:
16
]
.==
0.0
)
c2
=
join_with_exchanges
(
[
m1
,
m2
],
ex_rxn_mets
;
add_biomass_objective
=
true
,
biomass_ids
=
[
"biomass1"
,
"biomass1"
],
)
c2
=
join_with_exchanges
([
m1
,
m2
],
ex_rxn_mets
;
biomass_ids
=
[
"biomass1"
,
"biomass1"
])
# test if same base stoich matrix
@test
all
(
c2
.
S
[
1
:
14
,
1
:
16
]
.==
c1
.
S
)
# test if biomass reaction and metabolites are added correctly
...
...
@@ -58,12 +53,7 @@ end
biomass_ids
=
[
"BIOMASS_Ecoli_core_w_GAM"
,
"BIOMASS_Ecoli_core_w_GAM"
]
community
=
join_with_exchanges
(
[
m1
,
m2
],
exchange_rxn_mets
;
add_biomass_objective
=
true
,
biomass_ids
=
biomass_ids
,
)
community
=
join_with_exchanges
([
m1
,
m2
],
exchange_rxn_mets
;
biomass_ids
=
biomass_ids
)
env_ex_inds
=
indexin
(
keys
(
exchange_rxn_mets
),
reactions
(
community
))
m2_ex_inds
=
indexin
(
keys
(
exchange_rxn_mets
),
reactions
(
m2
))
...
...
@@ -96,12 +86,7 @@ end
biomass_ids
=
[
"BIOMASS_Ecoli_core_w_GAM"
,
"BIOMASS_Ec_iJO1366_core_53p95M"
]
community
=
join_with_exchanges
(
[
m1
,
m2
],
exchange_rxn_mets
;
add_biomass_objective
=
true
,
biomass_ids
=
biomass_ids
,
)
community
=
join_with_exchanges
([
m1
,
m2
],
exchange_rxn_mets
;
biomass_ids
=
biomass_ids
)
env_ex_inds
=
indexin
(
keys
(
exchange_rxn_mets
),
reactions
(
community
))
m2_ex_inds
=
indexin
(
keys
(
exchange_rxn_mets
),
reactions
(
m2
))
...
...
@@ -148,12 +133,7 @@ end
biomass_ids
=
[
"BIOMASS_Ecoli_core_w_GAM"
]
community
=
join_with_exchanges
(
[
m1
],
exchange_rxn_mets
;
add_biomass_objective
=
true
,
biomass_ids
=
biomass_ids
,
)
community
=
join_with_exchanges
([
m1
],
exchange_rxn_mets
;
biomass_ids
=
biomass_ids
)
env_ex_inds
=
indexin
(
keys
(
exchange_rxn_mets
),
reactions
(
community
))
m1_ex_inds
=
indexin
(
keys
(
exchange_rxn_mets
),
reactions
(
m1
))
...
...
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