Gapfilling constantly fails for model
kristycyw opened this issue · 2 comments
Checklist
- [ Y] I searched the documentation.
- [ Y] I looked through similar issues on GitHub.
- [ Y] I looked up "How to do ... in cobrapy" on a search engine.
Question
Hi Cobrapy team,
I am not very familiar with gapfilling and am struggling with it:
I used model.solver="glpk" with my model and the universal model used is the universal model from the Bigg database that was kindly converted to be cobrapy friendly previously.
I referred to articles #781 and #941
At first, on Jupyter on windows, with the same model, I was constantly getting a message asking to lower the integer threshold, so I used the solution featured in #941:
gapfiller = cobra.flux_analysis.gapfilling.GapFiller(model2, universal=model1, demand_reactions=False, integer_threshold=1e-10)
gapfiller.model.solver.configuration.tolerances.feasibility = 1e-10
gapfiller.model.solver.configuration.tolerances.integrality = 1e-10
gapfiller.fill()
The code ran, but the gapfiller.fill has run for 4 hours without signs of completion with no messages or prompts and I was quite confused.
I swapped to Ubuntu command line and tried the following:
solution=gapfill(model, universal, demand_reactions=False)
Traceback (most recent call last):
File "", line 1, in
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 407, in gapfill
return gapfiller.fill(iterations=iterations)
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 296, in fill
self.model.slim_optimize(
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/core/model.py", line 1063, in slim_optimize
assert_optimal(self, message)
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/util/solver.py", line 590, in assert_optimal
raise exception_cls(f"{message} ({status}).")
cobra.exceptions.Infeasible: gap filling optimization failed (infeasible).
solution=gapfill(model, universal, demand_reactions=True, exchange_reactions=True)
Traceback (most recent call last):
File "", line 1, in
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 399, in gapfill
gapfiller = GapFiller(
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 144, in init
self.extend_model(exchange_reactions, demand_reactions)
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 192, in extend_model
rxn = self.universal.add_boundary(
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/core/model.py", line 626, in add_boundary
raise ValueError(
ValueError: Boundary reaction 'DM_anth_c' already exists.
solution=gapfill(model, universal, demand_reactions=True)
Traceback (most recent call last):
File "", line 1, in
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 399, in gapfill
gapfiller = GapFiller(
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 144, in init
self.extend_model(exchange_reactions, demand_reactions)
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 192, in extend_model
rxn = self.universal.add_boundary(
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/core/model.py", line 626, in add_boundary
raise ValueError(
ValueError: Boundary reaction 'DM_anth_c' already exists.
model.solver.configuration.tolerances.feasibility=1e-9
solution=gapfill(model, universal, demand_reactions=False)
Traceback (most recent call last):
File "", line 1, in
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 407, in gapfill
return gapfiller.fill(iterations=iterations)
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/flux_analysis/gapfilling.py", line 296, in fill
self.model.slim_optimize(
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/core/model.py", line 1063, in slim_optimize
assert_optimal(self, message)
File "/home/kristy/Desktop/venv-cobrapy/lib/python3.10/site-packages/cobra/util/solver.py", line 590, in assert_optimal
raise exception_cls(f"{message} ({status}).")
cobra.exceptions.Infeasible: gap filling optimization failed (infeasible).
Apologies for the early closure, rerunning the script with lower thresholds provided a solution much to my surprise, I am still not sure what prevented it from running at 10e-9, perhaps the experts can comment?
Hmm hard to say. But interrupting some of the algorithms can sometimes leave the model in a semi-broken state where some solver modifications are not reversed. Rerunning the script would fix that.