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