00242917a58263154851ef6890584b38e66dc833 markd Wed Mar 8 12:43:58 2017 -0800 add "filter active" inicator to label when filters are active on all gencode diff --git src/hg/hgTracks/gencodeTracks.c src/hg/hgTracks/gencodeTracks.c index ad9c30a..10301f9 100644 --- src/hg/hgTracks/gencodeTracks.c +++ src/hg/hgTracks/gencodeTracks.c @@ -12,30 +12,31 @@ struct gencodeQuery /* structure used to store information about the query being assembled. * this allows a join to bring in additional data without having to * do repeated queries. */ { struct dyString *fields; // select fields struct dyString *from; // from clause struct dyString *where; // where clause boolean isGenePredX; // does this have the extended fields? int nextFieldCol; // next available column in result row int supportLevelCol; // support level column if joined for highlighting, or -1 int transcriptTypeCol; // transcript type column if joined for highlighting, or -1 int transcriptSourceCol; // transcript source column if joined for method highlighting, or -1 int tagCol; // tag column if joined for method highlighting, or -1 + boolean isFiltered; // are there filters on the query? filterBy_t *supportLevelHighlight; // choices for support level highlighting if not NULL filterBy_t *transcriptTypeHighlight; // choices for transcript type highlighting if not NULL filterBy_t *transcriptMethodHighlight; // choices for transcript method highlighting if not NULL filterBy_t *tagHighlight; // choices for tag highlighting if not NULL boolean joinAttrs; // join the wgEncodeGencodeAttrs table boolean joinSupportLevel; // join the wgEncodeGencodeTranscriptionSupportLevel table boolean joinTranscriptSource; // join the wgEncodeGencodeTranscriptSource table boolean joinTag; // join the wgEncodeGencodeTag table }; static struct gencodeQuery *gencodeQueryNew(void) /* construct a new gencodeQuery object */ { struct gencodeQuery *gencodeQuery; AllocVar(gencodeQuery); @@ -221,30 +222,31 @@ } static void gencodeFilterByQuery(struct track *tg, filterBy_t *filterBy, struct gencodeQuery *gencodeQuery) /* handle adding on filterBy clause for gencode */ { if (sameString(filterBy->column, "transcriptMethod")) filterByMethodQuery(tg, filterBy, gencodeQuery); else if (sameString(filterBy->column, "supportLevel")) filterBySupportLevelQuery(tg, filterBy, gencodeQuery); else if (sameString(filterBy->column, "tag")) filterByTagQuery(tg, filterBy, gencodeQuery); else if (startsWith("attrs.", filterBy->column)) filterByAttrsQuery(tg, filterBy, gencodeQuery); else errAbort("gencodeFilterByQuery: don't know how to filter on column \"%s\"", filterBy->column); +gencodeQuery->isFiltered = TRUE; } static void gencodeFilterBySetQuery(struct track *tg, struct gencodeQuery *gencodeQuery) /* build where clause based on filters. */ { filterBy_t *filterBySet = filterBySetGet(tg->tdb, cart, NULL); filterBy_t *filterBy; for (filterBy = filterBySet; filterBy != NULL; filterBy = filterBy->next) { if (!filterByAllChosen(filterBy)) gencodeFilterByQuery(tg, filterBy, gencodeQuery); } filterBySetFree(&filterBySet); } @@ -484,51 +486,62 @@ sqlCkIl(dyStringContents(gencodeQuery->fields)), dyStringContents(gencodeQuery->from), dyStringContents(gencodeQuery->where)); struct sqlResult *sr = sqlGetResult(conn, dyStringContents(query)); dyStringFree(&query); return sr; } static struct linkedFeatures *loadGencodeGenePred(struct track *tg, struct gencodeQuery *gencodeQuery, char **row, unsigned highlightColor) /* load one genePred record into a linkedFeatures object */ { struct genePred *gp = genePredExtLoad(row, (gencodeQuery->isGenePredX ? GENEPREDX_NUM_COLS: GENEPRED_NUM_COLS)); struct linkedFeatures *lf = linkedFeaturesFromGenePred(tg, gp, TRUE); highlightByGetColor(row, gencodeQuery, highlightColor, lf); return lf; } +static void labelTrackAsFiltered(struct track *tg) +/* add text to track long label to indicate filter is active */ +{ +char *oldLabel = tg->longLabel; +tg->longLabel = catTwoStrings(oldLabel, " (filter activated)"); +freeMem(oldLabel); +} + static void loadGencodeGenePreds(struct track *tg) /* Load genePreds in window info linked feature, with filtering, etc. */ { struct gencodeQuery *gencodeQuery = gencodeQueryConstruct(tg); struct sqlConnection *conn = hAllocConn(database); struct sqlResult *sr = gencodeMakeQuery(conn, gencodeQuery); struct linkedFeatures *lfList = NULL; unsigned highlightColor = getHighlightColor(tg); char **row; while ((row = sqlNextRow(sr)) != NULL) slAddHead(&lfList, loadGencodeGenePred(tg, gencodeQuery, row, highlightColor)); sqlFreeResult(&sr); hFreeConn(&conn); -gencodeQueryFree(&gencodeQuery); if (tg->visibility != tvDense) slSort(&lfList, linkedFeaturesCmpStart); else slReverse(&lfList); tg->items = lfList; genePredAssignConfiguredName(tg); + +if (gencodeQuery->isFiltered) + labelTrackAsFiltered(tg); +gencodeQueryFree(&gencodeQuery); } static char *gencodeGeneName(struct track *tg, void *item) /* Get name to use for Gencode gene item. */ { struct linkedFeatures *lf = item; if (lf->extra != NULL) return lf->extra; else return lf->name; } static void gencodeGeneMethods(struct track *tg) /* Load up custom methods for ENCODE Gencode gene track */ {