5711ac6c2bcaeda814ae1049a0661f499775885e markd Wed Dec 13 00:36:12 2023 -0800 change pslProtToRnaCoords to use common code with pslMap to convert protein/NA to CDS-coordinate/NA alignments. This will correctly remove overlapping blocks after conversion diff --git src/lib/psl.c src/lib/psl.c index 66f2b9c..8ba73f2 100644 --- src/lib/psl.c +++ src/lib/psl.c @@ -1342,30 +1342,38 @@ qStart = psl->qStarts[0]; tStart = psl->tStarts[0]; size = psl->blockSizes[last]; qEnd = psl->qStarts[last] + size; tEnd = psl->tStarts[last] + size; if (psl->strand[0] == '-') reverseIntRange(&qStart, &qEnd, psl->qSize); if (psl->strand[1] == '-') reverseIntRange(&tStart, &tEnd, psl->tSize); psl->qStart = qStart; psl->qEnd = qEnd; psl->tStart = tStart; psl->tEnd = tEnd; } +void pslRecalcBaseCounts(struct psl *psl) +/* Update match/mismatch base counts in PSL, assuming everything is a match */ +{ +psl->match = psl->misMatch = psl->repMatch = psl->nCount = 0; +for (int iBlk = 0; iBlk < psl->blockCount; iBlk++) + psl->match += psl->blockSizes[iBlk]; +} + struct psl *pslTrimToTargetRange(struct psl *oldPsl, int tMin, int tMax) /* Return psl trimmed to fit inside tMin/tMax. Note this does not * update the match/misMatch and related fields. */ { int newSize; int oldBlockCount = oldPsl->blockCount; boolean tIsRc = (oldPsl->strand[1] == '-'); int newBlockCount = 0, completeBlockCount = 0; int i; struct psl *newPsl = NULL; int tMn = tMin, tMx = tMax; /* tMin/tMax adjusted for strand. */ /* Deal with case where we're completely trimmed out quickly. */ newSize = rangeIntersection(oldPsl->tStart, oldPsl->tEnd, tMin, tMax); if (newSize <= 0)