Hi, thanks for this great package - it's making our lives downstream much easier!
I've been using pybigtools' BBIRead.values(), which says it can read regions even if (partially) outside chromosome boundaries (and indeed has the argument oob for that specific case).
When trying to extract values from a region exceeding the chromosome boundary, however, a specific assertion always fails:
with pybigtools.open("your_bw.bw") as f:
f.values(chrom, start, end_outside_chrom, bins = bins)
This seems to be because of an assertion in intervals_to_array (line 308):
assert_eq!(bin_end, array.len() - 1);
Which expects an array 1 smaller than the actual array's output. I can't quite figure out why this subtraction is here, since in my testing, bin_end and array.len() both match the expected size. For example, even with a region of 524288 bp and 32 bp bins, I get assertion left == right failed; left: 16384; right: 16383, with the expected size indeed being 16384.
Reproducible example:
import pybigtools
with pybigtools.open("https://github.com/jackh726/bigtools/raw/refs/heads/master/bigtools/resources/test/valid.bigWig") as f:
chroms = f.chroms()
# Region: arbitrary chromosome, 1 bin outside overlap
chrom = list(chroms.keys())[0]
bin_size = 8
end = chroms[chrom]+bin_size
start = end - 2*bin_size
# Try to get values
f.values(chrom, start, end, bins = 3)
# Note: also happens if explicitly setting oob:
f.values(chrom, start, end, bins = 3, oob=0)
Hi, thanks for this great package - it's making our lives downstream much easier! I've been using pybigtools'
BBIRead.values()
, which says it can read regions even if (partially) outside chromosome boundaries (and indeed has the argumentoob
for that specific case).When trying to extract values from a region exceeding the chromosome boundary, however, a specific assertion always fails:
Error (with Rust stacktrace on):
This seems to be because of an assertion in
intervals_to_array
(line 308):Which expects an array 1 smaller than the actual array's output. I can't quite figure out why this subtraction is here, since in my testing, bin_end and array.len() both match the expected size. For example, even with a region of 524288 bp and 32 bp bins, I get
assertion left == right failed; left: 16384; right: 16383
, with the expected size indeed being 16384.Reproducible example: