src/hg/makeDb/hgTrackDb/hgTrackDb.c 1.62

1.62 2010/02/16 23:37:32 braney
fix the code to check that subGroups have the predefined attributes from the composite. This got broken in Jim's trackDb overhaul.
Index: src/hg/makeDb/hgTrackDb/hgTrackDb.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/makeDb/hgTrackDb/hgTrackDb.c,v
retrieving revision 1.61
retrieving revision 1.62
diff -b -B -U 4 -r1.61 -r1.62
--- src/hg/makeDb/hgTrackDb/hgTrackDb.c	6 Feb 2010 21:43:02 -0000	1.61
+++ src/hg/makeDb/hgTrackDb/hgTrackDb.c	16 Feb 2010 23:37:32 -0000	1.62
@@ -363,8 +363,9 @@
         char subGroupName[256];
         AllocVar(sgd);
 	sgd->compositeTdb = td;
 
+	verbose(3,"getting subgroups for %s\n", td->tableName);
 	for(i=1; ; i++)
 	    {
 	    safef(subGroupName, sizeof(subGroupName), "subGroup%d", i);
 	    char *sgSetting = trackDbSetting(td, subGroupName);
@@ -381,8 +382,9 @@
 		hashAdd(subGroupHash, slPair->name, slPair->val);
 		}
 	    if (sgd->nameHash == NULL)
 		sgd->nameHash = newHash(3);
+	    verbose(3,"   adding group %s\n", sgName);
 	    hashAdd(sgd->nameHash, sgName, subGroupHash);
 	    }
 	hashAdd(compositeHash, td->tableName, sgd);
 	}
@@ -394,8 +396,9 @@
     struct trackDb *td, struct subGroupData *sgd)
 {
 char *subGroups = trackDbSetting(td, "subGroups");
 
+verbose(2, "   checkOne %s %s\n", compositeName, td->tableName);
 if (subGroups && (sgd->nameHash == NULL))
     {
     errAbort("subTrack %s has groups not defined in parent %s\n",
 	     td->tableName, compositeName);
@@ -444,23 +447,27 @@
 static void verifySubTracks(struct trackDb *tdbList, struct hash *compositeHash)
 /* Verify subGroup relelated settings in subtracks, assisted by compositeHash */
 {
 struct trackDb *tdb;
+
 for (tdb = tdbList; tdb != NULL; tdb = tdb->next)
     {
-    struct trackDb *parent = tdb->parent;
-    if (parent && parent->subtracks)  /* Second part of if is to escape superTrack system. */
+    struct slRef *child;
+    struct slRef *childList = trackDbListGetRefsToDescendantLeaves(
+	tdb->subtracks);
+
+    verbose(2,"verifying %s child %p\n",tdb->tableName, childList);
+    for (child = childList; child != NULL; child = child->next)
 	{
+	struct trackDb *childTdb = child->val;
+	verbose(2, "  checking child %s\n",childTdb->tableName);
+
 	/* Look for some ancestor in composite hash and set sgd to it. */
-	struct subGroupData *sgd = NULL;
-	for (;parent != NULL; parent = parent->parent)
-	    {
-	    sgd = hashFindVal(compositeHash, parent->tableName);
-	    if (sgd != NULL)
-	        break;
-	    }
+	struct subGroupData *sgd =  hashFindVal(compositeHash, tdb->tableName);
+	verbose(2, "looking for %s in compositeHash got %p\n", 
+	    tdb->tableName, sgd);
 	assert(sgd != NULL);	
-	checkOneSubGroups(parent->tableName, tdb, sgd);
+	checkOneSubGroups(tdb->tableName, childTdb, sgd);
 	}
     }
 }