#!/usr/bin/perl -w
use strict;
#use Perl::Tidy;
#use Getopt::Long;
my ($head,%h,$key,$len,@len_arr,$total,$num,$sub_count,$first);
print "input your sequence file name,then press Enter!\n";
$first=;
open IN,"<$first";

while (){
chomp;
if(/^>/){ $head=$_;}else{$h{$head}.=$_}
}
#  read data into hash
foreach $key(keys %h){ chomp$key;
  $len=length($h{$key});
  push @len_arr,$len;
 
}

for (0..$#len_arr){$total+=$len_arr[$_];}

#open OUT,">o";
foreach $num(sort{$b $a}@len_arr){       # like grep map
  $sub_count+=$num;
   if( $sub_count>= ($total*0.5) ){print "Sequence N50 value:$num\n";last;}else{next;}
   #print  OUT "$num\n";
}
exit;
##########like good ,can works  2015-4-20 xiaojin haerbin
  
10-09 09:43
查看更多