ed292c11c5008eec8dd80894e385fead2d77a97c
hiram
  Thu Oct 21 11:59:45 2021 -0700
correct result when the first contig satisifies the measurement no redmine

diff --git src/hg/utils/automation/n50.pl src/hg/utils/automation/n50.pl
index 8ac8281..2fb6da3 100755
--- src/hg/utils/automation/n50.pl
+++ src/hg/utils/automation/n50.pl
@@ -58,25 +58,29 @@
 
     my $prevContig = "";
     my $prevSize = 0;
 
     $totalSize = 0;
     my $contigCount =0;
     foreach my $key (sort { $sizes{$b} <=> $sizes{$a} } keys %sizes) {
 	++$contigCount;
 	$totalSize += $sizes{$key};
 	if ($totalSize > $n50Size) {
 	    my $prevName = $prevContig;
 	    $prevName =~ s/_X_[0-9]+//;
 	    my $origName = $key;
 	    $origName =~ s/_X_[0-9]+//;
 	    printf "# cumulative\tN50 count\tcontig\tcontig size\n";
+	    if (1 == $contigCount) {
+	      printf "%d\t%d\t%s\t%d\n", $totalSize, $contigCount, $origName, $sizes{$key};
+            } else {
 	      printf "%d\t%d\t%s\t%d\n",
 		  $totalSize-$sizes{$key},$contigCount-1,$prevName, $prevSize;
+            }
 	    printf "%d one half size\n", $n50Size;
 	    printf "%d\t%d\t%s\t%d\n", $totalSize, $contigCount, $origName, $sizes{$key};
 	    last;
 	}
 	$prevContig = $key;
 	$prevSize = $sizes{$key};
     }
 }