0831c38af9c5724d398fbf12e56853d773b24cb5
angie
  Tue Jan 11 15:19:57 2011 -0800
Made several portions of the SNP controls page collapsible.
diff --git src/hg/hgTrackUi/hgTrackUi.c src/hg/hgTrackUi/hgTrackUi.c
index a2fb590..e796ca9 100644
--- src/hg/hgTrackUi/hgTrackUi.c
+++ src/hg/hgTrackUi/hgTrackUi.c
@@ -151,52 +151,55 @@
 struct slName *genePredTables = hTrackTablesOfType(conn, "genePred%%"), *gt;
 if (genePredTables != NULL)
     {
     struct trackDb *geneTdbList = NULL, *gTdb;
     for (gt = genePredTables;  gt != NULL;  gt = gt->next)
 	{
 	gTdb = hTrackDbForTrack(database, gt->name);
 	if (gTdb && sameString(gTdb->grp, "genes"))
 	    {
 	    if (gTdb->parent)
 		gTdb->priority = (gTdb->parent->priority + gTdb->priority/1000);
 	    slAddHead(&geneTdbList, gTdb);
 	    }
 	}
     slSort(&geneTdbList, trackDbCmp);
+    jsBeginCollapsibleSection(cart, tdb->track, "geneTracks",
+			      "Use Gene Tracks for Functional Annotation", FALSE);
     printf("<BR><B>On details page, show function and coding differences relative to: </B> ");
     char cartVar[256];
     safef(cartVar, sizeof(cartVar), "%s_geneTrack", tdb->track);
     jsMakeCheckboxGroupSetClearButton(cartVar, TRUE);
     jsMakeCheckboxGroupSetClearButton(cartVar, FALSE);
     struct slName *selectedGeneTracks = cartOptionalSlNameList(cart, cartVar);
     if (!cartListVarExists(cart, cartVar))
 	{
 	char *defaultGeneTracks = trackDbSetting(tdb, "defaultGeneTracks");
 	if (isNotEmpty(defaultGeneTracks))
 	    selectedGeneTracks = slNameListFromComma(defaultGeneTracks);
 	}
     int numCols = 4, i;
     int menuSize = slCount(geneTdbList);
     char **values = needMem(menuSize*sizeof(char *));
     char **labels = needMem(menuSize*sizeof(char *));
     for (i = 0, gTdb = geneTdbList;  i < menuSize && gTdb != NULL;  i++, gTdb = gTdb->next)
 	{
 	values[i] = gTdb->track;
 	labels[i] = gTdb->shortLabel;
 	}
     cgiMakeCheckboxGroupWithVals(cartVar, labels, values, menuSize, selectedGeneTracks, numCols);
+    jsEndCollapsibleSection();
     }
 hFreeConn(&conn);
 }
 
 #define SNP125_FILTER_COLUMNS 4
 #define SNP125_DEFAULTS "snp125Defaults"
 
 void snp125PrintFilterControls(char *track, char *attributeLabel, char *attributeVar,
 			       char *labels[], char *values[], int menuSize)
 /* Print two or more rows (attribute name header and row(s) of checkboxes)
  * of a table displaying snp125 attribute filter checkboxes. */
 {
 printf("<TR><TD><B>%s:</B>&nbsp;\n", attributeLabel);
 char cartVar[256];
 safef(cartVar, sizeof(cartVar), "%s.include_%s", track, attributeVar);
@@ -249,93 +252,101 @@
 {
 char autoSubmit[2048];
 char *orthoTable = snp125OrthoTable(tdb, NULL);
 int version = snpVersion(tdb->track);
 jsInit();
 
 if (version < 130)
     snp125ValidArraySize--; // no by-1000genomes
 
 if (isNotEmpty(orthoTable) && hTableExists(database, orthoTable))
     {
     snp125ExtendedNames = cartUsualBoolean(cart, "snp125ExtendedNames", FALSE);
     printf("<BR><B>Include Chimp state and observed human alleles in name: </B>&nbsp;");
     cgiMakeCheckBox("snp125ExtendedNames",snp125ExtendedNames);
     printf("<BR>(If enabled, chimp allele is displayed first, then '>', then human alleles). </B>&nbsp;");
-    printf("<BR>\n");
+    printf("<BR><BR>\n");
     }
 
+// Make wrapper table for collapsible sections:
+puts("<TABLE border=0 cellspacing=0 cellpadding=0>");
+
 snp125OfferGeneTracksForFunction(tdb);
 
 //#*** Need snp125Ui funcs for backwards compat with old cart vars when these have track-specific
 //#*** settings as they should:
 double snp125AvHetCutoff = cartUsualDouble(cart, "snp125AvHetCutoff", SNP125_DEFAULT_MIN_AVHET);
-printf("<BR><B>Minimum <A HREF=\"#AvHet\">Average Heterozygosity</A>:</B>&nbsp;");
+printf("<TR><TD colspan=2><BR><B>Minimum <A HREF=\"#AvHet\">Average Heterozygosity</A>:</B>&nbsp;");
 cgiMakeDoubleVar("snp125AvHetCutoff",snp125AvHetCutoff,6);
+printf("</TD></TR>\n");
 
 int snp125WeightCutoff = cartUsualInt(cart, "snp125WeightCutoff", SNP125_DEFAULT_MAX_WEIGHT);
-printf("<BR><B>Maximum <A HREF=\"#Weight\">Weight</A>:</B>&nbsp;");
+printf("<TR><TD colspan=2><B>Maximum <A HREF=\"#Weight\">Weight</A>:</B>&nbsp;");
 cgiMakeIntVar("snp125WeightCutoff",snp125WeightCutoff,4);
-printf("&nbsp;<I>SNPs with higher weights are less reliable</I><BR><BR>\n");
+printf("&nbsp;<EM>Range: 1, 2 or 3; SNPs with higher weights are less reliable</EM><BR><BR>\n");
+printf("</TD></TR>\n");
 
-printf("<A name=\"filterControls\"><HR>\n"
-       "<B>Filter by Attribute</B><BR>\n"
-       "Check the boxes below to include SNPs with those attributes.  "
+printf("<TR><TD colspan=2><A name=\"filterControls\"></TD></TR>\n");
+jsBeginCollapsibleSection(cart, tdb->track, "filterByAttribute", "Filter by Attribute", FALSE);
+printf("Check the boxes below to include SNPs with those attributes.  "
        "In order to be displayed, a SNP must pass the filter for each "
        "category.  \n"
        "Some assemblies may not contain any SNPs that have some of the "
        "listed attributes.\n"
        "<BR><BR>\n");
 
 printf("<TABLE border=0 cellspacing=0 cellpadding=0>\n");
 if (version <= 127)
     snp125PrintFilterControls(tdb->track, "Location Type", "locType", snp125LocTypeLabels,
 			 snp125LocTypeDataName, snp125LocTypeArraySize);
 snp125PrintFilterControls(tdb->track, "Class", "class", snp125ClassLabels,
 			  snp125ClassDataName, snp125ClassArraySize);
 snp125PrintFilterControls(tdb->track, "Validation", "valid", snp125ValidLabels,
 			  snp125ValidDataName, snp125ValidArraySize);
 int funcArraySize = (version < 130) ? snp125FuncArraySize : (snp125FuncArraySize - 1);
 snp125PrintFilterControls(tdb->track, "Function", "func", snp125FuncLabels,
 			  snp125FuncDataName, funcArraySize);
 snp125PrintFilterControls(tdb->track, "Molecule Type", "molType", snp125MolTypeLabels,
 			  snp125MolTypeDataName, snp125MolTypeArraySize);
-printf("</TABLE><BR>\n");
+printf("</TABLE>\n");
+jsEndCollapsibleSection();
+puts("<TR><TD colspan=2><BR></TD></TR>");
 
 safef(autoSubmit, sizeof(autoSubmit), "onchange=\""
       "document."MAIN_FORM".action = '%s'; %s"
       "document."MAIN_FORM".submit();\"",
       cgiScriptName(), jsSetVerticalPosition(MAIN_FORM));
 cgiContinueHiddenVar("g");
 cgiContinueHiddenVar("c");
 
 /* The actual set defaults button is below, but we need to handle it here: */
 char defaultButton[1024];
 safef(defaultButton, sizeof(defaultButton), "%s_coloring", SNP125_DEFAULTS);
 stripChar(defaultButton, ' ');
 boolean defaultColoring = isNotEmpty(cgiOptionalString(defaultButton));
 if (defaultColoring)
     {
     cartRemove(cart, snp125ColorSourceVarName);
     cartRemoveStringArray(cart, snp125LocTypeStrings, snp125LocTypeArraySize);
     cartRemoveStringArray(cart, snp125ClassStrings, snp125ClassArraySize);
     cartRemoveStringArray(cart, snp125ValidStrings, snp125ValidArraySize);
     cartRemoveStringArray(cart, snp125FuncStrings, funcArraySize);
     cartRemoveStringArray(cart, snp125MolTypeStrings, snp125MolTypeArraySize);
     }
-printf("<A name=\"colorSpec\"><HR>\n");
-printf("<B>SNP Feature for Color Specification:</B>\n");
+printf("<TR><TD colspan=2><A name=\"colorSpec\"></TD></TR>\n");
+jsBeginCollapsibleSection(cart, tdb->track, "colorByAttribute", "Color by Attribute", FALSE);
+printf("<BR><B>SNP Feature for Color Specification:</B>\n");
 char *snp125ColorSourceCart = cartUsualString(cart, snp125ColorSourceVarName,
 					      snp125ColorSourceDefault);
 if (version <= 127)
     cgiMakeDropListFull(snp125ColorSourceVarName, snp125ColorSourceLabels,
 			snp125ColorSourceLabels, snp125ColorSourceArraySize,
 			snp125ColorSourceCart, autoSubmit);
 else
     {
     if (stringArrayIx(snp125ColorSourceCart, snp128ColorSourceLabels,
 		      snp128ColorSourceArraySize) < 0)
 	snp125ColorSourceCart = snp125ColorSourceDefault;
     cgiMakeDropListFull(snp125ColorSourceVarName, snp128ColorSourceLabels,
 			snp128ColorSourceLabels, snp128ColorSourceArraySize,
 			snp125ColorSourceCart, autoSubmit);
     }
@@ -361,31 +372,33 @@
 	snp125PrintColorSpec(snp125LocTypeStrings, snp125LocTypeLabels, snp125LocTypeDefault,
 			     snp125LocTypeArraySize);
     }
 else if (sameString(snp125ColorSourceCart, "Class"))
     snp125PrintColorSpec(snp125ClassStrings, snp125ClassLabels, snp125ClassDefault,
 			 snp125ClassArraySize);
 else if (sameString(snp125ColorSourceCart, "Validation"))
     snp125PrintColorSpec(snp125ValidStrings, snp125ValidLabels, snp125ValidDefault,
 			 snp125ValidArraySize);
 else if (sameString(snp125ColorSourceCart, "Function"))
     snp125PrintColorSpec(snp125FuncStrings, snp125FuncLabels, snp125FuncDefault,
 			 funcArraySize);
 else if (sameString(snp125ColorSourceCart, "Molecule Type"))
     snp125PrintColorSpec(snp125MolTypeStrings, snp125MolTypeLabels, snp125MolTypeDefault,
 			 snp125MolTypeArraySize);
-printf("<HR>\n");
+jsEndCollapsibleSection();
+// End wrapper table for collapsible sections:
+puts("</TABLE>");
 }
 
 void snpUi(struct trackDb *tdb)
 /* Put up UI snp data. */
 {
 int   snpSource  = 0;
 int   snpMolType = 0;
 int   snpClass   = 0;
 int   snpValid   = 0;
 int   snpFunc    = 0;
 int   snpLocType = 0;
 
 /* It would be nice to add a 'reset' button here to reset the snp
  * variables to their defaults.
  * I'd also like to see 'submit' buttons at several places along the