f09e062ead54042b3f2b20ea4f4addc21633625e cline Mon Sep 19 17:16:29 2011 -0700 Changed in response to Redmine #5290 (tRNA and Rfam genes being represented poorly by kgXref). The kgXref table now has two new fields: one for the tRNA name (which can be used to cross-reference the track items to tRNA Genes items), and one for the Rfam accession (which can be used for links to the appropriate Rfam model page). txGeneXref fills in both of these fields, and splices the sequence names appropriately to pull out half-meaningful gene symbols and descriptions diff --git src/hg/lib/kgXref.c src/hg/lib/kgXref.c index 960800b..d606e7c 100644 --- src/hg/lib/kgXref.c +++ src/hg/lib/kgXref.c @@ -1,180 +1,188 @@ /* kgXref.c was originally generated by the autoSql program, which also * generated kgXref.h and kgXref.sql. This module links the database and * the RAM representation of objects. */ #include "common.h" #include "linefile.h" #include "dystring.h" #include "jksql.h" #include "kgXref.h" static char const rcsid[] = "$Id:$"; void kgXrefStaticLoad(char **row, struct kgXref *ret) /* Load a row from kgXref table into ret. The contents of ret will * be replaced at the next call to this function. */ { ret->kgID = row[0]; ret->mRNA = row[1]; ret->spID = row[2]; ret->spDisplayID = row[3]; ret->geneSymbol = row[4]; ret->refseq = row[5]; ret->protAcc = row[6]; ret->description = row[7]; ret->rfamAcc = row[8]; +ret->tRnaName = row[9]; } struct kgXref *kgXrefLoad(char **row) /* Load a kgXref from row fetched with select * from kgXref * from database. Dispose of this with kgXrefFree(). */ { struct kgXref *ret; AllocVar(ret); ret->kgID = cloneString(row[0]); ret->mRNA = cloneString(row[1]); ret->spID = cloneString(row[2]); ret->spDisplayID = cloneString(row[3]); ret->geneSymbol = cloneString(row[4]); ret->refseq = cloneString(row[5]); ret->protAcc = cloneString(row[6]); ret->description = cloneString(row[7]); ret->rfamAcc = cloneString(row[8]); +ret->tRnaName = cloneString(row[9]); return ret; } struct kgXref *kgXrefLoadAll(char *fileName) /* Load all kgXref from a whitespace-separated file. * Dispose of this with kgXrefFreeList(). */ { struct kgXref *list = NULL, *el; struct lineFile *lf = lineFileOpen(fileName, TRUE); -char *row[9]; +char *row[10]; while (lineFileRow(lf, row)) { el = kgXrefLoad(row); slAddHead(&list, el); } lineFileClose(&lf); slReverse(&list); return list; } struct kgXref *kgXrefLoadAllByChar(char *fileName, char chopper) /* Load all kgXref from a chopper separated file. * Dispose of this with kgXrefFreeList(). */ { struct kgXref *list = NULL, *el; struct lineFile *lf = lineFileOpen(fileName, TRUE); -char *row[9]; +char *row[10]; while (lineFileNextCharRow(lf, chopper, row, ArraySize(row))) { el = kgXrefLoad(row); slAddHead(&list, el); } lineFileClose(&lf); slReverse(&list); return list; } struct kgXref *kgXrefCommaIn(char **pS, struct kgXref *ret) /* Create a kgXref out of a comma separated string. * This will fill in ret if non-null, otherwise will * return a new kgXref */ { char *s = *pS; if (ret == NULL) AllocVar(ret); ret->kgID = sqlStringComma(&s); ret->mRNA = sqlStringComma(&s); ret->spID = sqlStringComma(&s); ret->spDisplayID = sqlStringComma(&s); ret->geneSymbol = sqlStringComma(&s); ret->refseq = sqlStringComma(&s); ret->protAcc = sqlStringComma(&s); ret->description = sqlStringComma(&s); ret->rfamAcc = sqlStringComma(&s); +ret->tRnaName = sqlStringComma(&s); *pS = s; return ret; } void kgXrefFree(struct kgXref **pEl) /* Free a single dynamically allocated kgXref such as created * with kgXrefLoad(). */ { struct kgXref *el; if ((el = *pEl) == NULL) return; freeMem(el->kgID); freeMem(el->mRNA); freeMem(el->spID); freeMem(el->spDisplayID); freeMem(el->geneSymbol); freeMem(el->refseq); freeMem(el->protAcc); freeMem(el->description); freeMem(el->rfamAcc); +freeMem(el->tRnaName); freez(pEl); } void kgXrefFreeList(struct kgXref **pList) /* Free a list of dynamically allocated kgXref's */ { struct kgXref *el, *next; for (el = *pList; el != NULL; el = next) { next = el->next; kgXrefFree(&el); } *pList = NULL; } void kgXrefOutput(struct kgXref *el, FILE *f, char sep, char lastSep) /* Print out kgXref. Separate fields with sep. Follow last field with lastSep. */ { if (sep == ',') fputc('"',f); fprintf(f, "%s", el->kgID); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->mRNA); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->spID); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->spDisplayID); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->geneSymbol); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->refseq); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->protAcc); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->description); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->rfamAcc); if (sep == ',') fputc('"',f); +fputc(sep,f); +if (sep == ',') fputc('"',f); +fprintf(f, "%s", el->tRnaName); +if (sep == ',') fputc('"',f); fputc(lastSep,f); } /* -------------------------------- End autoSql Generated Code -------------------------------- */