INPUT FILE:
0000000000
-------------
INTERVALS:
chrX 1 3
chrX 5 6
chrX 8 9
------------
DESIRED OUTPUT FILE:
000N00N00N
-----------------
OUTPUT FILE:
N00NNNNNNN
----------------
CODE:
#!/usr/bin/perl -w
use strict;
use warnings;
my $population = "test";
open( INPUT, "/Users/logancurtis-whitchurch/Desktop/filtered.test.mask.txt") or die "can't open output file\n";
my $mask_input = ;
close INPUT;
my $filtered_sites = "/Users/logancurtis-whitchurch/Desktop/test.interval";
open (INTERVAL, "<$filtered_sites") or die "can't open $filtered_sites";
my $lastEnd = 1;
while ( ) {
my (undef, $start, $end) = split '\s', $_;
## change everything from the end of the last range
## to the start of this range to 'N'
substr( $mask_input, $lastEnd, $start ) =~ tr[\x00-\xff][N];
$lastEnd = $end;
}
close INTERVAL;
## change everything from the end of the last range to the end of string to 'N'
substr( $mask_input, $lastEnd, length( $mask_input ) ) =~ tr[\x00-\xff][N];
print OUT "$mask_input";