a3de0378c0ef6ffff6fd40e77407b2b8b80b5573
kate
Wed Jul 5 12:00:34 2017 -0700
Allow bin field for speedup. refs #15646
diff --git src/hg/hgc/gtexEqtlClusterClick.c src/hg/hgc/gtexEqtlClusterClick.c
index e5fb972..8af729c 100644
--- src/hg/hgc/gtexEqtlClusterClick.c
+++ src/hg/hgc/gtexEqtlClusterClick.c
@@ -1,57 +1,66 @@
/* Details page for GTEx eQTL Clusters */
/* Copyright (C) 2017 The Regents of the University of California
* See README in this or parent directory for licensing information. */
#include "common.h"
#include "hCommon.h"
#include "web.h"
#include "gtexTissue.h"
#include "gtexInfo.h"
#include "gtexEqtlCluster.h"
#include "hgc.h"
-static struct gtexEqtlCluster *getGtexEqtl(char *item, char *chrom, int start, char *table)
+static struct gtexEqtlCluster *getGtexEqtl(char *item, char *chrom, int start, int end, char *table)
/* Retrieve this item from the track table */
{
char *gene = firstWordInLine(cloneString(item));
struct sqlConnection *conn = hAllocConn(database);
-char query[512];
-sqlSafef(query, sizeof(query), "SELECT * FROM %s WHERE chrom='%s' AND chromStart=%d AND target='%s'",
- table, chrom, start, gene);
-struct gtexEqtlCluster *eqtl = gtexEqtlClusterLoadByQuery(conn, query);
+struct gtexEqtlCluster *eqtls = NULL, *eqtl;
+char **row;
+int offset;
+char where[512];
+sqlSafefFrag(where, sizeof(where), "target='%s'", gene);
+struct sqlResult *sr = hRangeQuery(conn, table, chrom, start, end, where, &offset);
+while ((row = sqlNextRow(sr)) != NULL)
+ {
+ eqtl = gtexEqtlClusterLoad(row+offset);
+ slAddHead(&eqtls, eqtl);
+ }
+slReverse(&eqtls);
+sqlFreeResult(&sr);
hFreeConn(&conn);
-return eqtl;
+return eqtls;
}
static char *getGeneDescription(struct sqlConnection *conn, char *geneName)
/* Return description from KnownGenes track */
{
char query[256];
sqlSafef(query, sizeof query,
"SELECT kgXref.description FROM kgXref WHERE geneSymbol='%s'", geneName);
return sqlQuickString(conn, query);
}
void doGtexEqtlDetails(struct trackDb *tdb, char *item)
/* Details of GTEx eQTL item */
{
char *chrom = cartString(cart, "c");
int start = cartInt(cart, "o");
-int end;
-struct gtexEqtlCluster *eqtl = getGtexEqtl(item, chrom, start, tdb->table);
+int end = cartInt(cart, "t");
+struct gtexEqtlCluster *eqtl = getGtexEqtl(item, chrom, start, end, tdb->table);
genericHeader(tdb, item);
char *version = gtexVersion(tdb->table);
struct gtexTissue *tissues = gtexGetTissues(version);
struct hash *tissueHash = hashNew(0);
struct gtexTissue *tis = NULL;
for (tis = tissues; tis != NULL; tis = tis->next)
hashAdd(tissueHash, tis->name, tis);
int i;
struct sqlConnection *conn = hAllocConn(database);
char *geneName = eqtl->target;
char *desc = getGeneDescription(conn, geneName);
printf("Gene: ");
if (desc == NULL)
printf("%s
\n", geneName);