76ae0eba49560eee79493370778b4283f8033639
braney
  Mon Oct 12 13:56:59 2015 -0700
a tweak to allow bedToBigBed to work with tab separated files and extra
indices.  Bug found by Hiram.  No redmine

diff --git src/lib/bbiWrite.c src/lib/bbiWrite.c
index 2710c8d..ae7cf9c 100644
--- src/lib/bbiWrite.c
+++ src/lib/bbiWrite.c
@@ -158,47 +158,52 @@
 
 void bbExIndexMakerUpdateMaxFieldSize(struct bbExIndexMaker *eim, char **row)
 /* Fold in information about row into bbExIndexMaker into eim->maxFieldSize */
 {
 int i;
 for (i=0; i<eim->indexCount; ++i)
     {
     int rowIx = eim->indexFields[i];
     int size = strlen(row[rowIx]);
     if (size > eim->maxFieldSize[i])
         eim->maxFieldSize[i] = size;
     }
 }
 
 struct bbiChromUsage *bbiChromUsageFromBedFile(struct lineFile *lf, struct hash *chromSizesHash, 
-	struct bbExIndexMaker *eim, int *retMinDiff, double *retAveSize, bits64 *retBedCount)
+	struct bbExIndexMaker *eim, int *retMinDiff, double *retAveSize, bits64 *retBedCount, boolean tabSep)
 /* Go through bed file and collect chromosomes and statistics.  If eim parameter is non-NULL
  * collect max field sizes there too. */
 {
 int maxRowSize = (eim == NULL ? 3 : bbExIndexMakerMaxIndexField(eim) + 1);
 char *row[maxRowSize];
 struct bbiChromUsage *usage = NULL, *usageList = NULL;
 int lastStart = -1;
 bits32 id = 0;
 bits64 totalBases = 0, bedCount = 0;
 int minDiff = BIGNUM;
 
 lineFileRemoveInitialCustomTrackLines(lf);
 
 for (;;)
     {
-    int rowSize = lineFileChopNext(lf, row, maxRowSize);
+    int rowSize = 0;
+
+    if (tabSep)
+        rowSize = lineFileChopCharNext(lf, '\t', row, maxRowSize);
+    else
+        rowSize = lineFileChopNext(lf, row, maxRowSize);
     if (rowSize == 0)
         break;
     lineFileExpectAtLeast(lf, maxRowSize, rowSize);
     char *chrom = row[0];
     int start = lineFileNeedNum(lf, row, 1);
     int end = lineFileNeedNum(lf, row, 2);
     if (eim != NULL)
 	bbExIndexMakerUpdateMaxFieldSize(eim, row);
     if (start > end)
         {
 	    errAbort("end (%d) before start (%d) line %d of %s",
 	    	end, start, lf->lineIx, lf->fileName);
 	}
     ++bedCount;
     totalBases += (end - start);