void doMiddle(struct cart *cart) /* Write body of web page. */ { struct trackDb *tdbList = NULL; char *organism = NULL; char *db = NULL; getDbAndGenome(cart, &db, &organism, NULL); char *chrom = cartUsualString(cart, "c", hDefaultChrom(db)); measureTiming = isNotEmpty(cartOptionalString(cart, "measureTiming")); // QUESTION: Do We need track list ??? trackHash ??? Can't we just get one track and no children trackHash = trackHashMakeWithComposites(db,chrom,&tdbList,FALSE); cartWebStart(cart, db, "Search for " FILE_SEARCH_WHAT " in the %s %s Assembly", organism, hFreezeFromDb(db)); webIncludeResourceFile("HGStyle.css"); webIncludeResourceFile("jquery-ui.css"); webIncludeResourceFile("ui.dropdownchecklist.css"); jsIncludeFile("jquery.js", NULL); jsIncludeFile("jquery-ui.js", NULL); jsIncludeFile("ui.dropdownchecklist.js",NULL); jsIncludeFile("utils.js",NULL); // This line is needed to get the multi-selects initialized jsIncludeFile("ddcl.js",NULL); printf("<script type='text/javascript'>$(document).ready(function() " "{ findTracks.updateMdbHelp(0); });</script>\n"); doFileSearch(db,organism,cart,tdbList); printf("<BR>\n"); webEnd(); }
void dispatchLocation() /* When this is called no output has been written at all. We * look at command variables in cart and figure out if we just * are going write an HTTP location line, which happens when we * want to invoke say the genome browser or gene sorter without * another intermediate page. If we need to do more than that * then we call hggDoUsualHttp. */ { struct sqlConnection *conn = NULL; getDbAndGenome(cart, &database, &genome, oldVars); setUdcCacheDir(); cartSetString(cart, "db", database); /* Some custom tracks code needs this */ withLabels = cartUsualBoolean(cart, hggLabels, TRUE); conn = hAllocConn(database); getGenoGraphs(conn); /* Handle cases that just want a HTTP Location line: */ if (cartVarExists(cart, hggClickX)) { clickOnImage(conn); return; } hFreeConn(&conn); /* For other cases we want to print out some of the usual HTTP * lines including content-type */ hggDoUsualHttp(); }
void dispatch() /* Look at input variables and figure out which page to show. */ { char *db, *organism; int maxSize = 4000; int minPerfect = 15; int minGood = 15; char *fPrimer = cartUsualString(cart, "wp_f", ""); char *rPrimer = cartUsualString(cart, "wp_r", ""); boolean flipReverse = cartUsualBoolean(cart, "wp_flipReverse", FALSE); struct pcrServer *serverList = getServerList(); getDbAndGenome(cart, &db, &organism, oldVars); /* Get variables. */ maxSize = cartUsualInt(cart, "wp_size", maxSize); minPerfect = cartUsualInt(cart, "wp_perfect", minPerfect); minGood = cartUsualInt(cart, "wp_good", minGood); if (minPerfect < 15) minPerfect = 15; if (minGood < minPerfect) minGood = minPerfect; /* Decide based on transient variables what page to put up. * By default put up get primer page. */ if (isNotEmpty(fPrimer) && isNotEmpty(rPrimer) && !cartVarExists(cart, "wp_showPage")) { struct pcrServer *server = NULL; struct targetPcrServer *targetServer = NULL; char *target = cartUsualString(cart, "wp_target", "genome"); if (isEmpty(target) || sameString(target, "genome")) server = findServer(db, serverList); else { targetServer = getTargetServerList(db, target); if (targetServer == NULL) errAbort("Can't find targetPcr server for db=%s, target=%s", db, target); } fPrimer = gfPcrMakePrimer(fPrimer); rPrimer = gfPcrMakePrimer(rPrimer); if (doPcr(server, targetServer, fPrimer, rPrimer, maxSize, minPerfect, minGood, flipReverse)) return; } doGetPrimers(db, organism, serverList, fPrimer, rPrimer, maxSize, minPerfect, minGood, flipReverse); }
void doMiddle(struct cart *theCart) /* Set up globals and make web page */ { char *db = NULL; char *ignored; struct trackDb *tracks; struct trackRef *tr; struct group *group, *groups = NULL; cart = theCart; cartWebStart(cart, NULL, "ENCODE Track Data Versions (%s)", db); getDbAndGenome(cart, &db, &ignored, NULL); tracks = hTrackDb(db); groups = groupTracks(db, tracks); for (group = groups; group != NULL; group = group->next) { if (group->tracks == NULL || !startsWith("encode", group->name)) continue; hTableStart(); puts("<TR>"); puts("<TH align=LEFT colspan=3 BGCOLOR=#536ED3>"); printf("<B> %s</B> ", wrapWhiteFont(group->label)); printf(" "); puts("</TH>\n"); puts("</TR>"); for (tr = group->tracks; tr != NULL; tr = tr->next) { char *version = trackDbSetting(tr->track, "dataVersion"); if (version) stripString(version, "ENCODE "); puts("<TR><TD>"); printf(" %s", tr->track->shortLabel); puts("</TD><TD>"); printf(" %s", version ? version : " "); puts("</TD><TD>"); printf(" %s", tr->track->longLabel); puts("</TD></TR>"); } /* printf("\t%s\t%s\t%s\n", version, tr->track->shortLabel, tr->track->longLabel); */ hTableEnd(); puts("<BR>"); } cartWebEnd(); }
void doMiddle(struct cart *theCart) /* Write header and body of html page. */ { char *userSeq; char *db, *organism; boolean clearUserSeq = cgiBoolean("Clear"); cart = theCart; dnaUtilOpen(); orgChange = sameOk(cgiOptionalString("changeInfo"),"orgChange"); if (orgChange) { cgiVarSet("db", hDefaultDbForGenome(cgiOptionalString("org"))); } getDbAndGenome(cart, &db, &organism, oldVars); char *oldDb = cloneString(db); findClosestServer(&db, &organism); /* Get sequence - from userSeq variable, or if * that is empty from a file. */ if (clearUserSeq) { cartSetString(cart, "userSeq", ""); cartSetString(cart, "seqFile", ""); } userSeq = cartUsualString(cart, "userSeq", ""); if (isEmpty(userSeq)) { userSeq = cartOptionalString(cart, "seqFile"); } if (isEmpty(userSeq) || orgChange) { cartWebStart(theCart, db, "%s BLAT Search", trackHubSkipHubName(organism)); if (differentString(oldDb, db)) printf("<HR><P><EM><B>Note:</B> BLAT search is not available for %s %s; " "defaulting to %s %s</EM></P><HR>\n", hGenome(oldDb), hFreezeDate(oldDb), organism, hFreezeDate(db)); askForSeq(organism,db); cartWebEnd(); } else { blatSeq(skipLeadingSpaces(userSeq), organism); } }
void cartMain(struct cart *theCart) /* We got the persistent/CGI variable cart. Now * set up the globals and make a web page. */ { struct sqlConnection *conn = NULL; cart = theCart; getDbAndGenome(cart, &database, &genome, oldCart); /* !!! force database to hiv1 until move to server hiv1 is complete and the default database of hgcentral on it point to hiv1. */ conn = hAllocConn(database); curSubjId = cgiOptionalString("hgs_subj"); if (curSubjId == NULL) curSubjId = strdup(""); cartHtmlStart("HIV Vaccine Subject View"); webMain(conn); hFreeConn(&conn); cartHtmlEnd(); }
void cartMain(struct cart *theCart) /* We got the persistent/CGI variable cart. Now * set up the globals and make a web page. */ { hgBotDelay(); cart = theCart; getDbAndGenome(cart, &database, &genome, oldVars); initGenbankTableNames(database); getGenomeSettings(); if (cartVarExists(cart, hggDoKgMethod)) doKgMethod(); else if (cartVarExists(cart, hggDoTxInfoDescription)) doTxInfoDescription(); else { struct sqlConnection *conn = NULL; char *geneName = cartUsualString(cart, hggGene, NULL); if (isEmpty(geneName)) { // Silly googlebots. hUserAbort("Error: the hgg_gene parameter is missing from the cart and the CGI params."); } /* if kgProtMap2 table exists, this means we are doing KG III */ if (hTableExists(database, "kgProtMap2")) kgVersion = KG_III; conn = hAllocConn(database); curGeneId = findGeneId(conn, geneName); getGenePosition(conn); curGenePred = getCurGenePred(conn); curGeneName = getGeneName(curGeneId, conn); spConn = hAllocConn(UNIPROT_DB_NAME); swissProtAcc = getSwissProtAcc(conn, spConn, curGeneId); if (isRgdGene(conn)) swissProtAcc=getRgdGeneUniProtAcc(curGeneId, conn); /* Check command variables, and do the ones that * don't want to put up the hot link bar etc. */ if (cartVarExists(cart, hggDoGetMrnaSeq)) doGetMrnaSeq(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoWikiTrack)) doWikiTrack(conn); else if (cartVarExists(cart, hggDoGetProteinSeq)) doGetProteinSeq(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoRnaFoldDisplay)) doRnaFoldDisplay(conn, curGeneId, curGeneName); else if (cartVarExists(cart, hggDoOtherProteinSeq)) doOtherProteinSeq(conn, curGeneName); else if (cartVarExists(cart, hggDoOtherProteinAli)) doOtherProteinAli(conn, curGeneId, curGeneName); else { /* Default case - start fancy web page. */ measureTiming = isNotEmpty(cartOptionalString(cart, "measureTiming")); struct trackDb *tdb = hTrackDbForTrack(database, genomeSetting("knownGene")); isGencode = trackDbSettingOn(tdb, "isGencode"); isGencode2 = trackDbSettingOn(tdb, "isGencode2"); cartWebStart(cart, database, "%s Gene %s (%s) Description and Page Index", genome, curGeneName, isGencode2 ? curGeneId : curAlignId); webMain(conn, tdb); cartWebEnd(); } hFreeConn(&spConn); hFreeConn(&conn); } cartRemovePrefix(cart, hggDoPrefix); }
void blatSeq(char *userSeq, char *organism) /* Blat sequence user pasted in. */ { FILE *f; struct dnaSeq *seqList = NULL, *seq; struct tempName pslTn, faTn; int maxSingleSize, maxTotalSize, maxSeqCount; int minSingleSize = minMatchShown; char *genome, *db; char *type = cgiString("type"); char *seqLetters = cloneString(userSeq); struct serverTable *serve; int conn; int oneSize, totalSize = 0, seqCount = 0; boolean isTx = FALSE; boolean isTxTx = FALSE; boolean txTxBoth = FALSE; struct gfOutput *gvo; boolean qIsProt = FALSE; enum gfType qType, tType; struct hash *tFileCache = gfFileCacheNew(); boolean feelingLucky = cgiBoolean("Lucky"); getDbAndGenome(cart, &db, &genome, oldVars); if(!feelingLucky) cartWebStart(cart, db, "%s BLAT Results", trackHubSkipHubName(organism)); /* Load user sequence and figure out if it is DNA or protein. */ if (sameWord(type, "DNA")) { seqList = faSeqListFromMemText(seqLetters, TRUE); uToT(seqList); isTx = FALSE; } else if (sameWord(type, "translated RNA") || sameWord(type, "translated DNA")) { seqList = faSeqListFromMemText(seqLetters, TRUE); uToT(seqList); isTx = TRUE; isTxTx = TRUE; txTxBoth = sameWord(type, "translated DNA"); } else if (sameWord(type, "protein")) { seqList = faSeqListFromMemText(seqLetters, FALSE); isTx = TRUE; qIsProt = TRUE; } else { seqList = faSeqListFromMemTextRaw(seqLetters); isTx = !seqIsDna(seqList); if (!isTx) { for (seq = seqList; seq != NULL; seq = seq->next) { seq->size = dnaFilteredSize(seq->dna); dnaFilter(seq->dna, seq->dna); toLowerN(seq->dna, seq->size); subChar(seq->dna, 'u', 't'); } } else { for (seq = seqList; seq != NULL; seq = seq->next) { seq->size = aaFilteredSize(seq->dna); aaFilter(seq->dna, seq->dna); toUpperN(seq->dna, seq->size); } qIsProt = TRUE; } } if (seqList != NULL && seqList->name[0] == 0) { freeMem(seqList->name); seqList->name = cloneString("YourSeq"); } trimUniq(seqList); /* If feeling lucky only do the first on. */ if(feelingLucky && seqList != NULL) { seqList->next = NULL; } /* Figure out size allowed. */ maxSingleSize = (isTx ? 10000 : 75000); maxTotalSize = maxSingleSize * 2.5; #ifdef LOWELAB maxSeqCount = 200; #else maxSeqCount = 25; #endif /* Create temporary file to store sequence. */ trashDirFile(&faTn, "hgSs", "hgSs", ".fa"); faWriteAll(faTn.forCgi, seqList); /* Create a temporary .psl file with the alignments against genome. */ trashDirFile(&pslTn, "hgSs", "hgSs", ".pslx"); f = mustOpen(pslTn.forCgi, "w"); gvo = gfOutputPsl(0, qIsProt, FALSE, f, FALSE, TRUE); serve = findServer(db, isTx); /* Write header for extended (possibly protein) psl file. */ if (isTx) { if (isTxTx) { qType = gftDnaX; tType = gftDnaX; } else { qType = gftProt; tType = gftDnaX; } } else { qType = gftDna; tType = gftDna; } pslxWriteHead(f, qType, tType); if (qType == gftProt) { minSingleSize = 14; } else if (qType == gftDnaX) { minSingleSize = 36; } /* Loop through each sequence. */ for (seq = seqList; seq != NULL; seq = seq->next) { printf(" "); fflush(stdout); /* prevent apache cgi timeout by outputting something */ oneSize = realSeqSize(seq, !isTx); if ((seqCount&1) == 0) // Call bot delay every 2nd time starting with first time hgBotDelay(); if (++seqCount > maxSeqCount) { warn("More than 25 input sequences, stopping at %s.", seq->name); break; } if (oneSize > maxSingleSize) { warn("Sequence %s is %d letters long (max is %d), skipping", seq->name, oneSize, maxSingleSize); continue; } if (oneSize < minSingleSize) { warn("Warning: Sequence %s is only %d letters long (%d is the recommended minimum)", seq->name, oneSize, minSingleSize); // we could use "continue;" here to actually enforce skipping, // but let's give the short sequence a chance, it might work. // minimum possible length = tileSize+stepSize, so mpl=16 for dna stepSize=5, mpl=10 for protein. if (qIsProt && oneSize < 1) // protein does not tolerate oneSize==0 continue; } totalSize += oneSize; if (totalSize > maxTotalSize) { warn("Sequence %s would take us over the %d letter limit, stopping here.", seq->name, maxTotalSize); break; } conn = gfConnect(serve->host, serve->port); if (isTx) { gvo->reportTargetStrand = TRUE; if (isTxTx) { gfAlignTransTrans(&conn, serve->nibDir, seq, FALSE, 5, tFileCache, gvo, !txTxBoth); if (txTxBoth) { reverseComplement(seq->dna, seq->size); conn = gfConnect(serve->host, serve->port); gfAlignTransTrans(&conn, serve->nibDir, seq, TRUE, 5, tFileCache, gvo, FALSE); } } else { gfAlignTrans(&conn, serve->nibDir, seq, 5, tFileCache, gvo); } } else { gfAlignStrand(&conn, serve->nibDir, seq, FALSE, minMatchShown, tFileCache, gvo); reverseComplement(seq->dna, seq->size); conn = gfConnect(serve->host, serve->port); gfAlignStrand(&conn, serve->nibDir, seq, TRUE, minMatchShown, tFileCache, gvo); } gfOutputQuery(gvo, f); } carefulClose(&f); showAliPlaces(pslTn.forCgi, faTn.forCgi, serve->db, qType, tType, organism, feelingLucky); if(!feelingLucky) cartWebEnd(); gfFileCacheFree(&tFileCache); }
static void webStartWrapperDetailedInternal(struct cart *theCart, char *db, char *headerText, char *textOutBuf, boolean withHttpHeader, boolean withLogo, boolean skipSectionHeader, boolean withHtmlHeader) /* output a CGI and HTML header with the given title in printf format */ { char uiState[256]; char *scriptName = cgiScriptName(); boolean isEncode = FALSE; if (theCart) { char *theGenome = NULL; char *genomeEnc = NULL; getDbAndGenome(theCart, &db, &theGenome, NULL); genomeEnc = cgiEncode(theGenome); safef(uiState, sizeof(uiState), "?%s=%s&%s=%s&%s=%u", orgCgiName, genomeEnc, dbCgiName, db, cartSessionVarName(), cartSessionId(theCart)); } else { uiState[0] = 0; uiState[1] = 0; } if (db == NULL) db = hDefaultDb(); boolean dbIsFound = hDbExists(db); boolean haveBlat = FALSE; if (dbIsFound) haveBlat = hIsBlatIndexedDatabase(db); if (scriptName == NULL) scriptName = cloneString(""); /* don't output two headers */ if(webHeadAlreadyOutputed) return; if (sameString(cgiUsualString("action",""),"encodeReleaseLog") || rStringIn("EncodeDataVersions", scriptName)) isEncode = TRUE; /* Preamble. */ dnaUtilOpen(); if (withHttpHeader) puts("Content-type:text/html\n"); if (withHtmlHeader) { char *newString, *ptr1, *ptr2; char *browserVersion; if (btIE == cgiClientBrowser(&browserVersion, NULL, NULL) && *browserVersion < '8') puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"); else puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " "\"http://www.w3.org/TR/html4/loose.dtd\">"); // Strict would be nice since it fixes atleast one IE problem (use of :hover CSS pseudoclass) puts( "<HTML>" "\n" "<HEAD>" "\n" ); printf("\t%s\n", headerText); printf("\t<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;CHARSET=iso-8859-1\">" "\n" "\t<META http-equiv=\"Content-Script-Type\" content=\"text/javascript\">" "\n" "\t<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" "\n" "\t<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">" "\n" "\t<TITLE>" ); /* we need to take any HTML formatting out of the titlebar string */ newString = cloneString(textOutBuf); for(ptr1=newString, ptr2=textOutBuf; *ptr2 ; ptr2++) { if (*ptr2 == '<') { for(; *ptr2 && (*ptr2 != '>'); ptr2++) ; } else *ptr1++ = *ptr2; } *ptr1 = 0; htmlTextOut(newString); printf(" </TITLE>\n "); webIncludeResourceFile("HGStyle.css"); if (extraStyle != NULL) puts(extraStyle); printf("</HEAD>\n"); printBodyTag(stdout); htmlWarnBoxSetup(stdout);// Sets up a warning box which can be filled with errors as they occur puts(commonCssStyles()); } puts( "<A NAME=\"TOP\"></A>" "\n" "" "\n" "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100%\">" "\n"); if (withLogo) { puts("<TR><TH COLSPAN=1 ALIGN=\"left\">"); if (isEncode) { puts("<A HREF=\"http://www.genome.gov/10005107\" TARGET=\"_BLANK\">" "<IMG SRC=\"../images/ENCODE_scaleup_logo.png\" height=50 ALT=\"ENCODE Project at NHGRI\">" "</A>"); puts("<IMG SRC=\"../images/encodeDcc.jpg\" ALT=\"ENCODE Project at UCSC\">"); } else { puts("<IMG SRC=\"../images/title.jpg\">"); } puts("</TH></TR>" "\n" "" "\n" ); } /* Put up the hot links bar. */ char *menuStr = menuBar(theCart); if(menuStr) { puts(menuStr); } if (endsWith(scriptName, "hgGateway") && geoMirrorEnabled()) { // Show an opt-out alert if user is on a host to which user has been automatically redirected (just once, right after they have been redirected) char *source = cgiOptionalString("source"); char *redirect = cgiOptionalString("redirect"); if (source != NULL && redirect != NULL && sameString(redirect, "auto")) { char *domain = cgiServerName(); char *port = cgiServerPort(); // We don't bother maintaining stuff in request URI, because it may contain items like hgsid and other host specific values int newUriSize = 2048; char *newUri = needMem(newUriSize); safef(newUri, newUriSize, "http%s://%s:%s/cgi-bin/hgGateway?redirect=manual&source=%s", cgiServerHttpsIsOn() ? "s" : "", source, port, domain); printf("<TR><TD COLSPAN=3 id='redirectTd' onclick=\"javascript:document.getElementById('redirectTd').innerHTML='';\">" "<div style=\"margin: 10px 25%%; border-style:solid; border-width:thin; border-color:#97D897;\">" "<h3 style=\"background-color: #97D897; text-align: left; margin-top:0px; margin-bottom:0px;\">" " You've been redirected to your nearest mirror - %s" "<idiv style=\"float:right;\">[x]</idiv>" "</h3> " "<ul style=\"margin:5px;\">" "<li>Take me back to <a href=\"%s\">%s</a>" "<idiv style=\"float:right;\"><a href=\"../goldenPath/help/genomeEuro.html\">What is this?</a></idiv>" "</li>" "</ul>" "</div>" "</TD></TR>\n" , domain, newUri, source ); } } if(!skipSectionHeader) /* this HTML must be in calling code if skipSectionHeader is TRUE */ { puts( // TODO: Replace nested tables with CSS (difficulty is that tables are closed elsewhere) "<!-- +++++++++++++++++++++ CONTENT TABLES +++++++++++++++++++ -->" "\n" "<TR><TD COLSPAN=3>\n" "<div id=firstSection>" " <!--outer table is for border purposes-->\n" " <TABLE WIDTH='100%' BGCOLOR='#" HG_COL_BORDER "' BORDER='0' CELLSPACING='0' " "CELLPADDING='1'><TR><TD>\n" " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' BORDER='0' CELLSPACING='0' " "CELLPADDING='0'><TR><TD>\n" " <div class='subheadingBar'><div class='windowSize' id='sectTtl'>" ); htmlTextOut(textOutBuf); puts(" </div></div>\n" " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' CELLPADDING=0>" "<TR><TH HEIGHT=10></TH></TR>\n" " <TR><TD WIDTH=10> </TD><TD>\n\n" ); }; webPushErrHandlers(); /* set the flag */ webHeadAlreadyOutputed = TRUE; } /* static void webStartWrapperDetailedInternal() */
int main(int argc, char *argv[]) /* Process command line. */ { pushCarefulMemHandler(100000000); cgiSpoof(&argc, argv); htmlSetStyle(htmlStyleUndecoratedLink); htmlSetBgColor(HG_CL_OUTSIDE); oldCart = hashNew(10); cart = cartAndCookie(hUserCookie(), excludeVars, oldCart); getDbAndGenome(cart, &database, &genome, oldCart); //hSetDb(database); conn = hAllocConn(database); database = strdup("h1n1"); /* Get sortOn. Revert to default by subject Id. */ orderOn = cartUsualString(cart, orderVarName, "+subjId"); displayCountString = cartUsualString(cart, countVarName, "50"); if (sameString(displayCountString, "all")) displayCount = BIGNUM; else displayCount = atoi(displayCountString); colList = getColumns(conn); if (cgiVarExists("submit_filter")) { struct dyString *head = dyStringNew(1024); boolean redir = cgiVarExists(redirectName); struct subjInfo *subjList = NULL; struct column *ordList = colList; struct column *ord = curOrder(ordList); subjList = getOrderedList(ord, colList, conn, BIGNUM); saveSubjList(subjList); if ((!subjList || redir)) { if (subjList && redir) { dyStringPrintf(head, "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=/cgi-bin/%s\">" "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" "<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">" , cgiString(redirectName)); cartRemove(cart, redirectName); } htmStartWithHead(stdout, head->string, "GISAID Table View"); if (!subjList) /* if everything has been filtered out, we'll have to go back */ { hPrintf("No subject(s) found with the filtering conditions specified.<br>"); hPrintf("Click <a href=\"gisaidTable?gisaidTable.do.advFilter=filter+%%28now+on%%29\">here</a> " "to return to Select Subjects.<br>"); } cartCheckout(&cart); htmlEnd(); hFreeConn(&conn); return 0; } } htmStart(stdout, "GISAID Table View"); cartWarnCatcher(doMiddle, cart, htmlVaWarn); cartCheckout(&cart); htmlEnd(); hFreeConn(&conn); return 0; }
void doMiddle(struct cart *theCart) /* Set up pretty web display. */ { struct sqlConnection *conn, *conn2; struct sqlConnection *connCentral = hConnectCentral(); char query[256], query2[256]; struct sqlResult *sr, *sr2; char **row, **row2; char buf[128]; char *answer; char *database; char *genome, *genomeDesc; char *kgID, *chrom, *txStart, *txEnd; int iCnt = 1; cart = theCart; cartWebStart(theCart, database, "UCSC Known Genes List \n"); getDbAndGenome(cart, &database, &genome, oldVars); if (!hTableExistsDb(database, "knownGene")) { printf("<br>Database %s currently does not have UCSC Known Genes.", database); cartWebEnd(); return; } sprintf(query, "select description from dbDb where name = '%s'", database); genomeDesc = strdup(sqlQuickQuery(connCentral, query, buf, sizeof(buf))); hDisconnectCentral(&connCentral); printf("<H2>%s Genome (%s Assembly)</H2>\n", genome, genomeDesc); conn = hAllocConn(database); conn2= hAllocConn(database); sprintf(query2,"select kgID from %s.kgXref order by geneSymbol;", database); /* use the following for quck testing */ /*sprintf(query2,"select kgID, geneSymbol, description, spID, refseq from %s.kgXref order by geneSymbol limit 10;", database); */ sr2 = sqlMustGetResult(conn2, query2); row2 = sqlNextRow(sr2); while (row2 != NULL) { kgID = row2[0]; sprintf(query,"select chrom, txSTart, txEnd from %s.knownGene where name='%s'", database, kgID); sr = sqlMustGetResult(conn, query); row = sqlNextRow(sr); chrom = row[0]; txStart = row[1]; txEnd = row[2]; printf("<A href=\"/cgi-bin/hgGene?db=%s&hgg_gene=%s", database, kgID); printf("&hgg_chrom=%s&hgg_start=%s&hgg_end=%s\">", chrom, txStart, txEnd); printf("%d</A><BR>\n", iCnt); iCnt++; if ((iCnt % 1000) == 0) fflush(stdout); sqlFreeResult(&sr); row2 = sqlNextRow(sr2); } sqlFreeResult(&sr2); cartWebEnd(); }
void doMiddle(struct cart *theCart) /* Set up globals and make web page */ { /* struct liftOverChain *chainList = NULL, *chain; */ char *userData; /* char *dataFile; */ char *dataFormat; char *organism; char *db; float minBlocks, minMatch; boolean multiple, fudgeThick; int minSizeQ, minSizeT; boolean refreshOnly = FALSE; /* char *err = NULL; */ struct liftOverChain *chainList = NULL, *choice; cart = theCart; if (cgiOptionalString(HGLFT_ERRORHELP_VAR)) { puts("<PRE>"); puts(liftOverErrHelp()); //system("/usr/bin/cal"); puts("</PRE>"); return; } /* Get data to convert - from userData variable, or if * that is empty from a file. */ if (cartOptionalString(cart, "SubmitFile")) userData = cartOptionalString(cart, HGLFT_DATAFILE_VAR); else userData = cartOptionalString(cart, HGLFT_USERDATA_VAR); dataFormat = cartCgiUsualString(cart, HGLFT_DATAFORMAT_VAR, DEFAULT_FORMAT); cartWebStart(cart, NULL, "Lift Genome Annotations"); getDbAndGenome(cart, &db, &organism, oldVars); chainList = liftOverChainListFiltered(); choice = defaultChoices(chainList, db); if (choice == NULL) errAbort("Sorry, no conversions available from this assembly\n"); minSizeQ = cartCgiUsualInt(cart, HGLFT_MINSIZEQ, choice->minSizeQ); minSizeT = cartCgiUsualInt(cart, HGLFT_MINSIZET, choice->minSizeT); minBlocks = cartCgiUsualDouble(cart, HGLFT_MINBLOCKS, choice->minBlocks); minMatch = cartCgiUsualDouble(cart, HGLFT_MINMATCH, choice->minMatch); fudgeThick = cartCgiUsualBoolean(cart, HGLFT_FUDGETHICK, (choice->fudgeThick[0]=='Y') ? TRUE : FALSE); multiple = cartCgiUsualBoolean(cart, HGLFT_MULTIPLE, (choice->multiple[0]=='Y') ? TRUE : FALSE); refreshOnly = cartCgiUsualInt(cart, HGLFT_REFRESHONLY_VAR, 0); webMain(choice, dataFormat, multiple); liftOverChainFreeList(&chainList); if (!refreshOnly && userData != NULL && userData[0] != '\0') { struct hash *chainHash = newHash(0); char *chainFile; struct tempName oldTn, mappedTn, unmappedTn; FILE *old, *mapped, *unmapped; char *line; int lineSize; char *fromDb, *toDb; int ct = 0, errCt = 0; /* read in user data and save to file */ makeTempName(&oldTn, HGLFT, ".user"); old = mustOpen(oldTn.forCgi, "w"); fputs(userData, old); fputs("\n", old); /* in case user doesn't end last line */ carefulClose(&old); chmod(oldTn.forCgi, 0666); /* setup output files -- one for converted lines, the other * for lines that could not be mapped */ makeTempName(&mappedTn, HGLFT, ".bed"); makeTempName(&unmappedTn, HGLFT, ".err"); mapped = mustOpen(mappedTn.forCgi, "w"); chmod(mappedTn.forCgi, 0666); unmapped = mustOpen(unmappedTn.forCgi, "w"); chmod(unmappedTn.forCgi, 0666); fromDb = cgiString(HGLFT_FROMDB_VAR); toDb = cgiString(HGLFT_TODB_VAR); chainFile = liftOverChainFile(fromDb, toDb); if (chainFile == NULL) errAbort("ERROR: Can't convert from %s to %s: no chain file loaded", fromDb, toDb); readLiftOverMap(chainFile, chainHash); if (sameString(dataFormat, WIGGLE_FORMAT)) /* TODO: implement Wiggle */ {} else if (sameString(dataFormat, POSITION_FORMAT)) { /* minSizeT here and in liftOverChain.c/h has been renamed minChainT in liftOver.c */ /* ignore multiple, it must be false when position is used */ ct = liftOverPositions(oldTn.forCgi, chainHash, minMatch, minBlocks, 0, minSizeQ, minSizeT, 0, fudgeThick, mapped, unmapped, FALSE, NULL, &errCt); } else if (sameString(dataFormat, BED_FORMAT)) { /* minSizeT here and in liftOverChain.c/h has been renamed minChainT in liftOver.c */ ct = liftOverBed(oldTn.forCgi, chainHash, minMatch, minBlocks, 0, minSizeQ, minSizeT, 0, fudgeThick, mapped, unmapped, multiple, NULL, &errCt); } else /* programming error */ errAbort("ERROR: Unsupported data format: %s\n", dataFormat); webNewSection("Results"); if (ct) { /* some records succesfully converted */ cgiParagraph(""); printf("Successfully converted %d record", ct); printf("%s: ", ct > 1 ? "s" : ""); printf("<A HREF=%s TARGET=_blank>View Conversions</A>\n", mappedTn.forCgi); } if (errCt) { /* some records not converted */ cgiParagraph(""); printf("Conversion failed on %d record", errCt); printf("%s. ", errCt > 1 ? "s" : ""); printf("<A HREF=%s TARGET=_blank>Display failure file</A> \n", unmappedTn.forCgi); printf("<A HREF=\"../cgi-bin/hgLiftOver?%s=1\" TARGET=_blank>Explain failure messages</A>\n", HGLFT_ERRORHELP_VAR); puts("<P>Failed input regions:\n"); struct lineFile *errFile = lineFileOpen(unmappedTn.forCgi, TRUE); puts("<BLOCKQUOTE><PRE>\n"); while (lineFileNext(errFile, &line, &lineSize)) puts(line); lineFileClose(&errFile); puts("</PRE></BLOCKQUOTE>\n"); } if (sameString(dataFormat, POSITION_FORMAT) && multiple) { puts("<BLOCKQUOTE><PRE>\n"); puts("Note: multiple checkbox ignored since it is not supported for position format."); puts("</PRE></BLOCKQUOTE>\n"); } carefulClose(&unmapped); } webDataFormats(); webDownloads(); cartWebEnd(); }
static void webStartWrapperDetailedInternal(struct cart *theCart, char *db, char *headerText, char *textOutBuf, boolean withHttpHeader, boolean withLogo, boolean skipSectionHeader, boolean withHtmlHeader) /* output a CGI and HTML header with the given title in printf format */ { char uiState[256]; char *scriptName = cgiScriptName(); boolean isEncode = FALSE; if (theCart) { char *theGenome = NULL; char *genomeEnc = NULL; getDbAndGenome(theCart, &db, &theGenome, NULL); genomeEnc = cgiEncode(theGenome); safef(uiState, sizeof(uiState), "?%s=%s&%s=%s&%s=%s", orgCgiName, genomeEnc, dbCgiName, db, cartSessionVarName(), cartSessionId(theCart)); } else { uiState[0] = 0; uiState[1] = 0; } if (db == NULL) db = hDefaultDb(); boolean dbIsFound = hDbExists(db); boolean haveBlat = FALSE; if (dbIsFound) haveBlat = hIsBlatIndexedDatabase(db); if (scriptName == NULL) scriptName = cloneString(""); /* don't output two headers */ if(webHeadAlreadyOutputed) return; if (sameString(cgiUsualString("action",""),"encodeReleaseLog") || rStringIn("EncodeDataVersions", scriptName)) isEncode = TRUE; /* Preamble. */ dnaUtilOpen(); if (withHttpHeader) puts("Content-type:text/html\n"); if (withHtmlHeader) { char *newString, *ptr1, *ptr2; char *browserVersion; if (btIE == cgiClientBrowser(&browserVersion, NULL, NULL) && *browserVersion < '8') puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"); else puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " "\"http://www.w3.org/TR/html4/loose.dtd\">"); // Strict would be nice since it fixes atleast one IE problem (use of :hover CSS pseudoclass) puts( "<HTML>" "\n" "<HEAD>" "\n" ); printf("\t%s\n", headerText); webPragmasEtc(); printf("\t<TITLE>"); /* we need to take any HTML formatting out of the titlebar string */ newString = cloneString(textOutBuf); for(ptr1=newString, ptr2=textOutBuf; *ptr2 ; ptr2++) { if (*ptr2 == '<') { for(; *ptr2 && (*ptr2 != '>'); ptr2++) ; } else *ptr1++ = *ptr2; } *ptr1 = 0; htmlTextOut(newString); printf(" </TITLE>\n "); webIncludeResourceFile("HGStyle.css"); if (extraStyle != NULL) puts(extraStyle); printf("</HEAD>\n"); printBodyTag(stdout); htmlWarnBoxSetup(stdout);// Sets up a warning box which can be filled with errors as they occur puts(commonCssStyles()); } webStartSectionTables(); if (withLogo) { puts("<TR><TH COLSPAN=1 ALIGN=\"left\">"); if (isEncode) { puts("<A HREF=\"http://www.genome.gov/10005107\" TARGET=\"_BLANK\">" "<IMG SRC=\"../images/ENCODE_scaleup_logo.png\" height=50 ALT=\"ENCODE Project at NHGRI\">" "</A>"); puts("<IMG SRC=\"../images/encodeDcc.jpg\" ALT=\"ENCODE Project at UCSC\">"); } else { puts("<IMG SRC=\"../images/title.jpg\">"); } puts("</TH></TR>" "\n" "" "\n" ); } /* Put up the hot links bar. */ char *menuStr = menuBar(theCart, db); if(menuStr) { puts(menuStr); } if(!skipSectionHeader) /* this HTML must be in calling code if skipSectionHeader is TRUE */ { webFirstSection(textOutBuf); }; webPushErrHandlers(); /* set the flag */ webHeadAlreadyOutputed = TRUE; errAbortSetDoContentType(FALSE); } /* static void webStartWrapperDetailedInternal() */
void doMiddle(struct cart *theCart) /* Write header and body of html page. */ { boolean gotDisconnect = FALSE; cart = theCart; if (cartVarExists(cart, hgHubDoClear)) { doClearHub(cart); cartWebEnd(); return; } if (cartVarExists(cart, hgHubDoDisconnect)) { gotDisconnect = TRUE; doDisconnectHub(cart); // now rebuild the cart variable ("trackHubs") that has which lists which // hubs are on. hubConnectHubsInCart(cart); } if (cartVarExists(cart, hgHubDoReset)) { doResetHub(cart); } cartWebStart(cart, NULL, "%s", pageTitle); jsIncludeFile("jquery.js", NULL); jsIncludeFile("utils.js", NULL); jsIncludeFile("jquery-ui.js", NULL); webIncludeResourceFile("jquery-ui.css"); jsIncludeFile("ajax.js", NULL); jsIncludeFile("hgHubConnect.js", NULL); jsIncludeFile("jquery.cookie.js", NULL); printf("<div id=\"hgHubConnectUI\"> <div id=\"description\"> \n"); printf( "<P>Track data hubs are collections of tracks from outside of UCSC that " "can be imported into the Genome Browser. To import a public hub check " "the box in the list below. " "After import the hub will show up as a group of tracks with its own blue " "bar and label underneath the main browser graphic, and in the " "configure page. For more information, see the " "<A HREF=\"../goldenPath/help/hgTrackHubHelp.html\" TARGET=_blank>" "User's Guide</A>.</P>\n" "<P><B>NOTE: Because Track Hubs are created and maintained by external sources," " UCSC is not responsible for their content.</B></P>" ); printf("</div>\n"); getDbAndGenome(cart, &database, &organism, oldVars); char *survey = cfgOptionEnv("HGDB_HUB_SURVEY", "hubSurvey"); char *surveyLabel = cfgOptionEnv("HGDB_HUB_SURVEY_LABEL", "hubSurveyLabel"); if (survey && differentWord(survey, "off")) hPrintf("<span style='background-color:yellow;'><A HREF='%s' TARGET=_BLANK><EM><B>%s</EM></B></A></span>\n", survey, surveyLabel ? surveyLabel : "Take survey"); hPutc('\n'); // check to see if we have any new hubs hubCheckForNew(cart); // grab all the hubs that are listed in the cart struct hubConnectStatus *hubList = hubConnectStatusListFromCartAll(cart); checkTrackDbs(hubList); // here's a little form for the add new hub button printf("<FORM ACTION=\"%s\" NAME=\"addHubForm\">\n", "../cgi-bin/hgHubConnect"); cgiMakeHiddenVar("hubUrl", ""); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); puts("</FORM>"); // this the form for the disconnect hub button printf("<FORM ACTION=\"%s\" NAME=\"disconnectHubForm\">\n", "../cgi-bin/hgHubConnect"); cgiMakeHiddenVar("hubId", ""); cgiMakeHiddenVar(hgHubDoDisconnect, "on"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); puts("</FORM>"); // this the form for the reset hub button printf("<FORM ACTION=\"%s\" NAME=\"resetHubForm\">\n", "../cgi-bin/hgHubConnect"); cgiMakeHiddenVar("hubUrl", ""); cgiMakeHiddenVar(hgHubDoReset, "on"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); puts("</FORM>"); // ... and now the main form if (cartVarExists(cart, hgHubConnectCgiDestUrl)) destUrl = cartOptionalString(cart, hgHubConnectCgiDestUrl); printf("<FORM ACTION=\"%s\" METHOD=\"POST\" NAME=\"mainForm\">\n", destUrl); cartSaveSession(cart); // we have two tabs for the public and unlisted hubs printf("<div id=\"tabs\">" "<ul> <li><a href=\"#publicHubs\">Public Hubs</a></li>" "<li><a href=\"#unlistedHubs\">My Hubs</a></li> " "</ul> "); struct hash *publicHash = hgHubConnectPublic(); hgHubConnectUnlisted(hubList, publicHash); printf("</div>"); printf("<div class=\"tabFooter\">"); cgiMakeButton("Submit", "Use Selected Hubs"); char *emailAddress = cfgOptionDefault("hub.emailAddress","*****@*****.**"); printf("<span class=\"small\">" "Contact <A HREF=\"mailto:%s\">%s</A> to add a public hub." "</span>\n", emailAddress,emailAddress); printf("</div>"); cgiMakeHiddenVar(hgHubConnectRemakeTrackHub, "on"); printf("</div>\n"); puts("</FORM>"); cartWebEnd(); }