033a7cd10442ee88f63ca9d0778c33530e058021
kent
  Tue Apr 5 15:27:41 2011 -0700
Moving routine to find next on list with a different chromosome to library since it keeps coming up.
diff --git src/lib/basicBed.c src/lib/basicBed.c
index 9b0e16e..6b45cdf 100644
--- src/lib/basicBed.c
+++ src/lib/basicBed.c
@@ -846,30 +846,41 @@
 struct bed *cloneBedList(struct bed *bedList)
 /* Make an all-newly-allocated list copied from bed. */
 {
 struct bed *bedListOut = NULL, *bed=NULL;
 
 for (bed=bedList;  bed != NULL;  bed=bed->next)
     {
     struct bed *newBed = cloneBed(bed);
     slAddHead(&bedListOut, newBed);
     }
 
 slReverse(&bedListOut);
 return bedListOut;
 }
 
+struct bed *bedListNextDifferentChrom(struct bed *bedList)
+/* Return next bed in list that is from a different chrom than the start of the list. */
+{
+char *firstChrom = bedList->chrom;
+struct bed *bed;
+for (bed = bedList->next; bed != NULL; bed = bed->next)
+    if (!sameString(firstChrom, bed->chrom))
+        break;
+return bed;
+}
+
 struct bed *bedCommaInN(char **pS, struct bed *ret, int fieldCount)
 /* Create a bed out of a comma separated string looking for fieldCount
  * fields. This will fill in ret if non-null, otherwise will return a
  * new bed */
 {
 char *s = *pS;
 int i;
 
 if (ret == NULL)
     AllocVar(ret);
 ret->chrom = sqlStringComma(&s);
 ret->chromStart = sqlUnsignedComma(&s);
 ret->chromEnd = sqlUnsignedComma(&s);
 if (fieldCount > 3)
     ret->name = sqlStringComma(&s);