eedd099cd94fbe910d8e40dc26021d23d5547569
tdreszer
  Wed Oct 27 15:59:41 2010 -0700
Links to controlled vocabulary for antibodies will now use target to get set of antibodies
diff --git src/hg/lib/hui.c src/hg/lib/hui.c
index 99fb34c..fc833a9 100644
--- src/hg/lib/hui.c
+++ src/hg/lib/hui.c
@@ -5746,54 +5746,54 @@
 (void)metadataForTable(db,childTdb,NULL);
 if(vocab == NULL)
     return cloneString(label); // No wrapping!
 
 char *words[15];
 int count,ix;
 boolean found=FALSE;
 if((count = chopByWhite(cloneString(vocab), words,15)) <= 1)
     return cloneString(label);
 
 char *suffix=NULL;
 char *rootLabel = labelRoot(label,&suffix);
 
 for(ix=1;ix<count && !found;ix++)
     {
-#define VOCAB_LINK "<A HREF='hgEncodeVocab?ra=%s&term=\"%s\"' title='%s details' TARGET=ucscVocab>%s</A>"
+#define VOCAB_LINK "<A HREF='hgEncodeVocab?ra=%s&%s=\"%s\"' title='%s details' TARGET=ucscVocab>%s</A>"
     if(sameString(vocabType,words[ix])) // controlledVocabulary setting matches tag so all labels are linked
         {
-        int sz=strlen(VOCAB_LINK)+strlen(words[0])+strlen(words[ix])+2*strlen(label) + 2;
+        int sz=strlen(VOCAB_LINK)+strlen(words[0])+strlen(words[ix])+2*strlen(label) + 10;
         char *link=needMem(sz);
-        safef(link,sz,VOCAB_LINK,words[0],words[ix],rootLabel,rootLabel);
+        safef(link,sz,VOCAB_LINK,words[0],"term",words[ix],rootLabel,rootLabel);
         if(suffix)
             safecat(link,sz,suffix);
         freeMem(words[0]);
         return link;
         }
     else if(countChars(words[ix],'=') == 1 && childTdb != NULL) // The name of a trackDb setting follows and will be the controlled vocab term
         {
         strSwapChar(words[ix],'=',0);
         if(sameString(vocabType,words[ix]))  // tags match, but search for term
             {
             char * cvSetting = words[ix] + strlen(words[ix]) + 1;
             const char * cvTerm = metadataFindValue(childTdb,cvSetting);
             if(cvTerm != NULL)
                 {
                 char *encodedTerm = cgiEncode((char *)cvTerm);
-                int sz=strlen(VOCAB_LINK)+strlen(words[0])+strlen(encodedTerm)+2*strlen(label) + 2;
+                int sz=strlen(VOCAB_LINK)+strlen(words[0])+strlen(encodedTerm)+2*strlen(label) + 10;
                 char *link=needMem(sz);
-                safef(link,sz,VOCAB_LINK,words[0],encodedTerm,cvTerm,rootLabel);
+                safef(link,sz,VOCAB_LINK,words[0],(sameWord(cvSetting,"antibody")?"target":"term"),encodedTerm,cvTerm,rootLabel);
                 if(suffix)
                     safecat(link,sz,suffix);
                 freeMem(words[0]);
                 freeMem(encodedTerm);
                 return link;
                 }
             }
         }
     }
 freeMem(words[0]);
 freeMem(rootLabel);
 return cloneString(label);
 }
 
 #define PM_BUTTON_UC "<IMG height=18 width=18 onclick=\"return (matSetMatrixCheckBoxes(%s%s%s%s%s%s) == false);\" id='btn_%s' src='../images/%s'>"
@@ -6003,56 +6003,56 @@
 static char *labelWithVocabLinkForMultiples(char *db,struct trackDb *parentTdb, members_t* members)
 /* If the parentTdb has a controlledVocabulary setting and the vocabType is found,
    then label will be wrapped with the link to all relevent terms.  Return string is cloned. */
 {
 assert(members->subtrackList != NULL);
 char *vocab = cloneString(trackDbSetting(parentTdb, "controlledVocabulary"));
 if(vocab == NULL)
     return cloneString(members->groupTitle); // No link wrapping!
 
 char *words[15];
 int count,ix;
 boolean found=FALSE;
 if((count = chopByWhite(vocab, words,15)) <= 1) // vocab now contains just the file name
     return cloneString(members->groupTitle);
 
-#define VOCAB_MULTILINK_BEG "<A HREF='hgEncodeVocab?ra=%s&term=\""
-#define VOCAB_MULTILINK_END "\"' title='Click for details of each %s' TARGET=ucscVocab>%s</A>"
-struct dyString *dyLink = dyStringCreate(VOCAB_MULTILINK_BEG,vocab);
 char *mdbVar = NULL;
 
 // Find mdb var to look up based upon the groupTag and cv setting
 for(ix=1;ix<count && !found;ix++)
     {
     if(sameString(members->groupTag,words[ix])) // controlledVocabulary setting matches tag so all labels are linked
         {
         mdbVar = members->groupTag;
         break;
         }
     else if(startsWithWordByDelimiter(members->groupTag,'=',words[ix]))
         {
         mdbVar = words[ix] + strlen(members->groupTag) + 1;
         break;
         }
     }
 if(mdbVar == NULL)
     {
-    dyStringFree(&dyLink);
     freeMem(vocab);
     return cloneString(members->groupTitle);
     }
 
+#define VOCAB_MULTILINK_BEG "<A HREF='hgEncodeVocab?ra=%s&%s=\""
+#define VOCAB_MULTILINK_END "\"' title='Click for details of each %s' TARGET=ucscVocab>%s</A>"
+struct dyString *dyLink = dyStringCreate(VOCAB_MULTILINK_BEG,vocab,(sameWord(mdbVar,"antibody")?"target":"term"));
+
 // Now build the comma delimited string of mdb vals (all have same mdb var)
 boolean first = TRUE;
 for(ix=0;ix<members->count;ix++)
     {
     if(members->subtrackList[ix] != NULL && members->subtrackList[ix]->val != NULL)
         {
         struct trackDb *childTdb = members->subtrackList[ix]->val;
         (void)metadataForTable(db,childTdb,NULL); // Makes sure this has been populated
         const char * mdbVal = metadataFindValue(childTdb,mdbVar); // one for each is enough
         if(mdbVal != NULL)
             {
             if(!first)
                 dyStringAppendC(dyLink,',');
             dyStringAppend(dyLink,(char *)mdbVal);
             first = FALSE;