b509f936321e0d635a785f48ee0638744fbc3b8d angie Fri Nov 5 11:07:20 2010 -0700 Bug found by Fan: in our zeal to detect "term:offset" (e.g. "chr1:2385495")search terms, we were mangling IDs like "RGD:2138". Solution: don't support single-base offsets except for sequences named in chromInfo (hgOfficialChromName). diff --git src/hg/lib/hgFind.c src/hg/lib/hgFind.c index 41d8ec7..c6dfbb1 100644 --- src/hg/lib/hgFind.c +++ src/hg/lib/hgFind.c @@ -2986,30 +2986,31 @@ if(isEmpty(term)) return hgp; hgp->query = cloneString(term); hgp->database = db; if (extraCgi == NULL) extraCgi = ""; hgp->extraCgi = cloneString(extraCgi); if (singleSearch(db, term, cart, hgp)) return hgp; /* Allow any search term to end with a :Start-End range -- also support stuff * pasted in from BED (chrom start end) or SQL query (chrom | start | end). * If found, strip it off and remember the start and end. */ +char *originalTerm = cloneString(term); if ((canonicalSpec = matchRegexSubstr(term, canonicalRangeExp, substrs, ArraySize(substrs))) || (gbrowserSpec = matchRegexSubstr(term, gbrowserRangeExp, substrs, ArraySize(substrs))) || (lengthSpec = matchRegexSubstr(term, lengthRangeExp, substrs, ArraySize(substrs))) || matchRegexSubstr(term, bedRangeExp, substrs, ArraySize(substrs)) || (singleBaseSpec = matchRegexSubstr(term, singleBaseExp, substrs, ArraySize(substrs))) || matchRegexSubstr(term, sqlRangeExp, substrs, ArraySize(substrs))) { /* Since we got a match, substrs[1] is the chrom/term, [2] is relStart, @@ -3053,30 +3054,35 @@ start = start + relStart; if (end > chromSize) end = chromSize; if (start < 0) start = 0; } singlePos(hgp, "Chromosome Range", NULL, "chromInfo", term, "", chrom, start, end); } else { struct hgFindSpec *shortList = NULL, *longList = NULL; struct hgFindSpec *hfs; boolean done = FALSE; + // Disable singleBaseSpec for any term that is not hgOfficialChromName + // because that mangles legitimate IDs that are [A-Z]:[0-9]+. + if (singleBaseSpec) + term = sqlEscapeString(originalTerm); + hgFindSpecGetAllSpecs(db, &shortList, &longList); for (hfs = shortList; hfs != NULL; hfs = hfs->next) { if (hgFindUsingSpec(db, hfs, term, hgp, relativeFlag, relStart, relEnd, multiTerm)) { done = TRUE; if (! hgFindSpecSetting(hfs, "semiShortCircuit")) break; } } if (! done) { for (hfs = longList; hfs != NULL; hfs = hfs->next) {