Commit 308190aa authored by Miroslav Kratochvil's avatar Miroslav Kratochvil
Browse files

fixups vol 2

parent 09ad6a21
Pipeline #55037 failed with stages
in 10 minutes and 8 seconds
......@@ -90,19 +90,14 @@ function make_gecko_model(
end
end
coupling_row_mass_group =
collect(zip(coupling_row_mass_group, mass_fraction_limit.(coupling_row_mass_group)))
coupling_row_gene_product = collect(
zip(coupling_row_gene_product, gene_product_limit.(coupling_row_gene_product)),
)
return GeckoModel(
coupling_row_mass_group = return GeckoModel(
columns,
coupling_row_reaction,
coupling_row_gene_product,
coupling_row_mass_group,
model,
collect(
zip(coupling_row_gene_product, gene_product_limit.(coupling_row_gene_product)),
)collect(
zip(coupling_row_mass_group, mass_fraction_limit.(coupling_row_mass_group)),
)model,
)
end
......
......@@ -93,6 +93,7 @@ coupling(model::GeckoModel) = vcat(
coupling(model.inner) * _gecko_column_reactions(model),
_gecko_reaction_coupling(model),
_gecko_gene_product_coupling(model),
_gecko_mass_group_coupling(model),
)
"""
......@@ -104,7 +105,8 @@ Count the coupling constraints in [`GeckoModel`](@ref) (refer to
n_coupling_constraints(model::GeckoModel) =
n_coupling_constraints(model.inner) +
length(model.coupling_row_reaction) +
length(model.coupling_row_gene_product)
length(model.coupling_row_gene_product) +
length(model.coupling_row_mass_group)
"""
coupling_bounds(model::GeckoModel)
......@@ -120,33 +122,13 @@ function coupling_bounds(model::GeckoModel)
iclb,
ilb[model.coupling_row_reaction],
[0.0 for _ in model.coupling_row_gene_product],
[0.0 for _ in model.coupling_row_mass_group],
),
vcat(
icub,
rub[model.coupling_row_reaction],
[c for (i, c) in model.coupling_row_gene_product],
[c for (i, c) in model.coupling_row_mass_group],
),
)
end
"""
reaction_flux(model::GeckoModel)
Helper function to get fluxes from optimization problem.
"""
function reaction_flux(model::GeckoModel)
R = spzeros(n_fluxes(model), n_genes(model) + n_reactions(model))
for (i, rid) in enumerate(fluxes(model))
for_idx = findfirst(
x -> x == rid * "§ARM§FOR" || x == rid * "§FOR",
model.irrev_reaction_ids,
)
rev_idx = findfirst(
x -> x == rid * "§ARM§REV" || x == rid * "§REV",
model.irrev_reaction_ids,
)
!isnothing(for_idx) && (R[i, for_idx] = 1.0)
!isnothing(rev_idx) && (R[i, rev_idx] = -1.0)
end
return R'
end
......@@ -28,13 +28,20 @@ _smoment_column_reactions(model::SMomentModel) = sparse(
Compute the part of the coupling for [`SMomentModel`](@ref) that limits the
"arm" reactions (which group the individual split unidirectional reactions).
"""
_smoment_reaction_coupling(model::SMomentModel) = sparse(
[col.coupling_row for col in model.columns if col.direction != 0],
[i for (i, col) in enumerate(model.columns) if col.direction != 0],
[col.direction for col in model.columns if col.direction != 0],
length(model.coupling_row_reaction),
length(model.columns),
)
_smoment_reaction_coupling(model::SMomentModel) =
let tmp = [
(col.coupling_row, i, col.direction) for
(i, col) = enumerate(model.columns) if col.direction != 0
]
sparse(
[row for (row, _, _) in tmp],
[col for (_, col, _) in tmp],
[val for (_, _, val) in tmp],
length(model.coupling_row_reaction),
length(model.columns),
)
end
"""
smoment_isozyme_speed(isozyme::Isozyme, gene_product_molar_mass)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment