Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
COBREXA.jl
Manage
Activity
Members
Plan
External wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LCSB-BioCore
COBREXA.jl
Commits
6e713c42
Commit
6e713c42
authored
3 years ago
by
Miroslav Kratochvil
Browse files
Options
Downloads
Patches
Plain Diff
start the grand unification of remove_whatever
parent
f20e41f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/base/macros/remove_item.jl
+28
-0
28 additions, 0 deletions
src/base/macros/remove_item.jl
src/reconstruction/StandardModel.jl
+46
-56
46 additions, 56 deletions
src/reconstruction/StandardModel.jl
with
74 additions
and
56 deletions
src/base/macros/remove_item.jl
0 → 100644
+
28
−
0
View file @
6e713c42
macro
_remove_fn
(
objname
,
model_type
,
idx_type
,
args
...
)
body
=
last
(
args
)
typeof
(
body
)
==
Expr
||
throw
(
DomainError
(
body
,
"missing function body"
))
plural
=
:
plural
in
args
plural_s
=
plural
?
"s"
:
""
inplace
=
:
inplace
in
args
fname
=
Symbol
(
:
remove_
,
objname
,
plural_s
,
inplace
?
"!"
:
""
)
idx_var
=
Symbol
(
objname
,
idx_type
==
:
Int
?
"_idx"
:
idx_type
==
:
String
?
"_id"
:
throw
(
DomainError
(
idx_type
,
"unsupported index type for _remove_fn macro"
)),
plural_s
,
)
if
plural
idx_type
=
AbstractVector
{
eval
(
idx_type
)}
end
docstring
=
"""
$
fname(model::
$
model_type,
$
idx_var::
$
idx_type)
Remove
$
objname
$
plural_s from the model of type `
$
model_type`
$
(inplace ? "
in
-
place
" : "
and
return
the
modified
model
").
"""
return
:
(
@doc
$
docstring
$
fname
(
model
::$
model_type
,
$
idx_var
::$
idx_type
)
=
$
body
)
end
This diff is collapsed.
Click to expand it.
src/reconstruction/StandardModel.jl
+
46
−
56
View file @
6e713c42
...
...
@@ -106,62 +106,6 @@ macro add_reactions!(model::Symbol, ex::Expr)
return
all_reactions
end
"""
remove_reactions!(model::StandardModel, ids::Vector{String})
Remove all reactions with `ids` from `model`. Note, may result in orphan metabolites.
# Example
```
remove_reactions!(model, ["
EX_glc__D_e
", "
fba
"])
```
"""
function
remove_reactions!
(
model
::
StandardModel
,
ids
::
Vector
{
String
})
pop!
.
(
Ref
(
model
.
reactions
),
ids
)
end
"""
remove_reaction!(model::StandardModel, id::String)
Remove reaction with `id` from `model`. Note, may result in orphan metabolites.
# Example
```
remove_reaction!(model, "
EX_glc__D_e
")
```
"""
remove_reaction!
(
model
::
StandardModel
,
id
::
String
)
=
remove_reactions!
(
model
,
[
id
])
"""
remove_metabolites!(model::StandardModel, ids::Vector{String})
Remove all metabolites with `ids` from `model`.
Warning, this could leave the model inconsistent, e.g. a reaction might
require the deleted metabolite, in which case analysis functions will error.
# Example
```
remove_metabolites!(model, ["
atp_c
", "
adp_c
"])
```
"""
function
remove_metabolites!
(
model
::
StandardModel
,
ids
::
Vector
{
String
})
pop!
.
(
Ref
(
model
.
metabolites
),
ids
)
end
"""
remove_metabolite!(model::StandardModel, id::String)
Remove metabolite with `id` from `model`.
Warning, this could leave the model inconsistent, e.g. a reaction might
require the deleted metabolite, in which case analysis functions will error.
# Example
```
remove_metabolite!(model, "
atp_c
")
```
"""
remove_metabolite!
(
model
::
StandardModel
,
id
::
String
)
=
remove_metabolites!
(
model
,
[
id
])
"""
remove_genes!(
model::StandardModel,
...
...
@@ -239,3 +183,49 @@ end
change_bounds!
(
n
,
rxn_ids
,
lower
=
lower
,
upper
=
upper
)
n
end
@_remove_fn
reaction
StandardModel
String
inplace
begin
delete!
(
model
.
reactions
,
reaction_id
)
end
@_remove_fn
reaction
StandardModel
String
inplace
plural
begin
remove_reaction!
.
(
Ref
(
model
),
reaction_ids
)
end
@_remove_fn
reaction
StandardModel
String
begin
remove_reactions
(
model
,
[
reaction_id
])
end
@_remove_fn
reaction
StandardModel
String
plural
begin
n
=
copy
(
model
)
n
.
reactions
=
copy
(
model
.
reactions
)
remove_reactions!
(
n
,
reaction_ids
)
n
end
@_remove_fn
metabolite
StandardModel
String
inplace
begin
remove_metabolites!
(
model
,
[
metabolite_id
])
end
@_remove_fn
metabolite
StandardModel
String
inplace
plural
begin
remove_reactions!
(
model
,
[
rid
for
(
rid
,
rn
)
in
model
.
reactions
if
any
(
haskey
.
(
Ref
(
rn
.
metabolites
),
metabolite_ids
))
],
)
delete!
.
(
Ref
(
model
.
metabolites
),
metabolite_ids
)
end
@_remove_fn
metabolite
StandardModel
String
plural
begin
n
=
copy
(
model
)
n
.
reactions
=
copy
(
model
.
reactions
)
n
.
metabolites
=
copy
(
model
.
metabolites
)
remove_metabolites!
(
n
,
metabolite_ids
)
n
end
@_remove_fn
metabolite
StandardModel
String
begin
remove_metabolites
(
model
,
[
metabolite_id
])
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment