f28d6cf170736d1374ccac80ea59943bb85e2cab max Wed May 27 02:08:22 2020 -0700 showing disease table on omim hgc page, refs #18419 diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c index 8318bac..460a48e 100644 --- src/hg/hgc/hgc.c +++ src/hg/hgc/hgc.c @@ -10557,134 +10557,192 @@ printf("%s</A></B>", row[0]); printedCnt++; } if (printedCnt >= 1) printf("<BR>\n"); } sqlFreeResult(&sr); } } printf("<HR>"); printPosOnChrom(chrom, atoi(chromStart), atoi(chromEnd), NULL, FALSE, itemName); } #include "omim.h" +static void showOmimDisorderTable(struct sqlConnection *conn, char *url, char *itemName) +{ +/* display disorder(s) as a table, in the same format as on the OMIM webpages, + * e.g. see the "Gene-Phenotype-Relationships" table at https://www.omim.org/entry/601542 */ +struct sqlResult *sr; +char query[256]; +char **row; + +// be tolerant of old table schema +if (sqlColumnExists(conn, "omimPhenotype", "inhMode")) + sqlSafef(query, sizeof(query), + "select description, %s, phenotypeId, inhMode from omimPhenotype where omimId=%s order by description", + omimPhenotypeClassColName, itemName); +else + // E.g. on a mirror that has not updated their OMIM tables yet + sqlSafef(query, sizeof(query), + "select description, %s, phenotypeId, 'data-missing' from omimPhenotype where omimId=%s order by description", + omimPhenotypeClassColName, itemName); + +sr = sqlMustGetResult(conn, query); +char *phenotypeClass, *phenotypeId, *disorder, *inhMode; + +printf("<table class='omimTbl'>\n"); +printf("<thead>\n"); +printf("<th>Phenotype</th>\n"); +printf("<th style='width:100px'>Phenotype MIM Number</th>\n"); +printf("<th>Inheritance</th>\n"); +printf("<th>Phenotype Key</th>\n"); +printf("</thead>\n"); + +printf("<tbody>\n"); +while ((row = sqlNextRow(sr)) != NULL) + { + disorder = row[0]; + phenotypeClass = row[1]; + phenotypeId = row[2]; + inhMode = row[3]; + + puts("<tr>\n"); + + puts("<td>"); + if (disorder) + puts(disorder); + puts("</td>\n"); + + puts("<td>"); + if (phenotypeId && (!sameWord(phenotypeId, "-1"))) + printf("<a HREF=\"%s%s\" target=_blank>%s</a>", url, phenotypeId, phenotypeId); + puts("</td>\n"); + + puts("<td>"); + if (inhMode) + puts(inhMode); + puts("</td>"); + + puts("<td>"); + if (phenotypeClass && !sameWord(phenotypeClass, "-1")) + { + puts(phenotypeClass); + if (isdigit(phenotypeClass[0])) + { + int phenoClass = atoi(phenotypeClass); + char* descs[] = + { + "disease was positioned by mapping of the wild-type gene", + "disorder itself was mapped", + "molecular basis of the disease is known", + "disorder is a chromosome deletion of duplication syndrome" + }; + if (phenoClass>=1 && phenoClass<=4) + { + puts(" - "); + puts(descs[phenoClass-1]); + } + else + // just in case that they ever add another class in the future + puts(phenotypeClass); + } + } + puts("</td>"); + + puts("</tr>"); + } + +sqlFreeResult(&sr); +printf("<tbody>\n"); +printf("</table>\n"); +} + void printOmimGene2Details(struct trackDb *tdb, char *itemName, boolean encode) /* Print details of an omimGene2 entry. */ { struct sqlConnection *conn = hAllocConn(database); char query[256]; struct sqlResult *sr; char **row; char *url = tdb->url; char *title1 = NULL; char *geneSymbol = NULL; char *chrom, *chromStart, *chromEnd; chrom = cartOptionalString(cart, "c"); chromStart = cartOptionalString(cart, "o"); chromEnd = cartOptionalString(cart, "t"); +printf("<div id='omimText'>"); if (url != NULL && url[0] != 0) { - printf("<B>OMIM: "); + printf("<B>MIM gene number: "); printf("<A HREF=\"%s%s\" target=_blank>", url, itemName); printf("%s</A></B>", itemName); sqlSafef(query, sizeof(query), "select geneName from omimGeneMap2 where omimId=%s;", itemName); sr = sqlMustGetResult(conn, query); row = sqlNextRow(sr); if (row != NULL) { if (row[0] != NULL) { title1 = cloneString(row[0]); printf(" %s", title1); } } else { printf("<BR>"); } sqlFreeResult(&sr); // disable NCBI link until they work it out with OMIM /* printf("<BR>\n"); printf("<B>OMIM page at NCBI: "); printf("<A HREF=\"%s%s\" target=_blank>", ncbiOmimUrl, itemName); printf("%s</A></B>", itemName); */ + // can use NOSQLINJ since itemName has already been checked to be a number + struct dyString *symQuery = newDyString(1024); + sqlDyStringPrintf(symQuery, "SELECT approvedSymbol from omimGeneMap2 where omimId=%s", itemName); + char *approvSym = sqlQuickString(conn, symQuery->string); + if (approvSym) { + printf("<BR><B>HGNC-approved symbol:</B> %s<BR>", approvSym); + freez(&approvSym); + } + printPosOnChrom(chrom, atoi(chromStart), atoi(chromEnd), NULL, FALSE, itemName); + sqlSafef(query, sizeof(query), "select geneSymbol from omimGeneMap2 where omimId=%s;", itemName); sr = sqlMustGetResult(conn, query); row = sqlNextRow(sr); if (row != NULL) { geneSymbol = cloneString(row[0]); } sqlFreeResult(&sr); if (geneSymbol!= NULL) { - boolean disorderShown; - char *phenotypeClass, *phenotypeId, *disorder; - - printf("<BR><B>Gene symbol(s):</B> %s", geneSymbol); - printf("<BR>\n"); - - /* display disorder(s) */ - sqlSafef(query, sizeof(query), - "select description, %s, phenotypeId from omimPhenotype where omimId=%s order by description", - omimPhenotypeClassColName, itemName); - sr = sqlMustGetResult(conn, query); - disorderShown = FALSE; - while ((row = sqlNextRow(sr)) != NULL) - { - if (!disorderShown) - { - printf("<B>Disorder(s):</B><UL>\n"); - disorderShown = TRUE; - } - disorder = row[0]; - phenotypeClass = row[1]; - phenotypeId = row[2]; - printf("<LI>%s", disorder); - if (phenotypeId != NULL) - { - if (!sameWord(phenotypeId, "-1")) - { - printf(" (phenotype <A HREF=\"%s%s\" target=_blank>", url, phenotypeId); - printf("%s</A></B>", phenotypeId); - // show phenotype class if available - if (!sameWord(phenotypeClass, "-1")) printf(" (%s)", phenotypeClass); - printf(")"); - } - else - { - // show phenotype class if available, even phenotypeId is not available - if (!sameWord(phenotypeClass, "-1")) printf(" (%s)", phenotypeClass); - } - - } + printf("<BR><B>Alternative symbols:</B> %s", geneSymbol); printf("<BR>\n"); } - if (disorderShown) printf("</UL>\n"); - sqlFreeResult(&sr); - } // show RefSeq Gene link(s) sqlSafef(query, sizeof(query), "select distinct locusLinkId from %s l, omim2gene g, refGene r where l.omimId=%s and g.geneId=l.locusLinkId and g.entryType='gene' and chrom='%s' and txStart = %s and txEnd= %s", refLinkTable, itemName, chrom, chromStart, chromEnd); sr = sqlMustGetResult(conn, query); row = sqlNextRow(sr); if (row != NULL) { char *geneId; geneId = strdup(row[0]); sqlFreeResult(&sr); sqlSafef(query, sizeof(query), "select distinct l.mrnaAcc from %s l where locusLinkId = '%s' order by mrnaAcc asc", refLinkTable, geneId); @@ -10709,62 +10767,62 @@ sqlFreeResult(&sr); } // show Related UCSC Gene links sqlSafef(query, sizeof(query), "select distinct kgId from kgXref x, %s l, omim2gene g where x.refseq = mrnaAcc and l.omimId=%s and g.omimId=l.omimId and g.entryType='gene'", refLinkTable, itemName); sr = sqlMustGetResult(conn, query); if (sr != NULL) { int printedCnt; printedCnt = 0; while ((row = sqlNextRow(sr)) != NULL) { if (printedCnt < 1) - printf("<B>Related UCSC Gene(s): </B>"); + printf("<B>Related Transcripts: </B>"); else printf(", "); printf("<A HREF=\"%s%s&hgg_chrom=none\">", "../cgi-bin/hgGene?hgg_gene=", row[0]); printf("%s</A></B>", row[0]); printedCnt++; } if (printedCnt >= 1) printf("<BR>\n"); } sqlFreeResult(&sr); // show GeneReviews link(s) if (sqlTableExists(conn, "geneReviewsDetail")) { sqlSafef(query, sizeof(query), "select distinct r.name2 from %s l, omim2gene g, refGene r where l.omimId=%s and g.geneId=l.locusLinkId and g.entryType='gene' and chrom='%s' and txStart = %s and txEnd= %s", refLinkTable, itemName, chrom, chromStart, chromEnd); sr = sqlMustGetResult(conn, query); if (sr != NULL) { while ((row = sqlNextRow(sr)) != NULL) { prGRShortRefGene(row[0]); } } sqlFreeResult(&sr); } + showOmimDisorderTable(conn, url, itemName); } -printf("<HR>"); -printPosOnChrom(chrom, atoi(chromStart), atoi(chromEnd), NULL, FALSE, itemName); +printf("</div>"); // #omimText } void printOmimLocationDetails(struct trackDb *tdb, char *itemName, boolean encode) /* Print details of an OMIM Class 3 Gene entry. */ { struct sqlConnection *conn = hAllocConn(database); struct sqlConnection *conn2 = hAllocConn(database); char query[256]; struct sqlResult *sr; char **row; char *url = tdb->url; char *kgId= NULL; char *title1 = NULL; char *geneSymbol = NULL; char *chrom, *chromStart, *chromEnd; @@ -11096,31 +11154,31 @@ printf("<hr>\n"); printPosOnChrom(chrom, atoi(chromStart), atoi(chromEnd), NULL, FALSE, itemName); } void doOmimAvSnp(struct trackDb *tdb, char *item) /* Put up OmimGene track info. */ { genericHeader(tdb, item); printOmimAvSnpDetails(tdb, item, FALSE); printTrackHtml(tdb); } void doOmimGene2(struct trackDb *tdb, char *item) /* Put up OmimGene track info. */ { -genericHeader(tdb, item); +cartWebStart(cart, database, "OMIM genes - %s", item); printOmimGene2Details(tdb, item, FALSE); printTrackHtml(tdb); } void doOmimGene(struct trackDb *tdb, char *item) /* Put up OmimGene track info. */ { genericHeader(tdb, item); printOmimGeneDetails(tdb, item, FALSE); printTrackHtml(tdb); } void printRgdSslpCustomUrl(struct trackDb *tdb, char *itemName, boolean encode) /* Print RGD QTL URL. */ {