N50 and N90 summarize the lengths of pieces in a genome assembly. N50 is the length at which pieces ordered from longest to shortest reach half the assembled sequence. N90 uses 90 percent. The archived Perl example below contains formatting errors.
#/usr/bin/perl -w
use strict;
my ($len,$total)=(0,0);
my @x;
while(<>){
if(/^\>\@/){
if(len>0)
total+=$len;
push @x,$len;
}
len=0;
else
s///g;
len+=length();
if (len>0){
$total+=$len;
push @x,len;
@x=sortb<=>a @x;
my (count,$half)=(0,0);
for (my $j=0;$j<@x;$j++){
$count+=$xj;
if (($count>=$total/2)&&(half==0))
print "N50:xj\n";
$half=$xj
}elsif ($count>=$total*0.9){
print "N90: $x$j\n";
exit;
}
}
댓글 0