042acb30f02d050444afd846b3f026eb33c99ab1 max Wed Sep 9 08:38:02 2026 -0700 varChat otto: don't blank the track's version file when the fetch fails /gbdb/hg38/bbi/varChatVersion.txt symlinks straight to /hive/data/outside/otto/varChat/version.txt, so the browser reads that file directly, and wget truncates its -O target before it has anything to write there. A failed or partial fetch therefore left the track showing an empty version. By that point the run has already done "mv varChat.hg38.latest.bb varChat.hg38.bb", so the new data is live and only the version string is gone, and set -e aborting afterwards does not undo it. VarChat only updates when upstream changes, and upstream has been on v1.1 - 2025-11-07 for ten months, so a blank could sit there that long. Fetch to version.new.txt, require it to be non-empty, and only then move it into place, keeping the old string with a warning otherwise. Same shape as mitoMap/checkMitoMapUpdate.sh, which already does this. Checked all three paths: the real upstream URL updates the file and leaves no temp behind, an unreachable URL and a URL returning an empty body both keep the previous string and warn. For contrast, the old one-liner against an unreachable URL truncated version.txt to zero bytes. Found while sweeping the otto updaters for the version-stamping problem behind the uniprot outage. refs #38300 diff --git src/hg/utils/otto/varChat/varChatOtto.sh src/hg/utils/otto/varChat/varChatOtto.sh index b8b3092825b..6d9e1b0db72 100755 --- src/hg/utils/otto/varChat/varChatOtto.sh +++ src/hg/utils/otto/varChat/varChatOtto.sh @@ -1,54 +1,65 @@ #!/bin/bash set -e -o pipefail cd /hive/data/outside/otto/varChat wget -q https://ucsc-engenome-varchat.s3.eu-west-1.amazonaws.com/latest/VarChat_GRCh38_latest.bb -O varChat.hg38.latest.bb wget -q https://ucsc-engenome-varchat.s3.eu-west-1.amazonaws.com/latest/VarChat_GRCh37_latest.bb -O varChat.hg19.latest.bb # Check if the files are the same if cmp -s varChat.hg38.latest.bb varChat.hg38.bb; then # Files are the same, exit silently rm varChat.hg38.latest.bb rm varChat.hg19.latest.bb exit 0 else # Files are different, continue with the script or add actions echo "Updating VarChat track..." fi oldCountHg38=$(bigBedInfo varChat.hg38.bb | grep -i "itemCount" | awk '{print $NF}') oldCountHg19=$(bigBedInfo varChat.hg19.bb | grep -i "itemCount" | awk '{print $NF}') newCountHg38=$(bigBedInfo varChat.hg38.latest.bb | grep -i "itemCount" | awk '{print $NF}') newCountHg19=$(bigBedInfo varChat.hg19.latest.bb | grep -i "itemCount" | awk '{print $NF}') # Calculate the percentage difference diffHg38=$(echo "scale=2; (($newCountHg38 - $oldCountHg38) / $oldCountHg38) * 100" | bc) diffHg19=$(echo "scale=2; (($newCountHg19 - $oldCountHg19) / $oldCountHg19) * 100" | bc) # Get the absolute values of the differences absDiffHg38=$(echo "$diffHg38" | sed 's/-//') absDiffHg19=$(echo "$diffHg19" | sed 's/-//') # Check if the absolute difference is greater than 20% if (( $(echo "$absDiffHg38 > 20" | bc -l) || $(echo "$absDiffHg19 > 20" | bc -l) )); then echo echo "Error: Difference in item count exceeds 20%." echo "Difference in hg38: $diffHg38%" echo "Difference in hg19: $diffHg19%" exit 1 fi # If the difference is within the 20%, proceed mv varChat.hg38.latest.bb varChat.hg38.bb mv varChat.hg19.latest.bb varChat.hg19.bb -wget -q https://ucsc-engenome-varchat.s3.eu-west-1.amazonaws.com/latest/version.txt -O version.txt +# /gbdb/hg38/bbi/varChatVersion.txt symlinks straight to this file, so the browser reads +# it directly, and wget truncates its -O target before it has anything to put there. Fetch +# to a temp file and only replace the live one if something actually arrived: the bigBeds +# above are already live by this point, so a failed fetch would otherwise leave the track +# showing a blank version until the next upstream release, which can be many months away. +# refs #38300 +if wget -q https://ucsc-engenome-varchat.s3.eu-west-1.amazonaws.com/latest/version.txt -O version.new.txt && [ -s version.new.txt ]; then + mv version.new.txt version.txt +else + rm -f version.new.txt + echo "Warning: could not fetch the VarChat version file, keeping $(cat version.txt 2>/dev/null)" +fi echo echo "Item counts for hg38 old vs. new bigBed. Old: $oldCountHg38 New: $newCountHg38" echo "Item counts for hg19 old vs. new bigBed. Old: $oldCountHg19 New: $newCountHg19" echo echo "VarChat track built successfully."