Skip to content
Snippets Groups Projects
Commit 486efbb9 authored by Miroslav Kratochvil's avatar Miroslav Kratochvil :bicyclist:
Browse files

consistent arg order for `fix_mass_balanced`

...together with the other commits in this branch, this:

Closes #330
parent d7c31b25
No related branches found
No related tags found
No related merge requests found
...@@ -175,8 +175,8 @@ check_duplicate_reaction(pgm_duplicate, model.reactions; only_metabolites = fals ...@@ -175,8 +175,8 @@ check_duplicate_reaction(pgm_duplicate, model.reactions; only_metabolites = fals
# ## Checking the internals of `StandardModel`s: `is_mass_balanced` # ## Checking the internals of `StandardModel`s: `is_mass_balanced`
# Finally, `is_mass_balanced` can be used to check if a reaction is mass # Finally, [`is_mass_balanced`](@ref) can be used to check if a reaction is mass
# balanced based on the formulas of the reaction equation. # balanced based on the formulas of the reaction equation.
pgm_duplicate.metabolites = Dict{String,Float64}("3pg_c" => 1, "2pg_c" => -1, "h2o_c" => 1) # not mass balanced now pgm_duplicate.metabolites = Dict{String,Float64}("3pg_c" => 1, "2pg_c" => -1, "h2o_c" => 1) # not mass balanced now
is_bal, extra_atoms = is_mass_balanced(pgm_duplicate, model) # extra_atoms shows which atoms are in excess/deficit is_bal, extra_atoms = is_mass_balanced(model, pgm_duplicate) # extra_atoms shows which atoms are in excess/deficit
...@@ -50,14 +50,14 @@ function is_boundary(rxn::Reaction)::Bool ...@@ -50,14 +50,14 @@ function is_boundary(rxn::Reaction)::Bool
end end
""" """
is_mass_balanced(rxn::Reaction, model::StandardModel) is_mass_balanced(model::StandardModel, rxn::Reaction)
Checks if `rxn` is atom balanced. Returns a boolean for whether the reaction is balanced, Checks if `rxn` is atom balanced. Returns a boolean for whether the reaction is balanced,
and the associated balance of atoms for convenience (useful if not balanced). and the associated balance of atoms for convenience (useful if not balanced).
See also: [`get_atoms`](@ref), [`check_duplicate_reaction`](@ref) See also: [`get_atoms`](@ref), [`check_duplicate_reaction`](@ref)
""" """
function is_mass_balanced(rxn::Reaction, model::StandardModel) function is_mass_balanced(model::StandardModel, rxn::Reaction)
atom_balances = Dict{String,Float64}() # float here because stoichiometry is not Int atom_balances = Dict{String,Float64}() # float here because stoichiometry is not Int
for (met, stoich) in rxn.metabolites for (met, stoich) in rxn.metabolites
atoms = metabolite_formula(model, met) atoms = metabolite_formula(model, met)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment