75540fb9566270848323a8cc647ddfe66aace1aa max Fri Apr 13 18:11:29 2012 -0700 reverting previous 3 commits, cannot get it to work and fullfill hirams comments, added comments to explain why diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c index bdfffe2..2c405b8 100644 --- src/hg/hgTracks/simpleTracks.c +++ src/hg/hgTracks/simpleTracks.c @@ -12227,31 +12227,31 @@ static void pubsAddExtra(struct track* tg, struct linkedFeatures* lf) /* add authorYear and title to linkedFeatures->extra */ { char *articleTable = trackDbSettingClosestToHome(tg->tdb, "pubsArticleTable"); if(isEmpty(articleTable)) return; if (lf->extra != NULL) return; struct sqlConnection *conn = hAllocConn(database); struct pubsExtra* extra = pubsMakeExtra(articleTable, conn, lf); lf->extra = extra; hFreeConn(&conn); } -static void pubsBlatLoadItems(struct track *tg) +static void pubsLoadKeywordYearItems(struct track *tg) /* load items that fulfill keyword and year filter */ { struct sqlConnection *conn = hAllocConn(database); char *keywords = cartOptionalStringClosestToHome(cart, tg->tdb, FALSE, "pubsKeywords"); char *yearFilter = cartOptionalStringClosestToHome(cart, tg->tdb, FALSE, "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)) { @@ -12300,30 +12300,32 @@ } hFreeConn(&conn); } #define PUBSFILTERNAME "pubsFilterArticleId" static void activatePslTrackIfCgi(struct track *tg) /* the publications hgc creates links back to the browser with * the cgi param pubsFilterArticleId to show only a single type * of feature for the pubsBlatPsl track. * If the parameter was supplied, we save this parameter here * into the cart and activate the track. */ { char *articleId = cgiOptionalString(PUBSFILTERNAME); +//if (articleId==NULL) + //articleId = cartOptionalString(cart, PUBSFILTERNAME); if (articleId!=NULL) { cartSetString(cart, PUBSFILTERNAME, articleId); tdbSetCartVisibility(tg->tdb, cart, hCarefulTrackOpenVis(database, tg->track)); tg->visibility=tvPack; } } char *pubsItemName(struct track *tg, void *item) /* get author/year from extra field */ { struct linkedFeatures *lf = item; pubsAddExtra(tg, lf); @@ -12346,31 +12348,34 @@ pubsAddExtra(tg, lf); struct pubsExtra* extra = lf->extra; char* mouseOver = NULL; if (extra != NULL) mouseOver = extra->mouseOver; else mouseOver = itemName; mapBoxHc(hvg, start, end, x, y, width, height, tg->track, mapItemName, mouseOver); } } static void pubsLoadMarkerItem (struct track *tg) /* copy item names into extra field */ { +//loadSimpleBed(tg); loadSimpleBedAsLinkedFeaturesPerBase(tg); +//tg->items = simpleBedListToLinkedFeatures(tg->items, tg->bedSize, TRUE, FALSE); +//if (! (hashFindVal(tdb->settingsHash, "pubsMarkerTable"))) enum trackVisibility vis = tg->visibility; if (vis == tvDense || vis == tvSquish) return; struct linkedFeatures *lf = NULL; for (lf = tg->items; lf != NULL; lf = lf->next) lf->extra = lf->name; } char *pubsMarkerItemName(struct track *tg, void *item) /* retrieve article count from score field and return.*/ { struct linkedFeatures *lf = item; char newName[64]; safef(newName, sizeof(newName), "%d articles", (int) lf->score); @@ -12389,30 +12394,31 @@ static struct hash* pubsLookupSequences(struct track *tg, struct sqlConnection* conn, char* articleId, bool getSnippet) /* create a hash with a mapping annotId -> snippet or annotId -> shortSeq for an articleId*/ { char query[LARGEBUF]; char *sequenceTable = trackDbRequiredSetting(tg->tdb, "pubsSequenceTable"); char *selectValSql = NULL; if (getSnippet) selectValSql = "replace(replace(snippet, \"\", \"\\n>>> \"), \"\", \" <<<\\n\")"; else selectValSql = "concat(substr(sequence,1,4),\"...\",substr(sequence,-4))"; safef(query, sizeof(query), "SELECT annotId, %s FROM %s WHERE articleId='%s' ", selectValSql, sequenceTable, articleId); struct hash *seqIdHash = sqlQuickHash(conn, query); + //freeMem(sequenceTable); // XX Why does this crash?? return seqIdHash; } static char *pubsArticleDispId(struct track *tg, struct sqlConnection *conn, char* articleId) /* given an articleId, lookup author and year and create label for it */ { char* dispLabel = NULL; char *articleTable = pubsArticleTable(tg); char query[LARGEBUF]; safef(query, sizeof(query), "SELECT firstAuthor, year FROM %s WHERE articleId = '%s'", articleTable, articleId); struct sqlResult *sr = sqlGetResult(conn, query); if (sr!=NULL) { char **row = NULL; @@ -12475,31 +12481,31 @@ } static void pubsBlatPslMethods(struct track *tg) /* a track that shows only the indiv matches for one single article */ { activatePslTrackIfCgi(tg); tg->loadItems = pubsPslLoadItems; tg->itemName = pubsItemName; tg->mapItem = pubsMapItem; } static void pubsBlatMethods(struct track *tg) /* publication blat tracks are bed12+2 tracks of sequences in text, mapped with BLAT */ { bedMethods(tg); -tg->loadItems = pubsBlatLoadItems; +tg->loadItems = pubsLoadKeywordYearItems; tg->itemName = pubsItemName; tg->mapItem = pubsMapItem; } static void pubsMarkerMethods(struct track *tg) /* publication marker tracks are bed5 tracks of genome marker occurences like rsXXXX found in text*/ { bedMethods(tg); tg->bedSize = 5; tg->loadItems = pubsLoadMarkerItem; tg->mapItem = pubsMarkerMapItem; tg->itemName = pubsMarkerItemName; } void fillInFromType(struct track *track, struct trackDb *tdb) @@ -12511,32 +12517,32 @@ 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; - // FIXME: this is in the wrong function, but needs to stay as long as - // registerTrackHandler does not accept wildcards + // FIXME: as long as registerTrackHandler doesn't accept wildcards, + // this probably needs to stay here (it's in the wrong function) if (startsWith("pubs", track->track) && stringIn("Marker", track->track)) pubsMarkerMethods(track); if (startsWith("pubs", track->track) && stringIn("Blat", track->track)) pubsBlatMethods(track); } /* else if (sameWord(type, "bedLogR")) { wordCount++; words[1] = "9"; complexBedMethods(track, tdb, FALSE, wordCount, words); //track->bedSize = 10; } */ else if (sameWord(type, "bigBed")) @@ -12576,30 +12582,34 @@ track->loadItems = loadGenePred; track->colorShades = NULL; if (track->itemAttrTbl != NULL) track->itemColor = genePredItemAttrColor; else if (trackDbSetting(track->tdb, GENEPRED_CLASS_TBL) !=NULL) track->itemColor = genePredItemClassColor; } else if (sameWord(type, "logo")) { logoMethods(track, tdb, wordCount, words); } #endif /* GBROWSE */ else if (sameWord(type, "psl")) { pslMethods(track, tdb, wordCount, words); + + // FIXME: registerTrackHandler doesn't accept wildcards, so this might be the only + // way to get this done in a general way. If this was in loaded with registerTrackHandler + // pslMethods would need the tdb object, which we don't have for these callbacks if (startsWith("pubs", track->track)) pubsBlatPslMethods(track); } else if (sameWord(type, "snake")) { snakeMethods(track, tdb, wordCount, words); } else if (sameWord(type, "chain")) { chainMethods(track, tdb, wordCount, words); } else if (sameWord(type, "netAlign")) { netMethods(track); } @@ -13286,31 +13296,30 @@ registerTrackHandler("encode_tba23EvoFold", rnaSecStrMethods); registerTrackHandler("encodeEvoFold", rnaSecStrMethods); registerTrackHandler("rnafold", rnaSecStrMethods); registerTrackHandler("mcFolds", rnaSecStrMethods); registerTrackHandler("rnaEditFolds", rnaSecStrMethods); registerTrackHandler("altSpliceFolds", rnaSecStrMethods); registerTrackHandler("chimpSimpleDiff", chimpSimpleDiffMethods); registerTrackHandler("tfbsCons", tfbsConsMethods); registerTrackHandler("tfbsConsSites", tfbsConsSitesMethods); registerTrackHandler("pscreen", simpleBedTriangleMethods); registerTrackHandler("dless", dlessMethods); registerTrackHandler("jaxAllele", jaxAlleleMethods); registerTrackHandler("jaxPhenotype", jaxPhenotypeMethods); registerTrackHandler("jaxAlleleLift", jaxAlleleMethods); registerTrackHandler("jaxPhenotypeLift", jaxPhenotypeMethods); - /* ENCODE related */ registerTrackHandlerOnFamily("wgEncodeGencode", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeSangerGencode", gencodeGeneMethods); // one per gencode version, after V7 when it was substantially changed // FIXME: this is hacky, need a way to register based on pattern registerTrackHandlerOnFamily("wgEncodeGencodeV3", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeGencodeV4", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeGencodeV7", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeGencodeV8", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeGencodeV9", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeGencodeV10", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeGencodeV11", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeGencodeV12", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeGencodeV13", gencodeGeneMethods); registerTrackHandlerOnFamily("wgEncodeGencodeV14", gencodeGeneMethods);