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

1.57 2009/05/06 00:05:26 sbenz
Added custom track handling
Index: src/hg/instinct/lib/hgHeatmapLib.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/lib/hgHeatmapLib.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -b -B -U 4 -r1.56 -r1.57
--- src/hg/instinct/lib/hgHeatmapLib.c	28 Jan 2009 01:53:47 -0000	1.56
+++ src/hg/instinct/lib/hgHeatmapLib.c	6 May 2009 00:05:26 -0000	1.57
@@ -72,23 +71,26 @@
 /* Connect to database on local host */
 struct genoHeatmap *gh = AllocVar(gh);
 struct trackDb *tdb = ct->tdb;
 
-gh->database= database;
+gh->database= "customTrash";
 gh->sampleList =NULL;
 gh->sampleOrder = NULL;
 gh->expIdOrder= NULL;
 gh->tDb = tdb;
+gh->custom = TRUE;
+gh->ct = ct;
 
 /* Setting on heatmap description from datasets.ra file*/
-gh->name = cloneString(tdb->tableName);
+gh->name = cloneString(ct->dbTableName);
 gh->shortLabel = cloneString(tdb->shortLabel);
 gh->longLabel = cloneString(tdb->longLabel);
 if (sameString(tdb->type, "array") && (ct->fieldCount == 15))
     gh->dataType = cloneString("bed 15");
 else
     gh->dataType = cloneString(tdb->type);
 gh->accessTable = NULL;
+gh->group = "Custom Tracks";
 
 gh->private = FALSE;
 
 /* Settings on patient information from datasets.ra file */
@@ -132,11 +134,11 @@
     {
 //    struct microarrayGroups *maGs = maGroupings(gh->database, tableName);
 //    if (!maGs)
 //	return NULL;
-//    struct maGrouping *allA= maGs->allArrays;
-    gh->expCount = 0;
-//    gh->expCount = allA->size;
+    struct maGrouping *	allA = maGetGroupingFromCt(ct);
+  	  
+    gh->expCount = allA->size;
     }
 
 gh->anaResult = NULL;
 gh->anaResultHash = NULL;
@@ -159,8 +161,9 @@
 gh->sampleList =NULL;
 gh->sampleOrder = NULL;
 gh->expIdOrder= NULL;
 gh->tDb = hMaybeTrackInfo(conn, tableName);
+gh->custom = FALSE;
 
 /* Setting on heatmap description from datasets.ra file*/
 gh->name = (char *)(hashMustFindVal(raHash, "name"));
 gh->shortLabel = (char *)(hashMustFindVal(raHash, "shortLabel"));
@@ -394,13 +397,19 @@
 for (i=0; i< gh->expCount; i++)
     gh->expIdOrder[i]= -1;
 
 /*microarray specific settings*/
+struct maGrouping *allA= NULL;
+if(gh->custom)
+	allA = maGetGroupingFromCt(gh->ct);
+else
+{
 struct microarrayGroups *maGs = maGroupings(gh->database, gh->name);
 if (!maGs)
     return;
-struct maGrouping *allA= maGs->allArrays;
-
+//struct maGrouping *allA= maGs->allArrays;
+allA= maGs->allArrays;
+}
 int counter = 0;    
 int expId; // bed15 format expId 
 char *sample;
 struct slName *sl;
@@ -450,12 +459,22 @@
     gh->expIdOrder[i]= -1;
 
 int expId;
 char *sample;
-struct microarrayGroups *maGs = maGroupings(gh->database, gh->name);
-if (!maGs)
+//struct microarrayGroups *maGs = NULL;
+struct maGrouping *allA= NULL;
+if(gh->custom)
+	allA = maGetGroupingFromCt(gh->ct);
+else
+{
+	struct microarrayGroups *maGs = maGroupings(gh->database, gh->name);
+
+	if (!maGs)
     return;
-struct maGrouping *allA= maGs->allArrays;
+	
+	allA= maGs->allArrays;
+//struct maGrouping *allA= maGs->allArrays;
+}
 
 for (i=0; i< allA->size; i++)
     {
     sample = allA->names[i];
@@ -473,12 +492,19 @@
  */
 struct slName *getAllSamples(struct genoHeatmap *gh)
 {
 char *sample;
+struct maGrouping *allA= NULL;
+if(gh->custom)
+	allA = maGetGroupingFromCt(gh->ct);
+else
+{
 struct microarrayGroups *maGs = maGroupings(gh->database, gh->name);
 if (!maGs)
     return NULL;
-struct maGrouping *allA= maGs->allArrays;
+//struct maGrouping *allA= maGs->allArrays;
+allA= maGs->allArrays;
+}
 struct slName *list = newSlName(NULL);
 int i;
 
 for (i=0; i< allA->size; i++)