e70152e44cc66cc599ff6b699eb8adc07f3e656a kent Sat May 24 21:09:34 2014 -0700 Adding Copyright NNNN Regents of the University of California to all files I believe with reasonable certainty were developed under UCSC employ or as part of Genome Browser copyright assignment. diff --git src/hg/sageVisCGI/sageVisCGI.c src/hg/sageVisCGI/sageVisCGI.c index 2d328a2..125f16d 100644 --- src/hg/sageVisCGI/sageVisCGI.c +++ src/hg/sageVisCGI/sageVisCGI.c @@ -1,277 +1,280 @@ +/* Copyright (C) 2013 The Regents of the University of California + * See README in this or parent directory for licensing information. */ + /** \page sageVisCGI.doxp sageVisCGI cgi program for viewing graphs of sage data used standalone or called by the hgc.c program in ~kent/src/hg/hgc/.
sageVisCGI creates graphs on the fly for the sage data of different
uniGene clusters. The clusters to be graphed are passed via cgi (or command
line) in the form u= Example
or http://genome-test.cse.ucsc.edu/cgi-bin/sageVisCGI?md=20&u=202&u=122566 .
\sa sageVisCGI.c
*/
#include "common.h"
#include "hCommon.h"
#include "dystring.h"
#include "sage.h"
#include "sageExp.h"
#include "gnuPlot2D.h"
#include "portable.h"
#include "jksql.h"
#include "dnautil.h"
#include "cheapcgi.h"
#include "htmshell.h"
#include "knownMore.h"
#include "hdb.h"
#include "genePred.h"
#include "hgConfig.h"
int maxDataVal =0;
int dataValCeiling;
/**
Just prints out the
sageVisCGI md=20 u=202 u=122566 > out.html
tag and filename
*/
void doPlotPrintOut(char *fileName)
{
printf( "
\n", fileName);
}
/**
* Appends one string to another without having to
* worry about going over. Assumes that the total length
* of dest is the strlen(dest) + 1. Wasteful if you want to
* use it lots of times in a row as it reallocates memory every time
*/
void dynamicStrncat(char **dest, const char *src)
{
ExpandArray(*dest, (strlen(*dest)+1), (strlen(*dest) +strlen(src) + 1));
strncat(*dest, src, strlen(src));
}
/**
Construct a graphPoint from data in sage and current index.
Assumes that the experiments are stored in order.
*/
struct graphPoint2D*createSageGraphPoint(struct sage *sg, int i)
{
struct graphPoint2D *gp = NULL;
char name[128];
sprintf(name, "Hs.%d", sg->uni);
AllocVar(gp);
gp->y = sg->meds[i-1];
if(gp->y > maxDataVal && gp->y < dataValCeiling)
maxDataVal = gp->y;
gp->x = i;
gp->name = cloneString(name);
gp->hName = cloneString(name);
gp->groupName = cloneString(name);
return gp;
}
/**
Uses the sage experiment data (sageExp) and sage data itself (sage)
to construct the basic gnuPlot2D data type, specifically creating the
graphPoint2D data lists for each element in sgList */
struct gnuPlot2D *createSagePlot(struct sageExp *seList, struct sage *sgList)
{
struct gnuPlot2D *gp = createGnuPlot2D();
struct sage *sg = NULL;
int i;
for(sg = sgList; sg != NULL; sg = sg->next)
{
struct graphPoint2D *gList = NULL;
for (i=0; i< sg->numExps; i++)
{
struct graphPoint2D *gTemp = NULL;
gTemp = createSageGraphPoint(sg, i+1);
slAddHead(&gList, gTemp);
}
gptAddGraphPointList(gp, gList, "linesp");
}
return gp;
}
/* Creates a string which tells gnuPlot what label to put on
xTics and where to put them. Will Chop "SAGE" from name if present */
char * constructXticsFromExps(struct sageExp *seList)
{
char *ret = cloneString("set xtics rotate(");
static char buff[256];
int count =1;
struct sageExp *se;
for(se = seList; se != NULL; se = se->next)
{
if(se->next == NULL)
sprintf(buff, " \"%d)%s\" %d ", count, strstr(se->exp,"SAGE_") ? strstr(se->exp,"_") : se->exp , count);
else
sprintf(buff, " \"%d)%s\" %d, ", count, strstr(se->exp,"SAGE_") ? strstr(se->exp, "_") : se->exp, count);
dynamicStrncat(&ret, buff);
count++;
}
dynamicStrncat(&ret, ")\n");
return ret;
}
/* Prints the header appropriate for the title
* passed in. Links html to chucks stylesheet for
* easier maintaince
*/
void chuckHtmlStart(char *title)
{
printf("");
//FIXME blueStyle should not be absolute to genome-test and should bae called by:
// webIncludeResourceFile("blueStyle.css");
printf("\n");
printf("