3001eec709205e44c2ed2f1c6f42df510b8a5c37
chmalee
  Thu Oct 29 14:47:14 2020 -0700
Fix off by one in gnomAD VCF to bed conversion, which resulted in a url link out error, so adding new substitution to trackDb url, refs #25010

diff --git src/hg/lib/hui.c src/hg/lib/hui.c
index 3dc1c91..3677391 100644
--- src/hg/lib/hui.c
+++ src/hg/lib/hui.c
@@ -9469,32 +9469,32 @@
     dyStringFree(&s);
     s = d;
     d = NULL;
     }
 return s;
 }
 
 char *replaceInUrl(char *url, char *idInUrl, struct cart *cart, char *db, char *seqName, 
                         int winStart, int winEnd, char *track, boolean encode, struct slPair *fields) 
 /* replace $$ in url with idInUrl. Supports many other wildchards, and custom fields $<field>
  * XX Do we have readable docs for these parameters somewhere?
  * Look at http://genome.ucsc.edu/goldenpath/help/trackDb/trackDbHub.html */
 {
 struct dyString *uUrl = NULL;
 struct dyString *eUrl = NULL;
-char startString[64], endString[64];
-char *ins[13], *outs[13];
+char startString[64], endString[64],oneBasedStart[64];
+char *ins[14], *outs[14];
 char *eItem = (encode ? cgiEncode(idInUrl) : cloneString(idInUrl));
 
 char *scName = NULL;
 // try to avoid the mysql query it not necessary
 if (stringIn("$n", url))
     {
     char *tmp = hScientificName(db);
     scName = replaceChars(tmp, " ", "_");
     freeMem(tmp);
     }
 
 char *taxId = NULL;
 // try to avoid the mysql query it not necessary
 if (stringIn("$taxId", url))
     {
@@ -9533,41 +9533,46 @@
     if (nextColon)	/* terminate suffixClone suffix */
         *nextColon = '\0';	/* when next colon is present */
     *suffix = '\0';   /* terminate itemClone prefix */
     outs[7] = itemClone;
     outs[8] = suffixClone;
     /* small memory leak here for these cloned strings */
     /* not important for a one-time operation in a CGI that will exit */
 } else {
     outs[7] = idInUrl;	/* otherwise, these are not expected */
     outs[8] = idInUrl;	/* to be used */
 }
 
 // URL may now contain item boundaries
 ins[9] = "${";
 ins[10] = "$}";
+ins[13] = "$#";
 if (cart!=NULL && cartOptionalString(cart, "o") && cartOptionalString(cart, "t"))
     {
     char *itemBeg = cartString(cart, "o"); // unexpected commas?
     char *itemEnd = cartString(cart, "t");
     outs[9] = itemBeg;
     outs[10] = itemEnd;
+    safef(oneBasedStart, sizeof(oneBasedStart), "%d", cartInt(cart, "o") + 1);
+    outs[13] = oneBasedStart;
     }
 else // should never be but I am unwilling to bet the farm
     {
     outs[9] = startString;
     outs[10] = endString;
+    safef(oneBasedStart, sizeof(oneBasedStart), "%d", winStart + 1);
+    outs[13] = oneBasedStart;
     }
 
 ins[11] = "$n";
 outs[11] = scName;
 
 ins[12] = "$taxId";
 outs[12] = taxId;
 
 uUrl = subMulti(url, ArraySize(ins), ins, outs);
 outs[0] = eItem;
 eUrl = subMulti(url, ArraySize(ins), ins, outs);
 freeDyString(&uUrl);
 freeMem(eItem);
 freeMem(scName);