N50 and N90 describe how much of a genome assembly is contained in its longer pieces. Order the pieces from longest to shortest and add their lengths. N50 is the length of the piece that takes the total to at least 50 percent, and N90 uses 90 percent.
the length of the smallest contig S in the sorted list of all
contigs where the cumulative length from the largest contig to
contig S is at least 50% of the total length.
perl -e 'my ($len,$total)=(0,0);my @x;while(<>){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+=$x[$j;if(($count>=$total/2)&&($half==0)){print "N50: $xj}elsif($count>=$total*0.9){print" target="_blank" rel="noopener">"N90: $x[$j\n";exit;}}' contigs.fahttp://seqanswers.com/forums/showthread.php?t=2766
N50 N90 calculation using Perl code
http://seqanswers.com/forums/showthread.php?t=2766
댓글 0