Ejemplo n.º 1
0
static void checkCustomTracks(char *db, char *outFile, char *expectedFile)
/* compare track lines of output file with expected.  Return error
 * settings are not a proper subset */
{
struct hash *expHash = hashNew(0);
struct customTrack *ct = NULL, *expCt = NULL;
struct customTrack *newCts = customFactoryParse(db, outFile, TRUE, NULL);
struct customTrack *expCts = customFactoryParse(db, expectedFile, TRUE, NULL);
verbose(3, "found %d tracks in output file %s, %d tracks in expected file %s\n",
                slCount(newCts), outFile, slCount(expCts), expectedFile);
for (ct = expCts; ct != NULL; ct = ct->next)
    hashAdd(expHash, ct->tdb->track, ct);
for (ct = newCts; ct != NULL; ct = ct->next)
    {
    if ((expCt = hashFindVal(expHash, ct->tdb->track)) == NULL)
        errAbort("ct %s not found in expected", ct->tdb->track);
    verbose(3, "output settings: %s %s\n%s\n", ct->tdb->track, 
                                ct->tdb->shortLabel, ct->tdb->settings);
    verbose(3, "expected settings: %s %s\n%s\n", expCt->tdb->track,
                                expCt->tdb->shortLabel, expCt->tdb->settings);
    struct hash *newSettings = trackDbHashSettings(ct->tdb);
    struct hash *expSettings = trackDbHashSettings(expCt->tdb);
    struct hashCookie hc = hashFirst(expSettings);
    struct hashEl *hel;
    while ((hel = hashNext(&hc)) != NULL)
        {
        char *setting = (char *)hel->name;
        /* ignore DB table name -- it will always differ */
        if (sameString(setting, "dbTableName"))
            continue;
        char *expVal = (char *)hel->val;
        char *newVal = NULL;
        if ((newVal = (char *)hashFindVal(newSettings, setting)) == NULL)
            errAbort("ct %s setting %s not found in new", 
                        ct->tdb->track, setting);
        if (differentString(newVal, expVal))
            errAbort("ct %s setting %s differs from expected: %s should be %s",
                        ct->tdb->track, setting, newVal, expVal);
        }
    }
}
Ejemplo n.º 2
0
int oneHubTrackSettings(char *hubUrl, struct hash *totals)
/* Read hub trackDb files, noting settings used */
{
struct trackHub *hub = NULL;
struct errCatch *errCatch = errCatchNew();
if (errCatchStart(errCatch))
    hub = trackHubOpen(hubUrl, "hub_0");
errCatchEnd(errCatch);
errCatchFree(&errCatch);

if (hub == NULL)
    return 1;

printf("%s (%s)\n", hubUrl, hub->shortLabel);
struct trackHubGenome *genome;
struct hash *counts;
if (totals)
    counts = totals;
else
    counts = newHash(0);
struct hashEl *el;
for (genome = hub->genomeList; genome != NULL; genome = genome->next)
    {
    struct trackDb *tdb, *tdbs = trackHubTracksForGenome(hub, genome);
    for (tdb = tdbs; tdb != NULL; tdb = tdb->next)
        {
        struct hashCookie cookie = hashFirst(trackDbHashSettings(tdb));
        verbose(2, "    track: %s\n", tdb->shortLabel);
        while ((el = hashNext(&cookie)) != NULL)
            {
            int count = hashIntValDefault(counts, el->name, 0);
            count++;
            hashReplace(counts, el->name, intToPt(count));
            }
        }
    }
if (!totals)
    printCounts(counts);
trackHubClose(&hub);
return 0;
}