4409063550e6c4cc87cfd37f92f7b8db2699f885 hiram Fri Mar 13 17:13:14 2026 -0700 with the aid of claude add a genome argument to the ucscGenomes endpoint and manage assembly alias a bit more than previously for ucscGenomes and genarkGenomes refs #35972 diff --git src/hg/hubApi/list.c src/hg/hubApi/list.c index 1258a04abd8..e9a751232f0 100644 --- src/hg/hubApi/list.c +++ src/hg/hubApi/list.c @@ -103,69 +103,85 @@ jsonWriteNumber(jw, columnNames[i++], (long long)el->taxId); jsonWriteObjectEnd(jw); } static void jsonDbDb() /* output the dbDb SQL table */ { char *extraArgs = verifyLegalArgs(argListUcscGenomes); /* no extras allowed */ if (extraArgs) apiErrAbort(err400, err400Msg, "extraneous arguments found for function /list/ucscGenomes '%s'", extraArgs); struct sqlConnection *conn = hConnectCentral(); char *dataTime = sqlTableUpdate(conn, "dbDb"); time_t dataTimeStamp = sqlDateToUnixTime(dataTime); replaceChar(dataTime, ' ', 'T'); /* ISO 8601 */ +char *genome = cgiOptionalString(argGenome); struct dbDb *dbList = ucscDbDb(); struct dbDb *el; struct jsonWrite *jw = apiStartOutput(); jsonWriteString(jw, "dataTime", dataTime); jsonWriteNumber(jw, "dataTimeStamp", (long long)dataTimeStamp); freeMem(dataTime); char **columnNames = NULL; char **columnTypes = NULL; int *jsonTypes = NULL; int columnCount = tableColumns(conn, "dbDb", &columnNames, &columnTypes, &jsonTypes); +long long itemCount = 0; jsonWriteObjectStart(jw, "ucscGenomes"); for ( el=dbList; el != NULL; el = el->next ) + { + if (genome == NULL || sameWord(genome, el->name)) { dbDbJsonData(jw, el, columnCount, columnNames); + ++itemCount; + } } jsonWriteObjectEnd(jw); +if (genome && itemCount < 1) + { + char *genomeInput = cgiOptionalString("genomeInput"); + apiErrAbort(err404, err404Msg, "genome '%s' not found", + isNotEmpty(genomeInput) ? genomeInput : genome); + } apiFinishOutput(0, NULL, jw); hDisconnectCentral(&conn); } static void jsonGenArk() /* output the genark.hgcentral SQL table */ { char *extraArgs = verifyLegalArgs(argListGenarkGenomes); /* no extras allowed */ if (extraArgs) apiErrAbort(err400, err400Msg, "extraneous arguments found for function /list/genark '%s'", extraArgs); struct sqlConnection *conn = hConnectCentral(); char *genArkTable = genarkTableName(); char *dataTime = sqlTableUpdate(conn, genArkTable); time_t dataTimeStamp = sqlDateToUnixTime(dataTime); replaceChar(dataTime, ' ', 'T'); /* ISO 8601 */ long long genArkCount = genArkSize(); char *genome = cgiOptionalString("genome"); struct genark *list = genArkList(genome); struct jsonWrite *jw = apiStartOutput(); if (genome && slCount(list) < 1) - apiErrAbort(err404, err404Msg, "genome '%s' not found", genome); + { + char *genomeInput = cgiOptionalString("genomeInput"); + apiErrAbort(err404, err404Msg, "genome '%s' not found", + isNotEmpty(genomeInput) ? genomeInput : genome); + } jsonWriteString(jw, "dataTime", dataTime); jsonWriteNumber(jw, "dataTimeStamp", (long long)dataTimeStamp); char *hubPrefix = cfgOption("genarkHubPrefix"); jsonWriteString(jw, "hubUrlPrefix", hubPrefix); freeMem(dataTime); char **columnNames = NULL; char **columnTypes = NULL; int *jsonTypes = NULL; int columnCount = tableColumns(conn, genArkTable, &columnNames, &columnTypes, &jsonTypes); jsonWriteObjectStart(jw, "genarkGenomes"); struct genark *el; for ( el=list; el != NULL; el = el->next ) { genArkJsonData(jw, el, columnCount, columnNames); @@ -762,31 +778,30 @@ long long totalBytes = 0; if (fileType) { char outString[1024]; if (genArkHub) { safef(outString, sizeof(outString), "https://%s/%s/%s/%s.2bit", DOWNLOAD_HOST, genArkUrl, genome, genome); textLineOut(outString); } else { safef(outString, sizeof(outString), "https://%s/gbdb/%s/%s.2bit", DOWNLOAD_HOST, genome, genome); textLineOut(outString); } - } else if (genArkHub) { totalBytes = rsyncList(jw, genome, genArkUrl, &itemsReturned, textOut); } else { totalBytes = rsyncList(jw, genome, "goldenPath", &itemsReturned, textOut); if (itemsReturned < maxItemsOutput) totalBytes += rsyncList(jw, genome, "gbdb", &itemsReturned, textOut); if (itemsReturned < maxItemsOutput) totalBytes += rsyncList(jw, genome, "mysql", &itemsReturned, textOut); } if (textOut)