Repository navigation
Fix protein_scale for window 1 and even window sizes - #5363
Open
barlowa124 wants to merge 2 commits into
Open
barlowa124 wants to merge 2 commits into
barlowa124 wants to merge 2 commits into
Conversation
This was referenced Nov 9, 2026
Merged
A window of 1 crashed on a division by zero in _weight_list, and an even window double-counted subsequence[window//2] (once as the back of the innermost mirrored pair, once as the 'middle'), making profiles depend on sequence direction. Even windows now skip the middle term and normalize by the sum of the two-sided weights. Fixes biopython#5340. I agree to dual license my contribution under both the Biopython License Agreement and the 3-Clause BSD License.
barlowa124
force-pushed
the
protein-scale-window-5340
branch
from
November 12, 2026 19:56
5fe8afa to
5ab4c90
Compare
Member
|
Since you're updating (not sure what changed), could you fill in the revised PR template with an AI declaration please? |
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.
I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I have read the
CONTRIBUTING.rstfile, have runpre-commitlocally, and understand that continuous integration checks will be used to
confirm the Biopython unit tests and style checks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rstandCONTRIB.rstas part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)
Closes #5340
Two window bugs in
ProteinAnalysis.protein_scaleare fixed.With
window=1,_weight_listdivided bywindow - 1and raisedZeroDivisionError. A one-residue window now returns the scale value for each residue.With an even window,
subsequence[window // 2]was counted twice (in the innermost mirrored pair and again as themiddlevalue), so a reversed sequence produced a different profile. Even windows now skip the middle term and normalize by the two-sided weight sum, making the profile direction-invariant.