src/hg/lib/hui.c 1.218

1.218 2009/07/06 17:43:08 braney
make sure hgPal is in sync with composite multiz tracks
Index: src/hg/lib/hui.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/hui.c,v
retrieving revision 1.217
retrieving revision 1.218
diff -b -B -U 4 -r1.217 -r1.218
--- src/hg/lib/hui.c	25 Jun 2009 08:43:07 -0000	1.217
+++ src/hg/lib/hui.c	6 Jul 2009 17:43:08 -0000	1.218
@@ -4050,8 +4050,36 @@
     }
 cfgEndBox(boxed);
 }
 
+static boolean isSpeciesOn(struct cart *cart, struct trackDb *tdb, char *species, char *option, int optionSize)
+/* check the cart to see if species is turned off or on (default on) */
+{
+boolean ret = TRUE;
+safef(option, optionSize, "%s.%s", tdb->tableName, species);
+
+/* see if this is a simple multiz (not composite track) */
+char *s = cartOptionalString(cart, option);
+if (s != NULL)
+    ret =  (sameString(s, "on") || atoi(s) > 0);
+else
+    {
+    /* check parent to see if it has these variables */
+    if (tdb->parent != NULL)
+	{
+	char *viewString;
+	if (subgroupFind(tdb, "view", &viewString))
+	    {
+	    safef(option, optionSize, "%s.%s.%s", 
+		tdb->parent->tableName, viewString,  species);
+	    ret = cartUsualBoolean(cart, option, TRUE);
+	    }
+	}
+    }
+
+return ret;
+}
+
 char **wigMafGetSpecies(struct cart *cart, struct trackDb *tdb, char *db, struct wigMafSpecies **list, int *groupCt)
 {
 int speciesCt = 0;
 char *speciesGroup = trackDbSetting(tdb, SPECIES_GROUP_VAR);
@@ -4099,11 +4127,9 @@
     for (i = 0; i < speciesCt; i++)
         {
         AllocVar(wmSpecies);
         wmSpecies->name = cloneString(species[i]);
-    	safef(option, sizeof(option), "%s.%s", tdb->tableName, wmSpecies->name);
-	wmSpecies->on = cartUsualBoolean(cart, option, TRUE);
-	//printf("checking %s and is %d\n",option,wmSpecies->on);
+	wmSpecies->on = isSpeciesOn(cart, tdb, wmSpecies->name, option, sizeof option);
         wmSpecies->group = group;
         slAddHead(&wmSpeciesList, wmSpecies);
         }
     }
@@ -4292,10 +4319,9 @@
         }
     else
     	{
     	puts("<TD>");
-    	safef(option, sizeof(option), "%s.%s", name, wmSpecies->name);
-        wmSpecies->on = cartUsualBoolean(cart, option, checked);
+        wmSpecies->on = isSpeciesOn(cart, tdb, wmSpecies->name, option, sizeof option);
         cgiMakeCheckBoxWithId(option, wmSpecies->on,id);
     	label = hOrganism(wmSpecies->name);
     	if (label == NULL)
 		label = wmSpecies->name;