klamt-lab / straindesign

StrainDesign is a python package for the computational design of metabolic networks and based on COBRApy
Apache License 2.0
33 stars 6 forks source link

Error when loanding models from cobra #10

Closed cjavier98 closed 10 months ago

cjavier98 commented 10 months ago

Maximum growth: 34.14842956394264. WARNING:root: Removing reaction bounds when larger than the cobra-threshold of 1000. C:\Users\cjrodriguezf\Documents\CNAPY\CNApy\miniconda\envs\cnapy-1.1.8\lib\site-packages\cobra\core\group.py:147: UserWarning: need to pass in a list warn("need to pass in a list") Traceback (most recent call last): File "c:/Users/cjrodriguezf/Documents/cobrapy/GMCS.py/strain_design_benchmarking", line 21, in sols = sd.compute_strain_designs(ecc, sd_modules = module_suppress, solution_approach = 'populate', gene_kos = True, max_cost = 3) File "C:\Users\cjrodriguezf\Documents\CNAPY\CNApy\miniconda\envs\cnapy-1.1.8\lib\site-packages\straindesign\compute_strain_designs.py", line 349, in compute_strain_designs cmp_mapReac = compress_model(cmp_model, no_par_compress_reacs) File "C:\Users\cjrodriguezf\Documents\CNAPY\CNApy\miniconda\envs\cnapy-1.1.8\lib\site-packages\straindesign\networktools.py", line 381, in compress_model stoichmat_coeff2rational(model) File "C:\Users\cjrodriguezf\Documents\CNAPY\CNApy\miniconda\envs\cnapy-1.1.8\lib\site-packages\straindesign\networktools.py", line 828, in stoichmat_coeff2rational
raise TypeError TypeError

cjavier98 commented 10 months ago

Could it be that I am loading the model from .mat, I do not encounter the error when loading from SBML

VonAlphaBisZulu commented 10 months ago

Hi and thanks for submitting the issue. Found the issue and fixed it.

The function "stoichmat_coeff2rational" converts all entries of the stoichiometric matrix into rational numbers, which is necessary for conserving exact stoichiometries throughout compression. The entries of the stoichimetric matrix are usually sympy-float point or integer values. When cobrapy loads a MATLAB model, it assigns numpy-floats as entries of the stoichiometric matrix instead. A case that wasn't captured by straindesign yet.

I will push this into a new release right away. You can update to 1.10 as soon as it is online and should get the fix.