6b4d4242132b637c7ae9a2da8d63efea608d41af
hiram
  Mon Dec 22 18:51:50 2025 -0800
get the liftOver and quickLift links properly in place for both database and GenArk browsers and the entries into the liftOverChain and quickLiftChain tables

diff --git src/hg/utils/automation/doBlastzChainNet.pl src/hg/utils/automation/doBlastzChainNet.pl
index 91690160617..767fd7e5a42 100755
--- src/hg/utils/automation/doBlastzChainNet.pl
+++ src/hg/utils/automation/doBlastzChainNet.pl
@@ -9,30 +9,31 @@
 # - lots of testing
 # - better logging: right now it just passes stdout and stderr,
 #   leaving redirection to a logfile up to the user
 # - -swapBlastz, -loadBlastz
 # - -tDb, -qDb
 # - -tUnmasked, -qUnmasked
 # - -axtBlastz
 # - another Gill wish list item: save a lav header (involves run-blastz-ucsc)
 # - 2bit / multi-sequence support when abridging?
 # - reciprocal best?
 # - hgLoadSeq of query instead of assuming there's a $qDb database?
 
 use Getopt::Long;
 use warnings;
 use strict;
+use Carp;
 use FindBin qw($Bin);
 use lib "$Bin";
 use HgAutomate;
 use HgRemoteScript;
 use HgStepManager;
 use File::Basename;
 
 # Hardcoded paths/command sequences:
 my $getFileServer = '/cluster/bin/scripts/fileServer';
 my $blastzRunUcsc = "$Bin/blastz-run-ucsc";
 my $partition = "$Bin/partitionSequence.pl";
 my $clusterLocal = '/scratch/hg';
 my $clusterSortaLocal = '/iscratch/i';
 my @clusterNAS = ('/cluster/bluearc', '/san/sanvol1');
 my $clusterNAS = join('/... or ', @clusterNAS) . '/...';
@@ -268,30 +269,45 @@
     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, $tChromInfoExists, $qChromInfoExists);
 
+sub genArkAccessionPath($) {
+  # return path to assembly hub GCx/012/345/678/accession/ directory
+  my ($asmId) = @_;
+  confess "Must have exactly 1 argument" if (scalar(@_) != 1);
+  confess "must supply GC[AF]_... assembly ID" if ($asmId !~ m/^GC/);
+  my @a = split(/_/, $asmId);
+  my $accession = "$a[0]_$a[1]";
+  my $gcX = substr($asmId,0,3);
+  my $d0 = substr($asmId,4,3);
+  my $d1 = substr($asmId,7,3);
+  my $d2 = substr($asmId,10,3);
+  my $accessionDir = "$gcX/$d0/$d1/$d2/$accession";
+  return $accessionDir;
+}
+
 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 " .
       "$desc instead of $dir .\n\n";
@@ -1620,32 +1636,46 @@
   if (! $isSelf && -s "$runDir/$tDb.$qDb.net.gz") {
      $successFile = "$runDir/$tDb.$qDb.net.gz";
   }
   if (! -e $successFile && ! $opt_debug) {
     die "installDownloads: looks like previous stage was not successful " .
       "(can't find $successFile).\n";
   }
   my $goldenPath = $HgAutomate::goldenPath;
   if ($tDb =~ m/^GC/) {
      $goldenPath = &HgAutomate::asmHubDownloadDir($tDb);
   }
   &dumpDownloadReadme("$runDir/README.txt");
   my $over = $tDb . "To$QDb.over.chain.gz";
   my $quick = $qDb;
   my $liftOverDir = "$HgAutomate::clusterData/$tDb/$HgAutomate::trackBuild/liftOver";
+  my $genArkQuickDir = "";	# build directory
+  my $genArkQuickLinkDir = "";	# asmHubs staging link directory quickLift
+  my $genArkOverLinkDir = "";	# asmHubs staging link directory liftOver
+  my $genArkGbdbQuickDir = "";	# /gbdb/genark/.../quickLift directory
+  my $genArkGbdbOverDir = "";	# /gbdb/genark/.../liftOver directory
+  my $genArkTrackLink = "";	# ../trackData/... directory
   if ($tDb =~ m/^GC/) {
      $liftOverDir = &HgAutomate::asmHubBuildDir($tAsmId) . "/liftOver";
+     $genArkQuickDir = &HgAutomate::asmHubBuildDir($tAsmId) . "/quickLift";
+     my $accessionPath = genArkAccessionPath($tAsmId);
+     $genArkQuickLinkDir = "/hive/data/genomes/asmHubs/${accessionPath}/quickLift";
+     $genArkOverLinkDir = "/hive/data/genomes/asmHubs/${accessionPath}/liftOver";
+     $genArkGbdbQuickDir = "/gbdb/genark/${accessionPath}/quickLift";
+     $genArkGbdbOverDir = "/gbdb/genark/${accessionPath}/liftOver";
+     $genArkTrackLink = "$buildDir/axtChain/$tDb.$qDb.quick";
+     $genArkTrackLink =~ s#.*trackData#../trackData#;
   }
   my $gpLiftOverDir = "$goldenPath/$tDb/liftOver";
   my $gbdbLiftOverDir = "$HgAutomate::gbdb/$tDb/liftOver";
   my $gbdbQuickLiftDir = "$HgAutomate::gbdb/$tDb/quickLift";
   my $andNets = $isSelf ? "." :
     ", nets and axtNet,\n" .
     "# and copies the liftOver chains to the liftOver download dir.";
   my $whatItDoes = "It creates the download directory for chains$andNets";
   my $bossScript = new HgRemoteScript("$runDir/installDownloads.csh", $dbHost,
 				      $runDir, $whatItDoes, $DEF);
   $bossScript->add(<<_EOF_
 mkdir -p $goldenPath/$tDb
 rm -rf $goldenPath/$tDb/vs$QDb
 mkdir -p $goldenPath/$tDb/vs$QDb
 cd $goldenPath/$tDb/vs$QDb
@@ -1662,31 +1692,49 @@
     if ( -s "$runDir/$tDb.$qDb.net.gz" ) {
     $bossScript->add(<<_EOF_
 ln -s $runDir/$tDb.$qDb.net.gz .
 _EOF_
       );
     }
     $bossScript->add(<<_EOF_
 
 $axt
 
 mkdir -p $gpLiftOverDir
 rm -f $gpLiftOverDir/$over
 ln -s $liftOverDir/$over $gpLiftOverDir/$over
 _EOF_
       );
-    if ($tDb !~ m/^GC/) {
+    if ($tDb =~ m/^GC/) {
+      $bossScript->add(<<_EOF_
+mkdir -p $genArkQuickDir
+rm -f $genArkQuickDir/${quick}.bb
+rm -f $genArkQuickDir/${quick}.link.bb
+rm -f $genArkQuickLinkDir $genArkGbdbQuickDir
+rm -f $genArkOverLinkDir $genArkGbdbOverDir
+ln -s ${genArkTrackLink}.bb $genArkQuickDir/${quick}.bb
+ln -s ${genArkTrackLink}Link.bb $genArkQuickDir/${quick}.link.bb
+ln -s $genArkQuickDir $genArkQuickLinkDir
+ln -s $genArkQuickLinkDir $genArkGbdbQuickDir
+ln -s $liftOverDir $genArkOverLinkDir
+ln -s $genArkOverLinkDir $genArkGbdbOverDir
+hgAddLiftOverChain -minMatch=0.1 -multiple -path=$genArkGbdbOverDir/$over \\
+  $tDb $qDb
+$ENV{'HOME'}/kent/src/hg/utils/automation/addQuickLift.py $tDb $qDb $genArkGbdbQuickDir/${quick}.bb
+_EOF_
+      );
+    } else {
       $bossScript->add(<<_EOF_
 mkdir -p $gbdbLiftOverDir $gbdbQuickLiftDir
 rm -f $gbdbLiftOverDir/$over
 rm -f $gbdbQuickLiftDir/${quick}.bb
 rm -f $gbdbQuickLiftDir/${quick}.link.bb
 ln -s $buildDir/axtChain/$tDb.$qDb.quick.bb $gbdbQuickLiftDir/${quick}.bb
 ln -s $buildDir/axtChain/$tDb.$qDb.quickLink.bb $gbdbQuickLiftDir/${quick}.link.bb
 ln -s $liftOverDir/$over $gbdbLiftOverDir/$over
 hgAddLiftOverChain -minMatch=0.1 -multiple -path=$gbdbLiftOverDir/$over \\
   $tDb $qDb
 $ENV{'HOME'}/kent/src/hg/utils/automation/addQuickLift.py $tDb $qDb $gbdbQuickLiftDir/${quick}.bb
 _EOF_
       );
     }