biosustain / cameo

cameo - computer aided metabolic engineering & optimization
http://cameo.bio
Apache License 2.0
113 stars 42 forks source link

Problem with SYMPY #266

Closed Bknmn closed 2 years ago

Bknmn commented 3 years ago

I'm having some problems getting with OPTNOCK, OPTGENE for SPICY.CORE.numbers.Zero was not iterable
So I installed the default version of python (3.7.6). and SYMPY(1.6.2)

I'm trying to run some of the PhPP, OPTNOCK and OPTGENE from tutorials, but I keep getting an Import Error. “TypeError: item in iterable cannot be '<class 'sympy.core.numbers.Zero'>'”

Here's the whole error message:

TypeError Traceback (most recent call last)

in ----> 1 fva_result = flux_variability_analysis(model_E_coli) 2 fva_result.data_frame /usr/local/lib/python3.7/dist-packages/cameo/flux_analysis/analysis.py in flux_variability_analysis(model, reactions, fraction_of_optimum, pfba_factor, remove_cycles, view) 223 else: 224 func_obj = _FvaFunctionObject(model, _flux_variability_analysis) --> 225 chunky_results = view.map(func_obj, reaction_chunks) 226 solution = pandas.concat(chunky_results) 227 /usr/local/lib/python3.7/dist-packages/cameo/parallel.py in map(self, *args, **kwargs) 229 class SequentialView(object): 230 def map(self, *args, **kwargs): --> 231 return list(map(*args, **kwargs)) 232 233 def apply(self, func, *args, **kwargs): /usr/local/lib/python3.7/dist-packages/cameo/flux_analysis/analysis.py in __call__(self, reactions) 347 348 def __call__(self, reactions): --> 349 return self.fva(self.model, reactions) 350 351 /usr/local/lib/python3.7/dist-packages/cameo/flux_analysis/analysis.py in _flux_variability_analysis(model, reactions) 358 lb_flags = dict() 359 with model: --> 360 model.objective = S.Zero 361 362 model.objective.direction = 'min' /usr/local/lib/python3.7/dist-packages/cobra/core/model.py in objective(self, value) 1144 if not isinstance(value, (dict, optlang.interface.Objective)): 1145 try: -> 1146 reactions = self.reactions.get_by_any(value) 1147 except KeyError: 1148 raise ValueError('invalid objective') /usr/local/lib/python3.7/dist-packages/cobra/core/dictlist.py in get_by_any(self, iterable) 90 if not isinstance(iterable, list): 91 iterable = [iterable] ---> 92 return [get_item(item) for item in iterable] 93 94 def query(self, search_function, attribute=None): /usr/local/lib/python3.7/dist-packages/cobra/core/dictlist.py in (.0) 90 if not isinstance(iterable, list): 91 iterable = [iterable] ---> 92 return [get_item(item) for item in iterable] 93 94 def query(self, search_function, attribute=None): /usr/local/lib/python3.7/dist-packages/cobra/core/dictlist.py in get_item(item) 86 return item 87 else: ---> 88 raise TypeError("item in iterable cannot be '%s'" % type(item)) 89 90 if not isinstance(iterable, list): TypeError: item in iterable cannot be ''
carrascomj commented 3 years ago

Thanks for the report!

This problem was caused by the update in dependencies. #265 solves this issue. Thus, until the next release, I'd suggest for using the devel branch and see if that solves the problem:

python -m pip install git+https://github.com/biosustain/cameo.git

I tested the notebooks and it works but be aware that the plotting functions work a bit different now (the tutorials need an update). For instance, you would need to change the cells [4]-[5] of 05-predict-gene-knockout-strategies.ipynb to

from cameo import phenotypic_phase_plane
from cameo.visualization.plotting.with_plotly import PlotlyPlotter

plotter = PlotlyPlotter()

p = phenotypic_phase_plane(model, variables=['BIOMASS_Ec_iJO1366_core_53p95M'], objective='EX_ac_e')
p.plot(plotter, points=[(growth, acetate_production)])
carrascomj commented 3 years ago

Hi @Bknmn,

cameo 0.13.0 is out! Upgrading the package and using the code above should fix your problem.

Bknmn commented 3 years ago

Thanks a lot!! , I upgrade the package rigth now

Fabian

El mar., 10 nov. 2020 05:21, Jorge Carrasco notifications@github.com escribió:

Hi @Bknmn https://github.com/Bknmn,

cameo 0.13.0 is out! Upgrading the package and using the code above should fix your problem.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/biosustain/cameo/issues/266#issuecomment-724542337, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALWSVFMHOSWIM7DTN3H2PHDSPDZXHANCNFSM4TMEOWGA .

carrascomj commented 2 years ago

Finally in the documentation (598b0a009475369dcddc47db2d2fb4d91f199f40). For instance, https://cameo.bio/05-predict-gene-knockout-strategies.html