7f33fb42a1fb58a02a3f798e56332e5beac65133 max Sat Mar 17 13:21:09 2012 -0700 renaming all publications tracks tables to pubsXXXX diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c index 8ea716b..1615972 100644 --- src/hg/hgTracks/simpleTracks.c +++ src/hg/hgTracks/simpleTracks.c @@ -12128,72 +12128,72 @@ // end stuff copied from hgTracks.c enum trackVisibility trackVis = track->tdb->visibility; if (s != NULL) trackVis = hTvFromString(s); if (trackVis != tvHide) { track->visibility = tvDense; track->limitedVis = tvDense; track->limitedVisSet = TRUE; } track->nextItemButtonable = track->nextExonButtonable = FALSE; track->nextPrevItem = NULL; track->nextPrevExon = NULL; } -char* t2gArticleTable(struct track *tg) -/* return the name of the t2g articleTable, either +char* pubsArticleTable(struct track *tg) +/* return the name of the pubs articleTable, either * the value from the trackDb statement 'articleTable' * or the default value: <trackName>Article */ { -char *articleTable = trackDbSetting(tg->tdb, "t2gArticleTable"); +char *articleTable = trackDbSetting(tg->tdb, "pubsArticleTable"); if (articleTable == NULL) { char buf[256]; safef(buf, sizeof(buf), "%sArticle", tg->track); articleTable = cloneString(buf); } return articleTable; } static char *makeMysqlMatchStr(char *str) { // return a string with all words prefixed with a '+' to force a boolean AND query; // we also strip leading/trailing spaces. char *matchStr = needMem(strlen(str) * 2 + 1); int i = 0; for(;*str && isspace(*str);str++) ; while(*str) { matchStr[i++] = '+'; for(; *str && !isspace(*str);str++) matchStr[i++] = *str; for(;*str && isspace(*str);str++) ; } matchStr[i++] = 0; return matchStr; } -static void t2gLoadItems(struct track *tg) -/* apply filter to t2g items */ +static void pubsLoadItems(struct track *tg) +/* apply filter to pubs items */ { struct sqlConnection *conn = hAllocConn(database); -char *keywords = cartOptionalString(cart, "t2gKeywords"); -char *yearFilter = cartOptionalString(cart, "t2gYear"); -char *articleTable = t2gArticleTable(tg); +char *keywords = cartOptionalString(cart, "pubsKeywords"); +char *yearFilter = cartOptionalString(cart, "pubsYear"); +char *articleTable = pubsArticleTable(tg); if(yearFilter != NULL && sameWord(yearFilter, "anytime")) yearFilter = NULL; if(isNotEmpty(keywords)) keywords = makeMysqlMatchStr(sqlEscapeString(keywords)); if(isEmpty(yearFilter) && isEmpty(keywords)) loadGappedBed(tg); else { char extra[2048], yearWhere[256], keywordsWhere[1024], prefix[256]; char **row; int rowOffset; struct linkedFeatures *lfList = NULL; struct trackDb *tdb = tg->tdb; int scoreMin = atoi(trackDbSettingClosestToHomeOrDefault(tdb, "scoreMin", "0")); int scoreMax = atoi(trackDbSettingClosestToHomeOrDefault(tdb, "scoreMax", "1000")); @@ -12213,123 +12213,123 @@ struct sqlResult *sr = hExtendedRangeQuery(conn, tg->table, chromName, winStart, winEnd, extra, FALSE, NULL, &rowOffset); while ((row = sqlNextRow(sr)) != NULL) { struct bed *bed = bedLoad12(row+rowOffset); slAddHead(&lfList, bedMungToLinkedFeatures(&bed, tdb, 12, scoreMin, scoreMax, useItemRgb)); } sqlFreeResult(&sr); slReverse(&lfList); slSort(&lfList, linkedFeaturesCmp); tg->items = lfList; } hFreeConn(&conn); } -static void t2gMapItem(struct track *tg, struct hvGfx *hvg, void *item, +static void pubsMapItem(struct track *tg, struct hvGfx *hvg, void *item, char *itemName, char *mapItemName, int start, int end, int x, int y, int width, int height) -/* create mouse overs with titles for t2g bed features */ +/* create mouse overs with titles for pubs bed features */ { if(!theImgBox || tg->limitedVis != tvDense || !tdbIsCompositeChild(tg->tdb)) { char query[1024], title[4096]; char *label = NULL; - char *articleTable = t2gArticleTable(tg); + char *articleTable = pubsArticleTable(tg); if(!isEmpty(articleTable)) { struct sqlConnection *conn = hAllocConn(database); safef(query, sizeof(query), "select title from %s where displayId = '%s'", articleTable, mapItemName); label = sqlQuickQuery(conn, query, title, sizeof(title)); hFreeConn(&conn); } if(isEmpty(label)) label = mapItemName; mapBoxHc(hvg, start, end, x, y, width, height, tg->track, mapItemName, label); } } -char* t2gLastMarkerName; +char* pubsLastMarkerName; -char *t2gMarkerItemName(struct track *tg, void *item) +char *pubsMarkerItemName(struct track *tg, void *item) /* retrieve article count from extra field, and return * side effect: save original name in global var for mapItem * Is this too hacky? No idea where I could save the original name otherwise... */ { struct bed *bed = item; char query[256]; char *escName = sqlEscapeString(bed->name); safef(query, sizeof(query), "select matchCount from %s where name = '%s'", tg->table, escName); char *articleCount = NULL; struct sqlConnection *conn = hAllocConn(database); articleCount = sqlQuickString(conn, query); char* newName = catTwoStrings(articleCount, " articles"); freeMem(articleCount); hFreeConn(&conn); -t2gLastMarkerName = bed->name; +pubsLastMarkerName = bed->name; return newName; } -static void t2gMarkerMapItem(struct track *tg, struct hvGfx *hvg, void *item, +static void pubsMarkerMapItem(struct track *tg, struct hvGfx *hvg, void *item, char *itemName, char *mapItemName, int start, int end, int x, int y, int width, int height) /* use previously saved itemName for the mouseOver */ { genericMapItem(tg, hvg, item, - t2gLastMarkerName, mapItemName, start, end, + pubsLastMarkerName, mapItemName, start, end, x, y, width, height); } -static void t2gMethods(struct track *tg) +static void pubsMethods(struct track *tg) { -if (startsWith("t2gMarker", tg->table)) +if (startsWith("pubsMarker", tg->table)) { - tg->mapItem = t2gMarkerMapItem; - tg->itemName = t2gMarkerItemName; + tg->mapItem = pubsMarkerMapItem; + tg->itemName = pubsMarkerItemName; } else { - tg->loadItems = t2gLoadItems; - tg->mapItem = t2gMapItem; + tg->loadItems = pubsLoadItems; + tg->mapItem = pubsMapItem; } } void fillInFromType(struct track *track, struct trackDb *tdb) /* Fill in various function pointers in track from type field of tdb. */ { char *typeLine = tdb->type, *words[8], *type; int wordCount; if (typeLine == NULL) return; wordCount = chopLine(cloneString(typeLine), words); if (wordCount <= 0) return; type = words[0]; #ifndef GBROWSE if (sameWord(type, "bed")) { complexBedMethods(track, tdb, FALSE, wordCount, words); /* bed.h includes genePred.h so should be able to use these trackDb settings. */ if (trackDbSetting(track->tdb, GENEPRED_CLASS_TBL) !=NULL) track->itemColor = genePredItemClassColor; - if (startsWith("t2g", track->table) ) - t2gMethods(track); + if (startsWith("pubs", track->table) ) + pubsMethods(track); } /* else if (sameWord(type, "bedLogR")) { wordCount++; words[1] = "9"; complexBedMethods(track, tdb, FALSE, wordCount, words); //track->bedSize = 10; } */ else if (sameWord(type, "bigBed")) { bigBedMethods(track, tdb, wordCount, words); if (trackShouldUseAjaxRetrieval(track)) track->loadItems = dontLoadItems;