62e62c6404011a058ce40b13b5d6a2a4d5724f29 hiram Fri Aug 21 22:39:45 2026 -0700 corresponding fix for updates to doNcbiGene.pl better indexing for ncbiGene refs #34917 diff --git src/hg/utils/automation/AsmHub.pm src/hg/utils/automation/AsmHub.pm index f52b71749c3..8f62543fc0c 100755 --- src/hg/utils/automation/AsmHub.pm +++ src/hg/utils/automation/AsmHub.pm @@ -43,46 +43,46 @@ # given a fully qualified asmId, e.g.: GCA_018504075.1_HG02723.alt.pat.f1_v2 # return the string representating the path: GCA/018/504/075 sub asmIdToPath($) { my ($asmId) = @_; my $gcX = substr($asmId, 0, 3); my $d0 = substr($asmId, 4, 3); my $d1 = substr($asmId, 7, 3); my $d2 = substr($asmId, 10, 3); my $ret = sprintf("%s/%s/%s/%s", $gcX, $d0, $d1, $d2); return $ret; } # Look up NCBI's own annotation provider/name/date for an accession from # the 'genark' database's assemblySummary{Genbank,Refseq} table, falling # back to the ...Historical variant when the accession isn't in the -# current one (a superseded/suppressed assembly). Returns an empty list -# if found in neither. +# current one (a superseded/suppressed assembly). Returns ("", "", "") +# if found in neither, so callers always get three defined strings. sub fetchAnnotationInfo($$) { my ($asmType, $accession) = @_; my $table = "assemblySummary" . ucfirst($asmType); foreach my $t ($table, "${table}Historical") { my $result = `hgsql -N -e 'select annotationProvider,annotationName,annotationDate from $t where assemblyAccession="$accession";' genark 2> /dev/null`; chomp $result; next if ($result eq ""); my ($provider, $name, $date) = split('\t', $result); $provider = "" if ( ! defined $provider || $provider eq "NULL" ); $name = "" if ( ! defined $name || $name eq "NULL" ); $date = "" if ( ! defined $date || $date eq "NULL" ); return ($provider, $name, $date) if ($provider ne "" || $name ne "" || $date ne ""); } - return (); + return ("", "", ""); } # fetchAnnotationInfo # Build the 'ncbiGene' track description HTML body. Used both by # asmHubNcbiGene.pl for the live track, and by doNcbiGene.pl for the # one-track archive hubs it writes under trackData/ncbiGene/archive/ -- # which is why every path is taken explicitly rather than assumed from # the usual trackData/ layout. $archiveNote, if given, is printed as a # lead-in banner ahead of the normal description (used for the archived # copies; the live page passes it undef). sub ncbiGeneDescription($$$$$;$) { my ($bbPath, $statsPath, $chromSizes, $namesFile, $ncbiAsmId, $archiveNote) = @_; if ( ! -s $bbPath ) { printf STDERR "ERROR: can not find %s file\n", $bbPath; exit 255; @@ -96,30 +96,34 @@ # bare accession (GCF_937001465.1), not the full asmId with its # _assemblyName suffix -- used both for the genark annotation lookup # below and for the archived-hub links further down. my $accession = "$partNames[0]_$partNames[1]"; # the .bb's mtime is stamped from the source gff's own mtime (see the # 'touch -r $gffFile' step in doNcbiGene.pl), so it doubles as this # track's own version/build date -- the same convention archiving uses # to name archive/<date>/ directories, which is why this lines up with # the dates listed under "Archived versions" below. my ($mday,$mon,$year) = (localtime(stat($bbPath)->mtime))[3,4,5]; my $dataVersion = sprintf("%04d-%02d-%02d", $year+1900, $mon+1, $mday); my $totalBases = asmSize($chromSizes); + if ( ! $totalBases ) { + printf STDERR "ERROR: asmSize returned no total from %s\n", $chromSizes; + exit 255; + } my $geneStats = `cat $statsPath | awk '{printf "%d\\n", \$2}' | xargs echo`; chomp $geneStats; my ($itemCount, $basesCovered) = split('\s+', $geneStats); my $percentCoverage = sprintf("%.3f", 100.0 * $basesCovered / $totalBases); $itemCount = commify($itemCount); $basesCovered = commify($basesCovered); my $totalBasesText = commify($totalBases); my $em = "<em>"; my $noEm = "</em>"; my $assemblyDate = `grep -v "^#" $namesFile | cut -f9`; chomp $assemblyDate; my $organism = `grep -v "^#" $namesFile | cut -f5`; chomp $organism;