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
fix: ZeroDivisionError in _ccbr_counts2density.py when flanking TSS bins have zero reads #122
atac_tss rule crashes with ZeroDivisionError when running on genomes (e.g. hs1_chrR) where some genes have zero read coverage in the outermost TSS flanking bins.
Discovered during the Biowulf test run for PR #120.
Error
Traceback (most recent call last):
File "_ccbr_counts2density.py", line 22, in <module>
density[n2bin[i]] = density[n2bin[i]] * 1.0 / flankavg
ZeroDivisionError: float division by zero
flanksum=0foriinrange(1, 11): # first 10 bins: positions -1995 to -1905flanksum+=density[n2bin[i]]
foriinrange(391, 401): # last 10 bins: positions +1905 to +1995flanksum+=density[n2bin[i]]
flankavg=flanksum*1.0/20# <-- crashes if flanksum == 0
flankavg is the mean read depth across the 10 outermost bins on each side of the ±2 kb TSS window. If a gene (e.g. on chrR) has zero reads in all 20 flanking bins, flankavg = 0 and the normalization on line 22 raises ZeroDivisionError.
Proposed fix
Guard against zero before the normalization loop. If flankavg == 0, emit 0.0 for all density values and report TSS enrichment as 0.0 rather than crashing:
changed the title [-]fix: hs1_chrR support broken in annotation scripts and TSS enrichment calculation[/-][+]fix: ZeroDivisionError in _ccbr_counts2density.py when flanking TSS bins have zero reads[/+]on Aug 4, 2026
Fixed in commit 19dcbf5 on branch issue_117 (folded into PR #120).
Change in workflow/scripts/_ccbr_counts2density.py: added a zero-guard immediately after computing flankavg. If all 20 flanking bins carry zero reads, the script now emits 0.0 for every density value and prints # TSS enrichment: 0.0000, then exits cleanly. This is the correct biological interpretation — a gene with no detectable background flanking the TSS has effectively zero TSS enrichment score.
Activity
[-]fix: hs1_chrR support broken in annotation scripts and TSS enrichment calculation[/-][+]fix: ZeroDivisionError in _ccbr_counts2density.py when flanking TSS bins have zero reads[/+]fix: guard against ZeroDivisionError in _ccbr_counts2density.py when …
kopardev commentedon Aug 4, 2026
Fixed in commit 19dcbf5 on branch
issue_117(folded into PR #120).Change in
workflow/scripts/_ccbr_counts2density.py: added a zero-guard immediately after computingflankavg. If all 20 flanking bins carry zero reads, the script now emits0.0for every density value and prints# TSS enrichment: 0.0000, then exits cleanly. This is the correct biological interpretation — a gene with no detectable background flanking the TSS has effectively zero TSS enrichment score.⚡ Generated using AI ⚡