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



char *gencodeExonSupportCommaSepFieldNames = "transcriptId,seqId,seqSrc,exonId,chrom,chromStart,chromEnd";

void gencodeExonSupportStaticLoad(char **row, struct gencodeExonSupport *ret)
/* Load a row from gencodeExonSupport 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 gencodeExonSupport *gencodeExonSupportLoad(char **row)
/* Load a gencodeExonSupport from row fetched with select * from gencodeExonSupport
 * from database.  Dispose of this with gencodeExonSupportFree(). */
{
struct gencodeExonSupport *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 gencodeExonSupport *gencodeExonSupportLoadAll(char *fileName) 
/* Load all gencodeExonSupport from a whitespace-separated file.
 * Dispose of this with gencodeExonSupportFreeList(). */
{
struct gencodeExonSupport *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
char *row[7];

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

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

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

struct gencodeExonSupport *gencodeExonSupportCommaIn(char **pS, struct gencodeExonSupport *ret)
/* Create a gencodeExonSupport out of a comma separated string. 
 * This will fill in ret if non-null, otherwise will
 * return a new gencodeExonSupport */
{
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 gencodeExonSupportFree(struct gencodeExonSupport **pEl)
/* Free a single dynamically allocated gencodeExonSupport such as created
 * with gencodeExonSupportLoad(). */
{
struct gencodeExonSupport *el;

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

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

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

void gencodeExonSupportOutput(struct gencodeExonSupport *el, FILE *f, char sep, char lastSep) 
/* Print out gencodeExonSupport.  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 -------------------------------- */

