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
ff038a24
Unverified
Commit
ff038a24
authored
Aug 09, 2021
by
St. Elmo
Committed by
GitHub
Aug 09, 2021
Browse files
Merge pull request #420 from LCSB-BioCore/mo-tiny-fixes
Mo tiny fixes
parents
0ac76bdd
1cf394f7
Pipeline
#45160
passed with stages
in 32 minutes and 9 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/analysis/modifications/generic.jl
View file @
ff038a24
...
...
@@ -25,19 +25,19 @@ change_constraint(id::String, lb, ub) =
end
"""
change_objective(new_objective::Union{String,Vector{String}}; weights=[], sense=
MOI.
MAX_SENSE)
change_objective(new_objective::Union{String,Vector{String}}; weights=[], sense=MAX_SENSE)
Modification that changes the objective function used in a constraint based
analysis function. `new_objective` can be a single reaction identifier, or an
array of reactions identifiers.
Optionally, the objective can be weighted by a vector of `weights`, and a
optimization `sense` can be set.
optimization `sense` can be set
to either `MAX_SENSE` or `MIN_SENSE`
.
"""
change_objective
(
new_objective
::
Union
{
String
,
Vector
{
String
}};
weights
=
[],
sense
=
MOI
.
MAX_SENSE
,
sense
=
MAX_SENSE
,
)
=
(
model
,
opt_model
)
->
begin
...
...
src/base/types/FluxSummary.jl
View file @
ff038a24
...
...
@@ -11,6 +11,20 @@ struct FluxSummary
unbounded_fluxes
::
OrderedDict
{
String
,
Float64
}
end
"""
FluxSummary()
A default empty constructor for `FluxSummary`.
"""
function
FluxSummary
()
FluxSummary
(
OrderedDict
{
String
,
Float64
}(),
OrderedDict
{
String
,
Float64
}(),
OrderedDict
{
String
,
Float64
}(),
OrderedDict
{
String
,
Float64
}(),
)
end
"""
flux_summary(flux_result::Dict{String, Float64};
exclude_exchanges = false,
...
...
@@ -49,7 +63,7 @@ Export:
```
"""
function
flux_summary
(
flux_result
::
Dict
{
String
,
Float64
};
flux_result
::
Maybe
{
Dict
{
String
,
Float64
}
}
;
exclude_exchanges
=
false
,
exchange_prefixes
=
_constants
.
exchange_prefixes
,
biomass_strings
=
_constants
.
biomass_strings
,
...
...
@@ -58,6 +72,8 @@ function flux_summary(
large_flux_bound
=
_constants
.
default_reaction_bound
,
keep_unbounded
=
false
,
)
isnothing
(
flux_result
)
&&
return
FluxSummary
()
rxn_ids
=
collect
(
keys
(
flux_result
))
ex_rxns
=
filter
(
x
->
looks_like_exchange_reaction
(
...
...
src/base/types/FluxVariabilitySummary.jl
View file @
ff038a24
...
...
@@ -9,6 +9,18 @@ struct FluxVariabilitySummary
exchange_fluxes
::
Dict
{
String
,
Vector
{
Union
{
Float64
,
Nothing
}}}
end
"""
FluxVariabilitySummary()
A default empty constructor for `FluxVariabilitySummary`
"""
function
FluxVariabilitySummary
()
FluxVariabilitySummary
(
Dict
{
String
,
Vector
{
Union
{
Float64
,
Nothing
}}}(),
Dict
{
String
,
Vector
{
Union
{
Float64
,
Nothing
}}}(),
)
end
"""
flux_variability_summary(flux_result::Tuple{Dict{String, Dict{String, Float64}}, Dict{String, Dict{String, Float64}}};
exclude_exchanges = false,
...
...
@@ -50,6 +62,7 @@ function flux_variability_summary(
biomass_strings
=
_constants
.
biomass_strings
,
exclude_biomass
=
false
,
)
isnothing
(
flux_result
)
&&
return
FluxVariabilitySummary
()
rxn_ids
=
keys
(
flux_result
[
1
])
ex_rxns
=
filter
(
...
...
src/base/utils/fluxes.jl
View file @
ff038a24
...
...
@@ -14,14 +14,13 @@ function metabolite_fluxes(model::MetabolicModel, flux_dict::Dict{String,Float64
for
(
row
,
mid
)
in
enumerate
(
mids
)
for
(
col
,
rid
)
in
enumerate
(
rids
)
mf
=
flux_dict
[
rid
]
*
S
[
row
,
col
]
# ignore zero flux
if
mf
<
-
_constants
.
tolerance
# consuming rxn
if
mf
<
0
# consuming rxn
if
haskey
(
consuming
,
mid
)
consuming
[
mid
][
rid
]
=
mf
else
consuming
[
mid
]
=
Dict
(
rid
=>
mf
)
end
elseif
mf
>
_constants
.
tolerance
elseif
mf
>
=
0
# producing rxn
if
haskey
(
producing
,
mid
)
producing
[
mid
][
rid
]
=
mf
else
...
...
src/io/show/FluxSummary.jl
View file @
ff038a24
...
...
@@ -5,9 +5,10 @@ end
_pad_spaces
(
str
::
String
,
maxlen
::
Int
)
=
_pad_spaces
(
length
(
str
),
maxlen
)
function
Base.show
(
io
::
IO
,
::
MIME
"text/plain"
,
flux_res
::
FluxSummary
)
longest_biomass_len
=
maximum
([
length
(
k
)
for
k
in
keys
(
flux_res
.
biomass_fluxes
)])
longest_import_len
=
maximum
([
length
(
k
)
for
k
in
keys
(
flux_res
.
import_fluxes
)])
longest_export_len
=
maximum
([
length
(
k
)
for
k
in
keys
(
flux_res
.
export_fluxes
)])
longest_biomass_len
=
maximum
(
length
(
k
)
for
k
in
keys
(
flux_res
.
biomass_fluxes
);
init
=
0
)
longest_import_len
=
maximum
(
length
(
k
)
for
k
in
keys
(
flux_res
.
import_fluxes
);
init
=
0
)
longest_export_len
=
maximum
(
length
(
k
)
for
k
in
keys
(
flux_res
.
export_fluxes
);
init
=
0
)
if
!
isempty
(
flux_res
.
unbounded_fluxes
)
longest_unbounded_len
=
...
...
src/io/show/FluxVariabilitySummary.jl
View file @
ff038a24
function
Base.show
(
io
::
IO
,
::
MIME
"text/plain"
,
flux_res
::
FluxVariabilitySummary
)
longest_biomass_len
=
maximum
([
length
(
k
)
for
k
in
keys
(
flux_res
.
biomass_fluxes
)])
longest_exchange_len
=
maximum
([
length
(
k
)
for
k
in
keys
(
flux_res
.
exchange_fluxes
)])
longest_biomass_len
=
maximum
(
length
(
k
)
for
k
in
keys
(
flux_res
.
biomass_fluxes
);
init
=
0
)
longest_exchange_len
=
maximum
(
length
(
k
)
for
k
in
keys
(
flux_res
.
exchange_fluxes
);
init
=
0
)
word_pad_len
=
max
(
longest_biomass_len
,
longest_exchange_len
)
longest_biomass_flux_len
=
maximum
([
length
(
string
(
round
(
v
[
1
],
digits
=
4
)))
for
v
in
values
(
flux_res
.
biomass_fluxes
)
])
longest_biomass_flux_len
=
maximum
(
length
(
string
(
round
(
v
[
1
],
digits
=
4
)))
for
v
in
values
(
flux_res
.
biomass_fluxes
);
init
=
0
,
)
longest_exchange_flux_len
=
max
(
maximum
(
[
maximum
(
length
(
string
(
round
(
v
[
1
],
digits
=
4
)))
for
v
in
values
(
flux_res
.
exchange_fluxes
)
]),
v
in
values
(
flux_res
.
exchange_fluxes
);
init
=
0
,
),
length
(
"Lower bound "
),
)
number_pad_len
=
max
(
longest_biomass_flux_len
,
longest_exchange_flux_len
)
...
...
test/reconstruction/community.jl
View file @
ff038a24
...
...
@@ -53,7 +53,7 @@ end
exchange_rxn_mets
=
Dict
(
ex_rxn
=>
first
(
keys
(
reaction_stoichiometry
(
m2
,
ex_rxn
)))
for
ex_rxn
in
filter
(
looks_like_exchange_reaction
,
reactions
(
m2
)
)
ex_rxn
in
reactions
(
m2
)
if
looks_like_exchange_reaction
(
ex_rxn
)
)
biomass_ids
=
[
"BIOMASS_Ecoli_core_w_GAM"
,
"BIOMASS_Ecoli_core_w_GAM"
]
...
...
@@ -91,7 +91,7 @@ end
exchange_rxn_mets
=
Dict
(
ex_rxn
=>
first
(
keys
(
reaction_stoichiometry
(
m2
,
ex_rxn
)))
for
ex_rxn
in
filter
(
looks_like_exchange_reaction
,
reactions
(
m2
)
)
ex_rxn
in
reactions
(
m2
)
if
looks_like_exchange_reaction
(
ex_rxn
)
)
biomass_ids
=
[
"BIOMASS_Ecoli_core_w_GAM"
,
"BIOMASS_Ec_iJO1366_core_53p95M"
]
...
...
@@ -143,7 +143,7 @@ end
exchange_rxn_mets
=
Dict
(
ex_rxn
=>
first
(
keys
(
reaction_stoichiometry
(
m1
,
ex_rxn
)))
for
ex_rxn
in
filter
(
looks_like_exchange_reaction
,
reactions
(
m1
)
)
ex_rxn
in
reactions
(
m1
)
if
looks_like_exchange_reaction
(
ex_rxn
)
)
biomass_ids
=
[
"BIOMASS_Ecoli_core_w_GAM"
]
...
...
cylon-x
🤖
@cylon-x
mentioned in commit
86cf093a
·
Aug 09, 2021
mentioned in commit
86cf093a
mentioned in commit 86cf093a93b6bc398c176f2d36b009de44eaf315
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