358c7f3665dca67c180f6b22ae11f6bf33d201ae angie Tue Jan 11 10:45:13 2011 -0800 Moved hgc.c's {begin,end}CollapsibleSection to jsHelper.c:js{Begin,End}CollapsibleSection so I can use in hgTrackUi. diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c index 730cced..54ebb4b 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -903,59 +903,30 @@ /* Wrapper to call printCustomUrlWithLabel using the url setting in trackDb */ { char urlSetting[10]; safef(urlSetting, sizeof(urlSetting), "url"); printCustomUrlWithLabel(tdb, itemName, itemName, urlSetting, encode); } void printOtherCustomUrl(struct trackDb *tdb, char *itemName, char* urlSetting, boolean encode) /* Wrapper to call printCustomUrlWithLabel to use another url setting other than url in trackDb e.g. url2, this allows the use of multiple urls for a track to be set in trackDb. */ { printCustomUrlWithLabel(tdb, itemName, itemName, urlSetting, encode); } -void beginCollapsibleSection(char *track, char *section, char *sectionTitle, boolean isOpenDefault) -/* Make the hidden input, collapse/expand button and <TR id=...> needed for -* hgTracks.js's setTableRowVisibility(). Caller needs to have already creates a <TABLE>. */ -{ -char collapseGroupVar[512]; -safef(collapseGroupVar, sizeof(collapseGroupVar), "%s.section_%s_close", track, section); -boolean isOpen = !cartUsualBoolean(cart, collapseGroupVar, !isOpenDefault); - -printf("<TR><TD><input type='hidden' name=\"%s\" id=\"%s\" value=\"%s\">\n", - collapseGroupVar, collapseGroupVar, isOpen ? "0" : "1"); -printf("<A HREF=\"%s?%s&%s=%s#%sGroup\" class='bigBlue'>\n", - cgiScriptName(), cartSidUrlString(cart), collapseGroupVar, (isOpen ? "1" : "0"), section); -char *buttonImage = (isOpen ? "../images/remove_sm.gif" : "../images/add_sm.gif"); -printf("<IMG height='18' width='18' " - "onclick=\"return setTableRowVisibility(this, '%s', '%s.section', 'section', true);\" " - "id=\"%s_button\" src=\"%s\" alt=\"%s\" title='%s this section' class='bigBlue'>" - "</A></TD>\n", - section, track, - section, buttonImage, (isOpen ? "-" : "+"), (isOpen ? "Collapse": "Expand")); -printf("<TD><FONT SIZE=4><B> %s</B></FONT></TD></TR>\n", sectionTitle); -printf("<TR %sid='%s-%d'><TD colspan=2>", isOpen ? "" : "style='display: none' ", section, 1); -} - -void endCollapsibleSection() -/* End the collapsible <TR id=...>. */ -{ -puts("</TD></TR>"); -} - void genericSampleClick(struct sqlConnection *conn, struct trackDb *tdb, char *item, int start, int smpSize) /* Handle click in generic sample (wiggle) track. */ { char table[64]; boolean hasBin; struct sample *smp; char query[512]; struct sqlResult *sr; char **row; boolean firstTime = TRUE; hFindSplitTable(database, seqName, tdb->table, table, &hasBin); sprintf(query, "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d", table, item, seqName, start); @@ -14363,31 +14334,31 @@ end = chromSize; } /* do the lookup */ seqNib = hChromSeqMixed(database, snp->chrom, start, end); if (seqNib == NULL) errAbort("Couldn't get genomic sequence around %s (%s:%d-%d)", snp->name, snp->chrom, start+1, end); if (isRc) reverseComplement(seqNib->dna, seqNib->size); char betterName[512]; safef(betterName, sizeof(betterName), "%s %s:%d-%d", database, seqName, start+1, end); seqNib->name = cloneString(betterName); -beginCollapsibleSection(tdb->track, "realignment", +jsBeginCollapsibleSection(cart, tdb->track, "realignment", "Re-alignment of the SNP's flanking sequences to the genomic sequence", FALSE); printf("Note: this alignment was computed by UCSC and may not be identical to " "NCBI's alignment used to map the SNP.\n"); printf("<PRE><B>Genomic sequence around %s (%s:%d-%d, %s strand):</B>\n", snp->name, snp->chrom, start+1, end, isRc ? "reverse complemented for -" : "+"); int snpWidth = snp->chromEnd - snp->chromStart; writeSeqWithBreaks(stdout, seqNib->dna, genoLen5, lineWidth); printf("<B>"); if (snp->chromEnd > snp->chromStart) writeSeqWithBreaks(stdout, seqNib->dna + genoLen5, snpWidth, lineWidth); else printf("-\n"); @@ -14419,31 +14390,31 @@ /* create seqDbSnp */ dyStringAppend(seqDbSnpTemp, leftFlank); dyStringAppend(seqDbSnpTemp, variation); dyStringAppend(seqDbSnpTemp, rightFlank); seqDbSnp = newDnaSeq(seqDbSnpTemp->string, strlen(seqDbSnpTemp->string), snp->name); if (seqDbSnp == NULL) { warn("Couldn't get sequences"); return; } seqDbSnp->size = strlen(seqDbSnp->dna); generateAlignment(seqNib, seqDbSnp, lineWidth, start, skipCount, genoLen5, genoLen5 + snpWidth, isRc); -endCollapsibleSection(); +jsEndCollapsibleSection(); } void doSnp(struct trackDb *tdb, char *itemName) /* Process SNP details. */ { char *snpTable = tdb->table; struct snp snp; int start = cartInt(cart, "o"); struct sqlConnection *conn = hAllocConn(database); struct sqlResult *sr; char **row; char query[256]; int rowOffset=hOffsetPastBin(database, seqName, snpTable); int firstOne=1; char *exception=0; @@ -16025,42 +15996,43 @@ { char *hgdpGeoTable = "hgdpGeo"; // make this a trackDb setting if (!hTableExists(database, hgdpGeoTable)) return; struct sqlResult *sr; char **row; char query[512]; safef(query, sizeof(query), "select * from %s where name = '%s' and chrom = '%s' and chromStart = %d", hgdpGeoTable, itemName, seqName, start); sr = sqlGetResult(conn, query); if ((row = sqlNextRow(sr)) != NULL) { struct hgdpGeo geo; hgdpGeoStaticLoad(row+1, &geo); - beginCollapsibleSection(tdb->track, "hgdpGeo", "Human Genome Diversity Project SNP", FALSE); + jsBeginCollapsibleSection(cart, tdb->track, "hgdpGeo", "Human Genome Diversity Project SNP", + FALSE); printf("Note: These annotations are taken directly from the " "<A HREF=\"http://hgdp.uchicago.edu/\" TARGET=_BLANK>HGDP Selection Browser</A>, " "and may indicate the allele on the opposite strand from that given above.<BR>\n"); printf("<B>Ancestral Allele:</B> %c<BR>\n", geo.ancestralAllele); printf("<B>Derived Allele:</B> %c<BR>\n", geo.derivedAllele); printf("<TABLE><TR><TD>\n"); hgdpGeoFreqTable(&geo); printf("</TD><TD valign=top>\n"); hgdpGeoImg(&geo); printf("</TD></TR></TABLE>\n"); - endCollapsibleSection(); + jsEndCollapsibleSection(); } sqlFreeResult(&sr); } void checkForHapmap(struct sqlConnection *conn, struct trackDb *tdb, char *itemName) { boolean isPhaseIII = sameString(trackDbSettingOrDefault(tdb, "hapmapPhase", "II"), "III"); boolean gotHapMap = FALSE; char query[512]; if (!isPhaseIII && sqlTableExists(conn, "hapmapAllelesSummary")) { safef(query, sizeof(query), "select count(*) from hapmapAllelesSummary where name = '%s'", itemName); if (sqlQuickNum(conn, query) > 0) gotHapMap = TRUE; @@ -16125,61 +16097,61 @@ /* generate LS-SNP and chimera links for a PDB id */ { char *lsSnpUrl = lsSnpPdbGetUrlPdbSnp(pdbId, snpId); struct tempName chimerax; lsSnpPdbChimeraSnpAnn(conn, pdbId, snpId, &chimerax); printf("<TD>%s<TD>%s<TD><A HREF=\"%s\" target=_blank>LS-SNP</A><td class=\"hgcLsSnpSep\"><A HREF=\"%s\">Chimera</A>\n", pdbId, lsSnpPdbChimeraGetStructType(conn, pdbId), lsSnpUrl, chimerax.forHtml); freeMem(lsSnpUrl); } static void printLsSnpMappings(struct sqlConnection *conn, struct slName *pdbIds, char *snpTrack, char *snpId) /* Print lsSnp mappings. */ { -beginCollapsibleSection(snpTrack, "lsSnp", "Mappings to PDB protein structures", FALSE); +jsBeginCollapsibleSection(cart, snpTrack, "lsSnp", "Mappings to PDB protein structures", FALSE); printf("<TABLE class=\"hgcLsSnp\">\n"); printf("<TBODY>\n"); int numPdbs = slCount(pdbIds); // limit column groups if just one row int numCols = (numPdbs < 3) ? numPdbs : 3; int iCol = 0; struct slName *pdbId; for (pdbId = pdbIds; pdbId != NULL; pdbId = pdbId->next) { if (iCol == 0) printf("<TR>\n"); printLsSnpPdb(conn, pdbId->name, snpId); iCol++; if (iCol == numCols) { printf("</TR>\n"); iCol = 0; } } if (iCol != 0) { // fill in last row for (; iCol < numCols; iCol++) printf("<TD colspan=4 class=\"hgcLsSnpSep\">\n"); printf("</TR>\n"); } printf("</TBODY>\n"); printf("</TABLE>\n"); printf("<A href=\"../goldenPath/help/chimera.html\" TARGET=_blank>Chimera help</A>\n"); -endCollapsibleSection(); +jsEndCollapsibleSection(); } static void checkForLsSnpMappings(struct sqlConnection *conn, char *snpTrack, char *snpId) /* check if this SNP is mapped to any protein by LS-SNP, and if so print * the information. */ { struct slName *pdbIds = lsSnpPdbChimeraGetSnpPdbs(conn, snpId); if (pdbIds != NULL) { printLsSnpMappings(conn, pdbIds, snpTrack, snpId); slFreeList(&pdbIds); } } void doSnpWithVersion(struct trackDb *tdb, char *itemName, int version)