951ae58cfc4a8b6b7dec665cbabb524abb4fc67a
hiram
  Fri May 1 13:09:53 2020 -0700
add class column in the table for VGP genomes refs #23734

diff --git src/hg/makeDb/doc/asmHubs/mkHubIndex.pl src/hg/makeDb/doc/asmHubs/mkHubIndex.pl
index 724f50d..54600b2 100755
--- src/hg/makeDb/doc/asmHubs/mkHubIndex.pl
+++ src/hg/makeDb/doc/asmHubs/mkHubIndex.pl
@@ -4,30 +4,42 @@
 use warnings;
 
 my $argc = scalar(@ARGV);
 if ($argc != 3) {
   printf STDERR "mkAsmStats Name asmName\n";
   printf STDERR "e.g.: mkHubIndex Primates primates GCF_000001405.39_GRCh38.p13\n";
   exit 255;
 }
 my $Name = shift;
 my $asmHubName = shift;
 my $defaultAssembly = shift;
 
 my $home = $ENV{'HOME'};
 my $toolsDir = "$home/kent/src/hg/makeDb/doc/asmHubs";
 my $commonNameOrder = "$asmHubName.commonName.asmId.orderList.tsv";
+my $vgpIndex = 0;
+$vgpIndex = 1 if ($Name =~ m/vgp/i);
+my %vgpClass;	# key is asmId, value is taxon 'class' as set by VGP project
+if ($vgpIndex) {
+  my $vgpClass = "$home/kent/src/hg/makeDb/doc/vgpAsmHub/vgp.taxId,asmId.class.txt";
+  open (FH, "<$vgpClass") or die "can not read $vgpClass";
+  while (my $line = <FH>) {
+    my ($taxId, $asmId, $class) = split('\t', $line);
+    $vgpClass{$asmId} = $class;
+  }
+  close (FH);
+}
 
 my @orderList;	# asmId of the assemblies in order from the *.list files
 # the order to read the different .list files:
 my $assemblyCount = 0;
 my %betterName;	# key is asmId, value is a common name better than found
 			# in assembly_report file
 
 ##############################################################################
 # 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
 }
@@ -35,31 +47,31 @@
 ##############################################################################
 ### start the HTML output
 ##############################################################################
 sub startHtml() {
 
 my $timeStamp = `date "+%F"`;
 chomp $timeStamp;
 
 # <html xmlns="http://www.w3.org/1999/xhtml">
 
 my $subSetMessage = "subset of $asmHubName only";
 if ($asmHubName eq "vertebrate") {
    $subSetMessage = "subset of other ${asmHubName}s only";
 }
 
-if ($Name =~ m/vgp/i) {
+if ($vgpIndex) {
   print <<"END"
 <!DOCTYPE HTML 4.01 Transitional>
 <!--#set var="TITLE" value="VGP - Vertebrate Genomes Project assembly hub" -->
 <!--#set var="ROOT" value="../.." -->
 
 <!--#include virtual="\$ROOT/inc/gbPageStartHardcoded.html" -->
 
 <h1>VGP - Vertebrate Genomes Project assembly hub</h1>
 <p>
 <a href='https://vertebrategenomesproject.org/' target=_blank>
 <img src='VGPlogo.png' width=280 alt='VGP logo'></a></p>
 <p>
 This assembly hub contains assemblies released
 by the <a href='https://vertebrategenomesproject.org/' target=_blank>
 Vertebrate Genomes Project.</a>
@@ -110,59 +122,64 @@
       <li>Then select the <strong>My Hubs</strong> tab and enter this URL into
           the textbox:
     <br><code>https://hgdownload.soe.ucsc.edu/hubs/$asmHubName/hub.txt</code></li>
       <li> Once you have added the URL to the entry form,
            press the <em><strong>Add Hub</strong></em> button to add the hub.</li>
     </ol>
   </li>
 </ol>
 </p>
 
 <p>
 After adding the hub, you will be redirected to the gateway page.  The
 genome assemblies can be selected from the
 <em>${Name} Hub Assembly</em> dropdown menu.
 Instead of adding all the assemblies in one collected group, use the individual
-<em>link to genome browser</em> in the table below.
+<em>view in browser</em> in the table below.
 </p>
 <h3>See also: <a href='asmStats.html'>assembly statistics</a>,&nbsp;<a href='trackData.html'>track statistics</a> <== additional information for these assemblies.</h3><br>
 <h3>Data resource links</h3>
 <p>
 NOTE: <em>Click on the column headers to sort the table by that column</em><br>
-The <em>common name/link to genome browser</em> will attach only that single assembly to
+The <em>common name/view in browser</em> will attach only that single assembly to
 the genome browser.<br>
 The <em>scientific name/and data download</em> link provides access to the files for that one
 assembly hub.<br>
+The <em>class/VGP link</em> provides access to the VGP GenomeArk page for that genome<br>
 The other links provide access to NCBI resources for these assemblies.
 </p>
 END
 }	#	sub startHtml()
 
 ##############################################################################
 ### start the table output
 ##############################################################################
 sub startTable() {
-print <<"END"
+print '
 <table class="sortable" border="1">
 <thead><tr><th>count</th>
-  <th>common name<br>link&nbsp;to&nbsp;genome&nbsp;browser</th>
+  <th>common&nbsp;name&nbsp;and<br>view&nbsp;in&nbsp;browser</th>
   <th>scientific name<br>and&nbsp;data&nbsp;download</th>
   <th>NCBI&nbsp;assembly</th>
   <th>bioSample</th><th>bioProject</th>
   <th>assembly&nbsp;date,<br>source&nbsp;link</th>
-</tr></thead><tbody>
-END
+';
+
+if ($vgpIndex) {
+  printf "<th>class<br>VGP&nbsp;link</th>\n";
+}
+print "</tr></thead><tbody>\n";
 }	#	sub startTable()
 
 ##############################################################################
 ### end the table output
 ##############################################################################
 sub endTable() {
 
 print <<"END"
 
 </tbody>
 </table>
 END
 }	#	sub endTable()
 
 ##############################################################################
@@ -282,30 +299,37 @@
     }
     close (FH);
     my $hubUrl = "https://hgdownload.soe.ucsc.edu/hubs/$accessionDir/$accessionId";
     printf "<tr><td align=right>%d</td>\n", ++$rowCount;
 ###    printf "<td align=center><a href='https://genome.ucsc.edu/cgi-bin/hgGateway?hubUrl=%s/hub.txt&amp;genome=%s&amp;position=lastDbPos' target=_blank>%s</a></td>\n", $hubUrl, $accessionId, $commonName;
     printf "<td align=center><a href='https://genome.ucsc.edu/h/%s' target=_blank>%s</a></td>\n", $accessionId, $commonName;
     printf "    <td align=center><a href='%s/' target=_blank>%s</a></td>\n", $hubUrl, $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;
     if ( $bioSample ne "notFound" ) {
     printf "    <td align=left><a href='https://www.ncbi.nlm.nih.gov/biosample/?term=%s' target=_blank>%s</a></td>\n", $bioSample, $bioSample;
     } else {
     printf "    <td align=left>n/a</td>\n";
     }
     printf "    <td align=left><a href='https://www.ncbi.nlm.nih.gov/bioproject/?term=%s' target=_blank>%s</a></td>\n", $bioProject, $bioProject;
     printf "    <td align=center><a href='%s' target=_blank>%s</a></td>\n", $ncbiFtpLink, $asmDate;
+    if ($vgpIndex) {
+      my $sciNameUnderscore = $sciName;
+      $sciNameUnderscore =~ s/ /_/g;
+      $sciNameUnderscore = "Strigops_habroptilus" if ($sciName =~ m/Strigops habroptila/);
+
+      printf "    <td align=center><a href='https://vgp.github.io/genomeark/%s/' target=_blank>%s</a></td>\n", $sciNameUnderscore, $vgpClass{$asmId}
+    }
     printf "</tr>\n";
   }
 }	#	sub tableContents()
 
 ##############################################################################
 ### main()
 ##############################################################################
 
 open (FH, "<$toolsDir/${commonNameOrder}") or die "can not read ${commonNameOrder}";
 while (my $line = <FH>) {
   next if ($line =~ m/^#/);
   chomp $line;
   my ($commonName, $asmId) = split('\t', $line);
   push @orderList, $asmId;
   $betterName{$asmId} = $commonName;