src/hg/instinct/bioInt2/bioIntDb.h 1.2
1.2 2009/03/21 19:54:10 jsanborn
added routine to set cohorts
Index: src/hg/instinct/bioInt2/bioIntDb.h
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/bioIntDb.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 4 -r1.1 -r1.2
--- src/hg/instinct/bioInt2/bioIntDb.h 20 Mar 2009 06:06:31 -0000 1.1
+++ src/hg/instinct/bioInt2/bioIntDb.h 21 Mar 2009 19:54:10 -0000 1.2
@@ -469,8 +469,160 @@
#define datasetsCommaOut(el,f) datasetsOutput(el,f,',',',');
/* Print out datasets as a comma separated list including final comma. */
+#define COHORTS_NUM_COLS 2
+
+struct cohorts
+/* All cohorts */
+ {
+ struct cohorts *next; /* Next in singly linked list. */
+ unsigned id; /* Cohort Id */
+ char *name; /* Cohort name */
+ };
+
+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. */
+
+struct cohorts *cohortsLoad(char **row);
+/* Load a cohorts from row fetched with select * from cohorts
+ * from database. Dispose of this with cohortsFree(). */
+
+struct cohorts *cohortsLoadAll(char *fileName);
+/* Load all cohorts from whitespace-separated file.
+ * Dispose of this with cohortsFreeList(). */
+
+struct cohorts *cohortsLoadAllByChar(char *fileName, char chopper);
+/* Load all cohorts from chopper separated file.
+ * Dispose of this with cohortsFreeList(). */
+
+#define cohortsLoadAllByTab(a) cohortsLoadAllByChar(a, '\t');
+/* Load all cohorts from tab separated file.
+ * Dispose of this with cohortsFreeList(). */
+
+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(). */
+
+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() */
+
+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 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 */
+
+void cohortsFree(struct cohorts **pEl);
+/* Free a single dynamically allocated cohorts such as created
+ * with cohortsLoad(). */
+
+void cohortsFreeList(struct cohorts **pList);
+/* Free a list of dynamically allocated cohorts's */
+
+void cohortsOutput(struct cohorts *el, FILE *f, char sep, char lastSep);
+/* Print out cohorts. Separate fields with sep. Follow last field with lastSep. */
+
+#define cohortsTabOut(el,f) cohortsOutput(el,f,'\t','\n');
+/* Print out cohorts as a line in a tab-separated file. */
+
+#define cohortsCommaOut(el,f) cohortsOutput(el,f,',',',');
+/* Print out cohorts as a comma separated list including final comma. */
+
+#define DATASETCOHORT_NUM_COLS 2
+
+struct datasetCohort
+/* Dataset cohort lookup */
+ {
+ struct datasetCohort *next; /* Next in singly linked list. */
+ unsigned dataset_id; /* Dataset Id */
+ unsigned cohort_id; /* Cohort Id */
+ };
+
+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. */
+
+struct datasetCohort *datasetCohortLoad(char **row);
+/* Load a datasetCohort from row fetched with select * from datasetCohort
+ * from database. Dispose of this with datasetCohortFree(). */
+
+struct datasetCohort *datasetCohortLoadAll(char *fileName);
+/* Load all datasetCohort from whitespace-separated file.
+ * Dispose of this with datasetCohortFreeList(). */
+
+struct datasetCohort *datasetCohortLoadAllByChar(char *fileName, char chopper);
+/* Load all datasetCohort from chopper separated file.
+ * Dispose of this with datasetCohortFreeList(). */
+
+#define datasetCohortLoadAllByTab(a) datasetCohortLoadAllByChar(a, '\t');
+/* Load all datasetCohort from tab separated file.
+ * Dispose of this with datasetCohortFreeList(). */
+
+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(). */
+
+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() */
+
+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 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 */
+
+void datasetCohortFree(struct datasetCohort **pEl);
+/* Free a single dynamically allocated datasetCohort such as created
+ * with datasetCohortLoad(). */
+
+void datasetCohortFreeList(struct datasetCohort **pList);
+/* Free a list of dynamically allocated datasetCohort's */
+
+void datasetCohortOutput(struct datasetCohort *el, FILE *f, char sep, char lastSep);
+/* Print out datasetCohort. Separate fields with sep. Follow last field with lastSep. */
+
+#define datasetCohortTabOut(el,f) datasetCohortOutput(el,f,'\t','\n');
+/* Print out datasetCohort as a line in a tab-separated file. */
+
+#define datasetCohortCommaOut(el,f) datasetCohortOutput(el,f,',',',');
+/* Print out datasetCohort as a comma separated list including final comma. */
+
#define GENELOOKUP_NUM_COLS 2
struct geneLookup
/* Lookup table linking knownGene */
@@ -1087,15 +1239,170 @@
#define clinicalDataCommaOut(el,f) clinicalDataOutput(el,f,',',',');
/* Print out clinicalData as a comma separated list including final comma. */
+#define ANALYSES_NUM_COLS 4
+
+struct analyses
+/* All analyses run */
+ {
+ struct analyses *next; /* Next in singly linked list. */
+ unsigned id; /* Analysis id */
+ unsigned cohort_id; /* Cohort Id */
+ char *module; /* Analysis Module */
+ char *result_table; /* Table containing result */
+ };
+
+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. */
+
+struct analyses *analysesLoad(char **row);
+/* Load a analyses from row fetched with select * from analyses
+ * from database. Dispose of this with analysesFree(). */
+
+struct analyses *analysesLoadAll(char *fileName);
+/* Load all analyses from whitespace-separated file.
+ * Dispose of this with analysesFreeList(). */
+
+struct analyses *analysesLoadAllByChar(char *fileName, char chopper);
+/* Load all analyses from chopper separated file.
+ * Dispose of this with analysesFreeList(). */
+
+#define analysesLoadAllByTab(a) analysesLoadAllByChar(a, '\t');
+/* Load all analyses from tab separated file.
+ * Dispose of this with analysesFreeList(). */
+
+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(). */
+
+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() */
+
+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 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 */
+
+void analysesFree(struct analyses **pEl);
+/* Free a single dynamically allocated analyses such as created
+ * with analysesLoad(). */
+
+void analysesFreeList(struct analyses **pList);
+/* Free a list of dynamically allocated analyses's */
+
+void analysesOutput(struct analyses *el, FILE *f, char sep, char lastSep);
+/* Print out analyses. Separate fields with sep. Follow last field with lastSep. */
+
+#define analysesTabOut(el,f) analysesOutput(el,f,'\t','\n');
+/* Print out analyses as a line in a tab-separated file. */
+
+#define analysesCommaOut(el,f) analysesOutput(el,f,',',',');
+/* Print out analyses as a comma separated list including final comma. */
+
+#define ANALYSISPARAMS_NUM_COLS 3
+
+struct analysisParams
+/* All analysis parameters */
+ {
+ struct analysisParams *next; /* Next in singly linked list. */
+ unsigned analysis_id; /* Module Id */
+ char *key; /* Parameter key */
+ char *val; /* Parameter val */
+ };
+
+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. */
+
+struct analysisParams *analysisParamsLoad(char **row);
+/* Load a analysisParams from row fetched with select * from analysisParams
+ * from database. Dispose of this with analysisParamsFree(). */
+
+struct analysisParams *analysisParamsLoadAll(char *fileName);
+/* Load all analysisParams from whitespace-separated file.
+ * Dispose of this with analysisParamsFreeList(). */
+
+struct analysisParams *analysisParamsLoadAllByChar(char *fileName, char chopper);
+/* Load all analysisParams from chopper separated file.
+ * Dispose of this with analysisParamsFreeList(). */
+
+#define analysisParamsLoadAllByTab(a) analysisParamsLoadAllByChar(a, '\t');
+/* Load all analysisParams from tab separated file.
+ * Dispose of this with analysisParamsFreeList(). */
+
+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(). */
+
+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() */
+
+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 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 */
+
+void analysisParamsFree(struct analysisParams **pEl);
+/* Free a single dynamically allocated analysisParams such as created
+ * with analysisParamsLoad(). */
+
+void analysisParamsFreeList(struct analysisParams **pList);
+/* Free a list of dynamically allocated analysisParams's */
+
+void analysisParamsOutput(struct analysisParams *el, FILE *f, char sep, char lastSep);
+/* Print out analysisParams. Separate fields with sep. Follow last field with lastSep. */
+
+#define analysisParamsTabOut(el,f) analysisParamsOutput(el,f,'\t','\n');
+/* Print out analysisParams as a line in a tab-separated file. */
+
+#define analysisParamsCommaOut(el,f) analysisParamsOutput(el,f,',',',');
+/* Print out analysisParams as a comma separated list including final comma. */
+
#define ANALYSISFEATURES_NUM_COLS 2
struct analysisFeatures
/* All analysis features */
{
struct analysisFeatures *next; /* Next in singly linked list. */
- unsigned feature_id; /* Feature Id */
+ unsigned id; /* Feature Id */
char *feature_name; /* Feature Name */
};
void analysisFeaturesStaticLoad(char **row, struct analysisFeatures *ret);
@@ -1170,9 +1477,9 @@
/* All analysis vals */
{
struct analysisVals *next; /* Next in singly linked list. */
unsigned sample_id; /* Sample Id */
- unsigned feature_id; /* Feature Id */
+ unsigned feature_id; /* Analysis Feature Id */
float val; /* Val */
float conf; /* Confidence */
};