src/hg/makeDb/hgBedsToBedExps/bToBeCfg.c 1.2
1.2 2010/03/08 23:35:38 kent
Small tweaking to get it to work with real rather than pretend data.
Index: src/hg/makeDb/hgBedsToBedExps/bToBeCfg.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/makeDb/hgBedsToBedExps/bToBeCfg.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -b -B -U 1000000 -r1.1 -r1.2
--- src/hg/makeDb/hgBedsToBedExps/bToBeCfg.c 26 Nov 2007 00:18:44 -0000 1.1
+++ src/hg/makeDb/hgBedsToBedExps/bToBeCfg.c 8 Mar 2010 23:35:38 -0000 1.2
@@ -1,161 +1,158 @@
/* bToBeCfg.c was originally generated by the autoSql program, which also
* generated bToBeCfg.h and bToBeCfg.sql. This module links the database and
* the RAM representation of objects. */
#include "common.h"
#include "linefile.h"
#include "dystring.h"
#include "jksql.h"
#include "bToBeCfg.h"
static char const rcsid[] = "$Id$";
void bToBeCfgStaticLoad(char **row, struct bToBeCfg *ret)
/* Load a row from bToBeCfg table into ret. The contents of ret will
* be replaced at the next call to this function. */
{
ret->factor = row[0];
ret->source = row[1];
ret->sourceId = row[2];
ret->dataSource = row[3];
-ret->dataType = row[4];
+ret->scoreCol = sqlSigned(row[4]);
ret->multiplier = sqlFloat(row[5]);
ret->dataTable = row[6];
}
struct bToBeCfg *bToBeCfgLoad(char **row)
/* Load a bToBeCfg from row fetched with select * from bToBeCfg
* from database. Dispose of this with bToBeCfgFree(). */
{
struct bToBeCfg *ret;
AllocVar(ret);
ret->factor = cloneString(row[0]);
ret->source = cloneString(row[1]);
ret->sourceId = cloneString(row[2]);
ret->dataSource = cloneString(row[3]);
-ret->dataType = cloneString(row[4]);
+ret->scoreCol = sqlSigned(row[4]);
ret->multiplier = sqlFloat(row[5]);
ret->dataTable = cloneString(row[6]);
return ret;
}
struct bToBeCfg *bToBeCfgLoadAll(char *fileName)
/* Load all bToBeCfg from a whitespace-separated file.
* Dispose of this with bToBeCfgFreeList(). */
{
struct bToBeCfg *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[7];
while (lineFileRow(lf, row))
{
el = bToBeCfgLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
struct bToBeCfg *bToBeCfgLoadAllByChar(char *fileName, char chopper)
/* Load all bToBeCfg from a chopper separated file.
* Dispose of this with bToBeCfgFreeList(). */
{
struct bToBeCfg *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[7];
while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
{
el = bToBeCfgLoad(row);
slAddHead(&list, el);
}
lineFileClose(&lf);
slReverse(&list);
return list;
}
struct bToBeCfg *bToBeCfgCommaIn(char **pS, struct bToBeCfg *ret)
/* Create a bToBeCfg out of a comma separated string.
* This will fill in ret if non-null, otherwise will
* return a new bToBeCfg */
{
char *s = *pS;
if (ret == NULL)
AllocVar(ret);
ret->factor = sqlStringComma(&s);
ret->source = sqlStringComma(&s);
ret->sourceId = sqlStringComma(&s);
ret->dataSource = sqlStringComma(&s);
-ret->dataType = sqlStringComma(&s);
+ret->scoreCol = sqlSignedComma(&s);
ret->multiplier = sqlFloatComma(&s);
ret->dataTable = sqlStringComma(&s);
*pS = s;
return ret;
}
void bToBeCfgFree(struct bToBeCfg **pEl)
/* Free a single dynamically allocated bToBeCfg such as created
* with bToBeCfgLoad(). */
{
struct bToBeCfg *el;
if ((el = *pEl) == NULL) return;
freeMem(el->factor);
freeMem(el->source);
freeMem(el->sourceId);
freeMem(el->dataSource);
-freeMem(el->dataType);
freeMem(el->dataTable);
freez(pEl);
}
void bToBeCfgFreeList(struct bToBeCfg **pList)
/* Free a list of dynamically allocated bToBeCfg's */
{
struct bToBeCfg *el, *next;
for (el = *pList; el != NULL; el = next)
{
next = el->next;
bToBeCfgFree(&el);
}
*pList = NULL;
}
void bToBeCfgOutput(struct bToBeCfg *el, FILE *f, char sep, char lastSep)
/* Print out bToBeCfg. Separate fields with sep. Follow last field with lastSep. */
{
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->factor);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->source);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->sourceId);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->dataSource);
if (sep == ',') fputc('"',f);
fputc(sep,f);
-if (sep == ',') fputc('"',f);
-fprintf(f, "%s", el->dataType);
-if (sep == ',') fputc('"',f);
+fprintf(f, "%d", el->scoreCol);
fputc(sep,f);
fprintf(f, "%g", el->multiplier);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->dataTable);
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
/* -------------------------------- End autoSql Generated Code -------------------------------- */