36d2f2ca7e1864bf11c8aba2e329ea7c2549a25c
chinhli
  Fri Sep 30 11:00:06 2011 -0700
put back logic to handle geneReviews track using the geneReviews table in the database
diff --git src/hg/hgc/hgc.c src/hg/hgc/hgc.c
index 97cd8ff..fb90992 100644
--- src/hg/hgc/hgc.c
+++ src/hg/hgc/hgc.c
@@ -23833,30 +23833,94 @@
         printf("<A HREF=\"%s&db=%s&position=%s%%3A%d-%d\">browser</A> | ",
                hgTracksPathAndSettings(), database,
                bed->chrom, bed->chromStart+1, bed->chromEnd);
 
         printf("%-20s %-10s %9d  %9d    %5d    %5d    %1s",
             bed->name, bed->chrom, bed->chromStart+1, bed->chromEnd,
             (bed->chromEnd - bed->chromStart),bed->score, bed->strand);
 
         printf("</TT></PRE>");
         }
 
  printf("<BR>");
  printTrackHtml(tdb);
  hFreeConn(&conn);
 }
+void doGeneReviews(struct trackDb *tdb, char *itemName)
+/* generate the detail page for geneReviews */
+{
+struct sqlConnection *conn = hAllocConn(database);
+//char *table = tdb->table;
+int start = cartInt(cart, "o");
+int num = 4;
+
+ genericHeader(tdb, itemName);
+ genericBedClick(conn, tdb, itemName, start, num);
+ prGeneReviews(conn, itemName);
+ printf("<BR>");
+ printTrackHtml(tdb);
+ hFreeConn(&conn);
+}
+
+void prGeneReviews(struct sqlConnection *conn, char *itemName)
+/* print GeneReviews associated to this item
+   Note: this print function has been replaced by addGeneReviewToBed.pl
+         which print the same information to the field 5 of bigBed file
+*/
+{
+struct sqlResult *sr;
+char **row;
+char query[512];
+int i;
+char *clickMsg = "Click link(s) below to search GeneReviews and GeneTests";
+boolean firstTime = TRUE;
+
+safef(query, sizeof(query), "select  grShort, diseaseID, diseaseName from geneReviewsRefGene where geneSymbol='%s'", itemName);
+sr = sqlGetResult(conn, query);
+while ((row = sqlNextRow(sr)) != NULL)
+    {
+        char *grShort = *row++;
+        char *diseaseID = *row++;
+        char *diseaseName = *row++;
+
+
+        if (firstTime)
+        {
+          printf("<BR><B> GeneReview(s) available for %s:</B> (%s)<BR>",itemName,clickMsg);
+          firstTime = FALSE;
+          printf("<PRE><TT>");
+              // #1234567890123456789012345678901234567890
+          printf("Short name    Disease ID     GeneTests disease name<BR>");
+          printf("-----------------------------------------------------------");
+          printf("-----------------------------------------------------------");
+          printf("----------------------------------<BR>");
+        }
+        printf("<A HREF=\"http://www.ncbi.nlm.nih.gov/books/n/gene/%s\" TARGET=_blank><B>%s</B></A>", grShort, grShort);
+        if (strlen(grShort) <= 15) {
+          for (i = 0; i <  15-strlen(grShort); i ++ )
+             {
+                printf("%s", " " );
+             }
+           }
+         printf("%-10s    ", diseaseID);
+        printf("<A HREF=\"http://www.ncbi.nlm.nih.gov/sites/GeneTests/review/disease/%s?db=genetests&search_param==begins_with\" TARGET=_blank><B>%s</B></A><BR>", diseaseName, diseaseName);
+
+    }  /* end while */
+ printf("</TT></PRE>");
+ //printf("<BR>");
+ sqlFreeResult(&sr);
+} /* end of prGeneReviews */
 
 void prGRShortRefGene(char *itemName)
 /* print GeneReviews short label associated to this refGene item */
 {
 struct sqlConnection *conn  = hAllocConn(database);
 struct sqlResult *sr;
 char **row;
 char query[512];
 boolean firstTime = TRUE;
 
 safef(query, sizeof(query), "select grShort, diseaseName from geneReviewsRefGene where geneSymbol='%s'", itemName);
 sr = sqlGetResult(conn, query);
 while ((row = sqlNextRow(sr)) != NULL)
     {
         char *grShort = *row++;
@@ -25088,30 +25152,34 @@
     {
     doT2gDetails(tdb, item);
     }
 else if (tdb != NULL && startsWith("bedDetail", tdb->type))
     {
     doBedDetail(tdb, NULL, item);
     }
 else if (startsWith("numtS", table))
     {
     doNumtS(tdb, item);
     }
 else if (startsWith("cosmic", table))
     {
     doCosmic(tdb, item);
     }
+else if (sameString("geneReviews", table))
+    {
+    doGeneReviews(tdb, item);
+    }
 else if (tdb != NULL)
     {
     genericClickHandler(tdb, item, NULL);
     }
 else
     {
     cartWebStart(cart, database, "%s", track);
     printf("Sorry, clicking there doesn't do anything yet (%s).", track);
     }
 /* End of 1000+ line dispatch on table involving 100+ if/elses. */
 
 if (didCartHtmlStart)
     cartHtmlEnd();
 }