f70c2b18fe16f73ae6faee21e006eabcf5fd9aa6 angie Wed Sep 26 10:05:16 2018 -0700 Tweak to prevent symmetrical _alt and _fix mappings from causing alt results in fix searches and vice versa. refs #18854 diff --git src/hg/hgSuggest/hgSuggest.c src/hg/hgSuggest/hgSuggest.c index ceff555..5ac118b 100644 --- src/hg/hgSuggest/hgSuggest.c +++ src/hg/hgSuggest/hgSuggest.c @@ -84,46 +84,48 @@ "\"id\": \"%s:%d-%s\", " "\"geneSymbol\": \"%s\", " "\"internalId\": \"%s\"}", count == 1 ? "" : ",\n", row[0], jsonStringEscape(description), row[1], atoi(row[2])+1, row[3], jsonStringEscape(row[0]), jsonStringEscape(row[4])); } } hFreeConn(&conn); dyStringPrintf(str, "\n]\n"); puts(dyStringContents(str)); } struct slName *queryQNames(struct sqlConnection *conn, char *table, char *term, boolean prefixOnly) -/* If table exists, return qNames in table that match term, otherwise NULL. */ +/* If table exists, return qNames in table that match term, otherwise NULL. Exclude items whose + * tName contains '_' so the mappings between _alt and _fix sequences don't sneak into the wrong + * category's results. */ { struct slName *names = NULL; if (sqlTableExists(conn, table)) { // If there is a ".", make it into a single-character wildcard so that "GL383518.1" // can match "chr1_GL383518v1_alt". char termCpy[strlen(term)+1]; safecpy(termCpy, sizeof termCpy, term); subChar(termCpy, '.', '?'); // Escape '_' because that is an important character in alt/fix sequence names, and support // wildcards: char *escapedTerm = sqlLikeFromWild(termCpy); char query[2048]; sqlSafef(query, sizeof query, "select distinct(qName) from %s where qName like '%s%s%%' " - "order by qName", + "and tName not rlike '.*_.*' order by qName", table, (prefixOnly ? "" : "%"), escapedTerm); names = sqlQuickList(conn, query); } return names; } void writeAltFixMatches(struct jsonWrite *jw, struct slName *matches, char *category) /* Append JSON objects containing alt or fix patch sequence names & optional category. */ { struct slName *match; for (match = matches; match != NULL; match = match->next) { if (strchr(match->name, '_')) { jsonWriteObjectStart(jw, NULL);