c8828612e3aba9e6c3072768129de10abe337878 hiram Fri May 29 11:29:04 2020 -0700 now allow orderList to be specifically stated and begin common set of html functions refs #23734 diff --git src/hg/makeDb/doc/asmHubs/mkHubIndex.pl src/hg/makeDb/doc/asmHubs/mkHubIndex.pl index c88c340..e2ee199 100755 --- src/hg/makeDb/doc/asmHubs/mkHubIndex.pl +++ src/hg/makeDb/doc/asmHubs/mkHubIndex.pl @@ -1,45 +1,55 @@ #!/usr/bin/env perl +# +# mkHubIndex.pl - construct index.html page for a set of assemblies in a hub +# use strict; use warnings; +use FindBin qw($Bin); +use lib "$Bin"; +use commonHtml; my $argc = scalar(@ARGV); if ($argc != 4) { printf STDERR "mkHubIndex.pl Name asmName defaultAsmId [two column name list] > index.html\n"; printf STDERR "e.g.: mkHubIndex Primates primates GCF_000001405.39_GRCh38.p13 primates.commonName.asmId.orderList.tsv\n"; printf STDERR "the name list is found in \$HOME/kent/src/hg/makeDb/doc/asmHubs/\n"; printf STDERR "\nthe two columns are 1: asmId (accessionId_assemblyName)\n"; printf STDERR "column 2: common name for species, columns separated by tab\n"; printf STDERR "The result prints to stdout the index.html page for this set of assemblies\n"; exit 255; } +my $home = $ENV{'HOME'}; +my $toolsDir = "$home/kent/src/hg/makeDb/doc/asmHubs"; + my $Name = shift; my $asmHubName = shift; my $defaultAssembly = shift; -my $commonNameOrder = shift; - -printf STDERR "# mkHubIndex %s %s %s %s\n", $Name, $asmHubName, $defaultAssembly, $commonNameOrder; +my $inputList = shift; +my $orderList = $inputList; +if ( ! -s "$orderList" ) { + $orderList = $toolsDir/$inputList; +} -my $home = $ENV{'HOME'}; -my $toolsDir = "$home/kent/src/hg/makeDb/doc/asmHubs"; +printf STDERR "# mkHubIndex %s %s %s %s\n", $Name, $asmHubName, $defaultAssembly, $orderList; 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"; + 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 %commonName; # key is asmId, value is a common name, perhaps more appropriate # than found in assembly_report file ############################################################################## @@ -55,45 +65,53 @@ ### 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 ($vgpIndex) { + my $vgpSubset = "(set of primary assemblies)"; + if ($orderList =~ m/vgp.alternate/) { + $vgpSubset = "(set of alternate/haplotype assemblies)"; + } elsif ($orderList =~ m/vgp.trio/) { + $vgpSubset = "(set of trio assemblies, maternal/paternal)"; + } elsif ($orderList =~ m/vgp.legacy/) { + $vgpSubset = "(set of legacy/superseded assemblies)"; + } 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> +Vertebrate Genomes Project.</a> $vgpSubset </p> END } else { print <<"END" <!DOCTYPE HTML 4.01 Transitional> <!--#set var="TITLE" value="$Name genomes assembly hubs" --> <!--#set var="ROOT" value="../.." --> <!--#include virtual="\$ROOT/inc/gbPageStartHardcoded.html" --> <h1>$Name Genomes assembly hubs</h1> <p> Assemblies from NCBI/Genbank/Refseq sources, $subSetMessage. </p> @@ -182,68 +200,33 @@ ############################################################################## sub endTable() { print <<"END" </tbody> </table> END } # sub endTable() ############################################################################## ### end the HTML output ############################################################################## sub endHtml() { -# do not print these links for VGP index - -if ((0 == $vgpIndex) && ($asmHubName ne "viral")) { - printf "<p>\n<table border='1'><thead>\n"; - printf "<tr><th colspan=6 style='text-align:center;'>Additional hubs with collections of assemblies</th></tr>\n"; - printf "<tr><th>Assembly hubs index pages: </th>\n"; - printf "<th><a href='../primates/index.html'>Primates</a></th>\n"; - printf "<th><a href='../mammals/index.html'>Mammals</a></th>\n"; - printf "<th><a href='../birds/index.html'>Birds</a></th>\n"; - printf "<th><a href='../fish/index.html'>Fish</a></th>\n"; - printf "<th><a href='../vertebrate/index.html'>other vertebrates</a></th>\n"; - - printf "</tr><tr>\n"; - printf "<th>Hubs assembly statistics: </th>\n"; - printf "<th><a href='../primates/asmStats.html'>Primates</a></th>\n"; - printf "<th><a href='../mammals/asmStats.html'>Mammals</a></th>\n"; - printf "<th><a href='../birds/asmStats.html'>Birds</a></th>\n"; - printf "<th><a href='../fish/asmStats.html'>Fish</a></th>\n"; - printf "<th><a href='../vertebrate/asmStats.html'>other vertebrates</a></th>\n"; - - printf "</tr><tr>\n"; - printf "<th>Hubs track statistics: </th>\n"; - printf "<th><a href='../primates/trackData.html'>Primates</a></th>\n"; - printf "<th><a href='../mammals/trackData.html'>Mammals</a></th>\n"; - printf "<th><a href='../birds/trackData.html'>Birds</a></th>\n"; - printf "<th><a href='../fish/trackData.html'>Fish</a></th>\n"; - printf "<th><a href='../vertebrate/trackData.html'>other vertebrates</a></th>\n"; - - printf "</tr></thead>\n</table>\n</p>\n"; -} +&commonHtml::otherHubLinks($vgpIndex, $asmHubName); +&commonHtml::htmlFooter($vgpIndex, $asmHubName); -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 endHtml() ############################################################################## ### tableContents() ############################################################################## sub tableContents() { my $rowCount = 0; foreach my $asmId (@orderList) { my ($gcPrefix, $asmAcc, $asmName) = split('_', $asmId, 3); my $accessionId = sprintf("%s_%s", $gcPrefix, $asmAcc); my $accessionDir = substr($asmId, 0 ,3); $accessionDir .= "/" . substr($asmId, 4 ,3); $accessionDir .= "/" . substr($asmId, 7 ,3); $accessionDir .= "/" . substr($asmId, 10 ,3); my $ncbiFtpLink = "ftp://ftp.ncbi.nlm.nih.gov/genomes/all/$accessionDir/$asmId"; @@ -331,31 +314,31 @@ if (! defined($vgpClass{$asmId})) { printf STDERR "# ERROR: no 'class' defined for VGP assembly %s\n", $asmId; exit 255; } 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}"; +open (FH, "<${orderList}") or die "can not read ${orderList}"; while (my $line = <FH>) { next if ($line =~ m/^#/); chomp $line; my ($asmId, $commonName) = split('\t', $line); push @orderList, $asmId; $commonName{$asmId} = $commonName; ++$assemblyCount; } close (FH); startHtml(); startTable(); tableContents(); endTable(); endHtml();