void makeNewExpTable(char *oldTable, struct maMedSpec *medList, char *newTable) /* Create new expTable in hgFixed that is very similar * to oldExpTable, but with rows defined by medList. */ { struct maMedSpec *med; struct expRecord *oldExp, newExp; struct sqlConnection *conn = sqlConnect("hgFixed"); FILE *f = hgCreateTabFile(tabDir, newTable); char query[256], **row; struct sqlResult *sr; int curId = 0; for (med = medList; med != NULL; med = med->next) { /* Load expression record from old table of first * thing in median. */ sqlSafef(query, sizeof(query), "select * from %s where id = %d", oldTable, med->ids[0]); sr = sqlGetResult(conn, query); if ((row = sqlNextRow(sr)) == NULL) errAbort("Can't find id %d in %s\n", med->ids[0], oldTable); oldExp = expRecordLoad(row); sqlFreeResult(&sr); if (oldExp->numExtras < 3) errAbort("Can only deal with old tables with 3 extras or more"); /* Create new expression record, mostly just a shallow copy of old. */ newExp = *oldExp; newExp.id = curId; ++curId; newExp.name = newExp.description = med->name; newExp.extras[2] = med->group; /* Save new one, free old one. */ expRecordTabOut(&newExp, f); expRecordFree(&oldExp); } if (doLoad) { expRecordCreateTable(conn, newTable); hgLoadTabFile(conn, tabDir, newTable, &f); hgRemoveTabFile(tabDir, newTable); } sqlDisconnect(&conn); }
void erHashElFree(struct hashEl *el) /* Frees up expRecord hash head. */ { struct expRecord *er = el->val; expRecordFree(&er); }