e745ccb794a88cf79f4e63a375a3eeb93e918563 braney Mon Jan 26 10:15:44 2026 -0800 move code to reverse exonFrames to calcLiftOverGenePred() so it will work with the liftOver tool diff --git src/hg/lib/genePred.c src/hg/lib/genePred.c index 1f90415322e..26f4d2ebb38 100644 --- src/hg/lib/genePred.c +++ src/hg/lib/genePred.c @@ -2103,61 +2103,68 @@ // 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 } +void genePredReverseFrames(struct genePred *gp) +// Reverse exon frames for this genePred +{ +if (gp->exonCount == 1) + return; + +int *reorderFrames; +AllocArray(reorderFrames, gp->exonCount); + +int ii; +for(ii=0; ii < gp->exonCount; ii++) + reorderFrames[ii] = gp->exonFrames[(gp->exonCount - 1) - ii]; + +gp->exonFrames = reorderFrames; +} + 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; - } + genePredReverseFrames((struct genePred *)gp); //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];