You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ProteinAnalysis.protein_scale crashes for window 1 and silently biases even windows #5340
ProteinAnalysis.protein_scale does not document an odd-window or minimum window restriction, but two valid-looking window choices seem to be mishandled:
window=1 raises ZeroDivisionError while the natural one-residue profile is simply the selected scale value for each residue.
An even window double-counts subsequence[window // 2]. The returned profile therefore depends on sequence direction even though all positional weights are described as symmetric about the window center.
Sorry for the late reply. There is a real biological use case that hits it directly: the Hopp–Woods hydrophilicity scale ProtParamData.hw, is defined for a hexapeptide window, i.e. an even window of 6.
With the default edge=1.0 the profile should be the plain 6-residue average, but the middle residue is counted twice. The first two values are -0.543 and -0.686, where the plain mean gives -0.550 and -0.417. Reversing the sequence also changes the profile.
So for this scale, an even window gives a silently wrong result rather than an error.
Activity
peterjc commentedon Oct 2, 2026
I'm guessing this was flagged with automated tools, rather than a biological use case?
Perhaps it would be simplest to document and impose limits on the window size.
ChenziqiAdam commentedon Oct 11, 2026
Sorry for the late reply. There is a real biological use case that hits it directly: the Hopp–Woods hydrophilicity scale
ProtParamData.hw, is defined for a hexapeptide window, i.e. an even window of 6.With the default
edge=1.0the profile should be the plain 6-residue average, but the middle residue is counted twice. The first two values are -0.543 and -0.686, where the plain mean gives -0.550 and -0.417. Reversing the sequence also changes the profile.So for this scale, an even window gives a silently wrong result rather than an error.
peterjc commentedon Oct 12, 2026
That's a good use-case then, thanks @ChenziqiAdam. Does the proposal on #5363 work for you?
ChenziqiAdam commentedon Oct 13, 2026
LGTM
Fix protein_scale for window 1 and even window sizes