904c1c8e951519488cf06099bfab3feb81abb3db
ceisenhart
  Wed Jul 5 14:45:07 2017 -0700
Fixing the table browser bug with bigWig files without tables, refs #19701

diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c
index aa9d1fc..a35e977 100644
--- src/hg/lib/hdb.c
+++ src/hg/lib/hdb.c
@@ -3225,30 +3225,61 @@
 	else if (hti->endField[0] != 0)
 	    hti->type = cloneString("bed 3");
 	else
 	    {
 	    hti->type = cloneString("chromGraph");
 	    safef(hti->endField, sizeof(hti->endField), "%s+1",
 	    	hti->startField);
 	    }
 	}
     else
 	hti->type = NULL;
     }
 return hti;
 }
 
+struct hTableInfo *hFindBigWigTrackInfo(char *db, char *chrom, char *rootName)
+/* Get track information on a big* file that has no table */
+{
+struct sqlConnection *conn;
+conn = hAllocConn(db);
+static struct hash *dbHash = NULL; 
+struct hash *hash;
+struct hTableInfo *hti;
+char fullName[HDB_MAX_TABLE_STRING];
+chrom = hDefaultChrom(db);
+dbHash = newHash(8);
+hash = hashFindVal(dbHash, db);
+if (hash == NULL)
+    {
+    hash = newHash(8);
+    hashAdd(dbHash, db, hash);
+    }
+if ((hti = hashFindVal(hash, rootName)) == NULL)
+    {
+    safecpy(fullName, sizeof(fullName), rootName);
+    safef(fullName, sizeof(fullName), "%s_%s", chrom, rootName);
+    AllocVar(hti);
+    hashAddSaveName(hash, rootName, hti, &hti->rootName);
+    hti->isSplit = FALSE;
+    hFreeConn(&conn);
+    return hti; 
+    }
+hFreeConn(&conn);
+return hti; 
+}
+
 int hTableInfoBedFieldCount(struct hTableInfo *hti)
 /* Return number of BED fields needed to save hti. */
 {
 if (hti->hasBlocks)
     return 12;
 else if (hti->hasCDS)
     return 8;
 else if (hti->strandField[0] != 0)
     return 6;
 else if (hti->scoreField[0] != 0)
     return 5;
 else if (hti->nameField[0] != 0)
     return 4;
 else
     return 3;