Skip Menu |

This queue is for tickets about the Set-IntervalTree CPAN distribution.

Report information
The Basics
Id: 89703
Status: resolved
Priority: 0/
Queue: Set-IntervalTree

People
Owner: Nobody in particular
Requestors: nyoungb2 [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: odd output for fetch_window
Date: Tue, 22 Oct 2013 13:54:31 -0500
To: <bug-Set-IntervalTree [...] rt.cpan.org>
From: Nicholas Youngblut <nyoungb2 [...] gmail.com>
Hello, I seem to be getting some odd output for the fetch_window function. It seems to find some windows but not others. Is this an overlap/adjacency issue (e.g. windows adjacent to each other or ends overlapping each other)? """ use Set::IntervalTree; use Data::Dumper; my @seq = split //, "ABCDEFGHIJ"; my $itree = Set::IntervalTree->new; for my $i (0..$#seq){ $itree->insert($seq[$i],$i+1,$i+1); } # appears to be normal with fetch # for my $i (0..$#seq){ my $res = $itree->fetch($i, $i+2); print Dumper $i, @$res; } # output is only every other character: 'b', then 'd', then 'f' # for my $i (0..$#seq){ print Dumper $i, $itree->fetch_window($i,$i); } """ Thanks for the module. It's been really helpful for my genomics work! Nick ~~~ Nicholas D. Youngblut Ph.D Candidate Rachel Whitaker Lab Microbiology Department University of Illinois at Urbana-Champaign
On Tue Oct 22 14:54:50 2013, nyoungb2@gmail.com wrote: Show quoted text
> Hello, > I seem to be getting some odd output for the fetch_window function. It seems > to find some windows but not others. Is this an overlap/adjacency issue > (e.g. windows adjacent to each other or ends overlapping each other)? > > > """ > use Set::IntervalTree; > use Data::Dumper; > my @seq = split //, "ABCDEFGHIJ"; > > my $itree = Set::IntervalTree->new; > for my $i (0..$#seq){ > $itree->insert($seq[$i],$i+1,$i+1); > } >
The problem is that the underlying C++ code can't handle intervals with non-positive width (0 or negative). The perl module uses half-open intervals, but the underlying C++ code uses both ends open intervals. The intervals you defined above have width zero because the start and stop values are the same. I added some code to the API to check to make sure the intervals are defined correctly. This should hopefully help avoid the weird output you were seeing.