c1e66c5c9d45f0965156318e2782714ee93b04ab
braney
  Mon Oct 19 16:08:32 2015 -0700
more work on bigMaf.  Works in hgc and hgTables now.  #15935

diff --git src/hg/lib/hgMaf.c src/hg/lib/hgMaf.c
index 1ee9666..69ce12b 100644
--- src/hg/lib/hgMaf.c
+++ src/hg/lib/hgMaf.c
@@ -432,15 +432,35 @@
 return (cloneString(option));
 }
 
 struct consWiggle *consWiggleFind(char *db,struct trackDb *parent,char *table)
 /* Return conservation wig if it is found in the parent. */
 {
 if (parent == NULL || !startsWith("wigMaf", parent->type))
     return NULL;
 
 struct consWiggle *wig, *wiggles = wigMafWiggles(db, parent);
 for (wig = wiggles;
      wig != NULL && differentString(wig->table,table);
      wig = wig->next) {}
 return wig;
 }
+
+struct mafAli *bigMafLoadInRegion( struct bbiFile *bbi,  char *chrom, int start, int end)
+/* Read in MAF blocks from bigBed. */
+{
+struct lm *lm = lmInit(0);
+struct bigBedInterval *bb, *bbList =  bigBedIntervalQuery(bbi, chrom, start, end, 0, lm);
+struct mafAli *mafList = NULL;
+for (bb = bbList; bb != NULL; bb = bb->next)
+    {
+    // the MAF block in the record as \001 instead of newlines 
+    char *mafText = replaceChars(bb->rest, "\001","\n");
+
+    struct mafFile mf;
+    mf.lf = lineFileOnString(NULL, TRUE, mafText);
+
+    struct mafAli *maf = mafNext(&mf);
+    slAddHead(&mafList, maf);
+    }
+return mafList;
+}