src/hg/instinct/bioInt2/bioSetLevel.c 1.3

1.3 2009/05/20 20:34:36 jsanborn
initial commit
Index: src/hg/instinct/bioInt2/bioSetLevel.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/bioSetLevel.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -b -B -U 4 -r1.2 -r1.3
--- src/hg/instinct/bioInt2/bioSetLevel.c	27 Apr 2009 06:15:48 -0000	1.2
+++ src/hg/instinct/bioInt2/bioSetLevel.c	20 May 2009 20:34:36 -0000	1.3
@@ -123,14 +123,15 @@
 
 struct analysisVals *av, *avList = NULL; 
 for (gs = spGenesets; gs; gs = gs->next)
     {
-    int feature_id = atoi(gs->name); //hashIntValDefault(featureHash, gs->name, -1);
+    int feature_id = atoi(gs->name);
     struct slName *members = gs->val;
     gd->genes = members;
     for (sp = spData; sp; sp = sp->next)
 	{
-	gd->data = sp->val;
+	struct typeHash *th = sp->val;
+	gd->data = th->hash;
 	int sample_id = atoi(sp->name);
 	av = ba->analyze(ba, gd, sample_id, feature_id);
 	if (!av)
 	    continue; 
@@ -149,100 +150,13 @@
 
 return avList;
 }            
 
-
-void slPairHashesFree(struct slPair **pEl)
-{
-struct slPair *el;
-
-if ((el = *pEl) == NULL) return;
-
-freeMem(el->name);
-struct hash *hash = el->val;
-hashFreeWithVals(&hash, analysisValsFree);
-freez(pEl);
-}
-
-void slPairHashesFreeList(struct slPair **pList)
-{
-struct slPair *el, *next;
-
-for (el = *pList; el != NULL; el = next)
-    {
-    next = el->next;
-    slPairHashesFree(&el);
-    }
-*pList = NULL;
-} 
-
-void slPairStringFree(struct slPair **pEl)
-{
-struct slPair *el;
-
-if ((el = *pEl) == NULL) return;
-
-freeMem(el->name);
-char *name = el->val;
-freeMem(name);
-freez(pEl);
-}
-
-void slPairStringFreeList(struct slPair **pList)
-{
-struct slPair *el, *next;
-
-for (el = *pList; el != NULL; el = next)
-    {
-    next = el->next;
-    slPairStringFree(&el);
-    }
-*pList = NULL;
-} 
-
-struct slPair *analysisValsSamplesHashes(struct sqlConnection *biConn,
-					 struct slName *dataset)
-{
-/* Currently only looks at first dataset in slName list passed in */
-char query[128];
-safef(query, sizeof(query), "select * from %s", dataset->name);
-struct slPair *sp, *spList = NULL;
-
-struct hash *hash = hashNew(0);
-struct sqlResult *sr = sqlGetResult(biConn, query);
-char **row = NULL;
-while ((row = sqlNextRow(sr)) != NULL)
-    {
-    char *sample_id = row[0];
-    char *feature_id = row[1];
-    struct analysisVals *av = analysisValsLoad(row);
-
-    struct hashEl *el = hashLookup(hash, sample_id);
-    if (!el)
-	{
-	AllocVar(sp);
-	sp->name = cloneString(sample_id);
-	sp->val = hashNew(0);
-	hashAdd(hash, sample_id, sp);
-	slAddHead(&spList, sp);
-	}
-    else
-	sp = el->val;
-                          
-    struct hash *featureHash = sp->val;
-    hashAdd(featureHash, feature_id, av);
-    }
-
-sqlFreeResult(&sr);
-hashFree(&hash);
-return spList;
-}  
-
 void genesetLevelPipeline(struct biAnalysis *ba)
 {
 uglyTime(NULL);
 struct sqlConnection *biConn = hAllocConnProfile("localDb", ba->db);
-struct slPair *spData = analysisValsSamplesHashes(biConn, ba->inputTables);
+struct slPair *spData = analysisValsSamplesHashesList(biConn, ba->inputTables);
 uglyTime("got sample hashes");
 
 struct slPair *spGenesets = getGenesets(biConn);
 fprintf(stderr, "got %d genesets\n", slCount(spGenesets));
@@ -254,8 +168,9 @@
 storeAnalysisValsInDb(biConn, ba->tableName, avList);
 uglyTime("analyzed all genesets");
 hFreeConn(&biConn);   
 
+analysisValsFreeList(&avList);
 slPairHashesFreeList(&spData);
 slPairStringFreeList(&spGenesets);
 hFreeConn(&biConn);
 }