Fix overinflated stepwise copy number values from multiple annotations on same gene #2176
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.
This very simple PR fixes issue #2173 and another bug that I found along the way. The fix and its caveats are detailed in #2173, but to summarize:
get_dereplicated_enzyme_hits_for_step_in_module()
does before each step's copy number is calculated from the annotation data.are_enzymes_indirect_alternatives_within_step
is used to detect the edge cases. It does NOT perfectly detect all indirect relationships between all enzymes in a step and should not be used generally for that purpose, but it works okay for the limited use-case of warning the user about specific overlapping annotations. See [BUG] Genes with multiple annotations overinflate stepwise pathway copy number values #2173 for an example warning.In short, stepwise copy numbers will no longer be inflated when one gene has multiple annotations. In the worst case, they may be too low rather than too high.
Finally, there was another bug that was also contributing to the inflation of step copy numbers in some cases -- missing annotations for direct alternatives were not counted as 0s if they were the first out of all the alternatives to be considered. This and its fix are also described in #2173, and I will note that it is perhaps the more important of the two fixes because it was not obvious and it affected more modules (15, in my test data, compared to 8 for the multiple annotations bug).