src/hg/makeDb/hgLoadSeq/hgLoadSeq.c 1.16
1.16 2009/10/16 00:07:04 markd
don't generate warnings on invalid dates; error not if warns occur, also added -drop option
Index: src/hg/makeDb/hgLoadSeq/hgLoadSeq.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/makeDb/hgLoadSeq/hgLoadSeq.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -b -B -U 4 -r1.15 -r1.16
--- src/hg/makeDb/hgLoadSeq/hgLoadSeq.c 1 Oct 2009 07:50:03 -0000 1.15
+++ src/hg/makeDb/hgLoadSeq/hgLoadSeq.c 16 Oct 2009 00:07:04 -0000 1.16
@@ -14,8 +14,9 @@
static struct optionSpec optionSpecs[] = {
{"abbr", OPTION_STRING},
{"prefix", OPTION_STRING},
{"replace", OPTION_BOOLEAN},
+ {"drop", OPTION_BOOLEAN},
{"test", OPTION_BOOLEAN},
{"seqTbl", OPTION_STRING},
{"extFileTbl", OPTION_STRING},
{NULL, 0}
@@ -27,8 +28,9 @@
char *abbr = NULL;
char *prefix = NULL;
boolean test = FALSE;
boolean replace = FALSE;
+boolean drop = FALSE;
char seqTableCreate[] =
/* This keeps track of a sequence. */
"create table %s ("
@@ -114,9 +116,9 @@
/* add to tab file */
seqId = hgNextId();
/* note: sqlDate column is empty */
-fprintf(seqTab, "%u\t%s\t%d\t\t%u\t%lld\t%d\n",
+fprintf(seqTab, "%u\t%s\t%d\t0000-00-00\t%u\t%lld\t%d\n",
seqId, sqlEscapeTabFileString2(faAccBuf, faAcc),
dnaSize, extFileId, (unsigned long long)faOffset, faSize);
return TRUE;
}
@@ -154,8 +156,15 @@
if (!test)
{
conn = hgStartUpdate(database);
char query[1024];
+ if (drop)
+ {
+ safef(query, sizeof(query), "drop table if exists %s", seqTbl);
+ sqlUpdate(conn, query);
+ safef(query, sizeof(query), "drop table if exists %s", extFileTbl);
+ sqlUpdate(conn, query);
+ }
safef(query, sizeof(query), seqTableCreate, seqTbl);
sqlMaybeMakeTable(conn, seqTbl, query);
}
@@ -166,9 +175,9 @@
loadFa(fileNames[i], conn, seqTab);
}
if (!test)
{
- unsigned opts = SQL_TAB_FILE_WARN_ON_ERROR;
+ unsigned opts = 0;
if (replace)
opts |= SQL_TAB_REPLACE;
verbose(1, "Updating %s table\n", seqTbl);
hgLoadTabFileOpts(conn, ".", seqTbl, opts, &seqTab);
@@ -193,8 +202,10 @@
" -replace - replace existing sequences with the same id\n"
" -seqTbl=tbl - use this table instead of seq\n"
" -extFileTbl=tbl - use this table instead of extFile\n"
" -test - do not load database table\n"
+ " -drop - drop tables before loading, can only use if -seqTbl and -extFileTbl\n"
+ " are specified. \n"
);
}
int main(int argc, char *argv[])
@@ -211,7 +222,10 @@
abbr = optionVal("abbr", NULL);
prefix = optionVal("prefix", NULL);
replace = optionExists("replace");
test = optionExists("test");
+drop = optionExists("drop");
+if (drop && !optionExists("seqTbl"))
+ errAbort("can only specify -drop with -seqTbl and -extFileTbl");
hgLoadSeq(argv[1], argc-2, argv+2);
return 0;
}