06b372f6628c2c35eebb105d5f5d6262b23e6d5c hiram Sun Feb 19 15:36:21 2023 -0800 some improvements after running through every single RefSeq assembly no redmine diff --git src/hg/makeDb/doc/asmHubs/commonNames.pl src/hg/makeDb/doc/asmHubs/commonNames.pl index f0a052a..73af586 100755 --- src/hg/makeDb/doc/asmHubs/commonNames.pl +++ src/hg/makeDb/doc/asmHubs/commonNames.pl @@ -14,90 +14,112 @@ my $ncbiSrc="/hive/data/outside/ncbi/genomes"; my $listFile = shift; open (FH, "<$listFile") or die "can not open $listFile"; while (my $asmId = ) { next if ($asmId =~ m/^#/); $asmId =~ s/\s+.*//; chomp $asmId; next if (length($asmId) < 1); my $gcx = substr($asmId, 0, 3); my $id0 = substr($asmId, 4, 3); my $id1 = substr($asmId, 7, 3); my $id2 = substr($asmId, 10, 3); my $srcDir = sprintf "%s/%s/%s/%s/%s/%s", $ncbiSrc, $gcx, $id0, $id1, $id2, $asmId; my $asmRpt = "$srcDir/${asmId}_assembly_report.txt"; + if ( ! -s "${asmRpt}" ) { + printf STDERR "%s\tmissing '%s'\n", $asmId, $asmRpt; + next; + } my $sciName = `grep -i -m 1 "Organism name:" "${asmRpt}" | tr -d " "`; chomp $sciName; $sciName =~ s/.*ism name:\s+//i; $sciName =~ s/\s+\(.*\)$//; + $sciName =~ s/\)//g; + $sciName =~ s/\(//g; + $sciName =~ s/\[//g; + $sciName =~ s/\]//g; my $yearDate = `grep -i -m 1 "Date:" "${asmRpt}" | tr -d " " | awk '{print \$NF}' | sed -e 's/-.*//;'`; chomp $yearDate; my $isolate = `grep -i -m 1 "Isolate:" "${asmRpt}" | tr -d " "`; chomp $isolate; if (length($isolate)) { $isolate =~ s/.*solate: *//; } my $cultivar = `grep -i -m 1 "Infraspecific name:" "${asmRpt}" | tr -d " "`; chomp $cultivar; if (length($cultivar)) { $cultivar =~ s/.*cultivar=//; $cultivar =~ s/.*ecotype=//; $cultivar =~ s/.*strain=//; $cultivar =~ s/.*breed=//; } my $extraStrings = ""; if (length($isolate) && length($cultivar)) { $extraStrings = "$cultivar $isolate $yearDate"; } elsif (length($isolate)) { $extraStrings = "$isolate $yearDate"; } elsif (length($cultivar)) { $extraStrings = "$cultivar $yearDate"; } if ( "x${extraStrings}y" eq "xy" ) { $extraStrings = "$yearDate"; } my $orgName = `grep -i -m 1 "Organism name:" "${asmRpt}" | tr -d " "`; $orgName =~ s/.*\(//; - $orgName =~ s/\)//; + $orgName =~ s/\)//g; + $orgName =~ s/\(//g; + $orgName =~ s/\[//g; + $orgName =~ s/\]//g; + $orgName =~ s/\+//g; chomp $orgName; if ($orgName =~ m/firmicutes|proteobacteria|high G|enterobacteria|agent of/) { # my @a = split('\s+', $sciName); # my $lastN = scalar(@a) - 1; # $orgName = uc(substr($a[0], 0, 1)) . "." . @a[1..$lastN]; $orgName = $sciName; } elsif ($orgName =~ m/ascomycete|basidiomycete|budding|microsporidian|smut|fungi/) { my ($order, undef) = split('\s', $orgName, 2); $order = "budding yeast" if ($order =~ m/budding/); $order = "smut fungi" if ($order =~ m/smut/); $order = "ascomycetes" if ($order =~ m/ascomycete/); $order = "basidiomycetes" if ($order =~ m/basidiomycete/); my @a = split('\s+', $sciName); my $lastN = scalar(@a) - 1; $orgName = "$order " . uc(substr($a[0], 0, 1)) . "." . @a[1..$lastN]; } elsif ($orgName eq "viruses") { $orgName = `grep -i -m 1 "Organism name:" "${asmRpt}" | tr -d " "`; chomp $orgName; $orgName =~ s/.*ism name:\s+//i; $orgName =~ s/\s+\(.*\)$//; } if (length($extraStrings)) { + $extraStrings =~ s/\(//g; + $extraStrings =~ s/\)//g; + $extraStrings =~ s/\[//g; + $extraStrings =~ s/\]//g; + $extraStrings =~ s/\+//g; my @a = split('\s+', $extraStrings); for (my $i = 0; $i < scalar(@a); ++$i) { $orgName =~ s/$a[$i]//; } $orgName =~ s/=//g; $orgName =~ s/ / /g; $orgName =~ s/ +$//; + $orgName =~ s/^ +//; + if (length($orgName)) { printf "%s\t%s (%s)\n", $asmId, $orgName, $extraStrings; } else { + printf "%s\t%s\n", $asmId, $extraStrings; + } + } else { printf "%s\t%s\n", $asmId, $orgName; } } close (FH); # GCA_003369685.2_UOA_Angus_1_assembly_report.txt # Organism name: # GCF_010993605.1_kPetMar1.pri # GCF_900246225.1_fAstCal1.2