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

cobra.flux_analysis.reaction #537

Closed
Karrenbelt opened this Issue Jul 5, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@Karrenbelt

Karrenbelt commented Jul 5, 2017

I'm using Mac OS X 10.10.5 (Yosemite)
cobrapy 0.6.2
python 3.5

when using functions that need to use "cobra/flux_analysis/reaction.py", such as:
cobra.flux_analysis.reaction.assess
cobra.flux_analysis.gapfill

----------- erroneous output -----------

//anaconda/lib/python3.5/site-packages/cobra/flux_analysis/reaction.py in assess_precursors(model, reaction, flux_coefficient_cutoff, solver)
     75     model.optimize(solver=solver)
     76     model.objective = original_objective
---> 77     if model.solution.f >= flux_coefficient_cutoff:
     78         return True
     79     #

AttributeError: 'Model' object has no attribute 'solution'

should be if model.optimize(solver=solver).objective_value >= flux_coefficient_cutoff:

@Midnighter Midnighter added the bug label Jul 5, 2017

@Midnighter Midnighter self-assigned this Jul 5, 2017

@Midnighter

This comment has been minimized.

Show comment
Hide comment
@Midnighter

Midnighter Jul 5, 2017

Member

Thank you for catching that. We'll make a fix shortly.

Member

Midnighter commented Jul 5, 2017

Thank you for catching that. We'll make a fix shortly.

@Midnighter Midnighter removed their assignment Jul 5, 2017

@hredestig hredestig self-assigned this Jul 6, 2017

@hredestig hredestig added the ready label Jul 6, 2017

@hredestig hredestig removed the ready label Jul 6, 2017

@Karrenbelt

This comment has been minimized.

Show comment
Hide comment
@Karrenbelt

Karrenbelt Aug 2, 2017

Karrenbelt commented Aug 2, 2017

@cdiener

This comment has been minimized.

Show comment
Hide comment
@cdiener

cdiener Aug 2, 2017

Member

This is because the docs you reference are for version 0.3.0 whereas we are currently at version 0.8.1 which has its own updated docs. The pop now only exists on Reaction.metabolites, meaning the following still works:

In [1]: from cobra.test import create_test_model

In [2]: mod = create_test_model("textbook")

In [3]: bm = mod.reactions.Biomass_Ecoli_core

In [4]: atp = mod.metabolites.atp_c

In [5]: bm.metabolites.pop(atp)
Out[5]: -59.81

Hope that helps 😄

Member

cdiener commented Aug 2, 2017

This is because the docs you reference are for version 0.3.0 whereas we are currently at version 0.8.1 which has its own updated docs. The pop now only exists on Reaction.metabolites, meaning the following still works:

In [1]: from cobra.test import create_test_model

In [2]: mod = create_test_model("textbook")

In [3]: bm = mod.reactions.Biomass_Ecoli_core

In [4]: atp = mod.metabolites.atp_c

In [5]: bm.metabolites.pop(atp)
Out[5]: -59.81

Hope that helps 😄

@Karrenbelt

This comment has been minimized.

Show comment
Hide comment
@Karrenbelt

Karrenbelt Aug 2, 2017

Karrenbelt commented Aug 2, 2017

@cdiener

This comment has been minimized.

Show comment
Hide comment
@cdiener

cdiener Aug 2, 2017

Member

Ah ok that is true. It does not do the same thing as Reaction.pop since it does not remove it. In the later cobra versions this is only possible with add_metabolites and subtract_metabolites, e.g.:

In [39]: coef = bm.metabolites[atp]

In [40]: coef
Out[40]: -59.81

In [41]: bm.subtract_metabolites({atp: coef})

In [42]: bm.metabolites
Out[42]: 
{<Metabolite 3pg_c at 0x7f08ea92de10>: -1.496,
 <Metabolite accoa_c at 0x7f08d6ab3240>: -3.7478,
 <Metabolite e4p_c at 0x7f08d6aab7f0>: -0.361,
 <Metabolite f6p_c at 0x7f08d6abb320>: -0.0709,
 <Metabolite g3p_c at 0x7f08d6aa9748>: -0.129,
 <Metabolite g6p_c at 0x7f08d6aa99b0>: -0.205,
 <Metabolite gln__L_c at 0x7f08d6aa9e80>: -0.2557,
 <Metabolite glu__L_c at 0x7f08ea97c0f0>: -4.9414,
 <Metabolite h2o_c at 0x7f08ea97c908>: -59.81,
 <Metabolite nad_c at 0x7f08ea977048>: -3.547,
 <Metabolite nadph_c at 0x7f08ea977908>: -13.0279,
 <Metabolite oaa_c at 0x7f08ea975908>: -1.7867,
 <Metabolite pep_c at 0x7f08ea975ba8>: -0.5191,
 <Metabolite pyr_c at 0x7f08ea9744e0>: -2.8328,
 <Metabolite r5p_c at 0x7f08ea974da0>: -0.8977,
 <Metabolite adp_c at 0x7f08d6ab3898>: 59.81,
 <Metabolite akg_c at 0x7f08d6ab3978>: 4.1182,
 <Metabolite coa_c at 0x7f08d6aab240>: 3.7478,
 <Metabolite h_c at 0x7f08ea97a278>: 59.81,
 <Metabolite nadh_c at 0x7f08ea977358>: 3.547,
 <Metabolite nadp_c at 0x7f08ea977630>: 13.0279,
 <Metabolite pi_c at 0x7f08ea975e10>: 59.81}
Member

cdiener commented Aug 2, 2017

Ah ok that is true. It does not do the same thing as Reaction.pop since it does not remove it. In the later cobra versions this is only possible with add_metabolites and subtract_metabolites, e.g.:

In [39]: coef = bm.metabolites[atp]

In [40]: coef
Out[40]: -59.81

In [41]: bm.subtract_metabolites({atp: coef})

In [42]: bm.metabolites
Out[42]: 
{<Metabolite 3pg_c at 0x7f08ea92de10>: -1.496,
 <Metabolite accoa_c at 0x7f08d6ab3240>: -3.7478,
 <Metabolite e4p_c at 0x7f08d6aab7f0>: -0.361,
 <Metabolite f6p_c at 0x7f08d6abb320>: -0.0709,
 <Metabolite g3p_c at 0x7f08d6aa9748>: -0.129,
 <Metabolite g6p_c at 0x7f08d6aa99b0>: -0.205,
 <Metabolite gln__L_c at 0x7f08d6aa9e80>: -0.2557,
 <Metabolite glu__L_c at 0x7f08ea97c0f0>: -4.9414,
 <Metabolite h2o_c at 0x7f08ea97c908>: -59.81,
 <Metabolite nad_c at 0x7f08ea977048>: -3.547,
 <Metabolite nadph_c at 0x7f08ea977908>: -13.0279,
 <Metabolite oaa_c at 0x7f08ea975908>: -1.7867,
 <Metabolite pep_c at 0x7f08ea975ba8>: -0.5191,
 <Metabolite pyr_c at 0x7f08ea9744e0>: -2.8328,
 <Metabolite r5p_c at 0x7f08ea974da0>: -0.8977,
 <Metabolite adp_c at 0x7f08d6ab3898>: 59.81,
 <Metabolite akg_c at 0x7f08d6ab3978>: 4.1182,
 <Metabolite coa_c at 0x7f08d6aab240>: 3.7478,
 <Metabolite h_c at 0x7f08ea97a278>: 59.81,
 <Metabolite nadh_c at 0x7f08ea977358>: 3.547,
 <Metabolite nadp_c at 0x7f08ea977630>: 13.0279,
 <Metabolite pi_c at 0x7f08ea975e10>: 59.81}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment