d3752edc12da1bf08427946150f564dbdd5d2254
angie
  Thu Oct 24 13:55:51 2019 -0700
bigDbSnp track handler code - initial commit.  refs #23283
* dnautil: Added trimRefAltLeft to get left-justified trimming (a la VCF not HGVS).
* bigBedClick: do hReplaceGbdb up front in parseDetailsTablUrls instead of waiting until endpoint.
* trackDbCustom.c: consolidating type-handling for wig/bigWig vs. bigBed-based big*.

diff --git src/hg/hgTrackUi/hgTrackUi.c src/hg/hgTrackUi/hgTrackUi.c
index 95bc36a..3103fa2 100644
--- src/hg/hgTrackUi/hgTrackUi.c
+++ src/hg/hgTrackUi/hgTrackUi.c
@@ -934,46 +934,36 @@
 
 void oregannoUi (struct trackDb *tdb)
 /* print the controls */
 {
 int i = 0; /* variable to walk through array */
 
 printf("<BR><B>Type of region to display: </B> ");
 printf("&nbsp;(Click <A HREF=\"http://www.oreganno.org/oregano/help/records.html\" target=\"_blank\">here</A> for detailed information on these element types)<BR>");
 for (i = 0; i < oregannoTypeSize; i++)
     {
     cartMakeCheckBox(cart, oregannoTypeString[i], TRUE);
     printf (" %s<BR>", oregannoTypeLabel[i]);
     }
 }
 
-void labelMakeCheckBox(struct trackDb *tdb, char *sym, char *desc, boolean dflt)
-/* add a checkbox use to choose labels to enable. */
-{
-char varName[64];
-safef(varName, sizeof(varName), "%s.label.%s", tdb->track, sym);
-boolean option = cartUsualBoolean(cart, varName, dflt);
-cgiMakeCheckBox(varName, option);
-printf(" %s&nbsp;&nbsp;&nbsp;", desc);
-}
-
 void gvIdControls (struct trackDb *tdb)
 /* print the controls for the label choice */
 {
 printf("<B>Label:</B> ");
-labelMakeCheckBox(tdb, "hgvs", "HGVS name", FALSE);
-labelMakeCheckBox(tdb, "common", "Common name", FALSE);
+labelMakeCheckBox(cart, tdb, "hgvs", "HGVS name", FALSE);
+labelMakeCheckBox(cart, tdb, "common", "Common name", FALSE);
 printf("<BR>\n");
 }
 
 void gvUi(struct trackDb *tdb)
 /* print UI for human mutation filters */
 {
 int i = 0; /* variable to walk through arrays */
 //char *def;
 
 gvIdControls(tdb);
 
 /*
 printf("<BR><B>Exclude data source</B><BR>");
 for (i = 0; i < gvSrcSize; i++)
     {
@@ -1652,100 +1642,100 @@
 void hg17KgUI(struct trackDb *tdb)
 /* Put up refGene-specific controls */
 {
 hg17KgIdConfig(tdb);
 baseColorDrawOptDropDown(cart, tdb);
 }
 
 void omimLocationConfig(struct trackDb *tdb)
 /* Put up OMIM Location track controls */
 {
 char varName[64];
 safef(varName, sizeof(varName), "%s.label", tdb->track);
 printf("<BR><B>Include Entries of:</B> ");
 printf("<UL>\n");
 printf("<LI>");
-labelMakeCheckBox(tdb, "class1", "Phenotype map key 1: the disorder has been placed on the map based on its association with a gene, but the underlying defect is not known.", TRUE);
+labelMakeCheckBox(cart, tdb, "class1", "Phenotype map key 1: the disorder has been placed on the map based on its association with a gene, but the underlying defect is not known.", TRUE);
 printf("<LI>");
-labelMakeCheckBox(tdb, "class2", "Phenotype map key 2: the disorder has been placed on the map by linkage; no mutation has been found.", TRUE);
+labelMakeCheckBox(cart, tdb, "class2", "Phenotype map key 2: the disorder has been placed on the map by linkage; no mutation has been found.", TRUE);
 printf("<LI>");
-labelMakeCheckBox(tdb, "class3", "Phenotype map key 3: the molecular basis for the disorder is known; a mutation has been found in the gene.", TRUE);
+labelMakeCheckBox(cart, tdb, "class3", "Phenotype map key 3: the molecular basis for the disorder is known; a mutation has been found in the gene.", TRUE);
 printf("<LI>");
-labelMakeCheckBox(tdb, "class4", "Phenotype map key 4: a contiguous gene deletion or duplication syndrome; multiple genes are deleted or duplicated causing the phenotype.", TRUE);
+labelMakeCheckBox(cart, tdb, "class4", "Phenotype map key 4: a contiguous gene deletion or duplication syndrome; multiple genes are deleted or duplicated causing the phenotype.", TRUE);
 
 // removed the "others" option for the time being
 //printf("<LI>");
-//labelMakeCheckBox(tdb, "others", "Others: no associated OMIM phenotype map key info available.", TRUE);
+//labelMakeCheckBox(cart, tdb, "others", "Others: no associated OMIM phenotype map key info available.", TRUE);
 printf("</UL>");
 }
 
 void omimGene2Config(struct trackDb *tdb)
 /* Put up OMIM Genes track controls */
 {
 char varName[64];
 safef(varName, sizeof(varName), "%s.label", tdb->track);
 printf("<BR><B>Include Entries of:</B> ");
 printf("<UL>\n");
 printf("<LI>");
-labelMakeCheckBox(tdb, "class1", "Phenotype map key 1: the disorder has been placed on the map based on its association with a gene, but the underlying defect is not known.", TRUE);
+labelMakeCheckBox(cart, tdb, "class1", "Phenotype map key 1: the disorder has been placed on the map based on its association with a gene, but the underlying defect is not known.", TRUE);
 printf("<LI>");
-labelMakeCheckBox(tdb, "class2", "Phenotype map key 2: the disorder has been placed on the map by linkage; no mutation has been found.", TRUE);
+labelMakeCheckBox(cart, tdb, "class2", "Phenotype map key 2: the disorder has been placed on the map by linkage; no mutation has been found.", TRUE);
 printf("<LI>");
-labelMakeCheckBox(tdb, "class3", "Phenotype map key 3: the molecular basis for the disorder is known; a mutation has been found in the gene.", TRUE);
+labelMakeCheckBox(cart, tdb, "class3", "Phenotype map key 3: the molecular basis for the disorder is known; a mutation has been found in the gene.", TRUE);
 printf("<LI>");
-labelMakeCheckBox(tdb, "class4", "Phenotype map key 4: a contiguous gene deletion or duplication syndrome; multiple genes are deleted or duplicated causing the phenotype.", TRUE);
+labelMakeCheckBox(cart, tdb, "class4", "Phenotype map key 4: a contiguous gene deletion or duplication syndrome; multiple genes are deleted or duplicated causing the phenotype.", TRUE);
 printf("<LI>");
-labelMakeCheckBox(tdb, "others", "Others: no associated OMIM phenotype map key info available.", TRUE);
+labelMakeCheckBox(cart, tdb, "others", "Others: no associated OMIM phenotype map key info available.", TRUE);
 printf("</UL>");
 }
 
 void omimGeneIdConfig(struct trackDb *tdb)
 /* Put up gene ID track controls */
 {
 char varName[64];
 char *geneLabel;
 safef(varName, sizeof(varName), "%s.label", tdb->track);
 geneLabel = cartUsualString(cart, varName, "OMIM ID");
 printf("<BR><B>Label:</B> ");
 radioButton(varName, geneLabel, "OMIM ID");
 radioButton(varName, geneLabel, "OMIM gene or syndrome");
 radioButton(varName, geneLabel, "UCSC gene symbol");
 }
 
 void knownGeneIdConfig(struct trackDb *tdb)
 /* Put up gene ID track controls */
 {
 struct sqlConnection *conn = hAllocConn(database);
 char query[256];
 char *omimAvail = NULL;
 sqlSafef(query, sizeof(query), "select kgXref.kgID from kgXref,%s r where kgXref.refseq = r.mrnaAcc and r.omimId != 0 limit 1", refLinkTable);
 omimAvail = sqlQuickString(conn, query);
 hFreeConn(&conn);
 boolean isGencode = trackDbSettingOn(tdb, "isGencode") || trackDbSettingOn(tdb, "isGencode2");
 
 printf("<B>Label:</B> ");
-labelMakeCheckBox(tdb, "gene", "gene symbol", FALSE);
+labelMakeCheckBox(cart, tdb, "gene", "gene symbol", FALSE);
 if (isGencode)
-    labelMakeCheckBox(tdb, "gencodeId", "GENCODE Transcript ID", FALSE);
-labelMakeCheckBox(tdb, "kgId", "UCSC Known Gene ID", FALSE);
-labelMakeCheckBox(tdb, "prot", "UniProt Display ID", FALSE);
+    labelMakeCheckBox(cart, tdb, "gencodeId", "GENCODE Transcript ID", FALSE);
+labelMakeCheckBox(cart, tdb, "kgId", "UCSC Known Gene ID", FALSE);
+labelMakeCheckBox(cart, tdb, "prot", "UniProt Display ID", FALSE);
 
 if (omimAvail != NULL)
     {
     char sym[32];
     safef(sym, sizeof(sym), "omim%s", cartString(cart, "db"));
-    labelMakeCheckBox(tdb, sym, "OMIM ID", FALSE);
+    labelMakeCheckBox(cart, tdb, sym, "OMIM ID", FALSE);
     }
 printf("<BR>\n");
 }
 
 void knownGeneShowWhatUi(struct trackDb *tdb)
 /* Put up line of controls that describe what parts to show. */
 {
 char varName[64];
 printf("<B>Show:</B> ");
 safef(varName, sizeof(varName), "%s.show.noncoding", tdb->track);
 boolean option = cartUsualBoolean(cart, varName, TRUE);
 cgiMakeCheckBox(varName, option);
 printf(" %s&nbsp;&nbsp;&nbsp;", "non-coding genes");
 safef(varName, sizeof(varName), "%s.show.spliceVariants", tdb->track);
 option = cartUsualBoolean(cart, varName, TRUE);
@@ -1779,32 +1769,32 @@
 knownGeneShowWhatUi(tdb);
 baseColorDrawOptDropDown(cart, tdb);
 wigOption(cart, "knownGene", "UCSC Genes", tdb);
 }
 
 void omimLocationUI(struct trackDb *tdb)
 /* Put up omimLcation-specific controls */
 {
 omimLocationConfig(tdb);
 }
 
 void omimGene2IdConfig(struct trackDb *tdb)
 /* Put up gene ID track controls */
 {
 printf("<B>Label:</B> ");
-labelMakeCheckBox(tdb, "omimId", "OMIM ID", FALSE);
-labelMakeCheckBox(tdb, "gene", "gene symbol", FALSE);
+labelMakeCheckBox(cart, tdb, "omimId", "OMIM ID", FALSE);
+labelMakeCheckBox(cart, tdb, "gene", "gene symbol", FALSE);
 
 printf("<BR>\n");
 }
 void omimGene2UI(struct trackDb *tdb)
 /* Put up omimGene2-specific controls */
 {
 omimGene2IdConfig(tdb);
 omimGene2Config(tdb);
 }
 
 void omimGeneUI(struct trackDb *tdb)
 /* Put up omimGene-specific controls */
 {
 omimGeneIdConfig(tdb);
 }
@@ -1839,118 +1829,118 @@
 static void hideNoncodingOpt(struct trackDb *tdb)
 /* Put up hide-noncoding options. */
 {
 /* Put up option to hide non-coding elements. */
 printf("<B>Hide non-coding genes:</B> ");
 char varName[64];
 safef(varName, sizeof(varName), "%s.%s", tdb->track, HIDE_NONCODING_SUFFIX);
 cartMakeCheckBox(cart, varName, HIDE_NONCODING_DEFAULT);
 }
 
 void rgdGene2UI(struct trackDb *tdb)
 /* Put up rgdGene2 gene ID track controls, with checkboxes */
 {
 /* Put up label line  - boxes for gene and accession. */
 printf("<B>Label:</B> ");
-labelMakeCheckBox(tdb, "gene", "gene", FALSE);
-labelMakeCheckBox(tdb, "acc", "accession", FALSE);
+labelMakeCheckBox(cart, tdb, "gene", "gene", FALSE);
+labelMakeCheckBox(cart, tdb, "acc", "accession", FALSE);
 printf("<BR>\n");
 
 baseColorDrawOptDropDown(cart, tdb);
 }
 
 void refGeneUI(struct trackDb *tdb)
 /* Put up refGene or xenoRefGene gene ID track controls, with checkboxes */
 {
 // Show label options only if top-level track; ncbiRefSeqUI (for refSeqComposite) shows
 // label options for all subtracks.
 if (tdb->parent == NULL)
     {
     /* Figure out if OMIM database is available. */
     int omimAvail = 0;
     if (sameString(tdb->track, "refGene"))
         {
         struct sqlConnection *conn = hAllocConn(database);
         char query[128];
         sqlSafef(query, sizeof(query), "select r.omimId from %s r, refGene where r.mrnaAcc = refGene.name and r.omimId != 0 limit 1", refLinkTable);
         omimAvail = sqlQuickNum(conn, query);
         hFreeConn(&conn);
         }
 
     /* Put up label line  - boxes for gene, accession or maybe OMIM. */
     printf("<BR><B>Label:</B> ");
-    labelMakeCheckBox(tdb, "gene", "gene", TRUE);
-    labelMakeCheckBox(tdb, "acc", "accession", FALSE);
+    labelMakeCheckBox(cart, tdb, "gene", "gene", TRUE);
+    labelMakeCheckBox(cart, tdb, "acc", "accession", FALSE);
     if (omimAvail != 0)
         {
         char sym[32];
         safef(sym, sizeof(sym), "omim%s", cartString(cart, "db"));
-        labelMakeCheckBox(tdb, sym, "OMIM ID", FALSE);
+        labelMakeCheckBox(cart, tdb, sym, "OMIM ID", FALSE);
         }
     printf("<BR>\n");
     }
 
 /* Put up noncoding option and codon coloring stuff. */
 hideNoncodingOpt(tdb);
 baseColorDrawOptDropDown(cart, tdb);
 printf("<BR>\n");
 
 // let the user choose to see the track in wiggle mode
 wigOption(cart, tdb->track, tdb->shortLabel, tdb);
 }
 
 void transMapUI(struct trackDb *tdb)
 /* Put up transMap-specific controls for table-based transMap */
 {
 // FIXME: this can be deleted once table-based transMap is no longer supported.
 printf("<B>Label:</B> ");
-labelMakeCheckBox(tdb, "orgCommon", "common name", FALSE);
-labelMakeCheckBox(tdb, "orgAbbrv", "organism abbreviation", FALSE);
-labelMakeCheckBox(tdb, "db", "assembly database", FALSE);
-labelMakeCheckBox(tdb, "gene", "gene", FALSE);
-labelMakeCheckBox(tdb, "acc", "accession", FALSE);
+labelMakeCheckBox(cart, tdb, "orgCommon", "common name", FALSE);
+labelMakeCheckBox(cart, tdb, "orgAbbrv", "organism abbreviation", FALSE);
+labelMakeCheckBox(cart, tdb, "db", "assembly database", FALSE);
+labelMakeCheckBox(cart, tdb, "gene", "gene", FALSE);
+labelMakeCheckBox(cart, tdb, "acc", "accession", FALSE);
 
 baseColorDrawOptDropDown(cart, tdb);
 indelShowOptions(cart, tdb);
 }
 
 void retroGeneUI(struct trackDb *tdb)
 /* Put up retroGene-specific controls */
 {
 printf("<B>Label:</B> ");
-labelMakeCheckBox(tdb, "gene", "gene", FALSE);
-labelMakeCheckBox(tdb, "acc", "accession", FALSE);
+labelMakeCheckBox(cart, tdb, "gene", "gene", FALSE);
+labelMakeCheckBox(cart, tdb, "acc", "accession", FALSE);
 
 baseColorDrawOptDropDown(cart, tdb);
 }
 
 void ncbiRefSeqUI(struct trackDb *tdb)
 /* Put up gene ID track controls */
 {
 char varName[256];
 safef(varName, sizeof(varName), "%s.label", tdb->track);
 printf("<br><b>Label:</b> ");
-labelMakeCheckBox(tdb, "gene", "gene symbol", TRUE);
-labelMakeCheckBox(tdb, "acc", "accession", FALSE);
+labelMakeCheckBox(cart, tdb, "gene", "gene symbol", TRUE);
+labelMakeCheckBox(cart, tdb, "acc", "accession", FALSE);
 struct sqlConnection *conn = hAllocConn(database);
 boolean omimAvail = sqlQuickNum(conn,
                                 NOSQLINJ"select 1 from ncbiRefSeqLink where omimId != 0 limit 1");
 if (omimAvail)
     {
     char sym[32];
     safef(sym, sizeof(sym), "omim%s", cartString(cart, "db"));
-    labelMakeCheckBox(tdb, sym, "OMIM ID", FALSE);
+    labelMakeCheckBox(cart, tdb, sym, "OMIM ID", FALSE);
     }
 hFreeConn(&conn);
 }
 
 void ensGeneUI(struct trackDb *tdb)
 /* Put up Ensembl Gene track-specific controls */
 {
 ensGeneIdConfig(tdb);
 printf("<BR>\n");
 
 /* Put up codon coloring stuff. */
 baseColorDrawOptDropDown(cart, tdb);
 }
 
 void vegaGeneUI(struct trackDb *tdb)
@@ -3237,35 +3227,31 @@
                 break;
                 }
             }
         grpFreeList(&grps);
         }
     }
 puts("<BR><BR>");
 
 if (ct && sameString(tdb->type, "maf"))
     tdb->canPack = TRUE;
 else if (sameString(tdb->track, WIKI_TRACK_TABLE))
     // special case wikiTrack (there's no trackDb entry); fixes redmine 2395
     tdb->canPack = TRUE;
 else if (sameString(tdb->type, "halSnake"))
     tdb->canPack = TRUE;
-else if (sameString(tdb->type, "bigPsl"))
-    tdb->canPack = TRUE;
-else if (startsWith(tdb->type, "bigLolly"))
-    tdb->canPack = TRUE;
-else if (sameString(tdb->type, "bigChain"))
+else if (!startsWith("bigWig", tdb->type) && startsWith("big", tdb->type))
     tdb->canPack = TRUE;
 else if (sameString(tdb->type, "bigNarrowPeak"))
     tdb->canPack = TRUE;
 
 // Don't bother with vis controls for downloadsOnly
 if (!tdbIsDownloadsOnly(tdb))
     {
     /* Display visibility menu */
     if (tdbIsComposite(tdb) && multViewCount(tdb) > 0)
         printf("<B>Maximum&nbsp;display&nbsp;mode:&nbsp;</B>");
     else
         printf("<B>Display&nbsp;mode:&nbsp;</B>");
     if (tdbIsSuper(tdb))
         {
         superTrackDropDown(cart, tdb, 1);