e469259cebde62bf0bf53f582f7f69ba9a22aebc
braney
  Tue Mar 29 12:28:22 2022 -0700
allow big* tracks with only a bigDataUrl to be used in Extended DNA
coloring page

diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 67fceff..6e4cf88 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -4963,31 +4963,31 @@
     tdb->type = cloneString("psl");
     tdb->longLabel = cloneString(USER_PSL_TRACK_LONGLABEL);
     tdb->visibility = tvFull;
     tdb->priority = 11.0;
     trackDbPolish(tdb);
     return(tdb);
     }
 }
 
 struct trackDb *rFindUnderstandableTrack(char *db, struct trackDb *tdb)
 // If any leaf is usable in getting DNA then that leaf's tdb is returned.
 {
 if (tdb->subtracks != NULL)
     return rFindUnderstandableTrack(db,tdb->subtracks);
 
-if (fbUnderstandTrack(db, tdb->table) && !dnaIgnoreTrack(tdb->table))
+if (fbUnderstandTrack(db, tdb) && !dnaIgnoreTrack(tdb->table))
     return tdb;
 else
     return NULL;
 }
 
 boolean forestHasUnderstandableTrack(char *db, struct trackDb *tdb)
 // TRUE if any leaf is usable in getting DNA.
 {
 return (rFindUnderstandableTrack(db, tdb) != NULL);
 }
 
 
 void doGetDnaExtended1()
 /* Do extended case/color get DNA options. */
 {
@@ -5546,30 +5546,56 @@
 
 safef(buf, sizeof buf, "%s_%s", track, type);
 if (cgiBoolean(buf))
     {
     for (fb = fbList; fb != NULL; fb = fb->next)
 	{
 	s = fb->start - winStart;
 	e = fb->end - winStart;
 	if (isRc)
 	    reverseIntRange(&s, &e, winSize);
 	bitSetRange(bits, s, e - s);
 	}
     }
 }
 
+static struct featureBits *getBigBedFbList(struct trackDb *tdb, char *seqName, int winStart, int winEnd)
+/* Get a list of featureBits structures from a bigBed file. */
+{
+struct lm *lm = lmInit(0);
+char *fileName = bbiNameFromSettingOrTable(tdb, NULL, tdb->table);
+struct bbiFile *bbi =  bigBedFileOpenAlias(fileName, chromAliasFindAliases);
+struct bigBedInterval *bb, *bbList = bigBedIntervalQuery(bbi, seqName, winStart, winEnd, 0, lm);
+char *bedRow[32];
+char startBuf[16], endBuf[16];
+struct featureBits *fbList = NULL, *fb;
+for (bb = bbList; bb != NULL; bb = bb->next)
+    {
+    bigBedIntervalToRow(bb, seqName, startBuf, endBuf, bedRow, ArraySize(bedRow));
+    struct bed *bed = bedLoadN(bedRow, bbi->definedFieldCount);
+    AllocVar(fb);
+    fb->name = bed->name;
+    fb->start = bed->chromStart;
+    fb->end = bed->chromEnd;
+    fb->strand = '+';
+    if (bed->strand[0])
+	fb->strand = bed->strand[0];
+    slAddHead(&fbList, fb);
+    }
+return fbList;
+}
+
 void doGetDna3()
 /* Fetch DNA in extended color format */
 {
 struct dnaSeq *seq;
 struct cfm *cfm;
 int i;
 boolean isRc = cartUsualBoolean(cart, "hgSeq.revComp", FALSE);
 boolean defaultUpper = sameString(cartString(cart, "hgSeq.casing"), "upper");
 int winSize;
 int lineWidth = cartInt(cart, "lineWidth");
 struct rgbColor *colors;
 struct trackDb *tdbList = hTrackDb(database), *tdb;
 struct trackDb *ctdbList = tdbForCustomTracks();
 struct trackDb *utdbList = tdbForUserPsl();
 char *pos = NULL;
@@ -5700,35 +5726,38 @@
 			       TRUE, FALSE);
 	    bedFreeList(&bedList2);
             if (!ct->bedList)
                 bedFreeList(&ctBedList);
 	    }
 	else
             {
             if (tdb->subtracks)
                 {
                 struct slRef *refLeaves = trackDbListGetRefsToDescendantLeaves(tdb->subtracks);
                 struct slRef *refLeaf = NULL;
                 while ((refLeaf = slPopHead(&refLeaves)) != NULL)
                     {
                     struct trackDb *tdbLeaf = refLeaf->val;
                     if (tdbVisLimitedByAncestors(cart,tdbLeaf,TRUE,TRUE) != tvHide
-                    &&  fbUnderstandTrack(database, tdbLeaf->table)
+                    &&  fbUnderstandTrack(database, tdbLeaf)
                     && !dnaIgnoreTrack(tdbLeaf->table))
                         {
-                        struct featureBits *fbLeafList =
-                                    fbGetRange(database, tdbLeaf->table, seqName, winStart, winEnd);
+                        struct featureBits *fbLeafList;
+                        if (startsWith("big", tdbLeaf->type))
+                            fbLeafList = getBigBedFbList(tdbLeaf, seqName, winStart, winEnd);
+                        else
+                            fbLeafList = fbGetRange(database, tdbLeaf->table, seqName, winStart, winEnd);
                         if (fbLeafList != NULL)
                             fbList = slCat(fbList,fbLeafList);
                         }
                     freeMem(refLeaf);
                     }
                 }
             else
                 fbList = fbGetRange(database, tdb->table, seqName, winStart, winEnd);
             }
 
         /* Flip underline/italic/bold bits. */
         getDnaHandleBits(track, "u", uBits, winStart, winEnd, isRc, fbList);
         getDnaHandleBits(track, "b", bBits, winStart, winEnd, isRc, fbList);
 	getDnaHandleBits(track, "i", iBits, winStart, winEnd, isRc, fbList);