Difference between revisions of "N50 and N90"
(Created page with "<p>The N50 contig size is a weighted median value and defined as <br /> the length of the smallest contig S in the sorted list of all <br /> contigs where the cumulative length f...") |
|||
Line 6: | Line 6: | ||
<p> </p> | <p> </p> | ||
<p>perl -e 'my ($len,$total)=(0,0);my @x;while(<>){if(/^[\>\@]/){if($len>0){$total+=$len;push@x,$len;};$len=0;}else{s/\s//g;$len+=length($_);}}if ($len>0){$total+=$len;push @x,$len;}@x=sort{$b<=>$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: $x[$j]\n";$half=$x[$j]}elsif($count>=$total*0.9){print "N90: $x[$j]\n";exit;}}' contigs.fahttp://seqanswers.com/forums/showthread.php?t=2766</p> | <p>perl -e 'my ($len,$total)=(0,0);my @x;while(<>){if(/^[\>\@]/){if($len>0){$total+=$len;push@x,$len;};$len=0;}else{s/\s//g;$len+=length($_);}}if ($len>0){$total+=$len;push @x,$len;}@x=sort{$b<=>$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: $x[$j]\n";$half=$x[$j]}elsif($count>=$total*0.9){print "N90: $x[$j]\n";exit;}}' contigs.fahttp://seqanswers.com/forums/showthread.php?t=2766</p> | ||
− | <p> </p> | + | <p>[[N50 N90 calculation using Perl code]] </p> |
<p> </p> | <p> </p> | ||
<p><a href="http://seqanswers.com/forums/showthread.php?t=2766">http://seqanswers.com/forums/showthread.php?t=2766</a></p> | <p><a href="http://seqanswers.com/forums/showthread.php?t=2766">http://seqanswers.com/forums/showthread.php?t=2766</a></p> | ||
<p> </p> | <p> </p> |
Latest revision as of 19:41, 8 November 2010
The N50 contig size is a weighted median value and defined as
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(/^[\>\@]/){if($len>0){$total+=$len;push@x,$len;};$len=0;}else{s/\s//g;$len+=length($_);}}if ($len>0){$total+=$len;push @x,$len;}@x=sort{$b<=>$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: $x[$j]\n";$half=$x[$j]}elsif($count>=$total*0.9){print "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