Open wshao1 opened 6 months ago
Hi, thanks for providing a reproducible example. In this case not an issue with the gapfiller (at least for GLPK) but rather an edge case due to the use of then context manager.
In this line
# ...
with human1 as test_model:
# ...
human1
and test_model
point to the same object/model. So when you remove the reaction from test_model
you also remove it from human1
. The with block only reverts all changes after the exiting but it does not take a copy of the model. Substituting this with a copy fixes it, at least for me:
In [70]: # Load Human1 GEM
...: human1 = read_sbml_model('Human-GEM.xml')
...: human1.solver = "glpk"
...:
...: # Try gapfilling an essential reaction (MAR06669)
...: with human1.copy() as test_model: # <-- note the copy here
...: rxn = test_model.reactions.get_by_id('MAR06669')
...: test_model.remove_reactions([rxn])
...: solution = gapfill(test_model, human1, demand_reactions=False)
...: for reaction in solution[0]:
...: print(reaction.id)
...:
MAR06669
I did notice an issue with CPLEX due to a low integer primal and the lack of an option to set this via gapfill
. I will send a PR for this part.
Ah thank you for catching that! I am still having issues with trying to use gapfill however. My goal is to identify alternative reactions/pathways to an essential reaction in a context-specific model. My reasoning was this: if a reaction is essential in the context-specific model but not in the universal model, then there should be alternative reactions/pathways. To identify these, I removed the essential reaction from both the context-specific and universal models, then tried to gap-fill. But I still get the infeasibility error. Is there an error in this reasoning?
Code:
# Load Human1 GEM and context-specific model
human1 = read_sbml_model('Human-GEM.xml')
context_specific_model= read_sbml_model('context_specific_model.xml')
# find alternative reactions to compensate for MAR01820
with context_specific_model as pruned_model:
with human1 as univ_model:
pruned_model.remove_reactions([pruned_model.reactions.MAR01820])
univ_model.remove_reactions([univ_model.reactions.MAR01820])
test_model.solver.configuration.tolerances.feasibility = 1e-9
solution = gapfill(pruned_model, univ_model, demand_reactions=False)
for reaction in solution[0]:
print(reaction.id)
Context-specific model: context_specific_model.zip
Also, the original Human1 check still breaks when I try to gapfill some other essential reactions (e.g. MAR06657, MAR00578, MAR06702
).
Is there an existing issue for this?
Problem description
What I tried to achieve:
How I went about it:
model.solver.configuration.tolerances.feasibility
threshold to1e-9
, as previous error threads showed this helped. But this yields the same error.Why the current behavior is a problem:
Code sample
Code run:
Traceback:
Environment
Anything else?
No response