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



char *gencodeToRefSeqCommaSepFieldNames = "transcriptId,rnaAcc,pepAcc";

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

ret->transcriptId = row[0];
ret->rnaAcc = row[1];
ret->pepAcc = row[2];
}

struct gencodeToRefSeq *gencodeToRefSeqLoad(char **row)
/* Load a gencodeToRefSeq from row fetched with select * from gencodeToRefSeq
 * from database.  Dispose of this with gencodeToRefSeqFree(). */
{
struct gencodeToRefSeq *ret;

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

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

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

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

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

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

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

void gencodeToRefSeqFree(struct gencodeToRefSeq **pEl)
/* Free a single dynamically allocated gencodeToRefSeq such as created
 * with gencodeToRefSeqLoad(). */
{
struct gencodeToRefSeq *el;

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

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

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

void gencodeToRefSeqOutput(struct gencodeToRefSeq *el, FILE *f, char sep, char lastSep) 
/* Print out gencodeToRefSeq.  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->rnaAcc);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->pepAcc);
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}

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

