a7ae401a6e1af3910b508aaa73a235b3cef426f9
kent
  Sun Apr 7 12:20:15 2013 -0700
Adding some more bed3 routines - for the minimalists.
diff --git src/lib/basicBed.c src/lib/basicBed.c
index 817795b..2cbb985 100644
--- src/lib/basicBed.c
+++ src/lib/basicBed.c
@@ -1645,15 +1645,68 @@
 			    , asCol->linkedSizeName, asCol->name);
 		    if (!(listSize >= 1))
 			lineFileAbort(lf, "invalid list size %d for list %s must be 1 or greater, empty lists are not allowed", listSize, asCol->name);
 		    if (!(listSize == count))
 			lineFileAbort(lf, "expecting %d elements in %s list, found %d", listSize, asCol->name, count);
 		    }
 		}
 	    }
 	asCol = asCol->next;
 	}
     hashFree(&linkHash);
     }
 
 }
 
+struct bed3 *bed3LoadAll(char *fileName)
+/* Load three columns from file as bed3. */
+{
+struct lineFile *lf = lineFileOpen(fileName, TRUE);
+char *row[3];
+struct bed3 *list = NULL, *el;
+while (lineFileRow(lf, row))
+    {
+    AllocVar(el);
+    el->chrom = cloneString(row[0]);
+    el->chromStart = sqlUnsigned(row[1]);
+    el->chromEnd = sqlUnsigned(row[2]);
+    slAddHead(&list, el);
+    }
+lineFileClose(&lf);
+slReverse(&list);
+return list;
+}
+
+void bed3Free(struct bed3 **pBed)
+/* Free up bed3 */
+{
+struct bed3 *bed = *pBed;
+if (bed != NULL)
+    {
+    freeMem(bed->chrom);
+    freez(pBed);
+    }
+}
+
+void bed3FreeList(struct bed3 **pList)
+/* Free a list of dynamically allocated bed3's */
+{
+struct bed3 *el, *next;
+
+for (el = *pList; el != NULL; el = next)
+    {
+    next = el->next;
+    bed3Free(&el);
+    }
+*pList = NULL;
+}
+
+long long bed3TotalSize(struct bed3 *bedList)
+/* Return sum of chromEnd-chromStart. */
+{
+long long sum = 0;
+struct bed3 *bed;
+for (bed = bedList; bed != NULL; bed = bed->next)
+    sum += bed->chromEnd - bed->chromStart;
+return sum;
+}
+