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
2a0ff182
Unverified
Commit
2a0ff182
authored
Nov 29, 2021
by
St. Elmo
Committed by
GitHub
Nov 29, 2021
Browse files
Merge pull request #517 from LCSB-BioCore/mo-return-nothing
Improve `remove_XXX` functions
parents
a4119885
241894e3
Pipeline
#50158
failed with stages
in 6 minutes and 47 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/reconstruction/CoreModel.jl
View file @
2a0ff182
...
...
@@ -363,7 +363,7 @@ end
model
.
xl
=
model
.
xl
[
mask
]
model
.
xu
=
model
.
xu
[
mask
]
model
.
rxns
=
model
.
rxns
[
mask
]
return
nothing
nothing
end
@_remove_fn
reaction
CoreModel
Int
begin
...
...
@@ -408,7 +408,7 @@ end
model
.
S
=
model
.
S
[
mask
,
:
]
model
.
b
=
model
.
b
[
mask
]
model
.
mets
=
model
.
mets
[
mask
]
return
nothing
nothing
end
@_remove_fn
metabolite
CoreModel
Int
begin
...
...
src/reconstruction/CoreModelCoupled.jl
View file @
2a0ff182
...
...
@@ -205,7 +205,6 @@ function add_coupling_constraints!(
return
add_coupling_constraints!
(
m
,
sparse
(
reshape
(
c
,
(
1
,
length
(
c
)))),
[
cl
],
[
cu
])
end
"""
add_coupling_constraints!(
m::CoreModelCoupled,
...
...
@@ -234,9 +233,9 @@ function add_coupling_constraints!(
m
.
C
=
vcat
(
m
.
C
,
sparse
(
C
))
m
.
cl
=
vcat
(
m
.
cl
,
collect
(
cl
))
m
.
cu
=
vcat
(
m
.
cu
,
collect
(
cu
))
nothing
end
"""
remove_coupling_constraints(m::CoreModelCoupled, args...)
...
...
@@ -250,7 +249,6 @@ function remove_coupling_constraints(m::CoreModelCoupled, args...)
return
new_model
end
"""
remove_coupling_constraints!(m::CoreModelCoupled, constraint::Int)
...
...
@@ -272,9 +270,9 @@ function remove_coupling_constraints!(m::CoreModelCoupled, constraints::Vector{I
m
.
C
=
m
.
C
[
to_be_kept
,
:
]
m
.
cl
=
m
.
cl
[
to_be_kept
]
m
.
cu
=
m
.
cu
[
to_be_kept
]
nothing
end
"""
change_coupling_bounds!(
model::CoreModelCoupled,
...
...
@@ -308,6 +306,7 @@ function change_coupling_bounds!(
throw
(
DimensionMismatch
(
"`constraints` size doesn't match with `cu`"
))
model
.
cu
[
red_constraints
]
=
cu
[
found
]
end
nothing
end
@_change_bounds_fn
CoreModelCoupled
Int
inplace
begin
...
...
@@ -358,7 +357,7 @@ end
orig_rxns
=
reactions
(
model
.
lm
)
remove_reactions!
(
model
.
lm
,
reaction_idxs
)
model
.
C
=
model
.
C
[
:
,
in
.
(
orig_rxns
,
Ref
(
Set
(
reactions
(
model
.
lm
))))]
return
nothing
nothing
end
@_remove_fn
reaction
CoreModelCoupled
Int
begin
...
...
@@ -396,7 +395,7 @@ end
orig_rxns
=
reactions
(
model
.
lm
)
model
.
lm
=
remove_metabolites
(
model
.
lm
,
metabolite_idxs
)
model
.
C
=
model
.
C
[
:
,
in
.
(
orig_rxns
,
Ref
(
Set
(
reactions
(
model
.
lm
))))]
return
nothing
nothing
end
@_remove_fn
metabolite
CoreModelCoupled
Int
begin
...
...
src/reconstruction/StandardModel.jl
View file @
2a0ff182
...
...
@@ -7,6 +7,7 @@ function add_reactions!(model::StandardModel, rxns::Vector{Reaction})
for
rxn
in
rxns
model
.
reactions
[
rxn
.
id
]
=
rxn
end
nothing
end
"""
...
...
@@ -25,6 +26,7 @@ function add_metabolites!(model::StandardModel, mets::Vector{Metabolite})
for
met
in
mets
model
.
metabolites
[
met
.
id
]
=
met
end
nothing
end
"""
...
...
@@ -43,6 +45,7 @@ function add_genes!(model::StandardModel, genes::Vector{Gene})
for
gene
in
genes
model
.
genes
[
gene
.
id
]
=
gene
end
nothing
end
"""
...
...
@@ -137,6 +140,7 @@ function remove_genes!(
pop!
.
(
Ref
(
model
.
reactions
),
rm_reactions
)
end
pop!
.
(
Ref
(
model
.
genes
),
gids
)
nothing
end
"""
...
...
@@ -161,7 +165,7 @@ remove_gene!(model::StandardModel, gid::String; knockout_reactions::Bool = false
@_change_bounds_fn
StandardModel
String
inplace
begin
isnothing
(
lower
)
||
(
model
.
reactions
[
rxn_id
]
.
lb
=
lower
)
isnothing
(
upper
)
||
(
model
.
reactions
[
rxn_id
]
.
ub
=
upper
)
return
nothing
nothing
end
@_change_bounds_fn
StandardModel
String
inplace
plural
begin
...
...
@@ -185,11 +189,17 @@ end
end
@_remove_fn
reaction
StandardModel
String
inplace
begin
delete!
(
model
.
reactions
,
reaction_id
)
if
!
(
reaction_id
in
reactions
(
model
))
@_models_log
@info
"Reaction
$
reaction_id not found in model."
else
delete!
(
model
.
reactions
,
reaction_id
)
end
nothing
end
@_remove_fn
reaction
StandardModel
String
inplace
plural
begin
remove_reaction!
.
(
Ref
(
model
),
reaction_ids
)
nothing
end
@_remove_fn
reaction
StandardModel
String
begin
...
...
@@ -208,6 +218,8 @@ end
end
@_remove_fn
metabolite
StandardModel
String
inplace
plural
begin
!
all
(
in
.
(
metabolite_ids
,
Ref
(
metabolites
(
model
))))
&&
@_models_log
@info
"Some metabolites not found in model."
remove_reactions!
(
model
,
[
...
...
@@ -216,7 +228,7 @@ end
],
)
delete!
.
(
Ref
(
model
.
metabolites
),
metabolite_ids
)
return
nothing
nothing
end
@_remove_fn
metabolite
StandardModel
String
begin
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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