src/hg/instinct/bioInt2/bioIntDb.c 1.5
1.5 2009/03/29 01:40:42 jsanborn
added to UI code
Index: src/hg/instinct/bioInt2/bioIntDb.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/bioInt2/bioIntDb.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -b -B -U 4 -r1.4 -r1.5
--- src/hg/instinct/bioInt2/bioIntDb.c 27 Mar 2009 20:15:52 -0000 1.4
+++ src/hg/instinct/bioInt2/bioIntDb.c 29 Mar 2009 01:40:42 -0000 1.5
@@ -9,31 +9,8 @@
#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
* be replaced at the next call to this function. */
{
@@ -207,36 +184,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void pathwaysJsonOutput(struct pathways *el, FILE *f)
-/* Print out pathways in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"source");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->source);
-fputc('"',f);
-fputc('}',f);
-}
-
void pathwayGenesStaticLoad(char **row, struct pathwayGenes *ret)
/* Load a row from pathwayGenes table into ret. The contents of ret will
* be replaced at the next call to this function. */
{
@@ -393,26 +342,8 @@
fprintf(f, "%u", el->gene_id);
fputc(lastSep,f);
}
-void pathwayGenesJsonOutput(struct pathwayGenes *el, FILE *f)
-/* Print out pathwayGenes in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"gene_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->gene_id);
-fputc('}',f);
-}
-
void pathwayInfoStaticLoad(char **row, struct pathwayInfo *ret)
/* Load a row from pathwayInfo table into ret. The contents of ret will
* be replaced at the next call to this function. */
{
@@ -576,28 +507,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void pathwayInfoJsonOutput(struct pathwayInfo *el, FILE *f)
-/* Print out pathwayInfo in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"description");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->description);
-fputc('"',f);
-fputc('}',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. */
{
@@ -761,28 +672,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void tissuesJsonOutput(struct tissues *el, FILE *f)
-/* Print out tissues in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc('}',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. */
{
@@ -956,36 +847,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void dataTypesJsonOutput(struct dataTypes *el, FILE *f)
-/* Print out dataTypes in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"format");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->format);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc('}',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. */
{
@@ -1194,70 +1057,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void datasetsJsonOutput(struct datasets *el, FILE *f)
-/* Print out datasets in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"tissue_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->tissue_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"type_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->type_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"num_samples");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->num_samples);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"data_table");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->data_table);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"probe_table");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->probe_table);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"probe_to_gene_table");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->probe_to_gene_table);
-fputc('"',f);
-fputc('}',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. */
{
@@ -1421,28 +1222,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void cohortsJsonOutput(struct cohorts *el, FILE *f)
-/* Print out cohorts in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc('}',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. */
{
@@ -1599,26 +1380,8 @@
fprintf(f, "%u", el->cohort_id);
fputc(lastSep,f);
}
-void datasetCohortJsonOutput(struct datasetCohort *el, FILE *f)
-/* Print out datasetCohort in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"dataset_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->dataset_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"cohort_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->cohort_id);
-fputc('}',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. */
{
@@ -1782,28 +1545,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void geneLookupJsonOutput(struct geneLookup *el, FILE *f)
-/* Print out geneLookup in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"kgId");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->kgId);
-fputc('"',f);
-fputc('}',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. */
{
@@ -1987,48 +1730,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void probeInfoJsonOutput(struct probeInfo *el, FILE *f)
-/* Print out probeInfo in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"chrom");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->chrom);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"start");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->start);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"stop");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->stop);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc('}',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. */
{
@@ -2185,26 +1888,8 @@
fprintf(f, "%u", el->gene_id);
fputc(lastSep,f);
}
-void probeToGeneJsonOutput(struct probeToGene *el, FILE *f)
-/* Print out probeToGene in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"probe_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->probe_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"gene_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->gene_id);
-fputc('}',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. */
{
@@ -2366,32 +2051,8 @@
fprintf(f, "%g", el->val);
fputc(lastSep,f);
}
-void probeSampleValJsonOutput(struct probeSampleVal *el, FILE *f)
-/* Print out probeSampleVal in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"probe_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->probe_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"sample_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->sample_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"val");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%g", el->val);
-fputc('}',f);
-}
-
struct probeVals *probeValsLoad(char **row)
/* Load a probeVals from row fetched with select * from probeVals
* from database. Dispose of this with probeValsFree(). */
{
@@ -2400,12 +2061,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;
}
@@ -2574,42 +2234,8 @@
}
fputc(lastSep,f);
}
-void probeValsJsonOutput(struct probeVals *el, FILE *f)
-/* Print out probeVals in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"probe_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->probe_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"sample_count");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->sample_count);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"sample_data");
-fputc('"',f);
-fputc(':',f);
-{
-int i;
-fputc('[',f);
-for (i=0; i<el->sample_count; ++i)
- {
- fprintf(f, "%g", el->sample_data[i]);
- if (i<(el->sample_count)-1)
- fputc(',',f);
- }
-fputc(']',f);
-}
-fputc('}',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. */
{
@@ -2803,60 +2429,8 @@
fprintf(f, "%u", el->tissue_id);
fputc(lastSep,f);
}
-void samplesJsonOutput(struct samples *el, FILE *f)
-/* Print out samples in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"patient_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->patient_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"patient_name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->patient_name);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"dataset_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->dataset_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"exp_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->exp_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"tissue_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->tissue_id);
-fputc('}',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. */
{
@@ -3040,44 +2614,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void featuresJsonOutput(struct features *el, FILE *f)
-/* Print out features in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"shortLabel");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->shortLabel);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"longLabel");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->longLabel);
-fputc('"',f);
-fputc('}',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. */
{
@@ -3251,40 +2789,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void clinicalDataJsonOutput(struct clinicalData *el, FILE *f)
-/* Print out clinicalData in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"sample_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->sample_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"feature_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->feature_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"val");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%g", el->val);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"code");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->code);
-fputc('"',f);
-fputc('}',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. */
{
@@ -3468,48 +2974,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void analysesJsonOutput(struct analyses *el, FILE *f)
-/* Print out analyses in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"cohort_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->cohort_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"module_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->module_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"result_table");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->result_table);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"input_tables");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->input_tables);
-fputc('"',f);
-fputc('}',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. */
{
@@ -3683,36 +3149,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void analysisModulesJsonOutput(struct analysisModules *el, FILE *f)
-/* Print out analysisModules in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"type");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->type);
-fputc('"',f);
-fputc('}',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. */
{
@@ -3886,36 +3324,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void analysisParamsJsonOutput(struct analysisParams *el, FILE *f)
-/* Print out analysisParams in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"analysis_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->analysis_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->name);
-fputc('"',f);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"val");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->val);
-fputc('"',f);
-fputc('}',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. */
{
@@ -4079,28 +3489,8 @@
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
-void analysisFeaturesJsonOutput(struct analysisFeatures *el, FILE *f)
-/* Print out analysisFeatures in JSON format. */
-{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"feature_name");
-fputc('"',f);
-fputc(':',f);
-fputc('"',f);
-fprintf(f, "%s", el->feature_name);
-fputc('"',f);
-fputc('}',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. */
{
@@ -4267,36 +3657,334 @@
fprintf(f, "%g", el->conf);
fputc(lastSep,f);
}
-void analysisValsJsonOutput(struct analysisVals *el, FILE *f)
-/* Print out analysisVals in JSON format. */
+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(). */
{
-fputc('{',f);
-fputc('"',f);
-fprintf(f,"sample_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->sample_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"feature_id");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%u", el->feature_id);
-fputc(',',f);
-fputc('"',f);
-fprintf(f,"val");
-fputc('"',f);
-fputc(':',f);
+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(',',f);
-fputc('"',f);
-fprintf(f,"conf");
-fputc('"',f);
-fputc(':',f);
-fprintf(f, "%g", el->conf);
-fputc('}',f);
+fputc(lastSep,f);
}
/* -------------------------------- End autoSql Generated Code -------------------------------- */