a44da9109b149669559c746cdee09821e279edf7
hiram
  Tue Aug 11 13:10:42 2026 -0700
better organization of the asmAlias update procedure refs #31811

diff --git src/hg/utils/otto/genArk/updateHgcentral.sh src/hg/utils/otto/genArk/updateHgcentral.sh
index 4a6d5c05555..1c63217a319 100755
--- src/hg/utils/otto/genArk/updateHgcentral.sh
+++ src/hg/utils/otto/genArk/updateHgcentral.sh
@@ -1,65 +1,81 @@
 #!/bin/bash
 
 # *** Do not edit this file outside of the source tree. ***
 # This file is from source tree:
 #     kent/src/hg/utils/otto/genArk/updatgeHgcentral.sh
 # called by otto cron job in /hive/data/inside/GenArk/
 # and using the helper script:
 #     kent/src/hg/utils/otto/genArk/genArkListToSql.pl
 
 # exit on any error
 set -beEu -o pipefail
 
 function usage() {
   printf "usage: ./updateCentral.sh makeItSo\n" 1>&2
   printf "updates hgcentraltest.genark with the latest hub list from hgdownload\n" 1>&2
-  printf "and the hgcentraltest.assemblyList table from NCBI listings.\n" 1>&2
+  printf "and the hgcentraltest.assemblyList table from NCBI listings,\n" 1>&2
+  printf "and the hgcentraltest.asmAlias table from NCBI listings.\n" 1>&2
 }
 
 # check for an 'unbound' variable safely
 if [ -z "${1+x}" ]; then
   usage
   exit 255
 fi
 # something is in $1, verify is is 'makeItSo'
 if [ "xxx$1" != "xxxmakeItSo" ]; then
   usage
   exit 255
 fi
 
 cd /hive/data/inside/GenArk
-export DS=`date "+%F"`
-export YYYY=`date "+%Y"`
+export DS=$(date "+%F")
+export YYYY=$(date "+%Y")
 export LC_NUMERIC=en_US
 export msgTo="hclawson@ucsc.edu,otto-group@ucsc.edu"
 export msgFile="/tmp/ottoGenArk.$$.txt"
+export asmAliasLog=""
+export asmAliasRc=0
 
 ###########################################################################
 ### helper functions
 ###########################################################################
 
 function msgToFrom() {
   printf "To: %s\n" "${msgTo}" > ${msgFile}
   printf "From: hiram@soe.ucsc.edu\n" >> ${msgFile}
 }
 
 function sendMsg() {
+  printf "\n%s\n" "${asmAliasLog}" >> ${msgFile}
+  if [ "${asmAliasRc}" -eq 0 ]; then
+     printf "### asmAlias update SUCCESSFUL\n" >> ${msgFile}
+  else
+     printf "### asmAlias update FAILED\n" >> ${msgFile}
+  fi
   cat $msgFile | /usr/sbin/sendmail -t -oi
   rm -f $msgFile
 }
 
+function asmAliasFail() {
+  msgToFrom
+  printf "Subject: ALERT: hgcentraltest.asmAlias update problem\n" >> ${msgFile}
+  printf "\n" >> ${msgFile}
+  sendMsg
+}
+
 function oddRowCounts() {
   todayCount=$1
   mysqlCount=$2
   msgToFrom
   printf "Subject: ALERT: hgcentraltest.genark update problem\n" >> ${msgFile}
   printf "\n" >> ${msgFile}
   printf "# puzzling, count in file %'d is not larger than the MySQL table %'d\n" "${todayCount}" "${mysqlCount}" >> ${msgFile}
   sendMsg
 }
 
 function updateIncorrect() {
   todayCount=$1
   mysqlCount=$2
   msgToFrom
   printf "Subject: ALERT: hgcentraltest.genark update problem\n" >> ${msgFile}
@@ -72,60 +88,71 @@
   todayCount=$1
   mysqlCount=$2
   msgToFrom
   printf "Subject: NOTE: hgcentraltest.genark has been updated\n" >> ${msgFile}
   printf "\n" >> ${msgFile}
   printf "# this message is from the otto cron job:\n" >> "${msgFile}"
   printf "# 37 10 * * 2 /hive/data/inside/GenArk/updateHgcentral.sh makeItSo\n" >> "${msgFile}"
   printf "# today MySQL rowCount %'d vs. previous MySQL rowCount %'d\n" "${todayCount}" "${mysqlCount}" >> ${msgFile}
   sendMsg
 }
 
 ###########################################################################
 ### begin processing
 ###########################################################################
 
+### adding asmAlias table update 2026-08-11
+if asmAliasLog=$(/hive/data/inside/GenArk/asmAlias/runUpdate.sh 2>&1); then
+    asmAliasRc=0
+else
+    asmAliasRc=$?
+    asmAliasFail
+fi
+
 # everything depends on this file from hgdownload
 rsync -a qateam@hgdownload:/mirrordata/hubs/UCSC_GI.assemblyHubList.txt ./list.${DS}
 
 #  see if it became newer than previous
-newSum=`grep -v "^#" list.${DS} | sort | md5sum | cut -d' ' -f1`
-prevSum=`grep -v "^#" previousList.txt | sort | md5sum | cut -d' ' -f1`
+newSum=$(grep -v "^#" list.${DS} | sort | md5sum | cut -d' ' -f1)
+prevSum=$(grep -v "^#" previousList.txt | sort | md5sum | cut -d' ' -f1)
 
-printf "# new list: %d, prevList: %d\n" "`grep -c . list.${DS}`" "`grep -c . previousList.txt`" 1>&2
+printf "# new list: %d, prevList: %d\n" "$(grep -c . list.${DS})" "$(grep -c . previousList.txt)" 1>&2
 
 if [ "${prevSum}" = "${newSum}" ]; then
   rm -f list.${DS}
   ### new assemblyList table in hgcentraltest 2024-08-08
   /hive/data/inside/GenArk/addAssemblyList.sh
+  if [ "${asmAliasRc}" -eq 0 ]; then
+    msgToFrom
+    printf "Subject: NOTE: hgcentraltest.asmAlias has been updated\n" >> ${msgFile}
+    printf "\n" >> ${msgFile}
+    sendMsg
+  fi
   exit 0
 fi
 
 # save this new list in history
 mkdir -p history/${YYYY}
 cp -p list.${DS} history/${YYYY}
 gzip history/${YYYY}/list.${DS}
-countToday=`grep -c -v "^#" list.${DS}`
-rowCount=`hgsql -N hgcentraltest -e 'select count(*) from genark;' | cat`
+countToday=$(grep -c -v "^#" list.${DS})
+rowCount=$(hgsql -N hgcentraltest -e 'select count(*) from genark;' | cat)
 
 if [ "${countToday}" -gt "${rowCount}" ]; then
   ./genArkListToSql.pl list.${DS} > genark.tsv
   ### new assemblyList table in hgcentraltest 2024-08-08 - loads genark table
   /hive/data/inside/GenArk/addAssemblyList.sh
-  newCount=`hgsql -N hgcentraltest -e 'select count(*) from genark;' | cat`
+  newCount=$(hgsql -N hgcentraltest -e 'select count(*) from genark;' | cat)
   if [ "${newCount}" -gt "${rowCount}" ]; then
     updateOK "${newCount}" "${rowCount}"
     rm -f previousList.txt
     mv list.${DS} previousList.txt
   else
     updateIncorrect "${newCount}" "${rowCount}"
     exit 255
   fi
 else
   oddRowCounts "${countToday}" "${rowCount}"
   exit 255
 fi
 
-### adding asmAlias table update 2026-08-11
-/hive/data/inside/GenArk/asmAlias/runUpdate.sh
-
 exit $?