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
c791716a
Unverified
Commit
c791716a
authored
Nov 29, 2021
by
St. Elmo
Browse files
implement reviews
parent
e2d3a7f9
Pipeline
#50154
failed with stages
in 8 minutes and 32 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/reconstruction/CoreModel.jl
View file @
c791716a
...
...
@@ -453,10 +453,8 @@ function change_objective!(
rxn_idxs
::
Vector
{
Int
};
weights
=
ones
(
length
(
rxn_idxs
)),
)
nz_idxs
,
_
=
findnz
(
objective
(
model
))
model
.
c
[
nz_idxs
]
.=
0.0
# reset
dropzeros!
(
model
.
c
)
# cleanup
model
.
c
[
rxn_idxs
]
.=
weights
# set
model
.
c
=
spzeros
(
length
(
model
.
c
))
model
.
c
[
rxn_idxs
]
.=
weights
nothing
end
...
...
src/reconstruction/CoreModelCoupled.jl
View file @
c791716a
...
...
@@ -428,31 +428,21 @@ end
"""
change_objective!(
model::CoreModelCoupled,
rxn_idxs::Vector{Int};
weights = ones(length(rxns))
,
args...,
kwargs...
,
)
Change the objective for `model` to reaction(s) with indices `rxn_ids`, optionally
specifying their `weights`. By default, assume equal weights. If no objective exists in
model, sets objective.
Forwards arguments to [`change_objective!`](@ref).
"""
function
change_objective!
(
model
::
CoreModelCoupled
,
rxn_idxs
::
Vector
{
Int
};
weights
=
ones
(
length
(
rxns
)),
)
change_objective!
(
model
.
lm
,
rxn_idxs
;
weights
)
function
change_objective!
(
model
::
CoreModelCoupled
,
args
...
;
kwargs
...
)
change_objective!
(
model
.
lm
,
args
...
;
kwargs
...
)
end
change_objective!
(
model
::
CoreModelCoupled
,
rxn_xid
::
Int
)
=
change_objective!
(
model
.
lm
,
[
rxn_xid
])
function
change_objective!
(
model
::
CoreModelCoupled
,
rxn_ids
::
Vector
{
String
};
weights
=
ones
(
length
(
rxns
)),
)
change_objective!
(
model
.
lm
,
rxn_ids
;
weights
)
function
change_objective!
(
model
::
CoreModelCoupled
,
args
...
;
kwargs
...
)
change_objective!
(
model
.
lm
,
args
...
;
kwargs
...
)
end
change_objective!
(
model
::
CoreModelCoupled
,
rxn_id
::
String
)
=
...
...
src/reconstruction/StandardModel.jl
View file @
c791716a
...
...
@@ -248,14 +248,12 @@ function change_objective!(
)
all
(
!
haskey
(
model
.
reactions
,
rid
)
for
rid
in
rxn_ids
)
&&
throw
(
DomainError
(
rxn_ids
,
"Some reaction ids were not found in model."
))
k
=
1
# counter
for
rid
in
reactions
(
model
)
if
rid
in
rxn_ids
model
.
reactions
[
rid
]
.
objective_coefficient
=
weights
[
k
]
k
+=
1
else
# set others to zero
model
.
reactions
[
rid
]
.
objective_coefficient
=
0.0
end
for
rid
in
reactions
(
model
)
# reset to zero
model
.
reactions
[
rid
]
.
objective_coefficient
=
0.0
end
for
(
k
,
rid
)
in
enumerate
(
rxn_ids
)
model
.
reactions
[
rid
]
.
objective_coefficient
=
weights
[
k
]
end
end
...
...
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