b94049706947c8eeaa56aa8593a74940fdfd544f
kate
  Thu Feb 12 15:22:25 2015 -0800
Use controlledVocabulary setting for non-ENCODE (table-based) vocabularies (replace briefly used *MetaTables settings)

diff --git src/hg/hgc/peakClusters.c src/hg/hgc/peakClusters.c
index d2663ce..51148f8 100644
--- src/hg/hgc/peakClusters.c
+++ src/hg/hgc/peakClusters.c
@@ -69,43 +69,43 @@
 	sum += sqlDouble(row[signalCol]);
 	}
     sqlFreeResult(&sr);
     hFreeConn(&conn);
     }
 
 if (count > 0)
     return sum/count;
 else
     return 0;
 }
 
 static void printControlledVocabFields(char **row, int fieldCount, 
 	struct slName *fieldList, char *vocabFile, struct hash *vocabHash)
 /* Print out fields from row, linking them to controlled vocab if need be. 
- * If vocabFile is NULL, the vocabHash is a metaHash, so links + mouseovers are
+ * If vocabFile is NULL, the vocabHash is not ENCODE, so links + mouseovers are
  * generated differently */
 {
 int i;
 struct slName *field;
 for (i=0, field = fieldList; i<fieldCount; ++i, field = field->next)
     {
     char *link = NULL;
     char *fieldVal = row[i];
     if (vocabFile && hashLookup(vocabHash, field->name))
         {
         // controlled vocabulary
-        link = controlledVocabLink(vocabFile, "term", fieldVal, fieldVal, fieldVal, "");
+        link = wgEncodeVocabLink(vocabFile, "term", fieldVal, fieldVal, fieldVal, "");
         }
     else if (!vocabFile && vocabHash != NULL)
         {
         // meta tables
         struct hash *fieldHash = hashFindVal(vocabHash, field->name);
         if (fieldHash != NULL)
             link = vocabLink(fieldHash, fieldVal, fieldVal);
 
         }
     webPrintLinkCell(link != NULL ? link : fieldVal);
     }
 }
 
 static void printMetadataForTable(char *table)
 /* If table exists, _and_ tdb associated with it exists, print out
@@ -140,45 +140,44 @@
     // skip leading comma
     dyStringPrintf(query, " order by %s", fields->string+1);
 dyStringFree(&fields);
 }
 
 static struct hash *getVocabHash(char *fileName)
 /* Get vocabulary term hash */
 {
 struct hash *hash = raTagVals(fileName, "type");
 hashAdd(hash, "cellType", NULL);	/* Will the kludge never end, no, never! */
 return hash;
 }
 
 static void getVocab(struct trackDb *tdb, struct cart *cart, 
                         char **vocabFile, struct hash **vocabHash)
-/* Get vocabulary info from trackDb settings (CV or meta tables) */
+/* Get vocabulary info from trackDb settings (CV or vocab tables) */
 {
 
 char *file = NULL;
 struct hash *hash = NULL;
 char *vocab = trackDbSetting(tdb, "controlledVocabulary");
-struct hash *metaHash = vocabBasicFromSetting(tdb, cart, "inputFieldMetaTables");
-if (vocab)
+if (vocabSettingIsEncode(vocab))
     {
     file = cloneFirstWord(vocab);
     hash = getVocabHash(file);
     }
-else if (metaHash)
+else
     {
-    hash = metaHash;
+    hash = vocabBasicFromSetting(tdb, cart);
     }
 if (vocabFile != NULL)
     *vocabFile = file;
 if (hash != NULL)
     *vocabHash = hash;
 }
 
 static void printPeakClusterInfo(struct trackDb *tdb, struct cart *cart,
                                 struct sqlConnection *conn, char *inputTrackTable, 
                                 struct slName *fieldList, struct bed *cluster)
 /* Print an HTML table showing sources with hits in the cluster, along with signal.
    If cluster is NULL, show all sources assayed */
 {
 /* Make the SQL query to get the table and all other fields we want to show
  * from inputTrackTable. */
@@ -209,31 +208,31 @@
 	webPrintDoubleCell(signal);
     printControlledVocabFields(row+1, fieldCount, fieldList, vocabFile, vocabHash);
     printMetadataForTable(row[0]);
     }
 sqlFreeResult(&sr);
 freez(&vocabFile);
 dyStringFree(&query);
 }
 
 static char *factorSourceVocabLink(char *vocabFile, char *fieldName, char *fieldVal)
 /* Add link to show controlled vocabulary entry for term.
  * Handles 'target' (factor) which is a special case, derived from Antibody entries */
 {
 char *vocabType = (sameString(fieldName, "target") || sameString(fieldName, "factor")) ?
                     "target" : "term";
-return controlledVocabLink(vocabFile, vocabType, fieldVal, fieldVal, fieldVal, "");
+return wgEncodeVocabLink(vocabFile, vocabType, fieldVal, fieldVal, fieldVal, "");
 }
 
 static void printFactorSourceTableHits(struct factorSource *cluster, struct sqlConnection *conn,
 	char *sourceTable, char *inputTrackTable, 
 	struct slName *fieldList, boolean invert, char *vocab)
 /* Put out a lines in an html table that shows assayed sources that have hits in this
  * cluster, or if invert is set, that have misses. */
 {
 char *vocabFile = NULL;
 if (vocab)
     {
     vocabFile = cloneFirstWord(vocab);
     }
 
 /* Make the monster SQL query to get all assays*/
@@ -477,31 +476,31 @@
 struct factorSource *cluster = NULL;
 if (row != NULL)
     cluster = factorSourceLoad(row + rowOffset);
 sqlFreeResult(&sr);
 
 if (cluster == NULL)
     errAbort("Error loading cluster from track %s", tdb->track);
 
 char *sourceTable = trackDbRequiredSetting(tdb, "sourceTable");
 
 char *factorLink = cluster->name;
 char *vocab = trackDbSetting(tdb, "controlledVocabulary");
 if (vocab != NULL)
     {
     char *file = cloneFirstWord(vocab);
-    factorLink = controlledVocabLink(file, "term", factorLink, factorLink, factorLink, "");
+    factorLink = wgEncodeVocabLink(file, "term", factorLink, factorLink, factorLink, "");
     }
 printf("<B>Factor:</B> %s<BR>\n", factorLink);
 printf("<B>Cluster Score (out of 1000):</B> %d<BR>\n", cluster->score);
 printPos(cluster->chrom, cluster->chromStart, cluster->chromEnd, NULL, TRUE, NULL);
 
 
 /* Get list of tracks we'll look through for input. */
 char *inputTrackTable = trackDbRequiredSetting(tdb, "inputTrackTable");
 sqlSafef(query, sizeof(query), 
     "select tableName from %s where factor='%s' order by source", inputTrackTable, 
     cluster->name);
 
 /* Next do the lists of hits and misses.  We have the hits from the non-zero signals in
  * cluster->expScores.  We need to figure out the sources actually assayed though
  * some other way.  We'll do this by one of two techniques. */