3a5ceb6cf9b3a4869e57ab621d1143fbd0573a5a
braney
Wed Nov 23 17:01:52 2016 -0800
implements blat results to custom track using bigPsl. Requires hg.conf
variable useBlatBigPsl=on, otherwise old behavior exists
diff --git src/hg/hgBlat/hgBlat.c src/hg/hgBlat/hgBlat.c
index eea2f90..ff85069 100644
--- src/hg/hgBlat/hgBlat.c
+++ src/hg/hgBlat/hgBlat.c
@@ -12,30 +12,31 @@
#include "fa.h"
#include "psl.h"
#include "genoFind.h"
#include "cheapcgi.h"
#include "htmshell.h"
#include "hdb.h"
#include "hui.h"
#include "cart.h"
#include "dbDb.h"
#include "blatServers.h"
#include "web.h"
#include "hash.h"
#include "botDelay.h"
#include "trashDir.h"
#include "trackHub.h"
+#include "hgConfig.h"
struct cart *cart; /* The user's ui state. */
struct hash *oldVars = NULL;
boolean orgChange = FALSE;
boolean dbChange = FALSE;
struct serverTable
/* Information on a server. */
{
char *db; /* Database name. */
char *genome; /* Genome name. */
boolean isTrans; /* Is tranlated to protein? */
char *host; /* Name of machine hosting server. */
char *port; /* Port that hosts server. */
@@ -250,31 +251,46 @@
{
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();
}
-void showAliPlaces(char *pslName, char *faName, char *database,
+static void makeBigPsl(char *pslName, char *faName, char *db, char *outputBigBed)
+/* Make a bigPsl with the blat results. */
+{
+struct tempName bigPslTn;
+trashDirFile(&bigPslTn, "bigPsl", "bp", ".bigPsl");
+
+char cmdBuffer[4096];
+safef(cmdBuffer, sizeof(cmdBuffer), "loader/pslToBigPsl %s -fa=%s stdout | sort -k1,1 -k2,2n > %s", pslName, faName, bigPslTn.forCgi);
+system(cmdBuffer);
+safef(cmdBuffer, sizeof(cmdBuffer), "loader/bedToBigBed -extraIndex=name -tab -as=loader/bigPsl.as -type=bed12+13 %s http://hgdownload.cse.ucsc.edu/goldenPath/%s/bigZips/%s.chrom.sizes %s",
+ bigPslTn.forCgi, db, db, outputBigBed);
+system(cmdBuffer);
+unlink(bigPslTn.forCgi);
+}
+
+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]);
char *output = cartUsualString(cart, "output", outputList[0]);
boolean pslOut = startsWith("psl", output);
boolean isStraightNuc = (qType == gftRna || qType == gftDna);
@@ -324,55 +340,60 @@
}
else
{
slSort(&pslList, pslCmpQueryScore);
}
if(feelingLucky)
{
/* If we found something jump browser to there. */
if(slCount(pslList) > 0)
printLuckyRedirect(browserUrl, pslList, database, pslName, faName, uiState, unhideTrack);
/* Otherwise call ourselves again not feeling lucky to print empty
results. */
else
{
cartWebStart(cart, database, "%s BLAT Results", trackHubSkipHubName(organism));
- showAliPlaces(pslName, faName, database, qType, tType, organism, FALSE);
+ showAliPlaces(pslName, faName, customText, database, qType, tType, organism, FALSE);
cartWebEnd();
}
}
else if (pslOut)
{
printf("");
if (!sameString(output, "psl no header"))
pslxWriteHead(stdout, qType, tType);
for (psl = pslList; psl != NULL; psl = psl->next)
pslTabOut(psl, stdout);
printf("
");
}
else
{
printf("
Go back to %s on the Genome Browser.
\n", browserUrl, posStr); printf(""); printf(" ACTIONS QUERY SCORE START END QSIZE IDENTITY CHRO STRAND START END SPAN\n"); printf("---------------------------------------------------------------------------------------------------\n"); for (psl = pslList; psl != NULL; psl = psl->next) { + if (customText) + printf("", + browserUrl, psl->tName, psl->tStart + 1, psl->tEnd, database, + customText, uiState, unhideTrack); + else printf("", browserUrl, psl->tName, psl->tStart + 1, psl->tEnd, database, pslName, faName, uiState, unhideTrack); printf("browser "); printf("", hgcUrl, psl->tStart, pslName, cgiEncode(faName), psl->qName, psl->tName, psl->tStart, psl->tEnd, database, uiState); printf("details "); printf("%-14s %5d %5d %5d %5d %5.1f%% %4s %2s %9d %9d %6d\n", psl->qName, pslScore(psl), psl->qStart+1, psl->qEnd, psl->qSize, 100.0 - pslCalcMilliBad(psl, TRUE) * 0.1, skipChr(psl->tName), psl->strand, psl->tStart+1, psl->tEnd, psl->tEnd - psl->tStart); } printf("\n"); @@ -479,33 +500,63 @@ int i, size = seq->size, count = 0; char *s = seq->dna; for (i=0; i
Note: BLAT search is not available for %s %s; " "defaulting to %s %s