9ea3b0def2516a738157514e8b8cdd9ba7210766
tdreszer
  Thu Mar 24 16:31:03 2011 -0700
Made mdb dependent upon cv defines.  Made hgEncodeVocab use cv defines.
diff --git src/hg/lib/cv.c src/hg/lib/cv.c
index e18fbfa..174ab2d 100644
--- src/hg/lib/cv.c
+++ src/hg/lib/cv.c
@@ -11,53 +11,75 @@
 #include "mdb.h"
 
 // CV Defines that should not necessarily be public
 
 // CV UGLY TERMS (NOTE: These should be hiddne inside cv.c APIS and callers should use non-UGLY terms)
 #define CV_UGLY_TOT_CELLTYPE    "cellType"
 #define CV_UGLY_TERM_CELL_LINE  "Cell Line"
 #define CV_UGLY_TERM_ANTIBODY   "Antibody"
 
 // Type of Terms searchable defines
 #define CV_SEARCHABLE               "searchable"
 #define CV_SEARCHABLE_SINGLE_SELECT "select"
 #define CV_SEARCHABLE_MULTI_SELECT  "multiSelect"
 #define CV_SEARCHABLE_FREE_TEXT     "freeText"
 
+char *cvTypeNormalized(char *sloppyTerm)
+// returns (on stack) the proper term to use when requesting a typeOfTerm
+{
+if (sameWord(sloppyTerm,CV_TERM_CELL) || sameWord(sloppyTerm,CV_UGLY_TERM_CELL_LINE))
+    return CV_UGLY_TOT_CELLTYPE;
+if (sameWord(sloppyTerm,CV_TERM_ANTIBODY))
+    return CV_UGLY_TERM_ANTIBODY;
+
+return sloppyTerm;
+}
+
+char *cvTermNormalized(char *sloppyTerm)
+// returns (on stack) the proper term to use when requesting a cvTerm hash
+{
+if (sameWord(sloppyTerm,CV_UGLY_TOT_CELLTYPE) || sameWord(sloppyTerm,CV_UGLY_TERM_CELL_LINE))
+    return CV_TERM_CELL;
+if (sameWord(sloppyTerm,CV_UGLY_TERM_ANTIBODY))
+    return CV_TERM_ANTIBODY;
+
+return sloppyTerm;
+}
+
 // TODO: decide to make this public or hide it away inside the one function so far that uses it.
 static char *cv_file()
 // return default location of cv.ra
 {
 static char filePath[PATH_LEN];
 char *root = hCgiRoot();
 if (root == NULL || *root == 0)
     root = "/usr/local/apache/cgi-bin/"; // Make this check out sandboxes?
 //    root = "/cluster/home/tdreszer/kent/src/hg/makeDb/trackDb/cv/alpha/"; // Make this check out sandboxes?
 safef(filePath, sizeof(filePath), "%s/encode/%s", root,CV_FILE_NAME);
 if(!fileExists(filePath))
     errAbort("Error: can't locate %s; %s doesn't exist\n", CV_FILE_NAME, filePath);
 return filePath;
 }
 
 const struct hash *cvTermHash(char *term)
 // returns a hash of hashes of a term which should be defined in cv.ra
 // NOTE: in static memory: DO NOT FREE
 {
 static struct hash *cvHashOfHashOfHashes = NULL;
-if (sameString(term,MDB_VAR_CELL))
+if (sameString(term,CV_TERM_CELL))
     term = CV_UGLY_TERM_CELL_LINE;
-else if (sameString(term,MDB_VAR_ANTIBODY))
+else if (sameString(term,CV_TERM_ANTIBODY))
     term = CV_UGLY_TERM_ANTIBODY;
 
 if (cvHashOfHashOfHashes == NULL)
     cvHashOfHashOfHashes = hashNew(0);
 
 struct hash *cvHashForTerm = hashFindVal(cvHashOfHashOfHashes,term);
 // Establish cv hash of Term Types if it doesn't already exist
 if (cvHashForTerm == NULL)
     {
     cvHashForTerm = raReadWithFilter(cv_file(), CV_TERM,CV_TYPE,term);
     if (cvHashForTerm != NULL)
         hashAdd(cvHashOfHashOfHashes,term,cvHashForTerm);
     }
 
 return cvHashForTerm;