opencobra / cobrapy

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

error when loading a bigg universal model #1123

Closed shumantov closed 2 years ago

shumantov commented 2 years ago

Hi,

I'm trying to gap-fill my model, using the BIGG universal model as reference, but for some reason I can't load it.

I've been using a code from a jupyter notebook I found in the cobrapie group, given by Moritz (which I guess is a part of CobraPy..), called "model_building_with_universal.ipynb".

these are the first lines:

import requests
from cobra import Model
from cobra.io import model_from_dict

resp = requests.get("http://bigg.ucsd.edu/static/namespace/universal_model.json")
resp.raise_for_status()

universal = model_from_dict(resp.json())

Then I get this error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-10-4230f221b04f> in <module>
----> 1 universal = model_from_dict(resp.json())

~\AppData\Roaming\Python\Python38\site-packages\cobra\io\dict.py in model_from_dict(obj)
    250     model = Model()
    251     model.add_metabolites(
--> 252         [metabolite_from_dict(metabolite) for metabolite in obj["metabolites"]]
    253     )
    254     model.genes.extend([gene_from_dict(gene) for gene in obj["genes"]])

~\AppData\Roaming\Python\Python38\site-packages\cobra\io\dict.py in <listcomp>(.0)
    250     model = Model()
    251     model.add_metabolites(
--> 252         [metabolite_from_dict(metabolite) for metabolite in obj["metabolites"]]
    253     )
    254     model.genes.extend([gene_from_dict(gene) for gene in obj["genes"]])

~\AppData\Roaming\Python\Python38\site-packages\cobra\io\dict.py in metabolite_from_dict(metabolite)
    115     new_metabolite = Metabolite()
    116     for k, v in iteritems(metabolite):
--> 117         setattr(new_metabolite, k, v)
    118     return new_metabolite
    119 

~\AppData\Roaming\Python\Python38\site-packages\cobra\core\object.py in annotation(self, annotation)
     48     def annotation(self, annotation):
     49         if not isinstance(annotation, dict):
---> 50             raise TypeError("Annotation must be a dict")
     51         else:
     52             self._annotation = annotation

TypeError: Annotation must be a dict

Don't know why this happens. I think this code should be reproducible.

Any help will be highly appreciated, regarding this issue, or another approach I should use for reading a universal model.

Best, Alon

Midnighter commented 2 years ago

Still not fixed I'm afraid 🙁 https://github.com/opencobra/cobrapy/issues/1012