75892bebe2505e10302cb56e9e1050bd811351d9
hiram
  Tue Sep 27 09:03:45 2022 -0700
accomodate promoted hubs with db but no chromInfo refs #29819

diff --git src/hg/utils/automation/doBlastzChainNet.pl src/hg/utils/automation/doBlastzChainNet.pl
index c8b8e1b..cf14f20 100755
--- src/hg/utils/automation/doBlastzChainNet.pl
+++ src/hg/utils/automation/doBlastzChainNet.pl
@@ -262,31 +262,31 @@
 15. SEQ2_SELF=1 specifies the SEQ2 is already specially split for self
     alignments and to use SEQ2 sequence for self alignment, not just a
     copy of SEQ1
 16. TMPDIR - specifies directory on cluster node to keep temporary files
     Typically TMPDIR=/scratch/tmp
 17. All other variables in DEF will be ignored!
 
 " if ($detailed);
   exit $status;
 }
 
 
 # Globals:
 my %defVars = ();
 my ($DEF, $tDb, $qDb, $QDb, $isSelf, $selfSplit, $buildDir, $fileServer);
-my ($swapDir, $tAsmId, $qAsmId, $splitRef, $inclHap, $secondsStart, $secondsEnd, $dbExists, $qDbExists);
+my ($swapDir, $tAsmId, $qAsmId, $splitRef, $inclHap, $secondsStart, $secondsEnd, $dbExists, $qDbExists, $tChromInfoExists, $qChromInfoExists);
 
 sub isInDirList {
   # Return TRUE if $dir is under (begins with) something in dirList.
   my ($dir, @dirList) = @_;
   my $pat = '^(' . join('|', @dirList) . ')(/.*)?$';
   return ($dir =~ m@$pat@);
 }
 
 sub enforceClusterNoNo {
   # Die right away if user is trying to put cluster output somewhere
   # off-limits.
   my ($dir, $desc) = @_;
   if (&isInDirList($dir, @clusterNoNo)) {
     die "\ncluster outputs are forbidden to go to " .
       join (' or ', @clusterNoNo) . " so please choose a different " .
@@ -1148,31 +1148,31 @@
 printf "%d bases of %d (%s%%) in intersection\\n" "\$basesCovered" "\$totalBases" "\$percentCovered" > ../fb.$tDb.chain${QDb}Link.txt
 rm -f link.tab
 rm -f chain.tab
 _EOF_
       );
     }
   }
   if (! $isSelf) {
   my $tRepeats = $opt_tRepeats ? "-tRepeats=$opt_tRepeats" : $defaultTRepeats;
   my $qRepeats = $opt_qRepeats ? "-qRepeats=$opt_qRepeats" : $defaultQRepeats;
   if ($opt_swap) {
     $tRepeats = $opt_qRepeats ? "-tRepeats=$opt_qRepeats" : $defaultQRepeats;
     $qRepeats = $opt_tRepeats ? "-qRepeats=$opt_tRepeats" : $defaultTRepeats;
   }
     if (! $opt_trackHub && $dbExists) {
-      if ($qDbExists) {
+      if ($qDbExists && $qChromInfoExists) {
       $bossScript->add(<<_EOF_
 
 # Add gap/repeat stats to the net file using database tables:
 cd $runDir
 netClass -verbose=0 $tRepeats $qRepeats -noAr noClass.net $tDb $qDb $tDb.$qDb.net
 
 # Load nets:
 netFilter -minGap=10 $tDb.$qDb.net \\
   | hgLoadNet -verbose=0 $tDb net$QDb stdin
 _EOF_
       );
       } else {
       $bossScript->add(<<_EOF_
 cp -p noClass.net $tDb.$qDb.net
 netFilter -minGap=10 noClass.net \\
@@ -1774,31 +1774,31 @@
     $bossScript->add(<<_EOF_
 netFilter -syn $tDb.$qDb.net.gz | gzip -c > $tDb.$qDb.syn.net.gz
 netChainSubset -verbose=0 $tDb.$qDb.syn.net.gz $tDb.$qDb.all.chain.gz stdout \\
   | chainStitchId stdin stdout | gzip -c > $tDb.$qDb.syn.chain.gz
 _EOF_
       );
 
     if (! $opt_trackHub && $dbExists) {
       $bossScript->add(<<_EOF_
 set lineCount = `zcat $tDb.$qDb.syn.chain.gz | wc -l`
 if (\$lineCount > 0) then
   hgLoadChain -tIndex $tDb chainSyn$QDb $tDb.$qDb.syn.chain.gz
 endif
 _EOF_
       );
-      if ($qDbExists) {
+      if ($qDbExists && $qChromInfoExists) {
         $bossScript->add(<<_EOF_
   netFilter -minGap=10 $tDb.$qDb.syn.net.gz \\
     | hgLoadNet -verbose=0 $tDb netSyn$QDb stdin
 endif
 _EOF_
         );
       }
     } else {
       $bossScript->add(<<_EOF_
 set lineCount = `zcat $tDb.$qDb.syn.chain.gz | wc -l`
 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
@@ -1957,33 +1957,47 @@
 	    'blastz/chain/net build directory (or use -blastzOutRoot)');
   }
   $splitRef = $seq1IsSplit;
   &HgAutomate::verbose(1, "Building in $buildDir\n");
 }
 
 if (! -e "$buildDir/DEF") {
   &HgAutomate::run("cp $DEF $buildDir/DEF");
 }
 
 $fileServer = &HgAutomate::chooseFileServer($opt_swap ? $swapDir : $buildDir);
 
 # may be working on a 2bit file that does not have a database browser
 $dbExists = 0;
 $dbExists = 1 if (&HgAutomate::databaseExists($dbHost, $tDb));
+# db might exist, but it may not have chromInfo table (promoted hub)
+$tChromInfoExists = 0;
+if ($dbExists) {
+  $tChromInfoExists = 1 if (&HgAutomate::dbTableExists($dbHost, $tDb, "chromInfo"));
+}
 # may be working with a query that does not have a database
 $qDbExists = 0;
 $qDbExists = 1 if (&HgAutomate::databaseExists($dbHost, $qDb));
+$qChromInfoExists = 0;
+if ($qDbExists) {
+  $qChromInfoExists = 1 if (&HgAutomate::dbTableExists($dbHost, $qDb, "chromInfo"));
+}
+
+printf STDERR "# target db exists: %s\n", $dbExists ? "TRUE" : "FALSE";
+printf STDERR "# target chromInfo exists: %s\n", $tChromInfoExists ? "TRUE" : "FALSE";
+printf STDERR "# query db exists: %s\n", $qDbExists ? "TRUE" : "FALSE";
+printf STDERR "# query chromInfo exists: %s\n", $qChromInfoExists ? "TRUE" : "FALSE";
 
 # When running -swap, swapGlobals() happens at the end of the chainMerge step.
 # However, if we also use -continue with some step later than chainMerge, we
 # need to call swapGlobals before executing the remaining steps.
 if ($opt_swap &&
     $stepper->stepPrecedes('chainMerge', $stepper->getStartStep())) {
   &swapGlobals();
 }
 
 $stepper->execute();
 
 $secondsEnd = `date "+%s"`;
 chomp $secondsEnd;
 my $elapsedSeconds = $secondsEnd - $secondsStart;
 my $elapsedMinutes = int($elapsedSeconds/60);