opencobra / cobrapy

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

[BUG] No biomass flux when another objective is added for FBA analysis #1386

Closed hites77 closed 3 months ago

hites77 commented 3 months ago

Is there an existing issue for this?

Problem description

I was trying to get glycerol production along with biomass growth in my fungal model. When objective is set separately, it shows biomass and glycerol production. When I set the weightage for both the objective simultaneously, the FBA solution shows some value along with glycerol production, but there was zero flux associated with biomass growth. following are the FBA results of 4 different run with different outcomes:

Biomass as objective (Weight:1) = 0.0824 mmol/gDW/hr , biomass = 0.0824; glycerol = 0 Biomass as objective : 10 = 0.8242 mmol/gDW/hr, biomass = 0.0824; glycerol = 0 Biomass: 10, Glycerol: 2 = 3.1179 mmol/gDW/hr , biomass = 0; glycerol = 1.558927668 Biomass: 10, Glycerol: 5 = 7.7946 mmol/gDW/hr , biomass = 0; glycerol = 1.558927668

how to solve this issue ?

I even tried it in COBRA toolbox in MATLAB but similar result

Code sample

Code run:

Traceback:

Environment

Anything else?

No response

Midnighter commented 3 months ago

Please share the code you used to prepare the different objectives and solutions.

hites77 commented 3 months ago

Here is a simple version of the code where I set 0.8 weight for biomass and 0.2 for glycerol production.

# Defining reactions representing for objectives
reaction_1 = model.reactions.get_by_id("r_2111")
reaction_2 = model.reactions.get_by_id("r_1808")

# Set weights for each objective
weight_1 = 0.8  # Higher weight for objective 1
weight_2 = 0.2  # Lower weight for objective 2

model.objective = {reaction_1: weight_1, reaction_2: weight_2}

# The upper bound set at 1000 to get the actual optimal value
model.reactions.get_by_id("r_1808").upper_bound = 1000.0

solution = model.optimize()
print (model.summary(solution=solution))
print (model.reactions.r_2111.flux)

Output:

Objective

========= 0.2 r_1808 + 0.8 r_2111 = 0.3117855336368235

Uptake

Metabolite Reaction Flux C-Number C-Flux s_0565 r_1714 1 6 100.00% s_1277 r_1992 0.5438 0 0.00% s_0805 r_2100 0.2357 0 0.00%

Secretion

Metabolite Reaction Flux C-Number C-Flux s_0458 r_1672 -1.323 1 22.05% s_0766 r_1808 -1.559 3 77.95%

0.0

here r_1672 is for carbon dioxide

Midnighter commented 3 months ago

Maybe what you're looking for is a production envelope? It's not surprising to have zero biomass in the way that the problem is set up.