Index: src/hg/instinct/hgDetails/hgDetails.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/instinct/hgDetails/hgDetails.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -b -B -U 1000000 -r1.3 -r1.4
--- src/hg/instinct/hgDetails/hgDetails.c	11 Apr 2010 01:50:30 -0000	1.3
+++ src/hg/instinct/hgDetails/hgDetails.c	11 Apr 2010 01:54:43 -0000	1.4
@@ -1,266 +1,266 @@
 /* hgDetails - details page for hgHeatmap datasets details page. */
 #include "common.h"
 #include "linefile.h"
 #include "hash.h"
 #include "options.h"
 #include "jksql.h"
 #include "hdb.h"
 #include "htmshell.h"
 #include "web.h"
 #include "cheapcgi.h"
 #include "cart.h"
 #include "hgHeatmapLib.h"
 #include "raDb.h"
 #include "hui.h"
 
 static char const rcsid[] = "$Id$";
 
 char *database;
 /* Global Variables */
 struct cart *cart;             /* CGI and other variables */
 struct hash *oldVars = NULL;
 
 char *localDbProfile = "localDb";
 #define hgDetailsPrefix "hgd_"
 #define hgDetailsName hgDetailsPrefix "name"
 
 void cgbTopBar()
 {
 puts("<!-- Top bar -->");
 puts("<TR><TD COLSPAN=2 HEIGHT=40><!-- This file generates the top menu bar on "
      "Genome Browser home page-->");
 puts("<!-- which has a different menu from the other static pages------------>");
 puts(" <TABLE BGCOLOR=\"000000\" CELLPADDING=\"1\" CELLSPACING=\"1\" "
      "WIDTH=\"100%\" HEIGHT=\"27\">");
 puts("  <TR BGCOLOR=\"2636D1\"><TD VALIGN=\"middle\">");
 puts("   <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=\"2636D1\" HEIGHT=\"24\">");
 puts("    <TR><TD VALIGN=\"middle\"><FONT COLOR=\"#89A1DE\">&nbsp;&nbsp;");
 puts("     <A HREF=\"../hgHeatmap\" class=\"topbar\">Cancer Genomics</A>&nbsp;&nbsp;-&nbsp;&nbsp;");
 puts("     <A HREF=\"hgGateway\" class=\"topbar\">Genomes</A>&nbsp;&nbsp;-&nbsp;&nbsp;");
 puts("     <A HREF=\"../cancerGenomics/help/userGuide/userGuide.html\" class=\"topbar\">Help</A>");
 puts("    </FONT></TD></TR>");
 puts("   </TABLE>");
 puts("  </TD></TR>");
 puts(" </TABLE>");
 puts("<!-- end topbar -->");
 puts("</TD></TR>");
 }
 
 void cgbSideBar()
 {
 puts("<!--Left Sidebar Menu----------------------------------------->");
 puts("<TR HEIGHT=\"100%\" VALIGN=\"top\">");
 puts("  <TD ROWSPAN=\"3\" VALIGN=\"top\" HEIGHT=\"100%\">");
 puts("  <!-- outer table is to align leftbar & content boxes at top of page -->");
 puts("   <TABLE WIDTH=\"100%\" BORDER=0 CELLPADDING=0 CELLSPACING=0>");
 puts("    <TR><TD><IMG SRC=\"../images/DOT.gif\" ALT="" HEIGHT=\"7\"></TD></TR>");
 puts("     <TR HEIGHT=\"100%\"><TD HEIGHT=\"100%\">");
 puts("     <!--outer table is for black border-->");
 puts("      <TABLE WIDTH=\"100%\" BGCOLOR=\"#000000\" BORDER=\"0\" "
      " CELLSPACING=\"0\" CELLPADDING=\"1\">");
 puts("       <TR><TD>");
 puts("       <TABLE WIDTH=\"100%\" BORDER=0 CELLSPACING=\"0\" CELLPADDING=10>");
 puts("        <TR HEIGHT=\"100%\">");
 puts("          <TD BGCOLOR=\"738ED3\" VALIGN=\"top\" HEIGHT=\"100%\" >");
 puts("            <A CLASS=\"leftbar\" HREF=\"../hgHeatmap\">Cancer Genomics Browser</A><HR>");
 puts("            <A CLASS=\"leftbar\" HREF=\"hgMicroscope\">Tumor Images</A><HR>");
 puts("            <A CLASS=\"leftbar\" HREF=\"../index.html.org\">Genome Browser</A><HR>");
 puts("            <A CLASS=\"leftbar\" HREF=\"../cancerGenomics/credits.html\">Credits</A><HR>");
 puts("            <A CLASS=\"leftbar\" HREF=\"../cancerGenomics/staff.cancerGenomics.html\">About Us</A><HR>");
 puts("            <A CLASS=\"leftbar\" HREF=\"mailto:genome-cancer@soe.ucsc.edu\">Contact Us</A><HR>");
 puts("           <BR>");
 puts("           <IMG SRC=\"../images/DOT.gif\" ALT=\"\" HEIGHT=700 WIDTH=1>");
 puts("          </TD></TR></TABLE>");
 puts("        </TD></TR></TABLE>");
 puts("     </TD></TR></TABLE>");
 puts("</TD>");
 }
 
 void cgbHeader(char *title)
 {
 puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
 puts("<HTML>" "\n"
      "<HEAD>");
 puts("\t<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;CHARSET=iso-8859-1\">");
 printf("\t<META name=\"description\" content=\"%s\">\n", title);
 printf("\t<TITLE>%s</TITLE>\n", title);
 puts("\t<LINK REL=\"STYLESHEET\" HREF=\"../style/HGStyle.css\">");
 puts("</HEAD>");
 puts("");
 puts("<BODY BGCOLOR=\"FFF9D2\" LINK=\"0000CC\" VLINK=\"#330066\" ALINK=\"#6600FF\">"
      "<A NAME=\"TOP\"></A>");
 puts("");
 puts("<!-- Header Images and links -->");
 puts("\t<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100%\">");
 puts("\t<TR>");
 puts("\t  <TH COLSPAN=2 ALIGN=\"left\">");
 /* switch with titleCancerGenomics.su2c.jpg if on SU2C server */
 puts("\t    <IMG SRC=\"../cancerGenomics/images/titleCancerGenomics.jpg\"" 
      "ALT=\"Cancer Genomics Browser\">");
 puts("\t  </TH>" "\n"
      "\t</TR>");
 
 cgbTopBar();
 }
 
 void cgbSectionStart(char *title)
 {
 puts("<!--Content Table------------------------------------------------------->");
 puts("<TR><TD COLSPAN=2 CELLPADDING=10>");
 puts("<!--outer table is for border purposes-->");
 puts("  <TABLE WIDTH=\"100%\" BGCOLOR=\"#888888\" BORDER=\"0\""
      " CELLSPACING=\"0\" CELLPADDING=\"1\">");
 puts("   <TR><TD>");
 puts("    <TABLE BGCOLOR=\"fffee8\" WIDTH=\"100%\"  BORDER=\"0\""
      " CELLSPACING=\"0\" CELLPADDING=\"0\">");
 puts("    <TR><TD>");
 puts("      <TABLE BGCOLOR=\"D9E4F8\" BACKGROUND=\"../images/hr.gif\" WIDTH=100%>");
 puts("        <TR><TD>");
 printf("       <FONT SIZE=\"4\"><b>&nbsp;   %s</FONT>", title);
 puts("        </TD></TR>");
 puts("      </TABLE>");
 puts("      <TABLE BGCOLOR=\"fffee8\" WIDTH=\"100%\" CELLPADDING=0>");
 puts("        <TR><TH HEIGHT=10></TH></TR>");
 puts("        <TR><TD WIDTH=10>&nbsp;</TD><TD>");
 }
 
 void cgbSectionEnd()
 {
 puts("	      </TD><TD WIDTH=15></TD></TR>");
 puts("	    </TABLE>");
 puts("     <BR></TD></TR>");
 puts("    </TABLE>");
 puts("   </TD></TR>");
 puts("  </TABLE>");
 puts("</TD></TR>");
 }
 
 void cgbFooter()
 {
 puts("</TABLE>");
 puts( "</BODY></HTML>");
 }
 
 void emptyPage()
 {
 cgbHeader("Dataset Details: N/A");
 cgbSectionStart("Dataset Details: N/A");
 printf("Please specify variable '%s'.", hgDetailsName);
 cgbSectionEnd();
 cgbFooter();
 }
 
 char *getClinicalFields(struct raDb *ra)
 {
 struct hash *raHash, *raHashList = readRa(ra->raFile);
 
 struct slName *sl, *slList = NULL;
 for (raHash = raHashList; raHash; raHash = raHash->next)
     {
     char *name = hashMustFindVal(raHash, "longLabel");
     slNameAddHead(&slList, name);
     }
 slNameSort(&slList);
 
 struct dyString *dy = newDyString(1000);
 for (sl = slList; sl; sl = sl->next)
     {
     dyStringPrintf(dy, "%s", sl->name);
     if (sl->next)
 	dyStringPrintf(dy, "<BR>");
     }
 return dyStringCannibalize(&dy);
 }
 
 void cgbDetails(struct raDb *ra)
 {
 char title[512];
 safef(title, sizeof(title), "Dataset Details: %s", ra->longLabel);
 cgbHeader(title);
 cgbSectionStart(title);
 
-puts("<TABLE WIDTH=\"100%\"  BORDER=\"0\">");
+puts("<TABLE WIDTH=\"100%\"  BORDER=\"0\" CELLPADDING = \"3\">");
 
 /* Print out info in a table */
 printf("<TR VALIGN=\"TOP\"><TD><B>Name:</B></TD><TD>%s</TD></TR>\n", ra->longLabel);
 if (ra->article_title)
     printf("<TR VALIGN=\"TOP\"><TD><B>Title:</B></TD><TD><FONT SIZE=\"4\"><I>%s</I></FONT></TD></TR>\n", ra->article_title);
 if (ra->author_list)
     printf("<TR VALIGN=\"TOP\"><TD><B>Authors:</B></TD><TD>%s</TD></TR>\n", ra->author_list);
 if (ra->citation)
     printf("<TR VALIGN=\"TOP\"><TD><B>Citation:</B></TD><TD>%s</TD></TR>\n", ra->citation);
 if (ra->url)
     {
     printf("<TR VALIGN=\"TOP\"><TD><B>URL:</B></TD>");
     printf("<TD><A HREF = \"%s\">%s</A></TD></TR>\n", ra->url, ra->url);
     }
 if (ra->expCount)
     printf("<TR VALIGN=\"TOP\"><TD><B># Samples:</B></TD><TD>%u</TD></TR>\n", *(ra->expCount));
 if (ra->groupName)
     printf("<TR VALIGN=\"TOP\"><TD><B>In group:</B></TD><TD>%s</TD></TR>\n", ra->groupName);
 if (ra->wrangler)
     printf("<TR VALIGN=\"TOP\"><TD><B>Wrangled by:</B></TD><TD>%s</TD></TR>\n", ra->wrangler);
 if (ra->wrangling_procedure)
     printf("<TR VALIGN=\"TOP\"><TD><B>Wrangling Procedure:</B></TD><TD>%s</TD></TR>\n", ra->wrangling_procedure);
 
 char *clinicalFields = getClinicalFields(ra);
 if (clinicalFields)
     printf("<TR VALIGN=\"TOP\"><TD><B>Clinical Fields:</B></TD><TD><FONT SIZE=\"2\">%s</FONT></TD></TR>\n", clinicalFields);
 
 puts("</TABLE>");
 
 cgbSectionEnd();
 cgbFooter();
 }
 void detailsPage(char *name)
 {
 char *nameEscaped = sqlEscapeString(name);
 char query[512];
 
 char *raDbName = raDbPath();
 
 struct sqlConnection *conn = hAllocConnProfile(localDbProfile, database);
 safef(query, sizeof(query), "select * from %s where name = '%s';", raDbName, nameEscaped);
 struct raDb *ra = raDbLoadByQuery(conn, query);
 hFreeConn(&conn);
 
 if (!ra)
     {
     cgbHeader("Dataset Details: N/A");
     cgbSectionStart("Dataset Details: N/A");
     printf("Dataset by name '%s' does not exist in database.\n", nameEscaped);
     cgbSectionEnd();
     cgbFooter();
     return;
     }
 
 cgbDetails(ra);
 
 }
 
 void doMiddle(struct cart *theCart)
 /* Set up globals and make web page */
 {
 cart = theCart;
 database = cloneString("hg18");
 
 char *name = cartOptionalString(cart, hgDetailsName);
 if (!name)
     emptyPage();
 else
     detailsPage(name);
 
 cartRemovePrefix(cart, hgDetailsPrefix);
 }
 
 /* Null terminated list of CGI Variables we don't want to save
  * permanently. */
 char *excludeVars[] = {"Submit", "submit", NULL,};
 
 int main(int argc, char *argv[])
 /* Process command line. */
 {
 cgiSpoof(&argc, argv);
 cartEmptyShell(doMiddle, hUserCookie(), excludeVars, oldVars);
 return 0;
 }

