a73cea4b50ac605516110de8e7db5b25b1f0e793 chmalee Tue Aug 10 10:19:26 2021 -0700 Fix bug I recently introduced when searching for old accessions in hgvs search, refs #27942 diff --git src/hg/lib/hgFind.c src/hg/lib/hgFind.c index f3db31c..c379184 100644 --- src/hg/lib/hgFind.c +++ src/hg/lib/hgFind.c @@ -2775,37 +2775,31 @@ table->description = "HGVS"; int padding = 5; int mapErrCnt = 0; struct dyString *dyWarn = dyStringNew(0); struct hgvsHelper *helper = NULL; struct hash *uniqHgvsPos = hashNew(0); struct dyString *chromPosIndex = dyStringNew(0); struct dyString *allWarnings = dyStringNew(0); for (hgvs = hgvsList; hgvs != NULL; hgvs = hgvs->next) { dyStringClear(dyWarn); dyStringClear(chromPosIndex); char *pslTable = NULL; struct bed *mapping = hgvsValidateAndMap(hgvs, db, term, dyWarn, &pslTable); if (dyStringLen(dyWarn) > 0) - { mapErrCnt++; - if (hgvsListLen == 1) - { - warn("%s", dyStringContents(dyWarn)); - } - } if (mapping) { char *trackTable; if (isEmpty(pslTable)) trackTable = "chromInfo"; else if (startsWith("lrg", pslTable)) trackTable = "lrgTranscriptAli"; else if (startsWith("wgEncodeGencode", pslTable)) trackTable = pslTable; else if (startsWith("ncbiRefSeqPsl", pslTable)) { if (startsWith("NM_", hgvs->seqAcc) || startsWith("NR_", hgvs->seqAcc) || startsWith("NP_", hgvs->seqAcc) || startsWith("YP_", hgvs->seqAcc)) trackTable = "ncbiRefSeqCurated"; else if (startsWith("XM_", hgvs->seqAcc) || startsWith("XR_", hgvs->seqAcc) || @@ -2867,57 +2861,62 @@ hgp->tableList->posList->highlight = addHighlight(db, helper->chrom, helper->chromStart, helper->chromEnd); } } } else // all of the positions mapped incorrectly, so the term was bad. However, we may // be able to still go to a general area around the term, so build that, warn the // user about their bad search term, and warn that this is not an exactly correct position // NOTE: There is a bug here in general, in that when mapping an hgvs term we don't // consider alternate haplotypes, and thus below we will always get at least some range // on the same chromosome within a gene, but if the mapping code were to change in the // future, we might end up with some weird coordinates { struct hashEl *hel, *helList= hashElListHash(uniqHgvsPos); + if (helList) + { if (hgp->tableList == NULL) hgp->tableList = table; foundIt = TRUE; - table->name = helper->table; struct hgPos *pos; AllocVar(pos); char *chrom = NULL; int spanStart = INT_MAX, spanEnd = 0; for (hel = helList; hel != NULL; hel = hel->next) { helper = (struct hgvsHelper *)hel->val; chrom = helper->chrom; spanStart = helper->chromStart < spanStart ? helper->chromStart : spanStart; spanEnd = helper->chromEnd > spanEnd ? helper->chromEnd : spanEnd; + table->name = helper->table; } pos->chrom = cloneString(chrom); pos->chromStart = spanStart-padding; pos->chromEnd = spanEnd + padding; pos->name = "Approximate area"; pos->description = term; pos->browserName = term; slAddHead(&table->posList, pos); // highlight the 'mapped' bases to distinguish from padding hgp->tableList->posList->highlight = addHighlight(db, helper->chrom, spanStart, spanEnd); warn("%s", dyStringContents(allWarnings)); warn("Sorry, couldn't locate %s, moving to general location", term); } + else + warn("%s", dyStringContents(dyWarn)); + } dyStringFree(&dyWarn); dyStringFree(&allWarnings); } return foundIt; } struct hgPositions *hgPositionsFind(char *db, char *term, char *extraCgi, char *hgAppNameIn, struct cart *cart, boolean multiTerm) /* Return container of tracks and positions (if any) that match term. */ { struct hgPositions *hgp = NULL, *hgpItem = NULL; regmatch_t substrs[4]; boolean canonicalSpec = FALSE; boolean gbrowserSpec = FALSE; boolean lengthSpec = FALSE;