src/hg/instinct/bioInt2/bioIntDb.c 1.9

1.9 2009/09/05 01:12:01 sbenz
Added em to pipeline
Index: src/hg/instinct/bioInt2/bioIntDb.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/bioIntDb.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -b -B -U 1000000 -r1.8 -r1.9
--- src/hg/instinct/bioInt2/bioIntDb.c	30 Apr 2009 19:54:28 -0000	1.8
+++ src/hg/instinct/bioInt2/bioIntDb.c	5 Sep 2009 01:12:01 -0000	1.9
@@ -1,3640 +1,3701 @@
 /* bioIntDb.c was originally generated by the autoSql program, which also 
  * generated bioIntDb.h and bioIntDb.sql.  This module links the database and
  * the RAM representation of objects. */
 
 #include "common.h"
 #include "linefile.h"
 #include "dystring.h"
 #include "jksql.h"
 #include "bioIntDb.h"
 
 static char const rcsid[] = "$Id$";
 
 void genesetsStaticLoad(char **row, struct genesets *ret)
 /* Load a row from genesets table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->name = row[1];
 ret->source = row[2];
 }
 
 struct genesets *genesetsLoad(char **row)
 /* Load a genesets from row fetched with select * from genesets
  * from database.  Dispose of this with genesetsFree(). */
 {
 struct genesets *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->name = cloneString(row[1]);
 ret->source = cloneString(row[2]);
 return ret;
 }
 
 struct genesets *genesetsLoadAll(char *fileName) 
 /* Load all genesets from a whitespace-separated file.
  * Dispose of this with genesetsFreeList(). */
 {
 struct genesets *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileRow(lf, row))
     {
     el = genesetsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct genesets *genesetsLoadAllByChar(char *fileName, char chopper) 
 /* Load all genesets from a chopper separated file.
  * Dispose of this with genesetsFreeList(). */
 {
 struct genesets *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = genesetsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct genesets *genesetsLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all genesets from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with genesetsFreeList(). */
 {
 struct genesets *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = genesetsLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void genesetsSaveToDb(struct sqlConnection *conn, struct genesets *el, char *tableName, int updateSize)
 /* Save genesets as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use genesetsSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->id,  el->name,  el->source);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void genesetsSaveToDbEscaped(struct sqlConnection *conn, struct genesets *el, char *tableName, int updateSize)
 /* Save genesets as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than genesetsSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *name, *source;
 name = sqlEscapeString(el->name);
 source = sqlEscapeString(el->source);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->id,  name,  source);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&name);
 freez(&source);
 }
 
 struct genesets *genesetsCommaIn(char **pS, struct genesets *ret)
 /* Create a genesets out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new genesets */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->name = sqlStringComma(&s);
 ret->source = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void genesetsFree(struct genesets **pEl)
 /* Free a single dynamically allocated genesets such as created
  * with genesetsLoad(). */
 {
 struct genesets *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->name);
 freeMem(el->source);
 freez(pEl);
 }
 
 void genesetsFreeList(struct genesets **pList)
 /* Free a list of dynamically allocated genesets's */
 {
 struct genesets *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     genesetsFree(&el);
     }
 *pList = NULL;
 }
 
 void genesetsOutput(struct genesets *el, FILE *f, char sep, char lastSep) 
 /* Print out genesets.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->name);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->source);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void genesetGenesStaticLoad(char **row, struct genesetGenes *ret)
 /* Load a row from genesetGenes table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->gene_id = sqlUnsigned(row[1]);
 }
 
 struct genesetGenes *genesetGenesLoad(char **row)
 /* Load a genesetGenes from row fetched with select * from genesetGenes
  * from database.  Dispose of this with genesetGenesFree(). */
 {
 struct genesetGenes *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->gene_id = sqlUnsigned(row[1]);
 return ret;
 }
 
 struct genesetGenes *genesetGenesLoadAll(char *fileName) 
 /* Load all genesetGenes from a whitespace-separated file.
  * Dispose of this with genesetGenesFreeList(). */
 {
 struct genesetGenes *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileRow(lf, row))
     {
     el = genesetGenesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct genesetGenes *genesetGenesLoadAllByChar(char *fileName, char chopper) 
 /* Load all genesetGenes from a chopper separated file.
  * Dispose of this with genesetGenesFreeList(). */
 {
 struct genesetGenes *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = genesetGenesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct genesetGenes *genesetGenesLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all genesetGenes from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with genesetGenesFreeList(). */
 {
 struct genesetGenes *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = genesetGenesLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void genesetGenesSaveToDb(struct sqlConnection *conn, struct genesetGenes *el, char *tableName, int updateSize)
 /* Save genesetGenes as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use genesetGenesSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u)", 
 	tableName,  el->id,  el->gene_id);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void genesetGenesSaveToDbEscaped(struct sqlConnection *conn, struct genesetGenes *el, char *tableName, int updateSize)
 /* Save genesetGenes as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than genesetGenesSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u)", 
 	tableName,  el->id,  el->gene_id);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 struct genesetGenes *genesetGenesCommaIn(char **pS, struct genesetGenes *ret)
 /* Create a genesetGenes out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new genesetGenes */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->gene_id = sqlUnsignedComma(&s);
 *pS = s;
 return ret;
 }
 
 void genesetGenesFree(struct genesetGenes **pEl)
 /* Free a single dynamically allocated genesetGenes such as created
  * with genesetGenesLoad(). */
 {
 struct genesetGenes *el;
 
 if ((el = *pEl) == NULL) return;
 freez(pEl);
 }
 
 void genesetGenesFreeList(struct genesetGenes **pList)
 /* Free a list of dynamically allocated genesetGenes's */
 {
 struct genesetGenes *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     genesetGenesFree(&el);
     }
 *pList = NULL;
 }
 
 void genesetGenesOutput(struct genesetGenes *el, FILE *f, char sep, char lastSep) 
 /* Print out genesetGenes.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 fprintf(f, "%u", el->gene_id);
 fputc(lastSep,f);
 }
 
 void genesetInfoStaticLoad(char **row, struct genesetInfo *ret)
 /* Load a row from genesetInfo table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->description = row[1];
 }
 
 struct genesetInfo *genesetInfoLoad(char **row)
 /* Load a genesetInfo from row fetched with select * from genesetInfo
  * from database.  Dispose of this with genesetInfoFree(). */
 {
 struct genesetInfo *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->description = cloneString(row[1]);
 return ret;
 }
 
 struct genesetInfo *genesetInfoLoadAll(char *fileName) 
 /* Load all genesetInfo from a whitespace-separated file.
  * Dispose of this with genesetInfoFreeList(). */
 {
 struct genesetInfo *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileRow(lf, row))
     {
     el = genesetInfoLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct genesetInfo *genesetInfoLoadAllByChar(char *fileName, char chopper) 
 /* Load all genesetInfo from a chopper separated file.
  * Dispose of this with genesetInfoFreeList(). */
 {
 struct genesetInfo *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = genesetInfoLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct genesetInfo *genesetInfoLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all genesetInfo from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with genesetInfoFreeList(). */
 {
 struct genesetInfo *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = genesetInfoLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void genesetInfoSaveToDb(struct sqlConnection *conn, struct genesetInfo *el, char *tableName, int updateSize)
 /* Save genesetInfo as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use genesetInfoSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%s)", 
 	tableName,  el->id,  el->description);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void genesetInfoSaveToDbEscaped(struct sqlConnection *conn, struct genesetInfo *el, char *tableName, int updateSize)
 /* Save genesetInfo as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than genesetInfoSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *description;
 description = sqlEscapeString(el->description);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s')", 
 	tableName,  el->id,  description);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&description);
 }
 
 struct genesetInfo *genesetInfoCommaIn(char **pS, struct genesetInfo *ret)
 /* Create a genesetInfo out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new genesetInfo */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->description = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void genesetInfoFree(struct genesetInfo **pEl)
 /* Free a single dynamically allocated genesetInfo such as created
  * with genesetInfoLoad(). */
 {
 struct genesetInfo *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->description);
 freez(pEl);
 }
 
 void genesetInfoFreeList(struct genesetInfo **pList)
 /* Free a list of dynamically allocated genesetInfo's */
 {
 struct genesetInfo *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     genesetInfoFree(&el);
     }
 *pList = NULL;
 }
 
 void genesetInfoOutput(struct genesetInfo *el, FILE *f, char sep, char lastSep) 
 /* Print out genesetInfo.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->description);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void tissuesStaticLoad(char **row, struct tissues *ret)
 /* Load a row from tissues table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->name = row[1];
 }
 
 struct tissues *tissuesLoad(char **row)
 /* Load a tissues from row fetched with select * from tissues
  * from database.  Dispose of this with tissuesFree(). */
 {
 struct tissues *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->name = cloneString(row[1]);
 return ret;
 }
 
 struct tissues *tissuesLoadAll(char *fileName) 
 /* Load all tissues from a whitespace-separated file.
  * Dispose of this with tissuesFreeList(). */
 {
 struct tissues *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileRow(lf, row))
     {
     el = tissuesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct tissues *tissuesLoadAllByChar(char *fileName, char chopper) 
 /* Load all tissues from a chopper separated file.
  * Dispose of this with tissuesFreeList(). */
 {
 struct tissues *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = tissuesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct tissues *tissuesLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all tissues from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with tissuesFreeList(). */
 {
 struct tissues *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = tissuesLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void tissuesSaveToDb(struct sqlConnection *conn, struct tissues *el, char *tableName, int updateSize)
 /* Save tissues as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use tissuesSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s')", 
 	tableName,  el->id,  el->name);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void tissuesSaveToDbEscaped(struct sqlConnection *conn, struct tissues *el, char *tableName, int updateSize)
 /* Save tissues as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than tissuesSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *name;
 name = sqlEscapeString(el->name);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s')", 
 	tableName,  el->id,  name);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&name);
 }
 
 struct tissues *tissuesCommaIn(char **pS, struct tissues *ret)
 /* Create a tissues out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new tissues */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->name = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void tissuesFree(struct tissues **pEl)
 /* Free a single dynamically allocated tissues such as created
  * with tissuesLoad(). */
 {
 struct tissues *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->name);
 freez(pEl);
 }
 
 void tissuesFreeList(struct tissues **pList)
 /* Free a list of dynamically allocated tissues's */
 {
 struct tissues *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     tissuesFree(&el);
     }
 *pList = NULL;
 }
 
 void tissuesOutput(struct tissues *el, FILE *f, char sep, char lastSep) 
 /* Print out tissues.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->name);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void dataTypesStaticLoad(char **row, struct dataTypes *ret)
 /* Load a row from dataTypes table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->format = row[1];
 ret->name = row[2];
 }
 
 struct dataTypes *dataTypesLoad(char **row)
 /* Load a dataTypes from row fetched with select * from dataTypes
  * from database.  Dispose of this with dataTypesFree(). */
 {
 struct dataTypes *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->format = cloneString(row[1]);
 ret->name = cloneString(row[2]);
 return ret;
 }
 
 struct dataTypes *dataTypesLoadAll(char *fileName) 
 /* Load all dataTypes from a whitespace-separated file.
  * Dispose of this with dataTypesFreeList(). */
 {
 struct dataTypes *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileRow(lf, row))
     {
     el = dataTypesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct dataTypes *dataTypesLoadAllByChar(char *fileName, char chopper) 
 /* Load all dataTypes from a chopper separated file.
  * Dispose of this with dataTypesFreeList(). */
 {
 struct dataTypes *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = dataTypesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct dataTypes *dataTypesLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all dataTypes from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with dataTypesFreeList(). */
 {
 struct dataTypes *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = dataTypesLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void dataTypesSaveToDb(struct sqlConnection *conn, struct dataTypes *el, char *tableName, int updateSize)
 /* Save dataTypes as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use dataTypesSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->id,  el->format,  el->name);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void dataTypesSaveToDbEscaped(struct sqlConnection *conn, struct dataTypes *el, char *tableName, int updateSize)
 /* Save dataTypes as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than dataTypesSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *format, *name;
 format = sqlEscapeString(el->format);
 name = sqlEscapeString(el->name);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->id,  format,  name);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&format);
 freez(&name);
 }
 
 struct dataTypes *dataTypesCommaIn(char **pS, struct dataTypes *ret)
 /* Create a dataTypes out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new dataTypes */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->format = sqlStringComma(&s);
 ret->name = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void dataTypesFree(struct dataTypes **pEl)
 /* Free a single dynamically allocated dataTypes such as created
  * with dataTypesLoad(). */
 {
 struct dataTypes *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->format);
 freeMem(el->name);
 freez(pEl);
 }
 
 void dataTypesFreeList(struct dataTypes **pList)
 /* Free a list of dynamically allocated dataTypes's */
 {
 struct dataTypes *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     dataTypesFree(&el);
     }
 *pList = NULL;
 }
 
 void dataTypesOutput(struct dataTypes *el, FILE *f, char sep, char lastSep) 
 /* Print out dataTypes.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->format);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->name);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void datasetsStaticLoad(char **row, struct datasets *ret)
 /* Load a row from datasets table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->tissue_id = sqlUnsigned(row[1]);
 ret->type_id = sqlUnsigned(row[2]);
 ret->num_samples = sqlUnsigned(row[3]);
 ret->name = row[4];
 ret->data_table = row[5];
 }
 
 struct datasets *datasetsLoad(char **row)
 /* Load a datasets from row fetched with select * from datasets
  * from database.  Dispose of this with datasetsFree(). */
 {
 struct datasets *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->tissue_id = sqlUnsigned(row[1]);
 ret->type_id = sqlUnsigned(row[2]);
 ret->num_samples = sqlUnsigned(row[3]);
 ret->name = cloneString(row[4]);
 ret->data_table = cloneString(row[5]);
 return ret;
 }
 
 struct datasets *datasetsLoadAll(char *fileName) 
 /* Load all datasets from a whitespace-separated file.
  * Dispose of this with datasetsFreeList(). */
 {
 struct datasets *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[6];
 
 while (lineFileRow(lf, row))
     {
     el = datasetsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct datasets *datasetsLoadAllByChar(char *fileName, char chopper) 
 /* Load all datasets from a chopper separated file.
  * Dispose of this with datasetsFreeList(). */
 {
 struct datasets *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[6];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = datasetsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct datasets *datasetsLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all datasets from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with datasetsFreeList(). */
 {
 struct datasets *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = datasetsLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void datasetsSaveToDb(struct sqlConnection *conn, struct datasets *el, char *tableName, int updateSize)
 /* Save datasets as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use datasetsSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%u,%u,'%s','%s')", 
 	tableName,  el->id,  el->tissue_id,  el->type_id,  el->num_samples,  el->name,  el->data_table);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void datasetsSaveToDbEscaped(struct sqlConnection *conn, struct datasets *el, char *tableName, int updateSize)
 /* Save datasets as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than datasetsSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *name, *data_table;
 name = sqlEscapeString(el->name);
 data_table = sqlEscapeString(el->data_table);
 
 dyStringPrintf(update, "insert into %s values ( %u,%u,%u,%u,'%s','%s')", 
 	tableName,  el->id,  el->tissue_id,  el->type_id,  el->num_samples,  name,  data_table);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&name);
 freez(&data_table);
 }
 
 struct datasets *datasetsCommaIn(char **pS, struct datasets *ret)
 /* Create a datasets out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new datasets */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->tissue_id = sqlUnsignedComma(&s);
 ret->type_id = sqlUnsignedComma(&s);
 ret->num_samples = sqlUnsignedComma(&s);
 ret->name = sqlStringComma(&s);
 ret->data_table = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void datasetsFree(struct datasets **pEl)
 /* Free a single dynamically allocated datasets such as created
  * with datasetsLoad(). */
 {
 struct datasets *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->name);
 freeMem(el->data_table);
 freez(pEl);
 }
 
 void datasetsFreeList(struct datasets **pList)
 /* Free a list of dynamically allocated datasets's */
 {
 struct datasets *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     datasetsFree(&el);
     }
 *pList = NULL;
 }
 
 void datasetsOutput(struct datasets *el, FILE *f, char sep, char lastSep) 
 /* Print out datasets.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 fprintf(f, "%u", el->tissue_id);
 fputc(sep,f);
 fprintf(f, "%u", el->type_id);
 fputc(sep,f);
 fprintf(f, "%u", el->num_samples);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->name);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->data_table);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void cohortsStaticLoad(char **row, struct cohorts *ret)
 /* Load a row from cohorts table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->name = row[1];
 }
 
 struct cohorts *cohortsLoad(char **row)
 /* Load a cohorts from row fetched with select * from cohorts
  * from database.  Dispose of this with cohortsFree(). */
 {
 struct cohorts *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->name = cloneString(row[1]);
 return ret;
 }
 
 struct cohorts *cohortsLoadAll(char *fileName) 
 /* Load all cohorts from a whitespace-separated file.
  * Dispose of this with cohortsFreeList(). */
 {
 struct cohorts *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileRow(lf, row))
     {
     el = cohortsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct cohorts *cohortsLoadAllByChar(char *fileName, char chopper) 
 /* Load all cohorts from a chopper separated file.
  * Dispose of this with cohortsFreeList(). */
 {
 struct cohorts *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = cohortsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct cohorts *cohortsLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all cohorts from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with cohortsFreeList(). */
 {
 struct cohorts *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = cohortsLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void cohortsSaveToDb(struct sqlConnection *conn, struct cohorts *el, char *tableName, int updateSize)
 /* Save cohorts as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use cohortsSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s')", 
 	tableName,  el->id,  el->name);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void cohortsSaveToDbEscaped(struct sqlConnection *conn, struct cohorts *el, char *tableName, int updateSize)
 /* Save cohorts as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than cohortsSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *name;
 name = sqlEscapeString(el->name);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s')", 
 	tableName,  el->id,  name);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&name);
 }
 
 struct cohorts *cohortsCommaIn(char **pS, struct cohorts *ret)
 /* Create a cohorts out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new cohorts */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->name = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void cohortsFree(struct cohorts **pEl)
 /* Free a single dynamically allocated cohorts such as created
  * with cohortsLoad(). */
 {
 struct cohorts *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->name);
 freez(pEl);
 }
 
 void cohortsFreeList(struct cohorts **pList)
 /* Free a list of dynamically allocated cohorts's */
 {
 struct cohorts *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     cohortsFree(&el);
     }
 *pList = NULL;
 }
 
 void cohortsOutput(struct cohorts *el, FILE *f, char sep, char lastSep) 
 /* Print out cohorts.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->name);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void datasetCohortStaticLoad(char **row, struct datasetCohort *ret)
 /* Load a row from datasetCohort table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->dataset_id = sqlUnsigned(row[0]);
 ret->cohort_id = sqlUnsigned(row[1]);
 }
 
 struct datasetCohort *datasetCohortLoad(char **row)
 /* Load a datasetCohort from row fetched with select * from datasetCohort
  * from database.  Dispose of this with datasetCohortFree(). */
 {
 struct datasetCohort *ret;
 
 AllocVar(ret);
 ret->dataset_id = sqlUnsigned(row[0]);
 ret->cohort_id = sqlUnsigned(row[1]);
 return ret;
 }
 
 struct datasetCohort *datasetCohortLoadAll(char *fileName) 
 /* Load all datasetCohort from a whitespace-separated file.
  * Dispose of this with datasetCohortFreeList(). */
 {
 struct datasetCohort *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileRow(lf, row))
     {
     el = datasetCohortLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct datasetCohort *datasetCohortLoadAllByChar(char *fileName, char chopper) 
 /* Load all datasetCohort from a chopper separated file.
  * Dispose of this with datasetCohortFreeList(). */
 {
 struct datasetCohort *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = datasetCohortLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct datasetCohort *datasetCohortLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all datasetCohort from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with datasetCohortFreeList(). */
 {
 struct datasetCohort *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = datasetCohortLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void datasetCohortSaveToDb(struct sqlConnection *conn, struct datasetCohort *el, char *tableName, int updateSize)
 /* Save datasetCohort as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use datasetCohortSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u)", 
 	tableName,  el->dataset_id,  el->cohort_id);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void datasetCohortSaveToDbEscaped(struct sqlConnection *conn, struct datasetCohort *el, char *tableName, int updateSize)
 /* Save datasetCohort as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than datasetCohortSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u)", 
 	tableName,  el->dataset_id,  el->cohort_id);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 struct datasetCohort *datasetCohortCommaIn(char **pS, struct datasetCohort *ret)
 /* Create a datasetCohort out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new datasetCohort */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->dataset_id = sqlUnsignedComma(&s);
 ret->cohort_id = sqlUnsignedComma(&s);
 *pS = s;
 return ret;
 }
 
 void datasetCohortFree(struct datasetCohort **pEl)
 /* Free a single dynamically allocated datasetCohort such as created
  * with datasetCohortLoad(). */
 {
 struct datasetCohort *el;
 
 if ((el = *pEl) == NULL) return;
 freez(pEl);
 }
 
 void datasetCohortFreeList(struct datasetCohort **pList)
 /* Free a list of dynamically allocated datasetCohort's */
 {
 struct datasetCohort *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     datasetCohortFree(&el);
     }
 *pList = NULL;
 }
 
 void datasetCohortOutput(struct datasetCohort *el, FILE *f, char sep, char lastSep) 
 /* Print out datasetCohort.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->dataset_id);
 fputc(sep,f);
 fprintf(f, "%u", el->cohort_id);
 fputc(lastSep,f);
 }
 
 void probeSampleValStaticLoad(char **row, struct probeSampleVal *ret)
 /* Load a row from probeSampleVal table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->probe_id = sqlUnsigned(row[0]);
 ret->sample_id = sqlUnsigned(row[1]);
 ret->val = sqlFloat(row[2]);
 }
 
 struct probeSampleVal *probeSampleValLoad(char **row)
 /* Load a probeSampleVal from row fetched with select * from probeSampleVal
  * from database.  Dispose of this with probeSampleValFree(). */
 {
 struct probeSampleVal *ret;
 
 AllocVar(ret);
 ret->probe_id = sqlUnsigned(row[0]);
 ret->sample_id = sqlUnsigned(row[1]);
 ret->val = sqlFloat(row[2]);
 return ret;
 }
 
 struct probeSampleVal *probeSampleValLoadAll(char *fileName) 
 /* Load all probeSampleVal from a whitespace-separated file.
  * Dispose of this with probeSampleValFreeList(). */
 {
 struct probeSampleVal *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileRow(lf, row))
     {
     el = probeSampleValLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct probeSampleVal *probeSampleValLoadAllByChar(char *fileName, char chopper) 
 /* Load all probeSampleVal from a chopper separated file.
  * Dispose of this with probeSampleValFreeList(). */
 {
 struct probeSampleVal *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = probeSampleValLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct probeSampleVal *probeSampleValLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all probeSampleVal from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with probeSampleValFreeList(). */
 {
 struct probeSampleVal *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = probeSampleValLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void probeSampleValSaveToDb(struct sqlConnection *conn, struct probeSampleVal *el, char *tableName, int updateSize)
 /* Save probeSampleVal as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use probeSampleValSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%g)", 
 	tableName,  el->probe_id,  el->sample_id,  el->val);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void probeSampleValSaveToDbEscaped(struct sqlConnection *conn, struct probeSampleVal *el, char *tableName, int updateSize)
 /* Save probeSampleVal as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than probeSampleValSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%g)", 
 	tableName,  el->probe_id,  el->sample_id,  el->val);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 struct probeSampleVal *probeSampleValCommaIn(char **pS, struct probeSampleVal *ret)
 /* Create a probeSampleVal out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new probeSampleVal */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->probe_id = sqlUnsignedComma(&s);
 ret->sample_id = sqlUnsignedComma(&s);
 ret->val = sqlFloatComma(&s);
 *pS = s;
 return ret;
 }
 
 void probeSampleValFree(struct probeSampleVal **pEl)
 /* Free a single dynamically allocated probeSampleVal such as created
  * with probeSampleValLoad(). */
 {
 struct probeSampleVal *el;
 
 if ((el = *pEl) == NULL) return;
 freez(pEl);
 }
 
 void probeSampleValFreeList(struct probeSampleVal **pList)
 /* Free a list of dynamically allocated probeSampleVal's */
 {
 struct probeSampleVal *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     probeSampleValFree(&el);
     }
 *pList = NULL;
 }
 
 void probeSampleValOutput(struct probeSampleVal *el, FILE *f, char sep, char lastSep) 
 /* Print out probeSampleVal.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->probe_id);
 fputc(sep,f);
 fprintf(f, "%u", el->sample_id);
 fputc(sep,f);
 fprintf(f, "%g", el->val);
 fputc(lastSep,f);
 }
 
 struct probeVals *probeValsLoad(char **row)
 /* Load a probeVals from row fetched with select * from probeVals
  * from database.  Dispose of this with probeValsFree(). */
 {
 struct probeVals *ret;
 
 AllocVar(ret);
 ret->sample_count = sqlUnsigned(row[1]);
 ret->probe_id = sqlUnsigned(row[0]);
 {
 int sizeOne;
 sqlFloatDynamicArray(row[2], &ret->sample_data, &sizeOne);
 assert(sizeOne == ret->sample_count);
 }
 return ret;
 }
 
 struct probeVals *probeValsLoadAll(char *fileName) 
 /* Load all probeVals from a whitespace-separated file.
  * Dispose of this with probeValsFreeList(). */
 {
 struct probeVals *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileRow(lf, row))
     {
     el = probeValsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct probeVals *probeValsLoadAllByChar(char *fileName, char chopper) 
 /* Load all probeVals from a chopper separated file.
  * Dispose of this with probeValsFreeList(). */
 {
 struct probeVals *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = probeValsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct probeVals *probeValsLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all probeVals from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with probeValsFreeList(). */
 {
 struct probeVals *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = probeValsLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void probeValsSaveToDb(struct sqlConnection *conn, struct probeVals *el, char *tableName, int updateSize)
 /* Save probeVals as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use probeValsSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 char  *sample_dataArray;
 sample_dataArray = sqlFloatArrayToString(el->sample_data, el->sample_count);
 dyStringPrintf(update, "insert into %s values ( %u,%u,'%s')", 
 	tableName,  el->probe_id,  el->sample_count,  sample_dataArray );
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&sample_dataArray);
 }
 
 void probeValsSaveToDbEscaped(struct sqlConnection *conn, struct probeVals *el, char *tableName, int updateSize)
 /* Save probeVals as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than probeValsSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *sample_dataArray;
 
 sample_dataArray = sqlFloatArrayToString(el->sample_data, el->sample_count);
 dyStringPrintf(update, "insert into %s values ( %u,%u,'%s')", 
 	tableName,  el->probe_id,  el->sample_count,  sample_dataArray );
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 struct probeVals *probeValsCommaIn(char **pS, struct probeVals *ret)
 /* Create a probeVals out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new probeVals */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->probe_id = sqlUnsignedComma(&s);
 ret->sample_count = sqlUnsignedComma(&s);
 {
 int i;
 s = sqlEatChar(s, '{');
 AllocArray(ret->sample_data, ret->sample_count);
 for (i=0; i<ret->sample_count; ++i)
     {
     ret->sample_data[i] = sqlFloatComma(&s);
     }
 s = sqlEatChar(s, '}');
 s = sqlEatChar(s, ',');
 }
 *pS = s;
 return ret;
 }
 
 void probeValsFree(struct probeVals **pEl)
 /* Free a single dynamically allocated probeVals such as created
  * with probeValsLoad(). */
 {
 struct probeVals *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->sample_data);
 freez(pEl);
 }
 
 void probeValsFreeList(struct probeVals **pList)
 /* Free a list of dynamically allocated probeVals's */
 {
 struct probeVals *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     probeValsFree(&el);
     }
 *pList = NULL;
 }
 
 void probeValsOutput(struct probeVals *el, FILE *f, char sep, char lastSep) 
 /* Print out probeVals.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->probe_id);
 fputc(sep,f);
 fprintf(f, "%u", el->sample_count);
 fputc(sep,f);
 {
 int i;
 if (sep == ',') fputc('{',f);
 for (i=0; i<el->sample_count; ++i)
     {
     fprintf(f, "%g", el->sample_data[i]);
     fputc(',', f);
     }
 if (sep == ',') fputc('}',f);
 }
 fputc(lastSep,f);
 }
 
 void samplesStaticLoad(char **row, struct samples *ret)
 /* Load a row from samples table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->name = row[1];
 ret->patient_id = sqlUnsigned(row[2]);
 ret->patient_name = row[3];
 ret->dataset_id = sqlUnsigned(row[4]);
 ret->tissue_id = sqlUnsigned(row[5]);
 }
 
 struct samples *samplesLoad(char **row)
 /* Load a samples from row fetched with select * from samples
  * from database.  Dispose of this with samplesFree(). */
 {
 struct samples *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->name = cloneString(row[1]);
 ret->patient_id = sqlUnsigned(row[2]);
 ret->patient_name = cloneString(row[3]);
 ret->dataset_id = sqlUnsigned(row[4]);
 ret->tissue_id = sqlUnsigned(row[5]);
 return ret;
 }
 
 struct samples *samplesLoadAll(char *fileName) 
 /* Load all samples from a whitespace-separated file.
  * Dispose of this with samplesFreeList(). */
 {
 struct samples *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[6];
 
 while (lineFileRow(lf, row))
     {
     el = samplesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct samples *samplesLoadAllByChar(char *fileName, char chopper) 
 /* Load all samples from a chopper separated file.
  * Dispose of this with samplesFreeList(). */
 {
 struct samples *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[6];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = samplesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct samples *samplesLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all samples from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with samplesFreeList(). */
 {
 struct samples *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = samplesLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void samplesSaveToDb(struct sqlConnection *conn, struct samples *el, char *tableName, int updateSize)
 /* Save samples as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use samplesSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s',%u,'%s',%u,%u)", 
 	tableName,  el->id,  el->name,  el->patient_id,  el->patient_name,  el->dataset_id,  el->tissue_id);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void samplesSaveToDbEscaped(struct sqlConnection *conn, struct samples *el, char *tableName, int updateSize)
 /* Save samples as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than samplesSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *name, *patient_name;
 name = sqlEscapeString(el->name);
 patient_name = sqlEscapeString(el->patient_name);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s',%u,'%s',%u,%u)", 
 	tableName,  el->id,  name,  el->patient_id,  patient_name,  el->dataset_id,  el->tissue_id);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&name);
 freez(&patient_name);
 }
 
 struct samples *samplesCommaIn(char **pS, struct samples *ret)
 /* Create a samples out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new samples */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->name = sqlStringComma(&s);
 ret->patient_id = sqlUnsignedComma(&s);
 ret->patient_name = sqlStringComma(&s);
 ret->dataset_id = sqlUnsignedComma(&s);
 ret->tissue_id = sqlUnsignedComma(&s);
 *pS = s;
 return ret;
 }
 
 void samplesFree(struct samples **pEl)
 /* Free a single dynamically allocated samples such as created
  * with samplesLoad(). */
 {
 struct samples *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->name);
 freeMem(el->patient_name);
 freez(pEl);
 }
 
 void samplesFreeList(struct samples **pList)
 /* Free a list of dynamically allocated samples's */
 {
 struct samples *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     samplesFree(&el);
     }
 *pList = NULL;
 }
 
 void samplesOutput(struct samples *el, FILE *f, char sep, char lastSep) 
 /* Print out samples.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->name);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 fprintf(f, "%u", el->patient_id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->patient_name);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 fprintf(f, "%u", el->dataset_id);
 fputc(sep,f);
 fprintf(f, "%u", el->tissue_id);
 fputc(lastSep,f);
 }
 
 void featuresStaticLoad(char **row, struct features *ret)
 /* Load a row from features table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->name = row[1];
 ret->shortLabel = row[2];
 ret->longLabel = row[3];
 }
 
 struct features *featuresLoad(char **row)
 /* Load a features from row fetched with select * from features
  * from database.  Dispose of this with featuresFree(). */
 {
 struct features *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->name = cloneString(row[1]);
 ret->shortLabel = cloneString(row[2]);
 ret->longLabel = cloneString(row[3]);
 return ret;
 }
 
 struct features *featuresLoadAll(char *fileName) 
 /* Load all features from a whitespace-separated file.
  * Dispose of this with featuresFreeList(). */
 {
 struct features *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[4];
 
 while (lineFileRow(lf, row))
     {
     el = featuresLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct features *featuresLoadAllByChar(char *fileName, char chopper) 
 /* Load all features from a chopper separated file.
  * Dispose of this with featuresFreeList(). */
 {
 struct features *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[4];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = featuresLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct features *featuresLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all features from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with featuresFreeList(). */
 {
 struct features *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = featuresLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void featuresSaveToDb(struct sqlConnection *conn, struct features *el, char *tableName, int updateSize)
 /* Save features as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use featuresSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s','%s')", 
 	tableName,  el->id,  el->name,  el->shortLabel,  el->longLabel);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void featuresSaveToDbEscaped(struct sqlConnection *conn, struct features *el, char *tableName, int updateSize)
 /* Save features as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than featuresSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *name, *shortLabel, *longLabel;
 name = sqlEscapeString(el->name);
 shortLabel = sqlEscapeString(el->shortLabel);
 longLabel = sqlEscapeString(el->longLabel);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s','%s')", 
 	tableName,  el->id,  name,  shortLabel,  longLabel);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&name);
 freez(&shortLabel);
 freez(&longLabel);
 }
 
 struct features *featuresCommaIn(char **pS, struct features *ret)
 /* Create a features out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new features */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->name = sqlStringComma(&s);
 ret->shortLabel = sqlStringComma(&s);
 ret->longLabel = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void featuresFree(struct features **pEl)
 /* Free a single dynamically allocated features such as created
  * with featuresLoad(). */
 {
 struct features *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->name);
 freeMem(el->shortLabel);
 freeMem(el->longLabel);
 freez(pEl);
 }
 
 void featuresFreeList(struct features **pList)
 /* Free a list of dynamically allocated features's */
 {
 struct features *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     featuresFree(&el);
     }
 *pList = NULL;
 }
 
 void featuresOutput(struct features *el, FILE *f, char sep, char lastSep) 
 /* Print out features.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->name);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->shortLabel);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->longLabel);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void clinicalDataStaticLoad(char **row, struct clinicalData *ret)
 /* Load a row from clinicalData table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->sample_id = sqlUnsigned(row[0]);
 ret->feature_id = sqlUnsigned(row[1]);
 ret->val = sqlDouble(row[2]);
 ret->code = row[3];
 }
 
 struct clinicalData *clinicalDataLoad(char **row)
 /* Load a clinicalData from row fetched with select * from clinicalData
  * from database.  Dispose of this with clinicalDataFree(). */
 {
 struct clinicalData *ret;
 
 AllocVar(ret);
 ret->sample_id = sqlUnsigned(row[0]);
 ret->feature_id = sqlUnsigned(row[1]);
 ret->val = sqlDouble(row[2]);
 ret->code = cloneString(row[3]);
 return ret;
 }
 
 struct clinicalData *clinicalDataLoadAll(char *fileName) 
 /* Load all clinicalData from a whitespace-separated file.
  * Dispose of this with clinicalDataFreeList(). */
 {
 struct clinicalData *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[4];
 
 while (lineFileRow(lf, row))
     {
     el = clinicalDataLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct clinicalData *clinicalDataLoadAllByChar(char *fileName, char chopper) 
 /* Load all clinicalData from a chopper separated file.
  * Dispose of this with clinicalDataFreeList(). */
 {
 struct clinicalData *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[4];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = clinicalDataLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct clinicalData *clinicalDataLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all clinicalData from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with clinicalDataFreeList(). */
 {
 struct clinicalData *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = clinicalDataLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void clinicalDataSaveToDb(struct sqlConnection *conn, struct clinicalData *el, char *tableName, int updateSize)
 /* Save clinicalData as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use clinicalDataSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%g,'%s')", 
 	tableName,  el->sample_id,  el->feature_id,  el->val,  el->code);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void clinicalDataSaveToDbEscaped(struct sqlConnection *conn, struct clinicalData *el, char *tableName, int updateSize)
 /* Save clinicalData as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than clinicalDataSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *code;
 code = sqlEscapeString(el->code);
 
 dyStringPrintf(update, "insert into %s values ( %u,%u,%g,'%s')", 
 	tableName,  el->sample_id,  el->feature_id,  el->val,  code);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&code);
 }
 
 struct clinicalData *clinicalDataCommaIn(char **pS, struct clinicalData *ret)
 /* Create a clinicalData out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new clinicalData */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->sample_id = sqlUnsignedComma(&s);
 ret->feature_id = sqlUnsignedComma(&s);
 ret->val = sqlDoubleComma(&s);
 ret->code = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void clinicalDataFree(struct clinicalData **pEl)
 /* Free a single dynamically allocated clinicalData such as created
  * with clinicalDataLoad(). */
 {
 struct clinicalData *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->code);
 freez(pEl);
 }
 
 void clinicalDataFreeList(struct clinicalData **pList)
 /* Free a list of dynamically allocated clinicalData's */
 {
 struct clinicalData *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     clinicalDataFree(&el);
     }
 *pList = NULL;
 }
 
 void clinicalDataOutput(struct clinicalData *el, FILE *f, char sep, char lastSep) 
 /* Print out clinicalData.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->sample_id);
 fputc(sep,f);
 fprintf(f, "%u", el->feature_id);
 fputc(sep,f);
 fprintf(f, "%g", el->val);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->code);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void analysesStaticLoad(char **row, struct analyses *ret)
 /* Load a row from analyses table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->cohort_id = sqlUnsigned(row[1]);
 ret->module_id = sqlUnsigned(row[2]);
 ret->result_table = row[3];
 ret->input_tables = row[4];
 }
 
 struct analyses *analysesLoad(char **row)
 /* Load a analyses from row fetched with select * from analyses
  * from database.  Dispose of this with analysesFree(). */
 {
 struct analyses *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->cohort_id = sqlUnsigned(row[1]);
 ret->module_id = sqlUnsigned(row[2]);
 ret->result_table = cloneString(row[3]);
 ret->input_tables = cloneString(row[4]);
 return ret;
 }
 
 struct analyses *analysesLoadAll(char *fileName) 
 /* Load all analyses from a whitespace-separated file.
  * Dispose of this with analysesFreeList(). */
 {
 struct analyses *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[5];
 
 while (lineFileRow(lf, row))
     {
     el = analysesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analyses *analysesLoadAllByChar(char *fileName, char chopper) 
 /* Load all analyses from a chopper separated file.
  * Dispose of this with analysesFreeList(). */
 {
 struct analyses *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[5];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = analysesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analyses *analysesLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all analyses from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with analysesFreeList(). */
 {
 struct analyses *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = analysesLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void analysesSaveToDb(struct sqlConnection *conn, struct analyses *el, char *tableName, int updateSize)
 /* Save analyses as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use analysesSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%u,'%s',%s)", 
 	tableName,  el->id,  el->cohort_id,  el->module_id,  el->result_table,  el->input_tables);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void analysesSaveToDbEscaped(struct sqlConnection *conn, struct analyses *el, char *tableName, int updateSize)
 /* Save analyses as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than analysesSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *result_table, *input_tables;
 result_table = sqlEscapeString(el->result_table);
 input_tables = sqlEscapeString(el->input_tables);
 
 dyStringPrintf(update, "insert into %s values ( %u,%u,%u,'%s','%s')", 
 	tableName,  el->id,  el->cohort_id,  el->module_id,  result_table,  input_tables);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&result_table);
 freez(&input_tables);
 }
 
 struct analyses *analysesCommaIn(char **pS, struct analyses *ret)
 /* Create a analyses out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new analyses */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->cohort_id = sqlUnsignedComma(&s);
 ret->module_id = sqlUnsignedComma(&s);
 ret->result_table = sqlStringComma(&s);
 ret->input_tables = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void analysesFree(struct analyses **pEl)
 /* Free a single dynamically allocated analyses such as created
  * with analysesLoad(). */
 {
 struct analyses *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->result_table);
 freeMem(el->input_tables);
 freez(pEl);
 }
 
 void analysesFreeList(struct analyses **pList)
 /* Free a list of dynamically allocated analyses's */
 {
 struct analyses *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     analysesFree(&el);
     }
 *pList = NULL;
 }
 
 void analysesOutput(struct analyses *el, FILE *f, char sep, char lastSep) 
 /* Print out analyses.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 fprintf(f, "%u", el->cohort_id);
 fputc(sep,f);
 fprintf(f, "%u", el->module_id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->result_table);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->input_tables);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void analysisModulesStaticLoad(char **row, struct analysisModules *ret)
 /* Load a row from analysisModules table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->name = row[1];
 ret->type = row[2];
 }
 
 struct analysisModules *analysisModulesLoad(char **row)
 /* Load a analysisModules from row fetched with select * from analysisModules
  * from database.  Dispose of this with analysisModulesFree(). */
 {
 struct analysisModules *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->name = cloneString(row[1]);
 ret->type = cloneString(row[2]);
 return ret;
 }
 
 struct analysisModules *analysisModulesLoadAll(char *fileName) 
 /* Load all analysisModules from a whitespace-separated file.
  * Dispose of this with analysisModulesFreeList(). */
 {
 struct analysisModules *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileRow(lf, row))
     {
     el = analysisModulesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analysisModules *analysisModulesLoadAllByChar(char *fileName, char chopper) 
 /* Load all analysisModules from a chopper separated file.
  * Dispose of this with analysisModulesFreeList(). */
 {
 struct analysisModules *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = analysisModulesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analysisModules *analysisModulesLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all analysisModules from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with analysisModulesFreeList(). */
 {
 struct analysisModules *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = analysisModulesLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void analysisModulesSaveToDb(struct sqlConnection *conn, struct analysisModules *el, char *tableName, int updateSize)
 /* Save analysisModules as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use analysisModulesSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->id,  el->name,  el->type);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void analysisModulesSaveToDbEscaped(struct sqlConnection *conn, struct analysisModules *el, char *tableName, int updateSize)
 /* Save analysisModules as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than analysisModulesSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *name, *type;
 name = sqlEscapeString(el->name);
 type = sqlEscapeString(el->type);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->id,  name,  type);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&name);
 freez(&type);
 }
 
 struct analysisModules *analysisModulesCommaIn(char **pS, struct analysisModules *ret)
 /* Create a analysisModules out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new analysisModules */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->name = sqlStringComma(&s);
 ret->type = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void analysisModulesFree(struct analysisModules **pEl)
 /* Free a single dynamically allocated analysisModules such as created
  * with analysisModulesLoad(). */
 {
 struct analysisModules *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->name);
 freeMem(el->type);
 freez(pEl);
 }
 
 void analysisModulesFreeList(struct analysisModules **pList)
 /* Free a list of dynamically allocated analysisModules's */
 {
 struct analysisModules *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     analysisModulesFree(&el);
     }
 *pList = NULL;
 }
 
 void analysisModulesOutput(struct analysisModules *el, FILE *f, char sep, char lastSep) 
 /* Print out analysisModules.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->name);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->type);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void analysisParamsStaticLoad(char **row, struct analysisParams *ret)
 /* Load a row from analysisParams table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->analysis_id = sqlUnsigned(row[0]);
 ret->name = row[1];
 ret->val = row[2];
 }
 
 struct analysisParams *analysisParamsLoad(char **row)
 /* Load a analysisParams from row fetched with select * from analysisParams
  * from database.  Dispose of this with analysisParamsFree(). */
 {
 struct analysisParams *ret;
 
 AllocVar(ret);
 ret->analysis_id = sqlUnsigned(row[0]);
 ret->name = cloneString(row[1]);
 ret->val = cloneString(row[2]);
 return ret;
 }
 
 struct analysisParams *analysisParamsLoadAll(char *fileName) 
 /* Load all analysisParams from a whitespace-separated file.
  * Dispose of this with analysisParamsFreeList(). */
 {
 struct analysisParams *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileRow(lf, row))
     {
     el = analysisParamsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analysisParams *analysisParamsLoadAllByChar(char *fileName, char chopper) 
 /* Load all analysisParams from a chopper separated file.
  * Dispose of this with analysisParamsFreeList(). */
 {
 struct analysisParams *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = analysisParamsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analysisParams *analysisParamsLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all analysisParams from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with analysisParamsFreeList(). */
 {
 struct analysisParams *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = analysisParamsLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void analysisParamsSaveToDb(struct sqlConnection *conn, struct analysisParams *el, char *tableName, int updateSize)
 /* Save analysisParams as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use analysisParamsSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->analysis_id,  el->name,  el->val);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void analysisParamsSaveToDbEscaped(struct sqlConnection *conn, struct analysisParams *el, char *tableName, int updateSize)
 /* Save analysisParams as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than analysisParamsSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *name, *val;
 name = sqlEscapeString(el->name);
 val = sqlEscapeString(el->val);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->analysis_id,  name,  val);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&name);
 freez(&val);
 }
 
 struct analysisParams *analysisParamsCommaIn(char **pS, struct analysisParams *ret)
 /* Create a analysisParams out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new analysisParams */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->analysis_id = sqlUnsignedComma(&s);
 ret->name = sqlStringComma(&s);
 ret->val = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void analysisParamsFree(struct analysisParams **pEl)
 /* Free a single dynamically allocated analysisParams such as created
  * with analysisParamsLoad(). */
 {
 struct analysisParams *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->name);
 freeMem(el->val);
 freez(pEl);
 }
 
 void analysisParamsFreeList(struct analysisParams **pList)
 /* Free a list of dynamically allocated analysisParams's */
 {
 struct analysisParams *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     analysisParamsFree(&el);
     }
 *pList = NULL;
 }
 
 void analysisParamsOutput(struct analysisParams *el, FILE *f, char sep, char lastSep) 
 /* Print out analysisParams.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->analysis_id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->name);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->val);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void analysisFeaturesStaticLoad(char **row, struct analysisFeatures *ret)
 /* Load a row from analysisFeatures table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->id = sqlUnsigned(row[0]);
 ret->feature_name = row[1];
 ret->type = row[2];
 }
 
 struct analysisFeatures *analysisFeaturesLoad(char **row)
 /* Load a analysisFeatures from row fetched with select * from analysisFeatures
  * from database.  Dispose of this with analysisFeaturesFree(). */
 {
 struct analysisFeatures *ret;
 
 AllocVar(ret);
 ret->id = sqlUnsigned(row[0]);
 ret->feature_name = cloneString(row[1]);
 ret->type = cloneString(row[2]);
 return ret;
 }
 
 struct analysisFeatures *analysisFeaturesLoadAll(char *fileName) 
 /* Load all analysisFeatures from a whitespace-separated file.
  * Dispose of this with analysisFeaturesFreeList(). */
 {
 struct analysisFeatures *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileRow(lf, row))
     {
     el = analysisFeaturesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analysisFeatures *analysisFeaturesLoadAllByChar(char *fileName, char chopper) 
 /* Load all analysisFeatures from a chopper separated file.
  * Dispose of this with analysisFeaturesFreeList(). */
 {
 struct analysisFeatures *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = analysisFeaturesLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analysisFeatures *analysisFeaturesLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all analysisFeatures from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with analysisFeaturesFreeList(). */
 {
 struct analysisFeatures *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = analysisFeaturesLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void analysisFeaturesSaveToDb(struct sqlConnection *conn, struct analysisFeatures *el, char *tableName, int updateSize)
 /* Save analysisFeatures as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use analysisFeaturesSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->id,  el->feature_name,  el->type);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void analysisFeaturesSaveToDbEscaped(struct sqlConnection *conn, struct analysisFeatures *el, char *tableName, int updateSize)
 /* Save analysisFeatures as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than analysisFeaturesSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *feature_name, *type;
 feature_name = sqlEscapeString(el->feature_name);
 type = sqlEscapeString(el->type);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')", 
 	tableName,  el->id,  feature_name,  type);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&feature_name);
 freez(&type);
 }
 
 struct analysisFeatures *analysisFeaturesCommaIn(char **pS, struct analysisFeatures *ret)
 /* Create a analysisFeatures out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new analysisFeatures */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->id = sqlUnsignedComma(&s);
 ret->feature_name = sqlStringComma(&s);
 ret->type = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void analysisFeaturesFree(struct analysisFeatures **pEl)
 /* Free a single dynamically allocated analysisFeatures such as created
  * with analysisFeaturesLoad(). */
 {
 struct analysisFeatures *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->feature_name);
 freeMem(el->type);
 freez(pEl);
 }
 
 void analysisFeaturesFreeList(struct analysisFeatures **pList)
 /* Free a list of dynamically allocated analysisFeatures's */
 {
 struct analysisFeatures *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     analysisFeaturesFree(&el);
     }
 *pList = NULL;
 }
 
 void analysisFeaturesOutput(struct analysisFeatures *el, FILE *f, char sep, char lastSep) 
 /* Print out analysisFeatures.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->feature_name);
 if (sep == ',') fputc('"',f);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->type);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void analysisValsStaticLoad(char **row, struct analysisVals *ret)
 /* Load a row from analysisVals table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->sample_id = sqlUnsigned(row[0]);
 ret->feature_id = sqlUnsigned(row[1]);
 ret->val = sqlFloat(row[2]);
 ret->conf = sqlFloat(row[3]);
 }
 
 struct analysisVals *analysisValsLoad(char **row)
 /* Load a analysisVals from row fetched with select * from analysisVals
  * from database.  Dispose of this with analysisValsFree(). */
 {
 struct analysisVals *ret;
 
 AllocVar(ret);
 ret->sample_id = sqlUnsigned(row[0]);
 ret->feature_id = sqlUnsigned(row[1]);
 ret->val = sqlFloat(row[2]);
 ret->conf = sqlFloat(row[3]);
 return ret;
 }
 
 struct analysisVals *analysisValsLoadAll(char *fileName) 
 /* Load all analysisVals from a whitespace-separated file.
  * Dispose of this with analysisValsFreeList(). */
 {
 struct analysisVals *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[4];
 
 while (lineFileRow(lf, row))
     {
     el = analysisValsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analysisVals *analysisValsLoadAllByChar(char *fileName, char chopper) 
 /* Load all analysisVals from a chopper separated file.
  * Dispose of this with analysisValsFreeList(). */
 {
 struct analysisVals *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[4];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = analysisValsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct analysisVals *analysisValsLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all analysisVals from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with analysisValsFreeList(). */
 {
 struct analysisVals *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = analysisValsLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void analysisValsSaveToDb(struct sqlConnection *conn, struct analysisVals *el, char *tableName, int updateSize)
 /* Save analysisVals as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use analysisValsSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%g,%g)", 
 	tableName,  el->sample_id,  el->feature_id,  el->val,  el->conf);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void analysisValsSaveToDbEscaped(struct sqlConnection *conn, struct analysisVals *el, char *tableName, int updateSize)
 /* Save analysisVals as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than analysisValsSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%g,%g)", 
 	tableName,  el->sample_id,  el->feature_id,  el->val,  el->conf);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 struct analysisVals *analysisValsCommaIn(char **pS, struct analysisVals *ret)
 /* Create a analysisVals out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new analysisVals */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->sample_id = sqlUnsignedComma(&s);
 ret->feature_id = sqlUnsignedComma(&s);
 ret->val = sqlFloatComma(&s);
 ret->conf = sqlFloatComma(&s);
 *pS = s;
 return ret;
 }
 
 void analysisValsFree(struct analysisVals **pEl)
 /* Free a single dynamically allocated analysisVals such as created
  * with analysisValsLoad(). */
 {
 struct analysisVals *el;
 
 if ((el = *pEl) == NULL) return;
 freez(pEl);
 }
 
 void analysisValsFreeList(struct analysisVals **pList)
 /* Free a list of dynamically allocated analysisVals's */
 {
 struct analysisVals *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     analysisValsFree(&el);
     }
 *pList = NULL;
 }
 
 void analysisValsOutput(struct analysisVals *el, FILE *f, char sep, char lastSep) 
 /* Print out analysisVals.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->sample_id);
 fputc(sep,f);
 fprintf(f, "%u", el->feature_id);
 fputc(sep,f);
 fprintf(f, "%g", el->val);
 fputc(sep,f);
 fprintf(f, "%g", el->conf);
 fputc(lastSep,f);
 }
 
 void pathwayValsStaticLoad(char **row, struct pathwayVals *ret)
 /* Load a row from pathwayVals table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->pathway_id = sqlUnsigned(row[0]);
 ret->sample_id = sqlUnsigned(row[1]);
 ret->feature_id = sqlUnsigned(row[2]);
 ret->val = sqlFloat(row[3]);
 ret->conf = sqlFloat(row[4]);
 }
 
 struct pathwayVals *pathwayValsLoad(char **row)
 /* Load a pathwayVals from row fetched with select * from pathwayVals
  * from database.  Dispose of this with pathwayValsFree(). */
 {
 struct pathwayVals *ret;
 
 AllocVar(ret);
 ret->pathway_id = sqlUnsigned(row[0]);
 ret->sample_id = sqlUnsigned(row[1]);
 ret->feature_id = sqlUnsigned(row[2]);
 ret->val = sqlFloat(row[3]);
 ret->conf = sqlFloat(row[4]);
 return ret;
 }
 
 struct pathwayVals *pathwayValsLoadAll(char *fileName) 
 /* Load all pathwayVals from a whitespace-separated file.
  * Dispose of this with pathwayValsFreeList(). */
 {
 struct pathwayVals *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[5];
 
 while (lineFileRow(lf, row))
     {
     el = pathwayValsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct pathwayVals *pathwayValsLoadAllByChar(char *fileName, char chopper) 
 /* Load all pathwayVals from a chopper separated file.
  * Dispose of this with pathwayValsFreeList(). */
 {
 struct pathwayVals *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[5];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = pathwayValsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct pathwayVals *pathwayValsLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all pathwayVals from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with pathwayValsFreeList(). */
 {
 struct pathwayVals *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = pathwayValsLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void pathwayValsSaveToDb(struct sqlConnection *conn, struct pathwayVals *el, char *tableName, int updateSize)
 /* Save pathwayVals as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use pathwayValsSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%u,%g,%g)", 
 	tableName,  el->pathway_id,  el->sample_id,  el->feature_id,  el->val,  el->conf);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void pathwayValsSaveToDbEscaped(struct sqlConnection *conn, struct pathwayVals *el, char *tableName, int updateSize)
 /* Save pathwayVals as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than pathwayValsSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%u,%g,%g)", 
 	tableName,  el->pathway_id,  el->sample_id,  el->feature_id,  el->val,  el->conf);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 struct pathwayVals *pathwayValsCommaIn(char **pS, struct pathwayVals *ret)
 /* Create a pathwayVals out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new pathwayVals */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->pathway_id = sqlUnsignedComma(&s);
 ret->sample_id = sqlUnsignedComma(&s);
 ret->feature_id = sqlUnsignedComma(&s);
 ret->val = sqlFloatComma(&s);
 ret->conf = sqlFloatComma(&s);
 *pS = s;
 return ret;
 }
 
 void pathwayValsFree(struct pathwayVals **pEl)
 /* Free a single dynamically allocated pathwayVals such as created
  * with pathwayValsLoad(). */
 {
 struct pathwayVals *el;
 
 if ((el = *pEl) == NULL) return;
 freez(pEl);
 }
 
 void pathwayValsFreeList(struct pathwayVals **pList)
 /* Free a list of dynamically allocated pathwayVals's */
 {
 struct pathwayVals *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     pathwayValsFree(&el);
     }
 *pList = NULL;
 }
 
 void pathwayValsOutput(struct pathwayVals *el, FILE *f, char sep, char lastSep) 
 /* Print out pathwayVals.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->pathway_id);
 fputc(sep,f);
 fprintf(f, "%u", el->sample_id);
 fputc(sep,f);
 fprintf(f, "%u", el->feature_id);
 fputc(sep,f);
 fprintf(f, "%g", el->val);
 fputc(sep,f);
 fprintf(f, "%g", el->conf);
 fputc(lastSep,f);
 }
 
 void cohortCorrStaticLoad(char **row, struct cohortCorr *ret)
 /* Load a row from cohortCorr table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->cohort_id = sqlUnsigned(row[0]);
 ret->result_table = row[1];
 }
 
 struct cohortCorr *cohortCorrLoad(char **row)
 /* Load a cohortCorr from row fetched with select * from cohortCorr
  * from database.  Dispose of this with cohortCorrFree(). */
 {
 struct cohortCorr *ret;
 
 AllocVar(ret);
 ret->cohort_id = sqlUnsigned(row[0]);
 ret->result_table = cloneString(row[1]);
 return ret;
 }
 
 struct cohortCorr *cohortCorrLoadAll(char *fileName) 
 /* Load all cohortCorr from a whitespace-separated file.
  * Dispose of this with cohortCorrFreeList(). */
 {
 struct cohortCorr *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileRow(lf, row))
     {
     el = cohortCorrLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct cohortCorr *cohortCorrLoadAllByChar(char *fileName, char chopper) 
 /* Load all cohortCorr from a chopper separated file.
  * Dispose of this with cohortCorrFreeList(). */
 {
 struct cohortCorr *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[2];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = cohortCorrLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct cohortCorr *cohortCorrLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all cohortCorr from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with cohortCorrFreeList(). */
 {
 struct cohortCorr *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = cohortCorrLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void cohortCorrSaveToDb(struct sqlConnection *conn, struct cohortCorr *el, char *tableName, int updateSize)
 /* Save cohortCorr as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use cohortCorrSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,'%s')", 
 	tableName,  el->cohort_id,  el->result_table);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void cohortCorrSaveToDbEscaped(struct sqlConnection *conn, struct cohortCorr *el, char *tableName, int updateSize)
 /* Save cohortCorr as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than cohortCorrSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 char  *result_table;
 result_table = sqlEscapeString(el->result_table);
 
 dyStringPrintf(update, "insert into %s values ( %u,'%s')", 
 	tableName,  el->cohort_id,  result_table);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 freez(&result_table);
 }
 
 struct cohortCorr *cohortCorrCommaIn(char **pS, struct cohortCorr *ret)
 /* Create a cohortCorr out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new cohortCorr */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->cohort_id = sqlUnsignedComma(&s);
 ret->result_table = sqlStringComma(&s);
 *pS = s;
 return ret;
 }
 
 void cohortCorrFree(struct cohortCorr **pEl)
 /* Free a single dynamically allocated cohortCorr such as created
  * with cohortCorrLoad(). */
 {
 struct cohortCorr *el;
 
 if ((el = *pEl) == NULL) return;
 freeMem(el->result_table);
 freez(pEl);
 }
 
 void cohortCorrFreeList(struct cohortCorr **pList)
 /* Free a list of dynamically allocated cohortCorr's */
 {
 struct cohortCorr *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     cohortCorrFree(&el);
     }
 *pList = NULL;
 }
 
 void cohortCorrOutput(struct cohortCorr *el, FILE *f, char sep, char lastSep) 
 /* Print out cohortCorr.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->cohort_id);
 fputc(sep,f);
 if (sep == ',') fputc('"',f);
 fprintf(f, "%s", el->result_table);
 if (sep == ',') fputc('"',f);
 fputc(lastSep,f);
 }
 
 void corrResultsStaticLoad(char **row, struct corrResults *ret)
 /* Load a row from corrResults table into ret.  The contents of ret will
  * be replaced at the next call to this function. */
 {
 
 ret->feature_id1 = sqlUnsigned(row[0]);
 ret->feature_id2 = sqlUnsigned(row[1]);
 ret->val = sqlFloat(row[2]);
 }
 
 struct corrResults *corrResultsLoad(char **row)
 /* Load a corrResults from row fetched with select * from corrResults
  * from database.  Dispose of this with corrResultsFree(). */
 {
 struct corrResults *ret;
 
 AllocVar(ret);
 ret->feature_id1 = sqlUnsigned(row[0]);
 ret->feature_id2 = sqlUnsigned(row[1]);
 ret->val = sqlFloat(row[2]);
 return ret;
 }
 
 struct corrResults *corrResultsLoadAll(char *fileName) 
 /* Load all corrResults from a whitespace-separated file.
  * Dispose of this with corrResultsFreeList(). */
 {
 struct corrResults *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileRow(lf, row))
     {
     el = corrResultsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct corrResults *corrResultsLoadAllByChar(char *fileName, char chopper) 
 /* Load all corrResults from a chopper separated file.
  * Dispose of this with corrResultsFreeList(). */
 {
 struct corrResults *list = NULL, *el;
 struct lineFile *lf = lineFileOpen(fileName, TRUE);
 char *row[3];
 
 while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
     {
     el = corrResultsLoad(row);
     slAddHead(&list, el);
     }
 lineFileClose(&lf);
 slReverse(&list);
 return list;
 }
 
 struct corrResults *corrResultsLoadByQuery(struct sqlConnection *conn, char *query)
 /* Load all corrResults from table that satisfy the query given.  
  * Where query is of the form 'select * from example where something=something'
  * or 'select example.* from example, anotherTable where example.something = 
  * anotherTable.something'.
  * Dispose of this with corrResultsFreeList(). */
 {
 struct corrResults *list = NULL, *el;
 struct sqlResult *sr;
 char **row;
 
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
     el = corrResultsLoad(row);
     slAddHead(&list, el);
     }
 slReverse(&list);
 sqlFreeResult(&sr);
 return list;
 }
 
 void corrResultsSaveToDb(struct sqlConnection *conn, struct corrResults *el, char *tableName, int updateSize)
 /* Save corrResults as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size
  * of a string that would contain the entire query. Arrays of native types are
  * converted to comma separated strings and loaded as such, User defined types are
  * inserted as NULL. Note that strings must be escaped to allow insertion into the database.
  * For example "autosql's features include" --> "autosql\'s features include" 
  * If worried about this use corrResultsSaveToDbEscaped() */
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%g)", 
 	tableName,  el->feature_id1,  el->feature_id2,  el->val);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 void corrResultsSaveToDbEscaped(struct sqlConnection *conn, struct corrResults *el, char *tableName, int updateSize)
 /* Save corrResults as a row to the table specified by tableName. 
  * As blob fields may be arbitrary size updateSize specifies the approx size.
  * of a string that would contain the entire query. Automatically 
  * escapes all simple strings (not arrays of string) but may be slower than corrResultsSaveToDb().
  * For example automatically copies and converts: 
  * "autosql's features include" --> "autosql\'s features include" 
  * before inserting into database. */ 
 {
 struct dyString *update = newDyString(updateSize);
 dyStringPrintf(update, "insert into %s values ( %u,%u,%g)", 
 	tableName,  el->feature_id1,  el->feature_id2,  el->val);
 sqlUpdate(conn, update->string);
 freeDyString(&update);
 }
 
 struct corrResults *corrResultsCommaIn(char **pS, struct corrResults *ret)
 /* Create a corrResults out of a comma separated string. 
  * This will fill in ret if non-null, otherwise will
  * return a new corrResults */
 {
 char *s = *pS;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->feature_id1 = sqlUnsignedComma(&s);
 ret->feature_id2 = sqlUnsignedComma(&s);
 ret->val = sqlFloatComma(&s);
 *pS = s;
 return ret;
 }
 
 void corrResultsFree(struct corrResults **pEl)
 /* Free a single dynamically allocated corrResults such as created
  * with corrResultsLoad(). */
 {
 struct corrResults *el;
 
 if ((el = *pEl) == NULL) return;
 freez(pEl);
 }
 
 void corrResultsFreeList(struct corrResults **pList)
 /* Free a list of dynamically allocated corrResults's */
 {
 struct corrResults *el, *next;
 
 for (el = *pList; el != NULL; el = next)
     {
     next = el->next;
     corrResultsFree(&el);
     }
 *pList = NULL;
 }
 
 void corrResultsOutput(struct corrResults *el, FILE *f, char sep, char lastSep) 
 /* Print out corrResults.  Separate fields with sep. Follow last field with lastSep. */
 {
 fprintf(f, "%u", el->feature_id1);
 fputc(sep,f);
 fprintf(f, "%u", el->feature_id2);
 fputc(sep,f);
 fprintf(f, "%g", el->val);
 fputc(lastSep,f);
 }
 
+struct pathwayEMParams *pathwayEMParamsLoad(char **row)
+/* Load a pathwayEMParams from row fetched with select * from pathwayEMParams
+ * from database.  Dispose of this with pathwayEMParamsFree(). */
+{
+struct pathwayEMParams *ret;
+
+AllocVar(ret);
+ret->pathway_id = sqlUnsigned(row[0]);
+ret->cohort_id = sqlUnsigned(row[1]);
+ret->dataset_id = sqlUnsigned(row[2]);
+ret->parent_state = sqlUnsigned(row[3]);
+ret->child_state = sqlUnsigned(row[4]);
+ret->val = sqlFloat(row[5]);
+
+return ret;
+}
+
+struct pathwayEMParams *pathwayEMParamsLoadByQuery(struct sqlConnection *conn, char *query)
+/* Load all pathwayEMParams from table that satisfy the query given.  
+ * Where query is of the form 'select * from example where something=something'
+ * or 'select example.* from example, anotherTable where example.something = 
+ * anotherTable.something'.
+ * Dispose of this with pathwayEMParamsFreeList(). */
+{
+struct pathwayEMParams *list = NULL, *el;
+struct sqlResult *sr;
+char **row;
+
+sr = sqlGetResult(conn, query);
+while ((row = sqlNextRow(sr)) != NULL)
+    {
+    el = pathwayEMParamsLoad(row);
+    slAddHead(&list, el);
+    }
+slReverse(&list);
+sqlFreeResult(&sr);
+return list;
+}
+
+void pathwayEMParamsFree(struct pathwayEMParams **pEl)
+/* Free a single dynamically allocated corrResults such as created
+ * with pathwayEMParamsLoad(). */
+{
+struct pathwayEMParams *el;
+
+if ((el = *pEl) == NULL) return;
+freez(pEl);
+}
+
+void pathwayEMParamsFreeList(struct pathwayEMParams **pList)
+/* Free a list of dynamically allocated pathwayEMParams's */
+{
+struct pathwayEMParams *el, *next;
+
+for (el = *pList; el != NULL; el = next)
+    {
+    next = el->next;
+    pathwayEMParamsFree(&el);
+    }
+*pList = NULL;
+}
 /* -------------------------------- End autoSql Generated Code -------------------------------- */