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

Problem converting RECON1 to core/standard model #563

Closed jchitpin closed 2 years ago

jchitpin commented 2 years ago

Minimal code example to reproduce the problem

using COBREXA

download("http://bigg.ucsd.edu/static/models/RECON1.json", "RECON1.json")
model = load_model("RECON1.json")

cm = convert(CoreModel, model)
sm = convert(StandardModel, model)

Expected result

Convert BiGG model to CoreModel and/or StandardModel. Not sure if this is an error with COBREXA or the RECON1 json input file.

Actual behavior

julia> using COBREXA

julia> download("http://bigg.ucsd.edu/static/models/RECON1.json", "RECON1.json")
"RECON1.json"

julia> model = load_model("RECON1.json")
Metabolic model of type JSONModel

⡰⣶⢻⠀⠄⢈⡖⠠⠀⠀⠆⠐⡂⠄⡄⠀⣷⣶⠀⠀⠀⠀⠀⠀⠀⠀⠀⣉⠁⢨⠂⠀⢠⢀⡤⠐⡁⠀⠀⠁⠀⣀⠐⠶⣖⢐⣒⡲⠳⠆⢀⠠⡄⠠⠀⠴⠀
⣆⣈⡿⡟⠄⡆⠠⠀⠄⠠⡀⢀⡠⠀⡂⠡⣫⣽⠀⠀⠀⠀⠀⠀⠀⠀⢰⠄⠀⢸⡃⣅⠄⢉⠀⢐⡢⠒⠪⢛⠀⠀⠀⡂⡕⠑⢕⡍⠁⠀⠐⡐⡂⠀⡐⠂⠍
⢻⠓⠹⡭⡄⣤⠌⢀⠠⠜⠂⡀⠀⢊⠀⠊⠟⢹⡄⠀⡠⠤⡤⢤⡤⡭⠪⠁⠆⠈⠁⠀⠡⠃⠇⠂⡥⠃⠇⣱⣄⢒⠌⠶⠉⣄⣠⢣⣁⣤⡑⡬⠇⠑⡆⡀⠐
⠾⡰⢸⣏⣻⣿⣿⠼⡘⣱⠊⠈⢸⡂⠁⠨⠈⢹⡇⠀⠁⠀⠀⠀⠋⡀⢴⡁⠀⠆⣍⣭⡉⢠⡄⠺⠍⡂⠀⢹⠯⢎⠄⣬⠶⠐⠊⠜⣓⠉⡰⡝⣣⡄⠗⠅⠂
⢘⣙⣈⠙⣛⢛⣿⣏⡏⠛⠙⣿⣽⢻⡛⡈⢙⠋⣇⢄⠀⢠⠠⣽⣩⣭⡙⢛⢉⠙⠈⣛⣋⢉⣛⣃⢋⠟⣓⣙⢻⢛⢝⣛⣽⠛⣯⣏⠍⠉⢁⢏⠫⢄⣚⠚⡉
⠘⠻⠸⢹⢛⠿⠗⠿⣿⡟⠗⡺⠟⡟⡗⠹⠚⠇⢹⡆⠁⠀⠀⢛⠩⢙⠛⠛⢗⠙⣘⠻⠓⠟⣽⠯⠂⠒⠛⡙⠒⠓⠏⢛⠚⠒⡺⣻⠛⢫⠛⣟⠛⠭⠺⡿⠗
⠰⠆⠀⠌⠀⠘⠀⢉⠒⡳⣖⠹⠳⣷⠄⡐⢀⠐⢘⡃⠀⠀⠂⠘⠆⠦⠀⠀⠸⠘⡇⢃⠀⠀⣃⠟⠄⠁⠀⠿⡙⣋⠼⠨⠢⠀⠀⠀⣿⢿⠰⠇⠠⠄⠀⠀⠀
⠜⣵⠀⠠⢠⢐⠖⠈⠭⠳⣿⡇⠈⢩⣿⡟⠸⡄⢸⡇⠀⠀⠀⠀⠠⢂⠦⡄⢀⢠⡔⠚⢜⣛⡠⠀⡄⡐⠒⠄⠀⣽⢵⠸⢠⡴⠐⠅⠉⣝⡂⠄⠠⠾⢃⢪⡆
⠈⠣⡀⠁⠀⠁⠀⢈⠂⠀⠟⠅⠠⠿⠙⢵⡀⠏⠀⣿⡀⠂⠂⠷⠲⠂⣀⡤⣄⣈⠈⠠⠨⠤⢰⠀⠀⠀⠈⠀⠈⠙⠩⢀⠚⠀⠒⠃⠀⠉⠀⣀⠂⢀⠈⡆⠁
⢀⠀⠐⠳⢁⡗⠸⠾⡐⣠⡎⠀⡁⠀⠂⣠⢃⠀⠀⢹⠗⠒⠒⠲⠖⡖⣷⣗⠿⣯⣐⡓⢁⠃⣖⣀⢢⣰⢢⠈⢑⡀⣀⢈⡆⠂⠺⠠⠀⡀⢈⠎⡶⠆⢀⣂⠀
⣠⣐⣐⣇⣠⣘⣪⣲⣧⣲⣀⣀⣀⣀⡀⣩⣈⠑⠀⡸⣆⠀⠀⢀⣀⣒⣿⣿⣗⣾⣿⣿⣶⣓⣡⣚⣇⣛⣉⣰⣂⣆⣁⣲⣗⣀⣚⣠⣀⣈⣲⣂⣱⣐⣞⢇⣩
⠙⠙⢙⢙⠙⠙⠍⢉⠟⢩⠝⢻⠛⠹⠃⠛⠛⠃⠀⠈⣿⡍⠉⢌⡟⡯⠉⠉⣙⢙⠿⠻⣝⡛⡟⡟⠋⠏⡋⠋⠛⠉⢝⠛⠟⠛⠻⡏⠹⠙⢻⠛⢻⡟⠙⢛⠛
⠘⠐⠒⠉⡊⠅⠠⠇⠄⡀⡠⠀⠁⠀⠀⢢⢀⠀⠀⠀⠙⡇⠀⠀⠒⠑⠀⢀⡆⠠⣨⢅⠻⣟⢮⣝⣎⠐⠎⡆⣾⠃⡅⠋⠀⠐⠐⡣⢠⢀⡦⡑⠅⠀⢛⠈⠘
⠀⠀⠀⠳⢺⢃⡠⡄⠀⠀⠈⡤⠀⠐⠄⡀⠀⠄⠀⠀⠀⢳⠄⠒⠐⠪⠈⢹⢫⡇⠄⠈⢠⣈⠀⢸⣬⣊⠤⣏⣯⣁⠁⠁⠀⠤⠄⠀⠃⢏⢫⡃⠁⠀⢀⠀⠀
⠀⠀⠀⢀⠁⢀⠀⠀⢂⡐⠀⢀⡀⢠⡀⠷⠰⠀⠀⠀⢐⢹⡇⣼⣠⢞⢀⠘⠉⠁⠁⡠⢰⢩⣀⣧⡉⣧⣿⡓⡉⠁⢂⣀⢒⣠⣈⣈⠁⠈⠀⠅⡀⠀⠂⠀⠀
⣩⣩⣛⡴⡫⢱⣾⣇⡧⢭⡰⠾⣠⢍⡅⡰⣬⡄⠀⠀⢸⡄⠃⢠⣠⣮⣤⢼⢮⣅⢭⣭⣬⣻⣆⣎⡼⣿⣟⣻⣩⣿⣧⣥⣆⣽⣕⣁⡀⢂⣥⣥⣤⢵⣥⣄⣩
⠯⢝⣘⣿⣛⡞⠛⣓⣿⡋⡂⢾⣋⡺⠅⢺⢿⡃⠀⠀⠨⣿⠩⣾⡟⣿⢚⢚⠒⡓⡰⣻⢿⢘⡛⡛⡍⡓⣛⡎⡑⣺⣛⣟⡻⣿⣿⣛⣽⢾⣮⣿⡛⢸⡂⣉⢳
⠆⠤⠀⠀⠀⡾⡆⢂⡍⢶⠀⠀⠪⠠⠄⠐⠤⠁⠀⠀⠀⢸⣃⠂⠁⢈⠅⠀⠀⠀⣀⢈⢈⠉⠞⡃⡔⠅⠲⠠⠲⣠⠐⢟⣷⢾⣝⢷⣄⠅⣃⠘⠄⢀⡀⠄⠄
⠃⢄⡀⠰⠀⢀⠁⣀⠀⢊⣠⢀⠀⢈⡄⠰⠀⠄⠀⠘⠀⠀⢹⠸⣤⢿⢘⣀⣄⢀⡉⠆⢁⠀⠔⠂⠁⡃⠀⠒⠀⠀⠄⠅⠄⠐⠉⠘⠟⢃⣻⣷⣏⣷⠁⠥⡠
⠠⠄⣬⡧⠤⠔⠋⣬⠀⡉⠀⠈⢠⠼⠀⠁⠀⠁⠀⠀⢀⠑⡼⡟⠻⢏⠊⢨⣤⡄⣭⠀⠀⢠⣄⠴⢧⠁⡀⢢⠤⠄⢑⠂⠶⢂⡀⠆⠀⠌⠉⠘⣟⢹⣿⡴⢯
⠠⠄⠀⠅⠀⠸⠣⠀⠈⠤⠠⠄⠄⠬⠄⠂⠀⠄⠀⠀⠀⠀⠈⠭⣽⠧⠊⠀⠀⠆⠈⠁⠈⠠⠈⠃⠇⠁⠀⠂⠈⠄⠯⠋⠈⢘⢁⠣⠀⠒⠀⠒⠈⠈⠭⣿⠏
Number of reactions: 3741
Number of metabolites: 2766

julia> cm = convert(CoreModel, model)
ERROR: DomainError with 1594_AT1:
Could not parse GRR
Stacktrace:
  [1] (::COBREXA.var"#fail#504"{String})()
    @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/utils/gene_associations.jl:72
  [2] _parse_grr_to_sbml(str::String)
    @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/utils/gene_associations.jl:109
  [3] _parse_grr(s::String)
    @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/utils/gene_associations.jl:52
  [4] _maybemap(f::typeof(COBREXA._parse_grr), x::String)
    @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/types/abstract/Maybe.jl:24
  [5] reaction_gene_association(model::JSONModel, rid::String)
    @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/types/JSONModel.jl:166
  [6] #9
    @ ./array.jl:0 [inlined]
  [7] iterate
    @ ./generator.jl:47 [inlined]
  [8] collect_to!(dest::Vector{Nothing}, itr::Base.Generator{Vector{String}, COBREXA.var"#9#10"{JSONModel}}, offs::Int64, st::Int64)
    @ Base ./array.jl:728
  [9] collect_to_with_first!
    @ ./array.jl:706 [inlined]
 [10] collect(itr::Base.Generator{Vector{String}, COBREXA.var"#9#10"{JSONModel}})
    @ Base ./array.jl:687
 [11] convert(#unused#::Type{CoreModel}, m::JSONModel)
    @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/types/CoreModel.jl:141
 [12] top-level scope
    @ REPL[474]:1

julia>

julia> sm = convert(StandardModel, model)
ERROR: DomainError with 1594_AT1:
Could not parse GRR
Stacktrace:
 [1] (::COBREXA.var"#fail#504"{String})()
   @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/utils/gene_associations.jl:72
 [2] _parse_grr_to_sbml(str::String)
   @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/utils/gene_associations.jl:109
 [3] _parse_grr(s::String)
   @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/utils/gene_associations.jl:52
 [4] _maybemap(f::typeof(COBREXA._parse_grr), x::String)
   @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/types/abstract/Maybe.jl:24
 [5] reaction_gene_association(model::JSONModel, rid::String)
   @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/types/JSONModel.jl:166
 [6] convert(#unused#::Type{StandardModel}, model::JSONModel)
   @ COBREXA ~/.julia/packages/COBREXA/Od0XR/src/base/types/StandardModel.jl:341
 [7] top-level scope
   @ REPL[475]:1

julia>

Optional: Environment

julia> (@v1.6) pkg> status Status ~/.julia/environments/v1.6/Project.toml [c7e460c6] ArgParse v1.1.4 [6e4b80f9] BenchmarkTools v1.2.2 [babc4406] COBREXA v1.2.1 [336ed68f] CSV v0.10.2 [479239e8] Catalyst v10.4.0 [a93c6f00] DataFrames v1.3.2 [0c46a032] DifferentialEquations v7.1.0 [31c24e10] Distributions v0.25.41 [8cc96de1] Escher v0.5.0 [60bf3e95] GLPK v0.14.14 [28b8d3ca] GR v0.62.1 [2e9cd046] Gurobi v0.9.14 [f67ccb44] HDF5 v0.15.7 [42fd0dbc] IterativeSolvers v0.9.2 [4076af6c] JuMP v0.21.10 [b8f27783] MathOptInterface v0.9.22 [961ee093] ModelingToolkit v8.3.2 [c020b1a1] NaturalSort v1.0.0 [bac558e1] OrderedCollections v1.4.1 [14b8a8f1] PkgTemplates v0.7.26 [91a5bcdd] Plots v1.24.3 [93e0c654] Reduce v1.2.12 [295af30f] Revise v3.3.1 [8bb1440f] DelimitedFiles [9a3f8284] Random [10745b16] Statistics [8dfed614] Test

exaexa commented 2 years ago

Hello! Thanks for the detailed report, this is very likely some unsupported content in the gene product association strings which we parse only very roughly now. (Is there even some specification of the string format that's used there?) I'll have a look tomorrow morning, hopefully this is a quick fix.

exaexa commented 2 years ago

Note to self: add RECON to tests.

exaexa commented 2 years ago

Anyway it seems that we didn't consider underscores as valid gene names in the GRR formulas so far; a very quick evening fix is available in branch mk-grr-underscores now, with some luck it could work. (If not, I'll need to debug it tomorrow.)

jchitpin commented 2 years ago

Thanks!

Note: I think the other human BiGG models like iAB_RBC_283.json and Recon3D contain underscores because I got similar GRR errors that disappeared when I used this test branch.

exaexa commented 2 years ago

that disappeared when I used this test branch

I kinda guessed the problem from the error message-- do I read correctly that the fix worked? :grinning:

If all is OK now, I'll add some QA&tests and send this to release. Thanks again for reporting!

jchitpin commented 2 years ago

Yup everything is working great and thanks for the quick reply! Please close the issue at your convenience.

exaexa commented 2 years ago

Great, thanks for confirming! This is now then fixed and tested (so hopefully should not break again :D ), the fix is in development branch, will be released in the next version.

:rocket: