47e835f978821dc372b81d378b59e9900a2b7ee0 tdreszer Thu May 5 17:02:38 2011 -0700 Jim wanted this little bit of cleanup to more stadardized function name. diff --git src/hg/lib/cv.c src/hg/lib/cv.c index 532cddd..0363138 100644 --- src/hg/lib/cv.c +++ src/hg/lib/cv.c @@ -59,81 +59,79 @@ char *ret = cloneString(lab); chopSuffixAt(ret, '('); return ret; } /* TBD char *cvLabDeNormalize(char *minimalTerm) // returns lab name with parenthesized trailing info, by lookup in cv.ra, and restores // other oddities caught by Normalize } */ -// TODO: decide to make this public or hide it away inside the one function so far that uses it. -static char *cv_file() +static char *cvFile() // 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,CV_TERM_CELL)) term = CV_UGLY_TERM_CELL_LINE; 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); + cvHashForTerm = raReadWithFilter(cvFile(), CV_TERM,CV_TYPE,term); if (cvHashForTerm != NULL) hashAdd(cvHashOfHashOfHashes,term,cvHashForTerm); } return cvHashForTerm; } const struct hash *cvTermTypeHash() // returns a hash of hashes of mdb and controlled vocabulary (cv) term types // Those terms should contain label,description,searchable,cvDefined,hidden // NOTE: in static memory: DO NOT FREE { // NOTE: "typeOfTerm" is specialized, so don't use cvTermHash static struct hash *cvHashOfTermTypes = NULL; // Establish cv hash of Term Types if it doesn't already exist if (cvHashOfTermTypes == NULL) { - cvHashOfTermTypes = raReadWithFilter(cv_file(), CV_TERM,CV_TYPE,CV_TOT); + cvHashOfTermTypes = raReadWithFilter(cvFile(), CV_TERM,CV_TYPE,CV_TOT); // Patch up an ugly inconsistency with 'cell' struct hash *cellHash = hashRemove(cvHashOfTermTypes,CV_UGLY_TOT_CELLTYPE); if (cellHash) { hashAdd(cvHashOfTermTypes,CV_TERM_CELL,cellHash); hashReplace(cellHash, CV_TERM, cloneString(CV_TERM_CELL)); // spilling memory of 'cellType' val } struct hash *abHash = hashRemove(cvHashOfTermTypes,CV_UGLY_TERM_ANTIBODY); if (abHash) { hashAdd(cvHashOfTermTypes,CV_TERM_ANTIBODY,abHash); hashReplace(abHash, CV_TERM, cloneString(CV_TERM_ANTIBODY)); // spilling memory of 'Antibody' val } }