static void writeFindPositionInfo(struct jsonWrite *jw, char *db, int taxId, char *hubUrl, char *position) /* Write JSON for the info needed to populate the 'Find Position' section. */ { char *genome = hGenome(db); if (isEmpty(genome)) { jsonWriteStringf(jw, "error", "No genome for db '%s'", db); } else { jsonWriteString(jw, "db", db); jsonWriteNumber(jw, "taxId", taxId); jsonWriteString(jw, "genome", genome); struct slPair *dbOptions = NULL; char genomeLabel[PATH_LEN*4]; if (isNotEmpty(hubUrl)) { struct trackHub *hub = hubConnectGetHub(hubUrl); if (hub == NULL) { jsonWriteStringf(jw, "error", "Can't connect to hub at '%s'", hubUrl); return; } struct dbDb *dbDbList = trackHubGetDbDbs(hub->name); dbOptions = trackHubDbDbToValueLabel(dbDbList); safecpy(genomeLabel, sizeof(genomeLabel), hub->shortLabel); jsonWriteString(jw, "hubUrl", hubUrl); } else { dbOptions = hGetDbOptionsForGenome(genome); safecpy(genomeLabel, sizeof(genomeLabel), genome); } jsonWriteValueLabelList(jw, "dbOptions", dbOptions); jsonWriteString(jw, "genomeLabel", genomeLabel); jsonWriteString(jw, "position", position); char *suggestTrack = NULL; if (! trackHubDatabase(db)) suggestTrack = assemblyGeneSuggestTrack(db); jsonWriteString(jw, "suggestTrack", suggestTrack); char *description = maybeGetDescriptionText(db); //#*** TODO: move jsonStringEscape inside jsonWriteString char *encoded = jsonStringEscape(description); jsonWriteString(jw, "description", encoded); listAssemblyHubs(jw); } }
static void printCladeOrgDbTree(struct jsonWrite *jw) /* Print out the tree of clades, organisms and dbs as JSON. Each node has value and label * for menu options; clade nodes and org nodes also have children and default. */ { jsonWriteListStart(jw, "cladeOrgDb"); struct slPair *clade, *cladeOptions = hGetCladeOptions(); struct dbDb *centralDbDbList = hDbDbList(); for (clade = cladeOptions; clade != NULL; clade = clade->next) { jsonWriteObjectStart(jw, NULL); jsonWriteValueLabel(jw, clade->name, clade->val); jsonWriteListStart(jw, "children"); struct slPair *org, *orgOptions = hGetGenomeOptionsForClade(clade->name); for (org = orgOptions; org != NULL; org = org->next) { jsonWriteObjectStart(jw, NULL); jsonWriteValueLabel(jw, org->name, org->val); jsonWriteListStart(jw, "children"); struct dbDb *dbDb, *dbDbList; if (isHubTrack(org->name)) dbDbList = trackHubGetDbDbs(clade->name); else dbDbList = centralDbDbList; for (dbDb = dbDbList; dbDb != NULL; dbDb = dbDb->next) { if (sameString(org->name, dbDb->genome)) { jsonWriteObjectStart(jw, NULL); jsonWriteValueLabel(jw, dbDb->name, dbDb->description); jsonWriteString(jw, "defaultPos", dbDb->defaultPos); jsonWriteObjectEnd(jw); } } jsonWriteListEnd(jw); // children (dbs) jsonWriteString(jw, "default", trimSpaces(hDefaultDbForGenome(org->name))); jsonWriteObjectEnd(jw); // org } jsonWriteListEnd(jw); // children (orgs) jsonWriteString(jw, "default", trimSpaces(hDefaultGenomeForClade(clade->name))); jsonWriteObjectEnd(jw); // clade } jsonWriteListEnd(jw); }