/* wgEncodeGencodeGeneSymbol.c was originally generated by the autoSql program, which also 
 * generated wgEncodeGencodeGeneSymbol.h and wgEncodeGencodeGeneSymbol.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 "encode/wgEncodeGencodeGeneSymbol.h"



char *wgEncodeGencodeGeneSymbolCommaSepFieldNames = "transcriptId,symbol,geneId";

void wgEncodeGencodeGeneSymbolStaticLoad(char **row, struct wgEncodeGencodeGeneSymbol *ret)
/* Load a row from wgEncodeGencodeGeneSymbol table into ret.  The contents of ret will
 * be replaced at the next call to this function. */
{

ret->transcriptId = row[0];
ret->symbol = row[1];
ret->geneId = row[2];
}

struct wgEncodeGencodeGeneSymbol *wgEncodeGencodeGeneSymbolLoad(char **row)
/* Load a wgEncodeGencodeGeneSymbol from row fetched with select * from wgEncodeGencodeGeneSymbol
 * from database.  Dispose of this with wgEncodeGencodeGeneSymbolFree(). */
{
struct wgEncodeGencodeGeneSymbol *ret;

AllocVar(ret);
ret->transcriptId = cloneString(row[0]);
ret->symbol = cloneString(row[1]);
ret->geneId = cloneString(row[2]);
return ret;
}

struct wgEncodeGencodeGeneSymbol *wgEncodeGencodeGeneSymbolLoadAll(char *fileName) 
/* Load all wgEncodeGencodeGeneSymbol from a whitespace-separated file.
 * Dispose of this with wgEncodeGencodeGeneSymbolFreeList(). */
{
struct wgEncodeGencodeGeneSymbol *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[3];

while (lineFileRow(lf, row))
    {
    el = wgEncodeGencodeGeneSymbolLoad(row);
    slAddHead(&list, el);
    }
lineFileClose(&lf);
slReverse(&list);
return list;
}

struct wgEncodeGencodeGeneSymbol *wgEncodeGencodeGeneSymbolLoadAllByChar(char *fileName, char chopper) 
/* Load all wgEncodeGencodeGeneSymbol from a chopper separated file.
 * Dispose of this with wgEncodeGencodeGeneSymbolFreeList(). */
{
struct wgEncodeGencodeGeneSymbol *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[3];

while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
    {
    el = wgEncodeGencodeGeneSymbolLoad(row);
    slAddHead(&list, el);
    }
lineFileClose(&lf);
slReverse(&list);
return list;
}

struct wgEncodeGencodeGeneSymbol *wgEncodeGencodeGeneSymbolCommaIn(char **pS, struct wgEncodeGencodeGeneSymbol *ret)
/* Create a wgEncodeGencodeGeneSymbol out of a comma separated string. 
 * This will fill in ret if non-null, otherwise will
 * return a new wgEncodeGencodeGeneSymbol */
{
char *s = *pS;

if (ret == NULL)
    AllocVar(ret);
ret->transcriptId = sqlStringComma(&s);
ret->symbol = sqlStringComma(&s);
ret->geneId = sqlStringComma(&s);
*pS = s;
return ret;
}

void wgEncodeGencodeGeneSymbolFree(struct wgEncodeGencodeGeneSymbol **pEl)
/* Free a single dynamically allocated wgEncodeGencodeGeneSymbol such as created
 * with wgEncodeGencodeGeneSymbolLoad(). */
{
struct wgEncodeGencodeGeneSymbol *el;

if ((el = *pEl) == NULL) return;
freeMem(el->transcriptId);
freeMem(el->symbol);
freeMem(el->geneId);
freez(pEl);
}

void wgEncodeGencodeGeneSymbolFreeList(struct wgEncodeGencodeGeneSymbol **pList)
/* Free a list of dynamically allocated wgEncodeGencodeGeneSymbol's */
{
struct wgEncodeGencodeGeneSymbol *el, *next;

for (el = *pList; el != NULL; el = next)
    {
    next = el->next;
    wgEncodeGencodeGeneSymbolFree(&el);
    }
*pList = NULL;
}

void wgEncodeGencodeGeneSymbolOutput(struct wgEncodeGencodeGeneSymbol *el, FILE *f, char sep, char lastSep) 
/* Print out wgEncodeGencodeGeneSymbol.  Separate fields with sep. Follow last field with lastSep. */
{
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->transcriptId);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->symbol);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->geneId);
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}

/* -------------------------------- End autoSql Generated Code -------------------------------- */

