a8463b815b54c8b69dcae73cf9d203891f9efa07 markd Sun Sep 27 23:04:28 2015 -0700 simplified pslCheck code diff --git src/lib/psl.c src/lib/psl.c index f85b1d9..46d0253 100644 --- src/lib/psl.c +++ src/lib/psl.c @@ -1430,99 +1430,97 @@ /* error handling on an pslCheck error, counting error and issuing description * of PSL on the first error. */ { if (*errCount == 0) printPslDesc(pslDesc, out, psl); va_list args; va_start(args, format); vfprintf(out, format, args); va_end(args); (*errCount)++; } static void chkBlkRanges(char* pslDesc, FILE* out, struct psl* psl, char* pName, char* pLabel, char pCLabel, char pStrand, unsigned pSize, unsigned pStart, unsigned pEnd, - unsigned iBlk, unsigned* blockSizes, - unsigned* pBlockStarts, int* errCount) + unsigned iBlk, unsigned* pBlockStarts, int* errCount) /* check the target or query ranges in a PSL incrementing errorCnt */ { unsigned blkStart = pBlockStarts[iBlk]; -unsigned blkEnd = blkStart+blockSizes[iBlk]; +unsigned blkEnd = blkStart+psl->blockSizes[iBlk]; /* translate stand to genomic coords */ unsigned gBlkStart = (pStrand == '+') ? blkStart : (pSize - blkEnd); unsigned gBlkEnd = (pStrand == '+') ? blkEnd : (pSize - blkStart); if ((pSize > 0) && (blkEnd > pSize)) chkError(pslDesc, out, psl, errCount, "\t%s %s block %u end %u > %cSize %u\n", pName, pLabel, iBlk, blkEnd, pCLabel, pSize); if (gBlkStart < pStart) chkError(pslDesc, out, psl, errCount, "\t%s %s block %u start %u < %cStart %u\n", pName, pLabel, iBlk, gBlkStart, pCLabel, pStart); if (gBlkStart >= pEnd) chkError(pslDesc, out, psl, errCount, "\t%s %s block %u start %u >= %cEnd %u\n", pName, pLabel, iBlk, gBlkStart, pCLabel, pEnd); if (gBlkEnd < pStart) chkError(pslDesc, out, psl, errCount, "\t%s %s block %u end %u < %cStart %u\n", pName, pLabel, iBlk, gBlkEnd, pCLabel, pStart); if (gBlkEnd > pEnd) chkError(pslDesc, out, psl, errCount, "\t%s %s block %u end %u > %cEnd %u\n", pName, pLabel, iBlk, gBlkEnd, pCLabel, pEnd); if (iBlk > 0) { - unsigned prevBlkEnd = pBlockStarts[iBlk-1]+blockSizes[iBlk-1]; + unsigned prevBlkEnd = pBlockStarts[iBlk-1]+psl->blockSizes[iBlk-1]; if (blkStart < prevBlkEnd) chkError(pslDesc, out, psl, errCount, "\t%s %s block %u start %u < previous block end %u\n", pName, pLabel, iBlk, blkStart, prevBlkEnd); } } static void chkRanges(char* pslDesc, FILE* out, struct psl* psl, char* pName, char* pLabel, char pCLabel, char pStrand, unsigned pSize, unsigned pStart, unsigned pEnd, - unsigned blockCount, unsigned* blockSizes, unsigned* pBlockStarts, int blockSizeMult, int* errCount) /* check the target or query ranges in a PSL, increment errorCnt */ { unsigned iBlk; if (pStart >= pEnd) chkError(pslDesc, out, psl, errCount, "\t%s %cStart %u >= %cEnd %u\n", pName, pCLabel, pStart, pCLabel, pEnd); if (pEnd > pSize) chkError(pslDesc, out, psl, errCount, "\t%s %cEnd %u >= %cSize %u\n", pName, pCLabel, pEnd, pCLabel, pSize); // check that block start/end matches overall start end unsigned pStartStrand = pStart, pEndStrand = pEnd; if (pStrand != '+') reverseUnsignedRange(&pStartStrand, &pEndStrand, pSize); -unsigned lastBlkEnd = pBlockStarts[blockCount-1] + (blockSizeMult * blockSizes[blockCount-1]); +unsigned lastBlkEnd = pBlockStarts[psl->blockCount-1] + (blockSizeMult * psl->blockSizes[psl->blockCount-1]); if ((pStartStrand != pBlockStarts[0]) || (pEndStrand != lastBlkEnd)) chkError(pslDesc, out, psl, errCount, "\t%s strand \"%c\" adjusted %cStart-%cEnd range %u-%u != block range %u-%u\n", pName, pStrand, pCLabel, pCLabel, pStartStrand, pEndStrand, pBlockStarts[0], lastBlkEnd); -for (iBlk = 0; iBlk < blockCount; iBlk++) +for (iBlk = 0; iBlk < psl->blockCount; iBlk++) chkBlkRanges(pslDesc, out, psl, pName, pLabel, pCLabel, pStrand, - pSize, pStart, pEnd, iBlk, blockSizes, pBlockStarts, errCount); + pSize, pStart, pEnd, iBlk, pBlockStarts, errCount); } static void chkInsertCounts(char* pslDesc, FILE* out, struct psl* psl, char* pName, char pCLabel, unsigned* pBlockStarts, unsigned pNumInsert, unsigned pBaseInsert, int* errCount) /* check the insert counts, incrementing errorCnt */ { unsigned numInsert = 0, baseInsert = 0; int iBlk; for (iBlk = 1; iBlk < psl->blockCount; iBlk++) { unsigned gapSize = pBlockStarts[iBlk] - (pBlockStarts[iBlk-1]+psl->blockSizes[iBlk-1]); @@ -1552,36 +1550,36 @@ int i, errCount = 0; int tBlockSizeMult = pslIsProtein(psl) ? 3 : 1; /* check strand value */ for (i = 0; VALID_STRANDS[i] != NULL; i++) { if (strcmp(psl->strand, VALID_STRANDS[i]) == 0) break; } if (VALID_STRANDS[i] == NULL) chkError(pslDesc, out, psl, &errCount, "\tinvalid PSL strand: \"%s\"\n", psl->strand); /* check target */ chkRanges(pslDesc, out, psl, psl->tName, "target", 't', pslTStrand(psl), psl->tSize, psl->tStart, psl->tEnd, - psl->blockCount, psl->blockSizes, psl->tStarts, tBlockSizeMult, &errCount); + psl->tStarts, tBlockSizeMult, &errCount); chkInsertCounts(pslDesc, out, psl, psl->tName, 't', psl->tStarts, psl->tNumInsert, psl->tBaseInsert, &errCount); /* check query */ chkRanges(pslDesc, out, psl, psl->qName, "query", 'q', pslQStrand(psl), psl->qSize, psl->qStart, psl->qEnd, - psl->blockCount, psl->blockSizes, psl->qStarts, 1, &errCount); + psl->qStarts, 1, &errCount); chkInsertCounts(pslDesc, out, psl, psl->qName, 'q', psl->qStarts, psl->qNumInsert, psl->qBaseInsert, &errCount); return errCount; } struct hash *readPslToBinKeeper(char *sizeFileName, char *pslFileName) /* read a list of psls and return results in hash of binKeeper structure for fast query*/ { struct binKeeper *bk; struct psl *psl; struct lineFile *sf = lineFileOpen(sizeFileName, TRUE); struct lineFile *pf = lineFileOpen(pslFileName , TRUE); struct hash *hash = newHash(0); char *chromRow[2]; char *row[21] ;