in reply to find the coverage of sequence in a particular range

The following ranges are covered:

  1. 46 - 196
  2. 403 - 553
  3. 800-950
  4. 832-982
  5. 1008-1158
  6. 1407-1524

There is an overlap between two of the ranges. Your question is how much of the range between 1 and 1524 is covered. Do I have that correct?

Update: solution

use strict; use warnings; my (%covered); open my $m, '<', 'count_try.txt' or die 'Cannot open count_try.txt'; while (my $seq = <$m>) { chomp $seq; my ($start, $range) = split /\t/, $seq; my ($fm,$to) = split /\.\./,$range; my $end = $start + 149; $end = $to if $end > $to; for(my $i=$start;$i<=$end;$i++) { $covered{$range}{$i} = 1 } } for my $range (keys %covered) { printf "Coverage in range %s is %d\n",$range,scalar keys %{$covere +d{$range}} } close $m;
But God demonstrates His own love toward us, in that while we were yet sinners, Christ died for us. Romans 5:8 (NASB)