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



char *wgEncodeGencodeEntrezGeneCommaSepFieldNames = "transcriptId,entrezGeneId";

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

ret->transcriptId = row[0];
ret->entrezGeneId = sqlSigned(row[1]);
}

struct wgEncodeGencodeEntrezGene *wgEncodeGencodeEntrezGeneLoad(char **row)
/* Load a wgEncodeGencodeEntrezGene from row fetched with select * from wgEncodeGencodeEntrezGene
 * from database.  Dispose of this with wgEncodeGencodeEntrezGeneFree(). */
{
struct wgEncodeGencodeEntrezGene *ret;

AllocVar(ret);
ret->transcriptId = cloneString(row[0]);
ret->entrezGeneId = sqlSigned(row[1]);
return ret;
}

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

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

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

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

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

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

void wgEncodeGencodeEntrezGeneFree(struct wgEncodeGencodeEntrezGene **pEl)
/* Free a single dynamically allocated wgEncodeGencodeEntrezGene such as created
 * with wgEncodeGencodeEntrezGeneLoad(). */
{
struct wgEncodeGencodeEntrezGene *el;

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

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

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

void wgEncodeGencodeEntrezGeneOutput(struct wgEncodeGencodeEntrezGene *el, FILE *f, char sep, char lastSep) 
/* Print out wgEncodeGencodeEntrezGene.  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);
fprintf(f, "%d", el->entrezGeneId);
fputc(lastSep,f);
}

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

