src/hg/utils/automation/doBlastzChainNet.pl 1.29

1.29 2009/06/08 18:42:40 hiram
Find db name from /scratch/data/ directory name, and generalize the ssh command to avoid questions to the shell for new hosts, and properly verify all DEF variables before they start
Index: src/hg/utils/automation/doBlastzChainNet.pl
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/utils/automation/doBlastzChainNet.pl,v
retrieving revision 1.28
retrieving revision 1.29
diff -b -B -U 4 -r1.28 -r1.29
--- src/hg/utils/automation/doBlastzChainNet.pl	19 Mar 2009 16:15:29 -0000	1.28
+++ src/hg/utils/automation/doBlastzChainNet.pl	8 Jun 2009 18:42:40 -0000	1.29
@@ -388,8 +388,17 @@
   my ($var) = @_;
   my $val = $defVars{$var};
   die "Error: $DEF $var=$val must specify a complete path\n"
     if ($val !~ m@^/\S+/\S+@);
+  if ( -d $val ) {
+    my $fileCount = `find $val -maxdepth 1 -type f | wc -l`;
+    chomp $fileCount;
+    if ($fileCount < 1) {
+	die "Error: $DEF variable: $var=$val specifies an empty directory.\n";
+    }
+  } elsif ( ! -s $val ) {
+    die "Error: $DEF variable: $var=$val is not a file or directory.\n";
+  }
 }
 
 sub requireNum {
   my ($var) = @_;
@@ -418,8 +427,13 @@
 	$val =~ s#^/hive/data/genomes/##;
 	$val =~ s#/.*##;
 	$db = $val;
 	warn "Warning: assuming database $db from /hive/data/genomes/<db>/ path\n";
+    } elsif ($val =~ m#^/scratch/data/#) {
+	$val =~ s#^/scratch/data/##;
+	$val =~ s#/.*##;
+	$db = $val;
+	warn "Warning: assuming database $db from /scratch/data/<db>/ path\n";
     }
   }
 return $db;
 }
@@ -509,9 +523,9 @@
     );
   $bossScript->execute();
   my $mkOutRootHost = $opt_blastzOutRoot ? $paraHub : $fileServer;
   my $mkOutRoot =     $opt_blastzOutRoot ? "mkdir -p $opt_blastzOutRoot;" : "";
-  &HgAutomate::run("ssh -x $mkOutRootHost " .
+  &HgAutomate::run("$HgAutomate::runSSH $mkOutRootHost " .
 		   "'(cd $runDir; $mkOutRoot csh -ef xdir.sh)'");
 }
 
 sub doBlastzClusterRun {
@@ -604,9 +618,9 @@
 each subdirectory of $outRoot into a per-target-chunk file.";
   my $bossScript = new HgRemoteScript("$runDir/doCatRun.csh", $paraHub,
 				      $runDir, $whatItDoes, $DEF);
   $bossScript->add(<<_EOF_
-(cd $outRoot; find . -type d -maxdepth 1 | grep '^./') \\
+(cd $outRoot; find . -maxdepth 1 -type d | grep '^./') \\
         | sed -e 's#/\$##; s#^./##' > tParts.lst
 chmod a+x cat.csh
 $HgAutomate::gensub2 tParts.lst single gsub jobList
 mkdir ../pslParts
@@ -765,15 +779,15 @@
   if (! -e $successFile && ! $opt_debug) {
     die "postProcessChains: looks like previous stage was not successful " .
       "(can't find $successFile).\n";
   }
-  my $cmd="ssh -x $workhorse nice ";
+  my $cmd="$HgAutomate::runSSH $workhorse nice ";
   $cmd .= "'find $runDir/run/chain -name \"*.chain\" ";
   $cmd .= "| chainMergeSort -inputList=stdin ";
   $cmd .= "| nice gzip -c > $runDir/$chain'";
   &HgAutomate::run($cmd);
   if ($splitRef) {
-    &HgAutomate::run("ssh -x $fileServer nice " .
+    &HgAutomate::run("$HgAutomate::runSSH $fileServer nice " .
 	 "chainSplit $runDir/chain $runDir/$chain");
   }
   &HgAutomate::nfsNoodge("$runDir/$chain");
 }	#	sub postProcessChains {}
@@ -813,15 +827,15 @@
      "($runDir/all.chain[.gz] exists).  Either run with -continue net or some " .
      "later stage, or move aside/remove $runDir/all.chain[.gz] and run again.\n";
   }
   # Main routine already made sure that $buildDir/axtChain/all.chain is there.
-  &HgAutomate::run("ssh -x $workhorse nice " .
+  &HgAutomate::run("$HgAutomate::runSSH $workhorse nice " .
        "'chainSwap $buildDir/axtChain/$inChain stdout " .
        "| nice chainSort stdin stdout " .
        "| nice gzip -c > $runDir/$swappedChain'");
   &HgAutomate::nfsNoodge("$runDir/$swappedChain");
   if ($splitRef) {
-    &HgAutomate::run("ssh -x $fileServer nice " .
+    &HgAutomate::run("$HgAutomate::runSSH $fileServer nice " .
 	 "chainSplit $runDir/chain $runDir/$swappedChain");
   }
 }	#	sub swapChains {}
 
@@ -1020,9 +1034,9 @@
   # Compress the netClassed .net for download (other files should have been
   # compressed already).
   my $runDir = "$buildDir/axtChain";
   if (-e "$runDir/$tDb.$qDb.net") {
-    &HgAutomate::run("ssh -x $fileServer nice " .
+    &HgAutomate::run("$HgAutomate::runSSH $fileServer nice " .
 	 "gzip $runDir/$tDb.$qDb.net");
   }
   # Make an md5sum.txt file.
   my $net = $isSelf ? "" : "$tDb.$qDb.net.gz";