ddafb30c2f0d5489f4a56c280f56fabf0b08c161 kate Wed May 4 12:45:18 2016 -0700 Add default visibility feature to hgGene sections. Setting 'visiblity hide' in section.ra will cause section to be collapsed as default. Using this to set microarray sections to default closed when GTEx data is present (perf boost). refs #17244 diff --git src/hg/hgGene/hgGene.c src/hg/hgGene/hgGene.c index a023af9..5b7cfca 100644 --- src/hg/hgGene/hgGene.c +++ src/hg/hgGene/hgGene.c @@ -257,55 +257,55 @@ hPrintf("%s", description); freez(&description); /* print genome position and size */ char buffer[1024]; char *commaPos; char *isGencode = trackDbSetting(tdb, "isGencode"); if (isGencode) hPrintf("Gencode Transcript: %s
\n", curAlignId); exonCnt = curGenePred->exonCount; safef(buffer, sizeof buffer, "%s:%d-%d", curGeneChrom, curGeneStart+1, curGeneEnd); commaPos = addCommasToPos(database, buffer); hPrintf("Transcript (Including UTRs)
\n"); -hPrintf("   Position: %s ",commaPos); +hPrintf("   Position: %s %s ",database, commaPos); sprintLongWithCommas(buffer, (long long)curGeneEnd - curGeneStart); -hPrintf("Size: %s ", buffer); -hPrintf("Total Exon Count: %d ", exonCnt); -hPrintf("Strand: %s
\n",curGenePred->strand); +hPrintf("Size: %s ", buffer); +hPrintf("Total Exon Count: %d ", exonCnt); +hPrintf("Strand: %s
\n",curGenePred->strand); cdsStart = curGenePred->cdsStart; cdsEnd = curGenePred->cdsEnd; /* count CDS exons */ if (cdsStart < cdsEnd) { for (i=0; iexonEnds[i]) && (cdsEnd >= curGenePred->exonStarts[i]) ) cdsExonCnt++; } hPrintf("Coding Region
\n"); safef(buffer, sizeof buffer, "%s:%d-%d", curGeneChrom, cdsStart+1, cdsEnd); commaPos = addCommasToPos(database, buffer); - hPrintf("   Position: %s ",commaPos); + hPrintf("   Position: %s %s ",database, commaPos); sprintLongWithCommas(buffer, (long long)cdsEnd - cdsStart); - hPrintf("Size: %s ", buffer); - hPrintf("Coding Exon Count: %d \n", cdsExonCnt); + hPrintf("Size: %s ", buffer); + hPrintf("Coding Exon Count: %d \n", cdsExonCnt); } fflush(stdout); } char *sectionSetting(struct section *section, char *name) /* Return section setting value if it exists. */ { return hashFindVal(section->settings, name); } char *sectionRequiredSetting(struct section *section, char *name) /* Return section setting. Squawk and die if it doesn't exist. */ { char *res = sectionSetting(section, name); if (res == NULL) @@ -475,76 +475,84 @@ section->name, section->shortLabel); webPrintLinkCellEnd(); } webFinishPartialLinkTable(rowIx, itemPos, maxPerRow); webPrintLinkTableEnd(); } char *sectionCloseVar(char *section) /* Get close variable for given section */ { static char buf[128]; safef(buf, sizeof(buf), "%s%s_%s_%s", hggPrefix, "section", section, "close"); return buf; } +boolean sectionIsOpen(struct section *section) +/* Check cart and ra to see if section is open(-) or closed(+) */ +{ +char *closeVarName = sectionCloseVar(section->name); +char *vis = sectionSetting(section, "visibility"); +int defaultClosed = (vis && sameString(vis, "hide")) ? 1 : 0; +return !(cartUsualInt(cart, closeVarName, defaultClosed)); +} + void printSections(struct section *sectionList, struct sqlConnection *conn, char *geneId) /* Print each section in turn. */ { struct section *section; for (section = sectionList; section != NULL; section = section->next) { - char *closeVarName = sectionCloseVar(section->name); - boolean isOpen = !(cartUsualInt(cart, closeVarName, 0)); + boolean isOpen = sectionIsOpen(section); char *otherState = (isOpen ? "1" : "0"); char *indicator = (isOpen ? "-" : "+"); char *indicatorImg = (isOpen ? "../images/remove.gif" : "../images/add.gif"); struct dyString *header = dyStringNew(0); //keep the following line for future debugging need //printf("
printing %s section\n", section->name);fflush(stdout); dyStringPrintf(header, "", section->name); + char *closeVarName = sectionCloseVar(section->name); dyStringPrintf(header, "\"%s\"  ", geneCgi, cartSidUrlString(cart), closeVarName, otherState, section->name, indicatorImg, indicator); dyStringAppend(header, section->longLabel); webNewSection("%s",header->string); if (isOpen) { long startTime = clock1000(); section->print(section, conn, geneId); section->printTime = clock1000() - startTime; } else { printf("Press \"+\" in the title bar above to open this section."); } dyStringFree(&header); } } void printTiming(struct section *sectionList) /* Print timing for each section, if measureTiming is set */ { if (!measureTiming) return; struct section *section; int total = 0; printf("

section, check time, print time, total
\n"); for (section = sectionList; section != NULL; section = section->next) { - char *closeVarName = sectionCloseVar(section->name); - boolean isOpen = !(cartUsualInt(cart, closeVarName, 0)); + boolean isOpen = sectionIsOpen(section); int sectionTime = section->checkTime + section->printTime; printf("%s, %d, %d, %d %s
\n", section->shortLabel, section->checkTime, section->printTime, sectionTime, isOpen ? "" : "closed"); total += sectionTime; } printf("total = %d\n", total); printf("

"); } void webMain(struct sqlConnection *conn) /* Set up fancy web page with hotlinks bar and * sections. */ { struct section *sectionList = NULL; struct trackDb *tdb = hTrackDbForTrack(database, genomeSetting("knownGene"));