0fc945bd365976b11531712cae21841a0369df6d
braney
  Wed Jun 17 11:43:40 2015 -0700
let users show GENCODE transcript id in UCSC genes refs #14639

diff --git src/hg/hgTracks/simpleTracks.c src/hg/hgTracks/simpleTracks.c
index 8c0bd74..34ea550 100644
--- src/hg/hgTracks/simpleTracks.c
+++ src/hg/hgTracks/simpleTracks.c
@@ -5028,90 +5028,103 @@
 {
 char str2[255];
 struct linkedFeatures *lf = item;
 /* piggy back the protein ID (hgg_prot variable) on hgg_gene variable */
 safef(str2, sizeof(str2), "%s&hgg_prot=%s", lf->name, ((struct knownGenesExtra *)(lf->extra))->hgg_prot);
 return(cloneString(str2));
 }
 
 void lookupKnownGeneNames(struct linkedFeatures *lfList)
 /* This converts the known gene ID to a gene symbol */
 {
 struct linkedFeatures *lf;
 struct sqlConnection *conn = hAllocConn(database);
 char *geneSymbol;
 char *protDisplayId;
+char *gencodeId;
 char *mimId;
 char cond_str[256];
 
 boolean useGeneSymbol= FALSE;
 boolean useKgId      = FALSE;
 boolean useProtDisplayId = FALSE;
 boolean useMimId = FALSE;
+boolean useGencodeId = FALSE;
 
 struct hashEl *knownGeneLabels = cartFindPrefix(cart, "knownGene.label");
 struct hashEl *label;
 boolean labelStarted = FALSE;
 
 if (hTableExists(database, "kgXref"))
     {
     char omimLabel[48];
     safef(omimLabel, sizeof(omimLabel), "omim%s", cartString(cart, "db"));
 
     if (knownGeneLabels == NULL)
         {
         useGeneSymbol = TRUE; /* default to gene name */
         /* set cart to match what doing */
         cartSetBoolean(cart, "knownGene.label.gene", TRUE);
         }
 
     for (label = knownGeneLabels; label != NULL; label = label->next)
         {
         if (endsWith(label->name, "gene") && differentString(label->val, "0"))
             useGeneSymbol = TRUE;
         else if (endsWith(label->name, "kgId") && differentString(label->val, "0"))
             useKgId = TRUE;
+        else if (endsWith(label->name, "gencodeId") && differentString(label->val, "0"))
+            useGencodeId = TRUE;
         else if (endsWith(label->name, "prot") && differentString(label->val, "0"))
             useProtDisplayId = TRUE;
         else if (endsWith(label->name, omimLabel) && differentString(label->val, "0"))
             useMimId = TRUE;
         else if (!endsWith(label->name, "gene") &&
+                 !endsWith(label->name, "gencodeId") &&
                  !endsWith(label->name, "kgId") &&
                  !endsWith(label->name, "prot") &&
                  !endsWith(label->name, omimLabel) )
             {
             useGeneSymbol = TRUE;
             cartRemove(cart, label->name);
             }
         }
 
     for (lf = lfList; lf != NULL; lf = lf->next)
 	{
         struct dyString *name = dyStringNew(SMALLDYBUF);
         struct knownGenesExtra *kgE;
         AllocVar(kgE);
         labelStarted = FALSE; /* reset between items */
         if (useGeneSymbol)
             {
             sqlSafefFrag(cond_str, sizeof cond_str,"kgID='%s'", lf->name);
             geneSymbol = sqlGetField(database, "kgXref", "geneSymbol", cond_str);
             if (geneSymbol != NULL)
                 {
                 dyStringAppend(name, geneSymbol);
                 }
             labelStarted = TRUE;
             }
+        if (useGencodeId)
+            {
+            if (labelStarted) dyStringAppendC(name, '/');
+            else labelStarted = TRUE;
+	    sqlSafefFrag(cond_str, sizeof(cond_str), "name='%s'", lf->name);
+	    gencodeId = sqlGetField(database, "knownGene", "alignID", cond_str);
+	    dyStringAppend(name, gencodeId);
+	    }
         if (useKgId)
             {
             if (labelStarted) dyStringAppendC(name, '/');
             else labelStarted = TRUE;
             dyStringAppend(name, lf->name);
 	    }
         if (useProtDisplayId)
             {
             if (labelStarted) dyStringAppendC(name, '/');
             else labelStarted = TRUE;
             if (lf->extra != NULL)
                 {
                 dyStringAppend(name, (char *)lf->extra);
                 }
             else