Fixed bug where added cofactor reactions would get deleted #38
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When we remove reactions due to cofactor redundancy (
Pickaxe._remove_cofactor_redunancy()
), the following code can delete reactions created for previous cofactors in this for loop (for cpd_id in cofactors_as_cpds:
).Specficially, it can add them to this set on subsequent runs of the loop:
The code that creates new reactions is further down in _remove_cofactor_redunancy():
So even though this new reaction is created, sometimes it will then get added to the
rxns_to_del
set the next time the loop runs and will get subsequently deleted. I think this only happens if there are > 1 cofactor on one side of the reaction (so when the loop gets to the other cofactor it sees this reaction as one to delete), but I'm not 100% sure on this.See commit changes for proposed fix. Basically I just make sure to not add any of the newly created cofactor reactions to the
rxns_to_del
set in subsequent runs of the loop.This fix seems to increase final number of predicted reactions by around 3% and compounds by around 2% in my use case (and those 3% added reactions all make sense and I would expect them to be in the final set).