4163e36238919a24e50cbd911aa52fa3a07a7796 chmalee Thu Aug 24 10:58:38 2023 -0700 Fix backwards compatibility bug I introduced when adding multiple pcr results, refs #32022 diff --git src/hg/cgilib/pcrResult.c src/hg/cgilib/pcrResult.c index 655f280..5d51810 100644 --- src/hg/cgilib/pcrResult.c +++ src/hg/cgilib/pcrResult.c @@ -95,69 +95,88 @@ *retFPrimer = fPrimer; } if (retRPrimer != NULL) { safecpy(rPrimer, sizeof(rPrimer), words[1]); touppers(rPrimer); *retRPrimer = rPrimer; } break; } } dyStringFree(&primerPair); lineFileClose(&lf); } +static boolean checkPcrResultCoordinates(boolean targetSearchResult, char *tName, int tStart, + int tEnd, char *item, int itemStart, int itemEnd, char *chrom) +/* Check the coordinates of a pcrResult match so we know which list of psls + * to add the match to */ +{ +if (targetSearchResult) + { + if (sameString(tName, item) && tStart == itemStart && tEnd == itemEnd) + return TRUE; + } +else if (sameString(tName, chrom) && tStart == itemStart && tEnd == itemEnd) + { + return TRUE; + } +return FALSE; +} + void pcrResultGetPsl(char *fileName, struct targetDb *target, char *item, char *chrom, int itemStart, int itemEnd, struct psl **retItemPsl, struct psl **retOtherPsls, char *fPrimer, char *rPrimer) /* Read in psl from file. If a psl matches the given item position, set * retItemPsl to that; otherwise add it to retOtherPsls. Die if no psl * matches the given item position. */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); struct psl *itemPsl = NULL, *otherPsls = NULL; char *pslFields[21]; boolean targetSearchResult = stringIn("__", item) != NULL; while (lineFileRow(lf, pslFields)) { struct psl *psl = pslLoad(pslFields); boolean gotIt = FALSE; + // if "_" is in the item name, we look up the result(s) by the primer pair, else + // we just show all psls + if (stringIn("_", item)) + { char *pair = cloneString(psl->qName); char *under = strchr(pair, '_'); *under = '\0'; char *thisFPrimer = pair; char *thisRPrimer = under+1; if (!differentWord(thisFPrimer, fPrimer) && !differentWord(thisRPrimer, rPrimer)) { - if (targetSearchResult) - { - if (sameString(psl->tName, item) && psl->tStart == itemStart && psl->tEnd == itemEnd) - gotIt = TRUE; + gotIt = checkPcrResultCoordinates(targetSearchResult, psl->tName, psl->tStart, + psl->tEnd, item, itemStart, itemEnd, chrom); + } } - else if (sameString(psl->tName, chrom) && psl->tStart == itemStart && - psl->tEnd == itemEnd) + else { - gotIt = TRUE; + gotIt = checkPcrResultCoordinates(targetSearchResult, psl->tName, psl->tStart, + psl->tEnd, item, itemStart, itemEnd, chrom); } if (gotIt) itemPsl = psl; else slAddHead(&otherPsls, psl); } - } lineFileClose(&lf); if (itemPsl == NULL) { if (target != NULL) errAbort("Did not find record for amplicon in %s sequence %s", target->description, item); else errAbort("Did not find record for amplicon at %s:%d-%d", chrom, itemStart, itemEnd); } if (retItemPsl != NULL) *retItemPsl = itemPsl; else pslFree(&itemPsl); if (retOtherPsls != NULL)