src/hg/instinct/hgHeatmap2/hgToolTip.c 1.7

1.7 2009/05/20 00:19:54 jsanborn
fixed bug with tool tip and sample/patient ids
Index: src/hg/instinct/hgHeatmap2/hgToolTip.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/hgHeatmap2/hgToolTip.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -b -B -U 4 -r1.6 -r1.7
--- src/hg/instinct/hgHeatmap2/hgToolTip.c	28 Jan 2009 01:54:28 -0000	1.6
+++ src/hg/instinct/hgHeatmap2/hgToolTip.c	20 May 2009 00:19:54 -0000	1.7
@@ -146,25 +146,36 @@
 {
 /* set up connection to table with both patient and sample information */
 char *db = gh->patDb;
 char *raName = gh->raFile;
+char *patField = gh->patField;
+char *patTable = gh->patTable;
+char *sampleField = gh->sampleField;
  
-if (raName == NULL || db==NULL)
+if (!raName || !db || !patField || !patTable || !sampleField)
     return NULL;
-
 struct sqlConnection *conn = hAllocConnProfile(heatMapDbProfile, db);
 
+char query[256];
+safef(query, sizeof(query), 
+      "select %s from %s where %s = \"%s\"",
+      patField, patTable, sampleField, sampleId);
+
+char *trackId = sqlQuickString(conn, query);
+if (!trackId)
+    return NULL;
+
 struct column *col, *colList = getColumns(conn, raName, db);
 
-struct slName *id = slNameNew(sampleId); 
+struct slName *id = slNameNew(trackId); 
 
 char *val = NULL;
 for (col = colList; col; col = col->next)
     {
     if (!sameString(col->name, feature))
 	continue;
 
-    if (subjectExists(conn, col, sampleId))
+    if (subjectExists(conn, col, trackId))
 	val = col->cellCodedVal(col, id, conn);
     break;
     }