src/hg/makeDb/hgLoadBed/hgLoadBed.c 1.67

1.67 2009/03/11 22:30:11 angie
Restoring option -allowStartEqualEnd which I shouldn't have removed in 1.52 (thanks Kate). SNPs and other tracks with valid 0-length items like insertion points will have to use -allowStartEqualEnd, but most tracks will get the appropriate level of checking b y default.
Index: src/hg/makeDb/hgLoadBed/hgLoadBed.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/makeDb/hgLoadBed/hgLoadBed.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -b -B -U 4 -r1.66 -r1.67
--- src/hg/makeDb/hgLoadBed/hgLoadBed.c	4 Dec 2008 17:21:13 -0000	1.66
+++ src/hg/makeDb/hgLoadBed/hgLoadBed.c	11 Mar 2009 22:30:11 -0000	1.67
@@ -23,8 +23,9 @@
 boolean noHistory = FALSE;	/* Do not add history table comments */
 boolean itemRgb = TRUE;		/* parse field nine as r,g,b when commas seen */
 boolean notItemRgb = FALSE;	/* do NOT parse field nine as r,g,b */
 boolean noStrict = FALSE;	/* skip the coord sanity checks */
+boolean allowStartEqualEnd = FALSE;  /* Even if strict-checking is on, allow zero-length items. */
 int minScore = 0;		/* minimum score for fillInScore option */
 int bedGraph = 0;		/* bedGraph column option, non-zero means yes */
 char *sqlTable = NULL;		/* Read table from this .sql if non-NULL. */
 boolean renameSqlTable = FALSE;	/* Rename table created with -sqlTable to */
@@ -38,9 +39,9 @@
 boolean allowNegativeScores = FALSE;	/* TRUE == score column set to int */
 char *fillInScoreColumn = NULL;      /* column to use to fill-in score column */
 boolean customTrackLoader = FALSE; /*TRUE == turn on all custom track options
                                     * turns on: noNameIx, ignoreEmpty, allowNegativeScores
-                                    * -verbose=0 */
+                                    * -verbose=0, allowStartEqualEnd */
 
 /* command line option specifications */
 static struct optionSpec optionSpecs[] = {
     {"noSort", OPTION_BOOLEAN},
@@ -59,8 +60,9 @@
     {"minScore", OPTION_INT},
     {"notItemRgb", OPTION_BOOLEAN},
     {"noStrict", OPTION_BOOLEAN},
     {"nostrict", OPTION_BOOLEAN},
+    {"allowStartEqualEnd", OPTION_BOOLEAN},
     {"maxChromNameLength", OPTION_INT},
     {"tmpDir", OPTION_STRING},
     {"noNameIx", OPTION_BOOLEAN},
     {"ignoreEmpty", OPTION_BOOLEAN},
@@ -99,12 +101,14 @@
   "                   - which will be removed after loading\n"
   "   -noNameIx  - no index for the name column (default creates index)\n"
   "   -ignoreEmpty  - no error on empty input file\n"
   "   -noStrict  - don't perform coord sanity checks\n"
-  "              - by default we abort when: chromStart > chromEnd\n"
+  "              - by default we abort when: chromStart >= chromEnd\n"
+  "   -allowStartEqualEnd  - even when doing strict checks, allow\n"
+  "                          chromStart==chromEnd (zero-length e.g. insertion)\n"
   "   -allowNegativeScores  - sql definition of score column is int, not unsigned\n"
   "   -customTrackLoader  - turns on: -noNameIx, -noHistory, -ignoreEmpty,\n"
-  "                         -allowNegativeScores -verbose=0\n"
+  "                         -allowStartEqualEnd, -allowNegativeScores, -verbose=0\n"
   "   -fillInScore=colName - if every score value is zero, then use column 'colName' to fill in the score column (from minScore-1000)\n"
   "   -minScore=N - minimum value for score field for -fillInScore option (default 100)\n"
   "   -verbose=N - verbose level for extra information to STDERR\n"
   );
@@ -193,8 +197,12 @@
 	{
 	if (bed->chromEnd < 1)
 	    errAbort("ERROR: line %d:'%s'\nchromEnd is less than 1\n",
 		     lf->lineIx, dupe);
+	if (bed->chromStart == bed->chromEnd && !allowStartEqualEnd)
+	    errAbort("ERROR: line %d:'%s'\nchromStart == chromEnd (%d) (zero-length item)\n"
+		     "Use -allowStartEqualEnd if that is legit (e.g. for insertion point).\n",
+		     lf->lineIx, dupe, bed->chromStart);
 	if (bed->chromStart > bed->chromEnd)
 	    errAbort("ERROR: line %d:'%s'\nchromStart after chromEnd (%d > %d)\n",
 		     lf->lineIx, dupe, bed->chromStart, bed->chromEnd);
 	}
@@ -583,20 +591,22 @@
 notItemRgb = optionExists("notItemRgb");
 if (notItemRgb) itemRgb = FALSE;
 maxChromNameLength = optionInt("maxChromNameLength",0);
 noStrict = optionExists("noStrict") || optionExists("nostrict");
+allowStartEqualEnd = optionExists("allowStartEqualEnd");
 tmpDir = optionVal("tmpDir", tmpDir);
 nameIx = ! optionExists("noNameIx");
 ignoreEmpty = optionExists("ignoreEmpty");
 allowNegativeScores = optionExists("allowNegativeScores");
 customTrackLoader = optionExists("customTrackLoader");
-/* turns on: noNameIx, ignoreEmpty, allowNegativeScores
+/* turns on: noNameIx, ignoreEmpty, allowStartEqualEnd, allowNegativeScores
  * -verbose=0 */
 if (customTrackLoader)
     {
     ignoreEmpty = TRUE;
     noHistory = TRUE;
     nameIx = FALSE;
+    allowStartEqualEnd = TRUE;
     allowNegativeScores = TRUE;
     verboseSetLevel(0);
     }
 fillInScoreColumn = optionVal("fillInScore", NULL);