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/trackData.pl src/hg/makeDb/doc/asmHubs/trackData.pl index ab7922d..55b31ca 100755 --- src/hg/makeDb/doc/asmHubs/trackData.pl +++ src/hg/makeDb/doc/asmHubs/trackData.pl @@ -1,53 +1,60 @@ #!/usr/bin/env perl use strict; use warnings; +use FindBin qw($Bin); +use lib "$Bin"; +use commonHtml; use File::stat; my $argc = scalar(@ARGV); if ($argc < 3) { printf STDERR "usage: trackData.pl Name asmHubName [two column name list] > trackData.html\n"; printf STDERR "e.g.: trackData.pl Mammals mammals mammals.asmId.commonName.tsv > trackData.html\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"; exit 255; } +my $home = $ENV{'HOME'}; +my $toolsDir = "$home/kent/src/hg/makeDb/doc/asmHubs"; + my $testOutput = 0; my $spliceOut = -1; if ($argc > 2) { for (my $i = 0; $i < $argc; ++$i) { if ($ARGV[$i] =~ /-test/) { $testOutput = 1; $spliceOut = $i; } } } if ($spliceOut != -1) { splice @ARGV, $spliceOut, 1; } my $Name = shift; my $asmHubName = shift; -my $commonNameOrder = shift; - -my $home = $ENV{'HOME'}; -my $toolsDir = "$home/kent/src/hg/makeDb/doc/asmHubs"; +my $inputList = shift; +my $orderList = $inputList; +if ( ! -s "$orderList" ) { + $orderList = $toolsDir/$inputList; +} -my @orderList; # asmId of the assemblies in order from the commonNameOrder file +my @orderList; # asmId of the assemblies in order from the orderList file my %commonName; # key is asmId, value is a common name, perhaps more appropriate # than found in assembly_report file # assembly_report my $vgpIndex = 0; $vgpIndex = 1 if ($Name =~ m/vgp/i); my $assemblyTotal = 0; # complete list of assemblies in this group my $asmCount = 0; # count of assemblies completed and in the table my $overallNucleotides = 0; my $overallSeqCount = 0; my $overallGapSize = 0; my $overallGapCount = 0; ############################################################################## # from Perl Cookbook Recipe 2.17, print out large numbers with comma delimiters: @@ -108,45 +115,53 @@ ############################################################################## ### start the HTML output ############################################################################## sub startHtml() { my $timeStamp = `date "+%F"`; chomp $timeStamp; 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 hubs, track statistics" --> <!--#set var="ROOT" value="../.." --> <!--#include virtual="\$ROOT/inc/gbPageStartHardcoded.html" --> <h1>VGP - Vertebrate Genomes Project assembly hubs, track statistics</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, track statistics" --> <!--#set var="ROOT" value="../.." --> <!--#include virtual="\$ROOT/inc/gbPageStartHardcoded.html" --> <h1>$Name Genomes assembly hubs, track statistics</h1> <p> Assemblies from NCBI/Genbank/Refseq sources, $subSetMessage. </p> @@ -249,67 +264,33 @@ END } else { print <<"END" </tbody> </table> END } } # sub endTable() ############################################################################## ### end the HTML output ############################################################################## sub endHtml() { -# do not print these links for VGP index +&commonHtml::otherHubLinks($vgpIndex, $asmHubName); +&commonHtml::htmlFooter($vgpIndex, $asmHubName); -if ((0 == $vgpIndex) && ($asmHubName ne "viral")) { - printf "<p>\n<table border='1'><thead>\n<tr>"; - printf "<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/asm.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"; -} - -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() sub asmCounts($) { my ($chromSizes) = @_; my ($sequenceCount, $totalSize) = split('\s+', `ave -col=2 $chromSizes | egrep "^count|^total" | awk '{printf "%d\\n", \$NF}' | xargs echo`); return ($sequenceCount, $totalSize); } # my ($gapSize, $maskPerCent, $sizeNoGaps) = maskStats($faSizeTxt); sub maskStats($) { my ($faSizeFile) = @_; my $sizeNoGaps = `grep 'sequences in 1 file' $faSizeFile | awk '{print \$4}'`; my $gapSize = `grep 'sequences in 1 file' $faSizeFile | awk '{print \$3}'`; chomp $gapSize; $gapSize =~ s/\(//; @@ -491,31 +472,31 @@ printf " <td align=right>%s<br>(%s)</td>\n", $itemCount, $percentCover; } } $tracksCounted += 1 if ($itemCount ne "n/a"); } # foreach my $track (@trackList) printf "</tr>\n"; $asmCounted += 1; printf STDERR "# %03d\t%02d tracks\t%s\n", $asmCounted, $tracksCounted, $asmId; } } ############################################################################## ### 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; ++$assemblyTotal; } close (FH); startHtml(); startTable(); tableContents(); endTable(); endHtml();