9a6b3e5b58d0c68eb152319bebf7339f24f42ed7 max Mon Dec 7 14:55:54 2015 -0800 adding malacards section to hgGene, refs #14417 diff --git src/hg/hgGene/malacards.c src/hg/hgGene/malacards.c new file mode 100644 index 0000000..995c144 --- /dev/null +++ src/hg/hgGene/malacards.c @@ -0,0 +1,84 @@ +/* malacards - do malacards section. parts copied from gad.c */ + +/* Copyright (C) 2013 The Regents of the University of California + * See README in this or parent directory for licensing information. */ + +#include "common.h" +#include "hash.h" +#include "linefile.h" +#include "dystring.h" +#include "cheapcgi.h" +#include "spDb.h" +#include "hgGene.h" +#include "hdb.h" +#include "net.h" + +static boolean malacardsExists(struct section *section, + struct sqlConnection *conn, char *geneId) +/* Return TRUE if malacards table exists and it has an entry with the gene symbol */ +{ +char query[1024]; +char *geneSymbol; + +if (sqlTableExists(conn, "malacards") == TRUE) + { + sqlSafef(query, sizeof(query), "select k.geneSymbol from kgXref k, malacards m" + " where k.kgId='%s' and k.geneSymbol = m.geneSymbol", geneId); + geneSymbol = sqlQuickString(conn, query); + if (geneSymbol != NULL) return(TRUE); + } +return(FALSE); +} +static void malacardsPrint(struct section *section, + struct sqlConnection *conn, char *geneId) +/* Print out malacards section. */ +{ +char query[1024]; +struct sqlResult *sr; +char **row; +char *itemName; + +sqlSafef(query, sizeof(query), "select k.geneSymbol from kgXref k, malacards m" + " where k.kgId='%s' and k.geneSymbol = m.geneSymbol", geneId); +itemName = sqlQuickString(conn, query); + +printf("<B>Malacards Gene Search: "); +printf("<A HREF='http://www.malacards.org/search/eliteGene/%s' target=_blank>", itemName); +printf("%s</B></A>\n", itemName); + +/* List diseases associated with the gene */ +sqlSafef(query, sizeof(query), +"select maladySymbol, urlSuffix, mainName, round(score) from malacards where geneSymbol='%s' order by score desc", +itemName); +sr = sqlMustGetResult(conn, query); +row = sqlNextRow(sr); + +if (row != NULL) + printf("<BR><B>Diseases sorted by score: </B>"); + +while (row != NULL) + { + char *maladySym = row[0]; + char *mainName = row[2]; + char *score = row[3]; + printf("<A HREF='http://www.malacards.org/card/%s' target=_blank>%s</a> (%s)", maladySym, mainName, score); + row = sqlNextRow(sr); + if (row!=NULL) + printf(", "); + } +sqlFreeResult(&sr); +} + +struct section *malacardsSection(struct sqlConnection *conn, + struct hash *sectionRa) +/* Create malacards section. */ +{ +struct section *section = sectionNew(sectionRa, "malacards"); +section->exists = malacardsExists; +section->print = malacardsPrint; +return section; +} + + + +