src/hg/bedItemOverlapCount/bedItemOverlapCount.c 1.10
1.10 2009/04/06 18:40:21 larrym
support host, user and password args
Index: src/hg/bedItemOverlapCount/bedItemOverlapCount.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/bedItemOverlapCount/bedItemOverlapCount.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -b -B -U 4 -r1.9 -r1.10
--- src/hg/bedItemOverlapCount/bedItemOverlapCount.c 13 Mar 2009 05:22:46 -0000 1.9
+++ src/hg/bedItemOverlapCount/bedItemOverlapCount.c 6 Apr 2009 18:40:21 -0000 1.10
@@ -18,11 +18,17 @@
//static char *strand = (char *)NULL; /* strand to process, default + */
/* this is not implemented, the user can filter + and - */
static struct hash *chromHash = NULL;
+static char *host = NULL;
+static char *user = NULL;
+static char *password = NULL;
/* command line option specifications */
static struct optionSpec optionSpecs[] = {
+ {"host", OPTION_STRING},
+ {"user", OPTION_STRING},
+ {"password", OPTION_STRING},
{"strand", OPTION_STRING},
{NULL, 0}
};
@@ -38,9 +44,12 @@
" sort -k1,1 -k2,2n bedFile.bed \\\n"
" | bedItemOverlapCount [options] <database> stdin \\\n"
" | wigEncode stdin data.wig data.wib\n"
"options:\n"
- " (none at this time - you will want to separate your + and - strand\n"
+ " -host\tmysql host\n"
+ " -user\tmysql user\n"
+ " -password\tmysql password\n\n"
+ "\tYou will want to separate your + and - strand\n"
"\titems before sending into this program as it only looks at\n"
"\tthe chrom, start and end columns of the bed file.\n"
"\tIt wants a <database> connection to lookup chrom sizes for a sanity\n"
"\tcheck of the incoming data. This should be redone to take a chrom.sizes\n"
@@ -54,14 +63,23 @@
static struct hash *loadAllChromInfo(char *database, unsigned *largest)
/* Load up all chromosome infos, return largest one if asked to do so. */
{
struct chromInfo *el;
-struct sqlConnection *conn = sqlConnect(database);
+struct sqlConnection *conn = NULL;
struct sqlResult *sr = NULL;
struct hash *ret;
char **row;
unsigned max = 0;
+if(host)
+ {
+ conn = sqlConnectRemote(host, user, password, database);
+ }
+else
+ {
+ conn = hAllocConn(database);
+ }
+
ret = newHash(0);
sr = sqlGetResult(conn, "select * from chromInfo");
while ((row = sqlNextRow(sr)) != NULL)
@@ -216,8 +234,11 @@
optionInit(&argc, argv, optionSpecs);
if (argc < 2)
usage();
+host = optionVal("host", NULL);
+user = optionVal("user", NULL);
+password = optionVal("password", NULL);
verbose(2, "#\tworking on database: %s\n", argv[1]);
bedItemOverlapCount(argv[1], argc-2, argv+2);
return 0;
}