f7d577042a7e3e41c1121082febb7ff25020bf0b markd Sun Feb 28 13:19:19 2021 -0800 have gfServer check that index files match the required naming convention diff --git src/gfServer/gfServer.c src/gfServer/gfServer.c index bd55595..a245f2e 100644 --- src/gfServer/gfServer.c +++ src/gfServer/gfServer.c @@ -1099,33 +1099,58 @@ sprintf(buf, "%sfiles", gfSignature()); mustWriteFd(sd, buf, strlen(buf)); /* Get count of files, and then each file name. */ if (netGetString(sd, buf) != NULL) { fileCount = atoi(buf); for (i=0; i<fileCount; ++i) { printf("%s\n", netRecieveString(sd, buf)); } } close(sd); } +static void checkIndexFileName(char *gfxFile, char *seqFile) +/* validate that index matches conventions, as base name is stored in index */ +{ +char seqBaseName[FILENAME_LEN], seqExt[FILEEXT_LEN]; +splitPath(seqFile, NULL, seqBaseName, seqExt); +if ((strlen(seqBaseName) == 0) || !sameString(seqExt, ".2bit")) + errAbort("gfServer index requires a two-bit genome file with a base name of `myGenome.2bit`, got %s%s", + seqBaseName, seqExt); + +char gfxBaseName[FILENAME_LEN], gfxExt[FILEEXT_LEN]; +splitPath(gfxFile, NULL, gfxBaseName, gfxExt); +if (!sameString(gfxExt, ".gfidx")) + errAbort("gfServer index must have an file extension of '.gfidx', got %s", gfxExt); +char expectBaseName[FILENAME_LEN]; +safef(expectBaseName, sizeof(expectBaseName), "%s.%s", seqBaseName, + (doTrans ? "trans" : "untrans")); +if (!sameString(gfxBaseName, expectBaseName)) + errAbort("%s index file base name must be '%s.gfidx', got %s%s", + (doTrans ? "translated" : "untranslated"), expectBaseName, gfxBaseName, gfxExt); +} + static void buildIndex(char *gfxFile, int fileCount, char *seqFiles[]) /* build pre-computed index for seqFiles and write to gfxFile */ { +if (fileCount > 1) + errAbort("gfServer index only works with a single genome file"); +checkIndexFileName(gfxFile, seqFiles[0]); + struct genoFindIndex *gfIdx = genoFindIndexBuild(fileCount, seqFiles, minMatch, maxGap, tileSize, repMatch, doTrans, NULL, allowOneMismatch, doMask, stepSize, noSimpRepMask); genoFindIndexWrite(gfIdx, gfxFile); } static void dynWarnErrorVa(char* msg, va_list args) /* warnHandler to log and send back an error response */ { char buf[4096]; int msgLen = vsnprintf(buf, sizeof(buf) - 1, msg, args); buf[msgLen] = '\0'; logError("%s", buf); printf("Error: %s\n", buf); }