f7a079f0d9b56429eb44109f1d05be2ab759294a
max
  Fri Sep 11 12:13:22 2026 -0700
uniprot otto: the duplicate-name count reported zero every time

The line that was meant to say how many CAT transcript names had been made unique
subtracted the distinct name count of the file it had just uniquified, which is
equal to its row count by construction, so the answer was always zero and the
message never appeared. The rename itself was working: the hs1 run has 3769 rows
carrying a -dup suffix and all 234903 names distinct.

Count the names in the input instead, and say which of the two numbers is which.
Verified against the real hs1 files: 234903 rows, 231134 distinct names before,
so it now reports 3769 renamed.

refs #38300

diff --git src/hg/utils/otto/uniprot/doUniprot src/hg/utils/otto/uniprot/doUniprot
index 91de301bdcf..0ce0a7e180b 100755
--- src/hg/utils/otto/uniprot/doUniprot
+++ src/hg/utils/otto/uniprot/doUniprot
@@ -1890,33 +1890,35 @@
         geneBb = findBestGeneBigBed(db, hubDir)[1]
         gpName = join(dbDir, "transcripts.gp")
         cdsName = join(dbDir, "transcripts.cds")
 
         run(["bigGenePredToGenePred", geneBb, gpName+".raw"])
 
         # CAT names its transcripts after the source gene, so paralogs share a name: the
         # hs1 CAT set has 777 duplicated names in 234903 transcripts, RBMY1F-1 three times
         # with three different lengths. pslMap then cannot tell which transcript a protein
         # alignment meant and stops with "inPsl RBMY1F-1 tSize (1887) != mapPsl RBMY1F-1
         # qSize (1718)". Make the names unique before the fasta and the PSL are derived
         # from this file, so the two always agree. RefSeq accessions are unique already,
         # so this is a no-op for them.
         run("""awk -F'\t' -v OFS='\t' '{ seen[$1]++; if (seen[$1]>1) $1 = $1 "-dup" seen[$1]; print }' %s.raw > %s""" \
                 % (gpName, gpName))
-        dupCount = len(open(gpName+".raw").readlines()) - len(set(l.split("\t")[0] for l in open(gpName)))
+        rawNames = [l.split("\t")[0] for l in open(gpName+".raw")]
+        dupCount = len(rawNames) - len(set(rawNames))
         if dupCount:
-            logging.info("%s: made %d duplicated transcript names unique" % (db, dupCount))
+            logging.info("%s: %d of %d transcripts shared a name with another and were "
+                    "renamed to keep the fasta and the PSL in step" % (db, dupCount, len(rawNames)))
         os.remove(gpName+".raw")
 
         run(["genePredToFakePsl", "-chromSize=%s" % chromSizesFile(db),
              "noDb", gpName, pslName, cdsName])
         run(["getRnaPred", "-genomeSeqs=%s" % twoBitFname(db),
              "noDb", gpName, "all", faName])
 
         logging.info("Created %s and %s for %s/%s from %s" % (faName, pslName, db, geneTable, geneBb))
         return faName, pslName
 
     if geneTable=="ncbiRefSeq":
         origFa = "/gbdb/%s/ncbiRefSeq/seqNcbiRefSeq.rna.fa" % db
         shutil.copyfile(origFa, faName)
         pslTable = "ncbiRefSeqPsl"