0716e4729afd2fe9750321279fe0ef6765bf01de
chinhli
Tue Aug 16 13:17:16 2011 -0700
Finished GeneReviews for UCSC knownGenes (hg19)
diff --git src/hg/hgGene/geneReviews.c src/hg/hgGene/geneReviews.c
index 06d0acb..0bdbbb0 100644
--- src/hg/hgGene/geneReviews.c
+++ src/hg/hgGene/geneReviews.c
@@ -1,53 +1,86 @@
/* GeneReviews - print out GeneReviews for this gene. */
#include "common.h"
#include "hash.h"
#include "hdb.h"
#include "linefile.h"
#include "dystring.h"
#include "hgGene.h"
static void geneReviewsPrint(struct section *section,
struct sqlConnection *conn, char *itemName)
/* print GeneReviews short label associated to this refGene item */
{
+char query[256];
+char * geneSymbol;
if (sqlTablesExist(conn, "geneReviews"))
{
- hPrintf("Printing geneReviews for %s
", itemName );
+ safef(query, sizeof(query), "select geneSymbol from kgXref where kgId = '%s'", itemName);
+ geneSymbol = sqlQuickString(conn, query);
+ if (geneSymbol != NULL)
+ {
+ prGRShortKg(conn,geneSymbol);
} else {
- hPrintf("geneReviews table not found
" );
+ hPrintf("No GeneReviews for this gene
" );
+ }
+ }
}
-/*******************************************************************
+
+void prGRShortKg(struct sqlConnection *conn, char *itemName)
+/* print GeneReviews short label associated to this refGene item */
+{
+
struct sqlResult *sr;
char **row;
char query[512];
boolean firstTime = TRUE;
-safef(query, sizeof(query), "select grShort from geneReviewsRefGene where geneSymbol='%s'", itemName);
+safef(query, sizeof(query), "select geneSymbol, grShort, diseaseID, diseaseName from geneReviewsRefGene where geneSymbol='%s'", itemName);
sr = sqlGetResult(conn, query);
while ((row = sqlNextRow(sr)) != NULL)
{
- char *grShort = *row++;
if (firstTime)
{
- printf(" GeneReview: ");
+ printf(" Gene Symbol: %s
", row[0]);
firstTime = FALSE;
- printf("%s", grShort, grShort);
- } else {
- printf(", ");
- printf("%s", grShort, grShort);
}
+ printf("%s:",row[1], row[1]);
+ printf(" %s (Id: %s)
", row[3], row[2]);
}
- printf("
");
-**********************************************************/
}
+static boolean geneReviewsExists(struct section *section,
+ struct sqlConnection *conn, char *geneId)
+/* Return TRUE if geneReviews table exist and have GeneReviews articles
+ * on this one. */
+{
+char query[256];
+char * geneSymbol;
+char * grSymbol;
+
+if (sqlTablesExist(conn, "geneReviews"))
+ {
+ safef(query, sizeof(query), "select geneSymbol from kgXref where kgId = '%s'", geneId);
+ geneSymbol = sqlQuickString(conn, query);
+ if (geneSymbol != NULL)
+ {
+ safef(query, sizeof(query), "select geneSymbol from geneReviewsRefGene where geneSymbol='%s'", geneSymbol);
+ grSymbol = sqlQuickString(conn, query);
+ if (grSymbol != NULL)
+ {
+ return TRUE;
+ }
+ }
+ }
+return FALSE;
+}
struct section *geneReviewsSection(struct sqlConnection *conn,
struct hash *sectionRa)
/* Create geneReviews (aka Other Names) section. */
{
struct section *section = sectionNew(sectionRa, "geneReviews");
+section->exists = geneReviewsExists;
section->print = geneReviewsPrint;
return section;
}