Index: src/hg/bedItemOverlapCount/bedItemOverlapCount.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/bedItemOverlapCount/bedItemOverlapCount.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -b -B -U 4 -r1.16 -r1.17
--- src/hg/bedItemOverlapCount/bedItemOverlapCount.c	25 Sep 2009 23:17:20 -0000	1.16
+++ src/hg/bedItemOverlapCount/bedItemOverlapCount.c	28 Sep 2009 18:52:20 -0000	1.17
@@ -30,8 +30,11 @@
 char *chromSizes = NULL;  /* read chrom sizes from file instead of database . */
 boolean doMax;   /* if overlap count will overflow, just keep max */
 boolean doZero;  /* add blocks with 0 counts */
 boolean doBed12;  /* expect bed12 and process block by block */
+boolean doOutBounds;  /* output min/max to stderr */
+unitSize overMin = ~1;
+unitSize overMax = 0;
 
 /* command line option specifications */
 static struct optionSpec optionSpecs[] = {
     {"chromSize", OPTION_STRING},
@@ -40,8 +43,9 @@
     {"password", OPTION_STRING},
     {"max", OPTION_BOOLEAN},
     {"zero", OPTION_BOOLEAN},
     {"bed12", OPTION_BOOLEAN},
+    {"outBounds", OPTION_BOOLEAN},
     {NULL, 0}
 };
 
 void usage()
@@ -59,8 +63,9 @@
   "   -zero  add blocks with zero count, normally these are ommitted\n"
   "   -bed12 expect bed12 and count based on blocks\n"
   "          normally only first three fields are used.\n"
   "   -max   if counts per base overflows set to max (%lu) instead of exiting\n"
+  "   -outBounds ouput min/max to stderr\n"
   "   -chromSize=sizefile\tRead chrom sizes from file instead of database\n"
   "             sizefile contains two white space separated fields per line:\n"
   "		chrom name and size\n"
   "   -host=hostname\tmysql host used to get chrom sizes\n"
@@ -129,8 +134,15 @@
 unitSize *ptr;
 
 for(ptr=counts; ptr < lastCount - 1; ptr++)
     {
+    if (doOutBounds)
+	{
+	if (ptr[1] < overMin)
+	    overMin = ptr[1];
+	if (ptr[1] > overMax)
+	    overMax = ptr[1];
+	}
     if (ptr[0] != ptr[1])
 	{
 	if (doZero || (ptr[0] != 0))
 	    printf("%s\t%lu\t%lu\t%lu\n", 
@@ -266,12 +279,15 @@
 
 if (outputToDo)
     outputCounts(counts, prevChrom, chromSize);
 
+if (doOutBounds)
+    fprintf(stderr, "min %lu max %lu\n", (unsigned long)overMin, (unsigned long)overMax);
+
 verbose(2,"#\tchrom %s done, size %d\n", prevChrom, chromSize);
 freeMem(counts);
 freez(&prevChrom);
-hashFreeWithVals(&chromHash, freez);
+// hashFreeWithVals(&chromHash, freez);
 freeHash(&seenHash);
 }
 
 int main(int argc, char *argv[])
@@ -287,8 +303,9 @@
 chromSizes = optionVal("chromSize", NULL);
 doMax = optionExists("max");
 doBed12 = optionExists("bed12");
 doZero = optionExists("zero");
+doOutBounds = optionExists("outBounds");
 verbose(2, "#\tworking on database: %s\n", argv[1]);
 bedItemOverlapCount(argv[1], argc-2, argv+2);
 optionFree();
 return 0;

