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

1.6 2009/04/04 00:39:22 jsanborn
added cohorts api
Index: src/hg/instinct/bioInt2/populateDb.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/populateDb.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -b -B -U 4 -r1.5 -r1.6
--- src/hg/instinct/bioInt2/populateDb.c	27 Mar 2009 21:56:27 -0000	1.5
+++ src/hg/instinct/bioInt2/populateDb.c	4 Apr 2009 00:39:22 -0000	1.6
@@ -25,16 +25,19 @@
   "populateDb \n"
   "   populateDb [OPTIONS] db table tissue\n"
   "options:\n"
   "   -dropAll   Drop/recreate any table\n"
+  "   -tcga      handles TCGA ids\n"
   "\n"
   );
 }
 
 boolean dropTable = FALSE;   // If true, any table that should be dropped/recreated will be
+boolean isTCGA    = FALSE;   // If true, specially handle TCGA ids 
 
 static struct optionSpec options[] = {
     {"dropAll", OPTION_BOOLEAN},
+    {"tcga", OPTION_BOOLEAN},
     {NULL, 0},
 };
 
 
@@ -443,13 +446,22 @@
 int i;
 struct samples *sa;
 for (i = 0; i < allA->size; i++)
     {
-    char *sampleName = cloneString(allA->names[i]);
-    int expId = allA->expIds[i];
+    char *sampleName, *patientName;
+    if (isTCGA)
+	{
+	sampleName = cloneStringZ(allA->names[i], 16);
+	patientName = cloneStringZ(allA->names[i], 12);
+	}
+    else
+	{
+	sampleName = cloneString(allA->names[i]);
+	patientName = findPatientName(pdConn, patTable, patField, sampleField, sampleName); 
+	}
 
+    int expId = allA->expIds[i];
     int sampleId = findId(biConn, "id", "name", sampleName);
-    char *patientName = findPatientName(pdConn, patTable, patField, sampleField, sampleName); 
     int patientId = findId(biConn, "patient_id", "patient_name", patientName);
 
     AllocVar(sa);
     sa->id = sampleId;
@@ -1268,8 +1280,10 @@
 
 dropTable = FALSE;
 if (optionExists("dropAll"))
     dropTable = TRUE;
+if (optionExists("tcga"))
+    isTCGA = TRUE;
 
 populateDb(argv[1], argv[2], argv[3]);
 return 0;
 }