a691c9d69d5a5163fb82ad949fb408c5329ae69e angie Sun Dec 4 23:47:15 2011 -0800 Feature #3707 (VCF in hgTables): Brooke pointed out the annoyance ofVCF custom track's hyperlinks output setting vis to full when it was already pack. Turns out that the canPack info for all custom tracks was being discarded due to use of hTrackOpenVis which looks for trackDb in database. We usually already have the tdb anyway, so when it's available, look at tdb->canPack and set vis only if the track is currently hidden. Also, while looking into a timeout case that Brooke identified, I noticed that hgTables wasn't calling knetUdc so it was using samtools & tabix's knetfile library instead of our own -- fixed. diff --git src/hg/hgTables/hgTables.c src/hg/hgTables/hgTables.c index a71c6d6..648ccd1 100644 --- src/hg/hgTables/hgTables.c +++ src/hg/hgTables/hgTables.c @@ -18,31 +18,34 @@ #include "trackDb.h" #include "botDelay.h" #include "grp.h" #include "customTrack.h" #include "pipeline.h" #include "hgFind.h" #include "hgTables.h" #include "joiner.h" #include "bedCart.h" #include "hgMaf.h" #include "gvUi.h" #include "wikiTrack.h" #include "trackHub.h" #include "hubConnect.h" #include "hgConfig.h" - +#include "udc.h" +#if ((defined USE_BAM || defined USE_TABIX) && defined KNETFILE_HOOKS) +#include "knetUdc.h" +#endif//def (USE_BAM || USE_TABIX) && KNETFILE_HOOKS void usage() /* Explain usage and exit. */ { errAbort( "hgTables - Get table data associated with tracks and intersect tracks\n" "usage:\n" " hgTables XXX\n" "options:\n" " -xxx=XXX\n" ); } /* Global variables. */ struct cart *cart; /* This holds cgi and other variables between clicks. */ @@ -1441,30 +1444,66 @@ /* Dump out primary table. */ { if (anySubtrackMerge(database, table)) errAbort("Can't do all fields output when subtrack merge is on. " "Please go back and select another output type (BED or custom track is good), or clear the subtrack merge."); if (anyIntersection()) errAbort("Can't do all fields output when intersection is on. " "Please go back and select another output type (BED or custom track is good), or clear the intersection."); textOpen(); if (sameWord(table, WIKI_TRACK_TABLE)) tabOutSelectedFields(wikiDbName(), table, NULL, fullTableFields(wikiDbName(), table)); else tabOutSelectedFields(database, table, NULL, fullTableFields(database, table)); } +void ensureVisibility(char *db, char *table, struct trackDb *tdb) +/* Check track visibility; if hide, print out CGI to set it to pack or full. */ +{ +enum trackVisibility vis = tvHide; +char *cartVis = cartOptionalString(cart, table); +if (isNotEmpty(cartVis)) + vis = hTvFromString(cartVis); +else + { + if (tdb == NULL) + tdb = hTrackDbForTrackAndAncestors(db, table); + if (tdb != NULL) + { + cartVis = cartOptionalString(cart, tdb->track); + if (isNotEmpty(cartVis)) + vis = hTvFromString(cartVis); + else + vis = tdb->visibility; + } + } +if (vis == tvHide) + { + enum trackVisibility openVis = tvFull; + if (tdb != NULL) + { + if (tdb->canPack) + openVis = tvPack; + hPrintf("&%s=%s", table, hStringFromTv(openVis)); + if (!sameString(table, tdb->track)) + hPrintf("&%s_sel=1", table); + } + else + hPrintf("&%s=%s", table, hStringFromTv(openVis)); + } +} + void doOutHyperlinks(char *table, struct sqlConnection *conn) /* Output as genome browser hyperlinks. */ { char *table2 = cartOptionalString(cart, hgtaIntersectTrack); int outputPad = cartUsualInt(cart, hgtaOutputPad,0); struct region *region, *regionList = getRegions(); char posBuf[64]; int count = 0; htmlOpen("Hyperlinks to Genome Browser"); for (region = regionList; region != NULL; region = region->next) { struct lm *lm = lmInit(64*1024); struct bed *bedList, *bed; bedList = cookedBedList(conn, table, region, lm, NULL); @@ -1473,33 +1512,33 @@ char *name; int start = max(0,bed->chromStart+1-outputPad); int end = min(hChromSize(database, bed->chrom),bed->chromEnd+outputPad); safef(posBuf, sizeof(posBuf), "%s:%d-%d", bed->chrom, start, end); /* Construct browser anchor URL with tracks we're looking at open. */ if (doGalaxy()) { char *s, *script = hgTracksName(); s = strstr(script, "cgi-bin"); hPrintf("<A HREF=\"http://%s/%s?db=%s", cgiServerNamePort(), s, database); } else hPrintf("<A HREF=\"%s?db=%s", hgTracksName(), database); hPrintf("&position=%s", posBuf); - hPrintf("&%s=%s", table, hTrackOpenVis(database, table)); + ensureVisibility(database, table, curTrack); if (table2 != NULL) - hPrintf("&%s=%s", table2, hTrackOpenVis(database, table2)); + ensureVisibility(database, table2, NULL); hPrintf("\" TARGET=_blank>"); name = bed->name; if (bed->name == NULL) name = posBuf; if (sameString(name, posBuf)) hPrintf("%s", posBuf); else { char *tmp = htmlEncode(name); hPrintf("%s at %s", tmp, posBuf); freeMem(tmp); } hPrintf("</A><BR>\n"); ++count; } @@ -1894,30 +1933,36 @@ { char *clade = NULL; oldVars = hashNew(10); /* Sometimes we output HTML and sometimes plain text; let each outputter * take care of headers instead of using a fixed cart*Shell(). */ cart = cartAndCookieNoContent(hUserCookie(), excludeVars, oldVars); /* Set up global variables. */ allJoiner = joinerRead("all.joiner"); getDbGenomeClade(cart, &database, &genome, &clade, oldVars); freezeName = hFreezeFromDb(database); setUdcCacheDir(); +int timeout = cartUsualInt(cart, "udcTimeout", 300); +if (udcCacheTimeout() < timeout) + udcSetCacheTimeout(timeout); +#if ((defined USE_BAM || defined USE_TABIX) && defined KNETFILE_HOOKS) +knetUdcInstall(); +#endif//def (USE_BAM || USE_TABIX) && KNETFILE_HOOKS if (lookupPosition()) { /* Init track and group lists and figure out what page to put up. */ initGroupsTracksTables(); if (cartUsualBoolean(cart, hgtaDoGreatOutput, FALSE)) doGetGreatOutput(dispatch); else dispatch(); } /* Save variables. */ cartCheckout(&cart); }