0564395ec363631f2ff8d295da6f6b50f873fda4 braney Mon Jan 24 17:01:53 2022 -0800 more chromAlias work: some name changes and support for the new genark chromAlias format diff --git src/hg/lib/hdb.c src/hg/lib/hdb.c index 2c1edcc..a6b29d6 100644 --- src/hg/lib/hdb.c +++ src/hg/lib/hdb.c @@ -201,76 +201,37 @@ /* aliasHash will be initialized if chromAlias table exists * or track chromAlias file exists * hash key is alias name, hash value is chromosome name */ static struct hash *aliasHash = NULL; if (strlen(name) > HDB_MAX_CHROM_STRING) return NULL; struct chromInfo *ci = NULL; char buf[HDB_MAX_CHROM_STRING]; strncpy(buf, name, HDB_MAX_CHROM_STRING); buf[HDB_MAX_CHROM_STRING-1] = 0; ci = hGetChromInfo(db, buf); if (ci != NULL) return cloneString(ci->chrom); -else - { - if (!aliasHash && trackHubDatabase(db)) - { - aliasHash = newHash(4); /* could remain empty if no hubHash which - * will prevent getting into this initalization again and all hash - * lookups will return NULL. - * hub hash is different than what we want here, its key is - * the chrom name with a hash value of: struct chromAlias * - */ - struct hash *hubHash = trackHubAllChromAlias(db); - if (hubHash) - { - /* rearrange hubHash into the hash we need here */ - struct hashCookie cookie = hashFirst(hubHash); - struct hashEl *hel; - while ((hel = hashNext(&cookie)) != NULL) - { - struct chromAlias *ca = (struct chromAlias *)hel->val; - hashAdd(aliasHash, ca->alias, cloneString(ca->chrom)); - } - } - } - if (aliasHash || hTableExists(db, "chromAlias")) - { - if (! aliasHash) /* first time, initialize aliasHash */ +aliasHash = chromAliasAliasToChromHash(db); +if (aliasHash) { - aliasHash = newHash(4); - struct sqlConnection *conn = hAllocConn(db); - char query[512]; - sqlSafef(query, sizeof(query), "select * from chromAlias"); - struct sqlResult *sr = sqlGetResult(conn, query); - char **row; - while ((row = sqlNextRow(sr)) != NULL) - { - struct chromAlias *ca = chromAliasLoad(row); - hashAdd(aliasHash, ca->alias, cloneString(ca->chrom)); - } - sqlFreeResult(&sr); - hFreeConn(&conn); - } char *chrom = (char *)hashFindVal(aliasHash, name); if (isNotEmpty(chrom)) return cloneString(chrom); } - } return NULL; } /* char *hgOfficialChromName(char *db, char *name) */ boolean hgIsOfficialChromName(char *db, char *name) /* Determine if name is exact (case-sensitive) match with * a chromosome in the given assembly */ { char *chrom; return ((chrom = hgOfficialChromName(db, name)) != NULL && sameString(name, chrom)); } static boolean minLen = 0; void setMinIndexLengthForTrashCleaner()