Skip to content
Snippets Groups Projects
Unverified Commit 7309a0ee authored by St. Elmo's avatar St. Elmo
Browse files

added nothing

parent 7e606ec3
No related branches found
No related tags found
No related merge requests found
...@@ -379,8 +379,8 @@ end ...@@ -379,8 +379,8 @@ end
function change_bounds!( function change_bounds!(
model::CoreModel, model::CoreModel,
reaction_idxs::Vector{Int}; reaction_idxs::Vector{Int};
lower_bounds = fill(-_constants.default_reaction_bound, length(reaction_idxs)), lower_bounds = fill(nothing, length(reaction_idxs)),
upper_bounds = fill(constants.default_reaction_bound, length(reaction_idxs)), upper_bounds = fill(nothing, length(reaction_idxs)),
) )
for (rxn_idx, lb, ub) in zip(reaction_idxs, lower_bounds, upper_bounds) for (rxn_idx, lb, ub) in zip(reaction_idxs, lower_bounds, upper_bounds)
change_bound!(model, rxn_idx; lower_bound=lb, upper_bound=ub) change_bound!(model, rxn_idx; lower_bound=lb, upper_bound=ub)
...@@ -391,11 +391,11 @@ end ...@@ -391,11 +391,11 @@ end
function change_bound!( function change_bound!(
model::CoreModel, model::CoreModel,
rxn::Int; rxn::Int;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
model.xl[rxn] = lower_bound !isnothing(lower_bound) && (model.xl[rxn] = lower_bound)
model.xu[rxn] = upper_bound !isnothing(upper_bound) && (model.xu[rxn] = upper_bound)
return nothing # so that nothing gets printed return nothing # so that nothing gets printed
end end
...@@ -403,8 +403,8 @@ end ...@@ -403,8 +403,8 @@ end
function change_bounds!( function change_bounds!(
model::CoreModel, model::CoreModel,
rxn_ids::Vector{String}; rxn_ids::Vector{String};
lower_bounds = fill(-_constants.default_reaction_bound, length(rxn_ids)), lower_bounds = fill(nothing, length(rxn_ids)),
upper_bounds = fill(constants.default_reaction_bound, length(rxn_ids)), upper_bounds = fill(nothing, length(rxn_ids)),
) )
change_bounds!(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds) change_bounds!(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end end
...@@ -413,8 +413,8 @@ end ...@@ -413,8 +413,8 @@ end
function change_bound!( function change_bound!(
model::CoreModel, model::CoreModel,
rxn_id::String; rxn_id::String;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
change_bound!(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound) change_bound!(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound)
end end
...@@ -423,14 +423,16 @@ end ...@@ -423,14 +423,16 @@ end
function change_bounds( function change_bounds(
model::CoreModel, model::CoreModel,
rxns::Vector{Int}; rxns::Vector{Int};
lower_bounds = fill(-_constants.default_reaction_bound, length(rxns)), lower_bounds = fill(nothing, length(rxns)),
upper_bounds = fill(constants.default_reaction_bound, length(rxns)), upper_bounds = fill(nothing, length(rxns)),
) )
m = copy(model) m = copy(model)
m.xl = copy(model.xl) m.xl = copy(model.xl)
m.xu = copy(model.xu) m.xu = copy(model.xu)
m.xl[rxns] .= lower_bounds for idx in rxns
m.xu[rxns] .= upper_bounds !isnothing(lower_bounds[idx]) && (m.xl[idx] = lower_bounds[idx])
!isnothing(upper_bounds[idx]) && (m.xu[idx] = upper_bounds[idx])
end
return m return m
end end
...@@ -438,14 +440,14 @@ end ...@@ -438,14 +440,14 @@ end
function change_bound( function change_bound(
model::CoreModel, model::CoreModel,
rxn::Int; rxn::Int;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
m = copy(model) m = copy(model)
m.xl = copy(model.xl) m.xl = copy(model.xl)
m.xu = copy(model.xu) m.xu = copy(model.xu)
m.xl[rxn] = lower_bound !isnothing(lower_bound) && (m.xl[rxn] = lower_bound)
m.xu[rxn] = upper_bound !isnothing(upper_bound) && (m.xu[rxn] = upper_bound)
return m return m
end end
...@@ -453,8 +455,8 @@ end ...@@ -453,8 +455,8 @@ end
function change_bounds( function change_bounds(
model::CoreModel, model::CoreModel,
rxn_ids::Vector{String}; rxn_ids::Vector{String};
lower_bounds = fill(-_constants.default_reaction_bound, length(rxn_ids)), lower_bounds = fill(nothing, length(rxn_ids)),
upper_bounds = fill(constants.default_reaction_bound, length(rxn_ids)), upper_bounds = fill(nothing, length(rxn_ids)),
) )
change_bounds(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds) change_bounds(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end end
...@@ -463,8 +465,8 @@ end ...@@ -463,8 +465,8 @@ end
function change_bound( function change_bound(
model::CoreModel, model::CoreModel,
rxn_id::String; rxn_id::String;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
change_bound(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound) change_bound(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound)
end end
...@@ -366,8 +366,8 @@ end ...@@ -366,8 +366,8 @@ end
function change_bounds!( function change_bounds!(
model::CoreModelCoupled, model::CoreModelCoupled,
reaction_idxs::Vector{Int}; reaction_idxs::Vector{Int};
lower_bounds = fill(-_constants.default_reaction_bound, length(rxns)), lower_bounds = fill(nothing, length(rxns)),
upper_bounds = fill(_constants.default_reaction_bound, length(rxns)), upper_bounds = fill(nothing, length(rxns)),
) )
for (rxn_idx, lb, ub) in zip(reaction_idxs, lower_bounds, upper_bounds) for (rxn_idx, lb, ub) in zip(reaction_idxs, lower_bounds, upper_bounds)
change_bound!(model, rxn_idx; lower_bound=lb, upper_bound=ub) change_bound!(model, rxn_idx; lower_bound=lb, upper_bound=ub)
...@@ -378,11 +378,11 @@ end ...@@ -378,11 +378,11 @@ end
function change_bound!( function change_bound!(
model::CoreModelCoupled, model::CoreModelCoupled,
rxn::Int; rxn::Int;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
model.lm.xl[rxn] = lower_bound !isnothing(lower_bound) && (model.lm.xl[rxn] = lower_bound)
model.lm.xu[rxn] = upper_bound !isnothing(upper_bound) && (model.lm.xu[rxn] = upper_bound)
return nothing # so that nothing gets printed return nothing # so that nothing gets printed
end end
...@@ -390,8 +390,8 @@ end ...@@ -390,8 +390,8 @@ end
function change_bounds!( function change_bounds!(
model::CoreModelCoupled, model::CoreModelCoupled,
rxn_ids::Vector{String}; rxn_ids::Vector{String};
lower_bounds = fill(-_constants.default_reaction_bound, length(rxn_ids)), lower_bounds = fill(nothing, length(rxn_ids)),
upper_bounds = fill(constants.default_reaction_bound, length(rxn_ids)), upper_bounds = fill(nothing, length(rxn_ids)),
) )
change_bounds!(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds) change_bounds!(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end end
...@@ -400,8 +400,8 @@ end ...@@ -400,8 +400,8 @@ end
function change_bound!( function change_bound!(
model::CoreModelCoupled, model::CoreModelCoupled,
rxn_id::String; rxn_id::String;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
change_bound!(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound) change_bound!(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound)
end end
...@@ -410,14 +410,16 @@ end ...@@ -410,14 +410,16 @@ end
function change_bounds( function change_bounds(
model::CoreModelCoupled, model::CoreModelCoupled,
rxns::Vector{Int}; rxns::Vector{Int};
lower_bounds = fill(-_constants.default_reaction_bound, length(rxns)), lower_bounds = fill(nothing, length(rxns)),
upper_bounds = fill(constants.default_reaction_bound, length(rxns)), upper_bounds = fill(nothing, length(rxns)),
) )
m = copy(model) m = copy(model)
m.lm.xl = copy(model.lm.xl) m.lm.xl = copy(model.lm.xl)
m.lm.xu = copy(model.lm.xu) m.lm.xu = copy(model.lm.xu)
m.lm.xl[rxns] .= lower_bounds for idx in rxns
m.lm.xu[rxns] .= upper_bounds !isnothing(lower_bounds[idx]) && (m.lm.xl[idx] = lower_bounds[idx])
!isnothing(upper_bounds[idx]) && (m.lm.xu[idx] = upper_bounds[idx])
end
return m return m
end end
...@@ -425,14 +427,14 @@ end ...@@ -425,14 +427,14 @@ end
function change_bound( function change_bound(
model::CoreModelCoupled, model::CoreModelCoupled,
reaction_idx::Int; reaction_idx::Int;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
m = copy(model) m = copy(model)
m.lm.xl = copy(model.lm.xl) m.lm.xl = copy(model.lm.xl)
m.lm.xu = copy(model.lm.xu) m.lm.xu = copy(model.lm.xu)
m.lm.xl[reaction_idx] = lower_bound !isnothing(lower_bound) && (m.lm.xl[reaction_idx] = lower_bound)
m.lm.xu[reaction_idx] = upper_bound !isnothing(upper_bound) && (m.lm.xu[reaction_idx] = upper_bound)
return m return m
end end
...@@ -440,8 +442,8 @@ end ...@@ -440,8 +442,8 @@ end
function change_bounds( function change_bounds(
model::CoreModelCoupled, model::CoreModelCoupled,
rxn_ids::Vector{String}; rxn_ids::Vector{String};
lower_bounds = fill(-_constants.default_reaction_bound, length(rxn_ids)), lower_bounds = fill(nothing, length(rxn_ids)),
upper_bounds = fill(constants.default_reaction_bound, length(rxn_ids)), upper_bounds = fill(nothing, length(rxn_ids)),
) )
change_bounds(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds) change_bounds(model, Int.(indexin(rxn_ids, reactions(model))); lower_bounds = lower_bounds, upper_bounds = upper_bounds)
end end
...@@ -450,8 +452,8 @@ end ...@@ -450,8 +452,8 @@ end
function change_bound( function change_bound(
model::CoreModelCoupled, model::CoreModelCoupled,
rxn_id::String; rxn_id::String;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
change_bound(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound) change_bound(model, first(indexin([rxn_id], reactions(model))); lower_bound = lower_bound, upper_bound = upper_bound)
end end
...@@ -217,12 +217,12 @@ remove_gene!(model::StandardModel, gid::String; knockout_reactions::Bool = false ...@@ -217,12 +217,12 @@ remove_gene!(model::StandardModel, gid::String; knockout_reactions::Bool = false
function change_bound!( function change_bound!(
model::StandardModel, model::StandardModel,
reaction_id::String; reaction_id::String;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
reaction = model.reactions[reaction_id] reaction = model.reactions[reaction_id]
reaction.lb = float(lower_bound) !isnothing(lower_bound) && (reaction.lb = float(lower_bound))
reaction.ub = float(upper_bound) !isnothing(upper_bound) && (reaction.ub = float(upper_bound))
return nothing # so that nothing gets printed return nothing # so that nothing gets printed
end end
...@@ -230,8 +230,8 @@ end ...@@ -230,8 +230,8 @@ end
function change_bounds!( function change_bounds!(
model::StandardModel, model::StandardModel,
reaction_ids::Vector{String}; reaction_ids::Vector{String};
lower_bounds = fill(-_constants.default_reaction_bound, length(reaction_ids)), lower_bounds = fill(nothing, length(reaction_ids)),
upper_bounds = fill(_constants.default_reaction_bound, length(reaction_ids)), upper_bounds = fill(nothing, length(reaction_ids)),
) )
for (rid, lb, ub) in zip(reaction_ids, lower_bounds, upper_bounds) for (rid, lb, ub) in zip(reaction_ids, lower_bounds, upper_bounds)
change_bound!(model, rid; lower_bound = lb, upper_bound = ub) change_bound!(model, rid; lower_bound = lb, upper_bound = ub)
...@@ -242,14 +242,14 @@ end ...@@ -242,14 +242,14 @@ end
function change_bound( function change_bound(
model::StandardModel, model::StandardModel,
reaction_id::String; reaction_id::String;
lower_bound = -_constants.default_reaction_bound, lower_bound = nothing,
upper_bound = _constants.default_reaction_bound, upper_bound = nothing,
) )
m = copy(model) m = copy(model)
m.reactions = copy(model.reactions) m.reactions = copy(model.reactions)
r = m.reactions[reaction_id] = copy(model.reactions[reaction_id]) r = m.reactions[reaction_id] = copy(model.reactions[reaction_id])
r.lb = float(lower_bound) !isnothing(lower_bound) && (r.lb = float(lower_bound))
r.ub = float(upper_bound) !isnothing(upper_bound) && (r.ub = float(upper_bound))
return m return m
end end
...@@ -257,15 +257,15 @@ end ...@@ -257,15 +257,15 @@ end
function change_bounds( function change_bounds(
model::StandardModel, model::StandardModel,
reaction_ids::Vector{String}; reaction_ids::Vector{String};
lower_bounds = fill(-_constants.default_reaction_bound, length(reaction_ids)), lower_bounds = fill(nothing, length(reaction_ids)),
upper_bounds = fill(constants.default_reaction_bound, length(reaction_ids)), upper_bounds = fill(nothing, length(reaction_ids)),
) )
m = copy(model) m = copy(model)
m.reactions = copy(model.reactions) m.reactions = copy(model.reactions)
for (rid, lb, ub) in zip(reaction_ids, lower_bounds, upper_bounds) for (rid, lb, ub) in zip(reaction_ids, lower_bounds, upper_bounds)
r = m.reactions[rid] = copy(model.reactions[rid]) r = m.reactions[rid] = copy(model.reactions[rid])
r.lb = float(lb) !isnothing(lb) && (r.lb = float(lb))
r.ub = float(ub) !isnothing(ub) && (r.ub = float(ub))
end end
return m return m
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment