static struct trackDb *buildTrackDb(char *org, char *database, char *hgRoot, boolean strict) /* Build trackDb objects from files. */ { struct hash *trackHash = newHash(0); char rootDir[PATH_LEN], orgDir[PATH_LEN], asmDir[PATH_LEN]; /* Create track list from hgRoot and hgRoot/org and hgRoot/org/assembly * ra format database. */ safef(rootDir, sizeof(rootDir), "%s", hgRoot); safef(orgDir, sizeof(orgDir), "%s/%s", hgRoot, org); safef(asmDir, sizeof(asmDir), "%s/%s/%s", hgRoot, org, database); /* Must call these top-down. * Also prunes things not in our release. */ layerOnRa(strict, database, rootDir, trackHash, TRUE); layerOnRa(strict, database, orgDir, trackHash, FALSE); layerOnRa(strict, database, asmDir, trackHash, FALSE); /* Represent hash as list */ struct trackDb *tdbList = trackDbListFromHash(trackHash); trackDbAddTableField(tdbList); /* Get rid of orphans with no parent of the correct release. */ tdbList = pruneOrphans(tdbList, trackHash); /* After this the hash is no longer needed, so get rid of it. */ hashFree(&trackHash); /* Read in HTML bits onto what remains. */ layerOnHtml(asmDir, tdbList, database); layerOnHtml(orgDir, tdbList, database); layerOnHtml(rootDir, tdbList, database); /* Set up parent/subtracks pointers. */ tdbList = trackDbLinkUpGenerations(tdbList); rSetTrackDbFields(tdbList); /* Fill in any additional missing info from defaults. */ rPolish(tdbList); polishSupers(tdbList); /* Optionally check for tables/tracks that actually exist and get rid of ones that don't. */ if (strict) tdbList = pruneStrict(tdbList, database); tdbList = pruneEmptyContainers(tdbList); checkSubGroups(database,tdbList,strict); trackDbPrioritizeContainerItems(tdbList); return tdbList; }
struct trackDb *hubAddTracks(struct hubConnectStatus *hub, char *database) /* Load up stuff from data hub and append to list. The hubUrl points to * a trackDb.ra format file. */ { /* Load trackDb.ra file and make it into proper trackDb tree */ struct trackDb *tdbList = NULL; struct trackHub *trackHub = hub->trackHub; if (trackHub != NULL) { struct trackHubGenome *hubGenome = trackHubFindGenome(trackHub, database); if (hubGenome != NULL) { tdbList = trackHubTracksForGenome(trackHub, hubGenome); tdbList = trackDbLinkUpGenerations(tdbList); tdbList = trackDbPolishAfterLinkup(tdbList, database); trackDbPrioritizeContainerItems(tdbList); trackHubPolishTrackNames(trackHub, tdbList); } } return tdbList; }
struct trackDb *hubConnectAddHubForTrackAndFindTdb( char *database, char *trackName, struct trackDb **pTdbList, struct hash *trackHash) /* Go find hub for trackName (which will begin with hub_), and load the tracks * for it, appending to end of list and adding to trackHash. Return the * trackDb associated with trackName. This will also fill in the html fields, * but just for that track and it's parents. */ { unsigned hubId = hubIdFromTrackName(trackName); struct hubConnectStatus *hub = hubFromId(hubId); struct trackHubGenome *hubGenome = trackHubFindGenome(hub->trackHub, database); struct trackDb *tdbList = trackHubTracksForGenome(hub->trackHub, hubGenome); tdbList = trackDbLinkUpGenerations(tdbList); tdbList = trackDbPolishAfterLinkup(tdbList, database); trackDbPrioritizeContainerItems(tdbList); trackHubPolishTrackNames(hub->trackHub, tdbList); char *fixTrackName = cloneString(trackName); trackHubFixName(fixTrackName); rAddTrackListToHash(trackHash, tdbList, NULL, FALSE); if (pTdbList != NULL) *pTdbList = slCat(*pTdbList, tdbList); struct trackDb *tdb = hashFindVal(trackHash, fixTrackName); if (tdb == NULL) // superTracks aren't in the hash... look in tdbList tdb = findSuperTrack(tdbList, fixTrackName); if (tdb == NULL) errAbort("Can't find track %s in %s", fixTrackName, hub->trackHub->url); /* Add html for track and parents. */ /* Note: this does NOT add the HTML for supertrack kids */ struct trackDb *parent; for (parent = tdb; parent != NULL; parent = parent->parent) trackHubAddDescription(hubGenome->trackDbFile, parent); return tdb; }