src/hg/lib/hui.c 1.222
1.222 2009/07/10 22:16:49 braney
check trackDb for species that should be off rather than depending on the cart having this.
Index: src/hg/lib/hui.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/hui.c,v
retrieving revision 1.221
retrieving revision 1.222
diff -b -B -U 4 -r1.221 -r1.222
--- src/hg/lib/hui.c 7 Jul 2009 01:07:13 -0000 1.221
+++ src/hg/lib/hui.c 10 Jul 2009 22:16:49 -0000 1.222
@@ -4120,12 +4120,12 @@
}
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) */
+static boolean isSpeciesOn(struct cart *cart, struct trackDb *tdb, char *species, char *option, int optionSize, boolean defaultState)
+/* check the cart to see if species is turned off or on (default is defaultState) */
{
-boolean ret = TRUE;
+boolean ret = defaultState;
safef(option, optionSize, "%s.%s", tdb->tableName, species);
/* see if this is a simple multiz (not composite track) */
char *s = cartOptionalString(cart, option);
@@ -4140,9 +4140,9 @@
if (subgroupFind(tdb, "view", &viewString))
{
safef(option, optionSize, "%s.%s.%s",
tdb->parent->tableName, viewString, species);
- ret = cartUsualBoolean(cart, option, TRUE);
+ ret = cartUsualBoolean(cart, option, ret);
}
}
}
@@ -4197,9 +4197,9 @@
for (i = 0; i < speciesCt; i++)
{
AllocVar(wmSpecies);
wmSpecies->name = cloneString(species[i]);
- wmSpecies->on = isSpeciesOn(cart, tdb, wmSpecies->name, option, sizeof option);
+ wmSpecies->on = isSpeciesOn(cart, tdb, wmSpecies->name, option, sizeof option, TRUE);
wmSpecies->group = group;
slAddHead(&wmSpeciesList, wmSpecies);
}
}
@@ -4257,13 +4257,20 @@
char prefix[512];
safef(prefix, sizeof prefix, "%s.", name);
char *defaultOffSpecies = trackDbSetting(tdb, "speciesDefaultOff");
+struct hash *offHash = NULL;
if (defaultOffSpecies)
{
+ offHash = newHash(5);
DEFAULT_BUTTON( "id", "default_pw","cb_maf_","_maf_");
int wordCt = chopLine(defaultOffSpecies, words);
defaultOffSpeciesCnt = wordCt;
+
+ /* build hash of species that should be off */
+ int ii;
+ for(ii=0; ii < wordCt; ii++)
+ hashAdd(offHash, words[ii], NULL);
}
if ((speciesTree != NULL) && ((tree = phyloParseString(speciesTree)) != NULL))
{
@@ -4389,9 +4396,12 @@
}
else
{
puts("<TD>");
- wmSpecies->on = isSpeciesOn(cart, tdb, wmSpecies->name, option, sizeof option);
+ boolean defaultState = TRUE;
+ if (offHash != NULL)
+ defaultState = (hashLookup(offHash, wmSpecies->name) == NULL);
+ wmSpecies->on = isSpeciesOn(cart, tdb, wmSpecies->name, option, sizeof option, defaultState );
cgiMakeCheckBoxWithId(option, wmSpecies->on,id);
label = hOrganism(wmSpecies->name);
if (label == NULL)
label = wmSpecies->name;