1fb8451afd9970c025e2c3a0c9a8c4f685d7416c angie Mon Oct 25 16:46:31 2010 -0700 Code Review #1452 (v243 preview1): Melissa pointed out that makingoffsetToGenomic recursive would be more robust than assuming that the answer must lie either in this exon or the next one. diff --git src/hg/hgTables/gffOut.c src/hg/hgTables/gffOut.c index 130b438..7f32135 100644 --- src/hg/hgTables/gffOut.c +++ src/hg/hgTables/gffOut.c @@ -101,17 +101,18 @@ { if (exonIndx < 1) errAbort("offsetToGenomic: need previous exon, but given index of %d", exonIndx); - int extra = exonStart - simpleAnswer; + int stillNeeded = simpleAnswer - exonStart; int prevExonEnd = bed->chromStart + bed->chromStarts[exonIndx-1] + bed->blockSizes[exonIndx-1]; - return prevExonEnd - extra; + return offsetToGenomic(bed, exonIndx-1, prevExonEnd, stillNeeded); } else if (offset > 0 && simpleAnswer > exonEnd) { if (exonIndx >= bed->blockCount - 1) errAbort("offsetToGenomic: need next exon, but given index of %d (>= %d)", exonIndx, bed->blockCount - 1); - int extra = simpleAnswer - exonEnd; - return (bed->chromStart + bed->chromStarts[exonIndx+1] + extra); + int stillNeeded = simpleAnswer - exonEnd; + int nextExonStart = bed->chromStart + bed->chromStarts[exonIndx+1]; + return offsetToGenomic(bed, exonIndx+1, nextExonStart, stillNeeded); } return simpleAnswer; }