be9e5faa96a0773d42929c54f58ded53f40b7e88
braney
Mon Dec 12 15:59:17 2016 -0800
some changes that make it easier for trash cleaner to squirrel away
custom tracks holding BLAT results
diff --git src/hg/hgBlat/hgBlat.c src/hg/hgBlat/hgBlat.c
index a78ebdf..510eb7e 100644
--- src/hg/hgBlat/hgBlat.c
+++ src/hg/hgBlat/hgBlat.c
@@ -251,58 +251,67 @@
{
char url[1024];
safef(url, sizeof(url), "%s?position=%s:%d-%d&db=%s&ss=%s+%s&%s%s",
browserUrl, psl->tName, psl->tStart + 1, psl->tEnd, database,
pslName, faName, uiState, unhideTrack);
/* htmlStart("Redirecting"); */
/* Odd it appears that we've already printed the Content-Typ:text/html line
but I can't figure out where... */
htmStart(stdout, "Redirecting");
printf("", url);
printf("", url);
htmlEnd();
}
+static char *replaceSuffix(char *input, char *newSuffix)
+/* Given a filename with a suffix, replace existing suffix with a new suffix. */
+{
+char buffer[4096];
+safecpy(buffer, sizeof buffer, input);
+char *dot = strrchr(buffer, '.');
+safecpy(dot+1, sizeof buffer - 1 - (dot - buffer), newSuffix);
+return cloneString(buffer);
+}
+
static void makeBigPsl(char *pslName, char *faName, char *db, char *outputBigBed)
/* Make a bigPsl with the blat results. */
{
-struct tempName bigPslTn;
-trashDirFile(&bigPslTn, "hgBlat", "bp", ".bigPsl");
+char *bigPslFile = replaceSuffix(outputBigBed, "bigPsl");
char cmdBuffer[4096];
-safef(cmdBuffer, sizeof(cmdBuffer), "loader/pslToBigPsl %s -fa=%s stdout | sort -k1,1 -k2,2n > %s", pslName, faName, bigPslTn.forCgi);
+safef(cmdBuffer, sizeof(cmdBuffer), "loader/pslToBigPsl %s -fa=%s stdout | sort -k1,1 -k2,2n > %s", pslName, faName, bigPslFile);
system(cmdBuffer);
char buf[4096];
char *twoBitDir;
if (trackHubDatabase(db))
{
struct trackHubGenome *genome = trackHubGetGenome(db);
twoBitDir = genome->twoBitPath;
}
else
{
safef(buf, sizeof(buf), "/gbdb/%s", db);
twoBitDir = hReplaceGbdbSeqDir(buf, db);
safef(buf, sizeof(buf), "%s%s.2bit", twoBitDir, db);
twoBitDir = buf;
}
safef(cmdBuffer, sizeof(cmdBuffer), "loader/bedToBigBed -verbose=0 -udcDir=%s -extraIndex=name -sizesIs2Bit -tab -as=loader/bigPsl.as -type=bed9+16 %s %s %s",
- udcDefaultDir(), bigPslTn.forCgi, twoBitDir, outputBigBed);
+ udcDefaultDir(), bigPslFile, twoBitDir, outputBigBed);
system(cmdBuffer);
-unlink(bigPslTn.forCgi);
+unlink(bigPslFile);
}
void showAliPlaces(char *pslName, char *faName, char *customText, char *database,
enum gfType qType, enum gfType tType,
char *organism, boolean feelingLucky)
/* Show all the places that align. */
{
struct lineFile *lf = pslFileOpen(pslName);
struct psl *pslList = NULL, *psl;
char *browserUrl = hgTracksName();
char *hgcUrl = hgcName();
char uiState[64];
char *vis;
char unhideTrack[64];
char *sort = cartUsualString(cart, "sort", sortList[0]);
@@ -597,55 +606,55 @@
}
else
{
safef(shortName, sizeof shortName, "blat %s+%d", names->name, count - 1);
safef(description, sizeof description, "blat on %d queries (%s, %s, ...)", count, names->name, names->next->name);
}
*pName = makeNameUnique(shortName, database, cart);
*pDescription = cloneString(description);
}
static char *outBigPsl(char *db, struct psl *pslList, char *pslFilename, char *faFilename, boolean isProt)
// Make a bigPsl from a list of psls and return its name.
{
struct tempName bigBedTn;
-trashDirFile(&bigBedTn, "hgBlat", "bp", ".bb");
-makeBigPsl(pslFilename, faFilename, db, bigBedTn.forCgi);
-struct tempName customTextTn;
-trashDirFile(&customTextTn, "hgBlat", "ct", ".txt");
-FILE *fp = fopen(customTextTn.forCgi, "w");
+trashDirDateFile(&bigBedTn, "hgBlat", "bp", ".bb");
+char *bigBedFile = bigBedTn.forCgi;
+makeBigPsl(pslFilename, faFilename, db, bigBedFile);
+char *customTextFile = replaceSuffix(bigBedFile, "txt");
+FILE *fp = fopen(customTextFile, "w");
char* host = getenv("HTTP_HOST");
char* reqUrl = getenv("REQUEST_URI");
// remove everything after / in URL
char *e = strrchr(reqUrl, '/');
if (e) *e = 0;
char *trackName = NULL;
char *trackDescription = NULL;
getCustomName(db, cart, pslList, &trackName, &trackDescription);
-char *customTextTemplate = "track type=bigPsl visibility=pack showAll=on htmlUrl=http://%s/goldenPath/help/hgUserPsl.html %s bigDataUrl=http://%s/%s/%s name=\"%s\" description=\"%s\"\n";
+char *customTextTemplate = "track type=bigPsl ctpsl_%s=%s visibility=pack showAll=on htmlUrl=http://%s/goldenPath/help/hgUserPsl.html %s bigDataUrl=http://%s%s/%s name=\"%s\" description=\"%s\"\n";
char *extraForMismatch = "showDiffBasesAllScales=. baseColorUseSequence=lfExtra baseColorDefault=diffBases";
if (isProt)
extraForMismatch = "";
-fprintf(fp, customTextTemplate, host, extraForMismatch, host, reqUrl, bigBedTn.forCgi, trackName, trackDescription);
+fprintf(fp, customTextTemplate, db, bigBedTn.forCgi, host, extraForMismatch, host, reqUrl, bigBedTn.forCgi, trackName, trackDescription);
fclose(fp);
char buffer[4096];
-safef(buffer, sizeof buffer, "http://%s/%s/%s", host, reqUrl, customTextTn.forCgi);
+safef(buffer, sizeof buffer, "http://%s/%s/%s", host, reqUrl, customTextFile);
return cloneString(buffer);
}
void blatSeq(char *userSeq, char *organism, char *database)
/* Blat sequence user pasted in. */
{
boolean doHyper = sameString(cartUsualString(cart, "output", outputList[0]), "hyperlink");;
boolean useBigPsl = cfgOptionBooleanDefault("useBlatBigPsl", FALSE) && doHyper;
FILE *f;
struct dnaSeq *seqList = NULL, *seq;
struct tempName pslTn, faTn;
int maxSingleSize, maxTotalSize, maxSeqCount;
int minSingleSize = minMatchShown;
char *genome, *db;