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



char *clinvarSubCommaSepFieldNames = "varId,clinSign,dateLastEval,description,subPhenoInfo,repPhenoInfo,revStatus,collMethod,originCounts,submitter,scv,subGeneSymbol,explOfInterp";

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

ret->varId = sqlSigned(row[0]);
ret->clinSign = row[1];
ret->dateLastEval = row[2];
ret->description = row[3];
ret->subPhenoInfo = row[4];
ret->repPhenoInfo = row[5];
ret->revStatus = row[6];
ret->collMethod = row[7];
ret->originCounts = row[8];
ret->submitter = row[9];
ret->scv = row[10];
ret->subGeneSymbol = row[11];
ret->explOfInterp = row[12];
}

struct clinvarSub *clinvarSubLoad(char **row)
/* Load a clinvarSub from row fetched with select * from clinvarSub
 * from database.  Dispose of this with clinvarSubFree(). */
{
struct clinvarSub *ret;

AllocVar(ret);
ret->varId = sqlSigned(row[0]);
ret->clinSign = cloneString(row[1]);
ret->dateLastEval = cloneString(row[2]);
ret->description = cloneString(row[3]);
ret->subPhenoInfo = cloneString(row[4]);
ret->repPhenoInfo = cloneString(row[5]);
ret->revStatus = cloneString(row[6]);
ret->collMethod = cloneString(row[7]);
ret->originCounts = cloneString(row[8]);
ret->submitter = cloneString(row[9]);
ret->scv = cloneString(row[10]);
ret->subGeneSymbol = cloneString(row[11]);
ret->explOfInterp = cloneString(row[12]);
return ret;
}

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

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

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

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

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

if (ret == NULL)
    AllocVar(ret);
ret->varId = sqlSignedComma(&s);
ret->clinSign = sqlStringComma(&s);
ret->dateLastEval = sqlStringComma(&s);
ret->description = sqlStringComma(&s);
ret->subPhenoInfo = sqlStringComma(&s);
ret->repPhenoInfo = sqlStringComma(&s);
ret->revStatus = sqlStringComma(&s);
ret->collMethod = sqlStringComma(&s);
ret->originCounts = sqlStringComma(&s);
ret->submitter = sqlStringComma(&s);
ret->scv = sqlStringComma(&s);
ret->subGeneSymbol = sqlStringComma(&s);
ret->explOfInterp = sqlStringComma(&s);
*pS = s;
return ret;
}

void clinvarSubFree(struct clinvarSub **pEl)
/* Free a single dynamically allocated clinvarSub such as created
 * with clinvarSubLoad(). */
{
struct clinvarSub *el;

if ((el = *pEl) == NULL) return;
freeMem(el->clinSign);
freeMem(el->dateLastEval);
freeMem(el->description);
freeMem(el->subPhenoInfo);
freeMem(el->repPhenoInfo);
freeMem(el->revStatus);
freeMem(el->collMethod);
freeMem(el->originCounts);
freeMem(el->submitter);
freeMem(el->scv);
freeMem(el->subGeneSymbol);
freeMem(el->explOfInterp);
freez(pEl);
}

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

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

void clinvarSubOutput(struct clinvarSub *el, FILE *f, char sep, char lastSep) 
/* Print out clinvarSub.  Separate fields with sep. Follow last field with lastSep. */
{
fprintf(f, "%d", el->varId);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->clinSign);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->dateLastEval);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->description);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->subPhenoInfo);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->repPhenoInfo);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->revStatus);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->collMethod);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->originCounts);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->submitter);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->scv);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->subGeneSymbol);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
fprintf(f, "%s", el->explOfInterp);
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}

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

