3668909bc45cf722a9b69e2dafbf5e161a6a87a6
angie
  Wed Dec 14 16:36:45 2016 -0800
annoStreamDb should not be hardcoded to find all.joiner in the current directory.  Now, if env var ALL_JOINER_FILE exists, it will be used instead.  vai.pl can now look for all.joiner in hgVai's parent directory (.../cgi-bin) and use ALL_JOINER_FILE if there is no ./all.joiner.  refs #12216 note-28

diff --git src/hg/utils/vai.pl src/hg/utils/vai.pl
index d6fef54..7eba6c5 100755
--- src/hg/utils/vai.pl
+++ src/hg/utils/vai.pl
@@ -246,30 +246,43 @@
 }
 
 # Add command line options that map directly to hgva_... CGI params
 foreach my $param (keys %paramOptions) {
   my $value = $paramOptions{$param}->[0];
   $hgVaiParams{"hgva_$param"} = uriEscape($value);
 }
 
 # If variant file has relative path then convert to absolute.
 if ($hgVaiParams{hgva_variantTrack} eq 'hgva_useVariantFileOrUrl' &&
     $hgVaiParams{hgva_variantFileOrUrl} !~ /^(https?|ftp):\/\// &&
     $hgVaiParams{hgva_variantFileOrUrl} =~ /^[^\/]/) {
   $hgVaiParams{hgva_variantFileOrUrl} = getcwd() . '/' . $hgVaiParams{hgva_variantFileOrUrl};
 }
 
+# If env var ALL_JOINER_FILE is not already set, try to find an all.joiner to set it to.
+if (! $ENV{ALL_JOINER_FILE})
+  {
+    if (-e "all.joiner") {
+      $ENV{ALL_JOINER_FILE} = "all.joiner";
+    } else {
+      my $hgVaiDir = dirname $hgVai;
+      my $joinerFile = $hgVaiDir . "/all.joiner";
+      if (-e $joinerFile) {
+        $ENV{ALL_JOINER_FILE} = $joinerFile};
+    }
+  }
+
 my @params = map { "$_=" . $hgVaiParams{$_} } keys %hgVaiParams;
 my $command = "$hgVai '" . join('&', @params) . "'";
 if ($debug) {
   print "$command\n";
 } else {
   delete $ENV{HTTP_COOKIE};
   if (! $ENV{JKTRASH}) {
     # If user has not set JKTRASH, but TMPDIR is defined, then use TMPDIR instead of cwd.
     my $tmpDir = $ENV{TMPDIR};
     if ($tmpDir) {
       $ENV{JKTRASH} = $tmpDir;
     }
   }
   exit runHgVai($command);
 }