src/hg/instinct/bioInt2/bioIntDb.c 1.7
1.7 2009/04/27 06:15:48 jsanborn
updated lots of stuff, will break older implementation of database
Index: src/hg/instinct/bioInt2/bioIntDb.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/bioIntDb.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -b -B -U 4 -r1.6 -r1.7
--- src/hg/instinct/bioInt2/bioIntDb.c 1 Apr 2009 03:26:58 -0000 1.6
+++ src/hg/instinct/bioInt2/bioIntDb.c 27 Apr 2009 06:15:48 -0000 1.7
@@ -9,133 +9,110 @@
#include "bioIntDb.h"
static char const rcsid[] = "$Id$";
-void sqlFloatDynamicArrayFixedSize(char *s, float **retArray, int size)
-/* Convert comma separated list of numbers to an dynamically allocated
- * array, which should be freeMem()'d when done. */
-{
-float *array = NULL;
-unsigned count = 0;
-
-AllocArray(array, size);
-for (;;)
- {
- char *e;
- if (s == NULL || s[0] == 0 || count == size)
- break;
- e = strchr(s, ',');
- if (e != NULL)
- *e++ = 0;
-
- array[count++] = atof(s);
- s = e;
- }
-*retArray = array;
-}
-
-void pathwaysStaticLoad(char **row, struct pathways *ret)
-/* Load a row from pathways table into ret. The contents of ret will
+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 pathways *pathwaysLoad(char **row)
-/* Load a pathways from row fetched with select * from pathways
- * from database. Dispose of this with pathwaysFree(). */
+struct genesets *genesetsLoad(char **row)
+/* Load a genesets from row fetched with select * from genesets
+ * from database. Dispose of this with genesetsFree(). */
{
-struct pathways *ret;
+struct genesets *ret;
AllocVar(ret);
ret->id = sqlUnsigned(row[0]);
ret->name = cloneString(row[1]);
ret->source = cloneString(row[2]);
return ret;
}
-struct pathways *pathwaysLoadAll(char *fileName)
-/* Load all pathways from a whitespace-separated file.
- * Dispose of this with pathwaysFreeList(). */
+struct genesets *genesetsLoadAll(char *fileName)
+/* Load all genesets from a whitespace-separated file.
+ * Dispose of this with genesetsFreeList(). */
{
-struct pathways *list = NULL, *el;
+struct genesets *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[3];
while (lineFileRow(lf, row))
{
- el = pathwaysLoad(row);
+ el = genesetsLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
-struct pathways *pathwaysLoadAllByChar(char *fileName, char chopper)
-/* Load all pathways from a chopper separated file.
- * Dispose of this with pathwaysFreeList(). */
+struct genesets *genesetsLoadAllByChar(char *fileName, char chopper)
+/* Load all genesets from a chopper separated file.
+ * Dispose of this with genesetsFreeList(). */
{
-struct pathways *list = NULL, *el;
+struct genesets *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[3];
while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
{
- el = pathwaysLoad(row);
+ el = genesetsLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
-struct pathways *pathwaysLoadByQuery(struct sqlConnection *conn, char *query)
-/* Load all pathways from table that satisfy the query given.
+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 pathwaysFreeList(). */
+ * Dispose of this with genesetsFreeList(). */
{
-struct pathways *list = NULL, *el;
+struct genesets *list = NULL, *el;
struct sqlResult *sr;
char **row;
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
- el = pathwaysLoad(row);
+ el = genesetsLoad(row);
slAddHead(&list, el);
}
slReverse(&list);
sqlFreeResult(&sr);
return list;
}
-void pathwaysSaveToDb(struct sqlConnection *conn, struct pathways *el, char *tableName, int updateSize)
-/* Save pathways as a row to the table specified by tableName.
+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 pathwaysSaveToDbEscaped() */
+ * 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 pathwaysSaveToDbEscaped(struct sqlConnection *conn, struct pathways *el, char *tableName, int updateSize)
-/* Save pathways as a row to the table specified by tableName.
+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 pathwaysSaveToDb().
+ * 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. */
{
@@ -151,12 +128,12 @@
freez(&name);
freez(&source);
}
-struct pathways *pathwaysCommaIn(char **pS, struct pathways *ret)
-/* Create a pathways out of a comma separated string.
+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 pathways */
+ * return a new genesets */
{
char *s = *pS;
if (ret == NULL)
@@ -167,35 +144,35 @@
*pS = s;
return ret;
}
-void pathwaysFree(struct pathways **pEl)
-/* Free a single dynamically allocated pathways such as created
- * with pathwaysLoad(). */
+void genesetsFree(struct genesets **pEl)
+/* Free a single dynamically allocated genesets such as created
+ * with genesetsLoad(). */
{
-struct pathways *el;
+struct genesets *el;
if ((el = *pEl) == NULL) return;
freeMem(el->name);
freeMem(el->source);
freez(pEl);
}
-void pathwaysFreeList(struct pathways **pList)
-/* Free a list of dynamically allocated pathways's */
+void genesetsFreeList(struct genesets **pList)
+/* Free a list of dynamically allocated genesets's */
{
-struct pathways *el, *next;
+struct genesets *el, *next;
for (el = *pList; el != NULL; el = next)
{
next = el->next;
- pathwaysFree(&el);
+ genesetsFree(&el);
}
*pList = NULL;
}
-void pathwaysOutput(struct pathways *el, FILE *f, char sep, char lastSep)
-/* Print out pathways. Separate fields with sep. Follow last field with lastSep. */
+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);
@@ -207,108 +184,108 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void pathwayGenesStaticLoad(char **row, struct pathwayGenes *ret)
-/* Load a row from pathwayGenes table into ret. The contents of ret will
+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 pathwayGenes *pathwayGenesLoad(char **row)
-/* Load a pathwayGenes from row fetched with select * from pathwayGenes
- * from database. Dispose of this with pathwayGenesFree(). */
+struct genesetGenes *genesetGenesLoad(char **row)
+/* Load a genesetGenes from row fetched with select * from genesetGenes
+ * from database. Dispose of this with genesetGenesFree(). */
{
-struct pathwayGenes *ret;
+struct genesetGenes *ret;
AllocVar(ret);
ret->id = sqlUnsigned(row[0]);
ret->gene_id = sqlUnsigned(row[1]);
return ret;
}
-struct pathwayGenes *pathwayGenesLoadAll(char *fileName)
-/* Load all pathwayGenes from a whitespace-separated file.
- * Dispose of this with pathwayGenesFreeList(). */
+struct genesetGenes *genesetGenesLoadAll(char *fileName)
+/* Load all genesetGenes from a whitespace-separated file.
+ * Dispose of this with genesetGenesFreeList(). */
{
-struct pathwayGenes *list = NULL, *el;
+struct genesetGenes *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[2];
while (lineFileRow(lf, row))
{
- el = pathwayGenesLoad(row);
+ el = genesetGenesLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
-struct pathwayGenes *pathwayGenesLoadAllByChar(char *fileName, char chopper)
-/* Load all pathwayGenes from a chopper separated file.
- * Dispose of this with pathwayGenesFreeList(). */
+struct genesetGenes *genesetGenesLoadAllByChar(char *fileName, char chopper)
+/* Load all genesetGenes from a chopper separated file.
+ * Dispose of this with genesetGenesFreeList(). */
{
-struct pathwayGenes *list = NULL, *el;
+struct genesetGenes *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[2];
while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
{
- el = pathwayGenesLoad(row);
+ el = genesetGenesLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
-struct pathwayGenes *pathwayGenesLoadByQuery(struct sqlConnection *conn, char *query)
-/* Load all pathwayGenes from table that satisfy the query given.
+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 pathwayGenesFreeList(). */
+ * Dispose of this with genesetGenesFreeList(). */
{
-struct pathwayGenes *list = NULL, *el;
+struct genesetGenes *list = NULL, *el;
struct sqlResult *sr;
char **row;
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
- el = pathwayGenesLoad(row);
+ el = genesetGenesLoad(row);
slAddHead(&list, el);
}
slReverse(&list);
sqlFreeResult(&sr);
return list;
}
-void pathwayGenesSaveToDb(struct sqlConnection *conn, struct pathwayGenes *el, char *tableName, int updateSize)
-/* Save pathwayGenes as a row to the table specified by tableName.
+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 pathwayGenesSaveToDbEscaped() */
+ * 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 pathwayGenesSaveToDbEscaped(struct sqlConnection *conn, struct pathwayGenes *el, char *tableName, int updateSize)
-/* Save pathwayGenes as a row to the table specified by tableName.
+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 pathwayGenesSaveToDb().
+ * 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. */
{
@@ -318,12 +295,12 @@
sqlUpdate(conn, update->string);
freeDyString(&update);
}
-struct pathwayGenes *pathwayGenesCommaIn(char **pS, struct pathwayGenes *ret)
-/* Create a pathwayGenes out of a comma separated string.
+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 pathwayGenes */
+ * return a new genesetGenes */
{
char *s = *pS;
if (ret == NULL)
@@ -333,140 +310,140 @@
*pS = s;
return ret;
}
-void pathwayGenesFree(struct pathwayGenes **pEl)
-/* Free a single dynamically allocated pathwayGenes such as created
- * with pathwayGenesLoad(). */
+void genesetGenesFree(struct genesetGenes **pEl)
+/* Free a single dynamically allocated genesetGenes such as created
+ * with genesetGenesLoad(). */
{
-struct pathwayGenes *el;
+struct genesetGenes *el;
if ((el = *pEl) == NULL) return;
freez(pEl);
}
-void pathwayGenesFreeList(struct pathwayGenes **pList)
-/* Free a list of dynamically allocated pathwayGenes's */
+void genesetGenesFreeList(struct genesetGenes **pList)
+/* Free a list of dynamically allocated genesetGenes's */
{
-struct pathwayGenes *el, *next;
+struct genesetGenes *el, *next;
for (el = *pList; el != NULL; el = next)
{
next = el->next;
- pathwayGenesFree(&el);
+ genesetGenesFree(&el);
}
*pList = NULL;
}
-void pathwayGenesOutput(struct pathwayGenes *el, FILE *f, char sep, char lastSep)
-/* Print out pathwayGenes. Separate fields with sep. Follow last field with lastSep. */
+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 pathwayInfoStaticLoad(char **row, struct pathwayInfo *ret)
-/* Load a row from pathwayInfo table into ret. The contents of ret will
+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 pathwayInfo *pathwayInfoLoad(char **row)
-/* Load a pathwayInfo from row fetched with select * from pathwayInfo
- * from database. Dispose of this with pathwayInfoFree(). */
+struct genesetInfo *genesetInfoLoad(char **row)
+/* Load a genesetInfo from row fetched with select * from genesetInfo
+ * from database. Dispose of this with genesetInfoFree(). */
{
-struct pathwayInfo *ret;
+struct genesetInfo *ret;
AllocVar(ret);
ret->id = sqlUnsigned(row[0]);
ret->description = cloneString(row[1]);
return ret;
}
-struct pathwayInfo *pathwayInfoLoadAll(char *fileName)
-/* Load all pathwayInfo from a whitespace-separated file.
- * Dispose of this with pathwayInfoFreeList(). */
+struct genesetInfo *genesetInfoLoadAll(char *fileName)
+/* Load all genesetInfo from a whitespace-separated file.
+ * Dispose of this with genesetInfoFreeList(). */
{
-struct pathwayInfo *list = NULL, *el;
+struct genesetInfo *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[2];
while (lineFileRow(lf, row))
{
- el = pathwayInfoLoad(row);
+ el = genesetInfoLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
-struct pathwayInfo *pathwayInfoLoadAllByChar(char *fileName, char chopper)
-/* Load all pathwayInfo from a chopper separated file.
- * Dispose of this with pathwayInfoFreeList(). */
+struct genesetInfo *genesetInfoLoadAllByChar(char *fileName, char chopper)
+/* Load all genesetInfo from a chopper separated file.
+ * Dispose of this with genesetInfoFreeList(). */
{
-struct pathwayInfo *list = NULL, *el;
+struct genesetInfo *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[2];
while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
{
- el = pathwayInfoLoad(row);
+ el = genesetInfoLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
-struct pathwayInfo *pathwayInfoLoadByQuery(struct sqlConnection *conn, char *query)
-/* Load all pathwayInfo from table that satisfy the query given.
+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 pathwayInfoFreeList(). */
+ * Dispose of this with genesetInfoFreeList(). */
{
-struct pathwayInfo *list = NULL, *el;
+struct genesetInfo *list = NULL, *el;
struct sqlResult *sr;
char **row;
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
- el = pathwayInfoLoad(row);
+ el = genesetInfoLoad(row);
slAddHead(&list, el);
}
slReverse(&list);
sqlFreeResult(&sr);
return list;
}
-void pathwayInfoSaveToDb(struct sqlConnection *conn, struct pathwayInfo *el, char *tableName, int updateSize)
-/* Save pathwayInfo as a row to the table specified by tableName.
+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 pathwayInfoSaveToDbEscaped() */
+ * 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 pathwayInfoSaveToDbEscaped(struct sqlConnection *conn, struct pathwayInfo *el, char *tableName, int updateSize)
-/* Save pathwayInfo as a row to the table specified by tableName.
+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 pathwayInfoSaveToDb().
+ * 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. */
{
@@ -480,12 +457,12 @@
freeDyString(&update);
freez(&description);
}
-struct pathwayInfo *pathwayInfoCommaIn(char **pS, struct pathwayInfo *ret)
-/* Create a pathwayInfo out of a comma separated string.
+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 pathwayInfo */
+ * return a new genesetInfo */
{
char *s = *pS;
if (ret == NULL)
@@ -495,34 +472,34 @@
*pS = s;
return ret;
}
-void pathwayInfoFree(struct pathwayInfo **pEl)
-/* Free a single dynamically allocated pathwayInfo such as created
- * with pathwayInfoLoad(). */
+void genesetInfoFree(struct genesetInfo **pEl)
+/* Free a single dynamically allocated genesetInfo such as created
+ * with genesetInfoLoad(). */
{
-struct pathwayInfo *el;
+struct genesetInfo *el;
if ((el = *pEl) == NULL) return;
freeMem(el->description);
freez(pEl);
}
-void pathwayInfoFreeList(struct pathwayInfo **pList)
-/* Free a list of dynamically allocated pathwayInfo's */
+void genesetInfoFreeList(struct genesetInfo **pList)
+/* Free a list of dynamically allocated genesetInfo's */
{
-struct pathwayInfo *el, *next;
+struct genesetInfo *el, *next;
for (el = *pList; el != NULL; el = next)
{
next = el->next;
- pathwayInfoFree(&el);
+ genesetInfoFree(&el);
}
*pList = NULL;
}
-void pathwayInfoOutput(struct pathwayInfo *el, FILE *f, char sep, char lastSep)
-/* Print out pathwayInfo. Separate fields with sep. Follow last field with lastSep. */
+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);
@@ -881,10 +858,8 @@
ret->type_id = sqlUnsigned(row[2]);
ret->num_samples = sqlUnsigned(row[3]);
ret->name = row[4];
ret->data_table = row[5];
-ret->probe_table = row[6];
-ret->probe_to_gene_table = row[7];
}
struct datasets *datasetsLoad(char **row)
/* Load a datasets from row fetched with select * from datasets
@@ -898,10 +873,8 @@
ret->type_id = sqlUnsigned(row[2]);
ret->num_samples = sqlUnsigned(row[3]);
ret->name = cloneString(row[4]);
ret->data_table = cloneString(row[5]);
-ret->probe_table = cloneString(row[6]);
-ret->probe_to_gene_table = cloneString(row[7]);
return ret;
}
struct datasets *datasetsLoadAll(char *fileName)
@@ -909,9 +882,9 @@
* Dispose of this with datasetsFreeList(). */
{
struct datasets *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[8];
+char *row[6];
while (lineFileRow(lf, row))
{
el = datasetsLoad(row);
@@ -927,9 +900,9 @@
* Dispose of this with datasetsFreeList(). */
{
struct datasets *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[8];
+char *row[6];
while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
{
el = datasetsLoad(row);
@@ -971,10 +944,10 @@
* 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','%s','%s')",
- tableName, el->id, el->tissue_id, el->type_id, el->num_samples, el->name, el->data_table, el->probe_table, el->probe_to_gene_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, el->name, el->data_table);
sqlUpdate(conn, update->string);
freeDyString(&update);
}
@@ -987,22 +960,18 @@
* "autosql's features include" --> "autosql\'s features include"
* before inserting into database. */
{
struct dyString *update = newDyString(updateSize);
-char *name, *data_table, *probe_table, *probe_to_gene_table;
+char *name, *data_table;
name = sqlEscapeString(el->name);
data_table = sqlEscapeString(el->data_table);
-probe_table = sqlEscapeString(el->probe_table);
-probe_to_gene_table = sqlEscapeString(el->probe_to_gene_table);
-dyStringPrintf(update, "insert into %s values ( %u,%u,%u,%u,'%s','%s','%s','%s')",
- tableName, el->id, el->tissue_id, el->type_id, el->num_samples, name, data_table, probe_table, probe_to_gene_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);
-freez(&probe_table);
-freez(&probe_to_gene_table);
}
struct datasets *datasetsCommaIn(char **pS, struct datasets *ret)
/* Create a datasets out of a comma separated string.
@@ -1018,10 +987,8 @@
ret->type_id = sqlUnsignedComma(&s);
ret->num_samples = sqlUnsignedComma(&s);
ret->name = sqlStringComma(&s);
ret->data_table = sqlStringComma(&s);
-ret->probe_table = sqlStringComma(&s);
-ret->probe_to_gene_table = sqlStringComma(&s);
*pS = s;
return ret;
}
@@ -1033,10 +1000,8 @@
if ((el = *pEl) == NULL) return;
freeMem(el->name);
freeMem(el->data_table);
-freeMem(el->probe_table);
-freeMem(el->probe_to_gene_table);
freez(pEl);
}
void datasetsFreeList(struct datasets **pList)
@@ -1069,16 +1034,8 @@
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->data_table);
if (sep == ',') fputc('"',f);
-fputc(sep,f);
-if (sep == ',') fputc('"',f);
-fprintf(f, "%s", el->probe_table);
-if (sep == ',') fputc('"',f);
-fputc(sep,f);
-if (sep == ',') fputc('"',f);
-fprintf(f, "%s", el->probe_to_gene_table);
-if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
void cohortsStaticLoad(char **row, struct cohorts *ret)
@@ -1403,516 +1360,8 @@
fprintf(f, "%u", el->cohort_id);
fputc(lastSep,f);
}
-void geneLookupStaticLoad(char **row, struct geneLookup *ret)
-/* Load a row from geneLookup table into ret. The contents of ret will
- * be replaced at the next call to this function. */
-{
-
-ret->id = sqlUnsigned(row[0]);
-ret->kgId = row[1];
-}
-
-struct geneLookup *geneLookupLoad(char **row)
-/* Load a geneLookup from row fetched with select * from geneLookup
- * from database. Dispose of this with geneLookupFree(). */
-{
-struct geneLookup *ret;
-
-AllocVar(ret);
-ret->id = sqlUnsigned(row[0]);
-ret->kgId = cloneString(row[1]);
-return ret;
-}
-
-struct geneLookup *geneLookupLoadAll(char *fileName)
-/* Load all geneLookup from a whitespace-separated file.
- * Dispose of this with geneLookupFreeList(). */
-{
-struct geneLookup *list = NULL, *el;
-struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[2];
-
-while (lineFileRow(lf, row))
- {
- el = geneLookupLoad(row);
- slAddHead(&list, el);
- }
-lineFileClose(&lf);
-slReverse(&list);
-return list;
-}
-
-struct geneLookup *geneLookupLoadAllByChar(char *fileName, char chopper)
-/* Load all geneLookup from a chopper separated file.
- * Dispose of this with geneLookupFreeList(). */
-{
-struct geneLookup *list = NULL, *el;
-struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[2];
-
-while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
- {
- el = geneLookupLoad(row);
- slAddHead(&list, el);
- }
-lineFileClose(&lf);
-slReverse(&list);
-return list;
-}
-
-struct geneLookup *geneLookupLoadByQuery(struct sqlConnection *conn, char *query)
-/* Load all geneLookup 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 geneLookupFreeList(). */
-{
-struct geneLookup *list = NULL, *el;
-struct sqlResult *sr;
-char **row;
-
-sr = sqlGetResult(conn, query);
-while ((row = sqlNextRow(sr)) != NULL)
- {
- el = geneLookupLoad(row);
- slAddHead(&list, el);
- }
-slReverse(&list);
-sqlFreeResult(&sr);
-return list;
-}
-
-void geneLookupSaveToDb(struct sqlConnection *conn, struct geneLookup *el, char *tableName, int updateSize)
-/* Save geneLookup 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 geneLookupSaveToDbEscaped() */
-{
-struct dyString *update = newDyString(updateSize);
-dyStringPrintf(update, "insert into %s values ( %u,'%s')",
- tableName, el->id, el->kgId);
-sqlUpdate(conn, update->string);
-freeDyString(&update);
-}
-
-void geneLookupSaveToDbEscaped(struct sqlConnection *conn, struct geneLookup *el, char *tableName, int updateSize)
-/* Save geneLookup 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 geneLookupSaveToDb().
- * For example automatically copies and converts:
- * "autosql's features include" --> "autosql\'s features include"
- * before inserting into database. */
-{
-struct dyString *update = newDyString(updateSize);
-char *kgId;
-kgId = sqlEscapeString(el->kgId);
-
-dyStringPrintf(update, "insert into %s values ( %u,'%s')",
- tableName, el->id, kgId);
-sqlUpdate(conn, update->string);
-freeDyString(&update);
-freez(&kgId);
-}
-
-struct geneLookup *geneLookupCommaIn(char **pS, struct geneLookup *ret)
-/* Create a geneLookup out of a comma separated string.
- * This will fill in ret if non-null, otherwise will
- * return a new geneLookup */
-{
-char *s = *pS;
-
-if (ret == NULL)
- AllocVar(ret);
-ret->id = sqlUnsignedComma(&s);
-ret->kgId = sqlStringComma(&s);
-*pS = s;
-return ret;
-}
-
-void geneLookupFree(struct geneLookup **pEl)
-/* Free a single dynamically allocated geneLookup such as created
- * with geneLookupLoad(). */
-{
-struct geneLookup *el;
-
-if ((el = *pEl) == NULL) return;
-freeMem(el->kgId);
-freez(pEl);
-}
-
-void geneLookupFreeList(struct geneLookup **pList)
-/* Free a list of dynamically allocated geneLookup's */
-{
-struct geneLookup *el, *next;
-
-for (el = *pList; el != NULL; el = next)
- {
- next = el->next;
- geneLookupFree(&el);
- }
-*pList = NULL;
-}
-
-void geneLookupOutput(struct geneLookup *el, FILE *f, char sep, char lastSep)
-/* Print out geneLookup. 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->kgId);
-if (sep == ',') fputc('"',f);
-fputc(lastSep,f);
-}
-
-void probeInfoStaticLoad(char **row, struct probeInfo *ret)
-/* Load a row from probeInfo table into ret. The contents of ret will
- * be replaced at the next call to this function. */
-{
-
-ret->id = sqlUnsigned(row[0]);
-ret->chrom = row[1];
-ret->start = sqlUnsigned(row[2]);
-ret->stop = sqlUnsigned(row[3]);
-ret->name = row[4];
-}
-
-struct probeInfo *probeInfoLoad(char **row)
-/* Load a probeInfo from row fetched with select * from probeInfo
- * from database. Dispose of this with probeInfoFree(). */
-{
-struct probeInfo *ret;
-
-AllocVar(ret);
-ret->id = sqlUnsigned(row[0]);
-ret->chrom = cloneString(row[1]);
-ret->start = sqlUnsigned(row[2]);
-ret->stop = sqlUnsigned(row[3]);
-ret->name = cloneString(row[4]);
-return ret;
-}
-
-struct probeInfo *probeInfoLoadAll(char *fileName)
-/* Load all probeInfo from a whitespace-separated file.
- * Dispose of this with probeInfoFreeList(). */
-{
-struct probeInfo *list = NULL, *el;
-struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[5];
-
-while (lineFileRow(lf, row))
- {
- el = probeInfoLoad(row);
- slAddHead(&list, el);
- }
-lineFileClose(&lf);
-slReverse(&list);
-return list;
-}
-
-struct probeInfo *probeInfoLoadAllByChar(char *fileName, char chopper)
-/* Load all probeInfo from a chopper separated file.
- * Dispose of this with probeInfoFreeList(). */
-{
-struct probeInfo *list = NULL, *el;
-struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[5];
-
-while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
- {
- el = probeInfoLoad(row);
- slAddHead(&list, el);
- }
-lineFileClose(&lf);
-slReverse(&list);
-return list;
-}
-
-struct probeInfo *probeInfoLoadByQuery(struct sqlConnection *conn, char *query)
-/* Load all probeInfo 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 probeInfoFreeList(). */
-{
-struct probeInfo *list = NULL, *el;
-struct sqlResult *sr;
-char **row;
-
-sr = sqlGetResult(conn, query);
-while ((row = sqlNextRow(sr)) != NULL)
- {
- el = probeInfoLoad(row);
- slAddHead(&list, el);
- }
-slReverse(&list);
-sqlFreeResult(&sr);
-return list;
-}
-
-void probeInfoSaveToDb(struct sqlConnection *conn, struct probeInfo *el, char *tableName, int updateSize)
-/* Save probeInfo 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 probeInfoSaveToDbEscaped() */
-{
-struct dyString *update = newDyString(updateSize);
-dyStringPrintf(update, "insert into %s values ( %u,'%s',%u,%u,'%s')",
- tableName, el->id, el->chrom, el->start, el->stop, el->name);
-sqlUpdate(conn, update->string);
-freeDyString(&update);
-}
-
-void probeInfoSaveToDbEscaped(struct sqlConnection *conn, struct probeInfo *el, char *tableName, int updateSize)
-/* Save probeInfo 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 probeInfoSaveToDb().
- * For example automatically copies and converts:
- * "autosql's features include" --> "autosql\'s features include"
- * before inserting into database. */
-{
-struct dyString *update = newDyString(updateSize);
-char *chrom, *name;
-chrom = sqlEscapeString(el->chrom);
-name = sqlEscapeString(el->name);
-
-dyStringPrintf(update, "insert into %s values ( %u,'%s',%u,%u,'%s')",
- tableName, el->id, chrom, el->start, el->stop, name);
-sqlUpdate(conn, update->string);
-freeDyString(&update);
-freez(&chrom);
-freez(&name);
-}
-
-struct probeInfo *probeInfoCommaIn(char **pS, struct probeInfo *ret)
-/* Create a probeInfo out of a comma separated string.
- * This will fill in ret if non-null, otherwise will
- * return a new probeInfo */
-{
-char *s = *pS;
-
-if (ret == NULL)
- AllocVar(ret);
-ret->id = sqlUnsignedComma(&s);
-ret->chrom = sqlStringComma(&s);
-ret->start = sqlUnsignedComma(&s);
-ret->stop = sqlUnsignedComma(&s);
-ret->name = sqlStringComma(&s);
-*pS = s;
-return ret;
-}
-
-void probeInfoFree(struct probeInfo **pEl)
-/* Free a single dynamically allocated probeInfo such as created
- * with probeInfoLoad(). */
-{
-struct probeInfo *el;
-
-if ((el = *pEl) == NULL) return;
-freeMem(el->chrom);
-freeMem(el->name);
-freez(pEl);
-}
-
-void probeInfoFreeList(struct probeInfo **pList)
-/* Free a list of dynamically allocated probeInfo's */
-{
-struct probeInfo *el, *next;
-
-for (el = *pList; el != NULL; el = next)
- {
- next = el->next;
- probeInfoFree(&el);
- }
-*pList = NULL;
-}
-
-void probeInfoOutput(struct probeInfo *el, FILE *f, char sep, char lastSep)
-/* Print out probeInfo. 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->chrom);
-if (sep == ',') fputc('"',f);
-fputc(sep,f);
-fprintf(f, "%u", el->start);
-fputc(sep,f);
-fprintf(f, "%u", el->stop);
-fputc(sep,f);
-if (sep == ',') fputc('"',f);
-fprintf(f, "%s", el->name);
-if (sep == ',') fputc('"',f);
-fputc(lastSep,f);
-}
-
-void probeToGeneStaticLoad(char **row, struct probeToGene *ret)
-/* Load a row from probeToGene table into ret. The contents of ret will
- * be replaced at the next call to this function. */
-{
-
-ret->probe_id = sqlUnsigned(row[0]);
-ret->gene_id = sqlUnsigned(row[1]);
-}
-
-struct probeToGene *probeToGeneLoad(char **row)
-/* Load a probeToGene from row fetched with select * from probeToGene
- * from database. Dispose of this with probeToGeneFree(). */
-{
-struct probeToGene *ret;
-
-AllocVar(ret);
-ret->probe_id = sqlUnsigned(row[0]);
-ret->gene_id = sqlUnsigned(row[1]);
-return ret;
-}
-
-struct probeToGene *probeToGeneLoadAll(char *fileName)
-/* Load all probeToGene from a whitespace-separated file.
- * Dispose of this with probeToGeneFreeList(). */
-{
-struct probeToGene *list = NULL, *el;
-struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[2];
-
-while (lineFileRow(lf, row))
- {
- el = probeToGeneLoad(row);
- slAddHead(&list, el);
- }
-lineFileClose(&lf);
-slReverse(&list);
-return list;
-}
-
-struct probeToGene *probeToGeneLoadAllByChar(char *fileName, char chopper)
-/* Load all probeToGene from a chopper separated file.
- * Dispose of this with probeToGeneFreeList(). */
-{
-struct probeToGene *list = NULL, *el;
-struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[2];
-
-while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
- {
- el = probeToGeneLoad(row);
- slAddHead(&list, el);
- }
-lineFileClose(&lf);
-slReverse(&list);
-return list;
-}
-
-struct probeToGene *probeToGeneLoadByQuery(struct sqlConnection *conn, char *query)
-/* Load all probeToGene 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 probeToGeneFreeList(). */
-{
-struct probeToGene *list = NULL, *el;
-struct sqlResult *sr;
-char **row;
-
-sr = sqlGetResult(conn, query);
-while ((row = sqlNextRow(sr)) != NULL)
- {
- el = probeToGeneLoad(row);
- slAddHead(&list, el);
- }
-slReverse(&list);
-sqlFreeResult(&sr);
-return list;
-}
-
-void probeToGeneSaveToDb(struct sqlConnection *conn, struct probeToGene *el, char *tableName, int updateSize)
-/* Save probeToGene 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 probeToGeneSaveToDbEscaped() */
-{
-struct dyString *update = newDyString(updateSize);
-dyStringPrintf(update, "insert into %s values ( %u,%u)",
- tableName, el->probe_id, el->gene_id);
-sqlUpdate(conn, update->string);
-freeDyString(&update);
-}
-
-void probeToGeneSaveToDbEscaped(struct sqlConnection *conn, struct probeToGene *el, char *tableName, int updateSize)
-/* Save probeToGene 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 probeToGeneSaveToDb().
- * 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->probe_id, el->gene_id);
-sqlUpdate(conn, update->string);
-freeDyString(&update);
-}
-
-struct probeToGene *probeToGeneCommaIn(char **pS, struct probeToGene *ret)
-/* Create a probeToGene out of a comma separated string.
- * This will fill in ret if non-null, otherwise will
- * return a new probeToGene */
-{
-char *s = *pS;
-
-if (ret == NULL)
- AllocVar(ret);
-ret->probe_id = sqlUnsignedComma(&s);
-ret->gene_id = sqlUnsignedComma(&s);
-*pS = s;
-return ret;
-}
-
-void probeToGeneFree(struct probeToGene **pEl)
-/* Free a single dynamically allocated probeToGene such as created
- * with probeToGeneLoad(). */
-{
-struct probeToGene *el;
-
-if ((el = *pEl) == NULL) return;
-freez(pEl);
-}
-
-void probeToGeneFreeList(struct probeToGene **pList)
-/* Free a list of dynamically allocated probeToGene's */
-{
-struct probeToGene *el, *next;
-
-for (el = *pList; el != NULL; el = next)
- {
- next = el->next;
- probeToGeneFree(&el);
- }
-*pList = NULL;
-}
-
-void probeToGeneOutput(struct probeToGene *el, FILE *f, char sep, char lastSep)
-/* Print out probeToGene. Separate fields with sep. Follow last field with lastSep. */
-{
-fprintf(f, "%u", el->probe_id);
-fputc(sep,f);
-fprintf(f, "%u", el->gene_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. */
{
@@ -2084,12 +1533,11 @@
AllocVar(ret);
ret->sample_count = sqlUnsigned(row[1]);
ret->probe_id = sqlUnsigned(row[0]);
{
-sqlFloatDynamicArrayFixedSize(row[2], &ret->sample_data, ret->sample_count);
-//int sizeOne;
-//sqlFloatDynamicArray(row[2], &ret->sample_data, &sizeOne);
-//assert(sizeOne == ret->sample_count);
+int sizeOne;
+sqlFloatDynamicArray(row[2], &ret->sample_data, &sizeOne);
+assert(sizeOne == ret->sample_count);
}
return ret;
}
@@ -2268,10 +1716,9 @@
ret->name = row[1];
ret->patient_id = sqlUnsigned(row[2]);
ret->patient_name = row[3];
ret->dataset_id = sqlUnsigned(row[4]);
-ret->exp_id = sqlUnsigned(row[5]);
-ret->tissue_id = sqlUnsigned(row[6]);
+ret->tissue_id = sqlUnsigned(row[5]);
}
struct samples *samplesLoad(char **row)
/* Load a samples from row fetched with select * from samples
@@ -2284,10 +1731,9 @@
ret->name = cloneString(row[1]);
ret->patient_id = sqlUnsigned(row[2]);
ret->patient_name = cloneString(row[3]);
ret->dataset_id = sqlUnsigned(row[4]);
-ret->exp_id = sqlUnsigned(row[5]);
-ret->tissue_id = sqlUnsigned(row[6]);
+ret->tissue_id = sqlUnsigned(row[5]);
return ret;
}
struct samples *samplesLoadAll(char *fileName)
@@ -2295,9 +1741,9 @@
* Dispose of this with samplesFreeList(). */
{
struct samples *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[7];
+char *row[6];
while (lineFileRow(lf, row))
{
el = samplesLoad(row);
@@ -2313,9 +1759,9 @@
* Dispose of this with samplesFreeList(). */
{
struct samples *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[7];
+char *row[6];
while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
{
el = samplesLoad(row);
@@ -2357,10 +1803,10 @@
* 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,%u)",
- tableName, el->id, el->name, el->patient_id, el->patient_name, el->dataset_id, el->exp_id, el->tissue_id);
+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);
}
@@ -2377,10 +1823,10 @@
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,%u)",
- tableName, el->id, name, el->patient_id, patient_name, el->dataset_id, el->exp_id, el->tissue_id);
+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);
@@ -2399,9 +1845,8 @@
ret->name = sqlStringComma(&s);
ret->patient_id = sqlUnsignedComma(&s);
ret->patient_name = sqlStringComma(&s);
ret->dataset_id = sqlUnsignedComma(&s);
-ret->exp_id = sqlUnsignedComma(&s);
ret->tissue_id = sqlUnsignedComma(&s);
*pS = s;
return ret;
}
@@ -2447,10 +1892,8 @@
if (sep == ',') fputc('"',f);
fputc(sep,f);
fprintf(f, "%u", el->dataset_id);
fputc(sep,f);
-fprintf(f, "%u", el->exp_id);
-fputc(sep,f);
fprintf(f, "%u", el->tissue_id);
fputc(lastSep,f);
}
@@ -3355,8 +2798,9 @@
{
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
@@ -3366,8 +2810,9 @@
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)
@@ -3375,9 +2820,9 @@
* Dispose of this with analysisFeaturesFreeList(). */
{
struct analysisFeatures *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[2];
+char *row[3];
while (lineFileRow(lf, row))
{
el = analysisFeaturesLoad(row);
@@ -3393,9 +2838,9 @@
* Dispose of this with analysisFeaturesFreeList(). */
{
struct analysisFeatures *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[2];
+char *row[3];
while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
{
el = analysisFeaturesLoad(row);
@@ -3437,10 +2882,10 @@
* 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')",
- tableName, el->id, el->feature_name);
+dyStringPrintf(update, "insert into %s values ( %u,'%s','%s')",
+ tableName, el->id, el->feature_name, el->type);
sqlUpdate(conn, update->string);
freeDyString(&update);
}
@@ -3453,16 +2898,18 @@
* "autosql's features include" --> "autosql\'s features include"
* before inserting into database. */
{
struct dyString *update = newDyString(updateSize);
-char *feature_name;
+char *feature_name, *type;
feature_name = sqlEscapeString(el->feature_name);
+type = sqlEscapeString(el->type);
-dyStringPrintf(update, "insert into %s values ( %u,'%s')",
- tableName, el->id, feature_name);
+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.
@@ -3474,8 +2921,9 @@
if (ret == NULL)
AllocVar(ret);
ret->id = sqlUnsignedComma(&s);
ret->feature_name = sqlStringComma(&s);
+ret->type = sqlStringComma(&s);
*pS = s;
return ret;
}
@@ -3486,8 +2934,9 @@
struct analysisFeatures *el;
if ((el = *pEl) == NULL) return;
freeMem(el->feature_name);
+freeMem(el->type);
freez(pEl);
}
void analysisFeaturesFreeList(struct analysisFeatures **pList)
@@ -3510,8 +2959,12 @@
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)