8563e44191c6433f3f7a4bc519061f090d15ef44 braney Wed Nov 14 12:54:41 2018 -0800 walk up the tree to find cart variables to use as labelFields diff --git src/hg/lib/bigBedLabel.c src/hg/lib/bigBedLabel.c index a27c874..10894f4 100644 --- src/hg/lib/bigBedLabel.c +++ src/hg/lib/bigBedLabel.c @@ -23,37 +23,47 @@ struct asObject *as = bigBedAsOrDefault(bbi); struct slPair *labelList = buildFieldList(tdb, "labelFields", as); if (labelList == NULL) { // There is no labelFields entry in the trackDb. // If there is a name, use it by default, otherwise no label by default if (bbi->fieldCount > 3) slAddHead(labelColumns, slIntNew(3)); } else if (sameString(labelList->name, "none")) return; // no label else { // what has the user said to use as a label + // we need to check parents as well as this tdb char cartVar[1024]; - safef(cartVar, sizeof cartVar, "%s.label", tdb->track); - struct hashEl *labelEl = cartFindPrefix(cart, cartVar); - struct hash *onHash = newHash(4); + struct hashEl *labelEl = NULL; + struct trackDb *cartTdb = tdb; + while ( labelEl == NULL) + { + safef(cartVar, sizeof cartVar, "%s.label", cartTdb->track); + labelEl = cartFindPrefix(cart, cartVar); + if ((labelEl != NULL) || (cartTdb->parent == NULL)) + break; + + cartTdb = cartTdb->parent; + } // fill hash with fields that should be used for labels // first turn on all the fields that are in defaultLabelFields + struct hash *onHash = newHash(4); struct slPair *defaultLabelList = buildFieldList(tdb, "defaultLabelFields", as); if (defaultLabelList != NULL) { for(; defaultLabelList; defaultLabelList = defaultLabelList->next) hashStore(onHash, defaultLabelList->name); } else // no default list, use first entry in labelFields as default hashStore(onHash, labelList->name); // use cart variables to tweak the default-on hash for(; labelEl; labelEl = labelEl->next) { /* the field name is after the <trackName>.label string */ char *fieldName = &labelEl->name[strlen(cartVar) + 1];