src/hg/instinct/extractData/extractData.c 1.3

1.3 2010/01/14 05:45:49 jsanborn
updated
Index: src/hg/instinct/extractData/extractData.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/extractData/extractData.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -B -U 4 -r1.2 -r1.3
--- src/hg/instinct/extractData/extractData.c	14 Jan 2010 05:37:23 -0000	1.2
+++ src/hg/instinct/extractData/extractData.c	14 Jan 2010 05:45:49 -0000	1.3
@@ -127,9 +127,9 @@
 
 return gaHash;                   
 }
 
-struct slDouble *getProbeData(struct sqlConnection *hgConn, struct maGrouping *allA, 
+struct slDouble *getProbeData(struct sqlConnection *hgConn, int expId, 
 			      char *dataTable, struct slName *probes)
 {
 struct slName *sl;
 struct dyString *dy = newDyString(100);
@@ -147,25 +147,19 @@
 
 /* Get bed15 data from hg18 database */
 struct sqlResult *sr = sqlGetResult(hgConn, query);
 
-int count = 0;
 char **row = NULL;
 struct slDouble *sdList = NULL;
 
-int i = 1;
 while ((row = sqlNextRow(sr)) != NULL)
     {
     struct bed *nb = bedLoadN(row+1, 15);
   
-// nb->expCount
-// nb->expScores
-    count += 1; 
-
-    if (i >= nb->expCount)
+    if (expId >= nb->expCount)
 	continue;
 
-    struct slDouble *sd = slDoubleNew(nb->expScores[i]);
+    struct slDouble *sd = slDoubleNew(nb->expScores[expId]);
     slAddHead(&sdList, sd);
 
     bedFree(&nb);
     }
@@ -188,8 +182,19 @@
 struct maGrouping *allA = getMaGrouping(hgConn, tableName);
 if (!allA)
     errAbort("Could not find maGrouping for %s!", tableName);
 
+int i = 0, expId = -1;
+for (; i < allA->size; i++)
+    {
+    if (!sameString(allA->names[i], sampleName))
+	continue;
+    expId = allA->expIds[i];
+    break;
+    }
+if (expId < 0)
+    errAbort("Couldn't find sample %s in %s.\n", sampleName, tableName);
+
 struct hash *settings = getSettings(tableName);
 
 el = hashLookup(settings, "aliasTable");
 if (!el)
@@ -202,9 +207,9 @@
 while ((el = hashNext(&cookie)) != NULL)
     {
     char *name = el->name;
     struct geneAlias *ga = el->val;    
-    struct slDouble *sd, *sdList = getProbeData(hgConn, allA, tableName, ga->probes);
+    struct slDouble *sd, *sdList = getProbeData(hgConn, expId, tableName, ga->probes);
 
     if (!sdList)
 	continue;