On Tue, 13 Sep 2011 04:54:40 -0700, Lemon wrote: > I have some segments start and end position on a reference sequence, I > want to calculate the uncoverage region for the reference; > > for example: reference sequence length= 100, > > name [start,end] > segment 1 [1,20] > segment 2 [2,28] > segment 3 [50,100] > segment 4 [5,38] > > so uncover region = [38,49] > > > now I already have %pos{start}=end structure for those segment position, > could somebody give a good method?
By the usual definition the uncovered region is [39,49]. Here's an approach: $ cat differ #!/usr/local/bin/perl use strict; use warnings; use Set::IntSpan; # http://search.cpan.org/perldoc?Set%3A%3AIntSpan my ($diff, @sets) = map { Set::IntSpan->new( $_ ) } qw(1-100 1-20 2-28 50-100 5-38); $diff -= $_ for @sets; print "$diff\n"; $ ./differ 39-49 -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ http://www.informit.com/store/product.aspx?isbn=0137001274 http://www.oreillyschool.com/certificates/perl-programming.php -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/