opencobra / cobrapy

COBRApy is a package for constraint-based modeling of metabolic networks.
http://opencobra.github.io/cobrapy/
GNU General Public License v2.0
465 stars 218 forks source link

.mat file reading unreasonably slow in version 0.25 #1269

Closed DKenefake closed 2 years ago

DKenefake commented 2 years ago

The load_matlab_model function now takes orders of magnitude longer to load in models than in previous versions, e.g. version 0.23 of cobra.

For the e_coli_core model, it takes approximately 30 seconds to load in version 0.25, while it is effectively immediate in version 0.23.

cdiener commented 2 years ago

Hmm that could be. The parser got an overhaul and reads much more of the Matlab info now. Could you provide an example as described in the issue template? That way we can investigate.

DKenefake commented 2 years ago

Sure although it is fairly minimal, basically just loading in the e_coli_core model, as sourced from the BIGG model website.

from cobra.io import load_matlab_model

model = load_matlab_model("e_coli_core.mat")

Generates the following output in 0.25.

This model seems to have metCharge instead of metCharges field. Will use metCharge for what metCharges represents.
No defined compartments in model e_coli_core. Compartments will be deduced heuristically using regular expressions.
Using regular expression found the following compartments:c, e
cdiener commented 2 years ago

Hmmm, can you also fill in the rest of the issue template, especially the python -c "import cobra;cobra.show_versions()" call, because I can't reproduce your timings at all. Reading the core model is fast for me on 0.25.0:

Python 3.10.6 (main, Aug 10 2022, 11:19:32) [GCC 12.1.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import cobra

In [2]: cobra.__version__
Out[2]: '0.25.0'

In [3]: %time cobra.io.load_matlab_model("e_coli_core.mat")
This model seems to have metCharge instead of metCharges field. Will use metCharge for what metCharges represents.
Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Problem data seem to be well scaled
No defined compartments in model e_coli_core. Compartments will be deduced heuristically using regular expressions.
Using regular expression found the following compartments:c, e
CPU times: user 62 ms, sys: 0 ns, total: 62 ms
Wall time: 60.4 ms
Out[3]: <Model e_coli_core at 0x7f9b515f42b0>
cdiener commented 2 years ago

Closing for now since it's missing some more info, but feel free to reopen if you have an example where it is slow.