-
Notifications
You must be signed in to change notification settings - Fork 218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix 673 #1264
base: devel
Are you sure you want to change the base?
Fix 673 #1264
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks mostly good to me.
The necessity to add so many sync functions just to ensure Species._reactions
mirrors what is defined in Model
makes it really clear that it would be much easier with a "single source of truth" design where Species.reactions
only looks through reactions in the models for whether they contain the species and returns an error if the Species in not part of a Model (where that function does not make much sense since that is a 1:1 mapping anyway for reactions that are not part of a model).
src/cobra/core/model.py
Outdated
@@ -828,21 +862,17 @@ def remove_reactions( | |||
self.reactions.remove(reaction) | |||
reaction._model = None | |||
|
|||
for met in reaction._metabolites: | |||
for met in reaction.metabolites: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is slower though since it creates a copy of the metabolite list. It's not great to access hidden attributes bu here it creates a large memory overhead not to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I change all other places where I access reaction.metabolites? I don't think so, but I'm not sure
added species.py functions to set ._reaction field made metabolites a settable property, and used that to simplify bits of model (including copy and add_reaction)
Fixed almost everything. If I remove context from species/remove_reaction, species/add_reaction almost everything works, which is simpler. However, test_remove_genes_with_context() breaks. Can you help me fix that? I'm not good with contexts. The previous version would not try to update contexts when calling add_reaction or remove_reaction from _associate_gene/__dissociate_gene and that would work. |
@cdiener - can you help me fix test_remove_genes_with_context() please |
Fix Adding reactions from another model does not reset the reactions their metabolites refer to #673 by making reactions in species search the model fields, if this species is in a model.
Added checks in the code to copy the reaction if it is in a model that isn't the one it is added to.
Added properties reaction.metabolites as a settable property, added reaction_add, reaction_remove, reaction_clear to species.py, in order to minimize use of ._reaction.
test_add_reactions_with_context
test_add_reactions_from_another_model