2e901bb19e96fbe3fe8bb9706cf528a20ed2477d
hiram
  Thu Jan 30 17:20:19 2020 -0800
protect against empty nestedRepeats result refs #23891

diff --git src/hg/utils/automation/doRepeatMasker.pl src/hg/utils/automation/doRepeatMasker.pl
index 5d17072..286e999 100755
--- src/hg/utils/automation/doRepeatMasker.pl
+++ src/hg/utils/automation/doRepeatMasker.pl
@@ -534,39 +534,43 @@
 export splitTabCount=`cat rmskClass/*.tab | wc -l`
 
 if [ "\$firstTabCount" -ne \$bbiCount ]; then
    echo "\$db.rmsk$updateTable.tab count: \$firstTabCount, split class tab file count: \$splitTabCount, bbi class item count:  \$bbiCount"
    echo "ERROR: did not account for all items in rmsk class bbi construction" 1>&2
    exit 255
 fi
 wc -l classBed/*.bed > \$db.class.profile.txt
 wc -l rmskClass/*.tab >> \$db.class.profile.txt
 rm -fr rmskClass classBed \$db.rmsk$updateTable.tab
 _EOF_
   );
 
   if ($opt_updateTable) {
   $bossScript->add(<<_EOF_
+if [ -s \$db.nestedRepeats.bed ]; then
   sed -e 's/nestedRepeats/nestedRepeatsUpdate/g' \$HOME/kent/src/hg/lib/nestedRepeats.sql > nestedRepeatsUpdate.sql
   hgLoadBed \$db nestedRepeats$updateTable \$db.nestedRepeats.bed \\
     -sqlTable=nestedRepeatsUpdate.sql
+fi
 _EOF_
   );
   } else {
   $bossScript->add(<<_EOF_
+if [ -s \$db.nestedRepeats.bed ]; then
   hgLoadBed \$db nestedRepeats \$db.nestedRepeats.bed \\
     -sqlTable=\$HOME/kent/src/hg/lib/nestedRepeats.sql
+fi
 _EOF_
   );
   }
 
   $bossScript->add(<<_EOF_
 rm -f $installDir/\$db.rmsk$updateTable.2bit
 ln -s $buildDir/\$db.rmsk$updateTable.2bit $installDir/\$db.rmsk$updateTable.2bit
 _EOF_
   );
   $bossScript->execute();
 
   # Make a new script for the fileServer if chrom-based:
   if ($chromBased) {
     my $fileServer = &HgAutomate::chooseFileServer($runDir);
     $whatItDoes =