src/hg/instinct/bioInt2/bioLevelI.c 1.4

1.4 2009/03/24 05:21:54 jsanborn
updated
Index: src/hg/instinct/bioInt2/bioLevelI.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/bioLevelI.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -B -U 4 -r1.3 -r1.4
--- src/hg/instinct/bioInt2/bioLevelI.c	23 Mar 2009 18:19:29 -0000	1.3
+++ src/hg/instinct/bioInt2/bioLevelI.c	24 Mar 2009 05:21:54 -0000	1.4
@@ -108,11 +108,11 @@
 boolean analysisFeatureExists(struct sqlConnection *biConn, struct analysisFeatures *af)
 {
 char query[256];
 safef(query, sizeof(query),
-      "select * from analysisFeatures where id = %d "
+      "select * from %s where id = %d "
       "and feature_name = \"%s\" ",
-      af->id, af->feature_name);
+      AF_TABLE, af->id, af->feature_name);
 
 return sqlExists(biConn, query);
 } 
 
@@ -121,9 +121,9 @@
 fprintf(stdout, "getting analysis features hash.\n");
 
 struct hash *hash = hashNew(0);
 char query[128];
-safef(query, sizeof(query), "select * from analysisFeatures");
+safef(query, sizeof(query), "select * from %s", AF_TABLE);
 
 struct analysisFeatures *af, *afList = analysisFeaturesLoadByQuery(biConn, query);
 
 for (af = afList; af; af = af->next)
@@ -136,11 +136,10 @@
 struct hash *storeAnalysisFeaturesInDb(struct sqlConnection *biConn, struct analysisResult *arList)
 {
 fprintf(stdout, "storing analysis features\n");
 
-char *tableName = "analysisFeatures";
-if (!sqlTableExists(biConn, tableName))
-    createAnalysisFeaturesTable(biConn, tableName);
+if (!sqlTableExists(biConn, AF_TABLE))
+    createAnalysisFeaturesTable(biConn, AF_TABLE);
 
 /* Get existing analysis features */
 struct hash *hash = getAnalysisFeaturesHash(biConn);
 
@@ -150,15 +149,15 @@
     {
     if (hashLookup(hash, ar->feature))
 	continue;  // already visited, ignore
 
-    int feature_id = findIdInTable(biConn, tableName, "id", "feature_name", ar->feature); 
+    int feature_id = findIdInTable(biConn, AF_TABLE, "id", "feature_name", ar->feature); 
 
     AllocVar(af);
     af->id = feature_id;
     af->feature_name = cloneString(ar->feature);
     if (!analysisFeatureExists(biConn, af))
-	analysisFeaturesSaveToDb(biConn, af, tableName, 10);
+	analysisFeaturesSaveToDb(biConn, af, AF_TABLE, 10);
 
     hashAddInt(hash, af->feature_name, af->id);
     analysisFeaturesFree(&af);
     }
@@ -195,9 +194,9 @@
 if (!sqlTableExists(biConn, ba->tableName))
     createAnalysisValsTable(biConn, ba->tableName);
 
 struct hash *featureIds = storeAnalysisFeaturesInDb(biConn, arList); 
-struct hash *sampleIds = createHash(biConn, "samples", "name", "id");
+struct hash *sampleIds = createHash(biConn, SA_TABLE, "name", "id");
 
 struct analysisVals *av = AllocA(struct analysisVals);
 struct analysisResult *ar;
 for (ar = arList; ar; ar = ar->next)