Perl module for separating / masking intervals

I use the code Set :: IntervalTree to compare two sets of intervals. However, I need an additional method that AFAIK is not currently implemented in this module.

I would like to have a method that splits or masks one interval into two or more. For instance:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx <= [Original Interval A] rrrrrrrrr <= [Interval B to mask against A] xxxxxxxxxxx xxxxxxxxxxxxxxxx <= [Resulting Intervals A1 and A2] 

Any ideas if this is possible using the existing Perl module?

EDIT:

For more information, each interval can be from 1 to 1 billion (1E9) in size, and from 1 to 1 million (1E6) is set in each interval.

+6
source share
1 answer

Set::IntSpan wants you to, considering that 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

+3
source

All Articles