## FBA objective function more than one reaction

cbasile
2013-05-05
2013-05-30

• cbasile
2013-05-05

My name is Christian ,  I am trying to do some flux balance analisis using Cobra, however, I am struggling because of the following:

It seems that in Cobra python you can define an objective function only , by choosing just one reaction.What I will like to do is to minimize  a

min (   ' ) = min (v1 + v2 + v3 + v4)

Sv = 0 ,   S being n(metabolite) by m ( reaction)

where where v are all the vm's , n being the number of fluxes or reaction in this case.

Some vm (specific ones) I want to constrained them to a number), both lower and upper bound,

So, far i think that Cobra is capable of doing this, but I dont see any documentation on trying to do this. All the examples are just minimizing  a    just      c1 vm     c1  being a coefficient  with 1x1 dimension, and vm being 1x1 also, that is great, but I dont want this, I want to minimize a 1x4 4x1  =  1x1 =   v1 + v2 + v3 + v4 ,    single objective function,

I would deeply appreciate help for this,

Thank you very much,

Christian,

I would deeply appreciate your help,

I am very excited to use your software,

Best,

Christian,

• Daniel Hyduke
2013-05-06

What should work is something like this:

from cobra.test import create_test_model
model = create_test_model()

#Set the linear coefficients all to 0
;

#Set linear objectives for a set of reactions
the_reactions = model.reactions
the_coefficients =
for the_reaction, the_coefficient in zip(the_reactions, the_coefficients):
the_reaction.objective_coefficient = the_coefficient

#optimize the model
model.optimize()

print model.solution.f

#Print the flux values
for the_reaction in the_reactions:
print the_reaction.id + ' = ' + repr(model.solution.x_dict)

P.S. I think we'll be adding a function soon to attach the results directly to the model variables; i.e., you'll be able to access the flux coefficients by entering the_reaction.x as opposed to model.solution.x_dict.