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 needed for -* hgTracks.js's setTableRowVisibility(). Caller needs to have already creates a . */ -{ -char collapseGroupVar[512]; -safef(collapseGroupVar, sizeof(collapseGroupVar), "%s.section_%s_close", track, section); -boolean isOpen = !cartUsualBoolean(cart, collapseGroupVar, !isOpenDefault); - -printf("\n", - section, track, - section, buttonImage, (isOpen ? "-" : "+"), (isOpen ? "Collapse": "Expand")); -printf("\n", sectionTitle); -printf(". */ -{ -puts(""); -} - 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("
Genomic sequence around %s (%s:%d-%d, %s strand):\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("");
 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 "
 	   "HGDP Selection Browser, "
 	   "and may indicate the allele on the opposite strand from that given above.
\n"); printf("Ancestral Allele: %c
\n", geo.ancestralAllele); printf("Derived Allele: %c
\n", geo.derivedAllele); printf("
\n", - collapseGroupVar, collapseGroupVar, isOpen ? "0" : "1"); -printf("\n", - cgiScriptName(), cartSidUrlString(cart), collapseGroupVar, (isOpen ? "1" : "0"), section); -char *buttonImage = (isOpen ? "../images/remove_sm.gif" : "../images/add_sm.gif"); -printf("\"%s\"" - " %s
", isOpen ? "" : "style='display: none' ", section, 1); -} - -void endCollapsibleSection() -/* End the collapsible
\n"); hgdpGeoFreqTable(&geo); printf("\n"); hgdpGeoImg(&geo); printf("
\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("%s%sLS-SNPChimera\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("\n"); printf("\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("\n"); printLsSnpPdb(conn, pdbId->name, snpId); iCol++; if (iCol == numCols) { printf("\n"); iCol = 0; } } if (iCol != 0) { // fill in last row for (; iCol < numCols; iCol++) printf("\n"); } printf("\n"); printf("
\n"); printf("
\n"); printf("Chimera help\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)