src/hg/instinct/bioInt2/grabData.c 1.6

1.6 2009/05/20 20:34:36 jsanborn
initial commit
Index: src/hg/instinct/bioInt2/grabData.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/grabData.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -b -B -U 4 -r1.5 -r1.6
--- src/hg/instinct/bioInt2/grabData.c	30 Apr 2009 19:54:29 -0000	1.5
+++ src/hg/instinct/bioInt2/grabData.c	20 May 2009 20:34:36 -0000	1.6
@@ -33,9 +33,17 @@
     {"transpose", OPTION_BOOLEAN},
     {NULL, 0}
 }; 
 
-void spHashListTranspose(struct slPair *spList, struct slName *slList, struct slPair **retSpList, struct slName **retSlList)
+struct valConf {
+    struct valConf *next;
+    double val;
+    double conf;
+};
+
+
+void spHashListTranspose(struct slPair *spList, struct slName *slList, 
+			 struct slPair **retSpList, struct slName **retSlList)
 {
 // Transpose data in spList. So, sp->name = sample name, sp->hash keyed by feature name 
 
 struct slName *sl, *outSlList = NULL;
@@ -112,9 +120,9 @@
 for (sl = slList; sl; sl = sl->next)
     {
     fprintf(f, "%s", sl->name);
     if (sl->next)
-	fprintf(f, ",");
+	fprintf(f, "\t");
     }
 fprintf(f, "\n");
 
 struct hashEl *el;
@@ -126,13 +134,13 @@
 	{
 	el = hashLookup(hash, sl->name);
 	if (el)
 	    {
-	    struct slDouble *sd = el->val;
-	    fprintf(f, "%f", sd->val);
+	    struct valConf *vc = el->val;
+	    fprintf(f, "%f,%f", vc->val, vc->conf);
 	    }
 	if (sl->next)
-	    fprintf(f, ",");
+	    fprintf(f, "\t");
 	}
     fprintf(f, "\n");
     }
 }
@@ -237,10 +245,13 @@
 	{
 	slNameAddHead(&slList, sample);
 	hashAddInt(samplesHash, sample, 1);
 	}
-    struct slDouble *sd = slDoubleNew(val);
-    hashAdd(sampleData, sample, sd);
+    struct valConf *vc;
+    AllocVar(vc);
+    vc->val = val;
+    vc->conf = -1.0;
+    hashAdd(sampleData, sample, vc);
     } 
 
 sqlFreeResult(&sr);
 hashFree(&featureData);
@@ -299,8 +310,9 @@
     {
     char *sample_id = row[0];
     char *feature_id = row[1];
     double val = atof(row[2]);
+    double conf = atof(row[3]);
 
     struct hash *sampleData;
     struct hashEl *el = hashLookup(featureData, feature_id);
     if (!el)
@@ -326,10 +338,13 @@
 	{
 	slNameAddHead(&slList, name);
 	hashAddInt(samplesHash, name, 1);
 	}
-    struct slDouble *sd = slDoubleNew(val);
-    hashAdd(sampleData, name, sd);
+    struct valConf *vc;
+    AllocVar(vc);
+    vc->val = val;
+    vc->conf = conf;
+    hashAdd(sampleData, name, vc);
     } 
 
 sqlFreeResult(&sr);
 hashFree(&featureData);