13e8fdadc6ab46c89eed7516344d3fda54b6c998
braney
  Fri Aug 13 14:56:38 2021 -0700
get the maf blocks in the right order so the draw engine doesn't get
confused.   Also a little speed-up

diff --git src/hg/lib/hgMaf.c src/hg/lib/hgMaf.c
index bd18fcc..60b0306 100644
--- src/hg/lib/hgMaf.c
+++ src/hg/lib/hgMaf.c
@@ -462,26 +462,27 @@
 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, ";","\n");
+    // the MAF block in the bigBed record has a semi-colon instead of newlines 
+    replaceChar(bb->rest, ';','\n');
 
     struct mafFile mf;
-    mf.lf = lineFileOnString(NULL, TRUE, mafText);
+    mf.lf = lineFileOnString(NULL, TRUE, bb->rest);
 
     struct mafAli *maf = mafNext(&mf);
     slAddHead(&mafList, maf);
     }
+slReverse(&mafList);
 return mafList;
 }