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

[Feature] Handle reaction removal in the objective #1396

Open cdiener opened 5 days ago

cdiener commented 5 days ago

Checklist

Problem

Right now removing reactions from a model will still reatin in them in the objective even when using remove_orphans=True. They are kind of handled correctly there because they appear as diconnected variables, meaning they are fixed to zero.

In [2]: from cobra.io import load_model

In [3]: mod = load_model("textbook")

In [4]: mod.objective
Out[4]: <optlang.cplex_interface.Objective at 0x7fb641a6d790>

In [5]: mod.objective.expression
Out[5]: 1.0*Biomass_Ecoli_core - 1.0*Biomass_Ecoli_core_reverse_2cdba

In [6]: mod.remove_reactions([mod.reactions.Biomass_Ecoli_core], True)

In [7]: mod.objective.expression
Out[7]: 1.0*Biomass_Ecoli_core - 1.0*Biomass_Ecoli_core_reverse_2cdba

In [8]: mod.optimize()
Out[8]: <Solution 0.000 at 0x7fb641a74590>

But it is still a bit confusing to have removed reactions appear there.

Solution

I don't have a definitive solution. It is challenging because the objective can be arbitrary non-linear functions so it is not trivial to correctly remove terms. Removing individual reactions in theory also breaks the scaling to 1gDW.

Alternatives

Other approaches:

Anything else?

Happy to hear the thoughts of the community!