-
Notifications
You must be signed in to change notification settings - Fork 217
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/refactor add/remove genes,metabolites,reactions #389
Comments
Where do we want to the code for adding metabolites / reactions to a model to live?
and then the same with metabolites (the functions should be identical). We'll have to be careful about how we handle temporary deletions... We need to be able to keep the object intact somewhere so we can add it back to the model at the end of the context. Also important will be the |
I would have put the implementations in the classes they belong to (organise code by class, or by function..) but that's just cosmetics and won't impact functionality / user experience so don't have a strong opinion on that. I find the cobrapy classes already a bit tricky to understand and I believe the right methods help here. So, |
I guess my point is that we should take the opportunity to standardize what the methods are called and where they live. I.e., why have reaction.remove_from_model but not add_to_model? Why have On the code, I'm more saying should the actual mechanics be implemented in Reaction (and Metabolite) or Model? Right now |
I'm all for standardizing method names and I do believe your second paragraph is important. To me, the hierarchy of what classes represent also implies which methods they should have.
That means, IMHO, that reactions need methods to add/remove metabolites from themselves and models need methods to add/remove reactions from themselves. Nothing more, nothing less. There is one interesting exception, of course. It is useful to get the set of all metabolites that occur in all reactions of a model. If we want that attribute |
I was thinking a bit more in the line of incremental changes and then the motivation for |
@Midnighter, the class hierarchy was something I thought about a good about when doing the context managers. If objects only looked down the stack (Model -> Reaction -> Metabolite), then a metabolite or reaction object could easily belong to more than one model, and model copying would become much faster (since the underlying objects wouldn't change). The problem is that a lot of the current methods rely on the fact that objects can look up the stack: ( More to the current issue: I do agree on backwards compatibility, but there's enough of an API change in 0.6 that I think we can safely refactor these methods if we want to. My main goal is to make things consistent, so whether that's deprecating |
The consistency is really nice to have but there is also the usefulness aspect, I'm sure you have a better idea than me on what's meaningful to have, so if |
I agree it's a major change and maybe more suitable for something close to 1.0 ;) From my limited experience with the cobra codebase what you describe is a major pain point for maintenance. All objects are extremely entangled meaning that refactoring affects large parts of the code base. And even worse, I've seen a bunch of code that accesses "private" attributes of composite objects, e.g.,
My vote then is to make the necessary changes on the |
I'm suggesting that we would replace the implementation currently in Same with Otherwise, we context manage the code in @Midnighter, we'll also have to totally rethink things like |
Your suggestion sounds good to me -> Model holds the code |
breakout from discussion in #311
these should allow resetting using history manager
The text was updated successfully, but these errors were encountered: