/* tfbsCons.h was originally generated by the autoSql program, which also 
 * generated tfbsCons.c and tfbsCons.sql.  This header links the database and
 * the RAM representation of objects. */

/* Copyright (C) 2013 The Regents of the University of California 
 * See README in this or parent directory for licensing information. */

#ifndef TFBSCONS_H
#define TFBSCONS_H

#ifndef JKSQL_H
#include "jksql.h"
#endif

#define TFBSCONS_NUM_COLS 9

struct tfbsCons
/* tfbsCons Data */
    {
    struct tfbsCons *next;  /* Next in singly linked list. */
    char *chrom;	/* Human chromosome */
    unsigned chromStart;	/* Start position in chromosome */
    unsigned chromEnd;	/* End position in chromosome */
    char *name;	/* Name of item */
    unsigned score;	/* Score from 0-1000 */
    char strand[2];	/* + or - */
    char species[7];	/* common name, scientific name */
    char factor[65];	/* factor  */
    char id[11];	/* id */
    };

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

struct tfbsCons *tfbsConsLoad(char **row);
/* Load a tfbsCons from row fetched with select * from tfbsCons
 * from database.  Dispose of this with tfbsConsFree(). */

struct tfbsCons *tfbsConsLoadAll(char *fileName);
/* Load all tfbsCons from whitespace-separated file.
 * Dispose of this with tfbsConsFreeList(). */

struct tfbsCons *tfbsConsLoadAllByChar(char *fileName, char chopper);
/* Load all tfbsCons from chopper separated file.
 * Dispose of this with tfbsConsFreeList(). */

#define tfbsConsLoadAllByTab(a) tfbsConsLoadAllByChar(a, '\t');
/* Load all tfbsCons from tab separated file.
 * Dispose of this with tfbsConsFreeList(). */

struct tfbsCons *tfbsConsLoadByQuery(struct sqlConnection *conn, char *query);
/* Load all tfbsCons from table that satisfy the query given.  
 * Where query is of the form 'select * from example where something=something'
 * or 'select example.* from example, anotherTable where example.something = 
 * anotherTable.something'.
 * Dispose of this with tfbsConsFreeList(). */

void tfbsConsSaveToDb(struct sqlConnection *conn, struct tfbsCons *el, char *tableName, int updateSize);
/* Save tfbsCons as a row to the table specified by tableName. 
 * As blob fields may be arbitrary size updateSize specifies the approx size
 * of a string that would contain the entire query. Arrays of native types are
 * converted to comma separated strings and loaded as such, User defined types are
 * inserted as NULL. Strings are automatically escaped to allow insertion into the database. */

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

void tfbsConsFree(struct tfbsCons **pEl);
/* Free a single dynamically allocated tfbsCons such as created
 * with tfbsConsLoad(). */

void tfbsConsFreeList(struct tfbsCons **pList);
/* Free a list of dynamically allocated tfbsCons's */

void tfbsConsOutput(struct tfbsCons *el, FILE *f, char sep, char lastSep);
/* Print out tfbsCons.  Separate fields with sep. Follow last field with lastSep. */

#define tfbsConsTabOut(el,f) tfbsConsOutput(el,f,'\t','\n');
/* Print out tfbsCons as a line in a tab-separated file. */

#define tfbsConsCommaOut(el,f) tfbsConsOutput(el,f,',',',');
/* Print out tfbsCons as a comma separated list including final comma. */

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

#endif /* TFBSCONS_H */

