src/hg/instinct/hgHeatmap2/hgHeatmap2.h 1.51

1.51 2009/10/23 20:01:39 cszeto
Added local_url feature
Index: src/hg/instinct/hgHeatmap2/hgHeatmap2.h
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/hgHeatmap2/hgHeatmap2.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -b -B -U 1000000 -r1.50 -r1.51
--- src/hg/instinct/hgHeatmap2/hgHeatmap2.h	2 Sep 2009 17:43:13 -0000	1.50
+++ src/hg/instinct/hgHeatmap2/hgHeatmap2.h	23 Oct 2009 20:01:39 -0000	1.51
@@ -1,415 +1,415 @@
 /********************************************************************************/
 /* Copyright 2007-2009 -- The Regents of the University of California           */
 /********************************************************************************/
 
 /* hgHeatmap.h - Include file used by hgHeatmap. 
  * hgHeatmap is a CGI script that produces a web page containing
  * a graphic with all chromosomes in genome */
 
 #ifndef HGHEATMAP2_H
 #define HGHEATMAP2_H
 
 #define VERSION "1.5"
 #define DEBUG_IMG 1           // Will always write new images. 
 #define MAX_NUM_RESPONSE 100  // maximum number of objects in JSON response
 #define MIN_HEATMAP_HEIGHT 100  // minimum height of a heatmap
 
 #include "cart.h"
 #include "genoLay.h"
 #include "hgHeatmapLib.h"
 #include "featuresLib.h"
 #include "filterFeatures.h"
 
 #define DEBUG 0
 
 /*** Prefixes for variables in cart we don't share with other apps. ***/
 #define hghPrefix "hgHeatmap_"
 #define hghDo hghPrefix "do"
 
 #define hghTableName hghPrefix "tableName"
 
 /*** Our various cart variables. ***/
 #define hghHeatmap hghPrefix "heatmap"
 #define hghDataSet hghPrefix "dataset"
 #define hghDisplayType hghPrefix "display"
 #define hghGhName hghPrefix "ghName"
 #define hghMaxGapToFill hghPrefix "maxGapToFill"
 #define hghImageWidth hghPrefix "imageWidth"
 #define hghDataConfigPrefix hghPrefix "data_" 
 
 /** Commands from Javascript client **/
 
 #define hgh2Prefix "hgh2_"
 
 /* Obtaining Heatmaps */
 #define hgh2Mode hgh2Prefix "mode"
 #define hgh2Type hgh2Prefix "type"
 #define hgh2Dataset hgh2Prefix "dataset"
 #define hgh2ChromStart hgh2Prefix "chromStart"
 #define hgh2ChromEnd hgh2Prefix "chromEnd"
 #define hgh2GeneSets hgh2Prefix "geneSets"
 #define hgh2UserGeneSet hgh2Prefix "userGeneSet"
 #define hgh2Feature hgh2Prefix "feature"
 #define hgh2FeatureList hgh2Prefix "featureList"
 #define hgh2Width hgh2Prefix "width"
 #define hgh2FeatureWidth hgh2Prefix "featureWidth"
 #define hgh2SampleHeight hgh2Prefix "sampleHeight"
 
 #define hgh2LowColor hgh2Prefix "lowColor"
 #define hgh2ZeroColor hgh2Prefix "zeroColor"
 #define hgh2HighColor hgh2Prefix "highColor"
 
 /* Sorting heatmaps */
 #define hgh2SortType hgh2Prefix "sortType"
 #define hgh2FeatureSort hgh2Prefix "featureSort"
 #define hgh2FeatureSortDir hgh2Prefix "featureSortDir"
 
 #define hgh2SortChromStart hgh2Prefix "sortChromStart"
 #define hgh2SortChromEnd hgh2Prefix "sortChromEnd"
 #define hgh2SortGene hgh2Prefix "sortGene"
 #define hgh2SortDir hgh2Prefix "sortDir"
 
 /* Searching genesets */
 #define hgh2MatchingGenes hgh2Prefix "matchingGenes"
 #define hgh2MatchingGenesets hgh2Prefix "matchingGenesets"
 
 /* Storin user genesets */
 #define hgh2UserGenesetName hgh2Prefix "userGenesetName"
 #define hgh2UserGenesetMembers hgh2Prefix "userGenesetMembers"
 
 /* Subgrouping */
 #define hgh2SubgroupNum hgh2Prefix "subgroupNum"
 #define hgh2Subgroup1Features hgh2Prefix "subgroup1Features"
 #define hgh2Subgroup1Mins hgh2Prefix "subgroup1Mins"
 #define hgh2Subgroup1Maxs hgh2Prefix "subgroup1Maxs"
 #define hgh2Subgroup2Features hgh2Prefix "subgroup2Features"
 #define hgh2Subgroup2Mins hgh2Prefix "subgroup2Mins"
 #define hgh2Subgroup2Maxs hgh2Prefix "subgroup2Maxs"
 
 #define hgh2Subgroup1CodedFeatures hgh2Prefix "subgroup1CodedFeatures"
 #define hgh2Subgroup1Codes hgh2Prefix "subgroup1Codes"
 #define hgh2Subgroup2CodedFeatures hgh2Prefix "subgroup2CodedFeatures"
 #define hgh2Subgroup2Codes hgh2Prefix "subgroup2Codes"
 
 #define hgh2StatsFxn hgh2Prefix "statsFxn"
 
 /* Stats */
 #define hgh2StatsCorrection hgh2Prefix "statsCorrection"
 
 /* Save session */
 #define hgh2Vars hgh2Prefix "vars"
 #define hgh2Key hgh2Prefix "key"
 
 /* User login */
 #define hgh2UserLogin hgh2Prefix "login"
 #define hgh2UserPass hgh2Prefix "pass"
 #define hgh2UserId hgh2Prefix "userId"
 #define hgh2UserTokenId hgh2Prefix "tokenId"
 
 /* Tooltip */
 #define hgh2Sample hgh2Prefix "sample"
 #define hgh2Probe hgh2Prefix "probe"
 
 /* Circle Map */
 #define hgh2Gene hgh2Prefix "gene"
 #define hgh2Summarize hgh2Prefix "summarize"
 #define hgh2SummaryDisplay hgh2Prefix "summaryDisplay"
 
 /*** Name prefixes to separate user from db graphs. */
 #define hghUserTag "user: "
 #define hghDbTag "db: "
 
 #define hghVis hghPrefix "vis"
 #define hghBetweenRowPad 3
 #define hghBetweenVPad 2
 #define SMALL_SPACING 1
 #define hgHeatmapDefaultPixWidth 700
 #define hgFeatureDefaultPixWidth 250
 #define hgDefaultScalePixWidth 60
 #define hgHeatmapDefaultCircleWidth 50
 #define hgDefaultGenomeScalePixHeight 20
 #define hgHeatmapDefaultLabelHeight 15
 
 #define hgHeatmapDefaultSummaryHeight 150
 #define hgSampleHeightDefault 1
 #define hghSubgroupDefaultPixWidth 10
 #define hghTrackContrlBar 10
 #define hghFeatureLabel 80
 #define hghGeneSetLabel 120
 #define hghGeneLabelHeight 50
 #define hghGeneLabelMinSize 7   /* max number of genes to display gene labels*/
 #define hgh2SubgroupDefaultNum 2
 #define hghBed5Height 40
 #define hghProbCutoff 1.3       /* Equivalent of p<0.05 in -log10(p) */
 
 /* ---- Global variables declared in hgHeatmap.c */
 extern struct cart *cart;	/* This holds cgi and other variables between clicks. */
 
 struct hmPixel {
     struct hmPixel *next;
     int x;
     int y;
     int w;
     int h;
     
     double val;
     int count;
     Color color;
 
     struct slDouble *valList;
     double sum;
     double avg;
     double median;  // median
     double lowQ;    // low quantile
     double highQ;   // high quantile
     double lowW;    // low whisker
     double highW;   // high whisker
 
     double val2;    // TODO: A temporary hack
     int count2;
 };
 
 struct hmElement {
     struct hmElement *next;
 
     char *name;
     int pixelStart;
     int pixelEnd;
 
     unsigned long baseStart;  // only for chrom
     unsigned long baseEnd;    // only for chrom
 
     char *shortLabel;         // only for feature
     char *longLabel;          // only for feature
 
     char *probeName;           // only for geneset hmElement
     struct bed *bed;           // only for geneset hmElement
 };
 
 struct heatmapLay {
     struct heatmapLay *next;
 
     char *name;
     int width;
     int height;
 
     int genesetLabelHeight;
     int sampleHeight;
     double basesPerPixel;
 
     int pixelStart;
     int pixelEnd;
     
     MgFont *font;
     int fontHeight;
 
     /* For scales */
     int maxValPos;
     double maxVal;
     int minValPos;
     double minVal;
 
     struct hmElement *elements;
 
     struct rgbColor *lowColor;
     struct rgbColor *zeroColor;
     struct rgbColor *highColor;
 };
 
 /* next two structs are used to group datasets for display */
 struct dataset {
     struct dataset *next; 
 
     char *name;
     char *shortLabel;
     char *longLabel;
-    char *url;
+    char *local_url;
     int expCount;
 };
 
 struct datasetGroup {
     struct datasetGroup *next; 
 
     char *name;
     struct dataset *datasets;
 };
    
 
 /*** Routines from hgHeatmap.h ***/
 int heatmapHeight(struct genoHeatmap *gh);
 /* Return height of heatmap. This is only for those experiments that will be displayed. */
 
 int heatmapFullHeight(struct genoHeatmap *gh);
 /* Return height of the heatmap, analysis result, and gene labels if there are */
 
 int heatmapFullHeightWithLabels(struct genoHeatmap *gh);
 /* Return height of the heatmap section, after evaluation all related labels */
 
 char *dataSetRaName();
 /* Return the dataset configuration ra file name */
 
 int experimentHeight();
 /* Return height of an experiment */
 
 int experimentCount(struct genoHeatmap *gh);
 /* Return the number of experiments */
 
 char *getPathwayDb();
 
 struct sqlConnection *getPathwayDbConn();
 
 struct sqlConnection *getFeatureDbConn(struct genoHeatmap *gh);
 
 //char *chromLayout();
 /* Return one of above strings specifying layout. */
 
 struct genoLay *defaultLayoutH(struct genoLay *gl, int width, int height);
 /* Layout area based on previously layed out, horizontally extend on the right with width and height */
 
 struct genoLay *defaultLayoutV(struct genoLay *gl, int width, int height);
 /* Layout area based on previously layed out, vertically extend in below with width and height */
 
 struct genoLay *ggLayout(struct sqlConnection *conn);
 /* Figure out how to lay out image. */
 
 void heatmapLayResetMinMax(struct heatmapLay *hlList);
 
 struct heatmapLay *chromLayout(struct sqlConnection *conn, struct genoHeatmap *gh,
                                char *chromStart, int startBase,
                                char *chromEnd, int endBase,
                                int width, int sampleHeight);
 /* Layout chromosome view */
 
 struct heatmapLay *genesetLayout(struct genoHeatmap *gh,
                                  char *geneSetNames,
                                  int width, int sampleHeight);
 /* Layout geneset view */
 
 struct heatmapLay *featureLayout(struct genoHeatmap *gh, int width, int sampleHeight);
 /* Layout feature panel */
 
 /*** Routine related to mainPage.c ***/
 void mainPage(struct sqlConnection *conn, char *tableName);
 /* Do main page of application:  hotlinks bar, controls, graphic. */
 
 char *genomeGif(struct sqlConnection *conn, struct heatmapLay *hl, 
 		struct genoHeatmap *gh);
 
 char *genomeLabelsGif(struct sqlConnection *conn, struct heatmapLay *hl);
 
 char *genesetGif(struct sqlConnection *conn, struct heatmapLay *hl,
                  struct genoHeatmap *gh);
 
 char *genesetLabelsGif(struct sqlConnection *conn, struct heatmapLay *hl);
 
 char *genomeSummaryGif(struct sqlConnection *conn, struct heatmapLay *hl, 
 		       struct genoHeatmap *gh, struct slName *sampleList, 
 		       int totalH, int subset, int subsetNum);
 
 char *genesetSummaryGif(struct sqlConnection *conn, struct heatmapLay *hl,
 			struct genoHeatmap *gh, struct slName *sampleList, 
 			int totalH, int subset, int subsetNum);
  
 char *featureGif(struct sqlConnection *conn, struct heatmapLay *hl, 
 		 struct genoHeatmap *gh, char *tableName);
 
 char *featureSummaryGif(struct sqlConnection *conn, struct heatmapLay *hl,
                         struct genoHeatmap *gh, char *tableName, struct slName *sampleList, 
 			int buffer, int subset, int subsetNum);
 
 char *subgroupGif(struct genoHeatmap *gh, char *tableName, int width, int sampleHeight);
 
 char *genomeStatsGif(struct sqlConnection *conn, struct heatmapLay *hl,
                      struct genoHeatmap *gh, float colorCutoff);
 
 char *genesetStatsGif(struct sqlConnection *conn, struct heatmapLay *hl,
                       struct genoHeatmap *gh, float colorCutoff);
  
 void geneSetsAddPathwayLayout(struct geneSet *geneSets, struct hash *geneHash);  
 
 void geneSetsChromLayout(struct geneSet *geneSets);
 
 char *simpleScaleGif(struct heatmapLay *hl, struct genoHeatmap *gh, int subset, int subsetNum);
  
 char *genomeScaleGif(struct heatmapLay *hl, double numBases);
 
 void hghDoUsualHttp();
 /* Wrap html page dispatcher with code that writes out
  * HTTP header and write cart back to database. */
 
 /*** Functions imported from other modules. ***/
 
 void printMainHelp();
 /* Put up main page help info. */
 
 char *cartSettingsString(char *prefix, char *functionName);
 
 void trashDirMD5File(struct tempName *tn, char *dirName, char *suffix, char *strToHash);
 
 char *retrieveSettings(struct cart *cart, char *key);
 /* Retrieves settings according to unique key... if key is NULL, then session according to 
  * user id is returned.  If no session exists, NULL is returned. */
 
 int saveUserSettings(struct cart *cart, char *vars);  
 /* Saves settings in vars to mysql database, one entry in db per user-id.
  * -1 is returned if problem occurred. */
 
 struct slName *getGenesMatchingList(char *searchGenes); 
 
 struct slName *getGenesMatching(char *searchGene); 
 
 struct slName *getGenesNotMatching(char *searchGenes);
 
 struct slName *getGenesetsMatching(struct cart *cart, char *searchGenes, char *searchGenesets);
 
 char *getDescriptionOfGeneset(char *geneset);
  
 char *storeUserGeneset(struct cart *cart, char *name, char *geneList);
 
 struct geneSet *getAllPathways(struct cart *cart, char *db, char *pathwayNames);
 
 struct slName *getGenesInGeneset(struct cart *cart, char *geneset);
 
 char *annotationGif(struct heatmapLay *hl, char *table);
 
 void vgMakeColorGradient(struct vGfx *vg,
 			 struct rgbColor *start, struct rgbColor *end,
 			 int steps, Color *colorIxs);
 
 boolean singleChromImage(struct heatmapLay *hl); 
 
 char *md5HashString(char *str);
 
 char *toolTipByProbe(struct genoHeatmap *gh, char *sampleId, char *probeId);
 
 char *toolTipByFeature(struct genoHeatmap *gh, char *sampleId, char *feature);
 
 char *toolTipByPatient(struct genoHeatmap *gh, char *sampleId);
 
 char *toolTipByChromPos(struct genoHeatmap *gh, char *sampleId,
 			char *chrom, int chromStart, int chromStop); 
 
 char *toolTipGeneTrackByChromPos(char *db, char *tableName, char *chromName,
 				 int chromStart, int chromStop, int maxNumGenes);  
 
 void verticalTextRight(struct vGfx *vg, int x, int y,
 		       int width, int height, int colorIx, MgFont *font, char *string);
 
 void drawLayoutLines(struct vGfx *vg, struct heatmapLay *hlList, int width);
 
 
 void heatmapLaySetDefaultColor(struct heatmapLay *hl, char *platform);
 
 /* Moving all circle map to own file, to prepare for making it separate CGI */
 void modeGetCircleMap();
 
 void setupFeatureVisibility(struct genoHeatmap *gh);
 
 void setupSort(struct genoHeatmap *gh); 
 
 char *getId(struct sqlConnection *conn, char *table, char *key, char *sample, char *value);
 /* get patient ID from sample (or experiment) Id */ 
 
 void setSubgroups(struct genoHeatmap *gh);
 
 #endif /* HGHEATMAP2_H */