src/hg/utils/gapToLift/gapToLift.c 1.9

1.9 2010/03/26 16:42:01 hiram
add minGap argument
Index: src/hg/utils/gapToLift/gapToLift.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/utils/gapToLift/gapToLift.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -b -B -U 4 -r1.8 -r1.9
--- src/hg/utils/gapToLift/gapToLift.c	10 Aug 2009 20:58:59 -0000	1.8
+++ src/hg/utils/gapToLift/gapToLift.c	26 Mar 2010 16:42:01 -0000	1.9
@@ -18,8 +18,9 @@
   "       uses gap table(s) from specified db.  Writes to liftFile.lft\n"
   "       generates lift file segements separated by non-bridged gaps.\n"
   "options:\n"
   "   -chr=chrN - work only on given chrom\n"
+  "   -minGap=M - examine gaps only >= than M\n"
   "   -insane - do *not* perform coordinate sanity checks on gaps\n"
   "   -bedFile=fileName.bed - output segments to fileName.bed\n"
   "   -verbose=N - N > 1 see more information about procedure"
   );
@@ -29,14 +30,15 @@
 static char *workChr = NULL;	/* work only on this given chrom name */
 static boolean insane = FALSE;	/* TRUE do not perform sanity checks on gaps */
 static FILE *bedFile = NULL; /* when requested, output segments to bed file */
 static char *bedFileName = NULL; /* output to bedFileName name */
-
+static int minGap = 0;	/* gap size must be >= than this */
 
 static struct optionSpec options[] = {
    {"chr", OPTION_STRING},
    {"insane", OPTION_BOOLEAN},
    {"bedFile", OPTION_STRING},
+   {"minGap", OPTION_INT},
    {NULL, 0},
 };
 
 static struct hash *cInfoHash = NULL;
@@ -146,17 +148,28 @@
 	cInfo->size, NULL, &rowOffset);
     while ((row = sqlNextRow(sr)) != NULL)
 	{
 	struct agpGap *gap = agpGapLoad(row+rowOffset);
+	if (minGap)
+	    {
+	    if (gap->size >= minGap)
+		{
+		slAddHead(&gapList, gap);
+		++gapCount;
+		}
+	    }
+	else
+	    {
 	slAddHead(&gapList, gap);
 	++gapCount;
 	}
+	}
     sqlFreeResult(&sr);
     }
 slSort(&gapList, bedCmp);
 if (! insane)
     gapSanityCheck(gapList);
-verbose(2,"#\tfound %d gaps\n", gapCount);
+verbose(2,"#\tfound %d gaps of size >= %d\n", gapCount, minGap);
 return (gapList);
 }
 
 static int liftOutLine(FILE *out, char *chr, int start, int end,
@@ -271,7 +284,8 @@
     usage();
 workChr = optionVal("chr", NULL);
 bedFileName = optionVal("bedFile", NULL);
 insane = optionExists("insane");
+minGap = optionInt("minGap", minGap);
 gapToLift(argv[1], argv[2]);
 return 0;
 }