LCSB-BioCore / COBREXA.jl

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

Conversion from MATModel produces opaque errors if fields are missing #709

Open htpusa opened 1 year ago

htpusa commented 1 year ago
julia> m = load_model("model.mat") # model has no metCharge field
julia> convert(StandardModel,m)
ERROR: MethodError: no method matching isnan(::Nothing)
Closest candidates are:
  isnan(::Complex) at /Applications/Julia-1.7.app/Contents/Resources/julia/share/julia/base/complex.jl:147
  isnan(::FixedPointNumbers.FixedPoint) at ~/.julia/packages/FixedPointNumbers/HAGk2/src/FixedPointNumbers.jl:103
  isnan(::ColorTypes.Colorant) at ~/.julia/packages/ColorTypes/1dGw6/src/traits.jl:453
  ...
Stacktrace:
 [1] metabolite_charge(m::COBREXA.MATModel, mid::String)
   @ COBREXA ~/.julia/packages/COBREXA/28ssY/src/base/types/MATModel.jl:163
 [2] convert(#unused#::Type{COBREXA.StandardModel}, model::COBREXA.MATModel)
   @ COBREXA ~/.julia/packages/COBREXA/28ssY/src/base/types/StandardModel.jl:340
 [3] top-level scope
   @ none:1
exaexa commented 1 year ago

ok this should be improved. :]

Is the model available somewhere? (to make a test case)

htpusa commented 1 year ago

This should reproduce:

https://github.com/htpusa/moomin.jl/blob/master/test/data/toyModel.mat

stelmo commented 1 year ago

Same issue with JSONModels happens. If a model has nothing for notes the conversion to ObjectModel breaks