Unverified Commit 0081b9b2 authored by St. Elmo's avatar St. Elmo Committed by GitHub
Browse files

Merge pull request #213 from LCSB-BioCore/mo-better-errors

Add error message
parents a0564590 09bba8ed
...@@ -30,7 +30,7 @@ mutable struct CoreModel <: MetabolicModel ...@@ -30,7 +30,7 @@ mutable struct CoreModel <: MetabolicModel
) where {V<:VecType,M<:MatType,K<:StringVecType} ) where {V<:VecType,M<:MatType,K<:StringVecType}
all([length(b), length(mets)] .== size(S, 1)) || all([length(b), length(mets)] .== size(S, 1)) ||
throw(DimensionMismatch("inconsistent number of reactions")) throw(DimensionMismatch("inconsistent number of metabolites"))
all([length(c), length(xl), length(xu), length(rxns)] .== size(S, 2)) || all([length(c), length(xl), length(xu), length(rxns)] .== size(S, 2)) ||
throw(DimensionMismatch("inconsistent number of reactions")) throw(DimensionMismatch("inconsistent number of reactions"))
......
...@@ -108,6 +108,14 @@ function stoichiometry(model::StandardModel)::SparseMat ...@@ -108,6 +108,14 @@ function stoichiometry(model::StandardModel)::SparseMat
for (i, rxn_id) in enumerate(rxn_ids) # column, in order for (i, rxn_id) in enumerate(rxn_ids) # column, in order
for (met_id, coeff) in model.reactions[rxn_id].metabolites for (met_id, coeff) in model.reactions[rxn_id].metabolites
j = findfirst(==(met_id), met_ids) # row j = findfirst(==(met_id), met_ids) # row
if isnothing(j)
throw(
DomainError(
met_id,
"Metabolite not found in model but occurs in stoichiometry of $(rxn_id). Perhaps it was deleted?",
),
)
end
S[j, i] = coeff S[j, i] = coeff
end end
end end
......
Markdown is supported
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