114bd9cc108feeb8b20ad0b98b35454ea3fde8e0
kate
  Mon May 2 11:45:50 2016 -0700
Add details page info to show highest expressed tissue with scores. refs #17244

diff --git src/hg/lib/gtexInfo.c src/hg/lib/gtexInfo.c
index 951c626..7220b14 100644
--- src/hg/lib/gtexInfo.c
+++ src/hg/lib/gtexInfo.c
@@ -180,45 +180,47 @@
 sqlSafef(query, sizeof(query),
 "CREATE TABLE %s (\n"
 "    version varchar(255) not null,	# GTEX data release (e.g. V4, V6)\n"
 "    releaseDate varchar(255) not null,	# Release date\n"
 "    maxScore double not null,	# Maximum score observed (use to scale display)\n"
 "    maxMedianScore double not null,	# Maximum score observed for a tissue median (use to scale display)\n"
 "        #Indices\n"
 "    PRIMARY KEY(version)\n"
 ")\n",   table);
 sqlRemakeTable(conn, table, query);
 }
 
 char *gtexVersionSuffix(char *table)
 /* Return version string for a GTEx track table.  For now, just supporting V4 and V6 (default, no suffix )*/                                        
 {
-if (endsWith(table, "V4"))
+if (table && endsWith(table, "V4"))
     return("V4");
 return("");
 }
 
 char *gtexVersion(char *table)
 /* Return version string based on table suffix. Default version tables have no suffix */
 {
 char *suffix = gtexVersionSuffix(table);
 return (sameString(suffix, "")) ? GTEX_DEFAULT_VERSION : suffix;
 }
 
 char *gtexVersionSuffixFromVersion(char *version)
 /* Return version table suffix for a version */
 {
+if (!version)
+    version = GTEX_DEFAULT_VERSION;
 return (sameString(version, GTEX_DEFAULT_VERSION)) ? "" : version;
 }
 
 double gtexMaxMedianScore(char *version)
 /* Retrieve max median score for latest (or named) version */
 {
 char query[1024];
 struct sqlConnection *conn = hAllocConn("hgFixed");
 if (!conn)
     return 0;
 // TODO: trackDB setting for this
 if (!version || sameString(version, ""))
     version = GTEX_DEFAULT_VERSION;
 sqlSafef(query, sizeof query, "select maxMedianScore from gtexInfo where version='%s'", version);
 double score = sqlQuickDouble(conn, query);