1c41dff03108b4818777b9c9914e81c72555163f hiram Tue Sep 29 12:28:41 2026 -0700 miniMap2 now with swap option refs #34360 diff --git src/hg/utils/automation/AsmHub.pm src/hg/utils/automation/AsmHub.pm index e42f13f4753..b344435310d 100755 --- src/hg/utils/automation/AsmHub.pm +++ src/hg/utils/automation/AsmHub.pm @@ -8,31 +8,31 @@ use warnings; use strict; use Carp; use File::Basename; use File::stat; use vars qw(@ISA @EXPORT_OK); use Exporter; @ISA = qw(Exporter); # This is a listing of the public methods and variables (which should be # treated as constants) exported by this module: @EXPORT_OK = ( # Support for common command line options: qw( commify asmSize ncbiGeneDescription asmIdToPath - accessionFromPath mashSketchDir + accessionFromPath mashSketchDir asmBuildDir ), ); # from Perl Cookbook Recipe 2.17, print out large numbers with comma # delimiters, input is a large number with no commas: sub commify($) { my $text = reverse $_[0]; $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; return scalar reverse $text } # given an asmId.chrom.sizes, return the assembly size from the # sum of column 2: sub asmSize($) { my ($chromSizes) = @_; @@ -55,49 +55,58 @@ # given any path to a sequence file (.2bit, .fa/.fasta, .fa.gz/.fasta.gz), # return the bare NCBI accession (e.g. GCA_939628115.1) if the basename # starts with one -- the standard GenArk convention is that these files # are named <asmId>.2bit, i.e. <accession>_<name>.2bit, but this only # needs the accession prefix to match. Returns undef if the basename # doesn't look like an accession at all (an arbitrary/non-GenArk file). sub accessionFromPath($) { my ($path) = @_; my $base = basename($path); return undef if ($base !~ m/^(GC[AF]_\d{9}\.\d+)/); return $1; } # given a bare accession (or full asmId -- only the accession prefix is -# used), resolve and return the standard GenArk mashSketch cache -# directory for it: -# /hive/data/genomes/asmHubs/{genbankBuild,refseqBuild}/GCx/ddd/ddd/ddd/asmId/mashSketch -# by locating the actual on-disk asmId directory, the same way -# asmHubChainNet.pl resolves a bare accession to its full build -# directory name. Returns undef if no such build directory exists -# (accession not built here, wrong accession, etc.) -- callers should -# fall back to an ordinary scratch directory in that case. -sub mashSketchDir($) { +# used), resolve and return the actual on-disk GenArk build directory for +# it: +# /hive/data/genomes/asmHubs/{genbankBuild,refseqBuild}/GCx/ddd/ddd/ddd/asmId +# by locating the real asmId directory, the same way asmHubChainNet.pl +# resolves a bare accession to its full build directory name. Returns +# undef if no such build directory exists (accession not built here, +# wrong accession, etc.) -- callers should treat that as "not a real, +# built GenArk assembly" and fall back accordingly. +sub asmBuildDir($) { my ($accession) = @_; return undef if ($accession !~ m/^GC[AF]_\d{9}/); my $gcX = substr($accession, 0, 3); my $hubBuildDir = ($gcX eq 'GCA') ? 'genbankBuild' : 'refseqBuild'; my $accDir = "/hive/data/genomes/asmHubs/$hubBuildDir/" . &asmIdToPath($accession); my $asmId = `ls -d $accDir/${accession}_* 2> /dev/null | head -1`; chomp $asmId; return undef if (! $asmId); $asmId =~ s#.*/##; - return "$accDir/$asmId/mashSketch"; + return "$accDir/$asmId"; +} + +# given a bare accession, return its standard GenArk mashSketch cache +# directory (see asmBuildDir() above) -- undef under the same conditions. +sub mashSketchDir($) { + my ($accession) = @_; + my $buildDir = &asmBuildDir($accession); + return undef if (! $buildDir); + return "$buildDir/mashSketch"; } # Look up NCBI's own annotation provider/name/date for an accession from # the 'genark' database's assemblySummary{Genbank,Refseq} table, falling # back to the ...Historical variant when the accession isn't in the # current one (a superseded/suppressed assembly). Returns ("", "", "") # if found in neither, so callers always get three defined strings. sub fetchAnnotationInfo($$) { my ($asmType, $accession) = @_; my $table = "assemblySummary" . ucfirst($asmType); foreach my $t ($table, "${table}Historical") { my $result = `hgsql -N -e 'select annotationProvider,annotationName,annotationDate from $t where assemblyAccession="$accession";' genark 2> /dev/null`; chomp $result; next if ($result eq ""); my ($provider, $name, $date) = split('\t', $result);