dbf1f3970c63ee81e66dca929395aa575a536a26
hiram
  Thu Apr 30 11:52:20 2026 -0700
eliminate duplicate code section and protect all net tracks with file exist test refs #31811

diff --git src/hg/utils/automation/asmHubChainNetTrackDb.sh src/hg/utils/automation/asmHubChainNetTrackDb.sh
index db3913da0c3..0b32546f4f9 100755
--- src/hg/utils/automation/asmHubChainNetTrackDb.sh
+++ src/hg/utils/automation/asmHubChainNetTrackDb.sh
@@ -105,65 +105,49 @@
       ln -s ../trackData/$lastzDir/bigMaf/$accessionId.$otherDb.liftOverNet.bb $buildDir/bbi/${asmId}.$otherDb.liftOverNet.bb
       ln -s ../trackData/$lastzDir/bigMaf/$accessionId.$otherDb.liftOverNet.summary.bb $buildDir/bbi/${asmId}.$otherDb.liftOverNet.summary.bb
     fi
   else
     printf "# there is NO chainLiftOver${OtherDb}.bb\n" 1>&2
   fi
 
   if [ -s "$buildDir/trackData/$lastzDir/axtChain/${accessionId}.${otherDb}.quick.bb" ]; then
     printf "# making quickLift/${otherDb}.bb\n" 1>&2
     ln -s ../trackData/$lastzDir/axtChain/${accessionId}.${otherDb}.quick.bb $buildDir/quickLift/${otherDb}.bb
     ln -s ../trackData/$lastzDir/axtChain/${accessionId}.${otherDb}.quickLink.bb $buildDir/quickLift/${otherDb}.link.bb
   else
     printf "# there is NO chainQuickLift${OtherDb}.bb\n" 1>&2
   fi
 
-  otherPrefix=`echo $otherDb | cut -c1-2`
-  if [ "${otherPrefix}" = "GC" ]; then
-    sciName=`grep -i 'organism name:' ${asmReport} | head -1 | tr -d "\r" | sed -e 's/.*organism name: *//i; s/ *(.*//;'`
-    organism=`grep -i 'organism name:' ${asmReport} | head -1 | tr -d "\r" | sed -e 's/.*organism name: *.*(//i; s/).*//;'`
-    taxId=`grep -i 'taxid:' ${asmReport} | head -1 | tr -d "\r" | sed -e 's/.*taxid: *//i;'`
-    o_date=`grep -i 'date:' ${asmReport} | head -1 | tr -d "\r" | sed -e 's/.*date: *//i;'`
-    matrix=""
-    linGap=""
-    minScore=""
-  else
-    organism=`hgsql -N -e "select organism from dbDb where name=\"$otherDb\"" hgcentraltest`
-    sciName=`hgsql -N -e "select scientificName from dbDb where name=\"$otherDb\"" hgcentraltest`
-    taxId=`hgsql -N -e "select taxId from dbDb where name=\"$otherDb\"" hgcentraltest`
-    o_date=`hgsql -N -e "select description from dbDb where name=\"$otherDb\"" hgcentraltest`
-    matrix=`~/kent/src/hg/utils/phyloTrees/findScores.pl $otherDb $targetDb 2>&1 | grep matrix`
-  fi
-
   otherPrefix=`echo $otherDb | cut -c1-2`
   if [ "${otherPrefix}" = "GC" ]; then
     sciName=`grep -i 'organism name:' ${asmReport} | head -1 | tr -d "\r" | sed -e 's/.*organism name: *//i; s/ *(.*//;'`
     organism=`grep -i 'organism name:' ${asmReport} | head -1 | tr -d "\r" | sed -e 's/.*organism name: *.*(//i; s/).*//;'`
     taxId=`grep -i 'taxid:' ${asmReport} | head -1 | tr -d "\r" | sed -e 's/.*taxid: *//i;'`
     o_date=`grep -i 'date:' ${asmReport} | head -1 | tr -d "\r" | sed -e 's/.*date: *//i;'`
     matrix=""
     linGap=""
     minScore=""
   else
     organism=`hgsql -N -e "select organism from dbDb where name=\"$otherDb\"" hgcentraltest`
     sciName=`hgsql -N -e "select scientificName from dbDb where name=\"$otherDb\"" hgcentraltest`
     taxId=`hgsql -N -e "select taxId from dbDb where name=\"$otherDb\"" hgcentraltest`
     o_date=`hgsql -N -e "select description from dbDb where name=\"$otherDb\"" hgcentraltest`
     matrix=`~/kent/src/hg/utils/phyloTrees/findScores.pl $otherDb $targetDb 2>&1 | grep matrix`
     minScore=`~/kent/src/hg/utils/phyloTrees/findScores.pl $otherDb $targetDb 2>&1 | grep MinScore`
    linGap=`~/kent/src/hg/utils/phyloTrees/findScores.pl $otherDb $targetDb 2>&1 | grep LinearGap`
   fi
+
   printf "##############################################################################
 # $otherDb - $organism - $sciName - taxId: $taxId
 ##############################################################################
 "
   printf "track chainNet$OtherDb
 compositeTrack on
 shortLabel $organism Chain/Net
 longLabel $organism ($o_date), Chain and Net Alignments
 subGroup1 view Views chain=Chain net=Net
 dragAndDrop subTracks
 visibility hide
 group compGeno
 "
 
   printf "priority 100.1
@@ -242,49 +226,60 @@
 
 printf "        track chainLiftOver$OtherDb
         parent chainNet${OtherDb}Viewchain
         subGroups view=chain
         shortLabel $organism loChain
         longLabel $organism ($o_date) Lift Over Chained Alignments
         type bigChain $otherDb
         bigDataUrl bbi/$asmId.chainLiftOver$OtherDb.bb
         linkDataUrl bbi/$asmId.chainLiftOver${OtherDb}Link.bb
         priority %d
 
 " $((chainNetPriority++))
 
 fi
 
+if [ -s "$buildDir/bbi/${asmId}.$otherDb.net.bb" ] \
+  || [ -s "$buildDir/bbi/${asmId}.$otherDb.synNet.summary.bb" ] \
+  || [ -s "$buildDir/bbi/${asmId}.$otherDb.rbestNet.summary.bb" ] \
+  || [ -s "$buildDir/bbi/${asmId}.$otherDb.liftOverNet.summary.bb" ]; then
+
 printf "    track mafNet${OtherDb}Viewnet
     shortLabel Net
     view net
     visibility full
     parent chainNet$OtherDb
 
-        track net$OtherDb
+"
+
+if [ -s "$buildDir/bbi/${asmId}.$otherDb.net.bb" ]; then
+
+printf "        track net$OtherDb
         parent mafNet${OtherDb}Viewnet
         subGroups view=net
         shortLabel $organism net
         longLabel $organism ($o_date) Net Alignment
         type bigMaf
         bigDataUrl bbi/$asmId.$otherDb.net.bb
         summary bbi/$asmId.$otherDb.net.summary.bb
         speciesOrder $otherDb
         priority %d
 
 " $((chainNetPriority++))
 
+fi
+
 if [ -s "$buildDir/bbi/${asmId}.$otherDb.synNet.summary.bb" ]; then
 
 printf "        track synNet$OtherDb
         parent mafNet${OtherDb}Viewnet
         subGroups view=net
         shortLabel $organism synNet
         longLabel $organism ($o_date) Syntenic Net Alignment
         type bigMaf
         bigDataUrl bbi/$asmId.$otherDb.synNet.bb
         summary bbi/$asmId.$otherDb.synNet.summary.bb
         speciesOrder $otherDb
         priority %d
 
 " $((chainNetPriority++))
 
@@ -312,16 +307,18 @@
 printf "        track liftOverNet$OtherDb
         parent mafNet${OtherDb}Viewnet
         subGroups view=net
         shortLabel $organism liftOverNet
         longLabel $organism ($o_date) Lift Over Net Alignment
         type bigMaf
         bigDataUrl bbi/$asmId.$otherDb.liftOverNet.bb
         summary bbi/$asmId.$otherDb.liftOverNet.summary.bb
         speciesOrder $otherDb
         priority %d
 
 " $((chainNetPriority++))
 
 fi
 
+fi	# any of the net files exists
+
 done