/* genotype.h was originally generated by the autoSql program, which also 
 * generated genotype.c and genotype.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 GENOTYPE_H
#define GENOTYPE_H

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

#define GENOTYPE_NUM_COLS 105

struct genotype
/* Genotypes from HapMap data */
    {
    struct genotype *next;  /* Next in singly linked list. */
    char *rsId;	/*  rs#		# rs10 */
    char SNPalleles[4];	/*  SNPalleles	# A/C */
    char *chrom;	/*  chrom		# Chr7 */
    int chromStart;	/*  pos		# 91995917 */
    char strand;	/*  strand	# + */
    char *assembly;	/*  genome_build	# ncbi_b34 */
    char *center;	/*  center	# illumina */
    char *protLSID;	/*  protLSID	# urn:LSID:illumina.hapmap.org:Protocol:Golden_Gate_1.0.0:1 */
    char *assayLSID;	/*  assayLSID	# urn:LSID:illumina.hapmap.org:Assay:19660:1 */
    char *panelLSID;	/*  panelLSID	# urn:lsid:dcc.hapmap.org:Panel:CEPH-30-trios:1 */
    char NA06985[3];	/*  NA06985	# CC */
    char NA06991[3];	/*  NA06991	# CC */
    char NA06993[3];	/*  NA06993	# CC */
    char NA06993_dup[3];	/*  NA06993.dup	# CC */
    char NA06994[3];	/*  NA06994	# CC */
    char NA07000[3];	/*  NA07000	# CC */
    char NA07019[3];	/*  NA07019	# CC */
    char NA07022[3];	/*  NA07022	# CC */
    char NA07029[3];	/*  NA07029	# CC */
    char NA07034[3];	/*  NA07034	# CC */
    char NA07048[3];	/*  NA07048	# CC */
    char NA07055[3];	/*  NA07055	# CC */
    char NA07056[3];	/*  NA07056	# CC */
    char NA07345[3];	/*  NA07345	# CC */
    char NA07348[3];	/*  NA07348	# CC */
    char NA07357[3];	/*  NA07357	# CC */
    char NA10830[3];	/*  NA10830	# CC */
    char NA10831[3];	/*  NA10831	# CC */
    char NA10835[3];	/*  NA10835	# CC */
    char NA10838[3];	/*  NA10838	# CC */
    char NA10839[3];	/*  NA10839	# CC */
    char NA10846[3];	/*  NA10846	# CC */
    char NA10847[3];	/*  NA10847	# CC */
    char NA10851[3];	/*  NA10851	# CC */
    char NA10854[3];	/*  NA10854	# CC */
    char NA10855[3];	/*  NA10855	# CC */
    char NA10856[3];	/*  NA10856	# CC */
    char NA10857[3];	/*  NA10857	# CC */
    char NA10859[3];	/*  NA10859	# CC */
    char NA10860[3];	/*  NA10860	# CC */
    char NA10861[3];	/*  NA10861	# CC */
    char NA10863[3];	/*  NA10863	# CC */
    char NA11829[3];	/*  NA11829	# CC */
    char NA11830[3];	/*  NA11830	# CC */
    char NA11831[3];	/*  NA11831	# CC */
    char NA11832[3];	/*  NA11832	# CC */
    char NA11839[3];	/*  NA11839	# CC */
    char NA11840[3];	/*  NA11840	# CC */
    char NA11881[3];	/*  NA11881	# CC */
    char NA11882[3];	/*  NA11882	# CC */
    char NA11992[3];	/*  NA11992	# CC */
    char NA11993[3];	/*  NA11993	# CC */
    char NA11993_dup[3];	/*  NA11993.dup	# CC */
    char NA11994[3];	/*  NA11994	# AC */
    char NA11995[3];	/*  NA11995	# CC */
    char NA12003[3];	/*  NA12003	# CC */
    char NA12003_dup[3];	/*  NA12003.dup	# CC */
    char NA12004[3];	/*  NA12004	# CC */
    char NA12005[3];	/*  NA12005	# CC */
    char NA12006[3];	/*  NA12006	# CC */
    char NA12043[3];	/*  NA12043	# CC */
    char NA12044[3];	/*  NA12044	# CC */
    char NA12056[3];	/*  NA12056	# CC */
    char NA12057[3];	/*  NA12057	# CC */
    char NA12144[3];	/*  NA12144	# CC */
    char NA12145[3];	/*  NA12145	# CC */
    char NA12146[3];	/*  NA12146	# CC */
    char NA12154[3];	/*  NA12154	# CC */
    char NA12155[3];	/*  NA12155	# CC */
    char NA12156[3];	/*  NA12156	# CC */
    char NA12156_dup[3];	/*  NA12156.dup	# CC */
    char NA12234[3];	/*  NA12234	# CC */
    char NA12236[3];	/*  NA12236	# CC */
    char NA12239[3];	/*  NA12239	# CC */
    char NA12248[3];	/*  NA12248	# CC */
    char NA12248_dup[3];	/*  NA12248.dup	# CC */
    char NA12249[3];	/*  NA12249	# CC */
    char NA12264[3];	/*  NA12264	# CC */
    char NA12707[3];	/*  NA12707	# CC */
    char NA12716[3];	/*  NA12716	# CC */
    char NA12717[3];	/*  NA12717	# CC */
    char NA12740[3];	/*  NA12740	# CC */
    char NA12750[3];	/*  NA12750	# CC */
    char NA12751[3];	/*  NA12751	# CC */
    char NA12752[3];	/*  NA12752	# CC */
    char NA12753[3];	/*  NA12753	# CC */
    char NA12760[3];	/*  NA12760	# AC */
    char NA12761[3];	/*  NA12761	# CC */
    char NA12762[3];	/*  NA12762	# CC */
    char NA12763[3];	/*  NA12763	# CC */
    char NA12801[3];	/*  NA12801	# CC */
    char NA12802[3];	/*  NA12802	# CC */
    char NA12812[3];	/*  NA12812	# AC */
    char NA12813[3];	/*  NA12813	# CC */
    char NA12814[3];	/*  NA12814	# CC */
    char NA12815[3];	/*  NA12815	# CC */
    char NA12864[3];	/*  NA12864	# CC */
    char NA12865[3];	/*  NA12865	# CC */
    char NA12872[3];	/*  NA12872	# CC */
    char NA12873[3];	/*  NA12873	# AC */
    char NA12874[3];	/*  NA12874	# CC */
    char NA12875[3];	/*  NA12875	# CC */
    char NA12878[3];	/*  NA12878	# CC */
    char NA12891[3];	/*  NA12891	# CC */
    char NA12892[3];	/*  NA12892	# CC */
    };

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

struct genotype *genotypeLoad(char **row);
/* Load a genotype from row fetched with select * from genotype
 * from database.  Dispose of this with genotypeFree(). */

struct genotype *genotypeLoadAll(char *fileName);
/* Load all genotype from whitespace-separated file.
 * Dispose of this with genotypeFreeList(). */

struct genotype *genotypeLoadAllByChar(char *fileName, char chopper);
/* Load all genotype from chopper separated file.
 * Dispose of this with genotypeFreeList(). */

#define genotypeLoadAllByTab(a) genotypeLoadAllByChar(a, '\t');
/* Load all genotype from tab separated file.
 * Dispose of this with genotypeFreeList(). */

struct genotype *genotypeLoadByQuery(struct sqlConnection *conn, char *query);
/* Load all genotype 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 genotypeFreeList(). */

void genotypeSaveToDb(struct sqlConnection *conn, struct genotype *el, char *tableName, int updateSize);
/* Save genotype 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 genotype *genotypeCommaIn(char **pS, struct genotype *ret);
/* Create a genotype out of a comma separated string. 
 * This will fill in ret if non-null, otherwise will
 * return a new genotype */

void genotypeFree(struct genotype **pEl);
/* Free a single dynamically allocated genotype such as created
 * with genotypeLoad(). */

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

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

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

#define genotypeCommaOut(el,f) genotypeOutput(el,f,',',',');
/* Print out genotype as a comma separated list including final comma. */

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

#endif /* GENOTYPE_H */

