24d667a6353af7e3d009ff35beb21f85dc40984d
hiram
  Tue Dec 20 10:40:08 2022 -0800
correctly make symLinks for chainNet files at the time they actually exist no redmine

diff --git src/hg/utils/automation/doBlastzChainNet.pl src/hg/utils/automation/doBlastzChainNet.pl
index d46225e..9c89d2a 100755
--- src/hg/utils/automation/doBlastzChainNet.pl
+++ src/hg/utils/automation/doBlastzChainNet.pl
@@ -1195,45 +1195,42 @@
 featureBits $tDb $QDbLink >&fb.$tDb.$QDbLink.txt
 cat fb.$tDb.$QDbLink.txt
 _EOF_
       );
     } else {	# not a database assembly
       $bossScript->add(<<_EOF_
 cp -p noClass.net $tDb.$qDb.net
 netFilter -minGap=10 noClass.net \\
   | hgLoadNet -test -noBin -warn -verbose=0 $tDb net$QDb stdin
 mv align.tab net$QDb.tab
 _EOF_
       );
       # target may be database assembly, special set of gbdb symLinks
       if ($dbExists && $tChromInfoExists) {
       $bossScript->add(<<_EOF_
+if ( -s "\$buildDir/axtChain/chain${QDb}.bb" ) then
   mkdir -p /gbdb/$tDb/chainNet
-foreach T (chain chainRBest chainSyn)
-  if ( -s "\$buildDir/axtChain/\${T}${QDb}.bb" ) then
-    rm -f "/gbdb/$tDb/chainNet/$tDb.\${T}$QDb.bb" "/gbdb/$tDb/chainNet/$tDb.\${T}.${QDb}Link.bb"
-    ln -s "\$buildDir/axtChain/\${T}${QDb}.bb" "/gbdb/$tDb/chainNet/$tDb.\${T}$QDb.bb"
-    ln -s "\$buildDir/axtChain/\${T}${QDb}Link.bb" "/gbdb/$tDb/chainNet/$tDb.\${T}.${QDb}Link.bb"
+  rm -f "/gbdb/$tDb/chainNet/$tDb.chain$QDb.bb" "/gbdb/$tDb/chainNet/$tDb.chain${QDb}Link.bb"
+  ln -s "\$buildDir/axtChain/chain${QDb}.bb" "/gbdb/$tDb/chainNet/$tDb.chain$QDb.bb"
+  ln -s "\$buildDir/axtChain/chain${QDb}Link.bb" "/gbdb/$tDb/chainNet/$tDb.chain${QDb}Link.bb"
 endif
-end
-foreach T (net rbestNet synNet)
-  if ( -s "\$buildDir/bigMaf/$tDb.$qDb.\${T}.bb" ) then
-    rm -f "/gbdb/$tDb/chainNet/$tDb.$qDb.\${T}.bb" "/gbdb/$tDb/chainNet/$tDb.$qDb.\${T}.summary.bb"
-    ln -s "\$buildDir/bigMaf/$tDb.$qDb.\${T}.bb" "/gbdb/$tDb/chainNet/$tDb.$qDb.\${T}.bb"
-    ln -s "\$buildDir/bigMaf/$tDb.$qDb.\${T}.summary.bb" "/gbdb/$tDb/chainNet/$tDb.$qDb.\${T}.summary.bb"
+if ( -s "\$buildDir/bigMaf/$tDb.$qDb.net.bb" ) then
+  mkdir -p /gbdb/$tDb/chainNet
+  rm -f "/gbdb/$tDb/chainNet/$tDb.$qDb.net.bb" "/gbdb/$tDb/chainNet/$tDb.$qDb.net.summary.bb"
+  ln -s "\$buildDir/bigMaf/$tDb.$qDb.net.bb" "/gbdb/$tDb/chainNet/$tDb.$qDb.net.bb"
+  ln -s "\$buildDir/bigMaf/$tDb.$qDb.net.summary.bb" "/gbdb/$tDb/chainNet/$tDb.$qDb.net.summary.bb"
 endif
-end
 _EOF_
       );
       }
     }
   }	#	if (! $isSelf)
   $bossScript->execute();
 # maybe also peek in trackDb and see if entries need to be added for chain/net
 }	#	sub loadUp {}
 
 
 sub makeDownloads {
   # Compress the netClassed .net for download (other files should have been
   # compressed already).
   my $runDir = "$buildDir/axtChain";
   if (-s "$runDir/$tDb.$qDb.net") {
@@ -1828,30 +1825,42 @@
 if (\$lineCount > 0) then
   hgLoadChain -test -noBin -tIndex $tDb chainSyn$QDb $tDb.$qDb.syn.chain.gz
   wget --no-check-certificate -O bigChain.as 'http://genome-source.soe.ucsc.edu/gitlist/kent.git/raw/master/src/hg/lib/bigChain.as'
   wget --no-check-certificate -O bigLink.as 'http://genome-source.soe.ucsc.edu/gitlist/kent.git/raw/master/src/hg/lib/bigLink.as'
   sed 's/.000000//' chain.tab | awk 'BEGIN {OFS="\\t"} {print \$2, \$4, \$5, \$11, 1000, \$8, \$3, \$6, \$7, \$9, \$10, \$1}' > chainSyn${QDb}.tab
   bedToBigBed -type=bed6+6 -as=bigChain.as -tab chainSyn${QDb}.tab $defVars{SEQ1_LEN} chainSyn${QDb}.bb
   awk 'BEGIN {OFS="\\t"} {print \$1, \$2, \$3, \$5, \$4}' link.tab | sort -k1,1 -k2,2n > chainSyn${QDb}Link.tab
   bedToBigBed -type=bed4+1 -as=bigLink.as -tab chainSyn${QDb}Link.tab $defVars{SEQ1_LEN} chainSyn${QDb}Link.bb
   set totalBases = `ave -col=2 $defVars{SEQ1_LEN} | grep "^total" | awk '{printf "%d", \$2}'`
   set basesCovered = `bedSingleCover.pl chainSyn${QDb}Link.tab | ave -col=4 stdin | grep "^total" | awk '{printf "%d", \$2}'`
   set percentCovered = `echo \$basesCovered \$totalBases | awk '{printf "%.3f", 100.0*\$1/\$2}'`
   printf "%d bases of %d (%s%%) in intersection\\n" "\$basesCovered" "\$totalBases" "\$percentCovered" > ../fb.$tDb.chainSyn${QDb}Link.txt
 netFilter -minGap=10 $tDb.$qDb.syn.net.gz \\
   | hgLoadNet -test -noBin -warn -verbose=0 $tDb netSyn$QDb stdin
 mv align.tab netSyn$QDb.tab
+if ( -s "\$buildDir/axtChain/chainSyn${QDb}.bb" ) then
+  mkdir -p /gbdb/$tDb/chainNet
+  rm -f "/gbdb/$tDb/chainNet/$tDb.chainSyn$QDb.bb" "/gbdb/$tDb/chainNet/$tDb.chainSyn${QDb}Link.bb"
+  ln -s "\$buildDir/axtChain/chainSyn${QDb}.bb" "/gbdb/$tDb/chainNet/$tDb.chainSyn$QDb.bb"
+  ln -s "\$buildDir/axtChain/chainSyn${QDb}Link.bb" "/gbdb/$tDb/chainNet/$tDb.chainSyn${QDb}Link.bb"
+endif
+if ( -s "\$buildDir/bigMaf/$tDb.$qDb.synNet.bb" ) then
+  mkdir -p /gbdb/$tDb/chainNet
+  rm -f "/gbdb/$tDb/chainNet/$tDb.$qDb.synNet.bb" "/gbdb/$tDb/chainNet/$tDb.$qDb.synNet.summary.bb"
+  ln -s "\$buildDir/bigMaf/$tDb.$qDb.synNet.bb" "/gbdb/$tDb/chainNet/$tDb.$qDb.synNet.bb"
+  ln -s "\$buildDir/bigMaf/$tDb.$qDb.synNet.summary.bb" "/gbdb/$tDb/chainNet/$tDb.$qDb.synNet.summary.bb"
+endif
 endif
 rm -f link.tab
 rm -f chain.tab
 _EOF_
       );
     }
 
     $bossScript->add(<<_EOF_
 if (\$lineCount > 0) then
   netToAxt $tDb.$qDb.syn.net.gz $tDb.$qDb.all.chain.gz \\
     $defVars{'SEQ1_DIR'} $defVars{'SEQ2_DIR'} stdout \\
     | axtSort stdin stdout \\
     | axtToMaf -tPrefix=$tDb. -qPrefix=$qDb. stdin \\
       $defVars{SEQ1_LEN} $defVars{SEQ2_LEN} \\
       stdout \\