25ea393c310876076793bbad0e093f83161e9d78
hiram
  Tue Aug 18 14:39:58 2026 -0700
improve efficiency of the trackData.pl an now using faSize to get sizes out of the 2bit files no redmine

diff --git src/hg/makeDb/doc/asmHubs/asmHubs.mk src/hg/makeDb/doc/asmHubs/asmHubs.mk
index 604f9959e5e..f2ada0e4d31 100644
--- src/hg/makeDb/doc/asmHubs/asmHubs.mk
+++ src/hg/makeDb/doc/asmHubs/asmHubs.mk
@@ -94,38 +94,47 @@
 [ -L ${hubsDownload}/$${json}.json ] && true || ln -s ${asmHubSrc}/$${json}.json ${hubsDownload} ; \
 done
 
 hubIndex::
 	rm -f ${destDir}/${testIndexName}.html ${destDir}/${indexName}.html ${destDir}/download.${indexName}.html
 	${toolsDir}/mkHubIndex.pl ${Name} ${name} ${defaultAssembly} ${orderList} | sed -e 's#${name}/hub.txt#${name}/${hubFile}.txt#;' > ${destDir}/download.${indexName}.html
 	sed -e "s#genome.ucsc.edu/h/#genome-test.gi.ucsc.edu/h/#g; s/hgdownload.soe/hgdownload-test.gi/g; s#genome.ucsc.edu#genome-test.gi.ucsc.edu#;" ${destDir}/download.${indexName}.html > ${destDir}/${indexName}.html
 	chmod +x ${destDir}/${indexName}.html ${destDir}/download.${indexName}.html
 
 asmStats::
 	rm -f ${destDir}/download.${statsName}.html ${destDir}/${statsName}.html ${destDir}/${testStatsName}.html
 	${toolsDir}/mkAsmStats.pl ${Name} ${name} ${orderList} > ${destDir}/download.${statsName}.html
 	sed -e "s#genome.ucsc.edu/h/#genome-test.gi.ucsc.edu/h/#g; s/hgdownload.soe/hgdownload-test.gi/g;" ${destDir}/download.${statsName}.html > ${destDir}/${statsName}.html
 	chmod +x ${destDir}/${statsName}.html ${destDir}/download.${statsName}.html
 
-# trackData makes different tables for the test vs. production version
+# trackData makes different tables for the test vs. production version.
+# both are built in a single trackData.pl pass now, so each assembly's
+# tracks are only measured once instead of twice.
+# the two pages are written to .new temporary files first, and only
+# 'mv'ed into their real names once trackData.pl has completely finished.
+# symlinks elsewhere point directly at ${dataName}.html/download.${dataName}.html,
+# and 'mv' within the same directory is an atomic rename, so those
+# symlinks never resolve to a truncated or half-written file while the
+# (potentially long) trackData.pl run is still in progress.
 # mkHubIndex.pl and mkAsmStats.pl should do this too . . .  TBD
 trackData::
-	rm -f ${destDir}/${testDataName}.html ${destDir}/${dataName}.html ${destDir}/download.${dataName}.html
-	${toolsDir}/trackData.pl ${Name} ${name} ${orderList} > ${destDir}/download.${dataName}.html
-	${toolsDir}/trackData.pl -test ${Name} ${name} ${orderList} > ${destDir}/${dataName}.html
-	chmod +x ${destDir}/${dataName}.html
-	chmod +x ${destDir}/download.${dataName}.html
+	rm -f ${destDir}/${testDataName}.html.new ${destDir}/${dataName}.html.new ${destDir}/download.${dataName}.html.new
+	${toolsDir}/trackData.pl ${Name} ${name} ${orderList} ${destDir}/download.${dataName}.html.new ${destDir}/${dataName}.html.new
+	chmod +x ${destDir}/${dataName}.html.new
+	chmod +x ${destDir}/download.${dataName}.html.new
+	mv -f ${destDir}/download.${dataName}.html.new ${destDir}/download.${dataName}.html
+	mv -f ${destDir}/${dataName}.html.new ${destDir}/${dataName}.html
 
 indexPages: mkJson hubIndex asmStats trackData
 	echo indexPages done
 
 ### obsolete, these hub.txt files are now static 2024-10-23
 hubTxt:
 	rm -f ${destDir}/${testHubFile}.txt ${destDir}/${hubFile}.txt
 	sed -e "s#index.html#${indexName}.html#; s#genomes.txt#${genomesTxt}.txt#;" ${srcDir}/${hubTxtFile} > ${destDir}/${hubFile}.txt
 
 # all hubs have the same set of groups, no need for any name customization
 #  copy only if different, the PHONY prevents problems if some file 'groupsTxt'
 #     happens to exist, it should not be examined
 .PHONY: groupsTxt
 groupsTxt:
 	@cmp -s ${toolsDir}/groups.txt ${destDir}/groups.txt || cp --remove-destination -p ${toolsDir}/groups.txt ${destDir}/groups.txt