Improved microbial enzyme secretion model#801
Merged
jacobcook1995 merged 9 commits intodevelopfrom Mar 27, 2025
Merged
Conversation
…s well as microbial group
…average of enzyme stochiometries and cellular stochiometries
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #801 +/- ##
===========================================
+ Coverage 94.62% 94.64% +0.01%
===========================================
Files 74 74
Lines 5102 5120 +18
===========================================
+ Hits 4828 4846 +18
Misses 274 274 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
dalonsoa
approved these changes
Mar 26, 2025
Collaborator
dalonsoa
left a comment
There was a problem hiding this comment.
I've just made a small, maths-related comment, but all looks good otherwise. Quite an interesting business!
Comment on lines
+185
to
+204
| enzyme_c_n_weighted = sum( | ||
| enzyme_classes[f"{name}_{substrate}"].c_n_ratio | ||
| * allocation | ||
| / total_enzyme_allocation | ||
| for substrate, allocation in enzyme_production.items() | ||
| ) | ||
|
|
||
| enzyme_c_p_weighted = sum( | ||
| enzyme_classes[f"{name}_{substrate}"].c_p_ratio | ||
| * allocation | ||
| / total_enzyme_allocation | ||
| for substrate, allocation in enzyme_production.items() | ||
| ) | ||
|
|
||
| return { | ||
| "nitrogen": (c_n_ratio + enzyme_c_n_weighted * total_enzyme_allocation) | ||
| / (1.0 + total_enzyme_allocation), | ||
| "phosphorus": (c_p_ratio + enzyme_c_p_weighted * total_enzyme_allocation) | ||
| / (1.0 + total_enzyme_allocation), | ||
| } |
Collaborator
There was a problem hiding this comment.
Please, let someone check my maths, but I think that you can take the dividing total_enzyme_allocation out of the sums, in which case it will cancel with the multiplying one below:
Suggested change
| enzyme_c_n_weighted = sum( | |
| enzyme_classes[f"{name}_{substrate}"].c_n_ratio | |
| * allocation | |
| / total_enzyme_allocation | |
| for substrate, allocation in enzyme_production.items() | |
| ) | |
| enzyme_c_p_weighted = sum( | |
| enzyme_classes[f"{name}_{substrate}"].c_p_ratio | |
| * allocation | |
| / total_enzyme_allocation | |
| for substrate, allocation in enzyme_production.items() | |
| ) | |
| return { | |
| "nitrogen": (c_n_ratio + enzyme_c_n_weighted * total_enzyme_allocation) | |
| / (1.0 + total_enzyme_allocation), | |
| "phosphorus": (c_p_ratio + enzyme_c_p_weighted * total_enzyme_allocation) | |
| / (1.0 + total_enzyme_allocation), | |
| } | |
| enzyme_c_n_weighted = sum( | |
| enzyme_classes[f"{name}_{substrate}"].c_n_ratio | |
| * allocation | |
| for substrate, allocation in enzyme_production.items() | |
| ) | |
| enzyme_c_p_weighted = sum( | |
| enzyme_classes[f"{name}_{substrate}"].c_p_ratio | |
| * allocation | |
| for substrate, allocation in enzyme_production.items() | |
| ) | |
| return { | |
| "nitrogen": (c_n_ratio + enzyme_c_n_weighted) | |
| / (1.0 + total_enzyme_allocation), | |
| "phosphorus": (c_p_ratio + enzyme_c_p_weighted) | |
| / (1.0 + total_enzyme_allocation), | |
| } |
Collaborator
Author
There was a problem hiding this comment.
Yes, you are right! I think I was overly focused on the line-by-line logic so I lost the big picture
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR changes how the calculation of enzyme secretion by microbes so that microbes have an allocate a certain fraction of new biomass to extracellular enzymes (previously it was a fraction of cellular maintenance). The reason behind this change is that it allows enzymes to have different stochiometries to the microbes producing them. This is something that needs to be added before fungi can be split between mycorrhizal and saprotrophic.
The main structural change arises because the microbial groups now need information about the enzyme classes (so that the average stoichiometry of the synthesised biomass can be found). So now a set of
EnzymeConstantshas to be provided for the creation of aMicrobialGroupConstantsdata class. Feedback on this would be appreciated!I also fixed a bug I noticed with the calculation of microbial pH suitability.
Fixes #760 #779
Type of change
Key checklist
pre-commitchecks:$ pre-commit run -a$ poetry run pytestFurther checks