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::MatType,
    b::VecType,
    c::VecType,
    xl::VecType,
    xu::VecType,
    rxns::StringVecType,
    mets::StringVecType;
    check_consistency = false,
)
source
COBREXA.add_reactionsMethod
add_reactions(
    m::CoreModel,
    Sp::MatType,
    b::VecType,
    c::VecType,
    xl::VecType,
    xu::VecType;
    check_consistency = false,
)
source
COBREXA.add_reactionsMethod
add_reactions(
    m::CoreModel,
    s::VecType,
    b::VecType,
    c::AbstractFloat,
    xl::AbstractFloat,
    xu::AbstractFloat,
    rxn::String,
    mets::K;
    check_consistency = false,
)
source
COBREXA.add_reactionsMethod
add_reactions(
    m::CoreModel,
    s::VecType,
    b::VecType,
    c::AbstractFloat,
    xl::AbstractFloat,
    xu::AbstractFloat;
    check_consistency = false,
)

Add reaction(s) to a CoreModel model m.

source
COBREXA.add_reactionsMethod
add_reactions(m1::CoreModel, m2::CoreModel; check_consistency = false)

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::Int)

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{Int};
    weights = ones(length(rxn_idxs)),
)

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 = ones(length(rxn_ids)),
)

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::M,
    b::V,
    c::V,
    xl::B,
    xu::B,
    names::K,
    mets::K,
    new_reactions,
    new_metabolites,
) where {M<:MatType,V<:VecType,B<:VecTypeK<:StringVecType}

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::CoreModelCoupled,
    c::VecType,
    cl::AbstractFloat,
    cu::AbstractFloat,
)

Overload for adding a single coupling constraint.

source
COBREXA.add_coupling_constraints!Method
add_coupling_constraints!(
    m::CoreModelCoupled,
    C::MatType,
    cl::V,
    cu::V,
) where {V<:VecType}

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 = false)

Add all reactions from m2 to m1.

source
COBREXA.add_reactionsMethod
add_reactions(
    m::CoreModelCoupled,
    s::V1,
    b::V2,
    c::AbstractFloat,
    xl::AbstractFloat,
    xu::AbstractFloat,
    rxn::String,
    mets::K;
    check_consistency = false,
) where {V1<:VecType,V2<:VecType,K<:StringVecType}
source
COBREXA.add_reactionsMethod
add_reactions(
    m::CoreModelCoupled,
    Sp::M,
    b::V,
    c::V,
    xl::V,
    xu::V,
    rxns::K,
    mets::K;
    check_consistency = false,
) where {M<:MatType,V<:VecType,K<:StringVecType}
source
COBREXA.add_reactionsMethod
add_reactions(
    m::CoreModelCoupled,
    s::V1,
    b::V2,
    c::AbstractFloat,
    xl::AbstractFloat,
    xu::AbstractFloat;
    check_consistency = false,
) where {V1<:VecType,V2<:VecType}

Add reaction(s) to a CoreModelCoupled model m.

source
COBREXA.add_reactionsMethod
add_reactions(
    m::CoreModelCoupled,
    Sp::M,
    b::V,
    c::V,
    xl::V,
    xu::V;
    check_consistency = false,
) where {M<:MatType,V<:VecType}
source
COBREXA.change_bound!Method
change_bound!(
    model::CoreModelCoupled,
    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::CoreModelCoupled,
    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::CoreModelCoupled,
    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::CoreModelCoupled,
    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::CoreModelCoupled,
    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::CoreModelCoupled,
    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::CoreModelCoupled,
    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::CoreModelCoupled,
    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::CoreModelCoupled,
    constraints::Vector{Int};
    cl::V = Float64[],
    cu::V = Float64[],
) where {V<:VecType}

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::CoreModelCoupled, metabolite_idx::Int)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

source
Base.:+Method
metabolite1 + metabolite2

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

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 = ones(length(rxn_ids)),
)

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,
    id::Vector{String};
    knockout_reactions::Bool = false,
)

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,
    ids::Vector{String};
    knockout_reactions::Bool = false,
)

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
@add_reactions!(model::Symbol, ex::Expr)

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 = "community_biomass",
)

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 = "community_biomass"
)

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 = "unknown_species",
    biomass_id = nothing,
)

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 = "unknown_species",
    biomass_id = nothing,
)

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::Vector{M},
    exchange_rxn_mets::Dict{String,String};
    biomass_ids = String[],
    model_names = String[],
) where {M<:MetabolicModel}

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::Vector{M},
    exchange_rxn_mets::Dict{String,String};
    biomass_ids = [],
    model_names = [],
)::StandardModel where {M<:MetabolicModel}

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

Variant specifiers