static struct genePred *getCurGenePred(struct sqlConnection *conn) /* Return current gene in genePred. */ { char *track = genomeSetting("knownGene"); char table[HDB_MAX_TABLE_STRING]; boolean hasBin; char query[256]; struct sqlResult *sr; char **row; struct genePred *gp = NULL; if (!hFindSplitTable(sqlGetDatabase(conn), curGeneChrom, track, table, sizeof table, &hasBin)) errAbort("track %s not found", track); bool hasAttrId = sqlColumnExists(conn, table, "alignId"); sqlSafef(query, sizeof(query), "select * from %s where name = '%s' " "and chrom = '%s' and txStart=%d and txEnd=%d" , table, curGeneId, curGeneChrom, curGeneStart, curGeneEnd); sr = sqlGetResult(conn, query); if ((row = sqlNextRow(sr)) != NULL) { gp = genePredLoad(row + hasBin); #define ALIGNIDFIELD 11 // Gencode Id if (hasAttrId) curAlignId = cloneString(row[ALIGNIDFIELD]); else curAlignId = gp->name; } sqlFreeResult(&sr); if (gp == NULL) errAbort("getCurGenePred: Can't find %s", query); return gp; }
int hubPublicCheck(char *table) /* hubPublicCheck - checks that the labels in hubPublic match what is in the hub labels. */ { struct sqlConnection *conn = hConnectCentral(); char query[512]; bool hasDescriptionUrl = sqlColumnExists(conn, table, "descriptionUrl"); if (hasDescriptionUrl) sqlSafef(query, sizeof(query), "select hubUrl, shortLabel,longLabel,dbList,descriptionUrl from %s", table); else sqlSafef(query, sizeof(query), "select hubUrl, shortLabel,longLabel,dbList from %s", table); struct sqlResult *sr = sqlGetResult(conn, query); char **row; int differences = 0; while ((row = sqlNextRow(sr)) != NULL) { char *url = row[0], *shortLabel = row[1], *longLabel = row[2], *dbList = row[3], *descriptionUrl = row[4]; struct errCatch *errCatch = errCatchNew(); boolean gotWarning = FALSE; struct trackHub *tHub = NULL; if (errCatchStart(errCatch)) tHub = trackHubOpen(url, "hub_1"); errCatchEnd(errCatch); if (errCatch->gotError) { gotWarning = TRUE; warn("%s", errCatch->message->string); } errCatchFree(&errCatch); if (gotWarning) { continue; } if (!sameString(shortLabel, tHub->shortLabel)) { differences++; printf("update %s set shortLabel=\"%s\" where hubUrl=\"%s\";\n",table, tHub->shortLabel, url); } if (!sameString(longLabel, tHub->longLabel)) { differences++; printf("update %s set longLabel=\"%s\" where hubUrl=\"%s\";\n",table, tHub->longLabel, url); } struct hashCookie cookie = hashFirst(tHub->genomeHash); struct dyString *dy = newDyString(1024); struct hashEl *hel; while ((hel = hashNext(&cookie)) != NULL) dyStringPrintf(dy, "%s,", trackHubSkipHubName(hel->name)); if (!sameString(dy->string, dbList)) { differences++; printf("update %s set dbList=\"%s\" where hubUrl=\"%s\";\n",table, dy->string, url); } if (hasDescriptionUrl && !isEmpty(tHub->descriptionUrl) && ((descriptionUrl == NULL) || !sameString(descriptionUrl, tHub->descriptionUrl))) { differences++; printf("update %s set descriptionUrl=\"%s\" where hubUrl=\"%s\";\n",table, tHub->descriptionUrl, url); } trackHubClose(&tHub); } return differences; }