95efc27edf24bba8d0c7e53d2ef4aead59982826 braney Mon Jun 15 18:29:39 2020 -0700 Merging in our gencode merge code to master branch diff --git src/hg/lib/gencodeToPdb.c src/hg/lib/gencodeToPdb.c new file mode 100644 index 0000000..8f564ef --- /dev/null +++ src/hg/lib/gencodeToPdb.c @@ -0,0 +1,126 @@ +/* gencodeToPdb.c was originally generated by the autoSql program, which also + * generated gencodeToPdb.h and gencodeToPdb.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 "gencodeToPdb.h" + + + +char *gencodeToPdbCommaSepFieldNames = "transcriptId,pdbId"; + +void gencodeToPdbStaticLoad(char **row, struct gencodeToPdb *ret) +/* Load a row from gencodeToPdb table into ret. The contents of ret will + * be replaced at the next call to this function. */ +{ + +ret->transcriptId = row[0]; +ret->pdbId = row[1]; +} + +struct gencodeToPdb *gencodeToPdbLoad(char **row) +/* Load a gencodeToPdb from row fetched with select * from gencodeToPdb + * from database. Dispose of this with gencodeToPdbFree(). */ +{ +struct gencodeToPdb *ret; + +AllocVar(ret); +ret->transcriptId = cloneString(row[0]); +ret->pdbId = cloneString(row[1]); +return ret; +} + +struct gencodeToPdb *gencodeToPdbLoadAll(char *fileName) +/* Load all gencodeToPdb from a whitespace-separated file. + * Dispose of this with gencodeToPdbFreeList(). */ +{ +struct gencodeToPdb *list = NULL, *el; +struct lineFile *lf = lineFileOpen(fileName, TRUE); +char *row[2]; + +while (lineFileRow(lf, row)) + { + el = gencodeToPdbLoad(row); + slAddHead(&list, el); + } +lineFileClose(&lf); +slReverse(&list); +return list; +} + +struct gencodeToPdb *gencodeToPdbLoadAllByChar(char *fileName, char chopper) +/* Load all gencodeToPdb from a chopper separated file. + * Dispose of this with gencodeToPdbFreeList(). */ +{ +struct gencodeToPdb *list = NULL, *el; +struct lineFile *lf = lineFileOpen(fileName, TRUE); +char *row[2]; + +while (lineFileNextCharRow(lf, chopper, row, ArraySize(row))) + { + el = gencodeToPdbLoad(row); + slAddHead(&list, el); + } +lineFileClose(&lf); +slReverse(&list); +return list; +} + +struct gencodeToPdb *gencodeToPdbCommaIn(char **pS, struct gencodeToPdb *ret) +/* Create a gencodeToPdb out of a comma separated string. + * This will fill in ret if non-null, otherwise will + * return a new gencodeToPdb */ +{ +char *s = *pS; + +if (ret == NULL) + AllocVar(ret); +ret->transcriptId = sqlStringComma(&s); +ret->pdbId = sqlStringComma(&s); +*pS = s; +return ret; +} + +void gencodeToPdbFree(struct gencodeToPdb **pEl) +/* Free a single dynamically allocated gencodeToPdb such as created + * with gencodeToPdbLoad(). */ +{ +struct gencodeToPdb *el; + +if ((el = *pEl) == NULL) return; +freeMem(el->transcriptId); +freeMem(el->pdbId); +freez(pEl); +} + +void gencodeToPdbFreeList(struct gencodeToPdb **pList) +/* Free a list of dynamically allocated gencodeToPdb's */ +{ +struct gencodeToPdb *el, *next; + +for (el = *pList; el != NULL; el = next) + { + next = el->next; + gencodeToPdbFree(&el); + } +*pList = NULL; +} + +void gencodeToPdbOutput(struct gencodeToPdb *el, FILE *f, char sep, char lastSep) +/* Print out gencodeToPdb. 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->pdbId); +if (sep == ',') fputc('"',f); +fputc(lastSep,f); +} + +/* -------------------------------- End autoSql Generated Code -------------------------------- */ +