51b9776d380b32ed640c81917ec2d9a3528d4b06
max
  Wed Sep 9 08:58:55 2026 -0700
UniProt otto: notifyRun.sh could not see that the TrEMBL parse had started

doUniprot's run() logs its "Running: <cmd>" line after os.system returns, not
before, so the log says a command has finished, never that it is running. The
stage ladder keyed the TrEMBL stage off that line, which meant it only noticed
TrEMBL once TrEMBL was over: a three-day parse would have been reported as
"parsing the SwissProt XML" throughout, including in every twelve-hour heartbeat.

Ask the process table for a running uniprotToTab --trembl instead, and keep the
log check as the fallback for after the process is gone. Later stages still
override it, so the ladder is unchanged otherwise. Caught on the live run, which
had the flag in its command line while the notifier still said SwissProt.

refs #38300

diff --git src/hg/utils/otto/uniprot/notifyRun.sh src/hg/utils/otto/uniprot/notifyRun.sh
index 734918e7dcc..4de2fe28166 100755
--- src/hg/utils/otto/uniprot/notifyRun.sh
+++ src/hg/utils/otto/uniprot/notifyRun.sh
@@ -44,31 +44,35 @@
       echo
       echo "last log lines:"
       grep -a " - " $log 2>/dev/null | tail -12
     } | mail -s "uniprot otto: $subject" "$to"
 }
 
 # Work out which stage the log has reached. Later matches win, so the order is the order
 # the pipeline goes through.
 stageOf() {
     s="starting up"
     grep -aq "Downloading NCBI gene2refseq"  $log 2>/dev/null && s="downloading the NCBI gene2refseq file"
     grep -aq "lftp ftp"                      $log 2>/dev/null && s="mirroring UniProt from expasy"
     grep -aq "Moving files from"             $log 2>/dev/null && s="download finished, moving files into place"
     grep -aq "not newer than file in"        $log 2>/dev/null && s="no new UniProt release, nothing to do"
     grep -aq "Converting uniprot XML"        $log 2>/dev/null && s="parsing the SwissProt XML"
-    grep -aq -- "--trembl"                   $log 2>/dev/null && s="parsing the TrEMBL XML, this is the multi-day part"
+    # doUniprot's run() logs its "Running: ..." line only after the command returns, so the
+    # log cannot tell us that the TrEMBL parse has started, only that it has finished.
+    # Ask the process table instead, and fall back to the log once the process is gone.
+    { pgrep -f "uniprotToTab.*--trembl" > /dev/null 2>&1 || grep -aq -- "--trembl" $log 2>/dev/null; } \
+                                             && s="parsing the TrEMBL XML, this is the multi-day part"
     grep -aq "checking/creating pslMap"      $log 2>/dev/null && s="parse done, building the protein-to-genome mappings on the cluster"
     grep -aq "Wrote release string"          $log 2>/dev/null && s="writing version files and flipping the bigBeds"
     grep -aq "Archive: Copied"               $log 2>/dev/null && s="copying to the hgdownload archive"
     grep -aq "Uniprot pipeline completed"    $log 2>/dev/null && s="finished"
     echo "$s"
 }
 
 running() {
     pgrep -f "doUniprot run" > /dev/null 2>&1
 }
 
 if ! running ; then
     echo "No doUniprot run in progress, nothing to watch."
     exit 1
 fi