LCSB-BioCore / COBREXA.jl

Constraint-Based Reconstruction and EXascale Analysis
https://lcsb-biocore.github.io/COBREXA.jl/
Apache License 2.0
42 stars 8 forks source link

🚸 💄 Informative error message when reaction is not found #319

Closed stelmo closed 3 years ago

stelmo commented 3 years ago

I ran this:

model = load_model(joinpath("modelfiles", "e_coli_core.json"))

fva_mins, fva_maxs = flux_variability_analysis_dict(
    model,
    Gurobi.Optimizer;
    bounds = objective_bounds(0.99),
    modifications = [
        change_optimizer_attribute("OutputFlag", 0),
        change_constraint("R_EX_glc__D_e", -10, 1000),
        change_constraint("EX_o2_e", 0.0, 0.0),
    ],
)

And got this error message:

Academic license - for non-commercial use only - expires 2021-07-25
ArgumentError: invalid index: nothing of type Nothing

Stacktrace:
  [1] to_index(i::Nothing)
    @ Base .\indices.jl:300
  [2] to_index(A::SparseArrays.SparseVector{Any, Int64}, i::Nothing)
    @ Base .\indices.jl:277
  [3] to_indices
    @ .\indices.jl:333 [inlined]
  [4] to_indices
    @ .\indices.jl:325 [inlined]
  [5] getindex(A::SparseArrays.SparseVector{Any, Int64}, I::Nothing)
    @ Base .\abstractarray.jl:1170
  [6] set_bound(vind::Nothing, opt_model::JuMP.Model; ub::Int64, lb::Int64)
    @ COBREXA C:\Users\St. Elmo\.julia\packages\COBREXA\Znogd\src\base\solver.jl:96
  [7] (::COBREXA.var"#185#186"{String, Int64, Int64})(model::JSONModel, opt_model::JuMP.Model)
    @ COBREXA C:\Users\St. Elmo\.julia\packages\COBREXA\Znogd\src\analysis\modifications\optimizer.jl:62
  [8] flux_balance_analysis(model::JSONModel, optimizer::Type; modifications::Vector{Function})
    @ COBREXA C:\Users\St. Elmo\.julia\packages\COBREXA\Znogd\src\analysis\flux_balance_analysis.jl:76
  [9] flux_variability_analysis(model::JSONModel, reactions::Vector{Int64}, optimizer::Type; modifications::Vector{Function}, workers::Vector{Int64}, bounds::COBREXA.var"#238#239"{Float64}, ret::Function)
    @ COBREXA C:\Users\St. Elmo\.julia\packages\COBREXA\Znogd\src\analysis\flux_variability_analysis.jl:60
 [10] flux_variability_analysis(model::JSONModel, optimizer::Type; kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol, Symbol}, NamedTuple{(:bounds, :modifications, :ret), Tuple{COBREXA.var"#238#239"{Float64}, Vector{Function}, COBREXA.var"#204#207"}}})
    @ COBREXA C:\Users\St. Elmo\.julia\packages\COBREXA\Znogd\src\analysis\flux_variability_analysis.jl:105
 [11] flux_variability_analysis_dict(model::JSONModel, optimizer::Type; kwargs::Base.Iterators.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:bounds, :modifications), Tuple{COBREXA.var"#238#239"{Float64}, Vector{Function}}}})
    @ COBREXA C:\Users\St. Elmo\.julia\packages\COBREXA\Znogd\src\analysis\flux_variability_analysis.jl:120
 [12] top-level scope
    @ In[20]:3
 [13] eval
    @ .\boot.jl:360 [inlined]
 [14] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
    @ Base .\loading.jl:1094

This is really not informative at all, is there a way to fix it?

stelmo commented 3 years ago

another error message:

glc + 2*atp + 2*pi + 2*nad ⟷ 2*adp + 2*dpg13 + 2*nadh

here pi is the number π but pi is often used as a name for phosphate... Make the error message better:

ERROR: MethodError: no method matching +(::Vector{MetaboliteWithCoefficient}, ::Float64)
Closest candidates are:
  +(::Any, ::Any, ::Any, ::Any...) at operators.jl:560
  +(::Union{VectorizationBase.AbstractMask{W, U} where U<:Union{UInt128, UInt16, UInt32, UInt64, UInt8}, VectorizationBase.VecUnroll{var"#s3", W, VectorizationBase.Bit, var"#s2"} where {var"#s3", var"#s2"<:(VectorizationBase.AbstractMask{W, U} where U<:Union{UInt128, UInt16, UInt32, UInt64, UInt8})}} where W, ::Union{Bool, Float32, Float64, Int16, Int32, Int64, Int8, UInt16, UInt32, UInt64, UInt8, VectorizationBase.Bit}) at C:\Users\St. Elmo\.julia\packages\VectorizationBase\y1g7W\src\base_defs.jl:282