Model construction functions

Functions for changing the models

COBREXA.add_reaction!Method
add_reaction!(model::CoreModel, rxn::Reaction)

Add rxn to model. The model must already contain the metabolites used by rxn in the model.

source
COBREXA.add_reactions!Method
add_reactions!(model::CoreModel, rxns::Vector{Reaction})

Add rxns to model efficiently. The model must already contain the metabolites used by rxns in the model.

source
COBREXA.add_reactionsMethod
add_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}}
source
COBREXA.add_reactionsMethod
add_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}}
source
COBREXA.add_reactionsMethod
add_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}}
source
COBREXA.add_reactionsMethod
add_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.

source
COBREXA.add_reactionsMethod
add_reactions(m1::CoreModel, m2::CoreModel; check_consistency) -> Union{CoreModel, Tuple{CoreModel, Vector{Int64}, Vector{Int64}}}

Add all reactions from m2 to m1.

source
COBREXA.change_bound!Method
change_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)
source
COBREXA.change_bound!Method
change_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)
source
COBREXA.change_boundMethod
change_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)
source
COBREXA.change_boundMethod
change_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)
source
COBREXA.change_bounds!Method
change_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])
source
COBREXA.change_bounds!Method
change_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])
source
COBREXA.change_boundsMethod
change_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])
source
COBREXA.change_boundsMethod
change_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])
source
COBREXA.change_objective!Method
change_objective!(model::CoreModel, rxn_idx::Int64)

Change objective function of a CoreModel to a single 1 at reaction index rxn_idx.

source
COBREXA.change_objective!Method
change_objective!(model::CoreModel, rxn_id::String)

Change objective function of a CoreModel to a single 1 at the given reaction ID.

source
COBREXA.change_objective!Method
change_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.

source
COBREXA.change_objective!Method
change_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.

source
COBREXA.remove_metabolite!Method
remove_metabolite!(model::CoreModel, metabolite_idx::Int)

Remove metabolite from the model of type CoreModel in-place.

source
COBREXA.remove_metabolite!Method
remove_metabolite!(model::CoreModel, metabolite_id::String)

Remove metabolite from the model of type CoreModel in-place.

source
COBREXA.remove_metaboliteMethod
remove_metabolite(model::CoreModel, metabolite_idx::Int)

Remove metabolite from the model of type CoreModel and return the modified model.

source
COBREXA.remove_metaboliteMethod
remove_metabolite(model::CoreModel, metabolite_id::String)

Remove metabolite from the model of type CoreModel and return the modified model.

source
COBREXA.remove_metabolites!Method
remove_metabolites!(model::CoreModel, metabolite_idxs::AbstractVector{Int64})

Remove metabolites from the model of type CoreModel in-place.

source
COBREXA.remove_metabolites!Method
remove_metabolites!(model::CoreModel, metabolite_ids::AbstractVector{String})

Remove metabolites from the model of type CoreModel in-place.

source
COBREXA.remove_metabolitesMethod
remove_metabolites(model::CoreModel, metabolite_idxs::AbstractVector{Int64})

Remove metabolites from the model of type CoreModel and return the modified model.

source
COBREXA.remove_metabolitesMethod
remove_metabolites(model::CoreModel, metabolite_ids::AbstractVector{String})

Remove metabolites from the model of type CoreModel and return the modified model.

source
COBREXA.remove_reaction!Method
remove_reaction!(model::CoreModel, reaction_idx::Int)

Remove reaction from the model of type CoreModel in-place.

source
COBREXA.remove_reaction!Method
remove_reaction!(model::CoreModel, reaction_id::String)

Remove reaction from the model of type CoreModel in-place.

source
COBREXA.remove_reactionMethod
remove_reaction(model::CoreModel, reaction_idx::Int)

Remove reaction from the model of type CoreModel and return the modified model.

source
COBREXA.remove_reactionMethod
remove_reaction(model::CoreModel, reaction_id::String)

Remove reaction from the model of type CoreModel and return the modified model.

source
COBREXA.remove_reactions!Method
remove_reactions!(model::CoreModel, reaction_idxs::AbstractVector{Int64})

Remove reactions from the model of type CoreModel in-place.

source
COBREXA.remove_reactions!Method
remove_reactions!(model::CoreModel, reaction_ids::AbstractVector{String})

Remove reactions from the model of type CoreModel in-place.

source
COBREXA.remove_reactionsMethod
remove_reactions(model::CoreModel, reaction_idxs::AbstractVector{Int64})

Remove reactions from the model of type CoreModel and return the modified model.

source
COBREXA.remove_reactionsMethod
remove_reactions(model::CoreModel, reaction_ids::AbstractVector{String})

Remove reactions from the model of type CoreModel and return the modified model.

source
COBREXA.verify_consistencyMethod
verify_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.

source
COBREXA.add_coupling_constraints!Method
add_coupling_constraints!(m::CoreCoupling, c::AbstractVector{Float64}, cl::AbstractFloat, cu::AbstractFloat)

Overload for adding a single coupling constraint.

source
COBREXA.add_coupling_constraints!Method
add_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ᵤ
source
COBREXA.add_reactionsMethod
add_reactions(m1::CoreModelCoupled, m2::CoreModel; check_consistency) -> CoreModelCoupled

Add all reactions from m2 to m1.

source
COBREXA.add_reactionsMethod
add_reactions(m::CoreModelCoupled, s::AbstractVector{Float64}, b::AbstractVector{Float64}, c::AbstractFloat, xl::AbstractFloat, xu::AbstractFloat, rxn::String, mets::AbstractVector{String}; check_consistency) -> CoreModelCoupled
source
COBREXA.add_reactionsMethod
add_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
source
COBREXA.add_reactionsMethod
add_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.

source
COBREXA.add_reactionsMethod
add_reactions(m::CoreModelCoupled, Sp::AbstractMatrix{Float64}, b::AbstractVector{Float64}, c::AbstractVector{Float64}, xl::AbstractVector{Float64}, xu::AbstractVector{Float64}; check_consistency) -> CoreModelCoupled
source
COBREXA.change_bound!Method
change_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)
source
COBREXA.change_bound!Method
change_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)
source
COBREXA.change_boundMethod
change_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)
source
COBREXA.change_boundMethod
change_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)
source
COBREXA.change_bounds!Method
change_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])
source
COBREXA.change_bounds!Method
change_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])
source
COBREXA.change_boundsMethod
change_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])
source
COBREXA.change_boundsMethod
change_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])
source
COBREXA.change_coupling_bounds!Method
change_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.

source
COBREXA.remove_metabolite!Method
remove_metabolite!(model::CoreCoupling, metabolite_idx::Int)

Remove metabolite from the model of type CoreCoupling in-place.

source
COBREXA.remove_metabolite!Method
remove_metabolite!(model::CoreCoupling, metabolite_id::String)

Remove metabolite from the model of type CoreCoupling in-place.

source
COBREXA.remove_metaboliteMethod
remove_metabolite(model::CoreCoupling, metabolite_idx::Int)

Remove metabolite from the model of type CoreCoupling and return the modified model.

source
COBREXA.remove_metaboliteMethod
remove_metabolite(model::CoreCoupling, metabolite_id::String)

Remove metabolite from the model of type CoreCoupling and return the modified model.

source
COBREXA.remove_metabolites!Method
remove_metabolites!(model::CoreCoupling, metabolite_idxs::AbstractVector{Int64})

Remove metabolites from the model of type CoreCoupling in-place.

source
COBREXA.remove_metabolites!Method
remove_metabolites!(model::CoreCoupling, metabolite_ids::AbstractVector{String})

Remove metabolites from the model of type CoreCoupling in-place.

source
COBREXA.remove_metabolitesMethod
remove_metabolites(model::CoreCoupling, metabolite_idxs::AbstractVector{Int64})

Remove metabolites from the model of type CoreCoupling and return the modified model.

source
COBREXA.remove_metabolitesMethod
remove_metabolites(model::CoreCoupling, metabolite_ids::AbstractVector{String})

Remove metabolites from the model of type CoreCoupling and return the modified model.

source
COBREXA.remove_reaction!Method
remove_reaction!(model::CoreCoupling, reaction_idx::Int)

Remove reaction from the model of type CoreCoupling in-place.

source
COBREXA.remove_reaction!Method
remove_reaction!(model::CoreCoupling, reaction_id::String)

Remove reaction from the model of type CoreCoupling in-place.

source
COBREXA.remove_reactionMethod
remove_reaction(model::CoreCoupling, reaction_idx::Int)

Remove reaction from the model of type CoreCoupling and return the modified model.

source
COBREXA.remove_reactionMethod
remove_reaction(model::CoreCoupling, reaction_id::String)

Remove reaction from the model of type CoreCoupling and return the modified model.

source
COBREXA.remove_reactions!Method
remove_reactions!(model::CoreCoupling, reaction_idxs::AbstractVector{Int64})

Remove reactions from the model of type CoreCoupling in-place.

source
COBREXA.remove_reactions!Method
remove_reactions!(model::CoreCoupling, reaction_ids::AbstractVector{String})

Remove reactions from the model of type CoreCoupling in-place.

source
COBREXA.remove_reactionsMethod
remove_reactions(model::CoreCoupling, reaction_idxs::AbstractVector{Int64})

Remove reactions from the model of type CoreCoupling and return the modified model.

source
COBREXA.remove_reactionsMethod
remove_reactions(model::CoreCoupling, reaction_ids::AbstractVector{String})

Remove reactions from the model of type CoreCoupling and return the modified model.

source
COBREXA._StoichiometryType
struct _Stoichiometry

A small helper type for constructing reactions inline

Fields

  • s::Dict{String, Float64}
source
Base.:+Method
+(a::Union{Metabolite, COBREXA._Stoichiometry}, b::Union{Metabolite, COBREXA._Stoichiometry}) -> COBREXA._Stoichiometry

Shorthand for metabolite1 + metabolite2. Add 2 groups of Metabolites together to form reactions inline. Use with +, *, and similar operators.

source
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.

source
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.

source
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.

source
COBREXA.unwrap_serializedMethod
unwrap_serialized(model::Serialized) -> Union{Nothing, M} where M

Returns the model stored in the serialized structure.

source
COBREXA.add_genes!Method
add_genes!(model::StandardModel, genes::Vector{Gene})

Add genes to model based on gene id.

source
COBREXA.change_bound!Method
change_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)
source
COBREXA.change_boundMethod
change_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)
source
COBREXA.change_bounds!Method
change_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])
source
COBREXA.change_boundsMethod
change_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])
source
COBREXA.change_objective!Method
change_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.

source
COBREXA.remove_gene!Method
remove_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")
source
COBREXA.remove_genes!Method
remove_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"])
source
COBREXA.remove_metabolite!Method
remove_metabolite!(model::StandardModel, metabolite_id::String)

Remove metabolite from the model of type StandardModel in-place.

source
COBREXA.remove_metaboliteMethod
remove_metabolite(model::StandardModel, metabolite_id::String)

Remove metabolite from the model of type StandardModel and return the modified model.

source
COBREXA.remove_metabolites!Method
remove_metabolites!(model::StandardModel, metabolite_ids::AbstractVector{String})

Remove metabolites from the model of type StandardModel in-place.

source
COBREXA.remove_metabolitesMethod
remove_metabolites(model::StandardModel, metabolite_ids::AbstractVector{String})

Remove metabolites from the model of type StandardModel and return the modified model.

source
COBREXA.remove_reaction!Method
remove_reaction!(model::StandardModel, reaction_id::String)

Remove reaction from the model of type StandardModel in-place.

source
COBREXA.remove_reactionMethod
remove_reaction(model::StandardModel, reaction_id::String)

Remove reaction from the model of type StandardModel and return the modified model.

source
COBREXA.remove_reactions!Method
remove_reactions!(model::StandardModel, reaction_ids::AbstractVector{String})

Remove reactions from the model of type StandardModel in-place.

source
COBREXA.remove_reactionsMethod
remove_reactions(model::StandardModel, reaction_ids::AbstractVector{String})

Remove reactions from the model of type StandardModel and return the modified model.

source
COBREXA.@add_reactions!Macro

Shortcut 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
source
COBREXA.add_community_objective!Method
add_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!

source
COBREXA.add_community_objective!Method
add_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.

source
COBREXA.add_model_with_exchangesMethod
add_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 CoreModels exists yet.

Example

community = add_model_with_exchanges(community,
    model,
    exchange_rxn_mets;
    model_name="species_2",
    biomass_id="BIOMASS_Ecoli_core_w_GAM")
source
COBREXA.add_model_with_exchangesMethod
add_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.

source
COBREXA.join_with_exchangesMethod
join_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,
)
source
COBREXA.join_with_exchangesMethod
join_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.

source
COBREXA.update_community_objective!Method
update_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!

source
COBREXA.update_community_objective!Method
update_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.

source
COBREXA.with_geckoMethod
with_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.

source
COBREXA.with_smomentMethod
with_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.

source
COBREXA._universal_stoichiometryMethod
_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.

source
COBREXA.gapfill_minimum_reactionsMethod
gapfill_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.

source
COBREXA.gapfilled_maskMethod
gapfilled_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
source
COBREXA.gapfilled_ridsMethod
gapfilled_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.

source
COBREXA.gapfilled_ridsMethod
gapfilled_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)
source

Variant specifiers

COBREXA.with_added_reactionsMethod
with_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.

source
COBREXA.with_changed_boundMethod
with_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.

source
COBREXA.with_changed_boundsMethod
with_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.

source
COBREXA.with_removed_metaboliteMethod
with_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.

source
COBREXA.with_removed_reactionMethod
with_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.

source