02710f0107a6b154d9e5689165941ce724cb4c6a
braney
  Fri Sep 4 13:38:54 2026 -0700
quickLift: fix the seams a second review pass found

quickLiftPslBackToProtein left two things wrong.  pslTransMap can hand back
strand[0] == '-', because it reverse complements the input when the two
alignments disagree about the strand of the sequence they share, and forcing
strand[1] to '+' on top of that produced "-+".  A protein psl is only ever "++"
or "+-", and pslShow reads strand[0] == '-' as "reverse complement the query", so
it would have reverse complemented a protein as though it were DNA.  It now turns
the alignment over so the minus lands on the target side.  qBaseInsert is in
nucleotides like everything else being divided, so it comes down too, and it
joins the divisibility guard:  without it the result failed pslCheck and the
number was printed verbatim on the details page.

Adding that back-conversion made a comment in pslTrack.c false.  The lift no
longer always returns an untranslated alignment, so the drawing code has to ask
rather than assume, the way bigBedTrack.c already did.  A quickLifted protein psl
track was drawing every block at a third of its length.  No such track exists on
hg19 or hg38 today, so this was latent.

The normalized score on the chain details page was read from the assembly on
screen.  Where that assembly has no such table the page died; where it has a
table of the same name, which is the common case for a self or a well known
chain track, it silently returned some other assembly's chain and printed a blank
score.  It now reads the assembly the chain came from, on a connection to it.

Two smaller things: htcBigPslAli guarded its connection with trackHubDatabase
alone, but a GenArk accession does not start with hub_, so it matches the guard
genericClickHandlerPlus already uses; and the table name tests in cds.c now skip
the hub prefix the way the ones in hgc.c were changed to, so a lifted refSeqAli
reaches its special case.

The chain item label took its start from the source chain and its strand
character from the lifted one.  Both now come from the source chain.

refs #38249

diff --git src/hg/lib/quickLift.c src/hg/lib/quickLift.c
index 0d01f7ee357..8ddda15e367 100644
--- src/hg/lib/quickLift.c
+++ src/hg/lib/quickLift.c
@@ -619,39 +619,49 @@
     hashAdd(*pMapPsls, key, mapPsl);
     }
 return mapPsl;
 }
 
 static boolean quickLiftPslBackToProtein(struct psl *lifted)
 /* pslTransMap puts a protein alignment into nucleotide space to do the mapping and leaves
  * it there, so the query start, end and size come back three times too large and the base
  * alignment view refuses the alignment ("size of rna X is 604, has changed since alignment
  * was performed when it was 1812").  Put the query side back into protein units.  Returns
  * FALSE, leaving the alignment alone, when the lift split a codon so the query side no
  * longer divides evenly. */
 {
 int i;
 
-if ((lifted->qStart % 3) || (lifted->qEnd % 3) || (lifted->qSize % 3))
+if ((lifted->qStart % 3) || (lifted->qEnd % 3) || (lifted->qSize % 3) ||
+    (lifted->qBaseInsert % 3))
     return FALSE;
 for (i = 0; i < lifted->blockCount; i++)
     if ((lifted->blockSizes[i] % 3) || (lifted->qStarts[i] % 3))
         return FALSE;
 
+// A protein psl always has its query on the forward strand, "++" or "+-".  pslTransMap can
+// hand back strand[0] == '-' (it reverse complements the input when the two alignments
+// disagree about the shared sequence's strand), and "-+" would tell pslShow to reverse
+// complement the protein as though it were DNA.  Turn it over so the minus lands on the
+// target side, where the protein display expects it.
+if (lifted->strand[0] == '-')
+    pslRc(lifted);
+
 lifted->qStart /= 3;
 lifted->qEnd /= 3;
 lifted->qSize /= 3;
+lifted->qBaseInsert /= 3;
 for (i = 0; i < lifted->blockCount; i++)
     {
     lifted->blockSizes[i] /= 3;
     lifted->qStarts[i] /= 3;
     }
 // A protein psl carries the target strand explicitly, and pslTransMap normalized the
 // target onto the forward strand on the way out.
 lifted->strand[1] = '+';
 lifted->strand[2] = 0;
 return TRUE;
 }
 
 struct psl *quickLiftPsl(struct hash *chainHash, struct hash **pMapPsls, struct psl *psl)
 // Map the target side of an alignment from the other assembly onto our current reference.
 // The query side (the mRNA, EST or protein the alignment is to) is left alone.  Returns