e70152e44cc66cc599ff6b699eb8adc07f3e656a kent Sat May 24 21:09:34 2014 -0700 Adding Copyright NNNN Regents of the University of California to all files I believe with reasonable certainty were developed under UCSC employ or as part of Genome Browser copyright assignment. diff --git src/hg/lib/transRegCodeProbe.c src/hg/lib/transRegCodeProbe.c index 798f75b..3acb1f0 100644 --- src/hg/lib/transRegCodeProbe.c +++ src/hg/lib/transRegCodeProbe.c @@ -1,187 +1,190 @@ /* transRegCodeProbe.c was originally generated by the autoSql program, which also * generated transRegCodeProbe.h and transRegCodeProbe.sql. This module links the database and * the RAM representation of objects. */ +/* Copyright (C) 2014 The Regents of the University of California + * See README in this or parent directory for licensing information. */ + #include "common.h" #include "linefile.h" #include "dystring.h" #include "jksql.h" #include "transRegCodeProbe.h" struct transRegCodeProbe *transRegCodeProbeLoad(char **row) /* Load a transRegCodeProbe from row fetched with select * from transRegCodeProbe * from database. Dispose of this with transRegCodeProbeFree(). */ { struct transRegCodeProbe *ret; AllocVar(ret); ret->tfCount = sqlUnsigned(row[4]); ret->chrom = cloneString(row[0]); ret->chromStart = sqlUnsigned(row[1]); ret->chromEnd = sqlUnsigned(row[2]); ret->name = cloneString(row[3]); { int sizeOne; sqlStringDynamicArray(row[5], &ret->tfList, &sizeOne); assert(sizeOne == ret->tfCount); } { int sizeOne; sqlFloatDynamicArray(row[6], &ret->bindVals, &sizeOne); assert(sizeOne == ret->tfCount); } return ret; } struct transRegCodeProbe *transRegCodeProbeLoadAll(char *fileName) /* Load all transRegCodeProbe from a whitespace-separated file. * Dispose of this with transRegCodeProbeFreeList(). */ { struct transRegCodeProbe *list = NULL, *el; struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[7]; while (lineFileRow(lf, row)) { el = transRegCodeProbeLoad(row); slAddHead(&list, el); } lineFileClose(&lf); slReverse(&list); return list; } struct transRegCodeProbe *transRegCodeProbeLoadAllByChar(char *fileName, char chopper) /* Load all transRegCodeProbe from a chopper separated file. * Dispose of this with transRegCodeProbeFreeList(). */ { struct transRegCodeProbe *list = NULL, *el; struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[7]; while (lineFileNextCharRow(lf, chopper, row, ArraySize(row))) { el = transRegCodeProbeLoad(row); slAddHead(&list, el); } lineFileClose(&lf); slReverse(&list); return list; } struct transRegCodeProbe *transRegCodeProbeCommaIn(char **pS, struct transRegCodeProbe *ret) /* Create a transRegCodeProbe out of a comma separated string. * This will fill in ret if non-null, otherwise will * return a new transRegCodeProbe */ { char *s = *pS; if (ret == NULL) AllocVar(ret); ret->chrom = sqlStringComma(&s); ret->chromStart = sqlUnsignedComma(&s); ret->chromEnd = sqlUnsignedComma(&s); ret->name = sqlStringComma(&s); ret->tfCount = sqlUnsignedComma(&s); { int i; s = sqlEatChar(s, '{'); AllocArray(ret->tfList, ret->tfCount); for (i=0; itfCount; ++i) { ret->tfList[i] = sqlStringComma(&s); } s = sqlEatChar(s, '}'); s = sqlEatChar(s, ','); } { int i; s = sqlEatChar(s, '{'); AllocArray(ret->bindVals, ret->tfCount); for (i=0; itfCount; ++i) { ret->bindVals[i] = sqlFloatComma(&s); } s = sqlEatChar(s, '}'); s = sqlEatChar(s, ','); } *pS = s; return ret; } void transRegCodeProbeFree(struct transRegCodeProbe **pEl) /* Free a single dynamically allocated transRegCodeProbe such as created * with transRegCodeProbeLoad(). */ { struct transRegCodeProbe *el; if ((el = *pEl) == NULL) return; freeMem(el->chrom); freeMem(el->name); /* All strings in tfList are allocated at once, so only need to free first. */ if (el->tfList != NULL) freeMem(el->tfList[0]); freeMem(el->tfList); freeMem(el->bindVals); freez(pEl); } void transRegCodeProbeFreeList(struct transRegCodeProbe **pList) /* Free a list of dynamically allocated transRegCodeProbe's */ { struct transRegCodeProbe *el, *next; for (el = *pList; el != NULL; el = next) { next = el->next; transRegCodeProbeFree(&el); } *pList = NULL; } void transRegCodeProbeOutput(struct transRegCodeProbe *el, FILE *f, char sep, char lastSep) /* Print out transRegCodeProbe. Separate fields with sep. Follow last field with lastSep. */ { 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(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->name); if (sep == ',') fputc('"',f); fputc(sep,f); fprintf(f, "%u", el->tfCount); fputc(sep,f); { int i; if (sep == ',') fputc('{',f); for (i=0; itfCount; ++i) { if (sep == ',') fputc('"',f); fprintf(f, "%s", el->tfList[i]); if (sep == ',') fputc('"',f); fputc(',', f); } if (sep == ',') fputc('}',f); } fputc(sep,f); { int i; if (sep == ',') fputc('{',f); for (i=0; itfCount; ++i) { fprintf(f, "%g", el->bindVals[i]); fputc(',', f); } if (sep == ',') fputc('}',f); } fputc(lastSep,f); } /* -------------------------------- End autoSql Generated Code -------------------------------- */