4a030195664cbdd1d3c1a4b81b1ed41dbf6d9bc5
angie
Fri Feb 15 14:02:58 2019 -0800
Prevent hgFind lib (specifically genomePos -> hgPositionsHtml) from opening a web page; instead, pass up results and warning messages to the calling CGI so it can open the page its own way. refs #22945
hgTracks, hgTables and hgVai used to call findGenomePos{,Web} to resolve positions; hgTables and hgVai had to detect after the fact whether an HTML page had been started (with warnings and/or multiple results).
In fact, hgPositionsHtml called webEnd which could cause conflicts with what the CGI was doing afterwards.
Now, instead of findGenomePos{,Web} there is hgFindSearch which returns hgp and also warning messages, if any, via a dyString parameter.
The calling CGI decides how to open the page if necessary (for hgTracks, it's already open) and displays warnings/multiple results -- or just proceeds as usual with the single position result.
diff --git src/hg/hgVai/hgVai.c src/hg/hgVai/hgVai.c
index c4f3862..109760f 100644
--- src/hg/hgVai/hgVai.c
+++ src/hg/hgVai/hgVai.c
@@ -26,30 +26,31 @@
#include "trackHub.h"
#include "hubConnect.h"
#include "twoBit.h"
#include "gpFx.h"
#include "bigGenePred.h"
#include "udc.h"
#include "knetUdc.h"
#include "md5.h"
#include "regexHelper.h"
#include "hAnno.h"
#include "annoGratorQuery.h"
#include "annoGratorGpVar.h"
#include "annoFormatVep.h"
#include "annoStreamBigBed.h"
#include "annoStreamDb.h"
+#include "annoStreamVcf.h"
#include "windowsToAscii.h"
#include "obscure.h"
#include "libifyMe.h"
#define GENCODE_TAG_DOC_URL "\"http://www.gencodegenes.org/gencode_tags.html\""
#define GENCODE_BASIC_DOC_URL "\"http://www.gencodegenes.org/faq.html\""
#define REFSEQ_STATUS_DOC_URL "\"https://www.ncbi.nlm.nih.gov/books/NBK21091/table/ch18.T.refseq_status_codes\""
#define APPRIS_DOC_URL "\"http://appris.bioinfo.cnio.es/#/help/database\""
#define HGVS_MUST_USE_ACC "Note: HGVS terms must use versioned transcript or genomic accessions " \
"(e.g. NM_000023.3, NC_000012.11, ENST00000000233.9), not gene symbols."
/* Global Variables */
struct cart *cart; /* CGI and other variables */
@@ -2983,30 +2984,43 @@
struct annoGratorQuery *query = annoGratorQueryNew(assembly, primary, gratorList, vepOut);
struct slName *comment;
for (comment = commentList; comment != NULL; comment = comment->next)
vepOut->comment(vepOut, comment->name);
if (chrom != NULL)
annoGratorQuerySetRegion(query, chrom, start, end);
annoGratorQueryExecute(query);
annoGratorQueryFree(&query);
if (doHtml)
webEnd();
else if (! isCommandLine)
textOutClose(&compressPipeline, NULL);
}
+struct hgPositions *lookupPosition(struct dyString *dyWarn)
+/* Look up position (aka range) if need be. Return a container of matching tables and positions.
+ * Warnings/errors are appended to dyWarn. */
+{
+char *range = windowsToAscii(cloneString(cartUsualString(cart, hgvaRange, "")));
+range = trimSpaces(range);
+if (isEmpty(range))
+ range = hDefaultPos(database);
+struct hgPositions *hgp = hgFindSearch(cart, &range, NULL, NULL, NULL, cgiScriptName(), dyWarn);
+cartSetString(cart, hgvaRange, range);
+return hgp;
+}
+
int main(int argc, char *argv[])
/* Process command line. */
{
long enteredMainTime = clock1000();
if (hIsPrivateHost())
pushCarefulMemHandler(LIMIT_2or6GB);
cgiSpoof(&argc, argv);
boolean isCommandLine = (cgiOptionalString("cgiSpoof") != NULL);
if (!isCommandLine)
htmlPushEarlyHandlers(); /* Make errors legible during initialization. */
oldVars = hashNew(10);
boolean startQuery = (cgiUsualString("hgva_startQuery", NULL) != NULL);
if (startQuery)
{
@@ -3026,43 +3040,45 @@
/* Set up global variables. */
getDbAndGenome(cart, &database, &genome, oldVars);
initGenbankTableNames(database);
regionType = cartUsualString(cart, hgvaRegionType, hgvaRegionTypeGenome);
if (isEmpty(cartOptionalString(cart, hgvaRange)))
cartSetString(cart, hgvaRange, hDefaultPos(database));
int timeout = cartUsualInt(cart, "udcTimeout", 300);
if (udcCacheTimeout() < timeout)
udcSetCacheTimeout(timeout);
knetUdcInstall();
char *range = trimSpaces(windowsToAscii(cartUsualString(cart, hgvaRange, "")));
cartSetLastPosition(cart, range, oldVars);
cartTrackDbInit(cart, &fullTrackList, &fullGroupList, TRUE);
-if (lookupPosition(cart, hgvaRange))
+struct dyString *dyWarn = dyStringNew(0);
+struct hgPositions *hgp = lookupPosition(dyWarn);
+if (hgp->singlePos && isEmpty(dyWarn->string))
{
if (startQuery)
doQuery();
else if (! isCommandLine)
doUi();
}
else
{
- // Revert to lastPosition if we have multiple matches or warnings,
- // especially in case user manually edits browser location as in #13009:
- char *position = cartUsualString(cart, "lastPosition", hDefaultPos(database));
- cartSetString(cart, hgvaRange, position);
- if (webGotWarnings())
- {
- // We land here when lookupPosition pops up a warning box.
- // Reset the problematic position and show the main page.
+ if (startQuery)
+ // Need Content-type (html)
+ cartWebStartHeader(cart, database, "Variant Annotation Integrator");
+ else
+ cartWebStart(cart, database, "Variant Annotation Integrator");
+ if (isNotEmpty(dyWarn->string))
+ warn("%s", dyWarn->string);
+ if (hgp->posCount > 1)
+ hgPositionsHtml(database, hgp, hgVaiName(), cart);
+ else
doMainPage();
- }
- // If lookupPosition returned FALSE and didn't report warnings,
- // then it wrote HTML showing multiple position matches & links.
+ cartWebEnd();
}
cartCheckout(&cart);
if (! isCommandLine)
cgiExitTime("hgVai", enteredMainTime);
return 0;
}