6 print "perl $0 <fa file> <out N zones>\n";
14 open( $infile,"-|","bzip2 -dc $in") or die "Error: $!\n";
15 } elsif ($in =~ /.gz$/) {
16 open( $infile,"-|","gzip -dc $in") or die "Error: $!\n";
17 } else {open( $infile,"<",$in) or die "Error: $!\n";}
22 die "[x]Not a FASTA file !\n" unless /^\s*>/;
25 open O
,'>',$out or die "Error: $!\n";
28 my ($id,$desc)=split / /,$_,2;
29 $desc='' unless $desc;
35 print STDERR
">$id,\t[$desc]:\n";
39 my ($Nstart,$Ncount,$Nlen)=(0,0,0);
40 while ($pos <= $len) {
41 my $base=substr($seq,$pos,1);
42 my $isN = ($base =~ /N/i);
43 if (! $isN and ! $inNzone) {
45 } elsif ($isN and ! $inNzone) {
48 print O
"$id\t",$pos+1,"\t";
49 } elsif (! $isN and $inNzone) {
51 print O
join("\t",$pos,$pos-$Nstart),"\n";
52 $Nlen += $pos-$Nstart;
61 $avg=int($Nlen/$Ncount) if $Ncount;
62 print STDERR
" Len:$len\tN-zone: $Nlen <- $Ncount x ",$avg,"\n";