a9ef87ba7d8b726b83b81adafb931e3e44c15998
braney
  Wed Dec 13 18:54:16 2017 -0800
ongoing work on hgCollection

diff --git src/hg/hgCollection/hgCollection.c src/hg/hgCollection/hgCollection.c
index f20f2d2..e070d5c 100644
--- src/hg/hgCollection/hgCollection.c
+++ src/hg/hgCollection/hgCollection.c
@@ -83,40 +83,43 @@
 {
 char *userString = "";
 char *prefix = "";
 char *viewFunc = NULL;
 char *missingMethod = NULL;
 
 if (user)
     {
     if (tdb->parent && tdb->subtracks) 
         {
         viewFunc = trackDbSetting(tdb, "viewFunc");
         missingMethod = trackDbSetting(tdb, "missingMethod");
         userString = "data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' viewType='view' class='folder'";
         }
     else if (tdb->subtracks)
-        userString = "data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' viewType='track' class='folder'";
+        {
+        viewFunc = trackDbSetting(tdb, "viewFunc");
+        userString = "data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' viewType='collection' class='folder'";
+        }
     else
         userString = "data-jstree='{\\\"icon\\\":\\\"fa fa-minus-square\\\"}' viewType='track'";
     }
 else
     {
     if (tdb->parent && tdb->subtracks) 
         userString = "data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' class='nodrop' viewType='view'";
     else if (tdb->subtracks)
-        userString = "data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' class='nodrop' viewType='track'";
+        userString = "data-jstree='{\\\"icon\\\":\\\"../images/folderC.png\\\"}' class='collection' viewType='track'";
     else
         userString = "data-jstree='{\\\"icon\\\":\\\"fa fa-plus\\\"}' class='nodrop' viewType='track'";
     }
     
     
 #define IMAKECOLOR_32(r,g,b) ( ((unsigned int)b<<0) | ((unsigned int)g << 8) | ((unsigned int)r << 16))
 
 char buffer[1024];
 char *viewFuncString = "";
 if (viewFunc != NULL)
     {
     safef(buffer, sizeof buffer, "viewFunc='%s' ", viewFunc);
     viewFuncString = cloneString(buffer);
     }
 
@@ -467,33 +470,34 @@
 static void outComposite(FILE *f, struct track *collection)
 // output a composite header for user composite
 {
 char *parent = collection->name;
 char *shortLabel = collection->shortLabel;
 char *longLabel = collection->longLabel;
 fprintf(f,"track %s\n\
 shortLabel %s\n\
 compositeTrack on\n\
 autoScale on\n\
 maxHeightPixels 100:30:11 \n\
 aggregate  none\n\
 longLabel %s\n\
 %s on\n\
 color %ld,%ld,%ld \n\
-type wig \n\
+viewFunc %s\n\
+type mathWig\n\
 visibility full\n\n", parent, shortLabel, longLabel, CUSTOM_COMPOSITE_SETTING,
- 0xff& (collection->color >> 16),0xff& (collection->color >> 8),0xff& (collection->color));
+ 0xff& (collection->color >> 16),0xff& (collection->color >> 8),0xff& (collection->color), collection->viewFunc);
 
 }
 
 static void modifyName(struct trackDb *tdb, char *hubName, struct hash  *collectionNameHash)
 /* If this is a new track in the collection we want to make sure
  * it gets a different name than the track in trackDb.
  * If it's a native track, we want to squirrel away the original track name. */
 {
 if ((tdb->grp == NULL) || (hubName == NULL) || differentString(tdb->grp, hubName))
     {
     if (collectionNameHash)
         hashStore(collectionNameHash,  tdb->track);
 
     char *bigDataUrl = trackDbSetting(tdb, "bigDataUrl");
     if (bigDataUrl == NULL)
@@ -538,30 +542,32 @@
 // save our state to the track hub
 {
 char *filename = getHubName(cart, db);
 char *hubName = hubNameFromUrl(filename);
 
 FILE *f = mustOpen(filename, "w");
 chmod(filename, 0666);
 
 struct hash *collectionNameHash = newHash(6);
 
 outHubHeader(f, db);
 struct track *collection;
 struct sqlConnection *conn = hAllocConn(db);
 for(collection = collectionList; collection; collection = collection->next)
     {
+    if (collection->trackList == NULL)  // don't output composites without children
+        continue;
     outComposite(f, collection);
     struct trackDb *tdb;
     struct track *track;
     int priority = 1;
     for (track = collection->trackList; track; track = track->next)
         {
         if (track->viewFunc != NULL)
             {
             priority = outView(f, conn, db, track, collection->name,  nameHash, collectionNameHash, priority, hubName);
             }
         else
             {
             tdb = hashMustFindVal(nameHash, track->name);
             modifyName(tdb, hubName, collectionNameHash);