src/hg/instinct/bioInt2/populateDb.c 1.14

1.14 2010/05/16 00:06:18 sbenz
Added profile option for loading data, so we can use -profile=cancerPubDb
Index: src/hg/instinct/bioInt2/populateDb.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/populateDb.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -b -B -U 4 -r1.13 -r1.14
--- src/hg/instinct/bioInt2/populateDb.c	16 May 2010 00:01:47 -0000	1.13
+++ src/hg/instinct/bioInt2/populateDb.c	16 May 2010 00:06:18 -0000	1.14
@@ -18,8 +18,9 @@
 #include "bioIntDb.h"
 
 char *hgDb = "hg18";
 char *genome = "Human";
+char *profile = "localDb";
 
 void usage()
 /* Explain usage and exit. */
 {
@@ -28,8 +29,9 @@
   "   populateDb [OPTIONS] db table tissue\n"
   "options:\n"
   "   -dropAll   Drop/recreate any table\n"
   "   -tcga      handles TCGA ids\n"
+  "   -profile=localDb   handles alternate db profiles\n"
   "\n"
   );
 }
 
@@ -38,8 +40,9 @@
 
 static struct optionSpec options[] = {
     {"dropAll", OPTION_BOOLEAN},
     {"tcga", OPTION_BOOLEAN},
+    {"profile", OPTION_STRING},
     {NULL, 0},
 };
 
 
@@ -388,9 +391,9 @@
 if (!el)
     errAbort("No sampleField");
 char *sampleField = cloneString(el->val);
 
-struct sqlConnection *pdConn = hAllocConnProfile("localDb", patDb);
+struct sqlConnection *pdConn = hAllocConnProfile(profile, patDb);
 
 int i;
 struct samples *sa;
 for (i = 0; i < allA->size; i++)
@@ -570,9 +573,9 @@
 
 if (!raFile || !patDb || !patTable || !patField || !sampleField)
     errAbort("Incomplete ra entry for %s.", da->data_table);
 
-struct sqlConnection *pdConn = hAllocConnProfile("localDb", patDb); //connection to patient data
+struct sqlConnection *pdConn = hAllocConnProfile(profile, patDb); //connection to patient data
 
 if (DEBUG)
     fprintf(stderr, "Getting columns of clinical data...\n");
 struct column *col, *colList = getColumns(pdConn, raFile, patDb);
@@ -1128,9 +1131,9 @@
 boolean inputGenesets = FALSE;
 boolean inputGenesetInfo = FALSE;
 boolean inputGenesetGenes = FALSE;
 
-struct sqlConnection *pdConn = hAllocConnProfile("localDb", "pathway");
+struct sqlConnection *pdConn = hAllocConnProfile(profile, "pathway");
 if (!pdConn)
     errAbort("Could not connect to pathways database.\n");
 
 if (sqlTableExists(biConn, GE_TABLE) && dropTable)
@@ -1320,9 +1323,9 @@
     }
 slNameFreeList(&slList);
 
 /* set up geneset features */
-struct sqlConnection *pdConn = hAllocConnProfile("localDb", "pathway");
+struct sqlConnection *pdConn = hAllocConnProfile(profile, "pathway");
 safef(query, sizeof(query), 
       "select name from genesets;");
 slList = sqlQuickList(pdConn, query);
 
@@ -1359,9 +1362,9 @@
 void populateDb(char *db, char *tableName, char *tissue)
 {
 tissue = strLower(tissue);
 struct sqlConnection *biConn = hAllocConnProfile("localDb", db);
-struct sqlConnection *hgConn = hAllocConnProfile("localDb", hgDb);
+struct sqlConnection *hgConn = hAllocConnProfile(profile, hgDb);
 
 /* Create analysis features (if necessary) */
 uglyTime(NULL);
 fprintf(stderr, "Setting up analysis features...\n");
@@ -1428,8 +1431,10 @@
 if (optionExists("dropAll"))
     dropTable = TRUE;
 if (optionExists("tcga"))
     isTCGA = TRUE;
+if(optionExists("profile"))
+	profile = optionVal("profile", profile);
 
 populateDb(argv[1], argv[2], argv[3]);
 return 0;
 }