src/hg/instinct/lib/hgHeatmapLib.c 1.66

1.66 2010/03/10 22:55:20 jsanborn
added profile to gh object for cancer public server
Index: src/hg/instinct/lib/hgHeatmapLib.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/lib/hgHeatmapLib.c,v
retrieving revision 1.65
retrieving revision 1.66
diff -b -B -U 4 -r1.65 -r1.66
--- src/hg/instinct/lib/hgHeatmapLib.c	18 Feb 2010 05:58:51 -0000	1.65
+++ src/hg/instinct/lib/hgHeatmapLib.c	10 Mar 2010 22:55:20 -0000	1.66
@@ -88,8 +88,9 @@
 gh->accessTable = NULL;
 gh->group = "Custom Tracks";
 
 gh->private = FALSE;
+gh->profile = cloneString("localDb");
 
 /* Settings on patient information from datasets.ra file */
 gh->raFile = NULL;
 gh->patDb = NULL;
@@ -107,16 +108,16 @@
 
 // probe table
 if (hashFindVal(tdbHash, "platform"))
 {
-	struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, gh->database);
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, gh->database);
 
-	/* Settings on gene sets from datasets.ra file */
-	gh->probeTable =(char *)(hashFindVal(tdbHash, "platform"));
-	if (!sqlTableExists(conn, gh->probeTable))
+/* Settings on gene sets from datasets.ra file */
+gh->probeTable =(char *)(hashFindVal(tdbHash, "platform"));
+if (!sqlTableExists(conn, gh->probeTable))
 		gh->probeTable= NULL;
 	
-	hFreeConn(&conn);
+hFreeConn(&conn);
 }
 else
 	gh->probeTable = NULL;
 
@@ -143,13 +144,9 @@
 
 /* microarray specific settings*/
 if (sameWord(gh->dataType,"bed 15"))
     {
-//    struct microarrayGroups *maGs = maGroupings(gh->database, tableName);
-//    if (!maGs)
-//	return NULL;
-    struct maGrouping *	allA = maGetGroupingFromCt(ct);
-  	  
+    struct maGrouping *allA = maGetGroupingFromCt(ct);
     gh->expCount = allA->size;
     }
 
 gh->anaResult = NULL;
@@ -237,8 +234,12 @@
     gh->private = TRUE;  // default to private tracks.
 else
     gh->private = !sameString(security, "public");
 
+gh->profile = (char *)(hashFindVal(raHash, "profile"));
+if (!gh->profile)
+    gh->profile = cloneString("localDb");
+
 /* microarray specific settings*/
 if (sameWord(gh->dataType,"bed 15"))
     {
     struct microarrayGroups *maGs = maGroupings(gh->database, tableName);
@@ -338,9 +339,9 @@
     defaultOrder(gh); 
     return;
     }
 
-struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, db);
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, db);
 
 if (!conn) // FIXME: why can this fail??
     {
     defaultOrder(gh); 
@@ -559,9 +560,9 @@
 char *key = gh->patField;
 char *val =gh->sampleField;
 
 struct sqlResult *sr;
-struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, db);
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, db);
 char **row;
 char *person;
 struct slName *patList=NULL;
 char query[strlen(sampleStr)+512];
@@ -590,9 +591,9 @@
 
 if ((labTable == NULL) || (key == NULL) || (db==NULL))
     return NULL;
 
-struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, db);
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, db);
 if (!conn)
     return NULL;
 
 char query[512];
@@ -627,9 +628,9 @@
 char *valField = gh->sampleField;
 
 if (!labTable || !key || !db)
     return NULL;
-struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, db); 
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, db); 
 if (!conn)
     return NULL;
 
 char *patStr = sqlStrFromSlNameList(patList);
@@ -760,9 +761,9 @@
 gs->name = NULL;
 gs->genes = slNameNew(gene);
 
 struct hash *geneHash = NULL;
-getChromHeatmapHash(&geneHash, gh->database, gh->probeTable,
+getChromHeatmapHash(gh, &geneHash, gh->database, gh->probeTable,
                     gh->name, NULL, gs);
 
 struct hashEl *el = hashLookup(geneHash, gene);
 if (!el)
@@ -820,9 +821,9 @@
     return;
     }
 
 /* get colList */
-struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, gh->patDb);
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, gh->patDb);
 char *raName = gh->raFile;
 struct column *colList = getColumns(conn, raName, gh->patDb);
 
 /* sort patients */
@@ -945,9 +946,9 @@
 	  tableName);
     }
 
 struct sqlConnection *conn;
-conn = hAllocConnProfile(heatMapDbProfile, database);
+conn = hAllocConnProfile(gh->profile, database);
 
 struct sqlResult *sr = sqlGetResult(conn, query);
 struct bed *tuple = NULL;
 struct bed *tupleList = NULL;
@@ -981,9 +982,9 @@
 safef(query, sizeof(query), 
       "select * from %s where chrom = '%s' and chromStart<%d and chromEnd>%d",
       tableName, chrom, stop,start);
 
-struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, database);
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, database);
 
 struct sqlResult *sr = sqlGetResult(conn, query);
 struct bed *tuple = NULL;
 struct bed *tupleList = NULL;
@@ -1029,9 +1030,9 @@
           "select * from %s \n",
           tableName);
     }
  
-struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, database);
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, database);
 
 struct sqlResult *sr = sqlGetResult(conn, query);
 struct bed *tuple = NULL;
 struct bed *tupleList = NULL;
@@ -1071,9 +1072,9 @@
 safef(query, sizeof(query), 
       "select * from %s where chrom = '%s' and chromStart<%d and chromEnd>%d",
       tableName, chrom, stop,start);
 
-struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, database);
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, database);
 
 struct sqlResult *sr = sqlGetResult(conn, query);
 struct bed *tuple = NULL;
 struct bed *tupleList = NULL;
@@ -1088,9 +1089,10 @@
 return tupleList;
 }
 
 
-void getChromHeatmapHash(struct hash **geneHash, char *geneDb, char *probeTable, 
+void getChromHeatmapHash(struct genoHeatmap *gh, struct hash **geneHash, char *geneDb, 
+			 char *probeTable, 
 			 char *tableName, char *chromName, struct geneSet *geneSets)
 /* Get the bed15 data of gneneSets 
    You can add probe hash information to geneHash accumulatively */ 
 {
@@ -1132,9 +1134,9 @@
           tableName, probeTable, tableName, probeTable, 
 	  probeTable, geneList); 
     }
 
-struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, geneDb);
+struct sqlConnection *conn = hAllocConnProfile(gh->profile, geneDb);
 struct sqlResult *sr = sqlGetResult(conn, query);
 
 struct bed *tuple = NULL;
 if (!(*geneHash))
@@ -1169,9 +1171,9 @@
 
 if ((labTable == NULL) || (key == NULL) || (value == NULL) || (patDb==NULL) )
     return NULL;
 
-struct sqlConnection *featureDbConn = hAllocConnProfile(heatMapDbProfile, patDb);
+struct sqlConnection *featureDbConn = hAllocConnProfile(gh->profile, patDb);
 if (!featureDbConn)
     return NULL;
 
 struct column *colList = getColumns(featureDbConn,raName,gh->patDb);
@@ -1325,9 +1327,9 @@
 char *probeAliases = gh->probeTable;
 char *tableName = gh->name; // no access table at gene set level
 
 struct hash *allHash = NULL;
-getChromHeatmapHash(&allHash, database, probeAliases,tableName, NULL, geneSets);  
+getChromHeatmapHash(gh, &allHash, database, probeAliases,tableName, NULL, geneSets);  
 if (!allHash)
     return NULL;
 
 // get the subsets
@@ -2050,9 +2052,9 @@
 
 char *probeAliases =gh->probeTable;
 
 struct hash *geneHash = NULL;
-getChromHeatmapHash(&geneHash,database, probeAliases, chromHeatmap, NULL, geneSets); 
+getChromHeatmapHash(gh, &geneHash,database, probeAliases, chromHeatmap, NULL, geneSets); 
 if (!geneHash)
     return NULL;
 
 struct hgStats *bd, *bedList = ar->stats;
@@ -2158,9 +2160,9 @@
 struct geneSet *geneSets =AllocA(struct geneSet);
 geneSets->genes = genes;
 
 struct hash *geneHash = NULL;
-getChromHeatmapHash(&geneHash, database, probeAliases, chromHeatmap, NULL, geneSets);
+getChromHeatmapHash(gh, &geneHash, database, probeAliases, chromHeatmap, NULL, geneSets);
 if (!geneHash)
     return;
 
 struct hgStats *bd, *bedList = ar->stats;