2fd02c5e1ce1bb989549b2e0069270ca8907efad
braney
  Thu Apr 10 15:03:42 2025 -0700
add bigLolly to quickLift support

diff --git src/hg/hgc/clinvarSubLolly.c src/hg/hgc/clinvarSubLolly.c
index 55e311abd06..a20af50ee39 100644
--- src/hg/hgc/clinvarSubLolly.c
+++ src/hg/hgc/clinvarSubLolly.c
@@ -1,27 +1,28 @@
 #include "common.h"
 #include "wiggle.h"
 #include "cart.h"
 #include "hgc.h"
 #include "hCommon.h"
 #include "hgColors.h"
 #include "bigBed.h"
 #include "hui.h"
 #include "subText.h"   
 #include "trackHub.h"   
 #include "clinvarSubLolly.h"   
 #include "chromAlias.h"
+#include "quickLift.h"
 
 char *statusByScore[] =
 {
 "Other",
 "Benign",
 "Likely Benign",
 "Uncertain significance",
 "Likely pathogenic",
 "Pathogenic",
 };
 
 void printSubmissions(struct trackDb *tdb, char *chrom, int start, int end, unsigned wantScore, int numSubs, boolean not)
 /* Print out all the submissions at this position that match the 
  * desired score (ie. clinical status).
  * If "not" is true, then print out all submissions that do NOT match score.
@@ -71,47 +72,66 @@
 void doClinvarSubLolly(struct trackDb *tdb, char *item)
 /* Put up page for clinvarSubLolly track. */
 {
 genericHeader(tdb, NULL);
 struct sqlConnection *conn = NULL;
 
 if (!trackHubDatabase(database))
     conn = hAllocConnTrack(database, tdb);
 
 int start = cartInt(cart, "o");
 int end = cartInt(cart, "t");
 char *chrom = cartString(cart, "c");
 char *fileName = bbiNameFromSettingOrTable(tdb, conn, tdb->table);
 struct bbiFile *bbi =  bigBedFileOpenAlias(hReplaceGbdb(fileName), chromAliasFindAliases);
 struct lm *lm = lmInit(0);
-struct bigBedInterval *bbList = bigBedIntervalQuery(bbi, chrom, start, end, 0, lm);
+struct bigBedInterval *bb, *bbList; 
+char *quickLiftFile = cloneString(trackDbSetting(tdb, "quickLiftUrl"));
+struct hash *chainHash = NULL;
+if (quickLiftFile)
+    bbList = quickLiftGetIntervals(quickLiftFile, bbi, chrom, start, end, &chainHash);
+else
+    bbList = bigBedIntervalQuery(bbi, chrom, start, end, 0, lm);
 
-struct bigBedInterval *bb;
 char *fields[bbi->fieldCount];
 for (bb = bbList; bb != NULL; bb = bb->next)
     {
-    if (!(bb->start == start && bb->end == end))
+    struct bed *bed = NULL;;
+    char startBuf[16], endBuf[16];
+    struct bed tempBed;
+    bigBedIntervalToRow(bb, chrom, startBuf, endBuf, fields, bbi->fieldCount);
+    if (quickLiftFile)
+        bed = quickLiftIntervalsToBed(bbi, chainHash, bb);
+    else
+        {
+        tempBed.chrom = chrom;
+        tempBed.chromStart = bb->start;
+        tempBed.chromEnd = bb->end;
+        tempBed.name = fields[3];
+        bed = &tempBed;
+        }
+
+    if (!(bed->chromStart == start && bed->chromEnd == end))
 	continue;
 
     // our names are unique
-    char *name = cloneFirstWordByDelimiterNoSkip(bb->rest, '\t');
+    char *name = bed->name;
     boolean match = (isEmpty(name) && isEmpty(item)) || sameOk(name, item);
     if (!match)
         continue;
 
-    char startBuf[16], endBuf[16];
-    bigBedIntervalToRow(bb, chrom, startBuf, endBuf, fields, bbi->fieldCount);
     int numSubs = chopString(fields[12], ",", NULL, 0);
 
-    printPos(chrom, bb->start, bb->end, NULL, FALSE, name);
+    printPos(bed->chrom, bed->chromStart, bed->chromEnd, NULL, FALSE, name);
+    
     // print all the submissions that match the clinical significance of the
     // bead that the user clicked on.
-    printSubmissions(tdb,  chrom, start, end, atoi(fields[4]), numSubs, FALSE);
+    printSubmissions(tdb,  chrom, bb->start, bb->end, atoi(fields[4]), numSubs, FALSE);
 
-    // no print the ones with a different clinical status
-    printSubmissions(tdb,  chrom, start, end, atoi(fields[4]), numSubs, TRUE);
+    // now print the ones with a different clinical status
+    printSubmissions(tdb,  chrom, bb->start, bb->end, atoi(fields[4]), numSubs, TRUE);
 
     // we found what we wanted
     break;
     }
 printTrackHtml(tdb);
 }