83ccf1c6b15c91b83723894b882f3af1e340882b
braney
  Sun Jun 1 16:37:23 2025 -0700
exon frames are in transcription strand order so if it's changed during quickLift we need to flip the order in the genePred

diff --git src/hg/lib/genePred.c src/hg/lib/genePred.c
index 65dadcf876d..1f90415322e 100644
--- src/hg/lib/genePred.c
+++ src/hg/lib/genePred.c
@@ -2103,47 +2103,61 @@
         // Yet to reach the target base... accumulate exon worth
         codingBasesSoFar += (exonEnd - exonStart);
         }
 
     exonIx += (reverse ? -1 : 1);
     }
 
 if (isCoding != NULL && codingBasesSoFar > 0)
     {
     *isCoding = FALSE;
     return codingBasesSoFar;
     }
 return -1;  // introns not okay
 }
 
-struct genePredExt  *genePredFromBedBigGenePred( char *chrom, struct bed *bed, struct bigBedInterval *bb)
+struct genePredExt  *genePredFromBedBigGenePred( char *chrom, struct bed *bed, struct bigBedInterval *bb, boolean changedStrand)
 /* build a genePred from a bigGenePred and a bed file */
 {
 char *extra = cloneString(bb->rest);
 int numCols = 12 + 8 - 3;
 char *row[numCols];
 int wordCount = chopByChar(extra, '\t', row, numCols);
 if (wordCount < numCols)
     errAbort("expected at least %d columns in bigGenePred, got %d; is this actually a bigGenePred?", numCols, wordCount);
 
 struct genePredExt *gp = bedToGenePredExt(bed);
 
 gp->name2 = cloneString(row[ 9]);
 
 int numBlocks;
 sqlSignedDynamicArray(row[ 12],  &gp->exonFrames, &numBlocks);
 gp->optFields |= genePredExonFramesFld;
+
+// exon frames are in transcription strand order so if it's changed during quickLift
+// we need to flip the order in the list
+if (changedStrand && (numBlocks > 1))
+    {
+    int *reorderFrames;
+    AllocArray(reorderFrames, numBlocks);
+
+    int ii;
+    for(ii=0; ii < numBlocks; ii++)
+        reorderFrames[ii] = gp->exonFrames[(numBlocks - 1) - ii];
+
+    gp->exonFrames = reorderFrames;
+    }
 //assert (numBlocks == gp->exonCount);
 
 gp->type = cloneString(row[13]);
 gp->geneName = cloneString(row[14]);
 gp->geneName2 = cloneString(row[15]);
 
 return gp;
 }
 
 struct genePredExt  *genePredFromBigGenePred( char *chrom, struct bigBedInterval *bb)
 /* build a genePred from a bigGenePred */
 {
 char *extra = cloneString(bb->rest);
 int numCols = 12 + 8 - 3;
 char *row[numCols];