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
f8b6830c
Unverified
Commit
f8b6830c
authored
Jun 08, 2021
by
Miroslav Kratochvil
Browse files
clean up exchanges a bit
parent
1011dcb5
Pipeline
#42914
passed with stages
in 8 minutes and 13 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/base/utils/looks_like.jl
View file @
f8b6830c
...
...
@@ -18,17 +18,20 @@ Also see [`find_exchange_reactions`](@ref).
findall(looks_like_exchange_reaction, reactions(model)) # returns indices
filter(looks_like_exchange_reaction, reactions(model)) # returns Strings
# to use the optional arguments you need to expand the function's arguments using an anonymous function
# to use the optional arguments you need to expand the function's arguments
# using an anonymous function
findall(x -> looks_like_exchange_reaction(x; exclude_biomass=true), reactions(model)) # returns indices
filter(x -> looks_like_exchange_reaction(x; exclude_biomass=true), reactions(model)) # returns Strings
```
"""
function
looks_like_exchange_reaction
(
rxn_id
::
String
;
function
looks_like_exchange_reaction
(
rxn_id
::
String
;
exclude_biomass
=
false
,
biomass_strings
=
_constants
.
biomass_strings
,
exchange_prefixes
=
_constants
.
exchange_prefixes
,
)
::
Bool
any
(
startswith
(
rxn_id
,
x
)
for
x
in
exchange_prefixes
)
&&
!
(
exclude_biomass
&&
any
(
occursin
(
x
,
rxn_id
)
for
x
in
biomass_strings
))
any
(
startswith
(
rxn_id
,
x
)
for
x
in
exchange_prefixes
)
&&
!
(
exclude_biomass
&&
any
(
occursin
(
x
,
rxn_id
)
for
x
in
biomass_strings
))
end
"""
...
...
@@ -43,7 +46,7 @@ find_exchange_reactions(m::MetabolicModel; kwargs...) =
"""
find_exchange_reaction_ids(m::MetabolicModel; kwargs...)
Shortcut for finding exchange reaction
name
s in a model; arguments are
Shortcut for finding exchange reaction
identifier
s in a model; arguments are
forwarded to [`looks_like_exchange_reaction`](@ref).
"""
find_exchange_reaction_ids
(
m
::
MetabolicModel
;
kwargs
...
)
=
...
...
@@ -67,12 +70,14 @@ filter(looks_like_biomass_reaction, reactions(model)) # returns strings
findall(looks_like_biomass_reaction, reactions(model)) # returns indices
```
"""
function
looks_like_biomass_reaction
(
rxn_id
::
String
;
function
looks_like_biomass_reaction
(
rxn_id
::
String
;
exclude_exchanges
=
false
,
exchange_prefixes
=
_constants
.
exchange_prefixes
,
biomass_strings
=
_constants
.
biomass_strings
,
)
::
Bool
any
(
occursin
(
x
,
rxn_id
)
for
x
in
biomass_strings
)
&&
!
(
exclude_exchanges
&&
any
(
startswith
(
rxn_id
,
x
)
for
x
in
exchange_prefixes
))
any
(
occursin
(
x
,
rxn_id
)
for
x
in
biomass_strings
)
&&
!
(
exclude_exchanges
&&
any
(
startswith
(
rxn_id
,
x
)
for
x
in
exchange_prefixes
))
end
"""
find_biomass_reactions(m::MetabolicModel; kwargs...)
...
...
@@ -86,8 +91,8 @@ find_biomass_reactions(m::MetabolicModel; kwargs...) =
"""
find_biomass_reaction_ids(m::MetabolicModel; kwargs...)
Shortcut for finding biomass reaction
name
s in a model; arguments are
forwarded
to [`looks_like_biomass_reaction`](@ref).
Shortcut for finding biomass reaction
identifier
s in a model; arguments are
forwarded
to [`looks_like_biomass_reaction`](@ref).
"""
find_biomass_reaction_ids
(
m
::
MetabolicModel
;
kwargs
...
)
=
filter
(
id
->
looks_like_biomass_reaction
(
id
,
kwargs
...
),
reactions
(
m
))
...
...
@@ -108,8 +113,26 @@ filter(looks_like_exchange_metabolite, metabolites(model)) # returns strings
findall(looks_like_exchange_metabolite, metabolites(model)) # returns indices
```
"""
function
looks_like_exchange_metabolite
(
met_id
::
String
;
function
looks_like_exchange_metabolite
(
met_id
::
String
;
exchange_suffixes
=
_constants
.
exchange_suffixes
,
)
::
Bool
any
(
endswith
(
met_id
,
x
)
for
x
in
exchange_suffixes
)
end
"""
find_exchange_metabolites(m::MetabolicModel; kwargs...)
Shortcut for finding exchange metabolite indexes in a model; arguments are
forwarded to [`looks_like_exchange_metabolite`](@ref).
"""
find_exchange_metabolites
(
m
::
MetabolicModel
;
kwargs
...
)
=
findall
(
id
->
looks_like_exchange_metabolite
(
id
;
kwargs
...
),
metabolites
(
m
))
"""
find_exchange_metabolite_ids(m::MetabolicModel; kwargs...)
Shortcut for finding exchange metabolite identifiers in a model; arguments are
forwarded to [`looks_like_exchange_metabolite`](@ref).
"""
find_exchange_metabolite_ids
(
m
::
MetabolicModel
;
kwargs
...
)
=
findall
(
id
->
looks_like_exchange_metabolite
(
id
;
kwargs
...
),
metabolites
(
m
))
src/reconstruction/CoreModelCoupled.jl
View file @
f8b6830c
...
...
@@ -381,61 +381,6 @@ function change_coupling_bounds!(
end
end
"""
find_exchange_reactions(
model::CoreModelCoupled;
exclude_biomass = false,
biomass_str::String = "
biomass
",
exc_prefs = ["
EX_
"; "
Exch_
"; "
Ex_
"],
)
Get indices of exchange reactions.
Exchange reactions are identified based on most commonly used prefixes.
"""
function
find_exchange_reactions
(
model
::
CoreModelCoupled
;
exclude_biomass
=
false
,
biomass_str
::
String
=
"biomass"
,
exc_prefs
=
[
"EX_"
;
"Exch_"
;
"Ex_"
],
)
return
find_exchange_reactions
(
model
.
lm
;
exclude_biomass
=
exclude_biomass
,
biomass_str
=
biomass_str
,
exc_prefs
=
exc_prefs
,
)
end
"""
find_exchange_metabolites(
model::CoreModelCoupled;
exclude_biomass = false,
biomass_str::String = "
biomass
",
exc_prefs = ["
EX_
"; "
Exch_
"; "
Ex_
"],
)
Get indices of exchanged metabolites.
In practice returns the metabolites consumed by the reactions given by `find_exchange_reactions`
and if called with the same arguments, the two outputs correspond.
"""
function
find_exchange_metabolites
(
model
::
CoreModelCoupled
;
exclude_biomass
=
false
,
biomass_str
::
String
=
"biomass"
,
exc_prefs
=
[
"EX_"
;
"Exch_"
;
"Ex_"
],
)
return
find_exchange_metabolites
(
model
.
lm
;
exclude_biomass
=
exclude_biomass
,
biomass_str
=
biomass_str
,
exc_prefs
=
exc_prefs
,
)
end
"""
change_bounds!(
model::CoreModelCoupled,
...
...
Miroslav Kratochvil
@miroslav.kratochvil
mentioned in commit
4d4945cf
·
Jun 10, 2021
mentioned in commit
4d4945cf
mentioned in commit 4d4945cfd23ce2b0cd2a49440104e15814e13875
Toggle commit list
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