3ba9819d796643362d5bdbc6996b21ee16dfd6eb
braney
  Tue Sep 24 15:08:16 2019 -0700
add a new function to bigBed to get any field's column

diff --git src/lib/bigBed.c src/lib/bigBed.c
index 7e660ee..e39afd8 100644
--- src/lib/bigBed.c
+++ src/lib/bigBed.c
@@ -520,30 +520,48 @@
 }
 
 struct asObject *bigBedFileAsObjOrDefault(char *fileName)
 // Get asObject associated with bigBed file, or the default.
 {
 struct bbiFile *bbi = bigBedFileOpen(fileName);
 if (bbi)
     {
     struct asObject *as = bigBedAsOrDefault(bbi);
     bbiFileClose(&bbi);
     return as;
     }
 return NULL;
 }
 
+int bbFieldIndex(struct bbiFile *bbi, char* fieldName)
+/* return the index of a given field */
+{
+if (fieldName==NULL)
+    return -1;
+struct asObject *as = bigBedAsOrDefault(bbi);
+if (as == NULL)
+    return -1;
+
+// search for field name, return index if found
+struct asColumn *col = as->columnList;
+int ix = 0;
+for (;col != NULL;col=col->next, ix+=1)
+    if (sameString(col->name, fieldName))
+        return ix; 
+return -1;
+}
+
 int bbExtraFieldIndex(struct bbiFile *bbi, char* fieldName)
 /* return the index of a given extra field */
 {
 if (fieldName==NULL)
     return 0;
 struct asObject *as = bigBedAsOrDefault(bbi);
 if (as == NULL)
     return 0;
 
 // search for field name, return index if found
 struct asColumn *col = as->columnList;
 int ix = 0;
 for (;col != NULL;col=col->next, ix+=1)
     if (sameString(col->name, fieldName))
         return max(ix-3, 0); // never return a negative value