2ea6e837990eb39bc317f2b1aacacfe4ff77a7ce
hiram
Tue Jun 11 18:00:29 2024 -0700
correctly check boolean CGI variable and ouput the tracks in a single file track hub while in html mode no redmine
diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c
index 95f479c..af5d541 100644
--- src/hg/hubApi/hubApi.c
+++ src/hg/hubApi/hubApi.c
@@ -384,30 +384,31 @@
* name of largest chrom and its size
*/
{
int retVal = 0;
*chromCount = 0;
*itemCount = 0;
struct errCatch *errCatch = errCatchNew();
if (errCatchStart(errCatch))
{
if (startsWithWord("bigNarrowPeak", type)
|| startsWithWord("bigBed", type)
|| startsWithWord("bigGenePred", type)
|| startsWithWord("bigPsl", type)
|| startsWithWord("bigChain", type)
|| startsWithWord("bigMaf", type)
+ || startsWithWord("bigRmsk", type)
|| startsWithWord("bigBarChart", type)
|| startsWithWord("bigInteract", type))
{
struct bbiFile *bbi = NULL;
bbi = bigBedFileOpen(bigDataUrl);
struct bbiChromInfo *chromList = bbiChromList(bbi);
*chromCount = slCount(chromList);
*itemCount = bigBedItemCount(bbi);
bbiLargestChrom(chromList, chromName, chromSize);
bbiChromInfoFreeList(&chromList);
bbiFileClose(&bbi);
}
else if (startsWithWord("bigWig", type))
{
struct bbiFile *bwf = bigWigFileOpen(bigDataUrl);
@@ -471,31 +472,31 @@
}
errCatchEnd(errCatch);
if (errCatch->gotError)
{
retVal = 1;
dyStringPrintf(errors, "%s", errCatch->message->string);
}
errCatchFree(&errCatch);
return retVal;
} /* static int bbiBriefMeasure() */
static void hubSubTracks(struct trackHub *hub, char *db, struct trackDb *tdb,
struct hash *countTracks, long chromCount, long itemCount,
char *chromName, unsigned chromSize, char *genome, char *errorString)
-/* tdb has subtracks, show only subTracks, no details */
+/* tdb has subtracks, show only subTracks, no details, this is RECURSIVE */
{
hPrintf("
\n");
if (debug)
{
hPrintf(" - subtracks for '%s' db: '%s'
\n", tdb->track, db);
hPrintf(" - chrom: '%s' size: %u
\n", chromName, chromSize);
}
if (tdb->subtracks)
{
struct trackDb *tdbEl = NULL;
for (tdbEl = tdb->subtracks; tdbEl; tdbEl = tdbEl->next)
{
boolean compositeContainer = tdbIsComposite(tdbEl);
boolean compositeView = tdbIsCompositeView(tdbEl);
if (! (compositeContainer || compositeView) )
@@ -572,30 +573,31 @@
if (sameWord("tableBrowser", hel->name)
&& startsWithWord("off", (char*)hel->val))
hPrintf(" - protectedData: 'true'
\n");
else if (protectedData && sameWord("bigDataUrl", hel->name))
hPrintf(" - bigDataUrl: <protected data>
\n");
else if (isEmpty((char *)hel->val))
hPrintf(" - %s: <empty>
\n", hel->name);
else
hPrintf(" - %s: '%s'
\n", hel->name, (char *)hel->val);
}
if (tdb->subtracks)
{
struct trackDb *tdbEl = NULL;
if (debug)
hPrintf(" - has %d subtrack(s)
\n", slCount(tdb->subtracks));
+
for (tdbEl = tdb->subtracks; tdbEl; tdbEl = tdbEl->next)
{
hPrintf("- subtrack: %s of parent: %s : type: '%s' (TBD: sample data)
\n", tdbEl->track, tdbEl->parent->track, tdbEl->type);
hashCountTrack(tdbEl, countTracks);
trackSettings(db, tdbEl, countTracks);
}
}
hPrintf("
\n");
}
static void hubCountOneTdb(struct trackHub *hub, char *db, struct trackDb *tdb,
char *bigDataIndex, struct hash *countTracks, char *chromName,
unsigned chromSize, char *genome)
{
char *bigDataUrl = trackDbSetting(tdb, "bigDataUrl");
@@ -820,33 +822,31 @@
hPrintf(" \n");
struct hashEl *hel;
struct hashCookie hc = hashFirst(genome->settingsHash);
while ((hel = hashNext(&hc)) != NULL)
{
if (sameWord("description", hel->name) ||
sameWord("defaultPos", hel->name) ||
sameWord("organism", hel->name) ||
sameWord("groups", hel->name) ||
sameWord("twoBitPath", hel->name) ||
sameWord("genome", hel->name)
)
continue; // already output in header
if (sameWord("trackDb", hel->name)) /* examine the trackDb structure */
- {
hubTrackList(hub, tdb, genome);
- }
else
hPrintf(" - %s: %s
\n", hel->name, (char *)hel->val);
if (timeOutReached())
break;
}
hPrintf("
\n");
}
static unsigned largestChromInfo(struct chromInfo *ci, char **chromName)
/* find largest chrom in this chromInfo, return name and size */
{
unsigned size = 0;
char *name = NULL;
struct chromInfo *el;
for (el = ci; el; el = el->next)
@@ -904,30 +904,32 @@
char sizeString[64];
sprintLongWithCommas(sizeString, chromSize);
hPrintf("Sequence count %d, largest: %s at %s bases\n", slCount(ci), chromName, sizeString);
safef(urlReference, sizeof(urlReference), " JSON example sequence output: %s:%u-%u", urlPrefix, hubTop->url, genome->name, chromName, chromSize/4, (chromSize/4)+128, chromName, chromSize/4, (chromSize/4)+128);
hPrintf("%s\n", urlReference);
}
safef(urlReference, sizeof(urlReference), " JSON example list tracks output", urlPrefix, hubTop->url, genome->name, trackLeavesOnly ? ";trackLeavesOnly=1" : "");
hPrintf("%s\n", urlReference);
hubInfo("organism", genome->organism);
hubInfo("name", genome->name);
hubInfo("description", genome->description);
hubInfo("groups", genome->groups);
hubInfo("defaultPos", genome->defaultPos);
hubInfo("trackDbFile", genome->trackDbFile);
hubAssemblySettings(hubTop, genome);
+ struct trackDb *tdbList = obtainTdb(genome, NULL);
+ hubTrackList(hubTop, tdbList, genome);
if (measureTiming)
{
long thisTime = clock1000();
hPrintf("processing time %s: %ld millis\n", genome->name, thisTime - lastTime);
hPrintf("
\n");
}
if (timeOutReached())
break;
}
if (trackCounter->elCount)
{
hPrintf(" total genome assembly count: %ld\n", totalAssemblyCount);
hPrintf(" %ld total tracks counted, %d different track types:\n", totalTracks, trackCounter->elCount);
hPrintf(" \n");
struct hashEl *hel, *helList = hashElListHash(trackCounter);
@@ -1397,30 +1399,32 @@
char *otherHubUrl = cartUsualString(cart, "urlHub", "");
char *hubDropDown = cartUsualString(cart, "publicHubs", defaultHub);
char *urlDropDown = urlFromShortLabel(hubDropDown);
char *ucscDb = cartUsualString(cart, "ucscGenome", defaultDb);
char *selectRadio = cartUsualString(cart, RADIO_GROUP, RADIO_PUBHUB);
char *urlInput = urlDropDown; /* assume public hub */
if (debug)
{
hPrintf("\n");
hPrintf("- otherHubUrl: '%s'
\n", otherHubUrl);
hPrintf("- hubDropDown: '%s'
\n", hubDropDown);
hPrintf("- urlDropDown: '%s'
\n", urlDropDown);
hPrintf("- ucscDb: '%s'
\n", ucscDb);
hPrintf("- urlInput: '%s'
\n", urlInput);
+ hPrintf("- trackLeavesOnly: '%s'
\n", trackLeavesOnly ? "TRUE" : "FALSE");
+ hPrintf("- jsonOutputArrays: '%s'
\n", jsonOutputArrays ? "TRUE" : "FALSE");
hPrintf("
\n");
}
if (isEmpty(otherHubUrl))
otherHubUrl = urlInput;
if (sameWord(RADIO_OTHERHUB, selectRadio)) /* requested other hub URL */
urlInput = otherHubUrl;
long lastTime = clock1000();
struct trackHub *hub = errCatchTrackHubOpen(urlInput);
if (measureTiming)
{
long thisTime = clock1000();
hPrintf("hub open time: %ld millis
\n", thisTime - lastTime);
}
@@ -1486,42 +1490,42 @@
for ( ; el; el = el->next)
{
hashIncInt(varCounter, el->name);
}
struct hashCookie cookie = hashFirst(varCounter);
struct hashEl *hel = NULL;
for ( hel = hashNext(&cookie); hel; hel = hashNext(&cookie))
{
if (ptToInt(hel->val) > 1)
apiErrAbort(err400, err400Msg, "parameter '%s' found %d times, only one instance allowed", hel->name, ptToInt(hel->val));
}
char *trackLeaves = cgiOptionalString("trackLeavesOnly");
if (isNotEmpty(trackLeaves))
{
- if (sameString("1", trackLeaves))
+ if (SETTING_IS_ON(trackLeaves))
trackLeavesOnly = TRUE;
else if (sameString("0", trackLeaves))
trackLeavesOnly = FALSE;
else
apiErrAbort(err400, err400Msg, "unrecognized 'trackLeavesOnly=%s' argument, can only be =1 or =0", trackLeaves);
}
char *jsonArray = cgiOptionalString("jsonOutputArrays");
if (isNotEmpty(jsonArray))
{
- if (sameString("1", jsonArray))
+ if (SETTING_IS_ON(jsonArray))
jsonOutputArrays = TRUE;
else if (sameString("0", jsonArray))
jsonOutputArrays = FALSE;
else
apiErrAbort(err400, err400Msg, "unrecognized 'jsonOutputArrays=%s' argument, can only be =1 or =0", jsonArray);
}
int maybeDebug = cgiOptionalInt("debug", 0);
if (1 == maybeDebug)
debug = TRUE;
char *measTime = cgiOptionalString("measureTiming");
if (isNotEmpty(measTime) && sameWord("1", measTime))
measureTiming = TRUE;
char *maxOut = cgiOptionalString("maxItemsOutput");