87f40c4dbf6ae4e07fe0ecd8b4cb75dec6e3c0a5 markd Thu Jul 25 20:21:01 2024 -0700 add option to pslMap to output TSVs for mapInfo files rather than autoSql tab format diff --git src/utils/pslMap/pslMap.c src/utils/pslMap/pslMap.c index 026a0f9..0f3d122 100644 --- src/utils/pslMap/pslMap.c +++ src/utils/pslMap/pslMap.c @@ -13,53 +13,55 @@ #include "dnautil.h" #include "chain.h" #include "verbose.h" /* command line option specifications */ static struct optionSpec optionSpecs[] = { {"suffix", OPTION_STRING}, {"keepTranslated", OPTION_BOOLEAN}, {"mapFileWithInQName", OPTION_BOOLEAN}, {"check", OPTION_BOOLEAN}, {"chainMapFile", OPTION_BOOLEAN}, {"swapMap", OPTION_BOOLEAN}, {"swapIn", OPTION_BOOLEAN}, {"mapInfo", OPTION_STRING}, + {"tsv", OPTION_BOOLEAN}, {"mappingPsls", OPTION_STRING}, {"inType", OPTION_STRING}, {"mapType", OPTION_STRING}, {"simplifyMappingIds", OPTION_BOOLEAN}, {NULL, 0} }; /* Values parsed from command line */ static char* suffix = NULL; static unsigned mapOpts = pslTransMapNoOpts; static boolean mapFileWithInQName = FALSE; static boolean chainMapFile = FALSE; static boolean swapMap = FALSE; static boolean swapIn = FALSE; static boolean check = FALSE; static boolean simplifyMappingIds = FALSE; static char* mapInfoFile = NULL; +static boolean tsv = FALSE; static char* mappingPslFile = NULL; static enum pslType inPslType = pslTypeUnspecified; static enum pslType mapPslType = pslTypeUnspecified; static char *mapInfoHdr = - "#srcQName\t" "srcQStart\t" "srcQEnd\t" "srcQSize\t" + "srcQName\t" "srcQStart\t" "srcQEnd\t" "srcQSize\t" "srcTName\t" "srcTStart\t" "srcTEnd\t" "srcStrand\t" "srcAligned\t" "mappingQName\t" "mappingQStart\t" "mappingQEnd\t" "mappingTName\t" "mappingTStart\t" "mappingTEnd\t" "mappingStrand\t" "mappingId\t" "mappedQName\t" "mappedQStart\t" "mappedQEnd\t" "mappedTName\t" "mappedTStart\t" "mappedTEnd\t" "mappedStrand\t" "mappedAligned\t" "qStartTrunc\t" "qEndTrunc\t" "mappedPslLine\n"; static void usage() /* usage msg and exit */ { /* message got huge, so it's in a generate file */ static char *usageMsg = @@ -375,30 +377,32 @@ struct genomeRangeTree *mapAlns; struct psl* inPsl; struct lineFile* inPslLf = pslFileOpen(inPslFile); FILE *outPslFh, *mapInfoFh = NULL, *mappingPslFh = NULL; unsigned outPslLine = 0; if (chainMapFile) mapAlns = loadMapChains(mapFile); else mapAlns = loadMapPsls(mapFile); outPslFh = mustOpen(outPslFile, "w"); if (mapInfoFile != NULL) { mapInfoFh = mustOpen(mapInfoFile, "w"); + if (!tsv) + fputc('#', mapInfoFh); fputs(mapInfoHdr, mapInfoFh); } if (mappingPslFile != NULL) mappingPslFh = mustOpen(mappingPslFile, "w"); while ((inPsl = pslNext(inPslLf)) != NULL) { if (swapIn) pslSwap(inPsl, FALSE); mapQueryPsl(inPsl, mapAlns, outPslFh, mapInfoFh, mappingPslFh, &outPslLine); pslFree(&inPsl); } carefulClose(&mappingPslFh); carefulClose(&mapInfoFh); carefulClose(&outPslFh); lineFileClose(&inPslLf); @@ -416,25 +420,26 @@ mapFileWithInQName = optionExists("mapFileWithInQName"); chainMapFile = optionExists("chainMapFile"); if (mapFileWithInQName && chainMapFile) errAbort("can't specify -mapFileWithInQName with -chainMapFile"); swapMap = optionExists("swapMap"); swapIn = optionExists("swapIn"); check = optionExists("check"); simplifyMappingIds = optionExists("simplifyMappingIds"); char *typeStr; if ((typeStr = optionVal("inType", NULL)) != NULL) inPslType = parsePslType(typeStr); if ((typeStr = optionVal("mapType", NULL)) != NULL) mapPslType = parsePslType(typeStr); mapInfoFile = optionVal("mapInfo", NULL); +tsv = optionExists("tsv"); mappingPslFile = optionVal("mappingPsls", NULL); pslMap(argv[1], argv[2], argv[3]); return 0; } /* * Local Variables: * c-file-style: "jkent-c" * End: */