70f5ad4d3afb51df8cd4c1b40dd75a6a0d0ee915 braney Sat Jan 29 08:13:53 2022 -0800 require that chromAliasSetup be called at init time to avoid potential thread race conditions diff --git src/hg/lib/chromAlias.c src/hg/lib/chromAlias.c index 7849260..b4e66b6 100644 --- src/hg/lib/chromAlias.c +++ src/hg/lib/chromAlias.c @@ -189,31 +189,30 @@ return FALSE; } return TRUE; } chromHashes.database = cloneString(database); return TRUE; } static void readOldAlias(struct lineFile *lf) /* Don't assume the table is fully populated, and dummy up a value for source. */ { char *words[1024]; /* process lines, no more than 1,024 words on a line */ char *line; int size; -printf("<BR>readOldAlias<BR>\n"); while (lineFileNext(lf, &line, &size)) { int wordCount = chopByWhite(line, words, ArraySize(words)); if (wordCount > 1) { int i = 1; for ( ; i < wordCount; ++i ) { if (isNotEmpty(words[i])) { struct chromAlias *ali; AllocVar(ali); ali->alias = cloneString(words[i]); ali->chrom = cloneString(words[0]); ali->source = cloneString("asmHub"); @@ -264,34 +263,37 @@ if (aliasFile == NULL) return; struct lineFile *lf = udcWrapShortLineFile(aliasFile, NULL, MAX_HUB_TRACKDB_FILE_SIZE); chromHashes.forwardHash = hashNew(0); chromHashes.reverseHash = hashNew(0); chromHashes.chromToAliasHash = hashNew(0); chromHashes.aliasToChromHash = hashNew(0); char *line; if (!lineFileNext(lf, &line, NULL)) errAbort("%s is empty", lf->fileName); lineFileReuse(lf); -if (line[0] == '#') +// for the moment always read the alias file in the "old" way +//if (line[0] == '#') +if (0) readFieldedTable(lf); else readOldAlias(lf); +lineFileClose(&lf); } static void chromAliasSetupSql(char *database) /* Look for a chromAlias SQL table and load the hashes with its contents. */ { if (!hTableExists(database, "chromAlias")) return; struct sqlConnection *conn = hAllocConn(database); chromHashes.forwardHash = hashNew(0); chromHashes.reverseHash = hashNew(0); chromHashes.chromToAliasHash = hashNew(0); chromHashes.aliasToChromHash = hashNew(0); @@ -323,43 +325,39 @@ if (chromHashes.inited) return; chromHashes.inited = TRUE; if (trackHubDatabase(database)) chromAliasSetupHub(database); else chromAliasSetupSql(database); } struct hash *chromAliasMakeLookupTable(char *database) /* Given a database name and a connection to that database, construct a lookup table * that takes chromosome alias names to a matching struct chromAlias. Returns NULL * if the given database does not have a chromAlias table. */ { -chromAliasSetup(database); return chromHashes.forwardHash; } struct hash *chromAliasMakeReverseLookupTable(char *database) /* Given a database name and a connection to that database, construct a lookup table * that takes the actual assembly chromosome names to struct chromAliases. Because a * chromosome name may well have multiple aliases, repeated calls to hashLookupNext * may be required to see them all. Returns NULL if the given database does not have * a chromAlias table. */ { -chromAliasSetup(database); return chromHashes.reverseHash; } struct hash *chromAliasAliasToChromHash(char *database) /* Get the hash that maps chrom names to their aliases. */ { -chromAliasSetup(database); return chromHashes.aliasToChromHash; } struct hash *chromAliasChromToAliasHash(char *database) /* Get the hash that maps chrom names to their aliases. */ { -chromAliasSetup(database); return chromHashes.chromToAliasHash; }