void mapZoomIn(int x, int y, int width, int height, double zx, double zy, double zScale)
/* Print out image map rectangle that calls self with zoom info. */
{
printf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", x, y, x+width, y+height);
printf("HREF=\"../cgi-bin/wikiPlot?contigDir=%s&mapX=%s&mapY=%s&pix=%d&xOff=%f&yOff=%f&zoom=%f\" ",
	cgiEncode(contigDir), cgiEncode(mapX), cgiEncode(mapY), pix, zx, zy, zScale);
printf(">\n");
}
예제 #2
0
static char *encodedHgSessionReturnUrl(char *hgsid)
/* Return a CGI-encoded hgSession URL with hgsid.  Free when done. */
{
char retBuf[1024];
safef(retBuf, sizeof(retBuf), "http%s://%s/cgi-bin/hgSession?hgsid=%s",
      cgiAppendSForHttps(), cgiServerNamePort(), hgsid);
return cgiEncode(retBuf);
}
static char *encodedHgSessionReturnUrl(int hgsid)
/* Return a CGI-encoded hgSession URL with hgsid.  Free when done. */
{
char retBuf[1024];
safef(retBuf, sizeof(retBuf), "http://%s/cgi-bin/hgSession?hgsid=%d",
      cgiServerName(), hgsid);
return cgiEncode(retBuf);
}
예제 #4
0
char *insertUserPasswordIntoUrl(char *url, char *user, char *password)
/* Insert cgi-encoded user and password into url after protocol. Free returned string when done. */
{
char resultUrl[1024];
char *encUser = cgiEncode(user);
char *encPassword = cgiEncode(password);
char *rest = stringIn("://", url);
if (!rest)
    errAbort("expected url [%s] to have ://", url);
char *protocol = cloneStringZ(url, rest - url);
rest += strlen("://");
safef(resultUrl, sizeof resultUrl, "%s://%s:%s@%s", protocol, encUser, encPassword, rest);

freeMem(protocol);
freeMem(encUser);
freeMem(encPassword);

return cloneString(resultUrl);
}
예제 #5
0
static void appendCgiVar(struct dyString *dy, char *name, char *value)
/* Append cgiVar with cgi-encoded value to dy. */
{
char *enc = NULL;
if (value == NULL)
    value = "";
enc = cgiEncode(value);
if (dy->stringSize != 0)
    dyStringAppendC(dy, '&');
dyStringAppend(dy, name);
dyStringAppendC(dy, '=');
dyStringAppend(dy, enc);
freez(&enc);
}
예제 #6
0
char *gsUploadUrl(char *gsToken, char *user, char *uploadFileName, off_t contentLength, char *base64Md5, char *contentType)
/* call uploadurl */
{
// UPLOADURLS 

// TODO deal with creating parent dirs if uploadFileName contains a path? maybe not.

// old:  "https://identity.genomespace.org/datamanager/uploadurls/users/"
// old     "https://dm.genomespace.org/datamanager/v1.0/uploadurl/users/"  // if this works, use default dir fetched earlier instead

char *dmSvr = getGenomeSpaceConfig("dmServer");
char uploadUrl[1024];
safef(uploadUrl, sizeof(uploadUrl),
    "%s/v1.0/uploadurl/users/"
    "%s/"
    "%s"
    "?Content-Length=%lld"
    "&Content-MD5=%s"
    "&Content-Type=%s"
    , dmSvr
    , user
    , uploadFileName
    , (long long) contentLength
    , cgiEncode(base64Md5)
    , contentType
    );


struct dyString *reqExtra = newDyString(256);
dyStringPrintf(reqExtra, "Cookie: gs-token=%s\r\n", gsToken);

int sd = netOpenHttpExt(uploadUrl, "GET", reqExtra->string);
if (sd < 0)
    errAbort("failed to open socket for [%s]", uploadUrl);

char *responseCode = NULL;
char *s3UploadUrl = parseResponse(sd, &responseCode);
if (sameString(responseCode, "404 Not Found"))
    errAbort("GenomeSpace: %s, if a path was used in the output name, it may indicate the path does not exist in GenomeSpace.", responseCode);
if (!sameString(responseCode, "200 OK"))
    errAbort("GenomeSpace: %s", responseCode);

dyStringFree(&reqExtra);

return s3UploadUrl;

}
static void gadPrint(struct section *section, 
	struct sqlConnection *conn, char *geneId)
/* Print out GAD section. */
{
int refPrinted = 0;
boolean showCompleteGadList;

char condStr[256];
char query[256];
struct sqlResult *sr;
char **row;
struct dyString *currentCgiUrl;
char *upperDisease;

char *url = 
cloneString("http://geneticassociationdb.nih.gov/cgi-bin/tableview.cgi?table=allview&cond=gene=");
char *itemName;

if (url != NULL && url[0] != 0)
    {
    safef(condStr, sizeof(condStr), 
    "k.kgId='%s' and k.geneSymbol = g.geneSymbol", geneId);
    itemName = sqlGetField(database, "kgXref k, gadAll g", "k.geneSymbol", condStr);
    showCompleteGadList = FALSE;
    if (cgiOptionalString("showAllRef") != NULL)
    	{
        if (sameWord(cgiOptionalString("showAllRef"), "Y") ||
	    sameWord(cgiOptionalString("showAllRef"), "y") )
	    {
	    showCompleteGadList = TRUE;
	    }
	}
    currentCgiUrl = cgiUrlString();
   
    printf("<B>Genetic Association Database: ");
    printf("<A HREF=\"%s'%s'\" target=_blank>", url, itemName);
    printf("%s</B></A>\n", itemName);

    printf("<BR><B>CDC HuGE Published Literature:  ");
    printf("<A HREF=\"%s%s%s\" target=_blank>", 
           "http://hugenavigator.net/HuGENavigator/searchSummary.do?firstQuery=",
           itemName, 
	   "&publitSearchType=now&whichContinue=firststart&check=n&dbType=publit&Mysubmit=go");
    printf("%s</B></A>\n", itemName);

    /* List diseases associated with the gene */
    safef(query, sizeof(query),
    "select distinct broadPhen from gadAll where geneSymbol='%s' and association = 'Y' order by broadPhen",
    itemName);
    sr = sqlMustGetResult(conn, query);
    row = sqlNextRow(sr);
    
    if (row != NULL) 
    	{
	upperDisease = replaceChars(row[0], "'", "''");
	touppers(upperDisease);
	printf("<BR><B>Positive Disease Associations:  </B>");
	printf("<A HREF=\"%s%s%s%s%s\" target=_blank>",
	"http://geneticassociationdb.nih.gov/cgi-bin/tableview.cgi?table=allview&cond=upper(DISEASE)%20like%20'%25",
	cgiEncode(upperDisease), "%25'%20AND%20upper(GENE)%20%20like%20'%25", itemName, "%25'");
	printf("%s</B></A>\n", row[0]);
        row = sqlNextRow(sr);
    	}
    while (row != NULL)
        {
	upperDisease = replaceChars(row[0], "'", "''");
	touppers(upperDisease);
	printf(", <A HREF=\"%s%s%s%s%s\" target=_blank>",
	"http://geneticassociationdb.nih.gov/cgi-bin/tableview.cgi?table=allview&cond=upper(DISEASE)%20like%20'%25",
	cgiEncode(upperDisease), "%25'%20AND%20upper(GENE)%20%20like%20'%25", itemName, "%25'");
	printf("%s</B></A>\n", row[0]);
        row = sqlNextRow(sr);
	}
    sqlFreeResult(&sr);

    refPrinted = 0;
    safef(query, sizeof(query), 
       "select broadPhen,reference,title,journal, pubMed, conclusion from gadAll where geneSymbol='%s' and association = 'Y' order by broadPhen",
       itemName);
    sr = sqlMustGetResult(conn, query);
    row = sqlNextRow(sr);
    
    if (row != NULL) printf("<BR><B>Related Studies: </B><OL>");
    while (row != NULL)
        {
        printf("<LI><B>%s </B>", row[0]);

	printf("<br>%s, %s, %s.\n", row[1], row[2], row[3]);
	if (!sameWord(row[4], ""))
	    {
	    printf(" [PubMed ");
	    printf("<A HREF=\"%s%s%s'\" target=_blank>",
	    "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=pubmed&cmd=Retrieve&dopt=Abstract&list_uids=",
	    row[4],"&query_hl=1&itool=genome.ucsc.edu");
	    printf("%s</B></A>]\n", row[4]);
	    }
	printf("<br><i>%s</i>\n", row[5]);
	
	printf("</LI>\n");
        refPrinted++;
        if ((!showCompleteGadList) && (refPrinted >= 3)) break;
	row = sqlNextRow(sr);
    	}
    sqlFreeResult(&sr);
    printf("</OL>");
    
    if ((!showCompleteGadList) && (row != NULL))
    	{
        printf("<B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; more ...  </B>");
        printf(
	      "<A HREF=\"%s?showAllRef=Y&%s&#35;gad\">click here to view the complete list</A> ", 
	      "hgGene", currentCgiUrl->string);
    	}
    }
}
예제 #8
0
static void cgDrawEither(struct track *tg, int seqStart, int seqEnd,
        struct hvGfx *hvg, int xOff, int yOff, int width,
        MgFont *font, Color color, enum trackVisibility vis,
        char *binFileName)
/* Draw chromosome graph - either built in or not. */
{
struct chromGraphSettings *cgs = tg->customPt;
int x,y,lastX=0,lastY=0, llastX = 0, llastY = 0;
int height = tg->height;
int maxGapToFill = cgs->maxGapToFill;
int lastPos = -maxGapToFill-1;
double minVal = cgs->minVal;
double yScale = (height-1)/(cgs->maxVal - minVal);
double xScale = scaleForPixels(width);
Color myColor = cgColorLikeHgGenome(tg, hvg);

/* Draw background lines in full mode. */
if (vis == tvFull && cgs->linesAtCount != 0)
    {
    int i;
    Color lightBlue = hvGfxFindRgb(hvg, &guidelineColor);
    for (i=0; i<cgs->linesAtCount; ++i)
        {
	y = height - 1 - (cgs->linesAt[i] - minVal)*yScale + yOff;
	hvGfxBox(hvg, xOff, y, width, 1, lightBlue);
	}
    }

if (binFileName)
    {
    struct chromGraphBin *cgb = chromGraphBinOpen(binFileName);
    if (chromGraphBinSeekToChrom(cgb, chromName))
	{
	int seqStartMinus = seqStart - cgs->maxGapToFill;
	while (chromGraphBinNextVal(cgb))
	    {
	    int pos = cgb->chromStart;
	    if (pos >= seqStartMinus)
		{
		double val = cgb->val;
		x = (pos - seqStart)*xScale + xOff;
		y = height - 1 - (val - minVal)*yScale + yOff;
		if (x >= xOff)
		    {
		    if (pos - lastPos <= maxGapToFill)
			{
			if (llastX != lastX || llastY != lastY || lastX != x || lastY != y)
			    hvGfxLine(hvg, lastX, lastY, x, y, myColor);
			}
		    else
			hvGfxDot(hvg, x, y, myColor);
		    }
		llastX = lastX;
		llastY = lastY;
		lastX = x;
		lastY = y;
		lastPos = pos;
		if (pos >= seqEnd)
		    break;
		}
	    }
	}
    }
else
    {
    struct sqlConnection *conn = hAllocConn(database);
    char query[512];
    struct sqlResult *sr;
    char **row;
    /* Construct query.  Set up a little more than window so that
     * we can draw connecting lines. */
    sqlSafef(query, sizeof(query),
	"select chromStart,val from %s "
	"where chrom='%s' and chromStart>=%d and chromStart<%d",
	tg->table, chromName,
	seqStart - cgs->maxGapToFill, seqEnd + cgs->maxGapToFill);
    sr = sqlGetResult(conn, query);

    /* Loop through drawing lines from one point to another unless
     * the points are too far apart. */
    while ((row = sqlNextRow(sr)) != NULL)
	{
	int pos = sqlUnsigned(row[0]);
	double val = atof(row[1]);
	x = (pos - seqStart)*xScale + xOff;
	y = height - 1 - (val - minVal)*yScale + yOff;
	if (x >= xOff)
	    {
	    if (pos - lastPos <= maxGapToFill)
		{
		if (llastX != lastX || llastY != lastY || lastX != x || lastY != y)
		    hvGfxLine(hvg, lastX, lastY, x, y, myColor);
		}
	    else
		hvGfxDot(hvg, x, y, myColor);
	    }
	llastX = lastX;
	llastY = lastY;
	lastX = x;
	lastY = y;
	lastPos = pos;
	if (pos >= seqEnd)
	    break;
	}
    sqlFreeResult(&sr);
    hFreeConn(&conn);
    }

/* Do map box */
xOff = hvGfxAdjXW(hvg, xOff, width);

char *encodedTrack = cgiEncode(tg->track);
if (theImgBox && curImgTrack)
    {
    char link[512];     // FIXME: winStart/winEnd are not right when using a portal
    safef(link,sizeof(link),"%s&c=%s&o=%d&t=%d&g=%s", hgcNameAndSettings(),
        chromName, winStart, winEnd, encodedTrack);
#ifdef IMAGEv2_SHORT_MAPITEMS
    if (xOff < insideX && xOff+width > insideX)
        warn("cgDrawEither(%s) map item spanning slices. LX:%d TY:%d RX:%d BY:%d  link:[%s]",
             encodedTrack,xOff, yOff, xOff+width, yOff+height, link);
#endif//def IMAGEv2_SHORT_MAPITEMS
    imgTrackAddMapItem(curImgTrack,link,NULL,xOff,yOff,xOff+width,yOff+height,tg->track);
    }
else
    {
    hPrintf("<AREA SHAPE=RECT COORDS=\"%d,%d,%d,%d\" ", xOff, yOff, xOff+width,
            yOff+height);
    hPrintf("HREF=\"%s&o=%d&t=%d&g=%s&c=%s&l=%d&r=%d&db=%s&pix=%d\">\n",
            hgcNameAndSettings(), winStart, winEnd, encodedTrack, chromName, winStart, winEnd,
            database, tl.picWidth);
    }
}
예제 #9
0
파일: web.c 프로젝트: elmargb/kentUtils
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;\">"
	    "&nbsp;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>&nbsp;</TD><TD>\n\n"
         );
    };
webPushErrHandlers();
/* set the flag */
webHeadAlreadyOutputed = TRUE;
}	/*	static void webStartWrapperDetailedInternal()	*/
예제 #10
0
파일: cgapSageTrack.c 프로젝트: bowhan/kent
static struct linkedFeatures *cgapSageToLinkedFeatures(struct cgapSage *tag, 
                  struct hash *libHash, struct hash *libTotHash, enum trackVisibility vis)
/* Convert a single CGAP tag to a list of linkedFeatures. */
{
struct linkedFeatures *libList = NULL;
struct linkedFeatures *skel = skeletonLf(tag);
int i;
if (vis == tvDense)
    /* Just use the skeleton one. */
    {
    int tagTotal = 0;
    int freqTotal = 0;
    int libsUsed = 0;
    for (i = 0; i < tag->numLibs; i++)
	{
	char libId[16];
	char *libName;
	safef(libId, sizeof(libId), "%d", tag->libIds[i]);
	libName = hashMustFindVal(libHash, libId);
	if (keepThisLib(libName, libId))
	    {
	    int libTotal = hashIntVal(libTotHash, libId);
	    tagTotal += libTotal;
	    freqTotal += tag->freqs[i];
	    libsUsed++;
	    }
	}
    if (libsUsed > 0)
	{
	skel->name = cloneString("whatever");
	skel->score = (float)((double)freqTotal * (1000000/tagTotal));
	skel->grayIx = grayIxForCgap(skel->score);
	addSimpleFeature(skel);
	libList = skel;
	}
    }
else if (vis == tvPack)
    {
    /* If it's pack mode, average tissues into one linkedFeature. */
    struct hash *tpmHash = combineCgapSages(tag, libHash, libTotHash);
    struct hashEl *tpmList = hashElListHash(tpmHash);
    struct hashEl *tpmEl;
    slSort(&tpmList, slNameCmp);
    for (tpmEl = tpmList; tpmEl != NULL; tpmEl = tpmEl->next)
	{
	struct linkedFeatures *tiss = CloneVar(skel);
	struct cgapSageTpmHashEl *tpm = (struct cgapSageTpmHashEl *)tpmEl->val;
	char link[256];
	char *encTissName = NULL;
	double score = 0;
        int len = strlen(tpmEl->name) + 32;
        tiss->name = needMem(len);
	safef(tiss->name, len, "%s (%d)", tpmEl->name, tpm->count);
	encTissName = cgiEncode(tpmEl->name);
	safef(link, sizeof(link), "i=%s&tiss=%s", tag->name, encTissName);
	score = (double)tpm->freqTotal*(1000000/(double)tpm->libTotals);
	tiss->score = (float)score;
	tiss->grayIx = grayIxForCgap(score);
	tiss->extra = cloneString(link);
	freeMem(encTissName);
	addSimpleFeature(tiss);
	slAddHead(&libList, tiss);
	}
    hashElFreeList(&tpmList);
    freeHashAndVals(&tpmHash);
    }
else 
    /* full mode */
    {
    for (i = 0; i < tag->numLibs; i++)
	{
	char libId[16];
	char *libName;
	char link[256];
	struct linkedFeatures *lf;
	safef(libId, sizeof(libId), "%d", tag->libIds[i]);
	libName = hashMustFindVal(libHash, libId);
	if (keepThisLib(libName, libId))
	    {	    
	    lf = CloneVar(skel);
	    lf->name = cloneString(libName);
	    safef(link, sizeof(link), "i=%s&lib=%s", tag->name, libId);
	    lf->score = (float)tag->tagTpms[i];
	    lf->grayIx = grayIxForCgap(tag->tagTpms[i]);
	    lf->extra = cloneString(link);
	    addSimpleFeature(lf);	
	    slAddHead(&libList, lf);
	    }
	}
    }
slSort(&libList, cgapLinkedFeaturesCmp);
slReverse(&libList);
return libList;
}
예제 #11
0
static void hgPositionsJson(struct jsonWrite *jw, char *db, struct hgPositions *hgp, struct cart *cart)
/* Write out JSON description of multiple position matches. */
{
struct hgPosTable *table;
jsonWriteListStart(jw, "positionMatches");
struct trackDb *tdbList = NULL;
for (table = hgp->tableList; table != NULL; table = table->next)
    {
    if (table->posList != NULL)
	{
	char *tableName = table->name;
	// clear the tdb cache if this track is a hub track
	if (isHubTrack(tableName))
	    tdbList = NULL;
	struct trackDb *tdb = tdbForTrack(db, tableName, &tdbList);
	if (!tdb && startsWith("all_", tableName))
            tdb = tdbForTrack(db, tableName+strlen("all_"), &tdbList);
        if (!tdb)
            errAbort("no track for table \"%s\" found via a findSpec", tableName);
	char *trackName = tdb->track;
	jsonWriteObjectStart(jw, NULL);
	jsonWriteString(jw, "name", table->name);
	jsonWriteString(jw, "trackName", trackName);
	jsonWriteString(jw, "description", table->description);
	jsonWriteString(jw, "vis", hCarefulTrackOpenVis(db, trackName));
	jsonWriteListStart(jw, "matches");
	struct hgPos *pos;
	for (pos = table->posList; pos != NULL; pos = pos->next)
	    {
	    char *encMatches = cgiEncode(pos->browserName);
	    jsonWriteObjectStart(jw, NULL); // begin one match
	    if (pos->chrom != NULL)
		jsonWriteStringf(jw, "position", "%s:%d-%d",
				 pos->chrom, pos->chromStart+1, pos->chromEnd);
	    else
		// GenBank results set position to GB accession instead of chr:s-e position.
		jsonWriteString(jw, "position", pos->name);
	    // this is magic to tell the browser to make the
	    // composite and this subTrack visible
	    if (tdb->parent)
		{
		if (tdbIsSuperTrackChild(tdb))
		    jsonWriteStringf(jw, "extraSel", "%s=show&", tdb->parent->track);
		else
		    {
		    // tdb is a subtrack of a composite or a view
		    jsonWriteStringf(jw, "extraSel", "%s_sel=1&%s_sel=1&",
				     trackName, tdb->parent->track);
		    }
		}
	    jsonWriteString(jw, "hgFindMatches", encMatches);
	    jsonWriteString(jw, "posName", htmlEncodeText(pos->name, FALSE));
	    if (pos->description)
		{
		stripString(pos->description, "\n");
		jsonWriteString(jw, "description", stripAnchor(pos->description));
		}
	    jsonWriteObjectEnd(jw); // end one match
	    }
	jsonWriteListEnd(jw); // end matches
	jsonWriteObjectEnd(jw); // end one table
	}
    }
    jsonWriteListEnd(jw); // end positionMatches
}
예제 #12
0
파일: mafClick.c 프로젝트: davidhoover/kent
void mafPrettyOut(FILE *f, struct mafAli *maf, int lineSize,
                  boolean onlyDiff, int blockNo)
{
int ii, ch;
int srcChars = 0;
struct mafComp *mc;
int lineStart, lineEnd;
char *summaryLine = needMem(lineSize+1);
char *referenceText;
int startChars, sizeChars, srcSizeChars;
boolean haveInserts = FALSE;
struct mafComp *masterMc = maf->components;

startChars = sizeChars = srcSizeChars = 0;

for (mc = maf->components; mc != NULL; mc = mc->next)
    {
    /* Figure out length of source (species) field. */
    /*if (mc->size != 0)*/
	{
	char dbOnly[128];
	int len;
	char *org;

	memset(dbOnly, 0, sizeof(dbOnly));
	safef(dbOnly, sizeof(dbOnly), "%s", mc->src);
	chopPrefix(dbOnly);

	if ((org = hOrganism(dbOnly)) == NULL)
	    len = strlen(dbOnly);
	else
	    len = strlen(org);
	if (srcChars < len)
	    srcChars = len;

	len = digitsBaseTen(mc->start);
	if (startChars < len)
	    startChars = len;
	len = digitsBaseTen(mc->size);
	if (sizeChars < len)
	    sizeChars = len;
	len = digitsBaseTen(mc->srcSize);
	if (srcSizeChars < len)
	    srcSizeChars = len;

	if (mc->text && (mc->rightStatus == MAF_INSERT_STATUS) && (masterMc->start + masterMc->size < winEnd))
	    haveInserts = TRUE;

#ifdef REVERSESTRAND
	/* complement bases if hgTracks is on reverse strand */
	if (mc->size && cartCgiUsualBoolean(cart, COMPLEMENT_BASES_VAR, FALSE))
	    complement(mc->text, maf->textSize);
#endif
	}
    }
/* first sequence in the alignment */
referenceText = maf->components->text;

for (lineStart = 0; lineStart < maf->textSize; lineStart = lineEnd)
    {
    int size;
    lineEnd = lineStart + lineSize;
    if (lineEnd >= maf->textSize)
        lineEnd = maf->textSize;
    size = lineEnd - lineStart;
    initSummaryLine(summaryLine, size, '*');
    for (mc = maf->components; mc != NULL; mc = mc->next)
        {
	char dbOnly[128], *chrom;
	int s = mc->start;
	int e = s + mc->size;
	char *org;
	char *revComp = "";
	char strand = mc->strand;
	struct dyString *dy = newDyString(512);
#ifdef REVERSESTRAND
	if (cartCgiUsualBoolean(cart, COMPLEMENT_BASES_VAR, FALSE))
	    strand = (strand == '+') ? '-' : '+';
#endif
	if (strand == '-') revComp = "&hgSeq.revComp=on";

	dyStringClear(dy);

	safef(dbOnly, sizeof(dbOnly), "%s", mc->src);
	chrom = chopPrefix(dbOnly);
	if ((org = hOrganism(dbOnly)) == NULL)
	    org = dbOnly;

	if (mc->strand == '-')
	    reverseIntRange(&s, &e, mc->srcSize);


	if (mc->text != NULL)
	    {
            if (lineStart == 0)
		{
		if (hDbIsActive(dbOnly))
		    {
		    dyStringPrintf(dy, "%s Browser %s:%d-%d %c %*dbps",hOrganism(dbOnly),chrom, s+1, e, mc->strand,sizeChars, mc->size);
		    linkToOtherBrowserTitle(dbOnly, chrom, s, e, dy->string);
		    dyStringClear(dy);
		    fprintf(f, "B</A> ");
		    }
		else
		    fprintf(f, "  ");

                if (hDbExists(dbOnly))
                    {
                    dyStringPrintf(dy, "Get %s DNA %s:%d-%d %c %*dbps",hOrganism(dbOnly),chrom, s+1, e, mc->strand,sizeChars, mc->size);
                    printf("<A TITLE=\"%s\" TARGET=\"_blank\" HREF=\"%s?o=%d&g=getDna&i=%s&c=%s&l=%d&r=%d&db=%s%s\">D</A> ",  dy->string,hgcName(),
                       s, cgiEncode(chrom),
                       chrom, s, e, dbOnly, revComp);
                    }
                else
                    fprintf(f, "  ");
                }
            else
                {
                fprintf(f, "    ");
                }

            dyStringClear(dy);
            dyStringPrintf(dy, "%s:%d-%d %c %*dbps",chrom, s+1, e, mc->strand,sizeChars, mc->size);
            fprintf(f, "<A TITLE=\"%s\"> %*s </A> ", dy->string, srcChars, org);

            updateSummaryLine(summaryLine, referenceText + lineStart, mc->text + lineStart, size);
            blueCapWrite(f, mc->text + lineStart, size,
			 (onlyDiff && mc != maf->components) ? referenceText + lineStart : NULL);
	    fprintf(f, "\n");
	    }
	else
	    {
	    if (((mc->leftStatus == MAF_CONTIG_STATUS) && (mc->rightStatus == MAF_CONTIG_STATUS) )
	    || ((mc->leftStatus == MAF_TANDEM_STATUS) && (mc->rightStatus == MAF_TANDEM_STATUS) )
	    || ((mc->leftStatus == MAF_INSERT_STATUS) && (mc->rightStatus == MAF_INSERT_STATUS) )
	    || ((mc->leftStatus == MAF_MISSING_STATUS) && (mc->rightStatus == MAF_MISSING_STATUS) ))
		{
                if (lineStart == 0)
		    {
		    int s = mc->start;
		    int e = s + mc->rightLen;
		    struct dyString *dy = newDyString(512);

		    if (mc->strand == '-')
			reverseIntRange(&s, &e, mc->srcSize);

		    if ( hDbIsActive(dbOnly))
			{
			dyStringPrintf(dy, "%s Browser %s:%d-%d %c %d bps Unaligned",hOrganism(dbOnly),chrom, s+1, e, mc->strand, e-s);
			linkToOtherBrowserTitle(dbOnly, chrom, s, e, dy->string);

			fprintf(f,"B</A> ");
			dyStringClear(dy);
			}
		    else
			fprintf(f,"  ");

                    if (hDbExists(dbOnly))
                        {
                        dyStringPrintf(dy, "Get %s DNA %s:%d-%d %c %d bps Unaligned",hOrganism(dbOnly),chrom, s+1, e, mc->strand, e-s);

                        printf("<A TITLE=\"%s\" TARGET=\"_blank\" HREF=\"%s?o=%d&g=getDna&i=%s&c=%s&l=%d&r=%d&db=%s%s\">D</A>  ", dy->string,  hgcName(),
                           s, cgiEncode(chrom),
                           chrom, s, e, dbOnly,revComp);
                        }
                    else
                        fprintf(f, "  ");
                    }
                else
		    fprintf(f, "     ");
		initSummaryLine(summaryLine, size, ' ');
		dyStringClear(dy);
		dyStringPrintf(dy, "%s:%d-%d %c %*dbps",chrom, s+1, e, mc->strand,sizeChars, mc->size);
		fprintf(f, "<A TITLE=\"%s\">%*s</A>  ", dy->string, srcChars, org);
		ch = '-';
		switch(mc->rightStatus)
		    {
		    case MAF_INSERT_STATUS:
			ch = '=';
			break;
		    case MAF_MISSING_STATUS:
			ch = 'N';
			break;
		    case MAF_TANDEM_STATUS:
		    case MAF_CONTIG_STATUS:
			ch = '-';
			break;
		    }
		for(ii=lineStart; ii < lineEnd ; ii++)
		    fputc(ch,f);
		fprintf(f,"\n");
		}
	    }
	}
#ifdef ADDMATCHLINE
    if (lineStart == 0)
	fprintf(f, "    %-*s %s\n", srcChars, "", summaryLine);
    else
	fprintf(f, "%-*s %s\n", srcChars, "", summaryLine);
#else
    fprintf(f, "\n");
#endif
    }

if (haveInserts)
    {
    fprintf(f, "<B>Inserts between block %d and %d in window</B>\n",blockNo, blockNo+1);
    for (mc = maf->components; mc != NULL; mc = mc->next)
	{
	char dbOnly[128], *chrom;
	int s = mc->start + mc->size;
	int e = s + mc->rightLen;
	char *org;

	if (mc->text == NULL)
	    continue;

	if (mc->strand == '-')
	    reverseIntRange(&s, &e, mc->srcSize);

	safef(dbOnly, sizeof(dbOnly), "%s", mc->src);
	chrom = chopPrefix(dbOnly);

	if ((org = hOrganism(dbOnly)) == NULL)
	    org = dbOnly;

	if (mc->rightStatus == MAF_INSERT_STATUS)
	    {
	    char *revComp = "";
	    if (hDbIsActive(dbOnly))
		{
		char strand = mc->strand;
#ifdef REVERSESTRAND
		if (cartCgiUsualBoolean(cart, COMPLEMENT_BASES_VAR, FALSE))
		    strand = (strand == '+') ? '-' : '+';
#endif
		if (strand == '-') revComp = "&hgSeq.revComp=on";

		linkToOtherBrowser(dbOnly, chrom, s, e);
		fprintf(f,"B");
		fprintf(f, "</A>");
		fprintf(f, " ");

		}
	    else
		fprintf(f, "  ");

            if (hDbExists(dbOnly))
                {
                printf("<A TARGET=\"_blank\" HREF=\"%s?o=%d&g=getDna&i=%s&c=%s&l=%d&r=%d"
                       "&db=%s%s\">D</A> ",  hgcName(), s, cgiEncode(chrom), chrom,  s,
                       e, dbOnly,revComp);
                }
            else
		fprintf(f, "  ");
            fprintf(f, "%*s %dbp\n", srcChars, org,mc->rightLen);
	    }
	}
    fprintf(f, "\n");
    }
freeMem(summaryLine);

}
예제 #13
0
파일: pbUtil.c 프로젝트: davidhoover/kent
void presentProteinSelections(char *queryID, int protCntInSwissByGene, int protCntInSupportedGenomeDb)
/* Fuction to present a web page with proteins of different organisms */
{
char *gDatabase;
char *org = NULL;
char *spID, *displayID, *desc;

char cond_str[255];
struct sqlConnection *conn, *conn3;
char query[256], query3[512];
struct sqlResult *sr, *sr3;
char **row, **row3;

struct sqlConnection *connCentral, *proteinsConn;
char queryCentral[256];
struct sqlResult *srCentral;
char *answer;
char *taxonId, *protAcc, *protDisp, *protOrg, *protDesc;
char *oldOrg, *orgSciName;
char *pbOrgSciName[MAX_PB_ORG];
boolean pbOrgPresented[MAX_PB_ORG];
boolean skipIt;
int  i, maxPbOrg;
int  otherCnt;
connCentral = hConnectCentral();

hPrintf("<TABLE WIDTH=\"100%%\" BGCOLOR=\"#"HG_COL_HOTLINKS"\" BORDER=\"0\" CELLSPACING=\"0\"");
hPrintf("CELLPADDING=\"2\"><TR>\n");
hPrintf("<TD ALIGN=LEFT><A HREF=\"../index.html\">%s</A></TD>", wrapWhiteFont("Home"));
hPrintf("<TD style='text-align:center; color:#FFFFFF; font-size:medium;'>%s</TD>",
        "UCSC Proteome Browser");
if (proteinInSupportedGenome)
    {
    hPrintf("<TD ALIGN=Right><A HREF=\"../goldenPath/help/pbTracksHelpFiles/pbTracksHelp.shtml\"");
    }
else
    {
    hPrintf("<TD ALIGN=Right><A HREF=\"../goldenPath/help/pbTracksHelpFiles/pbTracksHelp.shtml\"");
    }

hPrintf("TARGET=_blank>%s</A></TD>", wrapWhiteFont("Help"));
hPrintf("</TR></TABLE>");

hPrintf("<FONT SIZE=4><BR><B>Please select one of the following proteins:<BR><BR></B></FONT>\n");


/* remmember a list of scientific names for the genomes that supports PB */
sqlSafef(queryCentral, sizeof(queryCentral),
      "select distinct dbDb.scientificName from dbDb where hgPbOk=1");
srCentral = sqlMustGetResult(connCentral, queryCentral);
row3 = sqlNextRow(srCentral);
i=0;
while (row3 != NULL)
    {
    pbOrgSciName[i] = strdup(row3[0]);
    pbOrgPresented[i] = FALSE;
    i++;
    row3 = sqlNextRow(srCentral);
    }
maxPbOrg = i;
/* go through each genome DB that supports PB */
sqlSafef(queryCentral, sizeof(queryCentral),
      "select defaultDb.name, dbDb.organism, dbDb.scientificName from dbDb,defaultDb where hgPbOk=1 and defaultDb.name=dbDb.name");
srCentral = sqlMustGetResult(connCentral, queryCentral);
row3 = sqlNextRow(srCentral);
while (row3 != NULL)
    {
    gDatabase = row3[0];
    org       = row3[1];
    orgSciName= row3[2];

    protDbName = hPdbFromGdb(gDatabase);
    proteinsConn = sqlConnect(protDbName);

    conn = sqlConnect(gDatabase);
    sqlSafefFrag(cond_str, sizeof(cond_str), "alias='%s' and spID != ''", queryID);
    answer = sqlGetField(gDatabase, "kgSpAlias", "count(distinct spID)", cond_str);
    if ((answer != NULL) && (!sameWord(answer, "0")))
	{
	/* display organism name */
	hPrintf("<FONT SIZE=4><B>");
	hPrintf("<A href=\"http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Undef&name=%s&lvl=0&srchmode=1\" TARGET=_blank>%s</A>",
           cgiEncode(orgSciName), orgSciName);
	hPrintf(" (%s):</B></FONT>\n", org);
	hPrintf("<UL>");

       	sqlSafef(query, sizeof(query),
              "select distinct spID from %s.kgSpAlias where alias='%s' "
	      "and spID != ''",
	      gDatabase, queryID);

    	sr = sqlMustGetResult(conn, query);
    	row = sqlNextRow(sr);

    	while (row != NULL)
	    {
   	    spID = row[0];
    	    sqlSafefFrag(cond_str, sizeof(cond_str), "accession='%s'", spID);
    	    displayID = sqlGetField(protDbName, "spXref3", "displayID", cond_str);
    	    sqlSafefFrag(cond_str, sizeof(cond_str), "accession='%s'", spID);
    	    desc = sqlGetField(protDbName, "spXref3", "description", cond_str);

	    /* display a protein */
	    hPrintf(
		"<LI><A HREF=\"../cgi-bin/pbGlobal?proteinID=%s&db=%s\">",
		displayID, gDatabase);
	    if (sameWord(spID, displayID) || (strstr(displayID, spID) != NULL))
		{
		hPrintf("%s</A> %s\n", spID, desc);
		}
	    else
		{
	    	hPrintf("%s</A> (aka %s) %s\n", spID, displayID, desc);
		}

	    /* remember the fact that a protein is shown under this PB supported genome */
	    for (i=0; i<maxPbOrg; i++)
	        {
	    	if (sameWord(orgSciName, pbOrgSciName[i]))
		    {
		    pbOrgPresented[i] = TRUE;
		    }
	        }
	    row = sqlNextRow(sr);
	    }
	hPrintf("</UL>");fflush(stdout);
   	sqlFreeResult(&sr);
	}
    sqlDisconnect(&proteinsConn);
    row3 = sqlNextRow(srCentral);
    }
sqlFreeResult(&srCentral);
hDisconnectCentral(&connCentral);
sqlDisconnect(&conn);

if (protCntInSwissByGene > protCntInSupportedGenomeDb)
    {
    otherCnt = -1;
    if (protCntInSupportedGenomeDb >0)
    	{
	otherCnt = 0;
    	hPrintf("<FONT SIZE=4><B>Other Organisms:</B></FONT>\n");
    	hPrintf("<UL>");
	}
    else
        {
    	hPrintf("<UL>");
        }

    oldOrg = strdup("");
    conn3 = sqlConnect(UNIPROT_DB_NAME);
    sqlSafef(query3, sizeof(query3),
            "select taxon.id, gene.acc, displayId.val, binomial, description.val "
            "from gene, displayId, accToTaxon,taxon, description "
            "where gene.val='%s' and gene.acc=displayId.acc and accToTaxon.taxon=taxon.id "
            "and accToTaxon.acc=gene.acc and description.acc=gene.acc order by binomial",
            queryID);
    sr3  = sqlMustGetResult(conn3, query3);
    row3 = sqlNextRow(sr3);

   /* go through each protein */
    while (row3 != NULL)
    	{
        taxonId  = row3[0];
        protAcc  = row3[1];
        protDisp = row3[2];
        protOrg  = row3[3];
        protDesc = row3[4];

	/* decide if this entry should be skipped */
	skipIt = FALSE;
	for (i=0; i<maxPbOrg; i++)
	    {
	    if (sameWord(pbOrgSciName[i], protOrg) && pbOrgPresented[i])
	    	{
	    	skipIt = TRUE;
		}
	    }

	/* print organism name if organism changed */
	if (!sameWord(protOrg, oldOrg))
	    {
	    if (!sameWord(oldOrg, ""))
	        {
	        hPrintf("</UL>\n");
		}
	    if (!skipIt)
	    	{
    		sqlSafefFrag(cond_str, sizeof(cond_str), "id=%s and nameType='genbank common name'", taxonId);
    		answer = sqlGetField(PROTEOME_DB_NAME, "taxonNames", "name", cond_str);
		hPrintf("<FONT SIZE=3><B>");
		hPrintf("<A href=\"http://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?mode=Undef&name=%s&lvl=0&srchmode=1\" TARGET=_blank>%s</A>",
           		cgiEncode(protOrg), protOrg);
		if (answer != NULL)
		    {
		    hPrintf(" (%s)", answer);
		    }
		hPrintf(":</B></FONT>\n");
		}
            hPrintf("<UL>\n");
	    }

	/* print protein entry, if it is not already displayed in the PB supported genome list */
	if (!skipIt)
	    {
	    otherCnt++;
	    if (sameWord(protAcc, protDisp))
		{
		hPrintf("<LI><A HREF=\"../cgi-bin/pbGlobal?proteinID=%s\">", protAcc);
		hPrintf("%s</A> %s\n", protAcc, protDesc);
		}
	    else
		{
		hPrintf("<LI><A HREF=\"../cgi-bin/pbGlobal?proteinID=%s\">", protAcc);
		if (strstr(protDisp, protAcc) != NULL)
		    {
		    hPrintf("%s</A> %s\n", protAcc, protDesc);
		    }
	        else
		    {
	    	    hPrintf("%s</A> (aka %s) %s\n", protAcc, protDisp, protDesc);
		    }
		}
	    }
	oldOrg = strdup(protOrg);
	row3 = sqlNextRow(sr3);
	}
    if (otherCnt == 0) hPrintf("</UL>None");fflush(stdout);
    sqlFreeResult(&sr3);
    sqlDisconnect(&conn3);
    }
}
예제 #14
0
void doMiddle()
/* Write what goes between BODY and /BODY */
{
pushWarnHandler(localWarn);
if (!cgiServerHttpsIsOn())
     usage();
struct sqlConnection *conn = edwConnectReadWrite();
printf("<FORM ACTION=\"edwWebRegisterScript\" METHOD=POST>\n");
printf("<B>Register Script with ENCODE Data Warehouse</B><BR>\n");
#ifdef SOON
uglyf("HTTP_AUTHENTICATION: '%s'<BR>\n", getenv("HTTP_AUTHENTICATION"));
uglyf("HTTP_AUTHORIZATION: '%s'<BR>\n", getenv("HTTP_AUTHORIZATION"));
dumpEnv(mainEnv);
#endif
if (userEmail == NULL)
    {
    printf("Please sign in:");
    printf("<INPUT TYPE=BUTTON NAME=\"signIn\" VALUE=\"sign in\" id=\"signin\">");
    }
else if (cgiVarExists("description"))
    {
    struct edwUser *user = edwUserFromEmail(conn, userEmail);
    if (user == NULL)
	edwWarnUnregisteredUser(userEmail);
    else
	{
	char password[HEXED_32_SIZE];
	edwRandomHexed32(password);
	char babyName[HEXED_32_SIZE];
	edwRandomBabble(babyName, sizeof(babyName));

	edwRegisterScript(conn, user, babyName, password, cgiString("description"));
	printf("Script now registered.<BR>\n");
	printf("The script user name is %s.<BR>\n", babyName);
	printf("The script password is %s.<BR>\n", password);
	printf("Please save the script user name and password somewhere. ");
	puts("Please pass these two and the URL");
	puts(" of your validated manifest file (validated.txt) to our server to submit data.");
	puts("Construct a URL of the form:<BR>");
	printf("<PRE>https://encodedcc.sdsc.edu/cgi-bin/edwScriptSubmit"
	       "?user=%s&password=%s&url=%s\n</PRE>", 
	       babyName, password,
	       cgiEncode("http://your.host.edu/your_dir/validated.txt"));
	puts("That is pass the CGI encoded variables user, password, and url to the ");
	puts("web services CGI at");
	puts("https://encodedcc.sdsc.edu/cgi-bin/edwScriptSubmit. ");
	puts("You can use the http://encodedcc.sdsc.edu/cgi-bin/edwWebBrowse site to ");
	puts("monitor your submission interactively. Please contact your wrangler if you ");
	puts("have any questions.<BR>");
	cgiMakeButton("submit", "Register another script");
	}
    printf(" ");
    edwPrintLogOutButton();
    }
else
    {
    struct edwUser *user = edwUserFromEmail(conn, userEmail);
    edwPrintLogOutButton();
    if (user == NULL)
	edwWarnUnregisteredUser(userEmail);
    else
	{
	printf("%s is authorized to register a new script<BR>\n", userEmail);
	printf("<BR>Script description:\n");
	cgiMakeTextVar("description", NULL, 80);
	cgiMakeSubmitButton();
	}
    }
printf("</FORM>\n");
}
예제 #15
0
파일: hgBlat.c 프로젝트: maximilianh/kent
void showAliPlaces(char *pslName, char *faName, 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);
int  minThreshold = (isStraightNuc ? minMatchShown : 0);

sprintf(uiState, "%s=%s", cartSessionVarName(), cartSessionId(cart));

/* If user has hidden BLAT track, add a setting that will unhide the 
   track if user clicks on a browser link. */
vis = cartOptionalString(cart, "hgUserPsl");
if (vis != NULL && sameString(vis, "hide"))
    snprintf(unhideTrack, sizeof(unhideTrack), "&hgUserPsl=dense");
else
    unhideTrack[0] = 0;

while ((psl = pslNext(lf)) != NULL)
    {
    if (psl->match >= minThreshold)
	slAddHead(&pslList, psl);
    }
lineFileClose(&lf);
if (pslList == NULL)
    {
    puts("<table><tr><td><hr>Sorry, no matches found<hr><td></tr></table>");
    return;
    }

if (sameString(sort, "query,start"))
    {
    slSort(&pslList, pslCmpQuery);
    }
else if (sameString(sort, "query,score"))
    {
    slSort(&pslList, pslCmpQueryScore);
    }
else if (sameString(sort, "score"))
    {
    slSort(&pslList, pslCmpScore);
    }
else if (sameString(sort, "chrom,start"))
    {
    slSort(&pslList, pslCmpTargetStart);
    }
else if (sameString(sort, "chrom,score"))
    {
    slSort(&pslList, pslCmpTargetScore);
    }
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);
	cartWebEnd();
	}
    }
else if (pslOut)
    {
    printf("<TT><PRE>");
    if (!sameString(output, "psl no header"))
	pslxWriteHead(stdout, qType, tType);
    for (psl = pslList; psl != NULL; psl = psl->next)
	pslTabOut(psl, stdout);
    printf("</PRE></TT>");
    }
else
    {
    printf("<H2>BLAT Search Results</H2>");
    printf("<TT><PRE>");
    printf("   ACTIONS      QUERY           SCORE START  END QSIZE IDENTITY CHRO STRAND  START    END      SPAN\n");
    printf("---------------------------------------------------------------------------------------------------\n");
    for (psl = pslList; psl != NULL; psl = psl->next)
	{
	printf("<A HREF=\"%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);
	printf("browser</A> ");
	printf("<A HREF=\"%s?o=%d&g=htcUserAli&i=%s+%s+%s&c=%s&l=%d&r=%d&db=%s&%s\">", 
	    hgcUrl, psl->tStart, pslName, cgiEncode(faName), psl->qName,  psl->tName,
	    psl->tStart, psl->tEnd, database, uiState);
	printf("details</A> ");
	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("</PRE></TT>");
    }
pslFreeList(&pslList);

}
void configurePage()
/* Put up configuration page. */
{
cartWebStart(cart, database, "Configure Genome Graphs");
hPrintf("<FORM ACTION=\"../cgi-bin/hgGenome\" METHOD=GET>\n");
cartSaveSession(cart);
hPrintf("<TABLE>\n");
hPrintf("<TR>\n");
hPrintf("<TD>\n");
hPrintf("image width: ");
cgiMakeIntVar(hggImageWidth, cartUsualInt(cart, hggImageWidth, hgDefaultPixWidth), 4);
hPrintf("</TD>\n");
hPrintf("<TD>\n");
hPrintf("graph height: ");
cgiMakeIntVar(hggGraphHeight, graphHeight(), 3);
hPrintf("</TD>\n");
hPrintf("<TD>\n");
hPrintf(" graphs per line: ");
makeNumMenu(hggGraphsPerLine, minGraphsPerLine, maxGraphsPerLine, 
	graphsPerLine());
hPrintf("</TD>\n");
hPrintf("<TD>\n");
hPrintf(" lines of graphs: ");
makeNumMenu(hggLinesOfGraphs, minLinesOfGraphs, maxLinesOfGraphs, 
	linesOfGraphs());
hPrintf("</TD>\n");
hPrintf("</TR>\n");
hPrintf("</TABLE>\n");
hPrintf("<TABLE><TR><TD>\n");
hPrintf("chromosome layout: ");
cgiMakeDropList(hggChromLayout, chromLayouts, ArraySize(chromLayouts), 
        chromLayout());
hPrintf("</TD></TR></TABLE>\n");
hPrintf("<TABLE><TR><TD>\n");
hPrintf("numerical labels: ");
cartMakeCheckBox(cart, hggLabels, TRUE);
hPrintf(" <I>Label axis on left for first graph and on right for last graph</I>");
hPrintf("</TD></TR></TABLE>\n");
hPrintf("<TABLE><TR><TD>\n");
hPrintf("highlight missing: ");
cartMakeCheckBox(cart, hggYellowMissing, FALSE);
hPrintf(" <I>Highlight background in yellow/gray if there is missing data in first graph</I>");
hPrintf("</TD></TR></TABLE>\n");
hPrintf("<TABLE><TR><TD>\n");
hPrintf("region padding: ");
cgiMakeIntVar(hggRegionPad, regionPad(), 6);
hPrintf(" <I>Number of bases to add to either side of regions over threshold</I>");
hPrintf("</TD></TR></TABLE>\n");
hPrintf("<TABLE><TR><TD>\n");
cgiMakeButton("submit", "submit");
hPrintf("</TD></TR></TABLE>\n");
hPrintf("</TD>\n");
hPrintf("</FORM>\n");

webNewSection("Configure Graphs");
hPrintf("Click on the hyperlink by the graph name to configure it.");
hTableStart();
hPrintf("<TR><TH>name</TH>");
hPrintf("<TH>description</TH></TR>");
struct slRef *ref;
for (ref = ggList; ref != NULL; ref = ref->next)
    {
    struct genoGraph *gg = ref->val;
    /* Only show custom graphs, stand-alone DB graphs, and composite */
    /* graphs.  Don't show subGraphs part of a composite. */
    if (gg->isSubGraph == FALSE)
	{
	char *tmp = cgiEncode(gg->name);
	hPrintf("<TR><TD><A HREF=\"../cgi-bin/hgGenome?%s&%s=on&g=%s\">",
		cartSidUrlString(cart), hggConfigureOne, tmp);
	freeMem(tmp);
	hPrintf("%s</A></TD>", gg->shortLabel);
	hPrintf("<TD>%s</TD></TR>\n", gg->longLabel);
	}
    }
hTableEnd();
cartWebEnd();
}
예제 #17
0
파일: getgene.c 프로젝트: bowhan/kent
void doMiddle()
{
char *seqName;
boolean intronsLowerCase = TRUE;
boolean intronsParenthesized = FALSE;
boolean hiliteNear = FALSE;
int startRange = 0;
int endRange = 0;
boolean gotRange = FALSE;
struct dnaSeq *cdnaSeq;
boolean isChromRange = FALSE;
DNA *dna;
char *translation = NULL;

seqName = cgiString("geneName");
seqName = trimSpaces(seqName);
if (cgiVarExists("intronsLowerCase"))
    intronsLowerCase = cgiBoolean("intronsLowerCase");
if (cgiVarExists("intronsParenthesized"))
    intronsParenthesized = cgiBoolean("intronsParenthesized");
if (cgiVarExists("startRange") && cgiVarExists("endRange" ))
    {
    startRange = cgiInt("startRange");
    endRange = cgiInt("endRange");
    gotRange = TRUE;
    }
if (cgiVarExists("hiliteNear"))
    {
    hiliteNear = TRUE;
    }
fprintf(stdout, "<P><TT>\n");

/* The logic here is a little complex to optimize speed.
 * If we can decide what type of thing the name refers to by
 * simply looking at the name we do.  Otherwise we have to
 * search the database in various ways until we get a hit. */
if (wormIsNamelessCluster(seqName))
    {
    isChromRange = TRUE;
    }
else if (wormIsChromRange(seqName))
    {
    isChromRange = TRUE;
    }
else if (getWormGeneDna(seqName, &dna, TRUE))
    {
    if (cgiBoolean("litLink"))
        {
        char nameBuf[64];
        char *geneName = NULL;
        char *productName = NULL;
        char *coding;
        int transSize;
        struct wormCdnaInfo info;

        printf("<H3>Information and Links for %s</H3>\n", seqName);
        if (wormInfoForGene(seqName, &info))
            {
            if (info.description)
                printf("<P>%s</P>\n", info.description);
            geneName = info.gene;
            productName = info.product;
            }
        else
            {
            if (wormIsGeneName(seqName))
                geneName = seqName;
            else if (wormGeneForOrf(seqName, nameBuf, sizeof(nameBuf)))
                geneName = nameBuf;
            }
        coding = cloneUpperOnly(dna);
        transSize = 1 + (strlen(coding)+2)/3;
        translation = needMem(1+strlen(coding)/3);
        dnaTranslateSome(coding, translation, transSize);
        freez(&coding);

        if (geneName)
            {
            printf("<A HREF=\"http://www.ncbi.nlm.nih.gov/htbin-post/Entrez/query?form=4&db=m"
                    "&term=C+elegans+%s&dispmax=50&relentrezdate=No+Limit\">", geneName);
            printf("PubMed search on gene: </A>%s<BR>\n", geneName);
            }
        if (productName)
            {
            char *encoded = cgiEncode(productName);
            printf("<A HREF=\"http://www.ncbi.nlm.nih.gov/htbin-post/Entrez/query?form=4&db=m"
                    "&term=%s&dispmax=50&relentrezdate=No+Limit\">", encoded);
            printf("PubMed search on product:</A> %s<BR>\n", productName);
            freeMem(encoded);
            }
        /* Process name to get rid of isoform letter for Proteome. */
        if (geneName)
            strcpy(nameBuf, geneName);
        else
            {
            strcpy(nameBuf, seqName);
#ifdef NEVER
            /* Sometimes Proteome requires the letter after the orf name
             * in alt-spliced cases, sometimes it can't handle it.... */
            nameLen = strlen(nameBuf);
            if (wormIsOrfName(nameBuf) && isalpha(nameBuf[nameLen-1]))
                {
                char *dotPos = strrchr(nameBuf, '.');
                if (dotPos != NULL && isdigit(dotPos[1]))
                    nameBuf[nameLen-1] = 0;
                }
#endif /* NEVER */
            }
	printf("<A HREF=\"http://www.wormbase.org/db/seq/sequence?name=%s;class=Sequence\">", seqName);
	printf("WormBase link on:</A> %s<BR>\n", seqName);
        printf("<A HREF=\"http://www.proteome.com/databases/WormPD/reports/%s.html\">", nameBuf);
        printf("Proteome link on:</A> %s<BR>\n<BR>\n", nameBuf);


        printf("<A HREF=#DNA>Genomic DNA Sequence</A><BR>\n");
        if (hiliteNear)
            printf("<A HREF=\"#CLICKED\">Shortcut to where you clicked in gene</A><BR>");
        printf("<A HREF=#protein>Translated Protein Sequence</A><BR>\n");
        htmlHorizontalLine();
	printf("<A NAME=DNA></A>");
        printf("<H3>%s Genomic DNA sequence</H3>", seqName);
        }
    if (!intronsLowerCase)
        tolowers(dna);
    if (hiliteNear)
	{
	if (!gotRange)
	    {
	    double nearPos = cgiDouble("hiliteNear");
	    int rad = 5;
	    int dnaSize = strlen(dna);
	    long mid = (int)(dnaSize * nearPos);
	    startRange = mid - rad;
	    if (startRange < 0) startRange = 0;
	    endRange = mid + rad;
	    if (endRange >= dnaSize) endRange = dnaSize - 1;
	    }
	}
    outputSeq(dna, strlen(dna), hiliteNear, startRange, endRange, stdout);
    freez(&dna);
    }
else if (wormCdnaSeq(seqName, &cdnaSeq, NULL))
    {
    outputSeq(cdnaSeq->dna, cdnaSeq->size, FALSE, 0, 0, stdout);
    }
else
    {
    isChromRange = TRUE;
    }
if (isChromRange)
    {
    char *chromId;
    int start, end;
    char strand = '+';
    int size;

    if (!wormGeneRange(seqName, &chromId, &strand, &start, &end))
        errAbort("Can't find %s",seqName);
    size = end - start;
    if (intronsLowerCase)
        dna = wormChromPartExonsUpper(chromId, start, size);
    else
        {
        dna = wormChromPart(chromId, start, size);
        touppers(dna);
        }
    if (cgiVarExists("strand"))
        strand = cgiString("strand")[0];
    if (strand == '-')
        reverseComplement(dna, size);
    outputSeq(dna, size, FALSE, 0, 0, stdout);
    }
if (translation != NULL)
    {
    htmlHorizontalLine();
    printf("<A NAME=protein></A>");
    printf("<H3>Translated Protein of %s</H3>\n", seqName);
    outputSeq(translation, strlen(translation), FALSE, 0, 0, stdout);
    freez(&translation);
    }
fprintf(stdout, "</TT></P>\n");

}
예제 #18
0
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()	*/