src/utils/raSqlQuery/raSqlQuery.c 1.17
1.17 2009/11/22 02:01:30 kent
Adding 'strict' option, to only put in ones where database table exists.
Index: src/utils/raSqlQuery/raSqlQuery.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/utils/raSqlQuery/raSqlQuery.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -b -B -U 4 -r1.16 -r1.17
--- src/utils/raSqlQuery/raSqlQuery.c 22 Nov 2009 01:37:41 -0000 1.16
+++ src/utils/raSqlQuery/raSqlQuery.c 22 Nov 2009 02:01:30 -0000 1.17
@@ -11,8 +11,9 @@
#include "sqlNum.h"
#include "raRecord.h"
#include "rql.h"
#include "portable.h"
+#include "../../hg/inc/hdb.h"
static char const rcsid[] = "$Id$";
static char *clQueryFile = NULL;
@@ -24,8 +25,9 @@
static boolean clParent = FALSE;
static boolean clAddFile = FALSE;
static boolean clAddDb = FALSE;
static char *clRestrict = NULL;
+static boolean clStrict = FALSE;
static char *clDb = NULL;
static boolean clOverrideNeeded = FALSE;
static char *clTrackDbRootDir = "~/kent/src/hg/makeDb/trackDb";
@@ -37,8 +39,11 @@
errAbort(
"raSqlQuery - Do a SQL-like query on a RA file.\n"
"usage:\n"
" raSqlQuery raFile(s) query-options\n"
+ "or\n"
+ " raSqlQuery -db=dbName query-options\n"
+ "Where dbName is a UCSC Genome database like hg18, sacCer1, etc.\n"
"One of the following query-options must be specified\n"
" -queryFile=fileName\n"
" \"-query=select list,of,fields where field='this'\"\n"
"The queryFile just has a query in it in the same form as the query option, but\n"
@@ -59,9 +64,10 @@
" -merge - If there are multiple raFiles, records with the same keyField will be\n"
" merged together with fields in later files overriding fields in earlier files\n"
" -addFile - Add 'file' field to say where record is defined\n"
" -addDb - Add 'db' field to say where record is defined\n"
- " -restrict=keyListFile - restrict output to only ones with keys in file, which\n"
+ " -restrict=keyListFile - restrict output to only ones with keys in file.\n"
+ " -strict - Used only with db option. Only report tracks that exist in db\n"
" -db=hg19 - Acts on trackDb files for the given database. Sets up list of files\n"
" appropriately and sets parent, merge, and override all.\n"
" Use db=all for all databases\n"
"The output will be to stdout, in the form of a .ra file if the select command is used\n"
@@ -81,8 +87,9 @@
{"noInheritField", OPTION_STRING},
{"addFile", OPTION_BOOLEAN},
{"addDb", OPTION_BOOLEAN},
{"restrict", OPTION_STRING},
+ {"strict", OPTION_BOOLEAN},
{"db", OPTION_STRING},
{"overrideNeeded", OPTION_BOOLEAN},
{NULL, 0},
};
@@ -430,15 +437,18 @@
for (ra = raList; ra != NULL; ra = ra->next)
{
if (rqlStatementMatch(rql, ra))
{
+ if (!clStrict || (ra->key && hTableOrSplitExists(db, ra->key)))
+ {
matchCount += 1;
if (doSelect)
{
rqlStatementOutput(rql, ra, (clAddFile ? "file" : NULL), clAddDb, out);
}
}
}
+ }
if (!doSelect)
printf("%d\n", matchCount);
}
@@ -455,8 +465,9 @@
clNoInheritField = optionVal("noInheritField", clNoInheritField);
clAddFile = optionExists("addFile");
clAddDb = optionExists("addDb");
clRestrict = optionVal("restrict", NULL);
+clStrict = optionExists("strict");
clOverrideNeeded = optionExists("overrideNeeded");
clDb = optionVal("db", NULL);
if (argc < 2 && !clDb)
usage();