a47364d48ccd5b8ee8cdf7b47b7ba9edcfd66f1f
braney
  Wed Apr 16 10:58:32 2014 -0700
fix a crashing bug in hgCustom if the description field is empty on anassembly hub

diff --git src/hg/lib/wiggleCart.c src/hg/lib/wiggleCart.c
index fdb9b31..f2b45a4 100644
--- src/hg/lib/wiggleCart.c
+++ src/hg/lib/wiggleCart.c
@@ -587,30 +587,82 @@
 		if (differentWord(Default,(char *)hel->val))
 		    {
 		    freeMem(windowingFunction);
 		    windowingFunction = cloneString((char *)hel->val);
 		    }
 	    }
 	}
     }
 
 if (optString)
     *optString = cloneString(windowingFunction);
 
 ret = wiggleWindowingStringToEnum(windowingFunction);
 freeMem(windowingFunction);
 return(ret);
+}
+
+enum wiggleAggregateFunctionEnum wigFetchAggregateFunctionWithCart(struct cart *theCart,
+                                               struct trackDb *tdb, char *name, char **optString)
+/****** windowingFunction - Whiskers by default **************************/
+{
+char *Default = wiggleAggregateFunctionEnumToString(wiggleAggregateTransparent);
+boolean parentLevel = isNameAtParentLevel(tdb,name);
+char *aggregateFunction = NULL;
+enum wiggleAggregateFunctionEnum ret;
+
+aggregateFunction = cloneString(cartOptionalStringClosestToHome(theCart, tdb, parentLevel, 
+                                                                AGGREGATE));
+
+/*      If windowingFunction is a string, it came from the cart, otherwise
+ *      see if it is specified in the trackDb option, finally
+ *	return the default.
+ */
+if (!aggregateFunction)
+    {
+    char * tdbDefault =
+        trackDbSettingClosestToHomeOrDefault(tdb, AGGREGATE, Default);
+
+    freeMem(aggregateFunction);
+    if (differentWord(Default,tdbDefault))
+        aggregateFunction = cloneString(tdbDefault);
+    else
+	{
+	struct hashEl *hel;
+	/*	no aggregateFunction from trackDb, maybe it is in tdb->settings
+	 *	(custom tracks keep settings here)
+	 */
+	aggregateFunction = cloneString(Default);
+	if ((tdb->settings != (char *)NULL) &&
+	    (tdb->settingsHash != (struct hash *)NULL))
+	    {
+	    if ((hel =hashLookup(tdb->settingsHash, AGGREGATE)) !=NULL)
+		if (differentWord(Default,(char *)hel->val))
+		    {
+		    freeMem(aggregateFunction);
+		    aggregateFunction = cloneString((char *)hel->val);
+		    }
+	    }
+	}
+    }
+
+if (optString)
+    *optString = cloneString(aggregateFunction);
+
+ret = wiggleAggregateFunctionStringToEnum(aggregateFunction);
+freeMem(aggregateFunction);
+return(ret);
 }       /*      enum wiggleWindowingEnum wigFetchWindowingFunctionWithCart() */
 
 enum wiggleSmoothingEnum wigFetchSmoothingWindowWithCart(struct cart *theCart, struct trackDb *tdb, 
                                                          char *name, char **optString)
 /****** smoothingWindow - OFF by default **************************/
 {
 char * Default = wiggleSmoothingEnumToString(wiggleSmoothingOff);
 boolean parentLevel = isNameAtParentLevel(tdb,name);
 char * smoothingWindow = NULL;
 enum wiggleSmoothingEnum ret;
 
 smoothingWindow = cloneString(cartOptionalStringClosestToHome(theCart, tdb, parentLevel, 
                                                               SMOOTHINGWINDOW));
 
 if (!smoothingWindow) /* if nothing from the Cart, check trackDb/settings */
@@ -727,29 +779,23 @@
     double *min, double *max,double *tDbMin, double *tDbMax)
 /*****************************************************************************
  *	Min, Max Y viewing limits
  *	Absolute limits are defined by minLimit, maxLimit in the trackDb
  *		default to 0 and 1000 if not present
  *	User requested limits are defined in the cart
  *	Default opening display limits are optionally defined with the
  *		defaultViewLimits declaration from trackDb
  *		or viewLimits from custom tracks
  *		(both identifiers work from either custom or trackDb)
  *****************************************************************************/
 {
 wigFetchMinMaxYWithCart(theCart,tdb,name,min,max,tDbMin,tDbMax,0,NULL);
 }       /*      void wigFetchMinMaxYWithCart()  */
 
-char *wigFetchAggregateValWithCart(struct cart *cart, struct trackDb *tdb)
-/* Return aggregate value for track. */
-{
-return cartOrTdbString(cart, tdb, "aggregate", WIG_AGGREGATE_NONE);
-}
-
 boolean wigIsOverlayTypeAggregate(char *aggregate)
 /* Return TRUE if aggregater type is one of the overlay ones. */
 {
 if (aggregate == NULL)
     return FALSE;
 return differentString(aggregate, WIG_AGGREGATE_NONE);
 }