text: /* gtexSample.c was originally generated by the autoSql program, which also 
   * generated gtexSample.h and gtexSample.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 "gtexSample.h"
  
  
  
  char *gtexSampleCommaSepFieldNames = "name,tissue,donor";
  
  void gtexSampleStaticLoad(char **row, struct gtexSample *ret)
  /* Load a row from gtexSample table into ret.  The contents of ret will
   * be replaced at the next call to this function. */
  {
  
  ret->name = row[0];
  ret->tissue = row[1];
  ret->donor = row[2];
  }
  
  struct gtexSample *gtexSampleLoad(char **row)
  /* Load a gtexSample from row fetched with select * from gtexSample
   * from database.  Dispose of this with gtexSampleFree(). */
  {
  struct gtexSample *ret;
  
  AllocVar(ret);
  ret->name = cloneString(row[0]);
  ret->tissue = cloneString(row[1]);
  ret->donor = cloneString(row[2]);
  return ret;
  }
  
  struct gtexSample *gtexSampleLoadAll(char *fileName) 
  /* Load all gtexSample from a whitespace-separated file.
   * Dispose of this with gtexSampleFreeList(). */
  {
  struct gtexSample *list = NULL, *el;
  struct lineFile *lf = lineFileOpen(fileName, TRUE);
  char *row[3];
  
  while (lineFileRow(lf, row))
      {
      el = gtexSampleLoad(row);
      slAddHead(&list, el);
      }
  lineFileClose(&lf);
  slReverse(&list);
  return list;
  }
  
  struct gtexSample *gtexSampleLoadAllByChar(char *fileName, char chopper) 
  /* Load all gtexSample from a chopper separated file.
   * Dispose of this with gtexSampleFreeList(). */
  {
  struct gtexSample *list = NULL, *el;
  struct lineFile *lf = lineFileOpen(fileName, TRUE);
  char *row[3];
  
  while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
      {
      el = gtexSampleLoad(row);
      slAddHead(&list, el);
      }
  lineFileClose(&lf);
  slReverse(&list);
  return list;
  }
  
  struct gtexSample *gtexSampleCommaIn(char **pS, struct gtexSample *ret)
  /* Create a gtexSample out of a comma separated string. 
   * This will fill in ret if non-null, otherwise will
   * return a new gtexSample */
  {
  char *s = *pS;
  
  if (ret == NULL)
      AllocVar(ret);
  ret->name = sqlStringComma(&s);
  ret->tissue = sqlStringComma(&s);
  ret->donor = sqlStringComma(&s);
  *pS = s;
  return ret;
  }
  
  void gtexSampleFree(struct gtexSample **pEl)
  /* Free a single dynamically allocated gtexSample such as created
   * with gtexSampleLoad(). */
  {
  struct gtexSample *el;
  
  if ((el = *pEl) == NULL) return;
  freeMem(el->name);
  freeMem(el->tissue);
  freeMem(el->donor);
  freez(pEl);
  }
  
  void gtexSampleFreeList(struct gtexSample **pList)
  /* Free a list of dynamically allocated gtexSample's */
  {
  struct gtexSample *el, *next;
  
  for (el = *pList; el != NULL; el = next)
      {
      next = el->next;
      gtexSampleFree(&el);
      }
  *pList = NULL;
  }
  
  void gtexSampleOutput(struct gtexSample *el, FILE *f, char sep, char lastSep) 
  /* Print out gtexSample.  Separate fields with sep. Follow last field with lastSep. */
  {
  if (sep == ',') fputc('"',f);
  fprintf(f, "%s", el->name);
  if (sep == ',') fputc('"',f);
  fputc(sep,f);
  if (sep == ',') fputc('"',f);
  fprintf(f, "%s", el->tissue);
  if (sep == ',') fputc('"',f);
  fputc(sep,f);
  if (sep == ',') fputc('"',f);
  fprintf(f, "%s", el->donor);
  if (sep == ',') fputc('"',f);
  fputc(lastSep,f);
  }
  
  /* -------------------------------- End autoSql Generated Code -------------------------------- */
  
  void gtexSampleCreateTable(struct sqlConnection *conn, char *table)
  /* Create expression record format table of given name. */
  {
  char query[1024];
  
  sqlSafef(query, sizeof(query),
  "CREATE TABLE %s (\n"
  "    name varchar(255) not null,       # GTEx sample identifier\n"
  "    tissue varchar(255) not null,     # Tissue name\n"
  "    donor varchar(255) not null,      # GTEx subject identifier\n"
  "              #Indices\n"
  "    PRIMARY KEY(name)\n"
  ")\n",   table);
  sqlRemakeTable(conn, table, query);
  }
  