21d53b8ef473ed5f371d2dc14ccbbf3303705f2e angie Thu Apr 28 09:46:26 2016 -0700 hg38.kgXref has some extremely long descriptions (e.g. CLOCK 4277 chars) that make it difficult to see the actual matching genes in the pop-up menu. Truncate descriptions for autocomplete at 120 chars. diff --git src/hg/hgSuggest/hgSuggest.c src/hg/hgSuggest/hgSuggest.c index 681aa89..87a7581 100644 --- src/hg/hgSuggest/hgSuggest.c +++ src/hg/hgSuggest/hgSuggest.c @@ -72,32 +72,37 @@ if(hasKnownCanonical) sqlSafef(query, sizeof(query), "select x.geneSymbol, k.chrom, kg.txStart, kg.txEnd, x.kgID, x.description " "from knownCanonical k, knownGene kg, kgXref x where k.transcript = x.kgID and k.transcript = kg.name " "and x.geneSymbol LIKE '%s%%' order by x.geneSymbol, k.chrom, kg.txStart", prefix); else sqlSafef(query, sizeof(query), "select r.name2, r.chrom, r.txStart, r.txEnd, r.name, d.name " "from %s r, %s g, %s d where r.name2 LIKE '%s%%' and g.acc = r.name " "and g.description = d.id order by r.name2, r.chrom, r.txStart", table, gbCdnaInfoTable, descriptionTable, prefix); } sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { // ignore funny chroms (e.g. _hap chroms. See redmine #4257. if(!strchr(row[1], '_')) { + // We have some very long descriptions, e.g. 4277 chars for hg38 CLOCK, so truncate: + const int maxDesc = 120; + char *description = row[5]; + if (strlen(description) > maxDesc + 4) + strcpy(description + maxDesc, "..."); count++; dyStringPrintf(str, "%s{\"value\": \"%s (%s)\", " "\"id\": \"%s:%d-%s\", " "\"geneSymbol\": \"%s\", " "\"internalId\": \"%s\"}", - count == 1 ? "" : ",\n", row[0], jsonStringEscape(row[5]), + count == 1 ? "" : ",\n", row[0], jsonStringEscape(description), row[1], atoi(row[2])+1, row[3], jsonStringEscape(row[0]), jsonStringEscape(row[4])); } } dyStringPrintf(str, "\n]\n"); puts(dyStringContents(str)); cgiExitTime("hgSuggest", enteredMainTime); return 0; }