/* hgStsAlias - Make table of STS aliases. */ #include "common.h" #include "hash.h" #include "linefile.h" #include "jksql.h" #include "hgRelate.h" #include "stsAlias.h" #include "stsMarker.h" void usage() /* Explain usage and exit. */ { errAbort( "hgStsAlias - Make table of STS aliases\n" "usage:\n" " hgStsAlias database file.alias\n"); } struct hash *makeTrueHash(struct sqlConnection *conn) /* Make up hash of TRUE names. */ { struct hash *hash = newHash(0); struct sqlResult *sr; char **row; struct stsMarker marker; sr = sqlGetResult(conn, "select * from stsMarker"); while ((row = sqlNextRow(sr)) != NULL) { stsMarkerStaticLoad(row, &marker); hashAdd(hash, marker.name, NULL); } sqlFreeResult(&sr); return hash; } void hgStsAlias(char *database, char *inFile) /* hgStsAlias - Make table of STS aliases. */ { struct lineFile *lf = lineFileOpen(inFile, TRUE); char *words[16],*parts[64]; int partCount, wordCount; char *table = "stsAlias"; struct sqlConnection *conn = sqlConnect(database); FILE *f = hgCreateTabFile(".", table); struct hash *trueHash = makeTrueHash(conn); int i; char *alias, *trueName; int aliasCount = 0; while ((wordCount = lineFileChop(lf, words)) != 0) { trueName = NULL; if (wordCount != 2) { static boolean warned = FALSE; if (!warned) { warn("Got %d words line %d of %s, skipping", wordCount, lf->lineIx, lf->fileName); warn("There may be other lines like this as well"); warned = TRUE; } continue; } lineFileExpectWords(lf, 2, wordCount); partCount = chopByChar(words[1], ';', parts, ArraySize(parts)); if (partCount >= ArraySize(parts)) errAbort("Too many aliases line %d of %s\n", lf->lineIx, lf->fileName); /* Figure out which one we actually have a name for. */ for (i=0; i