static struct customTrack *beginCustomTrack(char *table, int fields, boolean doCt, boolean doWigHdr, boolean doDataPoints) /* If doCt, return a new custom track object from TB cart settings and params; * if !doCt, return NULL but print out a header line. */ { char *ctName = cgiUsualString(hgtaCtName, table); char *ctDesc = cgiUsualString(hgtaCtDesc, table); char *ctUrl = cgiUsualString(hgtaCtUrl, ""); char *ctVis = cgiUsualString(hgtaCtVis, "dense"); int visNum = (int) hTvFromStringNoAbort(ctVis); struct customTrack *ctNew = NULL; if (visNum < 0) visNum = 0; if (doCt) { ctNew = newCt(ctName, ctDesc, visNum, ctUrl, fields); if (doDataPoints) { struct dyString *wigSettings = newDyString(0); struct tempName tn; trashDirFile(&tn, "ct", hgtaCtTempNamePrefix, ".wib"); ctNew->wibFile = cloneString(tn.forCgi); char *wiggleFile = cloneString(ctNew->wibFile); chopSuffix(wiggleFile); strcat(wiggleFile, ".wia"); ctNew->wigAscii = cloneString(wiggleFile); chopSuffix(wiggleFile); /* .wig file will be created upon encoding in customFactory */ /*strcat(wiggleFile, ".wig"); ctNew->wigFile = cloneString(wiggleFile); */ ctNew->wiggle = TRUE; dyStringPrintf(wigSettings, "type wiggle_0\nwibFile %s\n", ctNew->wibFile); ctNew->tdb->settings = dyStringCannibalize(&wigSettings); freeMem(wiggleFile); } } else { if (doWigHdr) hPrintf("track type=wiggle_0 name=\"%s\" description=\"%s\" " "visibility=%d url=%s \n", ctName, ctDesc, visNum, ctUrl); else hPrintf("track name=\"%s\" description=\"%s\" visibility=%d url=%s \n", ctName, ctDesc, visNum, ctUrl); } return ctNew; }
int main(int argc, char *argv[]) /* Process command line. */ { cgiSpoof(&argc, argv); textField = cgiUsualString("textField", textField); fileComment = cgiUsualString("comment", fileComment); picky = cgiBoolean("picky"); makeMain = cgiBoolean("main"); positiveOnly = cgiBoolean("positive"); if (argc != 3) usage(); autoXml(argv[1], argv[2]); return 0; }
void doPlots() /* Do all the plots. */ { struct dyString *script = newDyString(2048); struct dyString *dummy = newDyString(256); char *skipPSet = cgiUsualString("skipPName", "G7153846@J939317_RC@j_at"); html = newDyString(1024); hSetDb("mm5"); dyStringPrintf(script, "%s", rHeader); /* Call query once to initialize altEvent. */ constructQueryForEvent(dummy, skipPSet, "dummy"); assert(altEvent); fprintf(stdout, "<h3>Plots for %s (%s)</h3>\n", altEvent->geneName, skipPSet); fflush(stdout); /* Probe set plots. */ doRegressionPlot(script, skipPSet, "mouseAEvent_inc_intensity", "mouseAEvent_skip_intensity", "mouseAEvent_gene_prob"); doProbeSet(script, skipPSet); doProbeSetPVals(script, skipPSet); doNormProbes(script, skipPSet); fflush(stdout); fflush(stderr); invokeR(script); fputs(html->string, stdout); }
static void choiceMenu() /* Put up choice menu. */ { static char *choices[] = {"one", "two", "three"}; char *var = "num"; char *val = cgiUsualString(var, "two"); char *script = "onchange=\"" " document.mainForm.submit();\""; cgiMakeDropListFull(var, choices, choices, ArraySize(choices), val, script); }
int main(int argc, char *argv[]) { cgiSpoof(&argc, argv); if(argc == 1) usage(); else { suffix = cgiUsualString("suffix", "pairs.sample.norm"); doAll = cgiBoolean("doAll"); avgTranscriptomeExps(); } return 0; }
void doAnalysisForBed(struct bed *bed) { char *hgdbTestTable = cgiUsualString("hgdbTestTable","affyTrans_hg12"); char *hgdbTestName = "sugnet"; FILE *tmpFile = NULL; char commandBuffer[4096]; char *fileNameRoot = getFileNameForBed(bed); char bedFile[512]; char dataFile[512]; int retVal = 0; /* Print out bed. */ safef(bedFile, sizeof(bedFile), "%s.bed", fileNameRoot); tmpFile = mustOpen(bedFile, "w"); bedTabOutN(bed, 12, tmpFile); carefulClose(&tmpFile); /* Get samples for bed. */ safef(dataFile, sizeof(dataFile), "%s.data", fileNameRoot); safef(commandBuffer, sizeof(commandBuffer), "samplesForCoordinates bedFile=%s hgdbTestName=%s hgdbTestTable=%s > %s", bedFile, hgdbTestName, hgdbTestTable, dataFile); retVal = system(commandBuffer); if(retVal != 0) { warn("%s failed running command:\n%s", fileNameRoot, commandBuffer); return; } safef(commandBuffer, sizeof(commandBuffer), "cp %s tmp.data", dataFile); retVal = system(commandBuffer); /* Run R analysis on data file. */ warn("Running R for %s", fileNameRoot); fflush(stderr); safef(commandBuffer, sizeof(commandBuffer), "R --vanilla < /cluster/home/sugnet/sugnet/R/maReg/R/runAnalysis.R"); warn("Done with R"); fflush(stderr); retVal = system(commandBuffer); if(retVal != 0) { warn("%s failed running command:\n%s", fileNameRoot, commandBuffer); return; } bedsAnalyzed++; }
int main(int argc, char *argv[]) /* Process command line. */ { long enteredMainTime = clock1000(); struct dyString *headText = newDyString(512); char *destination = cgiUsualString("destination", defaultDestination); if (strstr(destination, "://")) errAbort("To stop Open Redirect abuse, only relative URLs are supported. " "Request for destination=[%s] rejected.\n", destination); dyStringPrintf(headText, "<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"0;URL=%s\">" "<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" "<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">" ,destination); htmShellWithHead("Reset Cart", headText->string, doMiddle, NULL); dyStringFree(&headText); cgiExitTime("cartReset", enteredMainTime); return 0; }
/** load the sage experiment data */ struct sageExp *loadSageExps(char *tableName, struct slName *nmList) { char *user = cfgOption("db.user"); char *password = cfgOption("db.password"); struct sqlConnection *sc = NULL; char query[256]; struct sageExp *seList = NULL, *se=NULL; char **row; struct sqlResult *sr = NULL; char *db = cgiUsualString("db", "hgFixed"); sc = sqlConnectRemote("localhost", user, password, db); sqlSafef(query, sizeof query, "select * from sageExp order by num"); sr = sqlGetResult(sc,query); while((row = sqlNextRow(sr)) != NULL) { se = sageExpLoad(row); slAddHead(&seList,se); } sqlFreeResult(&sr); sqlDisconnect(&sc); slReverse(&seList); return seList; }
/** load the sage data by constructing a query based on the names in nmList */ struct sage *loadSageData(char *table, struct slName *nmList) { char *user = cfgOption("db.user"); char *password = cfgOption("db.password"); struct sqlConnection *sc = NULL; struct dyString *query = newDyString(2048); struct sage *sgList = NULL, *sg=NULL; struct slName *nm =NULL; char *db = cgiUsualString("db", "hgFixed"); char **row; int count=0; struct sqlResult *sr = NULL; sc = sqlConnectRemote("localhost", user, password, db); sqlDyStringPrintf(query, "select * from sage where "); for(nm=nmList;nm!=NULL;nm=nm->next) { if (count++) { sqlDyStringPrintf(query," or uni=%s ", nm->name ); } else { sqlDyStringPrintf(query," uni=%s ", nm->name); } } sr = sqlGetResult(sc,query->string); while((row = sqlNextRow(sr)) != NULL) { sg = sageLoad(row); slAddHead(&sgList,sg); } sqlFreeResult(&sr); sqlDisconnect(&sc); slReverse(&sgList); freeDyString(&query); return sgList; }
int main(int argc, char *argv[]) /* Process command line */ { long enteredMainTime = clock1000(); cgiSpoof(&argc, argv); termOpt = cgiOptionalString(CV_TERM); tagOpt = cgiOptionalString(CV_TAG); typeOpt = cgiOptionalString(CV_TYPE); targetOpt = cgiOptionalString(CV_TARGET); labelOpt = cgiOptionalString(CV_LABEL); organismOpt = cgiUsualString(ORGANISM, organismOpt); if (organismOpt != NULL) { organismOptLower=cloneString(organismOpt); strLower(organismOptLower); } char *bgColor = cgiOptionalString("bgcolor"); if (bgColor) htmlSetBgColor(strtol(bgColor, 0, 16)); htmlSetStyle(htmlStyleUndecoratedLink); htmShell("ENCODE Controlled Vocabulary", doMiddle, "get"); cgiExitTime("hgEncodeVocab", enteredMainTime); return 0; }
void doBedOrCtOptions(char *table, struct sqlConnection *conn, boolean doCt) /* Put up form to get options on BED or custom track output. */ /* (Taken from hgText.c/doBedCtOptions) */ { char *table2 = NULL; /* For now... */ struct hTableInfo *hti = getHti(database, table, conn); char buf[256]; char *setting; htmlOpen("Output %s as %s", table, (doCt ? "Custom Track" : "BED")); if (doGalaxy()) startGalaxyForm(); else if (doGreat()) { verifyGreatAssemblies(); startGreatForm(); } else hPrintf("<FORM ACTION=\"%s\" METHOD=GET>\n", getScriptName()); cartSaveSession(cart); if (!doGreat()) { hPrintf("%s\n", "<TABLE><TR><TD>"); if (doCt) { hPrintf("%s\n", "</TD><TD>" "<A HREF=\"../goldenPath/help/customTrack.html\" TARGET=_blank>" "Custom track</A> header: </B>"); } else { cgiMakeCheckBox(hgtaPrintCustomTrackHeaders, cartCgiUsualBoolean(cart, hgtaPrintCustomTrackHeaders, FALSE)); hPrintf("%s\n", "</TD><TD> <B> Include " "<A HREF=\"../goldenPath/help/customTrack.html\" TARGET=_blank>" "custom track</A> header: </B>"); } hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>name="); safef(buf, sizeof(buf), "tb_%s", hti->rootName); setting = cgiUsualString(hgtaCtName, buf); cgiMakeTextVar(hgtaCtName, setting, 16); hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>description="); safef(buf, sizeof(buf), "table browser query on %s%s%s", table, (table2 ? ", " : ""), (table2 ? table2 : "")); setting = cgiUsualString(hgtaCtDesc, buf); cgiMakeTextVar(hgtaCtDesc, setting, 50); hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>visibility="); if (isWiggle(database, table) || isBigWigTable(table)) { setting = cartCgiUsualString(cart, hgtaCtVis, ctVisWigMenu[2]); cgiMakeDropList(hgtaCtVis, ctVisWigMenu, ctVisWigMenuSize, setting); } else { setting = cartCgiUsualString(cart, hgtaCtVis, ctVisMenu[3]); cgiMakeDropList(hgtaCtVis, ctVisMenu, ctVisMenuSize, setting); } hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>url="); setting = cartCgiUsualString(cart, hgtaCtUrl, ""); cgiMakeTextVar(hgtaCtUrl, setting, 50); hPrintf("%s\n", "</TD></TR><TR><TD></TD><TD>"); hPrintf("%s\n", "</TD></TR></TABLE>"); } if (isWiggle(database, table) || isBedGraph(table) || isBigWigTable(table) ) { char *setting = NULL; hPrintf("<P> <B> Select type of data output: </B> <BR>\n"); setting = cartCgiUsualString(cart, hgtaCtWigOutType, outWigData); cgiMakeRadioButton(hgtaCtWigOutType, outWigBed, sameString(setting, outWigBed)); hPrintf("BED format (no data value information, only position)<BR>\n"); cgiMakeRadioButton(hgtaCtWigOutType, outWigData, sameString(setting, outWigData)); hPrintf("DATA VALUE format (position and real valued data)</P>\n"); } else { cgiDown(0.9); hPrintf("<B> Create one BED record per: </B>\n"); if ((anyIntersection() && intersectionIsBpWise()) || (anySubtrackMerge(database, table) && subtrackMergeIsBpWise())) { /* The original table may have blocks/CDS, described in hti, but * that info will be lost after base pair-wise operations. So make * a temporary copy of hti with its flags tweaked: */ struct hTableInfo simplifiedHti; memcpy(&simplifiedHti, hti, sizeof(simplifiedHti)); simplifiedHti.hasBlocks = FALSE; simplifiedHti.hasCDS = FALSE; fbOptionsHtiCart(&simplifiedHti, cart); } else fbOptionsHtiCart(hti, cart); } if (doCt) { if (doGalaxy()) { /* send the action parameter with the form as well */ cgiMakeHiddenVar(hgtaDoGetCustomTrackFile, "get custom track in file"); printGalaxySubmitButtons(); } else { cgiMakeButton(hgtaDoGetCustomTrackTb, "get custom track in table browser"); hPrintf(" "); cgiMakeButton(hgtaDoGetCustomTrackFile, "get custom track in file"); hPrintf("<BR>\n"); cgiMakeButton(hgtaDoGetCustomTrackGb, "get custom track in genome browser"); } } else { if (doGalaxy()) { cgiMakeHiddenVar(hgtaDoGetBed, "get BED"); printGalaxySubmitButtons(); } else if (doGreat()) { cgiMakeHiddenVar(hgtaDoGetBed, "get BED"); printGreatSubmitButtons(); } else cgiMakeButton(hgtaDoGetBed, "get BED"); } if (!doGalaxy() && !doGreat()) { hPrintf(" "); cgiMakeButton(hgtaDoMainPage, "cancel"); hPrintf("</FORM>\n"); } cgiDown(0.9); htmlClose(); }
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() */
void doExpRatio(struct trackDb *tdb, char *item, struct customTrack *ct) /* Generic expression ratio deatils using microarrayGroups.ra file */ /* and not the expRecord tables. */ { char *expScale = trackDbRequiredSetting(tdb, "expScale"); char *expStep = trackDbRequiredSetting(tdb, "expStep"); double maxScore = atof(expScale); double stepSize = atof(expStep); struct bed *bedList; char *itemName = cgiUsualString("i2","none"); char *expName = (item == NULL) ? itemName : item; char *tdbSetting = trackDbSettingOrDefault(tdb, "expColor", "redGreen"); char *colorVal = NULL; enum expColorType colorScheme; char colorVarName[256]; safef(colorVarName, sizeof(colorVarName), "%s.color", tdb->track); colorVal = cartUsualString(cart, colorVarName, tdbSetting); colorScheme = getExpColorType(colorVal); if (sameWord(tdb->grp, "cancerGenomics")) { /* set global flag */ isCancerGenomicsTrack = TRUE; } if (!ct) { genericHeader(tdb, itemName); bedList = loadMsBed(tdb, tdb->table, seqName, winStart, winEnd); } else if (ct->dbTrack) { genericHeader(tdb, itemName); printCustomUrl(tdb, itemName, TRUE); bedList = ctLoadMultScoresBedDb(ct, seqName, winStart, winEnd); } else bedList = bedFilterListInRange(ct->bedList, NULL, seqName, winStart, winEnd); if (bedList == NULL) printf("<b>No Expression Data in this Range.</b>\n"); else if (expName && sameString(expName, "zoomInMore")) printf("<b>Too much data to display in detail in this range.</b>\n"); else { struct microarrayGroups *groupings = NULL; struct maGrouping *combineGroup; struct hash *erHash = newHash(6); int i; if (!ct) { groupings = maGetTrackGroupings(database, tdb); combineGroup = maCombineGroupingFromCart(groupings, cart, tdb->track); } else combineGroup = maGetGroupingFromCt(ct); maBedClumpGivenGrouping(bedList, combineGroup); for (i = 0; i < combineGroup->numGroups; i++) { /* make stupid exprecord hash.perhaps eventually this won't be needed */ char id[16]; struct expRecord *er = basicExpRecord(combineGroup->names[i], i, 2); safef(id, sizeof(id), "%d", i); hashAdd(erHash, id, er); } puts("<h2></h2><p>\n"); msBedPrintTable(bedList, erHash, itemName, expName, -1*maxScore, maxScore, stepSize, 2, msBedDefaultPrintHeader, msBedExpressionPrintRow, printExprssnColorKey, getColorForExprBed, colorScheme); hashTraverseEls(erHash, erHashElFree); hashFree(&erHash); microarrayGroupsFree(&groupings); } puts("<h2></h2><p>\n"); bedFreeList(&bedList); }
void faNcbiToUcsc(char *inFile, char *out) /* faNcbiToUcsc - Convert FA file from NCBI to UCSC format.. */ { struct lineFile *lf = lineFileOpen(inFile, TRUE); char outName[512]; char *line; boolean split = cgiBoolean("split"); boolean ntLast = cgiBoolean("ntLast"); boolean encode = cgiBoolean("encode"); struct dnaSeq seq; FILE *f = NULL; char *wordBefore = cgiUsualString("wordBefore", "gb"); int wordIx = cgiUsualInt("wordIx", -1); char *e = NULL; char *nt = NULL; ZeroVar(&seq); if (split) makeDir(out); else f = mustOpen(out, "w"); while (lineFileNext(lf, &line, NULL)) { if (line[0] == '>') { if (ntLast || encode) { nt = NULL; if (ntLast) { e = NULL; nt = stringIn("NT_", line); if (nt == NULL) nt = stringIn("NG_", line); if (nt == NULL) nt = stringIn("NC_", line); if (nt == NULL) errAbort("Expecting NT_ NG_ or NC_in '%s'", line); e = strchr(nt, '|'); if (e != NULL) *e = 0; e = strchr(nt, ' '); if (e != NULL) *e = 0; } else { nt = stringIn("|EN", line); if (nt == NULL) errAbort("Expecting EN in %s", line); nt++; nt = firstWordInLine(nt); } if (split) { sprintf(outName, "%s/%s.fa", out, nt); carefulClose(&f); f = mustOpen(outName, "w"); } fprintf(f, ">%s\n", nt); } else { char *words[32]; int wordCount, i; char *accession = NULL; wordCount = chopString(line+1, "|", words, ArraySize(words)); if (wordIx >= 0) { if (wordIx >= wordCount) errAbort("Sorry only %d words", wordCount); accession = words[wordIx]; } else { for (i=0; i<wordCount-1; ++i) { if (sameString(words[i], wordBefore)) { accession = words[i+1]; break; } } if (accession == NULL) errAbort("Couldn't find '%s' line %d of %s", wordBefore, lf->lineIx, lf->fileName); } chopSuffix(accession); fprintf(f, ">%s\n", accession); } } else { fprintf(f, "%s\n", line); } } }
void wikiPlot() /* wikiPlot - Quick plots of maps vs. each other. */ { boolean gotDir = cgiVarExists("contigDir"); double step; contigDir = cgiUsualString("contigDir", contigDir); mapX = cgiUsualString("mapX", mapX); mapY = cgiUsualString("mapY", mapY); pix = cgiUsualInt("pix", pix); xOff = cgiUsualDouble("xOff", xOff); yOff = cgiUsualDouble("yOff", yOff); zoom = cgiUsualDouble("zoom", zoom); step = 0.1 * 1/zoom; if (cgiVarExists("boxOut")) { double invZoom = 1.0/zoom; double xCen = xOff + invZoom*0.5; double yCen = yOff + invZoom*0.5; zoom /= 2; invZoom = 1.0/zoom; xOff = xCen - invZoom*0.5; yOff = yCen - invZoom*0.5; } else if (cgiVarExists("boxUp")) yOff -= step; else if (cgiVarExists("boxDown")) yOff += step; else if (cgiVarExists("boxLeft")) xOff -= step; else if (cgiVarExists("boxRight")) xOff += step; else if (cgiVarExists("boxUpLeft")) { yOff -= step; xOff -= step; } else if (cgiVarExists("boxUpRight")) { yOff -= step; xOff += step; } else if (cgiVarExists("boxDownLeft")) { yOff += step; xOff -= step; } else if (cgiVarExists("boxDownRight")) { yOff += step; xOff += step; } else if (cgiVarExists("unzoom")) { xOff = yOff = -0.05; zoom = 0.9; } printf("<FORM ACTION=\"../cgi-bin/wikiPlot\" METHOD=\"GET\">\n"); printf("<TABLE BORDER=0 WIDTH=\"100%%\">\n"); printf("<TR>\n"); printf("<TD WIDTH=\"78%%\">\n"); printf("<B>Wiki Plotter</B><BR>\n"); printf("<B>Contig: </B>"); cgiMakeTextVar("contigDir", contigDir, 0); if (gotDir) { cgiMakeButton("refresh", "refresh"); } else cgiMakeButton("submit", "submit"); printf("<BR>\n"); printf("<B>Map X: </B>"); cgiMakeTextVar("mapX", mapX, 12); printf("<B>Map Y: </B>"); cgiMakeTextVar("mapY", mapY, 12); printf("<B>Pixels: </B>"); cgiMakeIntVar("pix", pix, 4); printf("</TD>\n"); printf("<TD WIDTH=\"22%%\">\n"); if (gotDir) printBox(); printf("</TD>\n"); printf("</TR>\n"); printf("</TABLE>\n"); if (gotDir) { char xFile[512], yFile[512]; struct hash *xHash = NULL, *yHash = NULL; struct clonePos *xList = NULL, *yList = NULL; sprintf(xFile, "%s/%s", contigDir, mapX); sprintf(yFile, "%s/%s", contigDir, mapY); loadMaps(xFile, yFile, &xList, &yList, &xHash, &yHash); makePlot(xList, yList, yHash); } /* Save hidden vars. */ { char buf[256]; sprintf(buf, "%f", zoom); cgiMakeHiddenVar("zoom", buf); sprintf(buf, "%f", xOff); cgiMakeHiddenVar("xOff", buf); sprintf(buf, "%f", yOff); cgiMakeHiddenVar("yOff", buf); } printf("</FORM>\n"); }
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() */