Model construction functions
Functions for changing the models
COBREXA.add_reaction!
— Methodadd_reaction!(model::CoreModel, rxn::Reaction)
Add rxn
to model
. The model must already contain the metabolites used by rxn
in the model.
COBREXA.add_reactions!
— Methodadd_reactions!(model::CoreModel, rxns::Vector{Reaction})
Add rxns
to model
efficiently. The model must already contain the metabolites used by rxns
in the model.
COBREXA.add_reactions
— Methodadd_reactions(m::CoreModel, Sp::AbstractMatrix{Float64}, b::AbstractVector{Float64}, c::AbstractVector{Float64}, xl::AbstractVector{Float64}, xu::AbstractVector{Float64}, rxns::AbstractVector{String}, mets::AbstractVector{String}; check_consistency) -> Union{CoreModel, Tuple{CoreModel, Any, Any}}
COBREXA.add_reactions
— Methodadd_reactions(m::CoreModel, Sp::AbstractMatrix{Float64}, b::AbstractVector{Float64}, c::AbstractVector{Float64}, xl::AbstractVector{Float64}, xu::AbstractVector{Float64}; check_consistency) -> Union{CoreModel, Tuple{CoreModel, Any, Any}}
COBREXA.add_reactions
— Methodadd_reactions(m::CoreModel, s::AbstractVector{Float64}, b::AbstractVector{Float64}, c::AbstractFloat, xl::AbstractFloat, xu::AbstractFloat, rxn::String, mets::AbstractVector{String}; check_consistency) -> Union{CoreModel, Tuple{CoreModel, Vector{Int64}, Any}}
COBREXA.add_reactions
— Methodadd_reactions(m::CoreModel, s::AbstractVector{Float64}, b::AbstractVector{Float64}, c::AbstractFloat, xl::AbstractFloat, xu::AbstractFloat; check_consistency) -> Union{CoreModel, Tuple{CoreModel, Vector{Int64}, Any}}
Add reaction(s) to a CoreModel
model m
.
COBREXA.add_reactions
— Methodadd_reactions(m1::CoreModel, m2::CoreModel; check_consistency) -> Union{CoreModel, Tuple{CoreModel, Vector{Int64}, Vector{Int64}}}
Add all reactions from m2
to m1
.
COBREXA.change_bound!
— Methodchange_bound!(
model::CoreModel,
rxn_idx::Int;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model in-place.
Example
new_model = change_bound!(model, 123, lower=-21.15, upper=42.3)
COBREXA.change_bound!
— Methodchange_bound!(
model::CoreModel,
rxn_id::String;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model in-place.
Example
new_model = change_bound!(model, "ReactionB", lower=-21.15, upper=42.3)
COBREXA.change_bound
— Methodchange_bound(
model::CoreModel,
rxn_idx::Int;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model and return the modified model.
Example
change_bound(model, 123, lower=-21.15, upper=42.3)
COBREXA.change_bound
— Methodchange_bound(
model::CoreModel,
rxn_id::String;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model and return the modified model.
Example
change_bound(model, "ReactionB", lower=-21.15, upper=42.3)
COBREXA.change_bounds!
— Methodchange_bounds!(
model::CoreModel,
rxn_idxs::AbstractVector{Int64};
lower = (nothing for _ = rxn_idxs),
upper = (nothing for _ = rxn_idxs),
)
Change the specified reaction flux bounds in the model in-place.
Example
new_model = change_bounds!(model, [123, 234], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_bounds!
— Methodchange_bounds!(
model::CoreModel,
rxn_ids::AbstractVector{String};
lower = (nothing for _ = rxn_ids),
upper = (nothing for _ = rxn_ids),
)
Change the specified reaction flux bounds in the model in-place.
Example
new_model = change_bounds!(model, ["ReactionA", "ReactionC"], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_bounds
— Methodchange_bounds(
model::CoreModel,
rxn_idxs::AbstractVector{Int64};
lower = (nothing for _ = rxn_idxs),
upper = (nothing for _ = rxn_idxs),
)
Change the specified reaction flux bounds in the model and return the modified model.
Example
change_bounds(model, [123, 234], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_bounds
— Methodchange_bounds(
model::CoreModel,
rxn_ids::AbstractVector{String};
lower = (nothing for _ = rxn_ids),
upper = (nothing for _ = rxn_ids),
)
Change the specified reaction flux bounds in the model and return the modified model.
Example
change_bounds(model, ["ReactionA", "ReactionC"], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_objective!
— Methodchange_objective!(model::CoreModel, rxn_idx::Int64)
Change objective function of a CoreModel to a single 1
at reaction index rxn_idx
.
COBREXA.change_objective!
— Methodchange_objective!(model::CoreModel, rxn_id::String)
Change objective function of a CoreModel to a single 1
at the given reaction ID.
COBREXA.change_objective!
— Methodchange_objective!(model::CoreModel, rxn_idxs::Vector{Int64}; weights)
Change the objective to reactions at given indexes, optionally specifying their weights
in the same order. By default, all set weights are 1.
COBREXA.change_objective!
— Methodchange_objective!(model::CoreModel, rxn_ids::Vector{String}; weights)
Change objective of given reaction IDs, optionally specifying objective weights
in the same order as rxn_ids
. By default, all set weights are 1.
COBREXA.remove_metabolite!
— Methodremove_metabolite!(model::CoreModel, metabolite_idx::Int)
Remove metabolite from the model of type CoreModel
in-place.
COBREXA.remove_metabolite!
— Methodremove_metabolite!(model::CoreModel, metabolite_id::String)
Remove metabolite from the model of type CoreModel
in-place.
COBREXA.remove_metabolite
— Methodremove_metabolite(model::CoreModel, metabolite_idx::Int)
Remove metabolite from the model of type CoreModel
and return the modified model.
COBREXA.remove_metabolite
— Methodremove_metabolite(model::CoreModel, metabolite_id::String)
Remove metabolite from the model of type CoreModel
and return the modified model.
COBREXA.remove_metabolites!
— Methodremove_metabolites!(model::CoreModel, metabolite_idxs::AbstractVector{Int64})
Remove metabolites from the model of type CoreModel
in-place.
COBREXA.remove_metabolites!
— Methodremove_metabolites!(model::CoreModel, metabolite_ids::AbstractVector{String})
Remove metabolites from the model of type CoreModel
in-place.
COBREXA.remove_metabolites
— Methodremove_metabolites(model::CoreModel, metabolite_idxs::AbstractVector{Int64})
Remove metabolites from the model of type CoreModel
and return the modified model.
COBREXA.remove_metabolites
— Methodremove_metabolites(model::CoreModel, metabolite_ids::AbstractVector{String})
Remove metabolites from the model of type CoreModel
and return the modified model.
COBREXA.remove_reaction!
— Methodremove_reaction!(model::CoreModel, reaction_idx::Int)
Remove reaction from the model of type CoreModel
in-place.
COBREXA.remove_reaction!
— Methodremove_reaction!(model::CoreModel, reaction_id::String)
Remove reaction from the model of type CoreModel
in-place.
COBREXA.remove_reaction
— Methodremove_reaction(model::CoreModel, reaction_idx::Int)
Remove reaction from the model of type CoreModel
and return the modified model.
COBREXA.remove_reaction
— Methodremove_reaction(model::CoreModel, reaction_id::String)
Remove reaction from the model of type CoreModel
and return the modified model.
COBREXA.remove_reactions!
— Methodremove_reactions!(model::CoreModel, reaction_idxs::AbstractVector{Int64})
Remove reactions from the model of type CoreModel
in-place.
COBREXA.remove_reactions!
— Methodremove_reactions!(model::CoreModel, reaction_ids::AbstractVector{String})
Remove reactions from the model of type CoreModel
in-place.
COBREXA.remove_reactions
— Methodremove_reactions(model::CoreModel, reaction_idxs::AbstractVector{Int64})
Remove reactions from the model of type CoreModel
and return the modified model.
COBREXA.remove_reactions
— Methodremove_reactions(model::CoreModel, reaction_ids::AbstractVector{String})
Remove reactions from the model of type CoreModel
and return the modified model.
COBREXA.verify_consistency
— Methodverify_consistency(m::CoreModel, Sp::AbstractMatrix{Float64}, b::AbstractVector{Float64}, c::AbstractVector{Float64}, xl::AbstractVector{Float64}, xu::AbstractVector{Float64}, names::AbstractVector{String}, mets::AbstractVector{String}, new_reactions, new_metabolites) -> Tuple{Any, Any}
Check the consistency of given reactions with existing reactions in m
.
TODO: work in progress, doesn't return consistency status.
COBREXA.add_coupling_constraints!
— Methodadd_coupling_constraints!(m::CoreCoupling, c::AbstractVector{Float64}, cl::AbstractFloat, cu::AbstractFloat)
Overload for adding a single coupling constraint.
COBREXA.add_coupling_constraints!
— Methodadd_coupling_constraints!(m::CoreCoupling, C::AbstractMatrix{Float64}, cl::AbstractVector{Float64}, cu::AbstractVector{Float64})
In-place add a single coupling constraint in form
cₗ ≤ C x ≤ cᵤ
COBREXA.add_coupling_constraints
— Methodadd_coupling_constraints(m::CoreCoupling, args...) -> CoreCoupling
Add constraints of the following form to CoreCoupling and return the modified model.
The arguments are same as for in-place add_coupling_constraints!
.
COBREXA.add_coupling_constraints
— Methodadd_coupling_constraints(m::CoreModel, args...) -> CoreModelCoupled
Add coupling constraints to a plain CoreModel
(returns a CoreModelCoupled
).
COBREXA.add_reactions
— Methodadd_reactions(m1::CoreModelCoupled, m2::CoreModel; check_consistency) -> CoreModelCoupled
Add all reactions from m2
to m1
.
COBREXA.add_reactions
— Methodadd_reactions(m::CoreModelCoupled, s::AbstractVector{Float64}, b::AbstractVector{Float64}, c::AbstractFloat, xl::AbstractFloat, xu::AbstractFloat, rxn::String, mets::AbstractVector{String}; check_consistency) -> CoreModelCoupled
COBREXA.add_reactions
— Methodadd_reactions(m::CoreModelCoupled, Sp::AbstractMatrix{Float64}, b::AbstractVector{Float64}, c::AbstractVector{Float64}, xl::AbstractVector{Float64}, xu::AbstractVector{Float64}, rxns::AbstractVector{String}, mets::AbstractVector{String}; check_consistency) -> CoreModelCoupled
COBREXA.add_reactions
— Methodadd_reactions(m::CoreModelCoupled, s::AbstractVector{Float64}, b::AbstractVector{Float64}, c::AbstractFloat, xl::AbstractFloat, xu::AbstractFloat; check_consistency) -> CoreModelCoupled
Add reaction(s) to a CoreModelCoupled
model m
.
COBREXA.add_reactions
— Methodadd_reactions(m::CoreModelCoupled, Sp::AbstractMatrix{Float64}, b::AbstractVector{Float64}, c::AbstractVector{Float64}, xl::AbstractVector{Float64}, xu::AbstractVector{Float64}; check_consistency) -> CoreModelCoupled
COBREXA.change_bound!
— Methodchange_bound!(
model::CoreCoupling,
rxn_idx::Int;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model in-place.
Example
new_model = change_bound!(model, 123, lower=-21.15, upper=42.3)
COBREXA.change_bound!
— Methodchange_bound!(
model::CoreCoupling,
rxn_id::String;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model in-place.
Example
new_model = change_bound!(model, "ReactionB", lower=-21.15, upper=42.3)
COBREXA.change_bound
— Methodchange_bound(
model::CoreCoupling,
rxn_idx::Int;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model and return the modified model.
Example
change_bound(model, 123, lower=-21.15, upper=42.3)
COBREXA.change_bound
— Methodchange_bound(
model::CoreCoupling,
rxn_id::String;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model and return the modified model.
Example
change_bound(model, "ReactionB", lower=-21.15, upper=42.3)
COBREXA.change_bounds!
— Methodchange_bounds!(
model::CoreCoupling,
rxn_idxs::AbstractVector{Int64};
lower = (nothing for _ = rxn_idxs),
upper = (nothing for _ = rxn_idxs),
)
Change the specified reaction flux bounds in the model in-place.
Example
new_model = change_bounds!(model, [123, 234], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_bounds!
— Methodchange_bounds!(
model::CoreCoupling,
rxn_ids::AbstractVector{String};
lower = (nothing for _ = rxn_ids),
upper = (nothing for _ = rxn_ids),
)
Change the specified reaction flux bounds in the model in-place.
Example
new_model = change_bounds!(model, ["ReactionA", "ReactionC"], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_bounds
— Methodchange_bounds(
model::CoreCoupling,
rxn_idxs::AbstractVector{Int64};
lower = (nothing for _ = rxn_idxs),
upper = (nothing for _ = rxn_idxs),
)
Change the specified reaction flux bounds in the model and return the modified model.
Example
change_bounds(model, [123, 234], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_bounds
— Methodchange_bounds(
model::CoreCoupling,
rxn_ids::AbstractVector{String};
lower = (nothing for _ = rxn_ids),
upper = (nothing for _ = rxn_ids),
)
Change the specified reaction flux bounds in the model and return the modified model.
Example
change_bounds(model, ["ReactionA", "ReactionC"], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_coupling_bounds!
— Methodchange_coupling_bounds!(model::CoreCoupling, constraints::Vector{Int64}; cl, cu)
Change the lower and/or upper bounds (cl
and cu
) for the given list of coupling constraints.
COBREXA.change_objective!
— Methodchange_objective!(model::CoreCoupling, args...; kwargs...) -> Any
Forwards arguments to change_objective!
of the internal model.
COBREXA.remove_coupling_constraints!
— Methodremove_coupling_constraints!(m::CoreCoupling, constraint::Int64)
Removes a single coupling constraints from a CoreCoupling
in-place.
COBREXA.remove_coupling_constraints!
— Methodremove_coupling_constraints!(m::CoreCoupling, constraints::Vector{Int64})
Removes a set of coupling constraints from a CoreCoupling
in-place.
COBREXA.remove_coupling_constraints
— Methodremove_coupling_constraints(m::CoreCoupling, args...) -> CoreCoupling
Remove coupling constraints from the linear model, and return the modified model. Arguments are the same as for in-place version remove_coupling_constraints!
.
COBREXA.remove_metabolite!
— Methodremove_metabolite!(model::CoreCoupling, metabolite_idx::Int)
Remove metabolite from the model of type CoreCoupling
in-place.
COBREXA.remove_metabolite!
— Methodremove_metabolite!(model::CoreCoupling, metabolite_id::String)
Remove metabolite from the model of type CoreCoupling
in-place.
COBREXA.remove_metabolite
— Methodremove_metabolite(model::CoreCoupling, metabolite_idx::Int)
Remove metabolite from the model of type CoreCoupling
and return the modified model.
COBREXA.remove_metabolite
— Methodremove_metabolite(model::CoreCoupling, metabolite_id::String)
Remove metabolite from the model of type CoreCoupling
and return the modified model.
COBREXA.remove_metabolites!
— Methodremove_metabolites!(model::CoreCoupling, metabolite_idxs::AbstractVector{Int64})
Remove metabolites from the model of type CoreCoupling
in-place.
COBREXA.remove_metabolites!
— Methodremove_metabolites!(model::CoreCoupling, metabolite_ids::AbstractVector{String})
Remove metabolites from the model of type CoreCoupling
in-place.
COBREXA.remove_metabolites
— Methodremove_metabolites(model::CoreCoupling, metabolite_idxs::AbstractVector{Int64})
Remove metabolites from the model of type CoreCoupling
and return the modified model.
COBREXA.remove_metabolites
— Methodremove_metabolites(model::CoreCoupling, metabolite_ids::AbstractVector{String})
Remove metabolites from the model of type CoreCoupling
and return the modified model.
COBREXA.remove_reaction!
— Methodremove_reaction!(model::CoreCoupling, reaction_idx::Int)
Remove reaction from the model of type CoreCoupling
in-place.
COBREXA.remove_reaction!
— Methodremove_reaction!(model::CoreCoupling, reaction_id::String)
Remove reaction from the model of type CoreCoupling
in-place.
COBREXA.remove_reaction
— Methodremove_reaction(model::CoreCoupling, reaction_idx::Int)
Remove reaction from the model of type CoreCoupling
and return the modified model.
COBREXA.remove_reaction
— Methodremove_reaction(model::CoreCoupling, reaction_id::String)
Remove reaction from the model of type CoreCoupling
and return the modified model.
COBREXA.remove_reactions!
— Methodremove_reactions!(model::CoreCoupling, reaction_idxs::AbstractVector{Int64})
Remove reactions from the model of type CoreCoupling
in-place.
COBREXA.remove_reactions!
— Methodremove_reactions!(model::CoreCoupling, reaction_ids::AbstractVector{String})
Remove reactions from the model of type CoreCoupling
in-place.
COBREXA.remove_reactions
— Methodremove_reactions(model::CoreCoupling, reaction_idxs::AbstractVector{Int64})
Remove reactions from the model of type CoreCoupling
and return the modified model.
COBREXA.remove_reactions
— Methodremove_reactions(model::CoreCoupling, reaction_ids::AbstractVector{String})
Remove reactions from the model of type CoreCoupling
and return the modified model.
COBREXA._Stoichiometry
— Typestruct _Stoichiometry
A small helper type for constructing reactions inline
Fields
s::Dict{String, Float64}
Base.:+
— Method+(a::Union{Metabolite, COBREXA._Stoichiometry}, b::Union{Metabolite, COBREXA._Stoichiometry}) -> COBREXA._Stoichiometry
Shorthand for metabolite1 + metabolite2
. Add 2 groups of Metabolite
s together to form reactions inline. Use with +
, *
, →
and similar operators.
COBREXA.:←
— Method←(substrates::Union{Nothing, Metabolite, COBREXA._Stoichiometry}, products::Union{Nothing, Metabolite, COBREXA._Stoichiometry}) -> Reaction
Shorthand for substrates ← products
. Make a reverse-only Reaction
from substrates
and products
.
COBREXA.:→
— Method→(substrates::Union{Nothing, Metabolite, COBREXA._Stoichiometry}, products::Union{Nothing, Metabolite, COBREXA._Stoichiometry}) -> Reaction
Shorthand for substrates → products
. Make a forward-only Reaction
from substrates
and products
.
COBREXA.:↔
— Method↔(substrates::Union{Nothing, Metabolite, COBREXA._Stoichiometry}, products::Union{Nothing, Metabolite, COBREXA._Stoichiometry}) -> Reaction
Shorthand for substrates ↔ products
. Make a bidirectional (reversible) Reaction
from substrates
and products
.
COBREXA._make_reaction_dict
— Method_make_reaction_dict(r, p) -> Dict{String, Float64}
COBREXA.add_reactions
— Methodadd_reactions(model::Serialized, ...)
Calls add_reactions
of the internal serialized model type. Returns the modified un-serialized model.
COBREXA.change_bound
— Methodchange_bound(model::Serialized, ...)
Calls change_bound
of the internal serialized model type. Returns the modified un-serialized model.
COBREXA.change_bounds
— Methodchange_bounds(model::Serialized, ...)
Calls change_bounds
of the internal serialized model type. Returns the modified un-serialized model.
COBREXA.remove_metabolite
— Methodremove_metabolite(model::Serialized, ...)
Calls remove_metabolite
of the internal serialized model type. Returns the modified un-serialized model.
COBREXA.remove_metabolites
— Methodremove_metabolites(model::Serialized, ...)
Calls remove_metabolites
of the internal serialized model type. Returns the modified un-serialized model.
COBREXA.remove_reaction
— Methodremove_reaction(model::Serialized, ...)
Calls remove_reaction
of the internal serialized model type. Returns the modified un-serialized model.
COBREXA.remove_reactions
— Methodremove_reactions(model::Serialized, ...)
Calls remove_reactions
of the internal serialized model type. Returns the modified un-serialized model.
COBREXA.unwrap_serialized
— Methodunwrap_serialized(model::Serialized) -> Union{Nothing, M} where M
Returns the model stored in the serialized structure.
COBREXA.add_gene!
— Methodadd_gene!(model::StandardModel, gene::Gene)
Add gene
to model
based on gene id
.
COBREXA.add_genes!
— Methodadd_genes!(model::StandardModel, genes::Vector{Gene})
Add genes
to model
based on gene id
.
COBREXA.add_metabolite!
— Methodadd_metabolite!(model::StandardModel, met::Metabolite)
Add met
to model
based on metabolite id
.
COBREXA.add_metabolites!
— Methodadd_metabolites!(model::StandardModel, mets::Vector{Metabolite})
Add mets
to model
based on metabolite id
.
COBREXA.add_reaction!
— Methodadd_reaction!(model::StandardModel, rxn::Reaction)
Add rxn
to model
based on reaction id
.
COBREXA.add_reactions!
— Methodadd_reactions!(model::StandardModel, rxns::Vector{Reaction})
Add rxns
to model
based on reaction id
.
COBREXA.change_bound!
— Methodchange_bound!(
model::StandardModel,
rxn_id::String;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model in-place.
Example
new_model = change_bound!(model, "ReactionB", lower=-21.15, upper=42.3)
COBREXA.change_bound
— Methodchange_bound(
model::StandardModel,
rxn_id::String;
lower = nothing,
upper = nothing,
)
Change the specified reaction flux bound in the model and return the modified model.
Example
change_bound(model, "ReactionB", lower=-21.15, upper=42.3)
COBREXA.change_bounds!
— Methodchange_bounds!(
model::StandardModel,
rxn_ids::AbstractVector{String};
lower = (nothing for _ = rxn_ids),
upper = (nothing for _ = rxn_ids),
)
Change the specified reaction flux bounds in the model in-place.
Example
new_model = change_bounds!(model, ["ReactionA", "ReactionC"], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_bounds
— Methodchange_bounds(
model::StandardModel,
rxn_ids::AbstractVector{String};
lower = (nothing for _ = rxn_ids),
upper = (nothing for _ = rxn_ids),
)
Change the specified reaction flux bounds in the model and return the modified model.
Example
change_bounds(model, ["ReactionA", "ReactionC"], lower=[-2.1, -50.05], upper=[4.2, 100.1])
COBREXA.change_objective!
— Methodchange_objective!(model::StandardModel, rxn_ids::Vector{String}; weights)
Change the objective for model
to reaction(s) with rxn_ids
, optionally specifying their weights
. By default, assume equal weights. If no objective exists in model, sets objective.
COBREXA.remove_gene!
— Methodremove_gene!(model::StandardModel, gid::String; knockout_reactions)
Remove gene with id
from model
. If knockout_reactions
is true, then also constrain reactions that require the genes to function to carry zero flux.
Example
remove_gene!(model, "g1")
COBREXA.remove_genes!
— Methodremove_genes!(model::StandardModel, gids::Vector{String}; knockout_reactions)
Remove all genes with ids
from model
. If knockout_reactions
is true, then also constrain reactions that require the genes to function to carry zero flux.
Example
remove_genes!(model, ["g1", "g2"])
COBREXA.remove_metabolite!
— Methodremove_metabolite!(model::StandardModel, metabolite_id::String)
Remove metabolite from the model of type StandardModel
in-place.
COBREXA.remove_metabolite
— Methodremove_metabolite(model::StandardModel, metabolite_id::String)
Remove metabolite from the model of type StandardModel
and return the modified model.
COBREXA.remove_metabolites!
— Methodremove_metabolites!(model::StandardModel, metabolite_ids::AbstractVector{String})
Remove metabolites from the model of type StandardModel
in-place.
COBREXA.remove_metabolites
— Methodremove_metabolites(model::StandardModel, metabolite_ids::AbstractVector{String})
Remove metabolites from the model of type StandardModel
and return the modified model.
COBREXA.remove_reaction!
— Methodremove_reaction!(model::StandardModel, reaction_id::String)
Remove reaction from the model of type StandardModel
in-place.
COBREXA.remove_reaction
— Methodremove_reaction(model::StandardModel, reaction_id::String)
Remove reaction from the model of type StandardModel
and return the modified model.
COBREXA.remove_reactions!
— Methodremove_reactions!(model::StandardModel, reaction_ids::AbstractVector{String})
Remove reactions from the model of type StandardModel
in-place.
COBREXA.remove_reactions
— Methodremove_reactions(model::StandardModel, reaction_ids::AbstractVector{String})
Remove reactions from the model of type StandardModel
and return the modified model.
COBREXA.@add_reactions!
— MacroShortcut to add multiple reactions and their lower and upper bounds
Call variants
@add_reactions! model begin
reaction_name, reaction
end
@add_reactions! model begin
reaction_name, reaction, lower_bound
end
@add_reactions! model begin
reaction_name, reaction, lower_bound, upper_bound
end
Examples
@add_reactions! model begin
"v1", nothing → A, 0, 500
"v2", A ↔ B + C, -500
"v3", B + C → nothing
end
COBREXA.add_community_objective!
— Methodadd_community_objective!(community::CoreModel, objective_mets_weights::Dict{String, Float64}; objective_id)
Add an objective column to the community
model with optional id objective_id
. Supply a dictionary mapping the string names of the objective metabolites to their weights in objective_mets_weights
. Note, the weights are negated inside the function so that positive weights are seen as reagents/substrates, NOT products in the reaction equation.
Example
add_community_objective!(model, Dict("met1"=>1.0, "met2"=>2.0))
See also: update_community_objective!
COBREXA.add_community_objective!
— Methodadd_community_objective!(community::StandardModel, objective_mets_weights::Dict{String, Float64}; objective_id)
Variant of [add_community_objective!
] that takes a StandardModel
community model as input.
COBREXA.add_model_with_exchanges!
— Methodadd_model_with_exchanges!(community::StandardModel, model::MetabolicModel, exchange_rxn_mets::Dict{String, String}; model_name, biomass_id)
The StandardModel
variant of add_model_with_exchanges
, but is in-place.
COBREXA.add_model_with_exchanges
— Methodadd_model_with_exchanges(community::CoreModel, model::MetabolicModel, exchange_rxn_mets::Dict{String, String}; model_name, biomass_id) -> CoreModel
Add model
to community
, which is a pre-existing community model with exchange reactions and metabolites in the dictionary exchange_rxn_mets
. The model_name
is appended to each reaction and metabolite, see join_with_exchanges
. If biomass_id
is specified then a biomass metabolite for model
is also added to the resulting model. The column corresponding to the biomass_id
reaction then produces this new biomass metabolite with unit coefficient. The exchange reactions and metabolites in exchange_rxn_mets
must already exist in community
. Always returns a new community model because it is more efficient than resizing all the matrices.
No in-place variant for CoreModel
s exists yet.
Example
community = add_model_with_exchanges(community,
model,
exchange_rxn_mets;
model_name="species_2",
biomass_id="BIOMASS_Ecoli_core_w_GAM")
COBREXA.add_model_with_exchanges
— Methodadd_model_with_exchanges(community::StandardModel, model::MetabolicModel, exchange_rxn_mets::Dict{String, String}; model_name, biomass_id) -> StandardModel
The StandardModel
variant of add_model_with_exchanges
. Makes a deepcopy of community
and calls the inplace variant of this function on that copy.
COBREXA.join_with_exchanges
— Methodjoin_with_exchanges(::Type{CoreModel}, models::Array{M<:MetabolicModel, 1}, exchange_rxn_mets::Dict{String, String}; biomass_ids, model_names) -> CoreModel
Return a CoreModel
representing the community model of models
joined through their exchange reactions and metabolites in the dictionary exchange_rxn_mets
, which maps exchange reactions to their associated metabolite. These exchange reactions and metabolites link model metabolites to environmental metabolites and reactions. Optionally specify model_names
to append a specific name to each reaction and metabolite of an organism for easier reference (default is species_i
for each model index i in models
). Note, the bounds of the environmental variables are all set to zero. Thus, to run a simulation you need to constrain them appropriately. All the other bounds are inherited from the models used to construct the community model.
If biomass_ids
is supplied, then a community model is returned that has an extra reaction added to the end of the stoichiometric matrix (last column) that can be assigned as the objective reaction. It also creates biomass "metabolites" that can be used in this objective reaction. In the returned mode, these biomass metabolites are produced by the reaction corresponding to biomass_ids
in each model respectively. Note, this reaction is unspecified, further action needs to be taken to specify it, e.g. assign weights to the last column of the stoichiometric matrix in the rows corresponding to the biomass metabolites.
To further clarify how this join
works. Suppose you have 2 organisms with stoichiometric matrices S₁ and S₂ and you want to link them with exchange_rxn_mets = Dict(er₁ => em₁, er₂ => em₂, er₃ => em₃, ...)
. Then a new community stoichiometric matrix is constructed that looks like this:
_ er₁ er₂ er₃ ... b_
|S₁ |
| S₂ |
em₁| |
S = em₂| |
em₃| |
...| |
bm₁| |
bm₂|_ _|
The exchange reactions in each model get linked to environmental metabolites, emᵢ
, and these get linked to environmental exchanges, erᵢ
. These erᵢ
behave like normal single organism exchange reactions. When biomass_ids
are supplied, each model's biomass reaction produces a pseudo-metabolite (bmᵢ
). These can be weighted in column b
, called the community_biomass
reaction in the community model, if desired. Refer to the tutorial if this is unclear.
Example
m1 = load_model(core_model_path)
m2 = load_model(CoreModel, core_model_path)
# need to list ALL the exchanges that will form part of the entire model
exchange_rxn_mets = Dict(k => first(keys(reaction_stoichiometry(m1, ex_rxn)))
for filter(looks_like_exchange_reaction, reactions(m1)))
biomass_ids = ["BIOMASS_Ecoli_core_w_GAM", "BIOMASS_Ecoli_core_w_GAM"]
community = join_with_exchanges(
CoreModel,
[m1, m2],
exchange_rxn_mets;
biomass_ids = biomass_ids,
)
COBREXA.join_with_exchanges
— Methodjoin_with_exchanges(::Type{StandardModel}, models::Array{M<:MetabolicModel, 1}, exchange_rxn_mets::Dict{String, String}; biomass_ids, model_names) -> StandardModel
A variant of join_with_exchanges
that returns a StandardModel
.
COBREXA.update_community_objective!
— Methodupdate_community_objective!(community::CoreModel, objective_id::String, objective_mets_weights::Dict{String, Float64})
Update the weights for the objective column with id objective_id
in community
using objective_mets_weights
, which maps metabolite ids to weights. The current weights are reset to 0 before being updated to the supplied weights. Note, the weights are negated inside the function so that the objective metabolites are seen as reagents/substrates, NOT products in the reaction equation.
Example
update_community_objective!(model, "community_biomass", Dict("met1"=>1.0, "met2"=>2.0))
See also: add_community_objective!
COBREXA.update_community_objective!
— Methodupdate_community_objective!(community::StandardModel, objective_id::String, objective_mets_weights::Dict{String, Float64})
Variant of [update_community_objective!
] that takes a StandardModel
community model as input.
COBREXA.with_gecko
— Methodwith_gecko(; kwargs...) -> COBREXA.var"#400#401"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Specifies a model variant which adds extra semantics of the Gecko algorithm, giving a GeckoModel
. The arguments are forwarded to make_gecko_model
. Intended for usage with screen
.
COBREXA.with_smoment
— Methodwith_smoment(; kwargs...) -> COBREXA.var"#397#398"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Specifies a model variant which adds extra semantics of the sMOMENT algorithm, giving a SMomentModel
. The arguments are forwarded to make_smoment_model
. Intended for usage with screen
.
COBREXA.with_expression_limits
— Methodwith_expression_limits(; kwargs...) -> COBREXA.var"#403#404"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Specifies a model variant which adds extra semantics of the ExpressionLimitedModel
, simulating the E-Flux algorithm. The arguments are forwarded to make_expression_limited_model
. Intended for usage with screen
.
COBREXA._universal_stoichiometry
— Method_universal_stoichiometry(urxns::Vector{Reaction}, mids::Vector{String}) -> NamedTuple{(:stoichiometry, :lbs, :ubs, :new_mids), Tuple{SparseArrays.SparseMatrixCSC{Float64, Int64}, Vector{Float64}, Vector{Float64}, Vector{String}}}
A helper function that constructs the stoichiometric matrix of a set of universal_reactions
. The order of the metabolites is determined with mids
, so that this stoichiometric matrix can be combined with another one.
COBREXA.gapfill_minimum_reactions
— Methodgapfill_minimum_reactions(model::MetabolicModel, universal_reactions::Vector{Reaction}, optimizer; objective_bounds, maximum_new_reactions, weights, modifications) -> JuMP.Model
Find a minimal set of reactions from universal_reactions
that should be added to model
so that the model has a feasible solution with bounds on its objective function given in objective_bounds
. Weights of the added reactions may be specified in weights
to prefer adding reactions with lower weights.
Internally, this builds and solves a mixed integer program, following the method of Reed et al. (Reed, Jennifer L., et al. "Systems approach to refining genome annotation." Proceedings of the National Academy of Sciences (2006)).
The function returns a solved JuMP optimization model, with the boolean reaction inclusion indicators in variable vector y
. Use gapfilled_mask
or gapfilled_rids
to collect the reaction information in Julia datatypes.
To reduce the uncertainty in the MILP solver (and likely reduce the complexity), you may put a limit on the size of the added reaction set in maximum_new_reactions
.
Common pitfalls
If gapfill_minimum_reactions
is supposed to generate any reasonable output, the input model MUST NOT be feasible, otherwise there is "no work to do" and no reactions are added. Notably, an inactive model (the flux is zero) is considered to be feasible. If this is the case, gapfilled_rids
will return an empty vector (as opposed to nothing
).
To prevent this, you may need to modify the model to disallow the trivial solutions (for example by putting a lower bound on reactions that you expect to be working in the solved model, in a similar manner like how the ATP maintenance reaction is bounded in E. Coli "core" model). The objective_bounds
parameter makes this easier by directly placing a bound on the objective value of the model, which typically forces the model to be active.
The maximum_new_reactions
parameter may have critical impact on performance in some solvers, because (in a general worst case) there is 2^maximum_new_reactions
model variants to be examined. Putting a hard limit on the reaction count may serve as a heuristic that helps the solver not to waste too much time solving impractically complex subproblems.
COBREXA.gapfilled_mask
— Methodgapfilled_mask(opt_model) -> BitVector
Get a BitVector
of added reactions from the model solved by gapfill_minimum_reactions
. The bit indexes correspond to the indexes of universal_reactions
given to the gapfilling function. In case the model is not solved, this returns nothing
.
If this function returns a zero vector (instead of nothing
), it is very likely that the original model was already feasible and you may need to constraint it more. Refer to "pitfalls" section in the documentation of gapfill_minimum_reactions
for more details.
Example
gapfill_minimum_reactions(myModel, myReactions, Tulip.Optimizer) |> gapfilled_mask
COBREXA.gapfilled_rids
— Methodgapfilled_rids(opt_model, universal_reactions::Vector{Reaction}) -> Vector{String}
Utility to extract a short vector of IDs of the reactions added by the gapfilling algorithm. Use with opt_model
returned from gapfill_minimum_reactions
.
If this function returns an empty vector (instead of nothing
), it is very likely that the original model was already feasible and you may need to constraint it more. Refer to "pitfalls" section in the documentation of gapfill_minimum_reactions
for more details.
COBREXA.gapfilled_rids
— Methodgapfilled_rids(universal_reactions::Vector{Reaction}) -> COBREXA.var"#414#415"{Vector{Reaction}}
Overload of gapfilled_rids
that can be piped easily.
Example
gapfill_minimum_reactions(myModel, myReactions, Tulip.Optimizer) |> gapfilled_rids(myReactions)
Variant specifiers
COBREXA.with_added_reactions
— Methodwith_added_reactions(args...; kwargs...) -> COBREXA.var"#448#449"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Specifies a model variant with reactions added. Forwards the arguments to add_reactions
. Intended to be used with screen
.
COBREXA.with_changed_bound
— Methodwith_changed_bound(args...; kwargs...) -> COBREXA.var"#436#437"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Specifies a model variant that has a new bound set. Forwards arguments to change_bound
. Intended for usage with screen
.
COBREXA.with_changed_bounds
— Methodwith_changed_bounds(args...; kwargs...) -> COBREXA.var"#439#440"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Specifies a model variant that has new bounds set. Forwards arguments to change_bounds
. Intended for usage with screen
.
COBREXA.with_removed_metabolite
— Methodwith_removed_metabolite(args...; kwargs...) -> COBREXA.var"#442#443"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Specifies a model variant without a certain metabolite. Forwards arguments to remove_metabolite
. Intended to be used with screen
.
COBREXA.with_removed_metabolites
— Methodwith_removed_metabolites(args...; kwargs...) -> COBREXA.var"#445#446"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Plural version of with_removed_metabolite
, calls remove_metabolites
internally.
COBREXA.with_removed_reaction
— Methodwith_removed_reaction(args...; kwargs...) -> COBREXA.var"#451#452"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Specifies a model variant without a certain reaction. Forwards arguments to remove_reaction
. Intended to be used with screen
.
COBREXA.with_removed_reactions
— Methodwith_removed_reactions(args...; kwargs...) -> COBREXA.var"#454#455"{Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}}}
Plural version of with_removed_reaction
, calls remove_reactions
internally.