/* wgEncodeGencodeExonSupport.c was originally generated by the autoSql program, which also 
 * generated wgEncodeGencodeExonSupport.h and wgEncodeGencodeExonSupport.sql.  This module links the database and
 * the RAM representation of objects. */

/* Copyright (C) 2012 The Regents of the University of California 
 * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */

#include "common.h"
#include "linefile.h"
#include "dystring.h"
#include "jksql.h"
#include "encode/wgEncodeGencodeExonSupport.h"


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

ret->transcriptId = row[0];
ret->seqId = row[1];
ret->seqSrc = row[2];
ret->exonId = row[3];
ret->chrom = row[4];
ret->chromStart = sqlUnsigned(row[5]);
ret->chromEnd = sqlUnsigned(row[6]);
}

struct wgEncodeGencodeExonSupport *wgEncodeGencodeExonSupportLoad(char **row)
/* Load a wgEncodeGencodeExonSupport from row fetched with select * from wgEncodeGencodeExonSupport
 * from database.  Dispose of this with wgEncodeGencodeExonSupportFree(). */
{
struct wgEncodeGencodeExonSupport *ret;

AllocVar(ret);
ret->transcriptId = cloneString(row[0]);
ret->seqId = cloneString(row[1]);
ret->seqSrc = cloneString(row[2]);
ret->exonId = cloneString(row[3]);
ret->chrom = cloneString(row[4]);
ret->chromStart = sqlUnsigned(row[5]);
ret->chromEnd = sqlUnsigned(row[6]);
return ret;
}

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

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

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

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

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

if (ret == NULL)
    AllocVar(ret);
ret->transcriptId = sqlStringComma(&s);
ret->seqId = sqlStringComma(&s);
ret->seqSrc = sqlStringComma(&s);
ret->exonId = sqlStringComma(&s);
ret->chrom = sqlStringComma(&s);
ret->chromStart = sqlUnsignedComma(&s);
ret->chromEnd = sqlUnsignedComma(&s);
*pS = s;
return ret;
}

void wgEncodeGencodeExonSupportFree(struct wgEncodeGencodeExonSupport **pEl)
/* Free a single dynamically allocated wgEncodeGencodeExonSupport such as created
 * with wgEncodeGencodeExonSupportLoad(). */
{
struct wgEncodeGencodeExonSupport *el;

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

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

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

void wgEncodeGencodeExonSupportOutput(struct wgEncodeGencodeExonSupport *el, FILE *f, char sep, char lastSep) 
/* Print out wgEncodeGencodeExonSupport.  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->seqId);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->seqSrc);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->exonId);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->chrom);
if (sep == ',') fputc('"',f);
fputc(sep,f);
fprintf(f, "%u", el->chromStart);
fputc(sep,f);
fprintf(f, "%u", el->chromEnd);
fputc(lastSep,f);
}

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

