COBREXA.jl icon indicating copy to clipboard operation
COBREXA.jl copied to clipboard

Conversion from MATModel produces opaque errors if fields are missing

Open htpusa opened this issue 2 years ago • 3 comments

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

htpusa avatar Dec 08 '22 10:12 htpusa

ok this should be improved. :]

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

exaexa avatar Dec 08 '22 11:12 exaexa

This should reproduce:

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

htpusa avatar Dec 08 '22 11:12 htpusa

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

stelmo avatar Dec 18 '22 10:12 stelmo