a67410efc5799d4df0cf424a5bd5b3c9dd5ab7f7
kate
  Thu Feb 4 20:10:09 2016 -0800
Load GTEx V6 gene table in hg19. refs #15645

diff --git src/hg/lib/gtexTranscript.c src/hg/lib/gtexTranscript.c
new file mode 100644
index 0000000..1bdcfe6
--- /dev/null
+++ src/hg/lib/gtexTranscript.c
@@ -0,0 +1,162 @@
+/* gtexTranscript.c was originally generated by the autoSql program, which also 
+ * generated gtexTranscript.h and gtexTranscript.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 "gtexTranscript.h"
+
+
+
+char *gtexTranscriptCommaSepFieldNames = "geneId,transcriptName";
+
+void gtexTranscriptStaticLoad(char **row, struct gtexTranscript *ret)
+/* Load a row from gtexTranscript table into ret.  The contents of ret will
+ * be replaced at the next call to this function. */
+{
+
+ret->geneId = row[0];
+ret->transcriptName = row[1];
+}
+
+struct gtexTranscript *gtexTranscriptLoadByQuery(struct sqlConnection *conn, char *query)
+/* Load all gtexTranscript 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 gtexTranscriptFreeList(). */
+{
+struct gtexTranscript *list = NULL, *el;
+struct sqlResult *sr;
+char **row;
+
+sr = sqlGetResult(conn, query);
+while ((row = sqlNextRow(sr)) != NULL)
+    {
+    el = gtexTranscriptLoad(row);
+    slAddHead(&list, el);
+    }
+slReverse(&list);
+sqlFreeResult(&sr);
+return list;
+}
+
+void gtexTranscriptSaveToDb(struct sqlConnection *conn, struct gtexTranscript *el, char *tableName, int updateSize)
+/* Save gtexTranscript 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. This function automatically escapes quoted strings for mysql. */
+{
+struct dyString *update = newDyString(updateSize);
+sqlDyStringPrintf(update, "insert into %s values ( '%s','%s')", 
+	tableName,  el->geneId,  el->transcriptName);
+sqlUpdate(conn, update->string);
+freeDyString(&update);
+}
+
+struct gtexTranscript *gtexTranscriptLoad(char **row)
+/* Load a gtexTranscript from row fetched with select * from gtexTranscript
+ * from database.  Dispose of this with gtexTranscriptFree(). */
+{
+struct gtexTranscript *ret;
+
+AllocVar(ret);
+ret->geneId = cloneString(row[0]);
+ret->transcriptName = cloneString(row[1]);
+return ret;
+}
+
+struct gtexTranscript *gtexTranscriptLoadAll(char *fileName) 
+/* Load all gtexTranscript from a whitespace-separated file.
+ * Dispose of this with gtexTranscriptFreeList(). */
+{
+struct gtexTranscript *list = NULL, *el;
+struct lineFile *lf = lineFileOpen(fileName, TRUE);
+char *row[2];
+
+while (lineFileRow(lf, row))
+    {
+    el = gtexTranscriptLoad(row);
+    slAddHead(&list, el);
+    }
+lineFileClose(&lf);
+slReverse(&list);
+return list;
+}
+
+struct gtexTranscript *gtexTranscriptLoadAllByChar(char *fileName, char chopper) 
+/* Load all gtexTranscript from a chopper separated file.
+ * Dispose of this with gtexTranscriptFreeList(). */
+{
+struct gtexTranscript *list = NULL, *el;
+struct lineFile *lf = lineFileOpen(fileName, TRUE);
+char *row[2];
+
+while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
+    {
+    el = gtexTranscriptLoad(row);
+    slAddHead(&list, el);
+    }
+lineFileClose(&lf);
+slReverse(&list);
+return list;
+}
+
+struct gtexTranscript *gtexTranscriptCommaIn(char **pS, struct gtexTranscript *ret)
+/* Create a gtexTranscript out of a comma separated string. 
+ * This will fill in ret if non-null, otherwise will
+ * return a new gtexTranscript */
+{
+char *s = *pS;
+
+if (ret == NULL)
+    AllocVar(ret);
+ret->geneId = sqlStringComma(&s);
+ret->transcriptName = sqlStringComma(&s);
+*pS = s;
+return ret;
+}
+
+void gtexTranscriptFree(struct gtexTranscript **pEl)
+/* Free a single dynamically allocated gtexTranscript such as created
+ * with gtexTranscriptLoad(). */
+{
+struct gtexTranscript *el;
+
+if ((el = *pEl) == NULL) return;
+freeMem(el->geneId);
+freeMem(el->transcriptName);
+freez(pEl);
+}
+
+void gtexTranscriptFreeList(struct gtexTranscript **pList)
+/* Free a list of dynamically allocated gtexTranscript's */
+{
+struct gtexTranscript *el, *next;
+
+for (el = *pList; el != NULL; el = next)
+    {
+    next = el->next;
+    gtexTranscriptFree(&el);
+    }
+*pList = NULL;
+}
+
+void gtexTranscriptOutput(struct gtexTranscript *el, FILE *f, char sep, char lastSep) 
+/* Print out gtexTranscript.  Separate fields with sep. Follow last field with lastSep. */
+{
+if (sep == ',') fputc('"',f);
+fprintf(f, "%s", el->geneId);
+if (sep == ',') fputc('"',f);
+fputc(sep,f);
+if (sep == ',') fputc('"',f);
+fprintf(f, "%s", el->transcriptName);
+if (sep == ',') fputc('"',f);
+fputc(lastSep,f);
+}
+
+/* -------------------------------- End autoSql Generated Code -------------------------------- */
+