src/hg/lib/refSeqStatus.c 1.4
1.4 2009/07/04 07:14:20 markd
added some .h files for genbank tables
Index: src/hg/lib/refSeqStatus.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/refSeqStatus.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -B -U 4 -r1.3 -r1.4
--- src/hg/lib/refSeqStatus.c 13 Apr 2005 06:25:56 -0000 1.3
+++ src/hg/lib/refSeqStatus.c 4 Jul 2009 07:14:20 -0000 1.4
@@ -9,15 +9,24 @@
#include "refSeqStatus.h"
static char const rcsid[] = "$Id$";
+/* definitions for status column */
+static char *values_status[] = {"Unknown", "Reviewed", "Validated", "Provisional", "Predicted", "Inferred", NULL};
+static struct hash *valhash_status = NULL;
+
+/* definitions for mol column */
+static char *values_mol[] = {"DNA", "RNA", "ds-RNA", "ds-mRNA", "ds-rRNA", "mRNA", "ms-DNA", "ms-RNA", "rRNA", "scRNA", "snRNA", "snoRNA", "ss-DNA", "ss-RNA", "ss-snoRNA", "tRNA", NULL};
+static struct hash *valhash_mol = NULL;
+
void refSeqStatusStaticLoad(char **row, struct refSeqStatus *ret)
/* Load a row from refSeqStatus table into ret. The contents of ret will
* be replaced at the next call to this function. */
{
ret->mrnaAcc = row[0];
-ret->status = row[1];
+ret->status = sqlEnumParse(row[1], values_status, &valhash_status);
+ret->mol = sqlEnumParse(row[2], values_mol, &valhash_mol);
}
struct refSeqStatus *refSeqStatusLoad(char **row)
/* Load a refSeqStatus from row fetched with select * from refSeqStatus
@@ -26,19 +35,20 @@
struct refSeqStatus *ret;
AllocVar(ret);
ret->mrnaAcc = cloneString(row[0]);
-ret->status = cloneString(row[1]);
+ret->status = sqlEnumParse(row[1], values_status, &valhash_status);
+ret->mol = sqlEnumParse(row[2], values_mol, &valhash_mol);
return ret;
}
struct refSeqStatus *refSeqStatusLoadAll(char *fileName)
-/* Load all refSeqStatus from a tab-separated file.
+/* Load all refSeqStatus from a whitespace-separated file.
* Dispose of this with refSeqStatusFreeList(). */
{
struct refSeqStatus *list = NULL, *el;
struct lineFile *lf = lineFileOpen(fileName, TRUE);
-char *row[2];
+char *row[3];
while (lineFileRow(lf, row))
{
el = refSeqStatusLoad(row);
@@ -48,30 +58,23 @@
slReverse(&list);
return list;
}
-struct refSeqStatus *refSeqStatusLoadWhere(struct sqlConnection *conn, char *table, char *where)
-/* Load all refSeqStatus from table that satisfy where clause. The
- * where clause may be NULL in which case whole table is loaded
+struct refSeqStatus *refSeqStatusLoadAllByChar(char *fileName, char chopper)
+/* Load all refSeqStatus from a chopper separated file.
* Dispose of this with refSeqStatusFreeList(). */
{
struct refSeqStatus *list = NULL, *el;
-struct dyString *query = dyStringNew(256);
-struct sqlResult *sr;
-char **row;
-
-dyStringPrintf(query, "select * from %s", table);
-if (where != NULL)
- dyStringPrintf(query, " where %s", where);
-sr = sqlGetResult(conn, query->string);
-while ((row = sqlNextRow(sr)) != NULL)
+struct lineFile *lf = lineFileOpen(fileName, TRUE);
+char *row[3];
+
+while (lineFileNextCharRow(lf, chopper, row, ArraySize(row)))
{
el = refSeqStatusLoad(row);
slAddHead(&list, el);
}
+lineFileClose(&lf);
slReverse(&list);
-sqlFreeResult(&sr);
-dyStringFree(&query);
return list;
}
struct refSeqStatus *refSeqStatusCommaIn(char **pS, struct refSeqStatus *ret)
@@ -83,9 +86,10 @@
if (ret == NULL)
AllocVar(ret);
ret->mrnaAcc = sqlStringComma(&s);
-ret->status = sqlStringComma(&s);
+ret->status = sqlEnumComma(&s, values_status, &valhash_status);
+ret->mol = sqlEnumComma(&s, values_mol, &valhash_mol);
*pS = s;
return ret;
}
@@ -96,9 +100,8 @@
struct refSeqStatus *el;
if ((el = *pEl) == NULL) return;
freeMem(el->mrnaAcc);
-freeMem(el->status);
freez(pEl);
}
void refSeqStatusFreeList(struct refSeqStatus **pList)
@@ -121,9 +124,15 @@
fprintf(f, "%s", el->mrnaAcc);
if (sep == ',') fputc('"',f);
fputc(sep,f);
if (sep == ',') fputc('"',f);
-fprintf(f, "%s", el->status);
+sqlEnumPrint(f, el->status, values_status);
+if (sep == ',') fputc('"',f);
+fputc(sep,f);
+if (sep == ',') fputc('"',f);
+sqlEnumPrint(f, el->mol, values_mol);
if (sep == ',') fputc('"',f);
fputc(lastSep,f);
}
+/* -------------------------------- End autoSql Generated Code -------------------------------- */
+