/* imreClone.c was originally generated by the autoSql program, which also * generated imreClone.h and imreClone.sql. This module links the database and * the RAM representation of objects. */ #include "common.h" #include "linefile.h" #include "jksql.h" #include "imreClone.h" void imreCloneStaticLoad(char **row, struct imreClone *ret) /* Load a row from imreClone table into ret. The contents of ret will * be replaced at the next call to this function. */ { int sizeOne,i; char *s; ret->accession = row[0]; ret->cloneName = row[1]; ret->imreContig = row[2]; ret->origContig = row[3]; ret->source = row[4]; } struct imreClone *imreCloneLoad(char **row) /* Load a imreClone from row fetched with select * from imreClone * from database. Dispose of this with imreCloneFree(). */ { struct imreClone *ret; int sizeOne,i; char *s; AllocVar(ret); ret->accession = cloneString(row[0]); ret->cloneName = cloneString(row[1]); ret->imreContig = cloneString(row[2]); ret->origContig = cloneString(row[3]); ret->source = cloneString(row[4]); return ret; } struct imreClone *imreCloneLoadAll(char *fileName) /* Load all imreClone from a tab-separated file. * Dispose of this with imreCloneFreeList(). */ { struct imreClone *list = NULL, *el; struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[5]; while (lineFileRow(lf, row)) { el = imreCloneLoad(row); slAddHead(&list, el); } lineFileClose(&lf); slReverse(&list); return list; } struct imreClone *imreCloneCommaIn(char **pS, struct imreClone *ret) /* Create a imreClone out of a comma separated string. * This will fill in ret if non-null, otherwise will * return a new imreClone */ { char *s = *pS; int i; if (ret == NULL) AllocVar(ret); ret->accession = sqlStringComma(&s); ret->cloneName = sqlStringComma(&s); ret->imreContig = sqlStringComma(&s); ret->origContig = sqlStringComma(&s); ret->source = sqlStringComma(&s); *pS = s; return ret; } void imreCloneFree(struct imreClone **pEl) /* Free a single dynamically allocated imreClone such as created * with imreCloneLoad(). */ { struct imreClone *el; if ((el = *pEl) == NULL) return; freeMem(el->accession); freeMem(el->cloneName); freeMem(el->imreContig); freeMem(el->origContig); freeMem(el->source); freez(pEl); } void imreCloneFreeList(struct imreClone **pList) /* Free a list of dynamically allocated imreClone's */ { struct imreClone *el, *next; for (el = *pList; el != NULL; el = next) { next = el->next; imreCloneFree(&el); } *pList = NULL; } void imreCloneOutput(struct imreClone *el, FILE *f, char sep, char lastSep) /* Print out imreClone. Separate fields with sep. Follow last field with lastSep. */ { int i; if (sep == ',') fputc('"',f); fprintf(f, "%s", el->accession); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->cloneName); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->imreContig); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->origContig); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->source); if (sep == ',') fputc('"',f); fputc(lastSep,f); }