7133bbf60ed53ab306628d72050c9379ee74a9f1
hiram
  Mon Jun 8 14:23:43 2026 -0700
watch for an assembly build to have begun refs #31811

diff --git src/hg/utils/otto/userRequests/asmRequestWatch.sh src/hg/utils/otto/userRequests/asmRequestWatch.sh
index ae2769498fd..e1e7161256d 100755
--- src/hg/utils/otto/userRequests/asmRequestWatch.sh
+++ src/hg/utils/otto/userRequests/asmRequestWatch.sh
@@ -73,45 +73,89 @@
     "SELECT email FROM ottoRequest WHERE id = ${reqId};" ${centDb})"
   if [ -z "${toAddr}" ]; then
     printf "ERROR: sendNotification: no email for request %s\n" "${reqId}" 1>&2
     return 1
   fi
   local bcc="genark-request-group@ucsc.edu"
   local from="genome-www@soe.ucsc.edu"
   local bounce="gb"
   bounce+="aut"
   bounce+="o"
   bounce+="@"
   bounce+="uc"
   bounce+="sc."
   bounce+="ed"
   bounce+="u"
-  printf "# DBG sending\n" 1>&2
   # -f sets the envelope sender (becomes Return-Path at delivery and the
   #    bounce address); -t reads recipients from To:/Cc:/Bcc: headers;
   #    -oi prevents a lone "." in body from ending the message
   {
     printf "From: %s\n" "${from}"
     printf "To: %s\n" "${toAddr}"
     printf "Bcc: %s\n" "${bcc}"
     printf "Reply-To: %s\n" "${from}"
     printf "Subject: %s\n" "${subject}"
     printf "\n"
     printf "%s\n" "${msgBody}"
   } | /usr/sbin/sendmail -f "${bounce}" -t -oi
 }	# function sendNotification()
 
+##############################################################################
+### accessionToPath - given an accession - expand to path name
+##############################################################################
+function accessionToPath() {
+  local acc="${1}"
+  local gcX="${acc:0:3}"
+  local d0="${acc:4:3}"
+  local d1="${acc:7:3}"
+  local d2="${acc:10:3}"
+  local pathName="${gcX}/${d0}/${d1}/${d2}"
+  printf "%s" "${pathName}"
+}	# function accessionToPath()
+
+############################################################################
+# phase 1: watch for new requests, detect when assembly build has started
+############################################################################
+while IFS=$'\t' read -r reqId fromDb; do
+  accPath=$(accessionToPath "${fromDb}")
+  # if the trackData/ directory is present, the build is running
+  shopt -s nullglob  # make globs expand to nothing if no matches
+  trackDataDirs=(/hive/data/genomes/asmHubs/allBuild/${accPath}/${fromDb}_*/trackData)
+  shopt -u nullglob  # restore default behavior
+  # Check the results
+  case ${#trackDataDirs[@]} in
+    0)	# no directory seen yet, nothing happening
+      ;;
+    1)  # single directory seen - build has started - set the buildDir
+      buildDir=$(dirname "$(realpath "${trackDataDirs[0]}")")
+      /cluster/bin/x86_64/${hgSql} -N -e \
+        "UPDATE ottoRequest SET status=2, buildDir='${buildDir}' \
+         WHERE id=${reqId};" ${centDb}
+      ;;
+    *)
+      scriptName=$(basename "$0")
+      printf "ERROR: %s: Multiple trackData directories found for %s:\n" "${scriptName}" "${accPath}" 1>&2
+      printf "  %s\n" "${trackDataDirs[@]}" 1>&2
+      setErrorStatus "${reqId}"
+      ;;
+  esac
+
+done < <(/cluster/bin/x86_64/${hgSql} -N -B -e \
+  "SELECT id, fromDb FROM ottoRequest WHERE status = 1 AND buildDir = '' AND requestType = 'assembly';" \
+  ${centDb})
+
+
 ############################################################################
 # check for phase 6: the assembly is complete and available on the RR
 #       this checking and setting status 6 is currently done manually,
 #       eventually this will become automatic.
 ############################################################################
 while IFS=$'\t' read -r reqId fromDb comment requestTime; do
 
   export gcX="${fromDb:0:3}"
   export d0="${fromDb:4:3}"
   export d1="${fromDb:7:3}"
   export d2="${fromDb:10:3}"
   export gbDbPath="/gbdb/genark/${gcX}/${d0}/${d1}/${d2}/${fromDb}/hub.txt"
   export hubTxt="https://genome.ucsc.edu/cgi-bin/hgTracks?genome=${fromDb}&hubUrl=${gbDbPath}"
 
   sendNotification "${reqId}" \