ede2fd190d25f754238a2f78b25249d400b596a3 hiram Thu Apr 14 22:10:55 2022 -0700 fixup the index creation to stuff in the "promoted" hub that is no longer in the tsv listings refs #29259 diff --git src/hg/makeDb/doc/asmHubs/trackData.pl src/hg/makeDb/doc/asmHubs/trackData.pl index 3ac3983..289789c 100755 --- src/hg/makeDb/doc/asmHubs/trackData.pl +++ src/hg/makeDb/doc/asmHubs/trackData.pl @@ -1,19 +1,20 @@ #!/usr/bin/env perl use strict; use warnings; +use File::Basename; 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; } @@ -586,31 +587,66 @@ } # foreach my $track (@trackList) printf "</tr>\n"; $asmCounted += 1; if ($asmId =~ m/^GC/) { printf STDERR "# %03d\t%02d tracks\t%s\n", $asmCounted, $tracksCounted, $asmId; } else { printf STDERR "# %03d\t%02d tracks\t%s_%s (%s)\n", $asmCounted, $tracksCounted, $accessionId, $asmName, $asmId; } } } ############################################################################## ### main() ############################################################################## +# if there is a 'promoted' list, it has been taken out of the 'orderList' +# so will need to stuff it back in at the correct ordered location +my %promotedList; # key is asmId, value is common name +my $promotedList = dirname(${orderList}) . "/promoted.list"; +my @promotedList; # contents are asmIds, in order by lc(common name) +my $promotedIndex = -1; # to walk through @promotedList; + +if ( -s "${promotedList}" ) { + open (FH, "<${promotedList}" ) or die "can not read ${promotedList}"; + while (my $line = <FH>) { + next if ($line =~ m/^#/); + chomp $line; + my ($asmId, $commonName) = split('\t', $line); + $promotedList{$asmId} = $commonName; + } + close (FH); + foreach my $asmId ( sort { lc($promotedList{$a}) cmp lc($promotedList{$b}) } keys %promotedList) { + push @promotedList, $asmId; + } + $promotedIndex = 0; +} + 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); + if ( ($promotedIndex > -1) && ($promotedIndex < scalar(@promotedList))) { + my $checkInsertAsmId = $promotedList[$promotedIndex]; + my $checkInsertName = $promotedList{$checkInsertAsmId}; + # insert before this commonName when alphabetic before + if (lc($checkInsertName) lt lc($commonName)) { + push @orderList, $checkInsertAsmId; + $commonName{$checkInsertAsmId} = $checkInsertName; + ++$assemblyTotal; + printf STDERR "# inserting '%s' before '%s' at # %03d\n", $checkInsertName, $commonName, $assemblyTotal; + ++$promotedIndex; # only doing one at this time + # TBD: will need to improve this for more inserts + } + } push @orderList, $asmId; $commonName{$asmId} = $commonName; ++$assemblyTotal; } close (FH); startHtml(); startTable(); tableContents(); endTable(); endHtml();