Skip to content
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

Remove depreceated manipulation #1200

Closed

Conversation

akaviaLab
Copy link
Contributor

  • fix Remove unused functions from manipulation module #530
  • description of feature/fix
    Removed deprecated manipulation functions including undelete_model_genes, get_compiled_gene_reaction_rules, find_gene_knockout_reactions
    Removed related functions from test_delete.py
    Removed trimmed field from model
  • tests modified
    Modified test_delete_genes to perform the same tests with the new functions.
  • add an entry to the next release

uri.akavia added 4 commits April 8, 2022 16:22
removed find_gene_knockout_reactions from delete.py
removed _find_gene_knockout_reactions_fast, _gene_knockout_computation, _get_removed from test_delete.py
@codecov-commenter
Copy link

codecov-commenter commented Apr 9, 2022

Codecov Report

Merging #1200 (54abd68) into devel (6e47ab6) will decrease coverage by 0.93%.
The diff coverage is 76.66%.

❗ Current head 54abd68 differs from pull request most recent head 7635ea6. Consider uploading reports for the commit 7635ea6 to get more accurate results

@@            Coverage Diff             @@
##            devel    #1200      +/-   ##
==========================================
- Coverage   84.03%   83.10%   -0.94%     
==========================================
  Files          65       65              
  Lines        5375     5327      -48     
  Branches     1241     1182      -59     
==========================================
- Hits         4517     4427      -90     
- Misses        551      598      +47     
+ Partials      307      302       -5     
Impacted Files Coverage Δ
src/cobra/core/model.py 87.80% <ø> (-0.07%) ⬇️
src/cobra/manipulation/__init__.py 100.00% <ø> (ø)
src/cobra/util/process_pool.py 39.53% <0.00%> (-60.47%) ⬇️
src/cobra/core/gene.py 80.53% <81.25%> (+0.98%) ⬆️
src/cobra/manipulation/delete.py 92.85% <81.25%> (+9.79%) ⬆️
src/cobra/io/dict.py 89.83% <83.33%> (+0.08%) ⬆️
src/cobra/sampling/optgp.py 75.38% <0.00%> (-16.93%) ⬇️
src/cobra/sampling/core.py 78.78% <0.00%> (-15.16%) ⬇️
src/cobra/flux_analysis/deletion.py 82.45% <0.00%> (-7.02%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6e47ab6...7635ea6. Read the comment docs.

@akaviaLab
Copy link
Contributor Author

@Midnighter @synchon @cdiener - can I get a review of this from one of you please?
Thank you

new_bounds = model.reactions.list_attr("bounds")
reaction_list = list()
for i, rxn in enumerate(model.reactions):
if orig_bounds[i] != new_bounds[i]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exact comparison with floating point numbers is never a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So math.isclose(), maybe with the solver defined tolerance?
Something else?
https://docs.python.org/3/whatsnew/3.5.html#pep-485-a-function-for-testing-approximate-equality

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since numpy is a direct dependency you can also use numpy.isclose if you like. And I don't think the solver tolerance has an impact on bound equivalence unless I overlooked something.



def find_gene_knockout_reactions(
def knock_out_model_genes(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a major API change and not what the PR title implies. Can you add some more comment to the PR description why that was necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.
My reasoning was - delete_model_genes() is marked as deprecated, and should be removed. However, it might be possible people want to set all reactions of a gene to zero.
I couldn't see any other function doing it, so I added a new function that will do so in a context specific manner.
If there is one that does it since remove_model_genes removes genes from model, I missed it and would be happy to point to it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reactions of a gene are already knocked out with a normal Gene.knockout. Did you mean knockout several genes in a model? The question there would if we really need a helper since [g.knockout() for g in gene_list()] is already pretty concise and will work with the context manager.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. Several genes in a model.
My function is simply a helper which returns a list, and so is functionally equivalent to delete_model_genes() only in a context aware manner and with updated code.
Do we want to have this helper for people who aren't that good with writing python code? If not , I can just delete it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cdiener - any decision on this?
Keep or remove?

) -> List["Reaction"]:
"""Identify reactions which will be disabled when genes are knocked out.
"""Temporarily remove the effect of genes in `gene_list`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe better to say "Disable the genes in gene_list." It's a bit unclear what "temporarily removing the effect" of a gene would mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix once other comments are answered, as to not spam the github actors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again. The problem of updates. I can rebase it on the new devel so there won't be a million commits and re-commits.

@cdiener
Copy link
Member

cdiener commented Apr 20, 2022

I was hoping we could fix the CI deadlocks before that, sorry for the delay.

@akaviaLab akaviaLab mentioned this pull request Apr 27, 2022
3 tasks
@akaviaLab
Copy link
Contributor Author

see #1208

@akaviaLab akaviaLab closed this Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove unused functions from manipulation module
5 participants