1b61c1a44e329fd4dc821d9a52a209bbc5fc9775
galt
Mon Jul 1 16:49:12 2013 -0700
simplifying sql abuses of sqlGetField
diff --git src/hg/hgGene/gad.c src/hg/hgGene/gad.c
index 55d03c6..e349285 100644
--- src/hg/hgGene/gad.c
+++ src/hg/hgGene/gad.c
@@ -1,156 +1,160 @@
/* gad - do GAD section. */
#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 gadExists(struct section *section,
struct sqlConnection *conn, char *geneId)
/* Return TRUE if gadAll table exists and it has an entry with the gene symbol */
{
-char condStr[255];
+char query[1024];
char *geneSymbol;
if (sqlTableExists(conn, "gadAll") == TRUE)
{
+ sqlSafef(query, sizeof(query), "select k.geneSymbol from kgXref k, gadAll g"
+ " where k.kgId='%s' and k.geneSymbol = g.geneSymbol", geneId);
+ geneSymbol = sqlQuickString(conn, query);
+ if (geneSymbol != NULL) return(TRUE);
+/*
sqlSafefFrag(condStr, sizeof(condStr),
"k.kgId='%s' and k.geneSymbol = g.geneSymbol", geneId);
geneSymbol = sqlGetField(database, "kgXref k, gadAll g", "k.geneSymbol", condStr);
- if (geneSymbol != NULL) return(TRUE);
+*/
}
return(FALSE);
}
static void gadPrint(struct section *section,
struct sqlConnection *conn, char *geneId)
/* Print out GAD section. */
{
int refPrinted = 0;
boolean showCompleteGadList;
-char condStr[256];
-char query[256];
+char query[1024];
struct sqlResult *sr;
char **row;
struct dyString *currentCgiUrl;
char *upperDisease;
char *url =
cloneString("http://geneticassociationdb.nih.gov/cgi-bin/tableview.cgi?table=allview&cond=gene=");
char *itemName;
if (url != NULL && url[0] != 0)
{
- sqlSafefFrag(condStr, sizeof(condStr),
- "k.kgId='%s' and k.geneSymbol = g.geneSymbol", geneId);
- itemName = sqlGetField(database, "kgXref k, gadAll g", "k.geneSymbol", condStr);
+ sqlSafef(query, sizeof(query), "select k.geneSymbol from kgXref k, gadAll g"
+ " where k.kgId='%s' and k.geneSymbol = g.geneSymbol", geneId);
+ itemName = sqlQuickString(conn, query);
showCompleteGadList = FALSE;
if (cgiOptionalString("showAllRef") != NULL)
{
if (sameWord(cgiOptionalString("showAllRef"), "Y") ||
sameWord(cgiOptionalString("showAllRef"), "y") )
{
showCompleteGadList = TRUE;
}
}
currentCgiUrl = cgiUrlString();
printf("Genetic Association Database: ");
printf("", url, itemName);
printf("%s\n", itemName);
printf("
CDC HuGE Published Literature: ");
printf("",
"http://hugenavigator.net/HuGENavigator/searchSummary.do?firstQuery=",
itemName,
"&publitSearchType=now&whichContinue=firststart&check=n&dbType=publit&Mysubmit=go");
printf("%s\n", itemName);
/* List diseases associated with the gene */
sqlSafef(query, sizeof(query),
"select distinct broadPhen from gadAll where geneSymbol='%s' and association = 'Y' order by broadPhen",
itemName);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
{
upperDisease = replaceChars(row[0], "'", "''");
touppers(upperDisease);
printf("
Positive Disease Associations: ");
printf("",
"http://geneticassociationdb.nih.gov/cgi-bin/tableview.cgi?table=allview&cond=upper(DISEASE)%20like%20'%25",
cgiEncode(upperDisease), "%25'%20AND%20upper(GENE)%20%20like%20'%25", itemName, "%25'");
printf("%s\n", row[0]);
row = sqlNextRow(sr);
}
while (row != NULL)
{
upperDisease = replaceChars(row[0], "'", "''");
touppers(upperDisease);
printf(", ",
"http://geneticassociationdb.nih.gov/cgi-bin/tableview.cgi?table=allview&cond=upper(DISEASE)%20like%20'%25",
cgiEncode(upperDisease), "%25'%20AND%20upper(GENE)%20%20like%20'%25", itemName, "%25'");
printf("%s\n", row[0]);
row = sqlNextRow(sr);
}
sqlFreeResult(&sr);
refPrinted = 0;
sqlSafef(query, sizeof(query),
"select broadPhen,reference,title,journal, pubMed, conclusion from gadAll where geneSymbol='%s' and association = 'Y' order by broadPhen",
itemName);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL) printf("
Related Studies: