6103cfb97b45dafba47eced8573b21179823a63e
hiram
Fri Apr 5 15:49:35 2019 -0700
better html output refs #18869
diff --git src/hg/hubApi/hubApi.c src/hg/hubApi/hubApi.c
index 867efe9..f754cdf 100644
--- src/hg/hubApi/hubApi.c
+++ src/hg/hubApi/hubApi.c
@@ -212,54 +212,54 @@
unsigned end = start + 10000;
if (end > chromSize)
end = chromSize;
char *genome = NULL;
if (hub)
genome = hub->genomeList->name;
if (db)
{
if (hub)
{
char urlReference[2048];
safef(urlReference, sizeof(urlReference), " (sample getData)%s\n", urlPrefix, hub->url, genome, tdb->track, chrom, start, end, errorPrint);
if (tdb->parent)
- hPrintf("
%s : %s subtrack of parent: %s%s\n", tdb->track, tdb->type, tdb->parent->track, urlReference);
+ hPrintf("%s: %s subtrack of parent: %s%s\n", tdb->track, tdb->type, tdb->parent->track, urlReference);
else
- hPrintf("%s : %s%s\n", tdb->track, tdb->type, urlReference);
+ hPrintf("%s: %s%s\n", tdb->track, tdb->type, urlReference);
}
else
{
char urlReference[2048];
safef(urlReference, sizeof(urlReference), " (sample getData)%s\n", urlPrefix, db, chrom, tdb->track, start, end, errorPrint);
if (tdb->parent)
- hPrintf("%s : %s subtrack of parent: %s%s\n", tdb->track, tdb->type, tdb->parent->track, urlReference);
+ hPrintf("%s: %s subtrack of parent: %s%s\n", tdb->track, tdb->type, tdb->parent->track, urlReference);
else
- hPrintf("%s : %s%s\n", tdb->track, tdb->type, urlReference );
+ hPrintf("%s: %s%s\n", tdb->track, tdb->type, urlReference );
}
}
else if (hub)
{
char urlReference[2048];
safef(urlReference, sizeof(urlReference), " (sample getData)%s\n", urlPrefix, hub->url, genome, tdb->track, chrom, start, end, errorPrint);
if (tdb->parent)
- hPrintf("%s : %s subtrack of parent: %s%s\n", tdb->track, tdb->type, tdb->parent->track, urlReference);
+ hPrintf("%s: %s subtrack of parent: %s%s\n", tdb->track, tdb->type, tdb->parent->track, urlReference);
else
- hPrintf("%s : %s%s\n", tdb->track, tdb->type, urlReference);
+ hPrintf("%s: %s%s\n", tdb->track, tdb->type, urlReference);
}
else
hPrintf("%s : %s not db hub track ?\n", tdb->track, tdb->type);
}
static void hubSampleUrl(struct trackHub *hub, struct trackDb *tdb,
long chromCount, long itemCount, char *chromName, unsigned chromSize,
char *genome, char *errorString)
{
unsigned start = chromSize / 4;
unsigned end = start + 10000;
if (end > chromSize)
end = chromSize;
char errorPrint[2048];
@@ -276,44 +276,44 @@
{
if (startsWithWord("bigBed", tdb->type))
safef(countsMessage, sizeof(countsMessage), " : %ld chroms : %ld item count ", chromCount, itemCount);
else if (startsWithWord("bigWig", tdb->type))
safef(countsMessage, sizeof(countsMessage), " : %ld chroms : %ld bases covered ", chromCount, itemCount);
else
safef(countsMessage, sizeof(countsMessage), " : %ld chroms : %ld count ", chromCount, itemCount);
}
if (isSupportedType(tdb->type))
{
char urlReference[2048];
safef(urlReference, sizeof(urlReference), "(sample getData)%s\n", urlPrefix, hub->url, genome, tdb->track, chromName, start, end, errorPrint);
if (startsWithWord("bigBed", tdb->type))
- hPrintf(" %s : %s%s%s\n", tdb->track, tdb->type, countsMessage, urlReference);
+ hPrintf(" %s: %s%s%s\n", tdb->track, tdb->type, countsMessage, urlReference);
else if (startsWithWord("bigWig", tdb->type))
- hPrintf(" %s : %s%s%s\n", tdb->track, tdb->type, countsMessage, urlReference);
+ hPrintf(" %s: %s%s%s\n", tdb->track, tdb->type, countsMessage, urlReference);
else
- hPrintf(" %s : %s%s%s\n", tdb->track, tdb->type, countsMessage, urlReference);
+ hPrintf(" %s: %s%s%s\n", tdb->track, tdb->type, countsMessage, urlReference);
}
else
{
if (startsWithWord("bigBed", tdb->type))
- hPrintf(" %s : %s%s\n", tdb->track, tdb->type, countsMessage);
+ hPrintf(" %s: %s%s\n", tdb->track, tdb->type, countsMessage);
else if (startsWithWord("bigWig", tdb->type))
- hPrintf(" %s : %s%s\n", tdb->track, tdb->type, countsMessage);
+ hPrintf(" %s: %s%s\n", tdb->track, tdb->type, countsMessage);
else
- hPrintf(" %s : %s%s\n", tdb->track, tdb->type, countsMessage);
+ hPrintf(" %s: %s%s\n", tdb->track, tdb->type, countsMessage);
}
} /* static void hubSampleUrl(struct trackHub *hub, struct trackDb *tdb,
* long chromCount, long itemCount, char *chromName, unsigned chromSize,
* char *genome)
*/
static void bbiLargestChrom(struct bbiChromInfo *chromList, char **chromName,
unsigned *chromSize)
/* find largest chromosome name and size in the chromList */
{
if (chromName && chromSize)
{
*chromSize = 0;
char *returnName = NULL;
struct bbiChromInfo *el;
@@ -455,93 +455,93 @@
{
char *bigDataIndex = NULL;
char *relIdxUrl = trackDbSetting(tdbEl, "bigDataIndex");
if (relIdxUrl != NULL)
bigDataIndex = trackHubRelativeUrl(hub->genomeList->trackDbFile, relIdxUrl);
char *bigDataUrl = trackDbSetting(tdbEl, "bigDataUrl");
char *longName = NULL;
unsigned longSize = 0;
struct dyString *errors = newDyString(1024);
(void) bbiBriefMeasure(tdbEl->type, bigDataUrl, bigDataIndex, &chromCount, &itemCount, errors, &longName, &longSize);
chromSize = longSize;
chromName = longName;
}
}
if (tdbIsCompositeView(tdbEl))
- hPrintf("%s : %s : composite view of parent: %s\n", tdbEl->track, tdbEl->type, tdbEl->parent->track);
+ hPrintf("%s: %s : composite view of parent: %s\n", tdbEl->track, tdbEl->type, tdbEl->parent->track);
else
{
if (isSupportedType(tdbEl->type))
hubSampleUrl(hub, tdbEl, chromCount, itemCount, chromName, chromSize, genome, errorString);
else
- hPrintf("%s : %s : subtrack of parent: %s\n", tdbEl->track, tdbEl->type, tdbEl->parent->track);
+ hPrintf("%s: %s : subtrack of parent: %s\n", tdbEl->track, tdbEl->type, tdbEl->parent->track);
}
hashCountTrack(tdbEl, countTracks);
if (tdbEl->subtracks)
hubSubTracks(hub, db, tdbEl, countTracks, chromCount, itemCount, chromName, chromSize, genome, errorString);
}
}
hPrintf(" \n");
} /* hubSubTracks() */
static void showSubTracks(struct trackHub *hub, char *db, struct trackDb *tdb, struct hash *countTracks,
char *chromName, unsigned chromSize, char *errorString)
/* tdb has subtracks, show only subTracks, no details */
{
hPrintf(" \n");
if (debug)
hPrintf(" - subtracks for '%s' db: '%s'
\n", tdb->track, db);
if (tdb->subtracks)
{
struct trackDb *tdbEl = NULL;
for (tdbEl = tdb->subtracks; tdbEl; tdbEl = tdbEl->next)
{
if (tdbIsCompositeView(tdbEl))
- hPrintf("- %s : %s : composite view of parent: %s
\n", tdbEl->track, tdbEl->type, tdbEl->parent->track);
+ hPrintf("- %s: %s : composite view of parent: %s
\n", tdbEl->track, tdbEl->type, tdbEl->parent->track);
else
{
if (isSupportedType(tdbEl->type))
sampleUrl(hub, db, tdbEl, chromName, chromSize, errorString);
else
- hPrintf("- %s : %s : subtrack of parent: %s
\n", tdbEl->track, tdbEl->type, tdbEl->parent->track);
+ hPrintf("- %s: %s : subtrack of parent: %s
\n", tdbEl->track, tdbEl->type, tdbEl->parent->track);
}
hashCountTrack(tdbEl, countTracks);
if (tdbEl->subtracks)
showSubTracks(hub, db, tdbEl, countTracks, chromName, chromSize, errorString);
}
}
hPrintf("
\n");
}
static void trackSettings(struct trackDb *tdb, struct hash *countTracks)
/* process the settingsHash for a trackDb, recursive when subtracks */
{
hPrintf(" \n");
// if (tdb->children) haven't yet seen a track with children ?
// hPrintf(" - %s: has children
\n", tdb->track);
// else
// hPrintf(" - %s: NO children
\n", tdb->track);
struct hashEl *hel;
struct hashCookie hc = hashFirst(tdb->settingsHash);
while ((hel = hashNext(&hc)) != NULL)
{
if (sameWord("track", hel->name))
continue; // already output in header
if (isEmpty((char *)hel->val))
- hPrintf(" - %s : <empty>
\n", hel->name);
+ hPrintf(" - %s: <empty>
\n", hel->name);
else
- hPrintf(" - %s : '%s'
\n", hel->name, (char *)hel->val);
+ 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'
\n", tdbEl->track, tdbEl->parent->track, tdbEl->type);
hashCountTrack(tdbEl, countTracks);
trackSettings(tdbEl, countTracks);
}
}
hPrintf("
\n");
}
@@ -575,50 +575,50 @@
unsigned longSize = 0;
(void) bbiBriefMeasure(tdb->type, bigDataUrl, bigDataIndex, &chromCount, &itemCount, errors, &longName, &longSize);
chromSize = longSize;
chromName = longName;
}
}
if (depthSearch && bigDataUrl)
{
if (isSupportedType(tdb->type))
hubSampleUrl(hub, tdb, chromCount, itemCount, chromName, chromSize, genome, errors->string);
}
else
{
if (compositeContainer)
- hPrintf(" %s : %s : composite track container has %d subtracks\n", tdb->track, tdb->type, slCount(tdb->subtracks));
+ hPrintf(" %s: %s : composite track container has %d subtracks\n", tdb->track, tdb->type, slCount(tdb->subtracks));
else if (compositeView)
- hPrintf(" %s : %s : composite view of parent: %s\n", tdb->track, tdb->type, tdb->parent->track);
+ hPrintf(" %s: %s : composite view of parent: %s\n", tdb->track, tdb->type, tdb->parent->track);
else if (superChild)
- hPrintf(" %s : %s : superTrack child of parent: %s (sample getData)\n", tdb->track, tdb->type, tdb->parent->track);
+ hPrintf(" %s: %s : superTrack child of parent: %s (sample getData)\n", tdb->track, tdb->type, tdb->parent->track);
else if (! depthSearch && bigDataUrl)
{
if (isSupportedType(tdb->type))
{
hubSampleUrl(hub, tdb, chromCount, itemCount, chromName, chromSize, genome, errors->string);
}
}
else
{
if (isSupportedType(tdb->type))
{
hubSampleUrl(hub, tdb, chromCount, itemCount, chromName, chromSize, genome, errors->string);
}
else
- hPrintf(" %s : %s (what is this)\n", tdb->track, tdb->type);
+ hPrintf(" %s: %s (what is this)\n", tdb->track, tdb->type);
}
}
if (allTrackSettings)
{
hPrintf(" \n");
trackSettings(tdb, countTracks); /* show all settings */
hPrintf("
\n");
}
else if (tdb->subtracks)
{
hubSubTracks(hub, db, tdb, countTracks, chromCount, itemCount, chromName, chromSize, genome, errors->string);
}
return;
} /* static void hubCountOneTdb(char *db, struct trackDb *tdb,
* char *bigDataIndex, struct hash *countTracks,
@@ -629,43 +629,43 @@
static void countOneTdb(char *db, struct trackDb *tdb,
struct hash *countTracks, char *chromName, unsigned chromSize,
char *errorString)
/* for this tdb in this db, count it up and provide a sample */
{
char *bigDataUrl = trackDbSetting(tdb, "bigDataUrl");
// char *compositeTrack = trackDbSetting(tdb, "compositeTrack");
boolean compositeContainer = tdbIsComposite(tdb);
boolean compositeView = tdbIsCompositeView(tdb);
// char *superTrack = trackDbSetting(tdb, "superTrack");
boolean superChild = tdbIsSuperTrackChild(tdb);
boolean depthSearch = cartUsualBoolean(cart, "depthSearch", FALSE);
hashCountTrack(tdb, countTracks);
if (compositeContainer)
- hPrintf(" %s : %s : composite track container has %d subtracks\n", tdb->track, tdb->type, slCount(tdb->subtracks));
+ hPrintf(" %s: %s : composite track container has %d subtracks\n", tdb->track, tdb->type, slCount(tdb->subtracks));
else if (compositeView)
- hPrintf(" %s : %s : composite view of parent: %s\n", tdb->track, tdb->type, tdb->parent->track);
+ hPrintf(" %s: %s : composite view of parent: %s\n", tdb->track, tdb->type, tdb->parent->track);
else if (superChild)
- hPrintf(" %s : %s : superTrack child of parent: %s\n", tdb->track, tdb->type, tdb->parent->track);
+ hPrintf(" %s: %s : superTrack child of parent: %s\n", tdb->track, tdb->type, tdb->parent->track);
else if (! depthSearch && bigDataUrl)
- hPrintf(" %s : %s : %s\n", tdb->track, tdb->type, bigDataUrl);
+ hPrintf(" %s: %s : %s\n", tdb->track, tdb->type, bigDataUrl);
else
{
if (isSupportedType(tdb->type))
sampleUrl(NULL, db, tdb, chromName, chromSize, errorString);
else
- hPrintf(" %s : %s\n", tdb->track, tdb->type);
+ hPrintf(" %s: %s\n", tdb->track, tdb->type);
}
if (allTrackSettings)
{
hPrintf(" \n");
trackSettings(tdb, countTracks); /* show all settings */
hPrintf("
\n");
}
else if (tdb->subtracks)
{
showSubTracks(NULL, db, tdb, countTracks, chromName, chromSize, NULL);
}
return;
} /* static void countOneTdb(char *db, struct trackDb *tdb,
* struct hash *countTracks, char *chromName,
@@ -708,149 +708,166 @@
struct trackDb *tdb = NULL;
for ( tdb = topTrackDb; tdb; tdb = tdb->next )
{
char *bigDataIndex = NULL;
char *relIdxUrl = trackDbSetting(topTrackDb, "bigDataIndex");
if (relIdxUrl != NULL)
bigDataIndex = trackHubRelativeUrl(genome->trackDbFile, relIdxUrl);
char *defaultGenome = NULL;
if (isNotEmpty(genome->name))
defaultGenome = genome->name;
char *chromName = NULL;
unsigned chromSize = 0;
int chromCount = 0;
if (isEmpty(genome->twoBitPath))
chromSize = largestChrom(defaultGenome, &chromName, &chromCount);
- else
- hPrintf(" twoBitPath %s genome %s\n", genome->twoBitPath, defaultGenome);
hubCountOneTdb(hub, defaultGenome, tdb, bigDataIndex, countTracks, chromName, chromSize, defaultGenome);
if (timeOutReached())
break;
} /* for ( tdb = topTrackDb; tdb; tdb = tdb->next ) */
hPrintf(" %d different track types\n",countTracks->elCount - 1);
/* add this single genome count to the overall multi-genome counts */
if (countTracks->elCount)
{
hPrintf(" \n");
struct hashEl *hel, *helList = hashElListHash(countTracks);
slSort(&helList, hashElCmpIntValDesc);
for (hel = helList; hel; hel = hel->next)
{
if (sameOk("track count", hel->name))
continue;
int prevCount = ptToInt(hashFindVal(trackCounter, hel->name));
if (differentStringNullOk("track count", hel->name))
totalTracks += ptToInt(hel->val);
hashReplace(trackCounter, hel->name, intToPt(prevCount + ptToInt(hel->val)));
if (isSupportedType(hel->name))
hPrintf(" - %d - %s - supported
\n", ptToInt(hel->val), hel->name);
else
hPrintf(" - %d - %s
\n", ptToInt(hel->val), hel->name);
}
hPrintf("
\n");
}
}
else
hPrintf(" no trackTopDb ?\n");
-hPrintf(" \n");
+hPrintf(" \n");
} /* static struct trackDb *hubTrackList() */
static void hubAssemblySettings(struct trackHub *hub, struct trackHubGenome *genome)
/* display all the assembly 'settingsHash' */
{
struct trackDb *tdb = obtainTdb(genome, NULL);
hPrintf(" \n");
struct hashEl *hel;
struct hashCookie hc = hashFirst(genome->settingsHash);
while ((hel = hashNext(&hc)) != NULL)
{
- hPrintf(" - %s : %s
\n", hel->name, (char *)hel->val);
+ 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)
{
if (el->size > size)
{
size = el->size;
name = el->chrom;
}
}
if (chromName)
*chromName = name;
return size;
}
+static void hubInfo(char *tag, char *val)
+/* print one list element with the given tag and value, show
+ * if not value present
+ */
+{
+if (isNotEmpty(val))
+ hPrintf("%s: '%s'\n", tag, val);
+else
+ hPrintf("%s: <empty>\n", tag);
+}
+
static void genomeList(struct trackHub *hubTop)
/* follow the pointers from the trackHub to trackHubGenome and around
* in a circle from one to the other to find all hub resources
*/
{
long totalAssemblyCount = 0;
struct trackHubGenome *genome = hubTop->genomeList;
hPrintf("genome sequences (and tracks) present in this track hub
\n");
if (NULL == genome)
{
hPrintf("odd error, can not find a gnomeList ? at url: '%s'
\n", hubTop->url);
return;
}
hPrintf("