Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundLocalError when running minimal_media with summarize=False #178

Closed
zoey-rw opened this issue May 8, 2024 · 1 comment · Fixed by #179
Closed

UnboundLocalError when running minimal_media with summarize=False #178

zoey-rw opened this issue May 8, 2024 · 1 comment · Fixed by #179

Comments

@zoey-rw
Copy link

zoey-rw commented May 8, 2024

When using the second dataframe output from complete_db_medium and summing up the fluxes per metabolite as the medium file for grow, most communities couldn't grow (the flux values seemed too low)

I also tried getting the per-sample results using the minimal_media function with summarize=False, but I'm receiving this error after 100%:

from micom.workflows import minimal_media


minimal_media_persample = minimal_media(manual_amplicon_manifest, summarize=False,
                    model_folder="/projectnb/dietzelab/zrwerbin/N-cycle/data/MICOM/manual_amplicon/", 
                          min_growth=.01,threads=28)

Running ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 100% 0:04:52

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
Cell In[5], line 3
      1 from micom.workflows import minimal_media
----> 3 minimal_media_persample = minimal_media(manual_amplicon_manifest, summarize=False,
      4                     model_folder="/projectnb/dietzelab/zrwerbin/N-cycle/data/MICOM/manual_amplicon/", 
      5                           min_growth=.01,threads=28)

File /projectnb/talbot-lab-data/zrwerbin/.conda/envs/micom/lib/python3.12/site-packages/micom/workflows/media.py:64, in minimal_media(manifest, model_folder, summarize, min_growth, threads)
     62 if summarize:
     63     medium = results.groupby("reaction").flux.max().reset_index()
---> 64 medium["metabolite"] = medium.reaction.str.replace("EX_", "")
     65 return medium

UnboundLocalError: cannot access local variable 'medium' where it is not associated with a value

Originally posted by @zoey-rw in #177 (comment)

@cdiener
Copy link
Collaborator

cdiener commented May 9, 2024

Yep, very clearly a bug. Will send in a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants