src/hg/lib/pgSnp.c 1.8

1.8 2010/03/08 17:45:41 giardine
Adding phenotype tables for pgSnp track hgc clicks
Index: src/hg/lib/pgSnp.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/pgSnp.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -b -B -U 4 -r1.7 -r1.8
--- src/hg/lib/pgSnp.c	22 Jan 2010 23:44:59 -0000	1.7
+++ src/hg/lib/pgSnp.c	8 Mar 2010 17:45:41 -0000	1.8
@@ -8,8 +8,9 @@
 #include "jksql.h"
 #include "pgSnp.h"
 #include "hdb.h"
 #include "dnaseq.h"
+#include "pgPhenoAssoc.h"
 
 static char const rcsid[] = "$Id$";
 
 void pgSnpStaticLoad(char **row, struct pgSnp *ret)
@@ -588,4 +589,37 @@
     printf("<tr><td>hydropathy</td><td>%1.1f</td><td>%1.1f</td></tr></table>\n", hyd1, hyd2);
 printf("<br>");
 }
 
+void printPgDbLink(char *db, struct trackDb *tdb, struct pgSnp *item)
+/* print the links to phenotype and other databases for pgSnps */
+{
+struct pgPhenoAssoc *el;
+struct sqlResult *sr;
+char **row;
+char query[512];
+struct sqlConnection *conn = hAllocConn(db);
+char *dbList[8];
+int tot = 0, i = 0, first = 1;
+char *tabs = trackDbSetting(tdb, "pgDbLink");
+if (tabs == NULL)
+    return;
+tot = chopByWhite(tabs, dbList, ArraySize(dbList));
+for(i=0;i<tot;i++)
+    {
+    safef(query, sizeof(query), "select chrom, chromStart, chromEnd, name, srcUrl from %s where chrom = '%s' and chromStart = %d and chromEnd = %d",
+    dbList[i], item->chrom, item->chromStart, item->chromEnd);
+
+    sr = sqlGetResult(conn, query);
+    while ((row = sqlNextRow(sr)) != NULL)
+        {
+        if (first == 1)
+             {
+             printf("<br><b>Links to phenotype databases</b><br>\n");
+             first = 0;
+             }
+        el = pgPhenoAssocLoad(row);
+        printf("<a href=\"%s\">%s</a></br>\n", el->srcUrl, el->name);
+        }
+    }
+}
+