89cf9d0784b0c1529f4a3638c3255f5b407be611
hiram
  Wed Jul 31 18:42:44 2019 -0700
add makefile to function from this source directory and cleaner html output via W3C validator checking refs #23734

diff --git src/hg/makeDb/doc/VGP/mkAsmStats.pl src/hg/makeDb/doc/VGP/mkAsmStats.pl
index 9d5a381..65c01e7 100755
--- src/hg/makeDb/doc/VGP/mkAsmStats.pl
+++ src/hg/makeDb/doc/VGP/mkAsmStats.pl
@@ -1,72 +1,70 @@
 #!/usr/bin/env perl
 
 use strict;
 use warnings;
 use File::stat;
 
 my @orderList;	# asmId of the assemblies in order from the *.list files
 # the order to read the different .list files:
-my @classList = qw( mammal bird amphibian fish );
+my @classList = qw( mammal bird reptile amphibian fish );
 my %class;	# key is asmId, value is from class list
 my $assemblyCount = 0;
 my $overallNucleotides = 0;
 my $overallSeqCount = 0;
 my $overallGapSize = 0;
 my $overallGapCount = 0;
 
 my %betterName;	# key is asmId, value is common name
 
 ##############################################################################
 # from Perl Cookbook Recipe 2.17, print out large numbers with comma delimiters:
 ##############################################################################
 sub commify($) {
     my $text = reverse $_[0];
     $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g;
     return scalar reverse $text
 }
 
 ##############################################################################
 ### start the HTML output
 ##############################################################################
 sub startHtml() {
 
 my $timeStamp = `date "+%F"`;
 chomp $timeStamp;
 
 print <<"END"
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
-                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<!--#set var="TITLE" value="VGP - Vertebrate Genome Project assembly statistics - $timeStamp" -->
+<!DOCTYPE HTML 4.01 Transitional>
+<!--#set var="TITLE" value="VGP - Vertebrate Genomes Project assembly statistics - $timeStamp" -->
 <!--#set var="ROOT" value="../.." -->
 
 <!--#include virtual="\$ROOT/inc/gbPageStartHardcoded.html" -->
 
-<h1>VGP - Vertebrate Genome Project assembly statistics - $timeStamp</h1>
+<h1>VGP - Vertebrate Genomes Project assembly statistics - $timeStamp</h1>
 <p>
 This assembly hub contains some of the first complete assemblies released
 by the <a href='https://vertebrategenomesproject.org/' target=_blank>
-<br><img src='VGPlogo.png' width=280 alt='VGP logo'><br>
-Vertebrate Genome Project.</a>
+Vertebrate Genomes Project.</a><br>
+<img src='VGPlogo.png' width=280 alt='VGP logo'>
 </p>
-<h3>See also: <a href='hubIndex.html' target=_blank>hub access</a> information</h3>
-
 <p>
-NOTE: <em>Click on the column headers to sort the table by that column</em>
+<h3>See also: <a href='hubIndex.html' target=_blank>hub access</a> information</h3>
 </p>
+
 <h3>Data resource links</h3>
+NOTE: <em>Click on the column headers to sort the table by that column</em>
 END
 }
 
 ##############################################################################
 ### start the table output
 ##############################################################################
 sub startTable() {
 print <<"END"
 <table class="sortable" border="1">
 <thead><tr><th>count</th><th>common&nbsp;name<br>view&nbsp;in&nbsp;browser</th>
   <th>scientific&nbsp;name</th>
   <th>NCBI&nbsp;assembly</th>
   <th>sequence<br>count</th><th>genome&nbsp;size<br>nucleotides</th>
   <th>gap<br>count</th><th>unknown&nbsp;bases<br>(gap size sum)</th><th>masking<br>percent</th>
 </tr></thead><tbody>
@@ -90,40 +88,41 @@
   <td align=right>$commaSeqCount</td>
   <td align=right>$commaNuc</td>
   <td align=right>$commaGapCount</td>
   <td align=right>$commaGapSize</td>
   <td colspan=1>&nbsp;</td>
   </tr></tfoot>
 </table>
 END
 }
 
 ##############################################################################
 ### end the HTML output
 ##############################################################################
 sub endHtml() {
 print <<"END"
+</div><!-- closing gbsPage from gbPageStartHardcoded.html -->
+</div><!-- closing container-fluid from gbPageStartHardcoded.html -->
 <!--#include virtual="\$ROOT/inc/gbFooterHardcoded.html"-->
 <script type="text/javascript" src="/js/sorttable.js"></script>
 </body></html>
 END
 }
 
 sub asmCounts($) {
   my ($chromSizes) = @_;
   my ($sequenceCount, $totalSize) = split('\s+', `ave -col=2 $chromSizes | egrep "^count|^total" | awk '{printf "%d\\n", \$NF}' | xargs echo`);
-  printf STDERR "# DBG: asmCounts: $sequenceCount, $totalSize\n";
   return ($sequenceCount, $totalSize);
 }
 
 #    my ($gapSize) = maskStats($faSizeTxt);
 sub maskStats($) {
   my ($faSizeFile) = @_;
   my $gapSize = `grep 'sequences in 1 file' $faSizeFile | awk '{print \$3}'`;
   chomp $gapSize;
   $gapSize =~ s/\(//;
   my $totalBases = `grep 'sequences in 1 file' $faSizeFile | awk '{print \$1}'`;
   chomp $totalBases;
   my $maskedBases = `grep 'sequences in 1 file' $faSizeFile | awk '{print \$9}'`;
   chomp $maskedBases;
   my $maskPerCent = 100.0 * $maskedBases / $totalBases;
   return ($gapSize, $maskPerCent);
@@ -206,59 +205,59 @@
            $commonName =~ s/.*\(//;
            $commonName =~ s/\)//;
            $sciName =~ s/.*:\s+//;
            $sciName =~ s/\s+\(.*//;
         }
       } elsif ($line =~ m/Taxid:/) {
         if ($taxId =~ m/notFound/) {
            ++$itemsFound;
            $taxId = $line;
            $taxId =~ s/.*:\s+//;
         }
       }
     }
     close (FH);
     $commonName = $betterName{$asmId} if (exists($betterName{$asmId}));
-    printf "<tr><th>%d</th><td align=center><a href='https://genome-test.gi.ucsc.edu/cgi-bin/hgGateway?hubUrl=http://genome-test.gi.ucsc.edu/hubs/VGP/hub.txt&genome=%s&position=lastDbPos' target=_blank>%s</a></td>\n", ++$asmCount, $asmId, $commonName;
+    printf "<tr><th>%d</th><td align=center><a href='https://genome-test.gi.ucsc.edu/cgi-bin/hgGateway?hubUrl=http://genome-test.gi.ucsc.edu/hubs/VGP/hub.txt&amp;genome=%s&amp;position=lastDbPos' target=_blank>%s</a></td>\n", ++$asmCount, $asmId, $commonName;
     printf "    <td align=center>%s</td>\n", $sciName;
     printf "    <td align=left><a href='https://www.ncbi.nlm.nih.gov/assembly/%s_%s/' target=_blank>%s</a></td>\n", $gcPrefix, $asmAcc, $asmId;
     printf "    <td align=right>%s</td>\n", commify($seqCount);
     printf "    <td align=right>%s</td>\n", commify($totalSize);
     printf "    <td align=right>%s</td>\n", commify($gapCount);
     printf "    <td align=right>%s</td>\n", commify($gapSize);
     printf "    <td align=right>%.2f</td>\n", $maskPerCent;
     printf "</tr>\n";
   }
 }
 
 ##############################################################################
 ### main()
 ##############################################################################
 
+my $home = $ENV{'HOME'};
+my $srcDir = "$home/kent/src/hg/makeDb/doc/VGP";
 
-open (FH, "<commonNames.txt") or die "can not read commonNames.txt";
+open (FH, "<$srcDir/commonNames.txt") or die "can not read $srcDir/commonNames.txt";
 while (my $line = <FH>) {
   chomp $line;
   my ($asmId, $name) = split('\t', $line);
   $betterName{$asmId} = $name;
 }
 close (FH);
 
-
 foreach my $species (@classList) {
-  my $listFile = "${species}.list";
-  printf STDERR "%s\n", $listFile;
+  my $listFile = "$srcDir/${species}.list";
   open (FH, "<$listFile") or die "can not read $listFile";
   while (my $asmId = <FH>) {
     chomp $asmId;
     push @orderList, $asmId;
     $class{$asmId} = $species;
     ++$assemblyCount;
   }
   close (FH);
 }
 
 startHtml();
 startTable();
 tableContents();
 endTable();
 endHtml();