src/hg/lib/trackDbCustom.c 1.85

1.85 2010/04/30 00:23:50 tdreszer
Added a couple of functions to determine the viewName for a view level track or a subtrack
Index: src/hg/lib/trackDbCustom.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/trackDbCustom.c,v
retrieving revision 1.84
retrieving revision 1.85
diff -b -B -U 4 -r1.84 -r1.85
--- src/hg/lib/trackDbCustom.c	13 Apr 2010 19:48:14 -0000	1.84
+++ src/hg/lib/trackDbCustom.c	30 Apr 2010 00:23:50 -0000	1.85
@@ -733,9 +732,8 @@
 {
 if (tdb->parent == NULL)
     return NULL;
 return trackDbSettingClosestToHome(tdb->parent, name);
-return NULL;
 }
 
 
 char *trackDbSettingClosestToHomeOrDefault(struct trackDb *tdb, char *name, char *defaultVal)
@@ -823,8 +821,34 @@
 return hashOptionalVal(tdb->extras, name, defaultVal);
 
 }
 
+boolean tdbIsView(struct trackDb *tdb,char **viewName)
+// Is this tdb a view?  Will fill viewName if provided
+{
+if(tdb && tdb->parent && tdb->subtracks)
+    {
+    char *view = trackDbLocalSetting(tdb, "view");
+    if(viewName)
+        *viewName = view;
+    return (view != NULL);
+    }
+return FALSE;
+}
+
+char *tdbGetViewName(struct trackDb *tdb)
+// returns NULL the view name for view or child track (do not free)
+{
+char *view = NULL;
+if(tdbIsComposite(tdb))
+    return NULL;
+else if(tdbIsCompositeChild(tdb) && subgroupFind(tdb,"view",&view))
+    return view;
+else if(tdbIsView(tdb,&view))
+    return view;
+return NULL;
+}
+
 struct trackDb *trackDbLinkUpGenerations(struct trackDb *tdbList)
 /* Convert a list to a forest - filling in parent and subtrack pointers.
  * The exact topology of the forest is a little complex due to the
  * fact there are two "inheritance" systems - the superTrack system