I am using the Set::IntervalTree code to compare two sets of intervals. However, I need an extra method that AFAIK is currently not implemented in this module.
I would like to have a method that splits or masks one interval into two or more. For example:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <= [Original Interval A]
rrrrrrrrr <= [Interval B to mask against A]
xxxxxxxxxxx xxxxxxxxxxxxxxxx <= [Resulting Intervals A1 and A2]
Any ideas if this is possible with an existing Perl module?
EDIT:
For more information, each interval can be of size 1 to 1 billion (1E9) and in each interval set there are between 1 to 1 million (1E6) intervals.
Set::IntSpan
does want you want, assuming you need integer boundaries for your intervals:
#!/usr/bin/perl -w
use strict;
use Set::IntSpan;
my $A = new Set::IntSpan '1-1000000000';
my $B = new Set::IntSpan '3-5,10-20,100-200,1000-2000';
my $C = diff $A $B;
print $C;
returns
1-2,6-9,21-99,201-999,2001-1000000000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With